4444
4545#include < Rtypes.h>
4646
47+ #include < algorithm>
4748#include < array>
4849#include < cstdint>
4950#include < cstdlib>
@@ -69,6 +70,7 @@ struct HfTaskDplus {
6970 Configurable<std::vector<int >> classMl{" classMl" , {0 , 1 , 2 }, " Indexes of ML scores to be stored. Three indexes max." };
7071 Configurable<bool > storeCentrality{" storeCentrality" , false , " Flag to store centrality information" };
7172 Configurable<bool > storeOccupancy{" storeOccupancy" , false , " Flag to store occupancy information" };
73+ Configurable<bool > storePvContributors{" storePvContributors" , false , " Flag to store number of PV contributors information" };
7274 Configurable<bool > fillMcBkgHistos{" fillMcBkgHistos" , false , " Flag to fill and store histograms for MC background" };
7375
7476 HfHelper hfHelper;
@@ -102,6 +104,7 @@ struct HfTaskDplus {
102104 ConfigurableAxis thnConfigAxisY{" thnConfigAxisY" , {40 , -1 , 1 }, " Cand. rapidity bins" };
103105 ConfigurableAxis thnConfigAxisCent{" thnConfigAxisCent" , {110 , 0 ., 110 .}, " axis for centrality" };
104106 ConfigurableAxis thnConfigAxisOccupancy{" thnConfigAxisOccupancy" , {14 , 0 , 14000 }, " axis for occupancy" };
107+ ConfigurableAxis thnConfigAxisPvContributors{" thnConfigAxisPvContributors" , {100 , 0 ., 100 .}, " axis for PV contributors" };
105108 ConfigurableAxis thnConfigAxisPtBHad{" thnConfigAxisPtBHad" , {25 , 0 ., 50 }, " axis for pt of B hadron decayed into D candidate" };
106109 ConfigurableAxis thnConfigAxisFlagBHad{" thnConfigAxisFlagBHad" , {5 , 0 ., 5 }, " axis for PDG of B hadron" };
107110 ConfigurableAxis thnConfigAxisMlScore0{" thnConfigAxisMlScore0" , {100 , 0 ., 1 .}, " axis for ML output score 0" };
@@ -137,6 +140,7 @@ struct HfTaskDplus {
137140 AxisSpec thnAxisFlagBHad{thnConfigAxisFlagBHad, " B Hadron flag" };
138141 AxisSpec thnAxisCent{thnConfigAxisCent, " Centrality" };
139142 AxisSpec thnAxisOccupancy{thnConfigAxisOccupancy, " Occupancy" };
143+ AxisSpec thnAxisPvContributors{thnConfigAxisPvContributors, " PV contributors" };
140144
141145 registry.add (" hMass" , " 3-prong candidates;inv. mass (#pi K #pi) (GeV/#it{c}^{2});entries" , {HistType::kTH2F , {{350 , 1.7 , 2.05 }, {vbins, " #it{p}_{T} (GeV/#it{c})" }}});
142146 registry.add (" hEta" , " 3-prong candidates;candidate #it{#eta};entries" , {HistType::kTH2F , {{100 , -2 ., 2 .}, {vbins, " #it{p}_{T} (GeV/#it{c})" }}});
@@ -180,13 +184,15 @@ struct HfTaskDplus {
180184 std::vector<AxisSpec> axes = {thnAxisMass, thnAxisPt};
181185
182186 if (doprocessDataWithMl) {
183- axes.insert (axes.end (), {thnAxisMlScore0, thnAxisMlScore1, thnAxisMlScore2});
187+ axes.push_back (thnAxisMlScore0);
188+ axes.push_back (thnAxisMlScore1);
189+ axes.push_back (thnAxisMlScore2);
184190 }
185191 if (storeCentrality) {
186- axes.insert (axes. end (), { thnAxisCent} );
192+ axes.push_back ( thnAxisCent);
187193 }
188194 if (storeOccupancy) {
189- axes.insert (axes. end (), { thnAxisOccupancy} );
195+ axes.push_back ( thnAxisOccupancy);
190196 }
191197
192198 registry.add (" hSparseMass" , " THn for Dplus" , HistType::kTHnSparseF , axes);
@@ -202,22 +208,28 @@ struct HfTaskDplus {
202208 axesFD.insert (axesFD.end (), {thnAxisMlScore0, thnAxisMlScore1, thnAxisMlScore2});
203209 }
204210 if (storeCentrality) {
205- axes.insert (axes. end (), { thnAxisCent} );
206- axesFD.insert (axesFD. end (), { thnAxisCent} );
207- axesGenPrompt.insert (axesGenPrompt. end (), { thnAxisCent} );
208- axesGenFD.insert (axesGenFD. end (), { thnAxisCent} );
211+ axes.push_back ( thnAxisCent);
212+ axesFD.push_back ( thnAxisCent);
213+ axesGenPrompt.push_back ( thnAxisCent);
214+ axesGenFD.push_back ( thnAxisCent);
209215 }
210216 if (storeOccupancy) {
211- axes.insert (axes.end (), {thnAxisOccupancy});
212- axesFD.insert (axesFD.end (), {thnAxisOccupancy});
213- axesGenPrompt.insert (axesGenPrompt.end (), {thnAxisOccupancy});
214- axesGenFD.insert (axesGenFD.end (), {thnAxisOccupancy});
217+ axes.push_back (thnAxisOccupancy);
218+ axesFD.push_back (thnAxisOccupancy);
219+ axesGenPrompt.push_back (thnAxisOccupancy);
220+ axesGenFD.push_back (thnAxisOccupancy);
221+ }
222+ if (storePvContributors) {
223+ axes.push_back (thnAxisPvContributors);
224+ axesFD.push_back (thnAxisPvContributors);
225+ axesGenPrompt.push_back (thnAxisPvContributors);
226+ axesGenFD.push_back (thnAxisPvContributors);
215227 }
216228
217- axesFD.insert (axesFD. end (), { thnAxisPtBHad} );
218- axesFD.insert (axesFD. end (), { thnAxisFlagBHad} );
219- axesGenFD.insert (axesGenFD. end (), { thnAxisPtBHad} );
220- axesGenFD.insert (axesGenFD. end (), { thnAxisFlagBHad} );
229+ axesFD.push_back ( thnAxisPtBHad);
230+ axesFD.push_back ( thnAxisFlagBHad);
231+ axesGenFD.push_back ( thnAxisPtBHad);
232+ axesGenFD.push_back ( thnAxisFlagBHad);
221233
222234 registry.add (" hSparseMassPrompt" , " THn for Dplus Prompt" , HistType::kTHnSparseF , axes);
223235 registry.add (" hSparseMassFD" , " THn for Dplus FD" , HistType::kTHnSparseF , axesFD);
@@ -267,12 +279,14 @@ struct HfTaskDplus {
267279 // / \param flagBHad transverse momentum of beauty mother for nonprompt candidates
268280 // / \param centrality collision centrality
269281 // / \param occupancy collision occupancy
282+ // / \param numPvContributors contributors to the PV
270283 template <bool isMc, bool isMatched, typename T1>
271284 void fillSparseML (const T1& candidate,
272285 float ptbhad,
273286 int flagBHad,
274287 float centrality,
275- float occupancy)
288+ float occupancy,
289+ float numPvContributors)
276290 {
277291 std::vector<float > outputMl = {-999 ., -999 ., -999 .};
278292 for (unsigned int iclass = 0 ; iclass < classMl->size (); iclass++) {
@@ -288,6 +302,8 @@ struct HfTaskDplus {
288302 registry.fill (HIST (" hSparseMassPrompt" ), hfHelper.invMassDplusToPiKPi (candidate), candidate.pt (), outputMl[0 ], outputMl[1 ], outputMl[2 ], centrality);
289303 } else if (!storeCentrality && storeOccupancy) {
290304 registry.fill (HIST (" hSparseMassPrompt" ), hfHelper.invMassDplusToPiKPi (candidate), candidate.pt (), outputMl[0 ], outputMl[1 ], outputMl[2 ], occupancy);
305+ } else if (!storeCentrality && !storeOccupancy && storePvContributors) {
306+ registry.fill (HIST (" hSparseMassPrompt" ), hfHelper.invMassDplusToPiKPi (candidate), candidate.pt (), outputMl[0 ], outputMl[1 ], outputMl[2 ], numPvContributors);
291307 } else {
292308 registry.fill (HIST (" hSparseMassPrompt" ), hfHelper.invMassDplusToPiKPi (candidate), candidate.pt (), outputMl[0 ], outputMl[1 ], outputMl[2 ]);
293309 }
@@ -300,6 +316,8 @@ struct HfTaskDplus {
300316 registry.fill (HIST (" hSparseMassFD" ), hfHelper.invMassDplusToPiKPi (candidate), candidate.pt (), outputMl[0 ], outputMl[1 ], outputMl[2 ], centrality, ptbhad, flagBHad);
301317 } else if (!storeCentrality && storeOccupancy) {
302318 registry.fill (HIST (" hSparseMassFD" ), hfHelper.invMassDplusToPiKPi (candidate), candidate.pt (), outputMl[0 ], outputMl[1 ], outputMl[2 ], occupancy, ptbhad, flagBHad);
319+ } else if (!storeCentrality && !storeOccupancy && storePvContributors) {
320+ registry.fill (HIST (" hSparseMassFD" ), hfHelper.invMassDplusToPiKPi (candidate), candidate.pt (), outputMl[0 ], outputMl[1 ], outputMl[2 ], numPvContributors);
303321 } else {
304322 registry.fill (HIST (" hSparseMassFD" ), hfHelper.invMassDplusToPiKPi (candidate), candidate.pt (), outputMl[0 ], outputMl[1 ], outputMl[2 ], ptbhad, flagBHad);
305323 }
@@ -312,6 +330,8 @@ struct HfTaskDplus {
312330 registry.fill (HIST (" hSparseMassBkg" ), hfHelper.invMassDplusToPiKPi (candidate), candidate.pt (), outputMl[0 ], outputMl[1 ], outputMl[2 ], centrality);
313331 } else if (!storeCentrality && storeOccupancy) {
314332 registry.fill (HIST (" hSparseMassBkg" ), hfHelper.invMassDplusToPiKPi (candidate), candidate.pt (), outputMl[0 ], outputMl[1 ], outputMl[2 ], occupancy);
333+ } else if (!storeCentrality && !storeOccupancy && storePvContributors) {
334+ registry.fill (HIST (" hSparseMassBkg" ), hfHelper.invMassDplusToPiKPi (candidate), candidate.pt (), outputMl[0 ], outputMl[1 ], outputMl[2 ], numPvContributors);
315335 } else {
316336 registry.fill (HIST (" hSparseMassBkg" ), hfHelper.invMassDplusToPiKPi (candidate), candidate.pt (), outputMl[0 ], outputMl[1 ], outputMl[2 ]);
317337 }
@@ -324,6 +344,8 @@ struct HfTaskDplus {
324344 registry.fill (HIST (" hSparseMassNotMatched" ), hfHelper.invMassDplusToPiKPi (candidate), candidate.pt (), outputMl[0 ], outputMl[1 ], outputMl[2 ], centrality);
325345 } else if (!storeCentrality && storeOccupancy) {
326346 registry.fill (HIST (" hSparseMassNotMatched" ), hfHelper.invMassDplusToPiKPi (candidate), candidate.pt (), outputMl[0 ], outputMl[1 ], outputMl[2 ], occupancy);
347+ } else if (!storeCentrality && !storeOccupancy && storePvContributors) {
348+ registry.fill (HIST (" hSparseMassNotMatched" ), hfHelper.invMassDplusToPiKPi (candidate), candidate.pt (), outputMl[0 ], outputMl[1 ], outputMl[2 ], numPvContributors);
327349 } else {
328350 registry.fill (HIST (" hSparseMassNotMatched" ), hfHelper.invMassDplusToPiKPi (candidate), candidate.pt (), outputMl[0 ], outputMl[1 ], outputMl[2 ]);
329351 }
@@ -335,6 +357,8 @@ struct HfTaskDplus {
335357 registry.fill (HIST (" hSparseMass" ), hfHelper.invMassDplusToPiKPi (candidate), candidate.pt (), outputMl[0 ], outputMl[1 ], outputMl[2 ], centrality);
336358 } else if (!storeCentrality && storeOccupancy) {
337359 registry.fill (HIST (" hSparseMass" ), hfHelper.invMassDplusToPiKPi (candidate), candidate.pt (), outputMl[0 ], outputMl[1 ], outputMl[2 ], occupancy);
360+ } else if (!storeCentrality && !storeOccupancy && storePvContributors) {
361+ registry.fill (HIST (" hSparseMass" ), hfHelper.invMassDplusToPiKPi (candidate), candidate.pt (), outputMl[0 ], outputMl[1 ], outputMl[2 ], numPvContributors);
338362 } else {
339363 registry.fill (HIST (" hSparseMass" ), hfHelper.invMassDplusToPiKPi (candidate), candidate.pt (), outputMl[0 ], outputMl[1 ], outputMl[2 ]);
340364 }
@@ -416,12 +440,14 @@ struct HfTaskDplus {
416440 // / \param flagGenB transverse momentum of beauty mother for nonprompt candidates
417441 // / \param centrality collision centrality
418442 // / \param occupancy collision occupancy
443+ // / \param numPvContributors contributors to the PV
419444 template <typename T1>
420445 void fillSparseMcGen (const T1& particle,
421446 float ptGenB,
422447 int flagGenB,
423448 float centrality,
424- float occupancy)
449+ float occupancy,
450+ float numPvContributors)
425451 {
426452 auto yGen = RecoDecay::y (particle.pVector (), o2::constants::physics::MassDPlus);
427453 if (particle.originMcGen () == RecoDecay::OriginType::Prompt) {
@@ -431,6 +457,8 @@ struct HfTaskDplus {
431457 registry.fill (HIST (" hSparseMassGenPrompt" ), particle.pt (), yGen, centrality);
432458 } else if (!storeCentrality && storeOccupancy) {
433459 registry.fill (HIST (" hSparseMassGenPrompt" ), particle.pt (), yGen, occupancy);
460+ } else if (!storeCentrality && !storeOccupancy && storePvContributors) {
461+ registry.fill (HIST (" hSparseMassGenPrompt" ), particle.pt (), yGen, numPvContributors);
434462 } else {
435463 registry.fill (HIST (" hSparseMassGenPrompt" ), particle.pt (), yGen);
436464 }
@@ -441,6 +469,8 @@ struct HfTaskDplus {
441469 registry.fill (HIST (" hSparseMassGenFD" ), particle.pt (), yGen, centrality, ptGenB, flagGenB);
442470 } else if (!storeCentrality && storeOccupancy) {
443471 registry.fill (HIST (" hSparseMassGenFD" ), particle.pt (), yGen, occupancy, ptGenB, flagGenB);
472+ } else if (!storeCentrality && !storeOccupancy && storePvContributors) {
473+ registry.fill (HIST (" hSparseMassGenFD" ), particle.pt (), yGen, numPvContributors, ptGenB, flagGenB);
444474 } else {
445475 registry.fill (HIST (" hSparseMassGenFD" ), particle.pt (), yGen, ptGenB, flagGenB);
446476 }
@@ -454,6 +484,7 @@ struct HfTaskDplus {
454484 {
455485 float cent{-1 .f };
456486 float occ{-1 .f };
487+ float numPvContr{-1 .f };
457488 float ptBhad{-1 .f };
458489 int flagBHad{-1 };
459490 if constexpr (!fillMl) {
@@ -477,10 +508,13 @@ struct HfTaskDplus {
477508 if (storeOccupancy && occEstimator != OccupancyEstimator::None) {
478509 occ = getOccupancyColl (collision, occEstimator);
479510 }
511+ if (storePvContributors) {
512+ numPvContr = collision.numContrib ();
513+ }
480514 }
481515
482516 fillHisto (candidate);
483- fillSparseML<false , false >(candidate, ptBhad, flagBHad, cent, occ);
517+ fillSparseML<false , false >(candidate, ptBhad, flagBHad, cent, occ, numPvContr );
484518 }
485519 }
486520 }
@@ -493,6 +527,7 @@ struct HfTaskDplus {
493527 {
494528 float cent{-1 };
495529 float occ{-1 };
530+ float numPvContr{-1 };
496531 float ptBhad{-1 };
497532 int flagBHad{-1 };
498533
@@ -530,11 +565,14 @@ struct HfTaskDplus {
530565 if (storeOccupancy && occEstimator != OccupancyEstimator::None) {
531566 occ = getOccupancyColl (collision, occEstimator);
532567 }
568+ if (storePvContributors) {
569+ numPvContr = collision.numContrib ();
570+ }
533571 }
534572
535573 fillHisto (candidate);
536574 fillHistoMCRec<true >(candidate);
537- fillSparseML<true , true >(candidate, ptBhad, flagBHad, cent, occ);
575+ fillSparseML<true , true >(candidate, ptBhad, flagBHad, cent, occ, numPvContr );
538576 }
539577 // Bkg
540578 ptBhad = -1 ;
@@ -551,8 +589,11 @@ struct HfTaskDplus {
551589 if (storeOccupancy && occEstimator != OccupancyEstimator::None) {
552590 occ = getOccupancyColl (collision, occEstimator);
553591 }
592+ if (storePvContributors) {
593+ numPvContr = collision.numContrib ();
594+ }
554595 fillHistoMCRec<false >(candidate);
555- fillSparseML<true , false >(candidate, ptBhad, flagBHad, cent, occ);
596+ fillSparseML<true , false >(candidate, ptBhad, flagBHad, cent, occ, numPvContr );
556597 }
557598 }
558599 }
@@ -570,6 +611,7 @@ struct HfTaskDplus {
570611 // MC gen.
571612 float cent{-1 .};
572613 float occ{-1 .};
614+ float numPvContr{-1 .};
573615 float ptGenB{-1 .};
574616 int flagGenB{-1 };
575617
@@ -586,6 +628,7 @@ struct HfTaskDplus {
586628 for (const auto & particle : mcParticlesPerGenMcColl) {
587629 ptGenB = -1 ;
588630 flagGenB = -1 ;
631+ numPvContr = -1 ;
589632 auto yGen = RecoDecay::y (particle.pVector (), o2::constants::physics::MassDPlus);
590633 if ((yCandGenMax >= 0 . && std::abs (yGen) > yCandGenMax) || (std::abs (particle.flagMcMatchGen ()) != hf_decay::hf_cand_3prong::DecayChannelMain::DplusToPiKPi)) {
591634 continue ;
@@ -595,9 +638,12 @@ struct HfTaskDplus {
595638 flagGenB = getBHadMotherFlag (bHadMother.pdgCode ());
596639 ptGenB = bHadMother.pt ();
597640 }
641+ for (const auto & recCol : mcRecoCollisions) {
642+ numPvContr = std::max<float >(numPvContr, recCol.numContrib ());
643+ }
598644 fillHistoMCGen (particle);
599645 if constexpr (fillMl) {
600- fillSparseMcGen (particle, ptGenB, flagGenB, cent, occ);
646+ fillSparseMcGen (particle, ptGenB, flagGenB, cent, occ, numPvContr );
601647 }
602648 }
603649 }
0 commit comments