@@ -50,6 +50,7 @@ struct HfTaskDplus {
5050 Configurable<std::vector<int >> classMl{" classMl" , {0 , 1 , 2 }, " Indexes of ML scores to be stored. Three indexes max." };
5151 Configurable<bool > storeCentrality{" storeCentrality" , false , " Flag to store centrality information" };
5252 Configurable<bool > storeOccupancy{" storeOccupancy" , false , " Flag to store occupancy information" };
53+ Configurable<bool > fillMcBkgHistos{" fillMcBkgHistos" , false , " Flag to fill and store histograms for MC background" };
5354
5455 HfHelper hfHelper;
5556
@@ -200,7 +201,9 @@ struct HfTaskDplus {
200201 }
201202 registry.add (" hSparseMassPrompt" , " THn for Dplus Prompt" , HistType::kTHnSparseF , axes);
202203 registry.add (" hSparseMassFD" , " THn for Dplus FD" , HistType::kTHnSparseF , axesFD);
203- registry.add (" hSparseMassBkg" , " THn for Dplus Bkg" , HistType::kTHnSparseF , axes);
204+ if (fillMcBkgHistos) {
205+ registry.add (" hSparseMassBkg" , " THn for Dplus Bkg" , HistType::kTHnSparseF , axes);
206+ }
204207 registry.add (" hSparseMassNotMatched" , " THn for Dplus not matched" , HistType::kTHnSparseF , axes);
205208 registry.add (" hSparseMassGenPrompt" , " THn for gen Prompt Dplus" , HistType::kTHnSparseF , axesGenPrompt);
206209 registry.add (" hSparseMassGenFD" , " THn for gen FD Dplus" , HistType::kTHnSparseF , axesGenFD);
@@ -282,15 +285,16 @@ struct HfTaskDplus {
282285 }
283286
284287 } else { // Bkg
285-
286- if (storeCentrality && storeOccupancy) {
287- registry.fill (HIST (" hSparseMassBkg" ), hfHelper.invMassDplusToPiKPi (candidate), candidate.pt (), outputMl[0 ], outputMl[1 ], outputMl[2 ], centrality, occupancy);
288- } else if (storeCentrality && !storeOccupancy) {
289- registry.fill (HIST (" hSparseMassBkg" ), hfHelper.invMassDplusToPiKPi (candidate), candidate.pt (), outputMl[0 ], outputMl[1 ], outputMl[2 ], centrality);
290- } else if (!storeCentrality && storeOccupancy) {
291- registry.fill (HIST (" hSparseMassBkg" ), hfHelper.invMassDplusToPiKPi (candidate), candidate.pt (), outputMl[0 ], outputMl[1 ], outputMl[2 ], occupancy);
292- } else {
293- registry.fill (HIST (" hSparseMassBkg" ), hfHelper.invMassDplusToPiKPi (candidate), candidate.pt (), outputMl[0 ], outputMl[1 ], outputMl[2 ]);
288+ if (fillMcBkgHistos) {
289+ if (storeCentrality && storeOccupancy) {
290+ registry.fill (HIST (" hSparseMassBkg" ), hfHelper.invMassDplusToPiKPi (candidate), candidate.pt (), outputMl[0 ], outputMl[1 ], outputMl[2 ], centrality, occupancy);
291+ } else if (storeCentrality && !storeOccupancy) {
292+ registry.fill (HIST (" hSparseMassBkg" ), hfHelper.invMassDplusToPiKPi (candidate), candidate.pt (), outputMl[0 ], outputMl[1 ], outputMl[2 ], centrality);
293+ } else if (!storeCentrality && storeOccupancy) {
294+ registry.fill (HIST (" hSparseMassBkg" ), hfHelper.invMassDplusToPiKPi (candidate), candidate.pt (), outputMl[0 ], outputMl[1 ], outputMl[2 ], occupancy);
295+ } else {
296+ registry.fill (HIST (" hSparseMassBkg" ), hfHelper.invMassDplusToPiKPi (candidate), candidate.pt (), outputMl[0 ], outputMl[1 ], outputMl[2 ]);
297+ }
294298 }
295299 }
296300 } else {
@@ -482,11 +486,13 @@ struct HfTaskDplus {
482486 fillHistoMCRec<true >(candidate);
483487 }
484488 // Bkg
485- for (const auto & candidate : recoBkgCandidates) {
486- if ((yCandRecoMax >= 0 . && std::abs (hfHelper.yDplus (candidate)) > yCandRecoMax)) {
487- continue ;
489+ if (fillMcBkgHistos) {
490+ for (const auto & candidate : recoBkgCandidates) {
491+ if ((yCandRecoMax >= 0 . && std::abs (hfHelper.yDplus (candidate)) > yCandRecoMax)) {
492+ continue ;
493+ }
494+ fillHistoMCRec<false >(candidate);
488495 }
489- fillHistoMCRec<false >(candidate);
490496 }
491497 } else {
492498 for (const auto & candidate : recoDPlusCandidatesWithMl) {
@@ -513,19 +519,21 @@ struct HfTaskDplus {
513519 // Bkg
514520 ptBhad = -1 ;
515521 flagBHad = -1 ;
516- for (const auto & candidate : recoBkgCandidatesWithMl) {
517- if ((yCandRecoMax >= 0 . && std::abs (hfHelper.yDplus (candidate)) > yCandRecoMax)) {
518- continue ;
519- }
520- auto collision = candidate.template collision_as <McRecoCollisionsCent>();
521- if (storeCentrality && centEstimator != CentralityEstimator::None) {
522- cent = getCentralityColl (collision, centEstimator);
523- }
524- if (storeOccupancy && occEstimator != OccupancyEstimator::None) {
525- occ = getOccupancyColl (collision, occEstimator);
522+ if (fillMcBkgHistos) {
523+ for (const auto & candidate : recoBkgCandidatesWithMl) {
524+ if ((yCandRecoMax >= 0 . && std::abs (hfHelper.yDplus (candidate)) > yCandRecoMax)) {
525+ continue ;
526+ }
527+ auto collision = candidate.template collision_as <McRecoCollisionsCent>();
528+ if (storeCentrality && centEstimator != CentralityEstimator::None) {
529+ cent = getCentralityColl (collision, centEstimator);
530+ }
531+ if (storeOccupancy && occEstimator != OccupancyEstimator::None) {
532+ occ = getOccupancyColl (collision, occEstimator);
533+ }
534+ fillHistoMCRec<false >(candidate);
535+ fillSparseML<true , false >(candidate, ptBhad, flagBHad, cent, occ);
526536 }
527- fillHistoMCRec<false >(candidate);
528- fillSparseML<true , false >(candidate, ptBhad, flagBHad, cent, occ);
529537 }
530538 }
531539 }
0 commit comments