Skip to content

Commit 8c3b8ad

Browse files
committed
make thnAxisProperLifetime optional
1 parent b6ded05 commit 8c3b8ad

File tree

1 file changed

+65
-49
lines changed

1 file changed

+65
-49
lines changed

PWGHF/D2H/Tasks/taskLc.cxx

Lines changed: 65 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ struct HfTaskLc {
6565
Configurable<bool> fillTHn{"fillTHn", false, "fill THn"};
6666
Configurable<bool> storeOccupancy{"storeOccupancy", true, "Flag to store occupancy information"};
6767
Configurable<int> occEstimator{"occEstimator", 2, "Occupancy estimation (None: 0, ITS: 1, FT0C: 2)"};
68+
Configurable<bool> storeProperLifetime{"storeProperLifetime", false, "Flag to store proper lifetime"};
6869

6970
constexpr static float CtToProperLifetimePs = 1.f / o2::constants::physics::LightSpeedCm2PS;
7071
constexpr static float NanoToPico = 1000.f;
@@ -344,22 +345,29 @@ struct HfTaskLc {
344345
axesStd = {thnAxisMass, thnAxisPt, thnAxisCentrality, thnAxisPtProng0, thnAxisPtProng1, thnAxisPtProng2, thnAxisChi2PCA, thnAxisDecLength, thnAxisCPA, thnAxisTracklets, thnAxisPtB, thnAxisCanType};
345346
}
346347
if (isMcStd || isMcWithMl) {
347-
axesGen = {thnAxisPt, thnAxisCentrality, thnAxisY, thnAxisTracklets, thnAxisPtB, thnAxisCanType, thnAxisProperLifetime};
348+
axesGen = {thnAxisPt, thnAxisCentrality, thnAxisY, thnAxisTracklets, thnAxisPtB, thnAxisCanType};
348349
}
349350
if (isDataWithMl) {
350-
axesWithBdt = {thnAxisMass, thnAxisPt, thnAxisCentrality, thnAxisBdtScoreLcBkg, thnAxisBdtScoreLcPrompt, thnAxisBdtScoreLcNonPrompt, thnAxisTracklets, thnAxisProperLifetime};
351+
axesWithBdt = {thnAxisMass, thnAxisPt, thnAxisCentrality, thnAxisBdtScoreLcBkg, thnAxisBdtScoreLcPrompt, thnAxisBdtScoreLcNonPrompt, thnAxisTracklets};
351352
}
352353
if (isMcWithMl) {
353-
axesWithBdt = {thnAxisMass, thnAxisPt, thnAxisCentrality, thnAxisBdtScoreLcBkg, thnAxisBdtScoreLcPrompt, thnAxisBdtScoreLcNonPrompt, thnAxisTracklets, thnAxisPtB, thnAxisCanType, thnAxisProperLifetime};
354+
axesWithBdt = {thnAxisMass, thnAxisPt, thnAxisCentrality, thnAxisBdtScoreLcBkg, thnAxisBdtScoreLcPrompt, thnAxisBdtScoreLcNonPrompt, thnAxisTracklets, thnAxisPtB, thnAxisCanType};
355+
}
356+
357+
if (storeProperLifetime) {
358+
for (const auto& axes : std::array<std::vector<AxisSpec>*, 2>{&axesGen, &axesWithBdt}) {
359+
if (!axes->empty()) {
360+
axes->push_back(thnAxisProperLifetime);
361+
}
362+
}
354363
}
355364

356365
if (storeOccupancy) {
357-
if (!axesWithBdt.empty())
358-
axesWithBdt.push_back(thnAxisOccupancy);
359-
if (!axesStd.empty())
360-
axesStd.push_back(thnAxisOccupancy);
361-
if (!axesGen.empty())
362-
axesGen.push_back(thnAxisOccupancy);
366+
for (const auto& axes : std::array<std::vector<AxisSpec>*, 3>{&axesWithBdt, &axesStd, &axesGen}) {
367+
if (!axes->empty()) {
368+
axes->push_back(thnAxisOccupancy);
369+
}
370+
}
363371
}
364372

365373
if (isDataWithMl) {
@@ -565,21 +573,20 @@ struct HfTaskLc {
565573
outputFD = candidate.mlProbLcToPKPi()[MlClassNonPrompt]; /// non-prompt score
566574
}
567575
/// Fill the ML outputScores and variables of candidate
576+
std::vector<Double_t> valuesToFill{massLc, pt, cent, outputBkg, outputPrompt, outputFD, static_cast<Double_t>(numPvContributors), ptRecB, static_cast<Double_t>(originType)};
577+
if (storeProperLifetime) {
578+
valuesToFill.push_back(properLifetime);
579+
}
568580
if (storeOccupancy && occEstimator != o2::hf_occupancy::OccupancyEstimator::None) {
569-
registry.get<THnSparse>(HIST("hnLcVarsWithBdt"))->Fill(massLc, pt, cent, outputBkg, outputPrompt, outputFD, numPvContributors, ptRecB, originType, properLifetime, occ);
570-
} else {
571-
registry.get<THnSparse>(HIST("hnLcVarsWithBdt"))->Fill(massLc, pt, cent, outputBkg, outputPrompt, outputFD, numPvContributors, ptRecB, originType, properLifetime);
581+
valuesToFill.push_back(occ);
572582
}
573-
583+
registry.get<THnSparse>(HIST("hnLcVarsWithBdt"))->Fill(valuesToFill.data());
574584
} else {
575-
585+
std::vector<Double_t> valuesToFill{massLc, pt, cent, ptProng0, ptProng1, ptProng2, chi2PCA, decayLength, cpa, static_cast<Double_t>(numPvContributors), ptRecB, static_cast<Double_t>(originType)};
576586
if (storeOccupancy && occEstimator != o2::hf_occupancy::OccupancyEstimator::None) {
577-
registry.get<THnSparse>(HIST("hnLcVars"))->Fill(massLc, pt, cent, ptProng0, ptProng1, ptProng2, chi2PCA, decayLength, cpa, numPvContributors, ptRecB, originType, occ);
578-
579-
} else {
580-
581-
registry.get<THnSparse>(HIST("hnLcVars"))->Fill(massLc, pt, cent, ptProng0, ptProng1, ptProng2, chi2PCA, decayLength, cpa, numPvContributors, ptRecB, originType);
587+
valuesToFill.push_back(occ);
582588
}
589+
registry.get<THnSparse>(HIST("hnLcVars"))->Fill(valuesToFill.data());
583590
}
584591
}
585592
if ((candidate.isSelLcToPiKP() >= selectionFlagLc) && pdgCodeProng0 == kPiPlus) {
@@ -592,18 +599,20 @@ struct HfTaskLc {
592599
outputFD = candidate.mlProbLcToPiKP()[MlClassNonPrompt]; /// non-prompt score
593600
}
594601
/// Fill the ML outputScores and variables of candidate (todo: add multiplicity)
602+
std::vector<Double_t> valuesToFill{massLc, pt, cent, outputBkg, outputPrompt, outputFD, static_cast<Double_t>(numPvContributors), ptRecB, static_cast<Double_t>(originType)};
603+
if (storeProperLifetime) {
604+
valuesToFill.push_back(properLifetime);
605+
}
595606
if (storeOccupancy && occEstimator != o2::hf_occupancy::OccupancyEstimator::None) {
596-
registry.get<THnSparse>(HIST("hnLcVarsWithBdt"))->Fill(massLc, pt, cent, outputBkg, outputPrompt, outputFD, numPvContributors, ptRecB, originType, properLifetime, occ);
597-
598-
} else {
599-
registry.get<THnSparse>(HIST("hnLcVarsWithBdt"))->Fill(massLc, pt, cent, outputBkg, outputPrompt, outputFD, numPvContributors, ptRecB, originType, properLifetime);
607+
valuesToFill.push_back(occ);
600608
}
609+
registry.get<THnSparse>(HIST("hnLcVarsWithBdt"))->Fill(valuesToFill.data());
601610
} else {
611+
std::vector<Double_t> valuesToFill{massLc, pt, cent, ptProng0, ptProng1, ptProng2, chi2PCA, decayLength, cpa, static_cast<Double_t>(numPvContributors), ptRecB, static_cast<Double_t>(originType)};
602612
if (storeOccupancy && occEstimator != o2::hf_occupancy::OccupancyEstimator::None) {
603-
registry.get<THnSparse>(HIST("hnLcVars"))->Fill(massLc, pt, cent, ptProng0, ptProng1, ptProng2, chi2PCA, decayLength, cpa, numPvContributors, ptRecB, originType, occ);
604-
} else {
605-
registry.get<THnSparse>(HIST("hnLcVars"))->Fill(massLc, pt, cent, ptProng0, ptProng1, ptProng2, chi2PCA, decayLength, cpa, numPvContributors, ptRecB, originType);
613+
valuesToFill.push_back(occ);
606614
}
615+
registry.get<THnSparse>(HIST("hnLcVars"))->Fill(valuesToFill.data());
607616
}
608617
}
609618
}
@@ -652,12 +661,14 @@ struct HfTaskLc {
652661

653662
if (particle.originMcGen() == RecoDecay::OriginType::Prompt) {
654663
if (fillTHn) {
664+
std::vector<Double_t> valuesToFill{ptGen, cent, yGen, static_cast<Double_t>(numPvContributors), ptGenB, static_cast<Double_t>(originType)};
665+
if (storeProperLifetime) {
666+
valuesToFill.push_back(properLifetime);
667+
}
655668
if (storeOccupancy && occEstimator != o2::hf_occupancy::OccupancyEstimator::None) {
656-
registry.get<THnSparse>(HIST("hnLcVarsGen"))->Fill(ptGen, cent, yGen, numPvContributors, ptGenB, originType, properLifetime, occ);
657-
658-
} else {
659-
registry.get<THnSparse>(HIST("hnLcVarsGen"))->Fill(ptGen, cent, yGen, numPvContributors, ptGenB, originType, properLifetime);
669+
valuesToFill.push_back(occ);
660670
}
671+
registry.get<THnSparse>(HIST("hnLcVarsGen"))->Fill(valuesToFill.data());
661672
}
662673
registry.fill(HIST("MC/generated/prompt/hPtGenPrompt"), ptGen);
663674
registry.fill(HIST("MC/generated/prompt/hEtaGenPrompt"), particle.eta());
@@ -670,12 +681,14 @@ struct HfTaskLc {
670681
if (particle.originMcGen() == RecoDecay::OriginType::NonPrompt) {
671682
ptGenB = mcParticles.rawIteratorAt(particle.idxBhadMotherPart()).pt();
672683
if (fillTHn) {
684+
std::vector<Double_t> valuesToFill{ptGen, cent, yGen, static_cast<Double_t>(numPvContributors), ptGenB, static_cast<Double_t>(originType)};
685+
if (storeProperLifetime) {
686+
valuesToFill.push_back(properLifetime);
687+
}
673688
if (storeOccupancy && occEstimator != o2::hf_occupancy::OccupancyEstimator::None) {
674-
registry.get<THnSparse>(HIST("hnLcVarsGen"))->Fill(ptGen, cent, yGen, numPvContributors, ptGenB, originType, properLifetime, occ);
675-
676-
} else {
677-
registry.get<THnSparse>(HIST("hnLcVarsGen"))->Fill(ptGen, cent, yGen, numPvContributors, ptGenB, originType, properLifetime);
689+
valuesToFill.push_back(occ);
678690
}
691+
registry.get<THnSparse>(HIST("hnLcVarsGen"))->Fill(valuesToFill.data());
679692
}
680693
registry.fill(HIST("MC/generated/nonprompt/hPtGenNonPrompt"), ptGen);
681694
registry.fill(HIST("MC/generated/nonprompt/hEtaGenNonPrompt"), particle.eta());
@@ -777,20 +790,20 @@ struct HfTaskLc {
777790
outputFD = candidate.mlProbLcToPKPi()[MlClassNonPrompt]; /// non-prompt score
778791
}
779792
/// Fill the ML outputScores and variables of candidate
793+
std::vector<Double_t> valuesToFill{massLc, pt, cent, outputBkg, outputPrompt, outputFD, static_cast<Double_t>(numPvContributors)};
794+
if (storeProperLifetime) {
795+
valuesToFill.push_back(properLifetime);
796+
}
780797
if (storeOccupancy && occEstimator != o2::hf_occupancy::OccupancyEstimator::None) {
781-
registry.get<THnSparse>(HIST("hnLcVarsWithBdt"))->Fill(massLc, pt, cent, outputBkg, outputPrompt, outputFD, numPvContributors, properLifetime, occ);
782-
783-
} else {
784-
registry.get<THnSparse>(HIST("hnLcVarsWithBdt"))->Fill(massLc, pt, cent, outputBkg, outputPrompt, outputFD, numPvContributors, properLifetime);
798+
valuesToFill.push_back(occ);
785799
}
800+
registry.get<THnSparse>(HIST("hnLcVarsWithBdt"))->Fill(valuesToFill.data());
786801
} else {
802+
std::vector<Double_t> valuesToFill{massLc, pt, cent, ptProng0, ptProng1, ptProng2, chi2PCA, decayLength, cpa, static_cast<Double_t>(numPvContributors)};
787803
if (storeOccupancy && occEstimator != o2::hf_occupancy::OccupancyEstimator::None) {
788-
789-
registry.get<THnSparse>(HIST("hnLcVars"))->Fill(massLc, pt, cent, ptProng0, ptProng1, ptProng2, chi2PCA, decayLength, cpa, numPvContributors, occ);
790-
} else {
791-
792-
registry.get<THnSparse>(HIST("hnLcVars"))->Fill(massLc, pt, cent, ptProng0, ptProng1, ptProng2, chi2PCA, decayLength, cpa, numPvContributors);
804+
valuesToFill.push_back(occ);
793805
}
806+
registry.get<THnSparse>(HIST("hnLcVars"))->Fill(valuesToFill.data());
794807
}
795808
}
796809
if (candidate.isSelLcToPiKP() >= selectionFlagLc) {
@@ -803,17 +816,20 @@ struct HfTaskLc {
803816
outputFD = candidate.mlProbLcToPiKP()[MlClassNonPrompt]; /// non-prompt score
804817
}
805818
/// Fill the ML outputScores and variables of candidate
819+
std::vector<Double_t> valuesToFill{massLc, pt, cent, outputBkg, outputPrompt, outputFD, static_cast<Double_t>(numPvContributors)};
820+
if (storeProperLifetime) {
821+
valuesToFill.push_back(properLifetime);
822+
}
806823
if (storeOccupancy && occEstimator != o2::hf_occupancy::OccupancyEstimator::None) {
807-
registry.get<THnSparse>(HIST("hnLcVarsWithBdt"))->Fill(massLc, pt, cent, outputBkg, outputPrompt, outputFD, numPvContributors, properLifetime, occ);
808-
} else {
809-
registry.get<THnSparse>(HIST("hnLcVarsWithBdt"))->Fill(massLc, pt, cent, outputBkg, outputPrompt, outputFD, numPvContributors, properLifetime);
824+
valuesToFill.push_back(occ);
810825
}
826+
registry.get<THnSparse>(HIST("hnLcVarsWithBdt"))->Fill(valuesToFill.data());
811827
} else {
828+
std::vector<Double_t> valuesToFill{massLc, pt, cent, ptProng0, ptProng1, ptProng2, chi2PCA, decayLength, cpa, static_cast<Double_t>(numPvContributors)};
812829
if (storeOccupancy && occEstimator != o2::hf_occupancy::OccupancyEstimator::None) {
813-
registry.get<THnSparse>(HIST("hnLcVars"))->Fill(massLc, pt, cent, ptProng0, ptProng1, ptProng2, chi2PCA, decayLength, cpa, numPvContributors, occ);
814-
} else {
815-
registry.get<THnSparse>(HIST("hnLcVars"))->Fill(massLc, pt, cent, ptProng0, ptProng1, ptProng2, chi2PCA, decayLength, cpa, numPvContributors);
830+
valuesToFill.push_back(occ);
816831
}
832+
registry.get<THnSparse>(HIST("hnLcVars"))->Fill(valuesToFill.data());
817833
}
818834
}
819835
}

0 commit comments

Comments
 (0)