@@ -96,8 +96,13 @@ struct HfCorrelatorFlowCharmHadronsReduced {
9696 Configurable<std::vector<double >> bdtScore0PtMaxs{" bdtScore0PtMaxs" , std::vector<double >{0.1 , 0.1 , 0.1 , 0.1 , 0.1 }, " pT-differential maximum score 0 for charm candidates" };
9797 Configurable<std::vector<double >> bdtScore1PtMins{" bdtScore1PtMins" , std::vector<double >{0.1 , 0.1 , 0.1 , 0.1 , 0.1 }, " pT-differential minimum score 1 for charm candidates" };
9898 Configurable<std::vector<double >> binsPtAssoc{" binsPtAssoc" , std::vector<double >{0.3 , 1 ., 2 ., 50 .}, " pT bin limits for associated particles" };
99+ Configurable<bool > selCentrality{" selCentrality" , false , " Use centrality to select events" };
100+ Configurable<bool > selMultiplicity{" selMultiplicity" , false , " Use multiplicity to select events" };
101+ Configurable<bool > countCharmCandsPerCollision{" countCharmCandsPerCollision" , false , " Count charm candidates per collision" };
99102 Configurable<float > centralityMin{" centralityMin" , 0 , " min. centrality" };
100103 Configurable<float > centralityMax{" centralityMax" , 10 ., " max. centrality" };
104+ Configurable<float > multiplicityMin{" multiplicityMin" , 0 , " min. multiplicity" };
105+ Configurable<float > multiplicityMax{" multiplicityMax" , 10 ., " max. multiplicity" };
101106 Configurable<float > deltaEtaAbsMin{" deltaEtaAbsMin" , 0.5 , " min. pair delta eta" };
102107 Configurable<float > deltaEtaAbsMax{" deltaEtaAbsMax" , 2 ., " max. pair delta eta" };
103108 Configurable<float > dcaXYTrackMax{" dcaXYTrackMax" , 1 ., " max. track DCA XY" };
@@ -106,7 +111,7 @@ struct HfCorrelatorFlowCharmHadronsReduced {
106111 Configurable<int > itsNClsMin{" itsNClsMin" , 1 , " min. ITS clusters" };
107112 Configurable<float > downSamplePairs{" downSamplePairs" , 1 ., " Fraction of pairs to keep" };
108113 Configurable<float > ptMaxForDownSample{" ptMaxForDownSample" , 10 ., " Maximum pt for the application of the downsampling factor" };
109- Configurable<float > centMaxForDownSample{ " centMaxForDownSample " , 10 ., " Maximum centrality for the application of the downsampling factor" };
114+ Configurable<float > centMultMaxForDownSample{ " centMultMaxForDownSample " , 10 ., " Maximum centrality for the application of the downsampling factor" };
110115
111116 SliceCache cache;
112117
@@ -131,17 +136,30 @@ struct HfCorrelatorFlowCharmHadronsReduced {
131136 ConfigurableAxis binsMultFT0M{" binsMultFT0M" , {100 , 0 ., 10000 .}, " Multiplicity as FT0M signal amplitude" };
132137 ConfigurableAxis binsCent{" binsCent" , {100 , 0 ., 100 .}, " Centrality bins" };
133138 ConfigurableAxis binsPosZ{" binsPosZ" , {100 , -10 ., 10 .}, " Primary vertex z coordinate" };
134- ConfigurableAxis binsEta{" binsEta" , {50 , -2 ., 2 .}, " Eta bins" };
135- ConfigurableAxis binsPhi{" binsPhi" , {64 , -o2::constants::math::PIHalf, 3 . * o2::constants::math::PIHalf}, " Phi bins" };
136139 ConfigurableAxis binsDeltaEta{" binsDeltaEta" , {100 , -2 ., 2 .}, " Delta Eta bins" };
137- ConfigurableAxis binsDeltaPhi{" binsDeltaPhi" , {64 , -3 . , 3 .}, " Delta Phi bins" };
140+ ConfigurableAxis binsDeltaPhi{" binsDeltaPhi" , {64 , -o2::constants::math::PIHalf , 3 . * o2::constants::math::PIHalf }, " Delta Phi bins" };
138141 ConfigurableAxis binsMlOne{" binsMlOne" , {100 , 0 ., 1 .}, " ML score index 1 bins" };
139142 ConfigurableAxis binsMlTwo{" binsMlTwo" , {100 , 0 ., 1 .}, " ML score index 2 bins" };
140143
141144 HistogramRegistry registry{" registry" , {}, OutputObjHandlingPolicy::AnalysisObject};
142145
143146 void init (InitContext&)
144147 {
148+ if (selCentrality && selMultiplicity) {
149+ LOGP (fatal, " You cannot select events based on both centrality and multiplicity! Please check your configuration!" );
150+ }
151+ if (!selCentrality && !selMultiplicity) {
152+ LOGP (fatal, " You must select events based on either centrality or multiplicity! Please check your configuration!" );
153+ }
154+
155+ // Fatal if selCentrality and process functions using multiplicity mixing, or selMultiplicity and process functions using centrality mixing
156+ if (selCentrality && (doprocessSameEventCharmHadWMultMix || doprocessMixedEventCharmHadWMultMix || doprocessSameEventHadHadWMultMix || doprocessMixedEventHadHadWMultMix)) {
157+ LOGP (fatal, " You cannot select events based on centrality and process functions using multiplicity mixing! Please check your configuration!" );
158+ }
159+ if (selMultiplicity && (doprocessSameEventCharmHadWCentMix || doprocessMixedEventCharmHadWCentMix || doprocessSameEventHadHadWCentMix || doprocessMixedEventHadHadWCentMix)) {
160+ LOGP (fatal, " You cannot select events based on multiplicity and process functions using centrality mixing! Please check your configuration!" );
161+ }
162+
145163 if ((doprocessSameEventCharmHadWCentMix && doprocessMixedEventCharmHadWMultMix) ||
146164 (doprocessSameEventCharmHadWMultMix && doprocessMixedEventCharmHadWCentMix) ||
147165 (doprocessSameEventHadHadWCentMix && doprocessMixedEventHadHadWMultMix) ||
@@ -185,6 +203,8 @@ struct HfCorrelatorFlowCharmHadronsReduced {
185203 }
186204 registry.add (" hZVtxPoolBinSE" , " z vertex SE" , {HistType::kTH2F , {{axisPosZ}, {axisPoolBin}}});
187205 registry.add (" hZVtxPoolBinME" , " z vertex ME" , {HistType::kTH2F , {{axisPosZ}, {axisPoolBin}}});
206+ registry.add (" hCollisionsCentMultAll" , " Collision centrality vs multiplicity" , {HistType::kTH2F , {{axisCent}, {axisMultFT0M}}});
207+ registry.add (" hCollisionsCentMultSel" , " Collision centrality vs multiplicity" , {HistType::kTH2F , {{axisCent}, {axisMultFT0M}}});
188208 registry.add (" hPoolBinTrigSE" , " Trigger candidates pool bin SE" , {HistType::kTH1F , {axisPoolBin}});
189209 registry.add (" hPoolBinTrigME" , " Trigger candidates pool bin ME" , {HistType::kTH1F , {axisPoolBin}});
190210 registry.add (" hPoolBinAssocSE" , " Associated particles pool bin SE" , {HistType::kTH1F , {axisPoolBin}});
@@ -205,12 +225,25 @@ struct HfCorrelatorFlowCharmHadronsReduced {
205225 registry.add (" hSparseCorrelationsMECharmHad" , " THn for ME Charm-Had correlations" , HistType::kTHnSparseF , axes);
206226 }
207227 if (doprocessCharmTriggers) {
228+ if (countCharmCandsPerCollision) {
229+ axesTrigger.push_back ({100 , -0.5 , 99.5 , " nCharmCandidates" });
230+ }
208231 registry.add (" hSparseTrigCandsCharm" , " THn for Charm trigger candidates" , HistType::kTHnSparseF , axesTrigger);
209232 }
210233 }
211234 }
212235 }
213236
237+ bool isSelCollision (const aod::HfcRedCorrColls& collision)
238+ {
239+ if (selCentrality) {
240+ return (collision.centrality () >= centralityMin && collision.centrality () <= centralityMax);
241+ } else if (selMultiplicity) {
242+ return (collision.multiplicity () >= multiplicityMin && collision.multiplicity () <= multiplicityMax);
243+ }
244+ return false ;
245+ }
246+
214247 // / Get the binning pool associated to the collision
215248 // / \param collision is the collision
216249 // / \param binPolicy is the binning policy for the correlation
@@ -265,9 +298,12 @@ struct HfCorrelatorFlowCharmHadronsReduced {
265298 const TBinningType& binPolicy)
266299 {
267300 auto collision = pair.template hfcRedCorrColl_as <o2::aod::HfcRedCorrColls>();
268- if (collision.centrality () < centralityMin || collision.centrality () > centralityMax) {
301+ registry.fill (HIST (" hCollisionsCentMultAll" ), collision.centrality (), collision.multiplicity ());
302+ if (!isSelCollision (collision)) {
269303 return ;
270304 }
305+ registry.fill (HIST (" hCollisionsCentMultSel" ), collision.centrality (), collision.multiplicity ());
306+
271307 double const ptTrig = trigCand.ptTrig ();
272308 if constexpr (requires { trigCand.bdtScore0Trig (); }) { // ML selection on bkg score for Charm-Had case
273309 if (!isSelBdtScoreCut (trigCand, ptTrig)) {
@@ -276,7 +312,8 @@ struct HfCorrelatorFlowCharmHadronsReduced {
276312 }
277313 if (downSamplePairs < 1 .) {
278314 float const pseudoRndm = ptTrig * 1000 . - static_cast <int64_t >(ptTrig * 1000 );
279- if (ptTrig < ptMaxForDownSample && collision.centrality () < centMaxForDownSample && pseudoRndm >= downSamplePairs) {
315+ float collCentMult = selCentrality ? collision.centrality () : collision.multiplicity ();
316+ if (ptTrig < ptMaxForDownSample && collCentMult < centMultMaxForDownSample && pseudoRndm >= downSamplePairs) {
280317 return ;
281318 }
282319 }
@@ -317,10 +354,14 @@ struct HfCorrelatorFlowCharmHadronsReduced {
317354 if (trigCands.size () == 0 || assocTracks.size () == 0 ) {
318355 continue ;
319356 }
320- if (trigColl.centrality () < centralityMin || trigColl.centrality () > centralityMax ||
321- assocColl.centrality () < centralityMin || assocColl.centrality () > centralityMax) {
357+ registry.fill (HIST (" hCollisionsCentMultAll" ), trigColl.centrality (), trigColl.multiplicity ());
358+ registry.fill (HIST (" hCollisionsCentMultAll" ), assocColl.centrality (), assocColl.multiplicity ());
359+ if (!isSelCollision (trigColl) || !isSelCollision (assocColl)) {
322360 continue ;
323361 }
362+ registry.fill (HIST (" hCollisionsCentMultSel" ), trigColl.centrality (), trigColl.multiplicity ());
363+ registry.fill (HIST (" hCollisionsCentMultSel" ), assocColl.centrality (), assocColl.multiplicity ());
364+
324365 int const poolBinTrig = getPoolBin<true >(trigColl, binPolicy);
325366 int const poolBinAssoc = getPoolBin<true >(assocColl, binPolicy);
326367 if (poolBinAssoc != poolBinTrig) {
@@ -345,8 +386,10 @@ struct HfCorrelatorFlowCharmHadronsReduced {
345386 double const ptAssoc = getPt (assocTrack);
346387 if (downSamplePairs < 1 .) {
347388 float const pseudoRndm = ptAssoc * 1000 . - static_cast <int64_t >(ptAssoc * 1000 );
348- if (ptTrig < ptMaxForDownSample && trigColl.centrality () < centMaxForDownSample &&
349- assocColl.centrality () < centMaxForDownSample && pseudoRndm >= downSamplePairs) {
389+ float trigCollCentMult = selCentrality ? trigColl.centrality () : trigColl.multiplicity ();
390+ float assocCollCentMult = selCentrality ? assocColl.centrality () : assocColl.multiplicity ();
391+ if (ptTrig < ptMaxForDownSample && trigCollCentMult < centMultMaxForDownSample &&
392+ assocCollCentMult < centMultMaxForDownSample && pseudoRndm >= downSamplePairs) {
350393 continue ;
351394 }
352395 }
@@ -430,12 +473,15 @@ struct HfCorrelatorFlowCharmHadronsReduced {
430473 Pair<TCollision, TTrigCand, TTrackAssoc, TBinningType> pairData{binPolicy, numberEventsMixed, -1 , collisions, tracksTuple, &cache};
431474
432475 for (const auto & [c1, tracks1, c2, tracks2] : pairData) {
476+ if (!isSelCollision (c1) || !isSelCollision (c2)) {
477+ continue ;
478+ }
433479 if (tracks1.size () == 0 ) {
434480 continue ;
435481 }
436482
437- int poolBin = binPolicy.getBin ({c2.posZ (), c2.centrality ()});
438- int poolBinTrigCand = binPolicy.getBin ({c1.posZ (), c1.centrality ()});
483+ int poolBin = binPolicy.getBin ({c2.posZ (), selCentrality ? c2.centrality () : c2. multiplicity ()});
484+ int poolBinTrigCand = binPolicy.getBin ({c1.posZ (), selCentrality ? c1.centrality () : c1. multiplicity ()});
439485
440486 if (poolBin != poolBinTrigCand) {
441487 LOGF (info, " Error, poolBins are different" );
@@ -446,7 +492,6 @@ struct HfCorrelatorFlowCharmHadronsReduced {
446492 if (!isSelBdtScoreCut (trigCand, trigCand.ptTrig ())) {
447493 continue ;
448494 }
449- LOGF (info, " Mixed event tracks pair: (%d, %d) from events (%d, %d), track event: (%d, %d)" , trigCand.index (), assTrk.index (), c1.index (), c2.index (), trigCand.hfcRedCorrCollId (), assTrk.hfcRedCorrCollId ());
450495
451496 double deltaPhi = RecoDecay::constrainAngle (assTrk.phiAssoc () - trigCand.phiTrig (), -o2::constants::math::PIHalf);
452497 double deltaEta = assTrk.etaAssoc () - trigCand.etaTrig ();
@@ -476,7 +521,7 @@ struct HfCorrelatorFlowCharmHadronsReduced {
476521 fillSameEvent<false , true >(pair, trigCand, binPolicyPosZMult);
477522 }
478523 }
479- PROCESS_SWITCH (HfCorrelatorFlowCharmHadronsReduced, processSameEventCharmHadWMultMix, " Process Same Event for Charm-Had with multiplicity pools" , true );
524+ PROCESS_SWITCH (HfCorrelatorFlowCharmHadronsReduced, processSameEventCharmHadWMultMix, " Process Same Event for Charm-Had with multiplicity pools" , false );
480525
481526 void processSameEventHadHadWMultMix (SameEvtPairsHadHad::iterator const & pair,
482527 aod::HfcRedTrigTracks const &,
@@ -595,15 +640,27 @@ struct HfCorrelatorFlowCharmHadronsReduced {
595640 void processCharmTriggers (aod::HfcRedTrigCharms const & trigCands,
596641 aod::HfcRedCorrColls const &)
597642 {
643+
644+ std::unordered_map<int , int > nCharmCandidatesPerCollision;
645+ for (const auto & cand : trigCands) {
646+ auto collision = cand.template hfcRedCorrColl_as <o2::aod::HfcRedCorrColls>();
647+ ++nCharmCandidatesPerCollision[collision.globalIndex ()];
648+ }
649+
598650 for (const auto & trigCand : trigCands) {
599651 auto collision = trigCand.template hfcRedCorrColl_as <o2::aod::HfcRedCorrColls>();
600- if (collision. centrality () < centralityMin || collision. centrality () > centralityMax ) {
652+ if (! isSelCollision ( collision) ) {
601653 continue ;
602654 }
603655 if (!isSelBdtScoreCut (trigCand, trigCand.ptTrig ())) {
604656 continue ;
605657 }
606- registry.fill (HIST (" hSparseTrigCandsCharm" ), trigCand.invMassTrig (), trigCand.ptTrig (), trigCand.bdtScore0Trig (), trigCand.bdtScore1Trig ());
658+ const auto nCharmCandidates = nCharmCandidatesPerCollision[collision.globalIndex ()];
659+ if (countCharmCandsPerCollision) {
660+ registry.fill (HIST (" hSparseTrigCandsCharm" ), trigCand.invMassTrig (), trigCand.ptTrig (), trigCand.bdtScore0Trig (), trigCand.bdtScore1Trig (), nCharmCandidates);
661+ } else {
662+ registry.fill (HIST (" hSparseTrigCandsCharm" ), trigCand.invMassTrig (), trigCand.ptTrig (), trigCand.bdtScore0Trig (), trigCand.bdtScore1Trig ());
663+ }
607664 }
608665 }
609666 PROCESS_SWITCH (HfCorrelatorFlowCharmHadronsReduced, processCharmTriggers, " Process charm trigger info" , false );
@@ -615,7 +672,7 @@ struct HfCorrelatorFlowCharmHadronsReduced {
615672 BinningCentPosZ binPolicyPosZCent{{zPoolBins, centPoolBins}};
616673
617674 for (const auto & collision : collisions) {
618- if (collision. centrality () < centralityMin || collision. centrality () > centralityMax ) {
675+ if (! isSelCollision ( collision) ) {
619676 continue ;
620677 }
621678 int poolBin = binPolicyPosZCent.getBin ({collision.posZ (), collision.centrality ()});
0 commit comments