Skip to content

Commit afcca3b

Browse files
committed
fixing the correct matching function
1 parent 122509c commit afcca3b

File tree

1 file changed

+46
-32
lines changed

1 file changed

+46
-32
lines changed

PWGJE/Core/JetHFUtilities.h

Lines changed: 46 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -601,20 +601,6 @@ bool isHFDaughterTrack(T& track, U& candidate)
601601
}
602602
}
603603

604-
/**
605-
* returns the index of the JMcParticle matched to the HF candidate
606-
*
607-
* @param candidate hf candidate that is being checked
608-
* @param tracks track table
609-
* @param particles particle table
610-
*/
611-
template <typename T, typename U, typename V>
612-
auto matchedHFParticleId(const T& candidate, const U& /*tracks*/, const V& /*particles*/)
613-
{
614-
const auto candidateDaughterParticle = candidate.template prong1_as<U>().template mcParticle_as<V>();
615-
return candidateDaughterParticle.template mothers_first_as<V>().globalIndex(); // can we get the Id directly?
616-
}
617-
618604
/**
619605
* returns the JMcParticle matched to the HF candidate
620606
*
@@ -626,35 +612,63 @@ template <typename T, typename U, typename V>
626612
auto matchedHFParticle(const T& candidate, const U& /*tracks*/, const V& /*particles*/)
627613
{
628614

629-
const typename V::iterator candidateDaughterParticle;
630-
if (std::abs(candidate.flagMcMatchRec()) == o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK) {
631-
candidateDaughterParticle = candidate.template prong1_as<U>().template mcParticle_as<V>();
615+
typename V::iterator candidateDaughterParticle;
616+
if constexpr (isD0Candidate<T>()) {
617+
if (std::abs(candidate.flagMcMatchRec()) == o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK) {
618+
candidateDaughterParticle = candidate.template prong0_as<U>().template mcParticle_as<V>();
619+
}
632620
}
633-
if (std::abs(candidate.flagMcMatchRec()) == o2::hf_decay::hf_cand_3prong::DecayChannelMain::DplusToPiKPi) {
634-
candidateDaughterParticle = candidate.template prong1_as<U>().template mcParticle_as<V>();
621+
if constexpr (isDplusCandidate<T>()) {
622+
if (std::abs(candidate.flagMcMatchRec()) == o2::hf_decay::hf_cand_3prong::DecayChannelMain::DplusToPiKPi) {
623+
candidateDaughterParticle = candidate.template prong0_as<U>().template mcParticle_as<V>();
624+
}
635625
}
636-
if (std::abs(candidate.flagMcMatchRec()) == o2::hf_decay::hf_cand_3prong::DecayChannelMain::DsToPiKK) {
637-
candidateDaughterParticle = candidate.template prong1_as<U>().template mcParticle_as<V>();
626+
if constexpr (isDsCandidate<T>()) {
627+
if (std::abs(candidate.flagMcMatchRec()) == o2::hf_decay::hf_cand_3prong::DecayChannelMain::DsToPiKK) {
628+
candidateDaughterParticle = candidate.template prong0_as<U>().template mcParticle_as<V>();
629+
}
638630
}
639-
if (std::abs(candidate.flagMcMatchRec()) == o2::hf_decay::hf_cand_dstar::DecayChannelMain::DstarToPiKPi) {
640-
candidateDaughterParticle = candidate.template prong3_as<U>().template mcParticle_as<V>();
631+
if constexpr (isDstarCandidate<T>()) {
632+
if (std::abs(candidate.flagMcMatchRec()) == o2::hf_decay::hf_cand_dstar::DecayChannelMain::DstarToPiKPi) {
633+
candidateDaughterParticle = candidate.template prong2_as<U>().template mcParticle_as<V>();
634+
}
641635
}
642-
if (std::abs(candidate.flagMcMatchRec()) == o2::hf_decay::hf_cand_3prong::DecayChannelMain::LcToPKPi) {
643-
candidateDaughterParticle = candidate.template prong1_as<U>().template mcParticle_as<V>();
636+
if constexpr (isLcCandidate<T>()) {
637+
if (std::abs(candidate.flagMcMatchRec()) == o2::hf_decay::hf_cand_3prong::DecayChannelMain::LcToPKPi) {
638+
candidateDaughterParticle = candidate.template prong0_as<U>().template mcParticle_as<V>();
639+
}
644640
}
645-
if (std::abs(candidate.flagMcMatchRec()) == o2::hf_decay::hf_cand_beauty::DecayChannelMain::B0ToDminusPi) {
646-
candidateDaughterParticle = candidate.template prong4_as<U>().template mcParticle_as<V>();
641+
if constexpr (isB0Candidate<T>()) {
642+
if (std::abs(candidate.flagMcMatchRec()) == o2::hf_decay::hf_cand_beauty::DecayChannelMain::B0ToDminusPi) {
643+
candidateDaughterParticle = candidate.template prong3_as<U>().template mcParticle_as<V>();
644+
}
647645
}
648-
if (std::abs(candidate.flagMcMatchRec()) == o2::hf_decay::hf_cand_beauty::DecayChannelMain::BplusToD0Pi) {
649-
candidateDaughterParticle = candidate.template prong3_as<U>().template mcParticle_as<V>();
646+
if constexpr (isBplusCandidate<T>()) {
647+
if (std::abs(candidate.flagMcMatchRec()) == o2::hf_decay::hf_cand_beauty::DecayChannelMain::BplusToD0Pi) {
648+
candidateDaughterParticle = candidate.template prong2_as<U>().template mcParticle_as<V>();
649+
}
650650
}
651-
if (std::abs(candidate.flagMcMatchRec()) == o2::aod::hf_cand_xic_to_xi_pi_pi::DecayType::XicToXiPiPi) {
652-
candidateDaughterParticle = candidate.template prong1_as<U>().template mcParticle_as<V>();
651+
if constexpr (isXicToXiPiPiCandidate<T>()) {
652+
if (std::abs(candidate.flagMcMatchRec()) == o2::aod::hf_cand_xic_to_xi_pi_pi::DecayType::XicToXiPiPi) {
653+
candidateDaughterParticle = candidate.template prong0_as<U>().template mcParticle_as<V>();
654+
}
653655
}
654-
655656
return candidateDaughterParticle.template mothers_first_as<V>();
656657
}
657658

659+
/**
660+
* returns the index of the JMcParticle matched to the HF candidate
661+
*
662+
* @param candidate hf candidate that is being checked
663+
* @param tracks track table
664+
* @param particles particle table
665+
*/
666+
template <typename T, typename U, typename V>
667+
auto matchedHFParticleId(const T& candidate, const U& tracks, const V& particles)
668+
{
669+
return (matchedHFParticle(candidate, tracks, particles)).globalIndex();
670+
}
671+
658672
/**
659673
* returns a slice of the table depending on the index of the HF candidate
660674
*

0 commit comments

Comments
 (0)