Skip to content

Commit 6358059

Browse files
[PWGHF] Add MC Generated ThnSparse in Lc task (#8887)
1 parent c9e57b7 commit 6358059

File tree

1 file changed

+46
-15
lines changed

1 file changed

+46
-15
lines changed

PWGHF/D2H/Tasks/taskLc.cxx

Lines changed: 46 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ struct HfTaskLc {
5353
ConfigurableAxis thnConfigAxisBdtScoreBkg{"thnConfigAxisBdtScoreBkg", {1000, 0., 1.}, ""};
5454
ConfigurableAxis thnConfigAxisBdtScoreSignal{"thnConfigAxisBdtScoreSignal", {100, 0., 1.}, ""};
5555
ConfigurableAxis thnConfigAxisCanType{"thnConfigAxisCanType", {5, 0., 5.}, ""};
56+
ConfigurableAxis thnAxisRapidity{"thnAxisRapidity", {20, -1, 1}, "Cand. rapidity bins"};
57+
ConfigurableAxis thnConfigAxisGenPtB{"thnConfigAxisGenPtB", {1000, 0, 100}, "Gen Pt B"};
58+
ConfigurableAxis thnConfigAxisNumPvContr{"thnConfigAxisNumPvContr", {200, -0.5, 199.5}, "Number of PV contributors"};
5659

5760
HfHelper hfHelper;
5861

@@ -70,7 +73,7 @@ struct HfTaskLc {
7073
using LcCandidatesMlMc = soa::Filtered<soa::Join<aod::HfCand3Prong, aod::HfSelLc, aod::HfMlLcToPKPi, aod::HfCand3ProngMcRec>>;
7174
using McParticles3ProngMatched = soa::Join<aod::McParticles, aod::HfCand3ProngMcGen>;
7275
Filter filterSelectCandidates = aod::hf_sel_candidate_lc::isSelLcToPKPi >= selectionFlagLc || aod::hf_sel_candidate_lc::isSelLcToPiKP >= selectionFlagLc;
73-
Preslice<aod::McParticles> perMcCollision = aod::mcparticle::mcCollisionId;
76+
PresliceUnsorted<aod::McCollisionLabels> colPerMcCollision = aod::mcparticle::mcCollisionId;
7477
Preslice<aod::HfCand3Prong> candLcPerCollision = aod::hf_cand::collisionId;
7578
SliceCache cache;
7679

@@ -286,11 +289,25 @@ struct HfTaskLc {
286289
const AxisSpec thnAxisBdtScoreLcPrompt{thnConfigAxisBdtScoreSignal, "BDT prompt score (Lc)"};
287290
const AxisSpec thnAxisBdtScoreLcNonPrompt{thnConfigAxisBdtScoreSignal, "BDT non-prompt score (Lc)"};
288291
const AxisSpec thnAxisCanType{thnConfigAxisCanType, "candidates type"};
292+
const AxisSpec thnAxisY{thnAxisRapidity, "rapidity"};
293+
const AxisSpec thnAxisPtB{thnConfigAxisGenPtB, "#it{p}_{T}^{B} (GeV/#it{c})"};
294+
const AxisSpec thnAxisTracklets{thnConfigAxisNumPvContr, "Number of PV contributors"};
295+
296+
if (doprocessDataWithMl || doprocessDataWithMlWithFT0C || doprocessDataWithMlWithFT0M) {
297+
298+
registry.add("hnLcVarsWithBdt", "THn for Lambdac candidates with BDT scores for data with ML", HistType::kTHnSparseF, {thnAxisMass, thnAxisPt, thnAxisCentrality, thnAxisBdtScoreLcBkg, thnAxisBdtScoreLcPrompt, thnAxisBdtScoreLcNonPrompt, thnAxisTracklets});
299+
300+
} else if (doprocessMcWithMl || doprocessMcWithMlWithFT0C || doprocessMcWithMlWithFT0M) {
301+
302+
registry.add("hnLcVarsWithBdt", "THn for Lambdac candidates with BDT scores for mc with ML", HistType::kTHnSparseF, {thnAxisMass, thnAxisPt, thnAxisCentrality, thnAxisBdtScoreLcBkg, thnAxisBdtScoreLcPrompt, thnAxisBdtScoreLcNonPrompt, thnAxisTracklets, thnAxisPtB, thnAxisCanType});
303+
registry.add("hnLcVarsGen", "THn for Generated Lambdac", HistType::kTHnSparseF, {thnAxisPt, thnAxisY, thnAxisTracklets, thnAxisPtB, thnAxisCanType});
304+
305+
} else if (doprocessDataStd || doprocessDataStdWithFT0C || doprocessDataStdWithFT0M) {
306+
registry.add("hnLcVars", "THn for Reconstructed Lambdac candidates for data without ML", HistType::kTHnSparseF, {thnAxisMass, thnAxisPt, thnAxisCentrality, thnAxisPtProng0, thnAxisPtProng1, thnAxisPtProng2, thnAxisChi2PCA, thnAxisDecLength, thnAxisCPA, thnAxisTracklets});
289307

290-
if (doprocessDataWithMl || doprocessDataWithMlWithFT0C || doprocessDataWithMlWithFT0M || doprocessMcWithMl || doprocessMcWithMlWithFT0C || doprocessMcWithMlWithFT0M) {
291-
registry.add("hnLcVarsWithBdt", "THn for Lambdac candidates with BDT scores", HistType::kTHnSparseF, {thnAxisMass, thnAxisPt, thnAxisCentrality, thnAxisBdtScoreLcBkg, thnAxisBdtScoreLcPrompt, thnAxisBdtScoreLcNonPrompt, thnAxisCanType});
292308
} else {
293-
registry.add("hnLcVars", "THn for Lambdac candidates", HistType::kTHnSparseF, {thnAxisMass, thnAxisPt, thnAxisCentrality, thnAxisPtProng0, thnAxisPtProng1, thnAxisPtProng2, thnAxisChi2PCA, thnAxisDecLength, thnAxisCPA, thnAxisCanType});
309+
registry.add("hnLcVars", "THn for Reconstructed Lambdac candidates for mc without ML", HistType::kTHnSparseF, {thnAxisMass, thnAxisPt, thnAxisCentrality, thnAxisPtProng0, thnAxisPtProng1, thnAxisPtProng2, thnAxisChi2PCA, thnAxisDecLength, thnAxisCPA, thnAxisTracklets, thnAxisPtB, thnAxisCanType});
310+
registry.add("hnLcVarsGen", "THn for Generated Lambdac", HistType::kTHnSparseF, {thnAxisPt, thnAxisY, thnAxisTracklets, thnAxisPtB, thnAxisCanType});
294311
}
295312
}
296313
}
@@ -341,6 +358,9 @@ struct HfTaskLc {
341358
auto cpa = candidate.cpa();
342359
auto cpaXY = candidate.cpaXY();
343360
auto originType = candidate.originMcRec();
361+
auto numPvContributors = collision.numContrib();
362+
auto ptRecB = candidate.ptBhadMotherPart();
363+
344364
/// MC reconstructed signal
345365
if ((candidate.isSelLcToPKPi() >= selectionFlagLc) && pdgCodeProng0 == kProton) {
346366
registry.fill(HIST("MC/reconstructed/signal/hMassRecSig"), hfHelper.invMassLcToPKPi(candidate));
@@ -476,9 +496,9 @@ struct HfTaskLc {
476496
outputFD = candidate.mlProbLcToPKPi()[2]; /// non-prompt score
477497
}
478498
/// Fill the ML outputScores and variables of candidate
479-
registry.get<THnSparse>(HIST("hnLcVarsWithBdt"))->Fill(massLc, pt, cent, outputBkg, outputPrompt, outputFD, originType);
499+
registry.get<THnSparse>(HIST("hnLcVarsWithBdt"))->Fill(massLc, pt, cent, outputBkg, outputPrompt, outputFD, numPvContributors, ptRecB, originType);
480500
} else {
481-
registry.get<THnSparse>(HIST("hnLcVars"))->Fill(massLc, pt, cent, ptProng0, ptProng1, ptProng2, chi2PCA, decayLength, cpa, originType);
501+
registry.get<THnSparse>(HIST("hnLcVars"))->Fill(massLc, pt, cent, ptProng0, ptProng1, ptProng2, chi2PCA, decayLength, cpa, numPvContributors, ptRecB, originType);
482502
}
483503
}
484504
if ((candidate.isSelLcToPiKP() >= selectionFlagLc) && pdgCodeProng0 == kPiPlus) {
@@ -491,9 +511,9 @@ struct HfTaskLc {
491511
outputFD = candidate.mlProbLcToPiKP()[2]; /// non-prompt score
492512
}
493513
/// Fill the ML outputScores and variables of candidate (todo: add multiplicity)
494-
registry.get<THnSparse>(HIST("hnLcVarsWithBdt"))->Fill(massLc, pt, cent, outputBkg, outputPrompt, outputFD, originType);
514+
registry.get<THnSparse>(HIST("hnLcVarsWithBdt"))->Fill(massLc, pt, cent, outputBkg, outputPrompt, outputFD, numPvContributors, ptRecB, originType);
495515
} else {
496-
registry.get<THnSparse>(HIST("hnLcVars"))->Fill(massLc, pt, cent, ptProng0, ptProng1, ptProng2, chi2PCA, decayLength, cpa, originType);
516+
registry.get<THnSparse>(HIST("hnLcVars"))->Fill(massLc, pt, cent, ptProng0, ptProng1, ptProng2, chi2PCA, decayLength, cpa, numPvContributors, ptRecB, originType);
497517
}
498518
}
499519
}
@@ -503,8 +523,8 @@ struct HfTaskLc {
503523

504524
/// Fill MC histograms at generated level
505525
/// \tparam fillMl switch to fill ML histograms
506-
template <typename CandLcMcGen>
507-
void fillHistosMcGen(CandLcMcGen const& mcParticles)
526+
template <typename CandLcMcGen, typename Coll>
527+
void fillHistosMcGen(CandLcMcGen const& mcParticles, Coll const& recoCollisions)
508528
{
509529
// MC gen.
510530
for (const auto& particle : mcParticles) {
@@ -514,6 +534,14 @@ struct HfTaskLc {
514534
continue;
515535
}
516536
auto ptGen = particle.pt();
537+
auto originType = particle.originMcGen();
538+
auto ptGenB = -1;
539+
unsigned int numPvContributors = 0;
540+
const auto& recoCollsPerMcColl = recoCollisions.sliceBy(colPerMcCollision, particle.mcCollision().globalIndex());
541+
for (const auto& recCol : recoCollsPerMcColl) {
542+
numPvContributors = recCol.numContrib() > numPvContributors ? recCol.numContrib() : numPvContributors;
543+
}
544+
517545
registry.fill(HIST("MC/generated/signal/hPtGen"), ptGen);
518546
registry.fill(HIST("MC/generated/signal/hEtaGen"), particle.eta());
519547
registry.fill(HIST("MC/generated/signal/hYGen"), yGen);
@@ -523,6 +551,7 @@ struct HfTaskLc {
523551
registry.fill(HIST("MC/generated/signal/hPhiVsPtGenSig"), particle.phi(), ptGen);
524552

525553
if (particle.originMcGen() == RecoDecay::OriginType::Prompt) {
554+
registry.get<THnSparse>(HIST("hnLcVarsGen"))->Fill(ptGen, yGen, numPvContributors, ptGenB, originType);
526555
registry.fill(HIST("MC/generated/prompt/hPtGenPrompt"), ptGen);
527556
registry.fill(HIST("MC/generated/prompt/hEtaGenPrompt"), particle.eta());
528557
registry.fill(HIST("MC/generated/prompt/hYGenPrompt"), yGen);
@@ -532,6 +561,8 @@ struct HfTaskLc {
532561
registry.fill(HIST("MC/generated/prompt/hPhiVsPtGenSigPrompt"), particle.phi(), ptGen);
533562
}
534563
if (particle.originMcGen() == RecoDecay::OriginType::NonPrompt) {
564+
ptGenB = mcParticles.rawIteratorAt(particle.idxBhadMotherPart()).pt();
565+
registry.get<THnSparse>(HIST("hnLcVarsGen"))->Fill(ptGen, yGen, numPvContributors, ptGenB, originType);
535566
registry.fill(HIST("MC/generated/nonprompt/hPtGenNonPrompt"), ptGen);
536567
registry.fill(HIST("MC/generated/nonprompt/hEtaGenNonPrompt"), particle.eta());
537568
registry.fill(HIST("MC/generated/nonprompt/hYGenNonPrompt"), yGen);
@@ -627,9 +658,9 @@ struct HfTaskLc {
627658
outputFD = candidate.mlProbLcToPKPi()[2]; /// non-prompt score
628659
}
629660
/// Fill the ML outputScores and variables of candidate
630-
registry.get<THnSparse>(HIST("hnLcVarsWithBdt"))->Fill(massLc, pt, cent, outputBkg, outputPrompt, outputFD, 0);
661+
registry.get<THnSparse>(HIST("hnLcVarsWithBdt"))->Fill(massLc, pt, cent, outputBkg, outputPrompt, outputFD, numPvContributors);
631662
} else {
632-
registry.get<THnSparse>(HIST("hnLcVars"))->Fill(massLc, pt, cent, ptProng0, ptProng1, ptProng2, chi2PCA, decayLength, cpa, 0);
663+
registry.get<THnSparse>(HIST("hnLcVars"))->Fill(massLc, pt, cent, ptProng0, ptProng1, ptProng2, chi2PCA, decayLength, cpa, numPvContributors);
633664
}
634665
}
635666
if (candidate.isSelLcToPiKP() >= selectionFlagLc) {
@@ -642,9 +673,9 @@ struct HfTaskLc {
642673
outputFD = candidate.mlProbLcToPiKP()[2]; /// non-prompt score
643674
}
644675
/// Fill the ML outputScores and variables of candidate
645-
registry.get<THnSparse>(HIST("hnLcVarsWithBdt"))->Fill(massLc, pt, cent, outputBkg, outputPrompt, outputFD, 0);
676+
registry.get<THnSparse>(HIST("hnLcVarsWithBdt"))->Fill(massLc, pt, cent, outputBkg, outputPrompt, outputFD, numPvContributors);
646677
} else {
647-
registry.get<THnSparse>(HIST("hnLcVars"))->Fill(massLc, pt, cent, ptProng0, ptProng1, ptProng2, chi2PCA, decayLength, cpa, 0);
678+
registry.get<THnSparse>(HIST("hnLcVars"))->Fill(massLc, pt, cent, ptProng0, ptProng1, ptProng2, chi2PCA, decayLength, cpa, numPvContributors);
648679
}
649680
}
650681
}
@@ -675,7 +706,7 @@ struct HfTaskLc {
675706
fillHistosMcRec<fillMl>(collision, candidates, mcParticles);
676707
}
677708
// MC gen.
678-
fillHistosMcGen(mcParticles);
709+
fillHistosMcGen(mcParticles, collisions);
679710
}
680711

681712
void processDataStd(Collisions const& collisions,

0 commit comments

Comments
 (0)