@@ -96,8 +96,12 @@ 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<float > centralityMin{" centralityMin" , 0 , " min. centrality" };
100- Configurable<float > centralityMax{" centralityMax" , 10 ., " max. centrality" };
99+ Configurable<bool > selCentrality{" selCentrality" , false , " Use centrality to select events" };
100+ Configurable<bool > selMultiplicity{" selMultiplicity" , false , " Use multiplicity to select events" };
101+ Configurable<float > centMin{" centMin" , 0 , " min. centrality" };
102+ Configurable<float > centMax{" centMax" , 10 ., " max. centrality" };
103+ Configurable<float > multMin{" multMin" , 0 , " min. multiplicity" };
104+ Configurable<float > multMax{" multMax" , 10 ., " max. multiplicity" };
101105 Configurable<float > deltaEtaAbsMin{" deltaEtaAbsMin" , 0.5 , " min. pair delta eta" };
102106 Configurable<float > deltaEtaAbsMax{" deltaEtaAbsMax" , 2 ., " max. pair delta eta" };
103107 Configurable<float > dcaXYTrackMax{" dcaXYTrackMax" , 1 ., " max. track DCA XY" };
@@ -106,7 +110,7 @@ struct HfCorrelatorFlowCharmHadronsReduced {
106110 Configurable<int > itsNClsMin{" itsNClsMin" , 1 , " min. ITS clusters" };
107111 Configurable<float > downSamplePairs{" downSamplePairs" , 1 ., " Fraction of pairs to keep" };
108112 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" };
113+ Configurable<float > centMultMaxForDownSample{ " centMultMaxForDownSample " , 10 ., " Maximum centrality for the application of the downsampling factor" };
110114
111115 SliceCache cache;
112116
@@ -131,17 +135,30 @@ struct HfCorrelatorFlowCharmHadronsReduced {
131135 ConfigurableAxis binsMultFT0M{" binsMultFT0M" , {100 , 0 ., 10000 .}, " Multiplicity as FT0M signal amplitude" };
132136 ConfigurableAxis binsCent{" binsCent" , {100 , 0 ., 100 .}, " Centrality bins" };
133137 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" };
136138 ConfigurableAxis binsDeltaEta{" binsDeltaEta" , {100 , -2 ., 2 .}, " Delta Eta bins" };
137- ConfigurableAxis binsDeltaPhi{" binsDeltaPhi" , {64 , -3 . , 3 .}, " Delta Phi bins" };
139+ ConfigurableAxis binsDeltaPhi{" binsDeltaPhi" , {64 , -o2::constants::math::PIHalf , 3 . * o2::constants::math::PIHalf }, " Delta Phi bins" };
138140 ConfigurableAxis binsMlOne{" binsMlOne" , {100 , 0 ., 1 .}, " ML score index 1 bins" };
139141 ConfigurableAxis binsMlTwo{" binsMlTwo" , {100 , 0 ., 1 .}, " ML score index 2 bins" };
140142
141143 HistogramRegistry registry{" registry" , {}, OutputObjHandlingPolicy::AnalysisObject};
142144
143145 void init (InitContext&)
144146 {
147+ if (selCentrality && selMultiplicity) {
148+ LOGP (fatal, " You cannot select events based on both centrality and multiplicity! Please check your configuration!" );
149+ }
150+ if (!selCentrality && !selMultiplicity) {
151+ LOGP (fatal, " You must select events based on either centrality or multiplicity! Please check your configuration!" );
152+ }
153+
154+ // Fatal if selCentrality and process functions using multiplicity mixing, or selMultiplicity and process functions using centrality mixing
155+ if (selCentrality && (doprocessSameEventCharmHadWMultMix || doprocessMixedEventCharmHadWMultMix || doprocessSameEventHadHadWMultMix || doprocessMixedEventHadHadWMultMix)) {
156+ LOGP (fatal, " You cannot select events based on centrality and process functions using multiplicity mixing! Please check your configuration!" );
157+ }
158+ if (selMultiplicity && (doprocessSameEventCharmHadWCentMix || doprocessMixedEventCharmHadWCentMix || doprocessSameEventHadHadWCentMix || doprocessMixedEventHadHadWCentMix)) {
159+ LOGP (fatal, " You cannot select events based on multiplicity and process functions using centrality mixing! Please check your configuration!" );
160+ }
161+
145162 if ((doprocessSameEventCharmHadWCentMix && doprocessMixedEventCharmHadWMultMix) ||
146163 (doprocessSameEventCharmHadWMultMix && doprocessMixedEventCharmHadWCentMix) ||
147164 (doprocessSameEventHadHadWCentMix && doprocessMixedEventHadHadWMultMix) ||
@@ -185,6 +202,8 @@ struct HfCorrelatorFlowCharmHadronsReduced {
185202 }
186203 registry.add (" hZVtxPoolBinSE" , " z vertex SE" , {HistType::kTH2F , {{axisPosZ}, {axisPoolBin}}});
187204 registry.add (" hZVtxPoolBinME" , " z vertex ME" , {HistType::kTH2F , {{axisPosZ}, {axisPoolBin}}});
205+ registry.add (" hCollisionsCentMultAll" , " Collision centrality vs multiplicity" , {HistType::kTH2F , {{axisCent}, {axisMultFT0M}}});
206+ registry.add (" hCollisionsCentMultSel" , " Collision centrality vs multiplicity" , {HistType::kTH2F , {{axisCent}, {axisMultFT0M}}});
188207 registry.add (" hPoolBinTrigSE" , " Trigger candidates pool bin SE" , {HistType::kTH1F , {axisPoolBin}});
189208 registry.add (" hPoolBinTrigME" , " Trigger candidates pool bin ME" , {HistType::kTH1F , {axisPoolBin}});
190209 registry.add (" hPoolBinAssocSE" , " Associated particles pool bin SE" , {HistType::kTH1F , {axisPoolBin}});
@@ -211,6 +230,18 @@ struct HfCorrelatorFlowCharmHadronsReduced {
211230 }
212231 }
213232
233+ template <typename TColl>
234+ bool isSelCollision (const TColl& collision)
235+ {
236+ bool isSel = false ;
237+ if (selCentrality) {
238+ isSel = (collision.centrality () >= centMin && collision.centrality () <= centMax);
239+ } else if (selMultiplicity) {
240+ isSel = (collision.multiplicity () >= multMin && collision.multiplicity () <= multMax);
241+ }
242+ return isSel;
243+ }
244+
214245 // / Get the binning pool associated to the collision
215246 // / \param collision is the collision
216247 // / \param binPolicy is the binning policy for the correlation
@@ -265,9 +296,12 @@ struct HfCorrelatorFlowCharmHadronsReduced {
265296 const TBinningType& binPolicy)
266297 {
267298 auto collision = pair.template hfcRedCorrColl_as <o2::aod::HfcRedCorrColls>();
268- if (collision.centrality () < centralityMin || collision.centrality () > centralityMax) {
299+ registry.fill (HIST (" hCollisionsCentMultAll" ), collision.centrality (), collision.multiplicity ());
300+ if (!isSelCollision (collision)) {
269301 return ;
270302 }
303+ registry.fill (HIST (" hCollisionsCentMultSel" ), collision.centrality (), collision.multiplicity ());
304+
271305 double const ptTrig = trigCand.ptTrig ();
272306 if constexpr (requires { trigCand.bdtScore0Trig (); }) { // ML selection on bkg score for Charm-Had case
273307 if (!isSelBdtScoreCut (trigCand, ptTrig)) {
@@ -276,7 +310,8 @@ struct HfCorrelatorFlowCharmHadronsReduced {
276310 }
277311 if (downSamplePairs < 1 .) {
278312 float const pseudoRndm = ptTrig * 1000 . - static_cast <int64_t >(ptTrig * 1000 );
279- if (ptTrig < ptMaxForDownSample && collision.centrality () < centMaxForDownSample && pseudoRndm >= downSamplePairs) {
313+ float collCentMult = selCentrality ? collision.centrality () : collision.multiplicity ();
314+ if (ptTrig < ptMaxForDownSample && collCentMult < centMultMaxForDownSample && pseudoRndm >= downSamplePairs) {
280315 return ;
281316 }
282317 }
@@ -317,10 +352,14 @@ struct HfCorrelatorFlowCharmHadronsReduced {
317352 if (trigCands.size () == 0 || assocTracks.size () == 0 ) {
318353 continue ;
319354 }
320- if (trigColl.centrality () < centralityMin || trigColl.centrality () > centralityMax ||
321- assocColl.centrality () < centralityMin || assocColl.centrality () > centralityMax) {
355+ registry.fill (HIST (" hCollisionsCentMultAll" ), trigColl.centrality (), trigColl.multiplicity ());
356+ registry.fill (HIST (" hCollisionsCentMultAll" ), assocColl.centrality (), assocColl.multiplicity ());
357+ if (!isSelCollision (trigColl) || !isSelCollision (assocColl)) {
322358 continue ;
323359 }
360+ registry.fill (HIST (" hCollisionsCentMultSel" ), trigColl.centrality (), trigColl.multiplicity ());
361+ registry.fill (HIST (" hCollisionsCentMultSel" ), assocColl.centrality (), assocColl.multiplicity ());
362+
324363 int const poolBinTrig = getPoolBin<true >(trigColl, binPolicy);
325364 int const poolBinAssoc = getPoolBin<true >(assocColl, binPolicy);
326365 if (poolBinAssoc != poolBinTrig) {
@@ -345,8 +384,10 @@ struct HfCorrelatorFlowCharmHadronsReduced {
345384 double const ptAssoc = getPt (assocTrack);
346385 if (downSamplePairs < 1 .) {
347386 float const pseudoRndm = ptAssoc * 1000 . - static_cast <int64_t >(ptAssoc * 1000 );
348- if (ptTrig < ptMaxForDownSample && trigColl.centrality () < centMaxForDownSample &&
349- assocColl.centrality () < centMaxForDownSample && pseudoRndm >= downSamplePairs) {
387+ float trigCollCentMult = selCentrality ? trigColl.centrality () : trigColl.multiplicity ();
388+ float assocCollCentMult = selCentrality ? assocColl.centrality () : assocColl.multiplicity ();
389+ if (ptTrig < ptMaxForDownSample && trigCollCentMult < centMultMaxForDownSample &&
390+ assocCollCentMult < centMultMaxForDownSample && pseudoRndm >= downSamplePairs) {
350391 continue ;
351392 }
352393 }
@@ -430,12 +471,15 @@ struct HfCorrelatorFlowCharmHadronsReduced {
430471 Pair<TCollision, TTrigCand, TTrackAssoc, TBinningType> pairData{binPolicy, numberEventsMixed, -1 , collisions, tracksTuple, &cache};
431472
432473 for (const auto & [c1, tracks1, c2, tracks2] : pairData) {
474+ if (!isSelCollision (c1) || !isSelCollision (c2)) {
475+ continue ;
476+ }
433477 if (tracks1.size () == 0 ) {
434478 continue ;
435479 }
436480
437- int poolBin = binPolicy.getBin ({c2.posZ (), c2.centrality ()});
438- int poolBinTrigCand = binPolicy.getBin ({c1.posZ (), c1.centrality ()});
481+ int poolBin = binPolicy.getBin ({c2.posZ (), selCentrality ? c2.centrality () : c2. multiplicity ()});
482+ int poolBinTrigCand = binPolicy.getBin ({c1.posZ (), selCentrality ? c1.centrality () : c1. multiplicity ()});
439483
440484 if (poolBin != poolBinTrigCand) {
441485 LOGF (info, " Error, poolBins are different" );
@@ -446,7 +490,6 @@ struct HfCorrelatorFlowCharmHadronsReduced {
446490 if (!isSelBdtScoreCut (trigCand, trigCand.ptTrig ())) {
447491 continue ;
448492 }
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 ());
450493
451494 double deltaPhi = RecoDecay::constrainAngle (assTrk.phiAssoc () - trigCand.phiTrig (), -o2::constants::math::PIHalf);
452495 double deltaEta = assTrk.etaAssoc () - trigCand.etaTrig ();
@@ -476,7 +519,7 @@ struct HfCorrelatorFlowCharmHadronsReduced {
476519 fillSameEvent<false , true >(pair, trigCand, binPolicyPosZMult);
477520 }
478521 }
479- PROCESS_SWITCH (HfCorrelatorFlowCharmHadronsReduced, processSameEventCharmHadWMultMix, " Process Same Event for Charm-Had with multiplicity pools" , true );
522+ PROCESS_SWITCH (HfCorrelatorFlowCharmHadronsReduced, processSameEventCharmHadWMultMix, " Process Same Event for Charm-Had with multiplicity pools" , false );
480523
481524 void processSameEventHadHadWMultMix (SameEvtPairsHadHad::iterator const & pair,
482525 aod::HfcRedTrigTracks const &,
@@ -595,9 +638,10 @@ struct HfCorrelatorFlowCharmHadronsReduced {
595638 void processCharmTriggers (aod::HfcRedTrigCharms const & trigCands,
596639 aod::HfcRedCorrColls const &)
597640 {
641+
598642 for (const auto & trigCand : trigCands) {
599643 auto collision = trigCand.template hfcRedCorrColl_as <o2::aod::HfcRedCorrColls>();
600- if (collision. centrality () < centralityMin || collision. centrality () > centralityMax ) {
644+ if (! isSelCollision ( collision) ) {
601645 continue ;
602646 }
603647 if (!isSelBdtScoreCut (trigCand, trigCand.ptTrig ())) {
@@ -615,7 +659,7 @@ struct HfCorrelatorFlowCharmHadronsReduced {
615659 BinningCentPosZ binPolicyPosZCent{{zPoolBins, centPoolBins}};
616660
617661 for (const auto & collision : collisions) {
618- if (collision. centrality () < centralityMin || collision. centrality () > centralityMax ) {
662+ if (! isSelCollision ( collision) ) {
619663 continue ;
620664 }
621665 int poolBin = binPolicyPosZCent.getBin ({collision.posZ (), collision.centrality ()});
0 commit comments