Skip to content

Commit fc47508

Browse files
committed
Rename variables and adjust map ordering
1 parent 5139e4f commit fc47508

File tree

4 files changed

+88
-92
lines changed

4 files changed

+88
-92
lines changed

PWGHF/TableProducer/candidateCreator2Prong.cxx

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -778,46 +778,42 @@ struct HfCandidateCreator2ProngExpressions {
778778

779779
if (matchCorrBkgs) {
780780
indexRec = -1; // Index of the matched reconstructed candidate
781-
int depth = 2;
782-
for (const auto& [chn, finalState] : hf_cand_2prong::DaughtersD0Main) {
781+
constexpr int FinalStateDepth = 2;
782+
constexpr int ResoDepth = 1;
783+
784+
// D0(bar) → π+ K−, π+ K− π0, π+ π−, π+ π− π0, K+ K−
785+
for (const auto& [chn, finalState] : hf_cand_2prong::daughtersD0Main) {
783786
std::array<int, 2> finalStateParts2Prong = std::array{finalState[0], finalState[1]};
784787
if (finalState.size() == 3) { // Partly Reco 2-prong decays
785788
if (matchKinkedDecayTopology && matchInteractionsWithMaterial) {
786-
indexRec = RecoDecay::getMatchedMCRec<false, false, true, true, true>(mcParticles, arrayDaughters, Pdg::kD0, finalStateParts2Prong, true, &sign, depth, &nKinkedTracks, &nInteractionsWithMaterial);
789+
indexRec = RecoDecay::getMatchedMCRec<false, false, true, true, true>(mcParticles, arrayDaughters, Pdg::kD0, finalStateParts2Prong, true, &sign, FinalStateDepth, &nKinkedTracks, &nInteractionsWithMaterial);
787790
} else if (matchKinkedDecayTopology && !matchInteractionsWithMaterial) {
788-
indexRec = RecoDecay::getMatchedMCRec<false, false, true, true, false>(mcParticles, arrayDaughters, Pdg::kD0, finalStateParts2Prong, true, &sign, depth, &nKinkedTracks);
791+
indexRec = RecoDecay::getMatchedMCRec<false, false, true, true, false>(mcParticles, arrayDaughters, Pdg::kD0, finalStateParts2Prong, true, &sign, FinalStateDepth, &nKinkedTracks);
789792
} else if (!matchKinkedDecayTopology && matchInteractionsWithMaterial) {
790-
indexRec = RecoDecay::getMatchedMCRec<false, false, true, false, true>(mcParticles, arrayDaughters, Pdg::kD0, finalStateParts2Prong, true, &sign, depth, nullptr, &nInteractionsWithMaterial);
793+
indexRec = RecoDecay::getMatchedMCRec<false, false, true, false, true>(mcParticles, arrayDaughters, Pdg::kD0, finalStateParts2Prong, true, &sign, FinalStateDepth, nullptr, &nInteractionsWithMaterial);
791794
} else {
792-
indexRec = RecoDecay::getMatchedMCRec<false, false, true, false, false>(mcParticles, arrayDaughters, Pdg::kD0, finalStateParts2Prong, true, &sign, depth);
795+
indexRec = RecoDecay::getMatchedMCRec<false, false, true, false, false>(mcParticles, arrayDaughters, Pdg::kD0, finalStateParts2Prong, true, &sign, FinalStateDepth);
793796
}
794797

795798
if (indexRec > -1) {
796799
auto motherParticle = mcParticles.rawIteratorAt(indexRec);
797800
std::array<int, 3> finalStateParts2ProngAll = std::array{finalState[0], finalState[1], finalState[2]};
798-
if (motherParticle.pdgCode() < 0) {
799-
for (auto& part : finalStateParts2ProngAll) {
800-
if (part == kPi0) {
801-
part = -part; // The Pi0 pdg code does not change between particle and antiparticle
802-
}
803-
}
804-
}
805-
if (!RecoDecay::isMatchedMCGen(mcParticles, motherParticle, Pdg::kD0, finalStateParts2ProngAll, true, &sign, depth)) {
801+
if (!RecoDecay::isMatchedMCGen(mcParticles, motherParticle, Pdg::kD0, finalStateParts2ProngAll, true, &sign, FinalStateDepth)) {
806802
indexRec = -1; // Reset indexRec if the generated decay does not match the reconstructed one does not match the reconstructed one
807803
}
808804
}
809805
} else if (finalState.size() == 2) { // Fully Reco 2-prong decays
810806
if (matchKinkedDecayTopology && matchInteractionsWithMaterial) {
811-
indexRec = RecoDecay::getMatchedMCRec<false, false, false, true, true>(mcParticles, arrayDaughters, Pdg::kD0, finalStateParts2Prong, true, &sign, depth, &nKinkedTracks, &nInteractionsWithMaterial);
807+
indexRec = RecoDecay::getMatchedMCRec<false, false, false, true, true>(mcParticles, arrayDaughters, Pdg::kD0, finalStateParts2Prong, true, &sign, FinalStateDepth, &nKinkedTracks, &nInteractionsWithMaterial);
812808
} else if (matchKinkedDecayTopology && !matchInteractionsWithMaterial) {
813-
indexRec = RecoDecay::getMatchedMCRec<false, false, false, true, false>(mcParticles, arrayDaughters, Pdg::kD0, finalStateParts2Prong, true, &sign, depth, &nKinkedTracks);
809+
indexRec = RecoDecay::getMatchedMCRec<false, false, false, true, false>(mcParticles, arrayDaughters, Pdg::kD0, finalStateParts2Prong, true, &sign, FinalStateDepth, &nKinkedTracks);
814810
} else if (!matchKinkedDecayTopology && matchInteractionsWithMaterial) {
815-
indexRec = RecoDecay::getMatchedMCRec<false, false, false, false, true>(mcParticles, arrayDaughters, Pdg::kD0, finalStateParts2Prong, true, &sign, depth, nullptr, &nInteractionsWithMaterial);
811+
indexRec = RecoDecay::getMatchedMCRec<false, false, false, false, true>(mcParticles, arrayDaughters, Pdg::kD0, finalStateParts2Prong, true, &sign, FinalStateDepth, nullptr, &nInteractionsWithMaterial);
816812
} else {
817-
indexRec = RecoDecay::getMatchedMCRec<false, false, false, false, false>(mcParticles, arrayDaughters, Pdg::kD0, finalStateParts2Prong, true, &sign, depth);
813+
indexRec = RecoDecay::getMatchedMCRec<false, false, false, false, false>(mcParticles, arrayDaughters, Pdg::kD0, finalStateParts2Prong, true, &sign, FinalStateDepth);
818814
}
819815
} else {
820-
LOG(info) << "Final state size not supported: " << finalStateParts2Prong.size();
816+
LOG(fatal) << "Final state size not supported: " << finalState.size();
821817
continue;
822818
}
823819
if (indexRec > -1) {
@@ -826,7 +822,7 @@ struct HfCandidateCreator2ProngExpressions {
826822
// Flag the resonant decay channel
827823
int resoMaxDepth = 1;
828824
std::vector<int> arrResoDaughIndex = {};
829-
RecoDecay::getDaughters(mcParticles.rawIteratorAt(indexRec), &arrResoDaughIndex, std::array{0}, resoMaxDepth);
825+
RecoDecay::getDaughters(mcParticles.rawIteratorAt(indexRec), &arrResoDaughIndex, std::array{0}, ResoDepth);
830826
std::array<int, NDaughtersResonant> arrPDGDaugh = {};
831827
if (arrResoDaughIndex.size() == NDaughtersResonant) {
832828
for (auto iProng = 0u; iProng < arrResoDaughIndex.size(); ++iProng) {

PWGHF/TableProducer/candidateCreator3Prong.cxx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -949,11 +949,13 @@ struct HfCandidateCreator3ProngExpressions {
949949

950950
if (matchCorrBkgs) {
951951
indexRec = -1; // Index of the matched reconstructed candidate
952+
constexpr int MaxDepth = 2; // Depth for final state matching
953+
constexpr int ResoMaxDepth = 1; // Depth for resonant decay matching
952954

953955
for (const auto& pdg : mothersCorrBkgsPdgs.value) {
954-
int depth = 2;
956+
int depth = MaxDepth;
955957
if (pdg == Pdg::kDStar) {
956-
depth = 3; // D0 resonant decays are active
958+
depth = MaxDepth+1; // D0 resonant decays are active
957959
}
958960
auto finalStates = getDecayChannel3Prong(pdg);
959961
for (const auto& [chn, finalState] : finalStates) {
@@ -1008,7 +1010,7 @@ struct HfCandidateCreator3ProngExpressions {
10081010
indexRec = RecoDecay::getMatchedMCRec<false, false, false, false, false>(mcParticles, arrayDaughters, pdg, finalStateParts3Prong, true, &sign, depth);
10091011
}
10101012
} else {
1011-
LOG(info) << "Final state size not supported: " << finalState.size();
1013+
LOG(fatal) << "Final state size not supported: " << finalState.size();
10121014
continue; // Skip unsupported final states
10131015
}
10141016
if (indexRec > -1) {

PWGHF/Utils/utilsMcGen.h

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -55,22 +55,17 @@ void fillMcMatchGen2Prong(T const& mcParticles, U const& mcParticlesPerMcColl, V
5555
continue;
5656
}
5757
if (matchCorrBkgs) {
58+
constexpr int MaxDepth = 2; // Depth for final state matching
59+
constexpr int ResoMaxDepth = 1; // Depth for resonant decay matching
5860
bool matched = false;
5961

60-
for (const auto& [chn, finalState] : o2::hf_decay::hf_cand_2prong::DaughtersD0Main) {
62+
for (const auto& [chn, finalState] : o2::hf_decay::hf_cand_2prong::daughtersD0Main) {
6163
if (finalState.size() == 3) { // Partly Reco 3-prong decays
6264
std::array<int, 3> finalStateParts = std::array{finalState[0], finalState[1], finalState[2]};
63-
if (particle.pdgCode() < 0) {
64-
for (auto& part : finalStateParts) {
65-
if (part == kPi0) {
66-
part = -part; // The Pi0 pdg code does not change between particle and antiparticle
67-
}
68-
}
69-
}
70-
matched = RecoDecay::isMatchedMCGen(mcParticles, particle, Pdg::kD0, finalStateParts, true, &sign, maxDepth);
65+
matched = RecoDecay::isMatchedMCGen(mcParticles, particle, Pdg::kD0, finalStateParts, true, &sign, MaxDepth);
7166
} else if (finalState.size() == 2) { // Fully Reco 2-prong decays
7267
std::array<int, 2> finalStateParts = std::array{finalState[0], finalState[1]};
73-
matched = RecoDecay::isMatchedMCGen(mcParticles, particle, Pdg::kD0, finalStateParts, true, &sign, maxDepth);
68+
matched = RecoDecay::isMatchedMCGen(mcParticles, particle, Pdg::kD0, finalStateParts, true, &sign, MaxDepth);
7469
} else {
7570
LOG(info) << "Final state size not supported: " << finalState.size();
7671
continue;
@@ -81,7 +76,7 @@ void fillMcMatchGen2Prong(T const& mcParticles, U const& mcParticlesPerMcColl, V
8176
// Flag the resonant decay channel
8277
int resoMaxDepth = 1;
8378
std::vector<int> arrResoDaughIndex = {};
84-
RecoDecay::getDaughters(particle, &arrResoDaughIndex, std::array{0}, resoMaxDepth);
79+
RecoDecay::getDaughters(particle, &arrResoDaughIndex, std::array{0}, ResoMaxDepth);
8580
std::array<int, NDaughtersResonant> arrPDGDaugh = {};
8681
if (arrResoDaughIndex.size() == NDaughtersResonant) {
8782
for (auto iProng = 0u; iProng < arrResoDaughIndex.size(); ++iProng) {
@@ -157,11 +152,14 @@ void fillMcMatchGen3Prong(T const& mcParticles, U const& mcParticlesPerMcColl, V
157152
if (std::abs(particle.pdgCode()) != motherPdgCode) {
158153
continue; // Skip if the particle PDG code does not match the mother PDG code
159154
}
160-
auto finalStates = o2::hf_decay::hf_cand_3prong::getDecayChannel3Prong(motherPdgCode);
161-
int maxDepth = 2;
155+
auto finalStates = o2::hf_decay::hf_cand_3prong::getDecayChannelMain(motherPdgCode);
156+
constexpr int MaxDepth = 2; // Depth for final state matching
157+
constexpr int ResoMaxDepth = 1; // Depth for resonant decay matching
158+
159+
int maxDepth = MaxDepth;
162160
bool matched = false;
163161
if (motherPdgCode == Pdg::kDStar) {
164-
maxDepth = 3; // D0 resonant decays are switched on
162+
maxDepth = MaxDepth+1; // D0 resonant decays are switched on
165163
}
166164

167165
std::vector<int> arrAllDaughtersIndex;
@@ -203,18 +201,18 @@ void fillMcMatchGen3Prong(T const& mcParticles, U const& mcParticlesPerMcColl, V
203201
std::vector<int> arrResoDaughIndex = {};
204202
if (std::abs(motherPdgCode) == Pdg::kDStar) {
205203
std::vector<int> arrResoDaughIndexDStar = {};
206-
RecoDecay::getDaughters(particle, &arrResoDaughIndexDStar, std::array{0}, resoMaxDepth);
204+
RecoDecay::getDaughters(particle, &arrResoDaughIndexDStar, std::array{0}, ResoMaxDepth);
207205
for (size_t iDaug = 0; iDaug < arrResoDaughIndexDStar.size(); iDaug++) {
208206
auto daughDstar = mcParticles.rawIteratorAt(arrResoDaughIndexDStar[iDaug]);
209207
if (std::abs(daughDstar.pdgCode()) == Pdg::kD0 || std::abs(daughDstar.pdgCode()) == Pdg::kDPlus) {
210-
RecoDecay::getDaughters(daughDstar, &arrResoDaughIndex, std::array{0}, resoMaxDepth);
208+
RecoDecay::getDaughters(daughDstar, &arrResoDaughIndex, std::array{0}, ResoMaxDepth);
211209
break;
212210
} else {
213211
LOG(info) << "[matchFinalStateCorrBkgsGen] D* Daughter with PDG code: " << mcParticles.rawIteratorAt(arrResoDaughIndexDStar[iDaug]).pdgCode() << " not recognized.";
214212
}
215213
}
216214
} else {
217-
RecoDecay::getDaughters(particle, &arrResoDaughIndex, std::array{0}, resoMaxDepth);
215+
RecoDecay::getDaughters(particle, &arrResoDaughIndex, std::array{0}, ResoMaxDepth);
218216
}
219217
std::array<int, NDaughtersResonant> arrPDGDaugh = {};
220218
if (arrResoDaughIndex.size() == NDaughtersResonant) {

0 commit comments

Comments
 (0)