@@ -102,6 +102,9 @@ struct HfCandidateCreator2Prong {
102102 OutputObj<TH2F > hDcaXYProngs{TH2F (" hDcaXYProngs" , " DCAxy of 2-prong candidates;#it{p}_{T} (GeV/#it{c};#it{d}_{xy}) (#mum);entries" , 100 , 0 ., 20 ., 200 , -500 ., 500 .)};
103103 OutputObj<TH2F > hDcaZProngs{TH2F (" hDcaZProngs" , " DCAz of 2-prong candidates;#it{p}_{T} (GeV/#it{c};#it{d}_{z}) (#mum);entries" , 100 , 0 ., 20 ., 200 , -500 ., 500 .)};
104104 OutputObj<TH1F > hVertexerType{TH1F (" hVertexerType" , " Use KF or DCAFitterN;Vertexer type;entries" , 2 , -0.5 , 1.5 )}; // See o2::aod::hf_cand::VertexerType
105+ OutputObj<TH1D > hCollisions{TH1D (" hCollisions" , " HF event counter" , ValuesEvSel::NEvSel, -0 .5f , static_cast <float >(ValuesEvSel::NEvSel) - 0 .5f )};
106+ OutputObj<TH1D > hPosZBeforeEvSel{TH1D (" hPosZBeforeEvSel" , " PV position Z before ev. selection;posZ (cm);entries" , 400 , -20 , 20 )};
107+ OutputObj<TH1D > hPosZAfterEvSel{TH1D (" hPosZAfterEvSel" , " PV position Z after ev. selection;posZ (cm);entries" , 400 , -20 , 20 )};
105108
106109 void init (InitContext const &)
107110 {
@@ -115,6 +118,23 @@ struct HfCandidateCreator2Prong {
115118 LOGP (fatal, " One and only one process function must be enabled at a time." );
116119 }
117120
121+ std::array<bool , 3 > processesCollisions = {doprocessCollisions, doprocessCollisionsCentFT0C, doprocessCollisionsCentFT0M};
122+ const int nProcessesCollisions = std::accumulate (processesCollisions.begin (), processesCollisions.end (), 0 );
123+ if (nProcessesCollisions > 1 ) {
124+ LOGP (fatal, " At most one process function for collision monitoring can be enabled at a time." );
125+ }
126+ if (nProcessesCollisions == 1 ) {
127+ if ((doprocessPvRefitWithDCAFitterN || doprocessNoPvRefitWithDCAFitterN || doprocessPvRefitWithKFParticle || doprocessNoPvRefitWithKFParticle) && !doprocessCollisions) {
128+ LOGP (fatal, " Process function for collision monitoring not correctly enabled. Did you enable \" processCollisions\" ?" );
129+ }
130+ if ((doprocessPvRefitWithDCAFitterNCentFT0C || doprocessNoPvRefitWithDCAFitterNCentFT0C || doprocessPvRefitWithKFParticleCentFT0C || doprocessNoPvRefitWithKFParticleCentFT0C) && !doprocessCollisionsCentFT0C) {
131+ LOGP (fatal, " Process function for collision monitoring not correctly enabled. Did you enable \" processCollisionsCentFT0C\" ?" );
132+ }
133+ if ((doprocessPvRefitWithDCAFitterNCentFT0M || doprocessNoPvRefitWithDCAFitterNCentFT0M || doprocessPvRefitWithKFParticleCentFT0M || doprocessNoPvRefitWithKFParticleCentFT0M) && !doprocessCollisionsCentFT0M) {
134+ LOGP (fatal, " Process function for collision monitoring not correctly enabled. Did you enable \" processCollisionsCentFT0M\" ?" );
135+ }
136+ }
137+
118138 massPi = MassPiPlus;
119139 massK = MassKPlus;
120140
@@ -139,9 +159,12 @@ struct HfCandidateCreator2Prong {
139159 ccdb->setLocalObjectValidityChecking ();
140160 lut = o2::base::MatLayerCylSet::rectifyPtrFromFile (ccdb->get <o2::base::MatLayerCylSet>(ccdbPathLut));
141161 runNumber = 0 ;
162+
163+ // / collision monitoring
164+ setLabelHistoEvSel (hCollisions.object );
142165 }
143166
144- template <bool doPvRefit, int centEstimator, typename Coll, typename CandType, typename TTracks>
167+ template <bool doPvRefit, o2::aod::hf_collision_centrality::CentralityEstimator centEstimator, typename Coll, typename CandType, typename TTracks>
145168 void runCreator2ProngWithDCAFitterN (Coll const & collisions,
146169 CandType const & rowsTrackIndexProng2,
147170 TTracks const & tracks,
@@ -150,24 +173,11 @@ struct HfCandidateCreator2Prong {
150173 // loop over pairs of track indices
151174 for (const auto & rowTrackIndexProng2 : rowsTrackIndexProng2) {
152175
153- // reject candidates in collisions outside the centrality range
176+ // / reject candidates not satisfying the event selections
154177 auto collision = rowTrackIndexProng2.template collision_as <Coll>();
155- float centrality = -1 .;
156- if constexpr (centEstimator != CentralityEstimator::None) {
157- if constexpr (centEstimator == CentralityEstimator::FT0C ) {
158- centrality = collision.centFT0C ();
159- } else if constexpr (centEstimator == CentralityEstimator::FT0M ) {
160- centrality = collision.centFT0M ();
161- } else {
162- LOGP (fatal, " Centrality estimator different from FT0C and FT0M, fix it!" );
163- }
164- if (centrality < centralityMin || centrality > centralityMax) {
165- continue ;
166- }
167- }
168-
169- // / event selection: sel8, PV posZ, TF border cut
170- if (!isHfCollisionSelected (collision, useSel8Trigger, maxPvPosZ, useTimeFrameBorderCut)) {
178+ const auto rejectionMask = getHfCollisionRejectionMask<centEstimator>(collision, centralityMin, centralityMax, useSel8Trigger, maxPvPosZ, useTimeFrameBorderCut);
179+ if (rejectionMask != 0 ) {
180+ // / at least one event selection not satisfied --> reject the candidate
171181 continue ;
172182 }
173183
@@ -283,7 +293,7 @@ struct HfCandidateCreator2Prong {
283293 }
284294 }
285295
286- template <bool doPvRefit, int centEstimator, typename Coll, typename CandType, typename TTracks>
296+ template <bool doPvRefit, o2::aod::hf_collision_centrality::CentralityEstimator centEstimator, typename Coll, typename CandType, typename TTracks>
287297 void runCreator2ProngWithKFParticle (Coll const & collisions,
288298 CandType const & rowsTrackIndexProng2,
289299 TTracks const & tracks,
@@ -292,24 +302,11 @@ struct HfCandidateCreator2Prong {
292302
293303 for (const auto & rowTrackIndexProng2 : rowsTrackIndexProng2) {
294304
295- // reject candidates in collisions outside the centrality range
305+ // / reject candidates in collisions not satisfying the event selections
296306 auto collision = rowTrackIndexProng2.template collision_as <Coll>();
297- float centrality = -1 .;
298- if constexpr (centEstimator != CentralityEstimator::None) {
299- if constexpr (centEstimator == CentralityEstimator::FT0C ) {
300- centrality = collision.centFT0C ();
301- } else if constexpr (centEstimator == CentralityEstimator::FT0M ) {
302- centrality = collision.centFT0M ();
303- } else {
304- LOGP (fatal, " Centrality estimator different from FT0C and FT0M, fix it!" );
305- }
306- if (centrality < centralityMin || centrality > centralityMax) {
307- continue ;
308- }
309- }
310-
311- // / event selection: sel8, PV posZ, TF border cut
312- if (!isHfCollisionSelected (collision, useSel8Trigger, maxPvPosZ, useTimeFrameBorderCut)) {
307+ const auto rejectionMask = getHfCollisionRejectionMask<centEstimator>(collision, centralityMin, centralityMax, useSel8Trigger, maxPvPosZ, useTimeFrameBorderCut);
308+ if (rejectionMask != 0 ) {
309+ // / at least one event selection not satisfied --> reject the candidate
313310 continue ;
314311 }
315312
@@ -572,6 +569,60 @@ struct HfCandidateCreator2Prong {
572569 runCreator2ProngWithKFParticle</* doPvRefit*/ false , CentralityEstimator::FT0M >(collisions, rowsTrackIndexProng2, tracks, bcWithTimeStamps);
573570 }
574571 PROCESS_SWITCH (HfCandidateCreator2Prong, processNoPvRefitWithKFParticleCentFT0M, " Run candidate creator using KFParticle package w/o PV refit and w/ centrality selection on FT0M" , false );
572+
573+ // /////////////////////////////////////////////////////////
574+ // / ///
575+ // / Process functions only for collision monitoring ///
576+ // / ///
577+ // /////////////////////////////////////////////////////////
578+
579+ // / @brief process function to monitor collisions - no centrality
580+ void processCollisions (soa::Join<aod::Collisions, aod::EvSels> const & collisions)
581+ {
582+ // / loop over collisions
583+ for (const auto & collision : collisions) {
584+
585+ // / bitmask with event. selection info
586+ const auto rejectionMask = getHfCollisionRejectionMask<CentralityEstimator::None>(collision, centralityMin, centralityMax, useSel8Trigger, maxPvPosZ, useTimeFrameBorderCut);
587+
588+ // / monitor the satisfied event selections
589+ monitorCollision (collision, rejectionMask, hCollisions.object , hPosZBeforeEvSel.object , hPosZAfterEvSel.object );
590+
591+ } // / end loop over collisions
592+ }
593+ PROCESS_SWITCH (HfCandidateCreator2Prong, processCollisions, " Collision monitoring - no centrality" , true );
594+
595+ // / @brief process function to monitor collisions - FT0C centrality
596+ void processCollisionsCentFT0C (soa::Join<aod::Collisions, aod::EvSels, aod::CentFT0Cs> const & collisions)
597+ {
598+ // / loop over collisions
599+ for (const auto & collision : collisions) {
600+
601+ // / bitmask with event. selection info
602+ const auto rejectionMask = getHfCollisionRejectionMask<CentralityEstimator::FT0C >(collision, centralityMin, centralityMax, useSel8Trigger, maxPvPosZ, useTimeFrameBorderCut);
603+
604+ // / monitor the satisfied event selections
605+ monitorCollision (collision, rejectionMask, hCollisions.object , hPosZBeforeEvSel.object , hPosZAfterEvSel.object );
606+
607+ } // / end loop over collisions
608+ }
609+ PROCESS_SWITCH (HfCandidateCreator2Prong, processCollisionsCentFT0C, " Collision monitoring - FT0C centrality" , false );
610+
611+ // / @brief process function to monitor collisions - FT0M centrality
612+ void processCollisionsCentFT0M (soa::Join<aod::Collisions, aod::EvSels, aod::CentFT0Ms> const & collisions)
613+ {
614+ // / loop over collisions
615+ for (const auto & collision : collisions) {
616+
617+ // / bitmask with event. selection info
618+ const auto rejectionMask = getHfCollisionRejectionMask<CentralityEstimator::FT0M >(collision, centralityMin, centralityMax, useSel8Trigger, maxPvPosZ, useTimeFrameBorderCut);
619+
620+ // / monitor the satisfied event selections
621+ monitorCollision (collision, rejectionMask, hCollisions.object , hPosZBeforeEvSel.object , hPosZAfterEvSel.object );
622+
623+ } // / end loop over collisions
624+ }
625+ PROCESS_SWITCH (HfCandidateCreator2Prong, processCollisionsCentFT0M, " Collision monitoring - FT0M centrality" , false );
575626};
576627
577628// / Extends the base table with expression columns.
0 commit comments