2020#include " PWGLF/Utils/inelGt.h"
2121
2222#include " Common/CCDB/EventSelectionParams.h"
23+ #include " Common/CCDB/RCTSelectionFlags.h"
2324#include " Common/DataModel/Centrality.h"
2425#include " Common/DataModel/EventSelection.h"
2526#include " Common/DataModel/Multiplicity.h"
4344
4445#include < TH1.h>
4546
47+ #include < string>
4648#include < utility>
4749#include < vector>
4850
4951using namespace o2 ;
5052using namespace o2 ::framework;
5153using namespace o2 ::framework::expressions;
54+ using namespace o2 ::aod::rctsel;
5255
5356void customize (std::vector<o2::framework::ConfigParamSpec>& workflowOptions)
5457{
@@ -61,6 +64,7 @@ void customize(std::vector<o2::framework::ConfigParamSpec>& workflowOptions)
6164using DauTracks = soa::Join<aod::Tracks, aod::TracksExtra, aod::TracksDCA, aod::pidTPCPi, aod::pidTPCKa, aod::pidTPCPr, aod::pidTOFPi, aod::pidTOFPr>;
6265using DauTracksMC = soa::Join<DauTracks, aod::McTrackLabels>;
6366using V0Collisions = soa::Join<aod::Collisions, aod::EvSels, aod::PVMults, aod::CentFT0Ms, aod::CentNGlobals>;
67+ using BCsWithBcSels = soa::Join<aod::BCsWithTimestamps, aod::BcSels>;
6468
6569struct LfV0qaanalysis {
6670
@@ -106,10 +110,12 @@ struct LfV0qaanalysis {
106110 registry.add (" hCentFT0M_GenRecoColl_MC_INELgt0" , " hCentFT0M_GenRecoColl_MC_INELgt0" , {HistType::kTH1F , {{1000 , 0 .f , 100 .f }}});
107111 registry.add (" hCentFT0M_GenColl_MC" , " hCentFT0M_GenColl_MC" , {HistType::kTH1F , {{1000 , 0 .f , 100 .f }}});
108112 registry.add (" hCentFT0M_GenColl_MC_INELgt0" , " hCentFT0M_GenColl_MC_INELgt0" , {HistType::kTH1F , {{1000 , 0 .f , 100 .f }}});
109- registry.add (" hNEventsMCGen" , " hNEventsMCGen" , {HistType::kTH1D , {{4 , 0 .f , 4 .f }}});
113+ registry.add (" hNEventsMCGen" , " hNEventsMCGen" , {HistType::kTH1D , {{5 , 0 .f , 5 .f }}});
110114 registry.get <TH1 >(HIST (" hNEventsMCGen" ))->GetXaxis ()->SetBinLabel (1 , " all" );
111115 registry.get <TH1 >(HIST (" hNEventsMCGen" ))->GetXaxis ()->SetBinLabel (2 , " zvertex_true" );
112- registry.get <TH1 >(HIST (" hNEventsMCGen" ))->GetXaxis ()->SetBinLabel (3 , " INELgt0_true" );
116+ registry.get <TH1 >(HIST (" hNEventsMCGen" ))->GetXaxis ()->SetBinLabel (3 , " BC TF/ITS ROF border" );
117+ registry.get <TH1 >(HIST (" hNEventsMCGen" ))->GetXaxis ()->SetBinLabel (4 , " RCTFlagsChecker" );
118+ registry.get <TH1 >(HIST (" hNEventsMCGen" ))->GetXaxis ()->SetBinLabel (5 , " INELgt0_true" );
113119 registry.add (" hNEventsMCGenReco" , " hNEventsMCGenReco" , {HistType::kTH1D , {{2 , 0 .f , 2 .f }}});
114120 registry.get <TH1 >(HIST (" hNEventsMCGenReco" ))->GetXaxis ()->SetBinLabel (1 , " INEL" );
115121 registry.get <TH1 >(HIST (" hNEventsMCGenReco" ))->GetXaxis ()->SetBinLabel (2 , " INELgt0" );
@@ -153,6 +159,7 @@ struct LfV0qaanalysis {
153159 registry.add (" Generated_MCGenColl_INELgt0_Lambda" , " Generated_MCGenColl_INELgt0_Lambda" , {HistType::kTH2F , {{250 , 0 .f , 25 .f }, {1000 , 0 .f , 100 .f }}});
154160 registry.add (" Generated_MCGenColl_INELgt0_AntiLambda" , " Generated_MCGenColl_INELgt0_AntiLambda" , {HistType::kTH2F , {{250 , 0 .f , 25 .f }, {1000 , 0 .f , 100 .f }}});
155161 }
162+ rctChecker.init (cfgEvtRCTFlagCheckerLabel, cfgEvtRCTFlagCheckerZDCCheck, cfgEvtRCTFlagCheckerLimitAcceptAsBad, applyRCTOnGen);
156163 registry.print ();
157164 }
158165
@@ -164,11 +171,18 @@ struct LfV0qaanalysis {
164171 Configurable<bool > isTriggerTVX{" isTriggerTVX" , 1 , " Is Trigger TVX" };
165172 Configurable<bool > isNoTimeFrameBorder{" isNoTimeFrameBorder" , 1 , " Is No Time Frame Border" };
166173 Configurable<bool > isNoITSROFrameBorder{" isNoITSROFrameBorder" , 1 , " Is No ITS Readout Frame Border" };
174+ Configurable<bool > applyBcBorderCutsOnGen{" applyBcBorderCutsOnGen" , false , " Apply enabled BC-level TF and ITS ROF border cuts on generated-level MC collisions" };
175+ Configurable<bool > applyRCTOnGen{" applyRCTOnGen" , false , " Apply enabled BC-level RCT run-condition selection on generated-level MC collisions" };
167176 Configurable<bool > isVertexTOFmatched{" isVertexTOFmatched" , 0 , " Is Vertex TOF matched" };
168177 Configurable<bool > isNoSameBunchPileup{" isNoSameBunchPileup" , 0 , " isNoSameBunchPileup" };
178+ Configurable<std::string> cfgEvtRCTFlagCheckerLabel{" cfgEvtRCTFlagCheckerLabel" , " CBT_hadronPID" , " Evt sel: RCT flag checker label" };
179+ Configurable<bool > cfgEvtRCTFlagCheckerZDCCheck{" cfgEvtRCTFlagCheckerZDCCheck" , false , " Evt sel: RCT flag checker ZDC check" };
180+ Configurable<bool > cfgEvtRCTFlagCheckerLimitAcceptAsBad{" cfgEvtRCTFlagCheckerLimitAcceptAsBad" , false , " Evt sel: RCT flag checker treat Limited Acceptance As Bad" };
169181 Configurable<int > v0TypeSelection{" v0TypeSelection" , 1 , " select on a certain V0 type (leave negative if no selection desired)" };
170182 Configurable<bool > NotITSAfterburner{" NotITSAfterburner" , 0 , " NotITSAfterburner" };
171183
184+ RCTFlagsChecker rctChecker;
185+
172186 // V0 selection criteria
173187 Configurable<double > v0cospa{" v0cospa" , 0.97 , " V0 CosPA" };
174188 Configurable<float > dcav0dau{" dcav0dau" , 10 , " DCA V0 Daughters" };
@@ -214,6 +228,27 @@ struct LfV0qaanalysis {
214228 return true ;
215229 }
216230
231+ template <typename TBC >
232+ bool acceptGeneratedEventBcBorderCuts (TBC const & bc)
233+ {
234+ if (!applyBcBorderCutsOnGen) {
235+ return true ;
236+ }
237+ if (isNoTimeFrameBorder && !bc.selection_bit (aod::evsel::kNoTimeFrameBorder )) {
238+ return false ;
239+ }
240+ if (isNoITSROFrameBorder && !bc.selection_bit (aod::evsel::kNoITSROFrameBorder )) {
241+ return false ;
242+ }
243+ return true ;
244+ }
245+
246+ template <typename TBC >
247+ bool acceptGeneratedEventRCT (TBC const & bc)
248+ {
249+ return !applyRCTOnGen || rctChecker (bc);
250+ }
251+
217252 Filter preFilterV0 = nabs(aod::v0data::dcapostopv) > dcapostopv&&
218253 nabs (aod::v0data::dcanegtopv) > dcanegtopv&& aod::v0data::dcaV0daughters < dcav0dau;
219254
@@ -230,7 +265,7 @@ struct LfV0qaanalysis {
230265 registry.fill (HIST (" hCentFT0M" ), collision.centFT0M ());
231266 registry.fill (HIST (" hCentNGlobals" ), collision.centNGlobal ());
232267
233- for (auto & v0 : V0s) { // loop over V0s
268+ for (const auto & v0 : V0s) { // loop over V0s
234269
235270 if (v0.v0Type () != v0TypeSelection) {
236271 continue ;
@@ -323,7 +358,7 @@ struct LfV0qaanalysis {
323358 }
324359
325360 auto v0sThisCollision = V0s.sliceBy (perCol, collision.globalIndex ());
326- for (auto & v0 : v0sThisCollision) { // loop over V0s
361+ for (const auto & v0 : v0sThisCollision) { // loop over V0s
327362
328363 if (!v0.has_mcParticle ()) {
329364 continue ;
@@ -371,8 +406,8 @@ struct LfV0qaanalysis {
371406 lPDG = v0mcparticle.pdgCode ();
372407 isprimary = v0mcparticle.isPhysicalPrimary ();
373408 }
374- for (auto & mcparticleDaughter0 : v0mcparticle.daughters_as <aod::McParticles>()) {
375- for (auto & mcparticleDaughter1 : v0mcparticle.daughters_as <aod::McParticles>()) {
409+ for (const auto & mcparticleDaughter0 : v0mcparticle.daughters_as <aod::McParticles>()) {
410+ for (const auto & mcparticleDaughter1 : v0mcparticle.daughters_as <aod::McParticles>()) {
376411 if (mcparticleDaughter0.pdgCode () == 211 && mcparticleDaughter1.pdgCode () == -211 ) {
377412 isDauK0Short = true ;
378413 }
@@ -389,7 +424,7 @@ struct LfV0qaanalysis {
389424 float pdgMother = 0 .;
390425
391426 if (std::abs (v0mcparticle.pdgCode ()) == 3122 && v0mcparticle.has_mothers ()) {
392- for (auto & mcparticleMother0 : v0mcparticle.mothers_as <aod::McParticles>()) {
427+ for (const auto & mcparticleMother0 : v0mcparticle.mothers_as <aod::McParticles>()) {
393428 if (std::abs (mcparticleMother0.pdgCode ()) == 3312 || std::abs (mcparticleMother0.pdgCode ()) == 3322 ) {
394429 ptMotherMC = mcparticleMother0.pt ();
395430 pdgMother = mcparticleMother0.pdgCode ();
@@ -435,7 +470,7 @@ struct LfV0qaanalysis {
435470 // Generated particles
436471 const auto particlesInCollision = mcParticles.sliceByCached (aod::mcparticle::mcCollisionId, mcCollision.globalIndex (), cache1);
437472
438- for (auto & mcParticle : particlesInCollision) {
473+ for (const auto & mcParticle : particlesInCollision) {
439474 if (!mcParticle.isPhysicalPrimary ()) {
440475 continue ;
441476 }
@@ -469,7 +504,8 @@ struct LfV0qaanalysis {
469504
470505 void processMCGen (soa::Join<aod::McCollisions, aod::McCentFT0Ms>::iterator const & mcCollision,
471506 aod::McParticles const & mcParticles,
472- soa::SmallGroups<soa::Join<aod::Collisions, aod::EvSels, aod::McCollisionLabels, aod::PVMults>> const & collisions)
507+ soa::SmallGroups<soa::Join<aod::Collisions, aod::EvSels, aod::McCollisionLabels, aod::PVMults>> const & collisions,
508+ BCsWithBcSels const &)
473509 {
474510 // ====================================
475511 // ===== Event Loss Denominator =======
@@ -481,21 +517,30 @@ struct LfV0qaanalysis {
481517 return ;
482518 }
483519 registry.fill (HIST (" hNEventsMCGen" ), 1.5 );
520+ const auto bc = mcCollision.bc_as <BCsWithBcSels>();
521+ if (!acceptGeneratedEventBcBorderCuts (bc)) {
522+ return ;
523+ }
524+ registry.fill (HIST (" hNEventsMCGen" ), 2.5 );
525+ if (!acceptGeneratedEventRCT (bc)) {
526+ return ;
527+ }
528+ registry.fill (HIST (" hNEventsMCGen" ), 3.5 );
484529 registry.fill (HIST (" hCentFT0M_GenColl_MC" ), mcCollision.centFT0M ());
485530
486531 bool isINELgt0true = false ;
487532
488533 if (pwglf::isINELgtNmc (mcParticles, 0 , pdgDB)) {
489534 isINELgt0true = true ;
490- registry.fill (HIST (" hNEventsMCGen" ), 2 .5 );
535+ registry.fill (HIST (" hNEventsMCGen" ), 4 .5 );
491536 registry.fill (HIST (" hCentFT0M_GenColl_MC_INELgt0" ), mcCollision.centFT0M ());
492537 }
493538
494539 // =====================================
495540 // ===== Signal Loss Denominator =======
496541 // =====================================
497542
498- for (auto & mcParticle : mcParticles) {
543+ for (const auto & mcParticle : mcParticles) {
499544
500545 if (!mcParticle.isPhysicalPrimary ()) {
501546 continue ;
@@ -526,7 +571,7 @@ struct LfV0qaanalysis {
526571
527572 int recoCollIndex_INEL = 0 ;
528573 int recoCollIndex_INELgt0 = 0 ;
529- for (auto & collision : collisions) { // loop on reconstructed collisions
574+ for (const auto & collision : collisions) { // loop on reconstructed collisions
530575
531576 // =====================================
532577 // ====== Event Split Numerator ========
@@ -553,7 +598,7 @@ struct LfV0qaanalysis {
553598 // ======== Sgn Split Numerator ========
554599 // =====================================
555600
556- for (auto & mcParticle : mcParticles) {
601+ for (const auto & mcParticle : mcParticles) {
557602
558603 if (!mcParticle.isPhysicalPrimary ()) {
559604 continue ;
@@ -605,7 +650,7 @@ struct LfV0qaanalysis {
605650 // ===== Signal Loss Numerator =========
606651 // =====================================
607652
608- for (auto & mcParticle : mcParticles) {
653+ for (const auto & mcParticle : mcParticles) {
609654
610655 if (!mcParticle.isPhysicalPrimary ()) {
611656 continue ;
@@ -682,7 +727,7 @@ struct LfMyV0s {
682727
683728 void process (aod::MyV0Candidates const & myv0s)
684729 {
685- for (auto & candidate : myv0s) {
730+ for (const auto & candidate : myv0s) {
686731
687732 registry.fill (HIST (" hMassLambda" ), candidate.masslambda ());
688733 registry.fill (HIST (" hPt" ), candidate.v0pt ());
0 commit comments