Skip to content

Commit f2f791e

Browse files
committed
bugfix: check mlProb vector size for correct PKPi/PiKP hypothesis
1 parent ffd89db commit f2f791e

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

PWGHF/D2H/Tasks/taskLc.cxx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -462,18 +462,18 @@ struct HfTaskLc {
462462
if (storeOccupancy && occEstimator != o2::hf_occupancy::OccupancyEstimator::None) {
463463
occ = o2::hf_occupancy::getOccupancyColl(collision, occEstimator);
464464
}
465-
double massLc(-1);
466465
double outputBkg(-1), outputPrompt(-1), outputFD(-1);
467466
const float properLifetime = HfHelper::ctLc(candidate) * CtToProperLifetimePs;
468467

469468
auto fillTHnRecSig = [&](bool isPKPi) {
470-
massLc = isPKPi ? HfHelper::invMassLcToPKPi(candidate) : HfHelper::invMassLcToPiKP(candidate);
469+
const auto massLc = isPKPi ? HfHelper::invMassLcToPKPi(candidate) : HfHelper::invMassLcToPiKP(candidate);
471470

472471
if constexpr (FillMl) {
473-
if (candidate.mlProbLcToPKPi().size() == NumberOfMlClasses) {
474-
outputBkg = isPKPi ? candidate.mlProbLcToPKPi()[MlClassBackground] : candidate.mlProbLcToPiKP()[MlClassBackground]; /// bkg score
475-
outputPrompt = isPKPi ? candidate.mlProbLcToPKPi()[MlClassPrompt] : candidate.mlProbLcToPiKP()[MlClassPrompt]; /// prompt score
476-
outputFD = isPKPi ? candidate.mlProbLcToPKPi()[MlClassNonPrompt] : candidate.mlProbLcToPiKP()[MlClassNonPrompt]; /// non-prompt score
472+
const auto& mlProb = isPKPi ? candidate.mlProbLcToPKPi() : candidate.mlProbLcToPiKP();
473+
if (mlProb.size() == NumberOfMlClasses) {
474+
outputBkg = mlProb[MlClassBackground]; /// bkg score
475+
outputPrompt = mlProb[MlClassPrompt]; /// prompt score
476+
outputFD = mlProb[MlClassNonPrompt]; /// non-prompt score
477477
}
478478
/// Fill the ML outputScores and variables of candidate
479479
std::vector<double> valuesToFill{massLc, pt, cent, outputBkg, outputPrompt, outputFD, static_cast<double>(numPvContributors), ptRecB, static_cast<double>(originType)};
@@ -655,18 +655,18 @@ struct HfTaskLc {
655655
if (storeOccupancy && occEstimator != o2::hf_occupancy::OccupancyEstimator::None) {
656656
occ = o2::hf_occupancy::getOccupancyColl(collision, occEstimator);
657657
}
658-
double massLc(-1);
659658
double outputBkg(-1), outputPrompt(-1), outputFD(-1);
660659
const float properLifetime = HfHelper::ctLc(candidate) * CtToProperLifetimePs;
661660

662661
auto fillTHnData = [&](bool isPKPi) {
663-
massLc = isPKPi ? HfHelper::invMassLcToPKPi(candidate) : HfHelper::invMassLcToPiKP(candidate);
662+
const auto massLc = isPKPi ? HfHelper::invMassLcToPKPi(candidate) : HfHelper::invMassLcToPiKP(candidate);
664663

665664
if constexpr (FillMl) {
666-
if (candidate.mlProbLcToPKPi().size() == NumberOfMlClasses) {
667-
outputBkg = isPKPi ? candidate.mlProbLcToPKPi()[MlClassBackground] : candidate.mlProbLcToPiKP()[MlClassBackground]; /// bkg score
668-
outputPrompt = isPKPi ? candidate.mlProbLcToPKPi()[MlClassPrompt] : candidate.mlProbLcToPiKP()[MlClassPrompt]; /// prompt score
669-
outputFD = isPKPi ? candidate.mlProbLcToPKPi()[MlClassNonPrompt] : candidate.mlProbLcToPiKP()[MlClassNonPrompt]; /// non-prompt score
665+
const auto& mlProb = isPKPi ? candidate.mlProbLcToPKPi() : candidate.mlProbLcToPiKP();
666+
if (mlProb.size() == NumberOfMlClasses) {
667+
outputBkg = mlProb[MlClassBackground]; /// bkg score
668+
outputPrompt = mlProb[MlClassPrompt]; /// prompt score
669+
outputFD = mlProb[MlClassNonPrompt]; /// non-prompt score
670670
}
671671
/// Fill the ML outputScores and variables of candidate
672672
std::vector<double> valuesToFill{massLc, pt, cent, outputBkg, outputPrompt, outputFD, static_cast<double>(numPvContributors)};

0 commit comments

Comments
 (0)