From 582f15626a769e8b49bdbfdf26d5e66400cb238b Mon Sep 17 00:00:00 2001 From: nzardosh Date: Sat, 22 Nov 2025 17:12:48 +0100 Subject: [PATCH] fixing the correct matching function --- PWGJE/Core/JetHFUtilities.h | 78 ++++++++++++++++++++++--------------- 1 file changed, 46 insertions(+), 32 deletions(-) diff --git a/PWGJE/Core/JetHFUtilities.h b/PWGJE/Core/JetHFUtilities.h index 7dc84055cd6..1d9bf0841a5 100644 --- a/PWGJE/Core/JetHFUtilities.h +++ b/PWGJE/Core/JetHFUtilities.h @@ -601,20 +601,6 @@ bool isHFDaughterTrack(T& track, U& candidate) } } -/** - * returns the index of the JMcParticle matched to the HF candidate - * - * @param candidate hf candidate that is being checked - * @param tracks track table - * @param particles particle table - */ -template -auto matchedHFParticleId(const T& candidate, const U& /*tracks*/, const V& /*particles*/) -{ - const auto candidateDaughterParticle = candidate.template prong1_as().template mcParticle_as(); - return candidateDaughterParticle.template mothers_first_as().globalIndex(); // can we get the Id directly? -} - /** * returns the JMcParticle matched to the HF candidate * @@ -626,35 +612,63 @@ template auto matchedHFParticle(const T& candidate, const U& /*tracks*/, const V& /*particles*/) { - const typename V::iterator candidateDaughterParticle; - if (std::abs(candidate.flagMcMatchRec()) == o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK) { - candidateDaughterParticle = candidate.template prong1_as().template mcParticle_as(); + typename V::iterator candidateDaughterParticle; + if constexpr (isD0Candidate()) { + if (std::abs(candidate.flagMcMatchRec()) == o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK) { + candidateDaughterParticle = candidate.template prong0_as().template mcParticle_as(); + } } - if (std::abs(candidate.flagMcMatchRec()) == o2::hf_decay::hf_cand_3prong::DecayChannelMain::DplusToPiKPi) { - candidateDaughterParticle = candidate.template prong1_as().template mcParticle_as(); + if constexpr (isDplusCandidate()) { + if (std::abs(candidate.flagMcMatchRec()) == o2::hf_decay::hf_cand_3prong::DecayChannelMain::DplusToPiKPi) { + candidateDaughterParticle = candidate.template prong0_as().template mcParticle_as(); + } } - if (std::abs(candidate.flagMcMatchRec()) == o2::hf_decay::hf_cand_3prong::DecayChannelMain::DsToPiKK) { - candidateDaughterParticle = candidate.template prong1_as().template mcParticle_as(); + if constexpr (isDsCandidate()) { + if (std::abs(candidate.flagMcMatchRec()) == o2::hf_decay::hf_cand_3prong::DecayChannelMain::DsToPiKK) { + candidateDaughterParticle = candidate.template prong0_as().template mcParticle_as(); + } } - if (std::abs(candidate.flagMcMatchRec()) == o2::hf_decay::hf_cand_dstar::DecayChannelMain::DstarToPiKPi) { - candidateDaughterParticle = candidate.template prong3_as().template mcParticle_as(); + if constexpr (isDstarCandidate()) { + if (std::abs(candidate.flagMcMatchRec()) == o2::hf_decay::hf_cand_dstar::DecayChannelMain::DstarToPiKPi) { + candidateDaughterParticle = candidate.template prong2_as().template mcParticle_as(); + } } - if (std::abs(candidate.flagMcMatchRec()) == o2::hf_decay::hf_cand_3prong::DecayChannelMain::LcToPKPi) { - candidateDaughterParticle = candidate.template prong1_as().template mcParticle_as(); + if constexpr (isLcCandidate()) { + if (std::abs(candidate.flagMcMatchRec()) == o2::hf_decay::hf_cand_3prong::DecayChannelMain::LcToPKPi) { + candidateDaughterParticle = candidate.template prong0_as().template mcParticle_as(); + } } - if (std::abs(candidate.flagMcMatchRec()) == o2::hf_decay::hf_cand_beauty::DecayChannelMain::B0ToDminusPi) { - candidateDaughterParticle = candidate.template prong4_as().template mcParticle_as(); + if constexpr (isB0Candidate()) { + if (std::abs(candidate.flagMcMatchRec()) == o2::hf_decay::hf_cand_beauty::DecayChannelMain::B0ToDminusPi) { + candidateDaughterParticle = candidate.template prong3_as().template mcParticle_as(); + } } - if (std::abs(candidate.flagMcMatchRec()) == o2::hf_decay::hf_cand_beauty::DecayChannelMain::BplusToD0Pi) { - candidateDaughterParticle = candidate.template prong3_as().template mcParticle_as(); + if constexpr (isBplusCandidate()) { + if (std::abs(candidate.flagMcMatchRec()) == o2::hf_decay::hf_cand_beauty::DecayChannelMain::BplusToD0Pi) { + candidateDaughterParticle = candidate.template prong2_as().template mcParticle_as(); + } } - if (std::abs(candidate.flagMcMatchRec()) == o2::aod::hf_cand_xic_to_xi_pi_pi::DecayType::XicToXiPiPi) { - candidateDaughterParticle = candidate.template prong1_as().template mcParticle_as(); + if constexpr (isXicToXiPiPiCandidate()) { + if (std::abs(candidate.flagMcMatchRec()) == o2::aod::hf_cand_xic_to_xi_pi_pi::DecayType::XicToXiPiPi) { + candidateDaughterParticle = candidate.template prong0_as().template mcParticle_as(); + } } - return candidateDaughterParticle.template mothers_first_as(); } +/** + * returns the index of the JMcParticle matched to the HF candidate + * + * @param candidate hf candidate that is being checked + * @param tracks track table + * @param particles particle table + */ +template +auto matchedHFParticleId(const T& candidate, const U& tracks, const V& particles) +{ + return (matchedHFParticle(candidate, tracks, particles)).globalIndex(); +} + /** * returns a slice of the table depending on the index of the HF candidate *