1313// / \author Paul Veen <paul.veen@cern.ch>
1414// / \author Chi Zhang <chi.zhang@cern.ch>
1515
16+ #include " Common/CCDB/EventSelectionParams.h"
17+ #include " Common/CCDB/RCTSelectionFlags.h"
1618#include " Common/DataModel/EventSelection.h"
1719
1820#include < CCDB/BasicCCDBManager.h>
@@ -83,6 +85,7 @@ using namespace o2::framework;
8385using namespace o2 ::framework::expressions;
8486
8587using MyEvents = soa::Join<aod::Collisions, aod::EvSels>;
88+ using MyBCs = soa::Join<aod::BCs, aod::Timestamps, aod::BcSels>;
8689using MyMuonsWithCov = soa::Join<aod::FwdTracks, aod::FwdTracksCov>;
8790using MyMFTs = aod::MFTTracks;
8891
@@ -185,6 +188,16 @@ struct muonQa {
185188 Configurable<bool > fEnableSingleMuonDiMuonCorrelations {" cfgEnableMuonDiMuonCorrelations" , false , " Enable muon-dimuon QA checks" };
186189 } configQAs;
187190
191+ // // Variables for selecting events
192+ struct : ConfigurableGroup {
193+ Configurable<bool > fEvSelRequireGoodRCT {" cfgEvSelRequireGoodRCT" , false , " Require good detector flags in Run Condition Table" };
194+ Configurable<bool > fEvSelRequireFrameBordersExclusion {" cfgEvSelRequireFrameBordersExclusion" , false , " Exclude events in the TF and ITS ROF borders" };
195+ Configurable<bool > fEvSelRequireNoCollInTimeRange {" cfgEvSelRequireNoCollInTimeRange" , false , " Exclude events with multiple collisions in time range (standard)" };
196+ Configurable<bool > fEvSelRequireNoSameBunch {" cfgEvSelRequireNoSameBunch" , false , " Exclude events with multiple collisions in the same bunch crossing" };
197+ Configurable<float > fEvSelVtxZMin {" cfgEvSelVtxZMin" , -10 .0f , " Minimum accepted value for vertex z position" };
198+ Configurable<float > fEvSelVtxZMax {" cfgEvSelVtxZMax" , 10 .0f , " Maximum accepted value for vertex z position" };
199+ } configEvSel;
200+
188201 // // Variables for selecting muon tracks
189202 struct : ConfigurableGroup {
190203 Configurable<float > fPMchLow {" cfgPMchLow" , 0 .0f , " " };
@@ -214,6 +227,9 @@ struct muonQa {
214227 Configurable<float > fDimuonDCAMassLow {" cfgDimuonDCAMassLow" , 2 .8f , " " };
215228 Configurable<float > fDimuonDCAMassHigh {" cfgDimuonDCAMassHigh" , 3 .4f , " " };
216229
230+ // Magnetic field position bias
231+ Configurable<float > fFieldOriginBiasZ {" cfgFieldOriginBiasZ" , 0 .0f , " Bias applied to the magnetic field z position" };
232+
217233 // // Variables for alignment corrections
218234 Configurable<bool > fEnableMFTAlignmentCorrections {" cfgEnableMFTAlignmentCorrections" , false , " " };
219235
@@ -273,6 +289,8 @@ struct muonQa {
273289 o2::field::MagneticField* fieldB = nullptr ;
274290 double Bz; // Bz for MFT
275291
292+ o2::aod::rctsel::RCTFlagsChecker rctChecker{" CBT_muon_glo" , false , false , true };
293+
276294 geo::TransformationCreator transformation;
277295 std::map<int , math_utils::Transform3D> transformRef; // reference geometry w.r.t track data
278296 std::map<int , math_utils::Transform3D> transformNew; // new geometry
@@ -2345,7 +2363,8 @@ struct muonQa {
23452363 fgValues = {};
23462364 }
23472365
2348- void initCCDB (aod::BCsWithTimestamps const & bcs)
2366+ template <typename BC >
2367+ void initCCDB (BC const & bcs)
23492368 {
23502369 // Update CCDB informations
23512370 if (bcs.size () > 0 && fCurrentRun != bcs.begin ().runNumber ()) {
@@ -2407,6 +2426,9 @@ struct muonQa {
24072426 ccdb->setCaching (true );
24082427 ccdb->setLocalObjectValidityChecking ();
24092428
2429+ // configure magnetic field position bias
2430+ o2::conf::ConfigurableParam::setValue (" FieldOriginBias.z" , std::to_string (fFieldOriginBiasZ .value ));
2431+
24102432 // Configuration for track fitter
24112433 const auto & trackerParam = TrackerParam::Instance ();
24122434 trackFitter.setBendingVertexDispersion (trackerParam.bendingVertexDispersion );
@@ -2685,6 +2707,38 @@ struct muonQa {
26852707 {
26862708 for (auto const & collision : collisions) {
26872709
2710+ const auto & bc = bcs.rawIteratorAt (collision.bcId ());
2711+
2712+ if (configEvSel.fEvSelRequireFrameBordersExclusion ) {
2713+ // remove TF/ROF borders and ambiguous collisions
2714+ if (!bc.selection_bit (o2::aod::evsel::kNoTimeFrameBorder ) ||
2715+ !bc.selection_bit (o2::aod::evsel::kNoITSROFrameBorder )) {
2716+ continue ;
2717+ }
2718+ }
2719+
2720+ // remove events with multiple collisions in one bunch crossing
2721+ if (configEvSel.fEvSelRequireNoCollInTimeRange &&
2722+ !bc.selection_bit (o2::aod::evsel::kNoCollInTimeRangeStandard )) {
2723+ continue ;
2724+ }
2725+
2726+ // remove events with multiple collisions in one bunch crossing
2727+ if (configEvSel.fEvSelRequireNoSameBunch &&
2728+ !bc.selection_bit (o2::aod::evsel::kNoSameBunchPileup )) {
2729+ continue ;
2730+ }
2731+
2732+ // remove events with bad RCT flags
2733+ if (configEvSel.fEvSelRequireGoodRCT && !rctChecker (collision)) {
2734+ continue ;
2735+ }
2736+
2737+ if (collision.posZ () < configEvSel.fEvSelVtxZMin ||
2738+ collision.posZ () > configEvSel.fEvSelVtxZMax ) {
2739+ continue ;
2740+ }
2741+
26882742 uint64_t collisionIndex = collision.globalIndex ();
26892743 auto muonsThisCollision = muons.sliceBy (fwdtracksPerCollision, collisionIndex);
26902744 auto mftsThisCollision = mfts.sliceBy (mftPerCollision, collisionIndex);
@@ -2695,7 +2749,7 @@ struct muonQa {
26952749
26962750 auto & fgValuesColl = collisionSel[collisionIndex];
26972751 FillCollision (collision, fgValuesColl);
2698- fgValuesColl.bc = bcs. rawIteratorAt (collision. bcId ()) .globalBC ();
2752+ fgValuesColl.bc = bc .globalBC ();
26992753 fgValuesColl.multMFT = mftsThisCollision.size ();
27002754 }
27012755 }
@@ -2708,7 +2762,7 @@ struct muonQa {
27082762
27092763 // // Get collision information if associated
27102764 VarColl fgValuesColl;
2711- if (muon.has_collision ()) {
2765+ if (muon.has_collision () && collisions. contains (muon. collisionId ()) ) {
27122766 fgValuesColl = collisions.at (muon.collisionId ());
27132767 } else {
27142768 continue ;
@@ -2897,8 +2951,14 @@ struct muonQa {
28972951
28982952 for (const auto & [muon1, muon2] : muonPairs) {
28992953 auto collisionIndex1 = muon1.first ;
2954+ if (!collisions.contains (collisionIndex1)) {
2955+ continue ;
2956+ }
29002957 auto const & collision1 = collisions.at (collisionIndex1);
29012958 auto collisionIndex2 = muon2.first ;
2959+ if (!collisions.contains (collisionIndex2)) {
2960+ continue ;
2961+ }
29022962 auto const & collision2 = collisions.at (collisionIndex2);
29032963
29042964 auto mchIndex1 = muon1.second ;
@@ -3840,7 +3900,7 @@ struct muonQa {
38403900 }
38413901 }
38423902
3843- void processMuonQa (MyEvents const & collisions, aod::BCsWithTimestamps const & bcs, MyMuonsWithCov const & muontracks, MyMFTs const & mfttracks, aod::FwdTrkCls const & muonclusters)
3903+ void processMuonQa (MyEvents const & collisions, MyBCs const & bcs, MyMuonsWithCov const & muontracks, MyMFTs const & mfttracks, aod::FwdTrkCls const & muonclusters)
38443904 {
38453905 std::map<uint64_t , VarColl> collisionSel;
38463906 std::map<uint64_t , std::vector<uint64_t >> matchingCandidates;
0 commit comments