Skip to content

Commit 07b9cd8

Browse files
committed
Delete debug prints for 2prong code
1 parent 77838d0 commit 07b9cd8

File tree

6 files changed

+153
-157
lines changed

6 files changed

+153
-157
lines changed

Common/Core/RecoDecay.h

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
#include <cstdio>
2525
#include <utility> // std::move
2626
#include <vector> // std::vector
27-
#include <iostream>
2827

2928
// ROOT includes
3029
#include <TMCProcess.h> // for VMC Particle Production Process
@@ -905,20 +904,12 @@ struct RecoDecay {
905904
}
906905
// Check the PDG code of the particle.
907906
auto pdgCandidate = candidate.pdgCode();
908-
bool debugPrint = false; // Set to true to enable debug printing.
909-
if (std::abs(pdgCandidate) == 413) {
910-
// Printf("MC Gen: Candidate PDG: %d", pdgCandidate);
911-
debugPrint = true; // Enable debug printing for D*.
912-
}
913907
// Printf("MC Gen: Candidate PDG: %d", pdgCandidate);
914908
if (pdgCandidate == pdgParticle) { // exact PDG match
915909
sgn = 1;
916910
} else if (acceptAntiParticles && pdgCandidate == -pdgParticle) { // antiparticle PDG match
917911
sgn = -1;
918912
} else {
919-
if (debugPrint) {
920-
std::cout << "MC Gen: Rejected: bad particle PDG: " << (acceptAntiParticles ? "abs " : "") << pdgCandidate << " != " << pdgParticle << std::endl;
921-
}
922913
// Printf("MC Gen: Rejected: bad particle PDG: %s%d != %d", acceptAntiParticles ? "abs " : "", pdgCandidate, std::abs(pdgParticle));
923914
return false;
924915
}
@@ -928,42 +919,25 @@ struct RecoDecay {
928919
std::vector<int> arrAllDaughtersIndex; // vector of indices of all daughters
929920
// Check the daughter indices.
930921
if (!candidate.has_daughters()) {
931-
if (debugPrint) {
932-
std::cout << "MC Gen: Rejected: bad daughter index range: " << candidate.daughtersIds().front() << "-" << candidate.daughtersIds().back() << std::endl;
933-
}
934922
// Printf("MC Gen: Rejected: bad daughter index range: %d-%d", candidate.daughtersIds().front(), candidate.daughtersIds().back());
935923
return false;
936924
}
937925
// Check that the number of direct daughters is not larger than the number of expected final daughters.
938926
if constexpr (!checkProcess) {
939927
if (candidate.daughtersIds().back() - candidate.daughtersIds().front() + 1 > static_cast<int>(N)) {
940-
if (debugPrint) {
941-
std::cout << "MC Gen: Rejected: too many direct daughters: " << candidate.daughtersIds().back() - candidate.daughtersIds().front() + 1
942-
<< " (expected " << N << " final)" << std::endl;
943-
}
944928
// Printf("MC Gen: Rejected: too many direct daughters: %d (expected %ld final)", candidate.daughtersIds().back() - candidate.daughtersIds().front() + 1, N);
945929
return false;
946930
}
947931
}
948932
// Get the list of actual final daughters.
949933
getDaughters<checkProcess>(candidate, &arrAllDaughtersIndex, arrPdgDaughters, depthMax);
950-
if (debugPrint) {
951-
std::cout << "MC Gen: Mother " << candidate.globalIndex() << " has " << arrAllDaughtersIndex.size() << " final daughters:";
952-
for (auto i : arrAllDaughtersIndex) {
953-
std::cout << " " << i;
954-
}
955-
std::cout << std::endl;
956-
}
957934
// printf("MC Gen: Mother %ld has %ld final daughters:", candidate.globalIndex(), arrAllDaughtersIndex.size());
958935
// for (auto i : arrAllDaughtersIndex) {
959936
// printf(" %d", i);
960937
// }
961938
// printf("\n");
962939
// Check whether the number of final daughters is equal to the required number.
963940
if (arrAllDaughtersIndex.size() != N) {
964-
if (debugPrint) {
965-
std::cout << "MC Gen: Rejected: incorrect number of final daughters: " << arrAllDaughtersIndex.size() << " (expected " << N << ")" << std::endl;
966-
}
967941
// Printf("MC Gen: Rejected: incorrect number of final daughters: %ld (expected %ld)", arrAllDaughtersIndex.size(), N);
968942
return false;
969943
}
@@ -981,25 +955,16 @@ struct RecoDecay {
981955
for (auto indexDaughterI : arrAllDaughtersIndex) { // o2-linter: disable=const-ref-in-for-loop (int elements)
982956
auto candidateDaughterI = particlesMC.rawIteratorAt(indexDaughterI - particlesMC.offset()); // ith daughter particle
983957
auto pdgCandidateDaughterI = candidateDaughterI.pdgCode(); // PDG code of the ith daughter
984-
if (debugPrint) {
985-
std::cout << "MC Gen: Daughter " << indexDaughterI << " PDG: " << pdgCandidateDaughterI << std::endl;
986-
}
987958
// Printf("MC Gen: Daughter %d PDG: %d", indexDaughterI, pdgCandidateDaughterI);
988959
bool isPdgFound = false; // Is the PDG code of this daughter among the remaining expected PDG codes?
989960
for (std::size_t iProngCp = 0; iProngCp < N; ++iProngCp) {
990-
if (debugPrint) {
991-
std::cout << "MC Gen: Checking against expected PDG: " << coefFlavourOscillation * sgn * arrPdgDaughters[iProngCp] << std::endl;
992-
}
993961
if (pdgCandidateDaughterI == coefFlavourOscillation * sgn * arrPdgDaughters[iProngCp]) {
994962
arrPdgDaughters[iProngCp] = 0; // Remove this PDG code from the array of expected ones.
995963
isPdgFound = true;
996964
break;
997965
}
998966
}
999967
if (!isPdgFound) {
1000-
if (debugPrint) {
1001-
std::cout << "MC Gen: Rejected: bad daughter PDG: " << pdgCandidateDaughterI << std::endl;
1002-
}
1003968
// Printf("MC Gen: Rejected: bad daughter PDG: %d", pdgCandidateDaughterI);
1004969
return false;
1005970
}
@@ -1008,9 +973,6 @@ struct RecoDecay {
1008973
*listIndexDaughters = arrAllDaughtersIndex;
1009974
}
1010975
}
1011-
if (debugPrint) {
1012-
std::cout << "MC Gen: Accepted: m: " << candidate.globalIndex() << std::endl;
1013-
}
1014976
// Printf("MC Gen: Accepted: m: %d", candidate.globalIndex());
1015977
if (sign) {
1016978
*sign = sgn;

PWGHF/Core/DecayChannels.h

Lines changed: 93 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,6 @@ enum DecayChannelResonant : int8_t {
152152
LastChannelResonant
153153
};
154154

155-
156155
std::unordered_map<DecayChannelResonant, std::array<int, 2> > resoStatesDPlus =
157156
{
158157
{DecayChannelResonant::DplusToPhiPi, std::array<int, 2>{+kPhi, +kPiPlus}},
@@ -312,108 +311,134 @@ enum DecayChannelResonant : int8_t {
312311
} // namespace hf_cand_beauty
313312
} // namespace o2::hf_decay
314313

315-
// using namespace o2::hf_decay;
316-
317314
namespace o2::hf_corrbkg
318315
{
319-
std::unordered_map<o2::hf_decay::hf_cand_3prong::DecayChannelMain, std::vector<int> > getDecayChannel3Prong(int pdgMother) {
316+
using namespace o2::hf_decay;
317+
318+
/// Returns a map of the possible final states for a specific 3-prong particle specie
319+
/// \param pdgMother PDG code of the mother particle
320+
/// \return a map of final states with their corresponding PDG codes
321+
std::unordered_map<hf_cand_3prong::DecayChannelMain, std::vector<int> > getDecayChannel3Prong(int pdgMother) {
320322
switch (pdgMother) {
321323
case Pdg::kDPlus:
322-
return o2::hf_decay::hf_cand_3prong::finalStatesDPlus;
324+
return hf_cand_3prong::finalStatesDPlus;
323325
case Pdg::kDS:
324-
return o2::hf_decay::hf_cand_3prong::finalStatesDs;
326+
return hf_cand_3prong::finalStatesDs;
325327
case Pdg::kDStar:
326-
return o2::hf_decay::hf_cand_3prong::finalStatesDstar;
328+
return hf_cand_3prong::finalStatesDstar;
327329
case Pdg::kLambdaCPlus:
328-
return o2::hf_decay::hf_cand_3prong::finalStatesLc;
330+
return hf_cand_3prong::finalStatesLc;
329331
case Pdg::kXiCPlus:
330-
return o2::hf_decay::hf_cand_3prong::finalStatesXic;
332+
return hf_cand_3prong::finalStatesXic;
331333
default:
332334
LOG(error) << "Unknown PDG code for 3-prong final states: " << pdgMother;
333335
return {};
334336
}
335337
}
336338

337-
std::unordered_map<o2::hf_decay::hf_cand_3prong::DecayChannelResonant, std::array<int, 2> > getResoChannels3Prong(int pdgMother) {
339+
/// Returns a map of the resonant decay channels for a specific 3-prong particle specie
340+
/// \param pdgMother PDG code of the mother particle
341+
/// \return a map of resonant decay channels with their corresponding PDG codes
342+
std::unordered_map<hf_cand_3prong::DecayChannelResonant, std::array<int, 2> > getResoChannels3Prong(int pdgMother) {
338343
switch (pdgMother) {
339344
case Pdg::kDPlus:
340-
return o2::hf_decay::hf_cand_3prong::resoStatesDPlus;
345+
return hf_cand_3prong::resoStatesDPlus;
341346
case Pdg::kDS:
342-
return o2::hf_decay::hf_cand_3prong::resoStatesDs;
347+
return hf_cand_3prong::resoStatesDs;
343348
case Pdg::kDStar:
344-
return o2::hf_decay::hf_cand_3prong::resoStatesDstar;
349+
return hf_cand_3prong::resoStatesDstar;
345350
case Pdg::kLambdaCPlus:
346-
return o2::hf_decay::hf_cand_3prong::resoStatesLambdaC;
351+
return hf_cand_3prong::resoStatesLambdaC;
347352
case Pdg::kXiCPlus:
348-
return o2::hf_decay::hf_cand_3prong::resoStatesXiC;
353+
return hf_cand_3prong::resoStatesXiC;
349354
default:
350355
LOG(error) << "Unknown PDG code for 3-prong final states: " << pdgMother;
351356
return {};
352357
}
353358
}
354359

360+
/// Perform the matching for a single resonant channel
361+
/// \tparam N size of the array of daughter PDG codes
362+
/// \param arrPdgResoChn array of daughter indices
363+
/// \param arrPdgDaugs array of PDG codes for the resonant decay
364+
/// \return true if the resonant channel is matched, false otherwise
355365
template <std::size_t N>
356-
bool checkResonantDecay(std::array<int, N> arrDaughIndex, std::array<int, N> arrPDGResonant) {
357-
LOG(info) << "Testing: " << arrDaughIndex[0] << ", " << arrDaughIndex[1] << " matching PDG codes: " << arrPDGResonant[0] << ", " << arrPDGResonant[1];
358-
for (int i = 0; i < N; i++) {
359-
LOG(info) << "Checking daughter index: " << arrDaughIndex[i];
360-
bool findDaug = false;
361-
for (int j = 0; j < N; j++) {
362-
LOG(info) << "Checking daughter PDG: " << arrDaughIndex[i] << " against resonant PDG: " << arrPDGResonant[j];
363-
if (std::abs(arrDaughIndex[i]) == std::abs(arrPDGResonant[j])) {
364-
arrPDGResonant[j] = -1; // Mark as found
365-
LOG(info) << "Matched!";
366-
findDaug = true;
367-
break;
368-
}
369-
}
370-
if (!findDaug) {
371-
LOG(info) << "Returning false";
372-
return false;
366+
bool checkResonantDecay(std::array<int, N> arrPdgResoChn, std::array<int, N> arrPdgDaugs) {
367+
// LOG(info) << "Testing: " << arrPdgResoChn[0] << ", " << arrPdgResoChn[1] << " matching PDG codes: " << arrPdgDaugs[0] << ", " << arrPdgDaugs[1];
368+
for (size_t i = 0; i < N; i++) {
369+
// LOG(info) << "Checking daughter index: " << arrPdgResoChn[i];
370+
bool findDaug = false;
371+
for (size_t j = 0; j < N; j++) {
372+
// LOG(info) << "Checking daughter PDG: " << arrPdgResoChn[i] << " against resonant PDG: " << arrPdgDaugs[j];
373+
if (std::abs(arrPdgResoChn[i]) == std::abs(arrPdgDaugs[j])) {
374+
arrPdgDaugs[j] = -1; // Mark as found
375+
// LOG(info) << "Matched!";
376+
findDaug = true;
377+
break;
373378
}
374379
}
375-
LOG(info) << "Resonant decay found with daughters: " << arrDaughIndex[0] << ", " << arrDaughIndex[1] << " matching PDG codes: " << arrPDGResonant[0] << ", " << arrPDGResonant[1];
376-
return true;
380+
if (!findDaug) {
381+
// LOG(info) << "Returning false";
382+
return false;
383+
}
377384
}
385+
// LOG(info) << "Resonant decay found with daughters: " << arrPdgResoChn[0] << ", " << arrPdgResoChn[1] << " matching PDG codes: " << arrPdgDaugs[0] << ", " << arrPdgDaugs[1];
386+
return true;
387+
}
378388

379-
/// Check if the decay is resonant
380-
/// \tparam arrDaughIndex index of the particle daughters at resonance level
381-
/// \tparam arrPDGResonant PDG code of the resonant decay
382-
/// \return true if the decay is resonant
383-
template <bool is3Prong = false, std::size_t N>
384-
void flagResonantDecay(int motherPdg, int8_t* channel, std::array<int, N> arrDaughIndex) {
385-
if constexpr (is3Prong) {
386-
std::unordered_map<o2::hf_decay::hf_cand_3prong::DecayChannelResonant, std::array<int, 2> > resoStates = getResoChannels3Prong(motherPdg);
387-
for (const auto& [flag, pdgCodes] : resoStates) {
388-
if (abs(motherPdg) == Pdg::kDStar) {
389-
std::cout << "Checking Dstar resonant decay with flag: " << flag << ", pdgCodes: " << pdgCodes[0] << ", " << pdgCodes[1] << " vs " << arrDaughIndex[0] << " " << arrDaughIndex[1] << std::endl;
390-
}
391-
if (checkResonantDecay(arrDaughIndex, pdgCodes)) {
392-
*channel = flag;
393-
if (abs(motherPdg) == Pdg::kDStar) {
394-
LOG(info) << "Dstar resonant decay found with channel: " << static_cast<int>(*channel);
395-
}
396-
break;
397-
}
398-
}
399-
if (abs(motherPdg) == Pdg::kDStar) {
400-
LOG(info) << "Leaving function with channel: " << static_cast<int>(*channel);
401-
}
402-
} else {
403-
if (motherPdg != Pdg::kD0) {
404-
LOG(error) << "Resonant decay flagging is only implemented for D0 resonances in 2-prong decays.";
405-
return;
389+
/// Flag the resonant decays
390+
/// Function documentation:
391+
/// \tparam is3Prong bool to specify if the mother decays with a 3-prong decay
392+
/// \tparam N size of the array of daughter PDG codes
393+
/// \param motherPdg PDG code of the mother particle
394+
/// \param channel decay channel flag to be set
395+
/// \param arrDaughPdgs array of daughter PDG codes
396+
template <bool is3Prong = false, std::size_t N>
397+
void flagResonantDecay(int motherPdg, int8_t* channel, std::array<int, N> arrDaughPdgs) {
398+
if constexpr (is3Prong) {
399+
std::unordered_map<hf_cand_3prong::DecayChannelResonant, std::array<int, 2> > resoStates = getResoChannels3Prong(motherPdg);
400+
if (abs(motherPdg) == Pdg::kDPlus) {
401+
std::cout << "Flagging resonant channel for D+ with daughters: " << arrDaughPdgs[0] << " " << arrDaughPdgs[1] << std::endl;
402+
}
403+
if (abs(motherPdg) == Pdg::kDS) {
404+
std::cout << "Flagging resonant channel for Ds with daughters: " << arrDaughPdgs[0] << " " << arrDaughPdgs[1] << std::endl;
405+
}
406+
if (abs(motherPdg) == Pdg::kDStar) {
407+
std::cout << "Flagging resonant channel for Dstar with daughters: " << arrDaughPdgs[0] << " " << arrDaughPdgs[1] << std::endl;
408+
}
409+
if (abs(motherPdg) == Pdg::kLambdaCPlus) {
410+
std::cout << "Flagging resonant channel for LambdaC with daughters: " << arrDaughPdgs[0] << " " << arrDaughPdgs[1] << std::endl;
411+
}
412+
if (abs(motherPdg) == Pdg::kXiCPlus) {
413+
std::cout << "Flagging resonant channel for XiC with daughters: " << arrDaughPdgs[0] << " " << arrDaughPdgs[1] << std::endl;
414+
}
415+
for (const auto& [flag, pdgCodes] : resoStates) {
416+
if (checkResonantDecay(arrDaughPdgs, pdgCodes)) {
417+
*channel = flag;
418+
// if (abs(motherPdg) == Pdg::kDStar) {
419+
// LOG(info) << "Dstar resonant decay found with channel: " << static_cast<int>(*channel);
420+
// }
421+
break;
406422
}
407-
for (const auto& [flag, pdgCodes] : o2::hf_decay::hf_cand_2prong::resoStatesD0) {
408-
std::cout << "Checking D0 resonant decay with flag: " << flag << ", pdgCodes: " << pdgCodes[0] << ", " << pdgCodes[1] << " vs " << arrDaughIndex[0] << " " << arrDaughIndex[1] << std::endl;
409-
if (checkResonantDecay(arrDaughIndex, pdgCodes)) {
410-
*channel = flag;
411-
LOG(info) << "D0 resonant decay found with channel: " << static_cast<int>(*channel);
412-
break;
413-
}
423+
}
424+
// if (abs(motherPdg) == Pdg::kDStar) {
425+
// LOG(info) << "Leaving function with channel: " << static_cast<int>(*channel);
426+
// }
427+
} else {
428+
if (motherPdg != Pdg::kD0) {
429+
// LOG(error) << "Resonant decay flagging is only implemented for D0 resonances in 2-prong decays.";
430+
return;
431+
}
432+
for (const auto& [flag, pdgCodes] : hf_cand_2prong::resoStatesD0) {
433+
// std::cout << "Checking D0 resonant decay with flag: " << flag << ", pdgCodes: " << pdgCodes[0] << ", " << pdgCodes[1] << " vs " << arrDaughPdgs[0] << " " << arrDaughPdgs[1] << std::endl;
434+
if (checkResonantDecay(arrDaughPdgs, pdgCodes)) {
435+
*channel = flag;
436+
// LOG(info) << "D0 resonant decay found with channel: " << static_cast<int>(*channel);
437+
break;
414438
}
415439
}
416440
}
441+
}
417442
} // namespace o2::hf_corrbkg
418443

419444
#endif // PWGHF_CORE_DECAYCHANNELS_H_

PWGHF/TableProducer/candidateCreator2Prong.cxx

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -776,8 +776,6 @@ struct HfCandidateCreator2ProngExpressions {
776776
std::vector<int> idxBhadMothers{};
777777

778778
if (matchCorrBkgs) {
779-
LOG(info) << "--------------------------------------------";
780-
LOG(info) << "Matching correlated bkgs";
781779
indexRec = -1; // Index of the matched reconstructed candidate
782780
int depth = 2;
783781
for (const auto& [chn, finalState] : finalStates2Prongs) {
@@ -799,12 +797,12 @@ struct HfCandidateCreator2ProngExpressions {
799797
if (sign < 0) {
800798
for (auto& part : finalStateParts2ProngAll) {
801799
if (part == kPi0) {
802-
part = -part; // Ensure all parts are positive for matching
800+
part = -part; // The Pi0 pdg code does not change between particle and antiparticle
803801
}
804802
}
805803
}
806804
if (!RecoDecay::isMatchedMCGen(mcParticles, motherParticle, Pdg::kD0, finalStateParts2ProngAll, false, &sign, depth)) {
807-
indexRec = -1; // Reset indexRec if the generated decay
805+
indexRec = -1; // Reset indexRec if the generated decay does not match the reconstructed one does not match the reconstructed one
808806
}
809807
}
810808
} else if (finalState.size() == 2) { // Fully Reco 2-prong decays
@@ -819,12 +817,11 @@ struct HfCandidateCreator2ProngExpressions {
819817
}
820818
} else {
821819
LOG(info) << "Final state size not supported: " << finalStateParts2Prong.size();
822-
continue; // Skip unsupported final states
820+
continue;
823821
}
824822
if (indexRec > -1) {
825-
// std::cout << "Matched final state: " << chn << " with PDG code: " << pdg << std::endl;
826-
flag = sign * chn; // Only D0 decay channels are considered here
827-
823+
flag = sign * chn;
824+
828825
// Flag the resonant decay channel
829826
int resoMaxDepth = 1;
830827
std::vector<int> arrResoDaughIndex = {};
@@ -836,13 +833,10 @@ struct HfCandidateCreator2ProngExpressions {
836833
arrPDGDaugh[iProng] = daughI.pdgCode();
837834
}
838835
flagResonantDecay(Pdg::kD0, &channel, arrPDGDaugh);
839-
// LOG(info) << "[matchFinalStateCorrBkgs] Matched D0 final state: " << chn << ", flag: " << static_cast<int>(flag) << ", &sign: " << static_cast<int>(sign);
840-
// LOG(info) << "[matchFinalStateCorrBkgs] Flag set to: " << static_cast<int>(flag) << " sign: " << static_cast<int>(sign) << " for channel: " << static_cast<int>(channel);
841836
}
842-
break; // Exit loop if a match is found
837+
break;
843838
}
844839
}
845-
// LOG(info) << "D0 matching ended with flag " << static_cast<int>(flag) << " and indexRec " << static_cast<int>(indexRec) << ", &sign " << static_cast<int>(sign) << ", channel " << static_cast<int>(channel);
846840
} else {
847841
// D0(bar) → π± K∓
848842
if (matchKinkedDecayTopology && matchInteractionsWithMaterial) {
@@ -890,10 +884,8 @@ struct HfCandidateCreator2ProngExpressions {
890884
}
891885
if (origin == RecoDecay::OriginType::NonPrompt) {
892886
auto bHadMother = mcParticles.rawIteratorAt(idxBhadMothers[0]);
893-
LOG(info) << "[MCREC] Filling with flag: " << static_cast<int>(flag) << ", origin: " << static_cast<int>(origin) << ", channel: " << static_cast<int>(channel);
894887
rowMcMatchRec(flag, origin, channel, bHadMother.pt(), bHadMother.pdgCode(), nKinkedTracks, nInteractionsWithMaterial);
895888
} else {
896-
LOG(info) << "[MCREC] Filling with flag: " << static_cast<int>(flag) << ", origin: " << static_cast<int>(origin) << ", channel: " << static_cast<int>(channel);
897889
rowMcMatchRec(flag, origin, channel, -1.f, 0, nKinkedTracks, nInteractionsWithMaterial);
898890
}
899891
}

0 commit comments

Comments
 (0)