diff --git a/PWGHF/D2H/Tasks/taskLc.cxx b/PWGHF/D2H/Tasks/taskLc.cxx index 6445108a71d..632d3d7ebd0 100644 --- a/PWGHF/D2H/Tasks/taskLc.cxx +++ b/PWGHF/D2H/Tasks/taskLc.cxx @@ -468,6 +468,7 @@ struct HfTaskLc { auto fillTHnRecSig = [&](bool isPKPi) { const auto massLc = isPKPi ? HfHelper::invMassLcToPKPi(candidate) : HfHelper::invMassLcToPiKP(candidate); + std::vector valuesToFill; if constexpr (FillMl) { const auto& mlProb = isPKPi ? candidate.mlProbLcToPKPi() : candidate.mlProbLcToPiKP(); if (mlProb.size() == NumberOfMlClasses) { @@ -476,22 +477,21 @@ struct HfTaskLc { outputFD = mlProb[MlClassNonPrompt]; /// non-prompt score } /// Fill the ML outputScores and variables of candidate - std::vector valuesToFill{massLc, pt, cent, outputBkg, outputPrompt, outputFD, static_cast(numPvContributors), ptRecB, static_cast(originType)}; - if (storeOccupancy && occEstimator != o2::hf_occupancy::OccupancyEstimator::None) { - valuesToFill.push_back(occ); - } - if (storeProperLifetime) { - valuesToFill.push_back(properLifetime); - } + valuesToFill.reserve(registry.get(HIST("hnLcVarsWithBdt"))->GetNdimensions()); + valuesToFill.insert(valuesToFill.end(), {massLc, pt, cent, outputBkg, outputPrompt, outputFD, static_cast(numPvContributors), ptRecB, static_cast(originType)}); + } else { + valuesToFill.reserve(registry.get(HIST("hnLcVars"))->GetNdimensions()); + valuesToFill.insert(valuesToFill.end(), {massLc, pt, cent, ptProng0, ptProng1, ptProng2, chi2PCA, decayLength, cpa, static_cast(numPvContributors), ptRecB, static_cast(originType)}); + } + if (storeOccupancy && occEstimator != o2::hf_occupancy::OccupancyEstimator::None) { + valuesToFill.push_back(occ); + } + if (storeProperLifetime) { + valuesToFill.push_back(properLifetime); + } + if constexpr (FillMl) { registry.get(HIST("hnLcVarsWithBdt"))->Fill(valuesToFill.data()); } else { - std::vector valuesToFill{massLc, pt, cent, ptProng0, ptProng1, ptProng2, chi2PCA, decayLength, cpa, static_cast(numPvContributors), ptRecB, static_cast(originType)}; - if (storeOccupancy && occEstimator != o2::hf_occupancy::OccupancyEstimator::None) { - valuesToFill.push_back(occ); - } - if (storeProperLifetime) { - valuesToFill.push_back(properLifetime); - } registry.get(HIST("hnLcVars"))->Fill(valuesToFill.data()); } }; @@ -661,6 +661,7 @@ struct HfTaskLc { auto fillTHnData = [&](bool isPKPi) { const auto massLc = isPKPi ? HfHelper::invMassLcToPKPi(candidate) : HfHelper::invMassLcToPiKP(candidate); + std::vector valuesToFill; if constexpr (FillMl) { const auto& mlProb = isPKPi ? candidate.mlProbLcToPKPi() : candidate.mlProbLcToPiKP(); if (mlProb.size() == NumberOfMlClasses) { @@ -669,22 +670,21 @@ struct HfTaskLc { outputFD = mlProb[MlClassNonPrompt]; /// non-prompt score } /// Fill the ML outputScores and variables of candidate - std::vector valuesToFill{massLc, pt, cent, outputBkg, outputPrompt, outputFD, static_cast(numPvContributors)}; - if (storeOccupancy && occEstimator != o2::hf_occupancy::OccupancyEstimator::None) { - valuesToFill.push_back(occ); - } - if (storeProperLifetime) { - valuesToFill.push_back(properLifetime); - } + valuesToFill.reserve(registry.get(HIST("hnLcVarsWithBdt"))->GetNdimensions()); + valuesToFill.insert(valuesToFill.end(), {massLc, pt, cent, outputBkg, outputPrompt, outputFD, static_cast(numPvContributors)}); + } else { + valuesToFill.reserve(registry.get(HIST("hnLcVars"))->GetNdimensions()); + valuesToFill.insert(valuesToFill.end(), {massLc, pt, cent, ptProng0, ptProng1, ptProng2, chi2PCA, decayLength, cpa, static_cast(numPvContributors)}); + } + if (storeOccupancy && occEstimator != o2::hf_occupancy::OccupancyEstimator::None) { + valuesToFill.push_back(occ); + } + if (storeProperLifetime) { + valuesToFill.push_back(properLifetime); + } + if constexpr (FillMl) { registry.get(HIST("hnLcVarsWithBdt"))->Fill(valuesToFill.data()); } else { - std::vector valuesToFill{massLc, pt, cent, ptProng0, ptProng1, ptProng2, chi2PCA, decayLength, cpa, static_cast(numPvContributors)}; - if (storeOccupancy && occEstimator != o2::hf_occupancy::OccupancyEstimator::None) { - valuesToFill.push_back(occ); - } - if (storeProperLifetime) { - valuesToFill.push_back(properLifetime); - } registry.get(HIST("hnLcVars"))->Fill(valuesToFill.data()); } };