Skip to content

Commit b30536c

Browse files
committed
Delete debug prints for 2prong code
1 parent 7a470ef commit b30536c

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
@@ -25,7 +25,6 @@
2525
#include <tuple> // std::apply
2626
#include <utility> // std::move
2727
#include <vector> // std::vector
28-
#include <iostream>
2928

3029
// ROOT includes
3130
#include <TMCProcess.h> // for VMC Particle Production Process
@@ -919,20 +918,12 @@ struct RecoDecay {
919918
}
920919
// Check the PDG code of the particle.
921920
auto pdgCandidate = candidate.pdgCode();
922-
bool debugPrint = false; // Set to true to enable debug printing.
923-
if (std::abs(pdgCandidate) == 413) {
924-
// Printf("MC Gen: Candidate PDG: %d", pdgCandidate);
925-
debugPrint = true; // Enable debug printing for D*.
926-
}
927921
// Printf("MC Gen: Candidate PDG: %d", pdgCandidate);
928922
if (pdgCandidate == pdgParticle) { // exact PDG match
929923
sgn = 1;
930924
} else if (acceptAntiParticles && pdgCandidate == -pdgParticle) { // antiparticle PDG match
931925
sgn = -1;
932926
} else {
933-
if (debugPrint) {
934-
std::cout << "MC Gen: Rejected: bad particle PDG: " << (acceptAntiParticles ? "abs " : "") << pdgCandidate << " != " << pdgParticle << std::endl;
935-
}
936927
// Printf("MC Gen: Rejected: bad particle PDG: %s%d != %d", acceptAntiParticles ? "abs " : "", pdgCandidate, std::abs(pdgParticle));
937928
return false;
938929
}
@@ -942,42 +933,25 @@ struct RecoDecay {
942933
std::vector<int> arrAllDaughtersIndex; // vector of indices of all daughters
943934
// Check the daughter indices.
944935
if (!candidate.has_daughters()) {
945-
if (debugPrint) {
946-
std::cout << "MC Gen: Rejected: bad daughter index range: " << candidate.daughtersIds().front() << "-" << candidate.daughtersIds().back() << std::endl;
947-
}
948936
// Printf("MC Gen: Rejected: bad daughter index range: %d-%d", candidate.daughtersIds().front(), candidate.daughtersIds().back());
949937
return false;
950938
}
951939
// Check that the number of direct daughters is not larger than the number of expected final daughters.
952940
if constexpr (!checkProcess) {
953941
if (candidate.daughtersIds().back() - candidate.daughtersIds().front() + 1 > static_cast<int>(N)) {
954-
if (debugPrint) {
955-
std::cout << "MC Gen: Rejected: too many direct daughters: " << candidate.daughtersIds().back() - candidate.daughtersIds().front() + 1
956-
<< " (expected " << N << " final)" << std::endl;
957-
}
958942
// Printf("MC Gen: Rejected: too many direct daughters: %d (expected %ld final)", candidate.daughtersIds().back() - candidate.daughtersIds().front() + 1, N);
959943
return false;
960944
}
961945
}
962946
// Get the list of actual final daughters.
963947
getDaughters<checkProcess>(candidate, &arrAllDaughtersIndex, arrPdgDaughters, depthMax);
964-
if (debugPrint) {
965-
std::cout << "MC Gen: Mother " << candidate.globalIndex() << " has " << arrAllDaughtersIndex.size() << " final daughters:";
966-
for (auto i : arrAllDaughtersIndex) {
967-
std::cout << " " << i;
968-
}
969-
std::cout << std::endl;
970-
}
971948
// printf("MC Gen: Mother %ld has %ld final daughters:", candidate.globalIndex(), arrAllDaughtersIndex.size());
972949
// for (auto i : arrAllDaughtersIndex) {
973950
// printf(" %d", i);
974951
// }
975952
// printf("\n");
976953
// Check whether the number of final daughters is equal to the required number.
977954
if (arrAllDaughtersIndex.size() != N) {
978-
if (debugPrint) {
979-
std::cout << "MC Gen: Rejected: incorrect number of final daughters: " << arrAllDaughtersIndex.size() << " (expected " << N << ")" << std::endl;
980-
}
981955
// Printf("MC Gen: Rejected: incorrect number of final daughters: %ld (expected %ld)", arrAllDaughtersIndex.size(), N);
982956
return false;
983957
}
@@ -995,25 +969,16 @@ struct RecoDecay {
995969
for (auto indexDaughterI : arrAllDaughtersIndex) { // o2-linter: disable=const-ref-in-for-loop (int elements)
996970
auto candidateDaughterI = particlesMC.rawIteratorAt(indexDaughterI - particlesMC.offset()); // ith daughter particle
997971
auto pdgCandidateDaughterI = candidateDaughterI.pdgCode(); // PDG code of the ith daughter
998-
if (debugPrint) {
999-
std::cout << "MC Gen: Daughter " << indexDaughterI << " PDG: " << pdgCandidateDaughterI << std::endl;
1000-
}
1001972
// Printf("MC Gen: Daughter %d PDG: %d", indexDaughterI, pdgCandidateDaughterI);
1002973
bool isPdgFound = false; // Is the PDG code of this daughter among the remaining expected PDG codes?
1003974
for (std::size_t iProngCp = 0; iProngCp < N; ++iProngCp) {
1004-
if (debugPrint) {
1005-
std::cout << "MC Gen: Checking against expected PDG: " << coefFlavourOscillation * sgn * arrPdgDaughters[iProngCp] << std::endl;
1006-
}
1007975
if (pdgCandidateDaughterI == coefFlavourOscillation * sgn * arrPdgDaughters[iProngCp]) {
1008976
arrPdgDaughters[iProngCp] = 0; // Remove this PDG code from the array of expected ones.
1009977
isPdgFound = true;
1010978
break;
1011979
}
1012980
}
1013981
if (!isPdgFound) {
1014-
if (debugPrint) {
1015-
std::cout << "MC Gen: Rejected: bad daughter PDG: " << pdgCandidateDaughterI << std::endl;
1016-
}
1017982
// Printf("MC Gen: Rejected: bad daughter PDG: %d", pdgCandidateDaughterI);
1018983
return false;
1019984
}
@@ -1022,9 +987,6 @@ struct RecoDecay {
1022987
*listIndexDaughters = arrAllDaughtersIndex;
1023988
}
1024989
}
1025-
if (debugPrint) {
1026-
std::cout << "MC Gen: Accepted: m: " << candidate.globalIndex() << std::endl;
1027-
}
1028990
// Printf("MC Gen: Accepted: m: %d", candidate.globalIndex());
1029991
if (sign) {
1030992
*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}},
@@ -336,108 +335,134 @@ enum DecayChannelToJpsiResonant : int8_t {
336335
} // namespace hf_cand_beauty
337336
} // namespace o2::hf_decay
338337

339-
// using namespace o2::hf_decay;
340-
341338
namespace o2::hf_corrbkg
342339
{
343-
std::unordered_map<o2::hf_decay::hf_cand_3prong::DecayChannelMain, std::vector<int> > getDecayChannel3Prong(int pdgMother) {
340+
using namespace o2::hf_decay;
341+
342+
/// Returns a map of the possible final states for a specific 3-prong particle specie
343+
/// \param pdgMother PDG code of the mother particle
344+
/// \return a map of final states with their corresponding PDG codes
345+
std::unordered_map<hf_cand_3prong::DecayChannelMain, std::vector<int> > getDecayChannel3Prong(int pdgMother) {
344346
switch (pdgMother) {
345347
case Pdg::kDPlus:
346-
return o2::hf_decay::hf_cand_3prong::finalStatesDPlus;
348+
return hf_cand_3prong::finalStatesDPlus;
347349
case Pdg::kDS:
348-
return o2::hf_decay::hf_cand_3prong::finalStatesDs;
350+
return hf_cand_3prong::finalStatesDs;
349351
case Pdg::kDStar:
350-
return o2::hf_decay::hf_cand_3prong::finalStatesDstar;
352+
return hf_cand_3prong::finalStatesDstar;
351353
case Pdg::kLambdaCPlus:
352-
return o2::hf_decay::hf_cand_3prong::finalStatesLc;
354+
return hf_cand_3prong::finalStatesLc;
353355
case Pdg::kXiCPlus:
354-
return o2::hf_decay::hf_cand_3prong::finalStatesXic;
356+
return hf_cand_3prong::finalStatesXic;
355357
default:
356358
LOG(error) << "Unknown PDG code for 3-prong final states: " << pdgMother;
357359
return {};
358360
}
359361
}
360362

361-
std::unordered_map<o2::hf_decay::hf_cand_3prong::DecayChannelResonant, std::array<int, 2> > getResoChannels3Prong(int pdgMother) {
363+
/// Returns a map of the resonant decay channels for a specific 3-prong particle specie
364+
/// \param pdgMother PDG code of the mother particle
365+
/// \return a map of resonant decay channels with their corresponding PDG codes
366+
std::unordered_map<hf_cand_3prong::DecayChannelResonant, std::array<int, 2> > getResoChannels3Prong(int pdgMother) {
362367
switch (pdgMother) {
363368
case Pdg::kDPlus:
364-
return o2::hf_decay::hf_cand_3prong::resoStatesDPlus;
369+
return hf_cand_3prong::resoStatesDPlus;
365370
case Pdg::kDS:
366-
return o2::hf_decay::hf_cand_3prong::resoStatesDs;
371+
return hf_cand_3prong::resoStatesDs;
367372
case Pdg::kDStar:
368-
return o2::hf_decay::hf_cand_3prong::resoStatesDstar;
373+
return hf_cand_3prong::resoStatesDstar;
369374
case Pdg::kLambdaCPlus:
370-
return o2::hf_decay::hf_cand_3prong::resoStatesLambdaC;
375+
return hf_cand_3prong::resoStatesLambdaC;
371376
case Pdg::kXiCPlus:
372-
return o2::hf_decay::hf_cand_3prong::resoStatesXiC;
377+
return hf_cand_3prong::resoStatesXiC;
373378
default:
374379
LOG(error) << "Unknown PDG code for 3-prong final states: " << pdgMother;
375380
return {};
376381
}
377382
}
378383

384+
/// Perform the matching for a single resonant channel
385+
/// \tparam N size of the array of daughter PDG codes
386+
/// \param arrPdgResoChn array of daughter indices
387+
/// \param arrPdgDaugs array of PDG codes for the resonant decay
388+
/// \return true if the resonant channel is matched, false otherwise
379389
template <std::size_t N>
380-
bool checkResonantDecay(std::array<int, N> arrDaughIndex, std::array<int, N> arrPDGResonant) {
381-
LOG(info) << "Testing: " << arrDaughIndex[0] << ", " << arrDaughIndex[1] << " matching PDG codes: " << arrPDGResonant[0] << ", " << arrPDGResonant[1];
382-
for (int i = 0; i < N; i++) {
383-
LOG(info) << "Checking daughter index: " << arrDaughIndex[i];
384-
bool findDaug = false;
385-
for (int j = 0; j < N; j++) {
386-
LOG(info) << "Checking daughter PDG: " << arrDaughIndex[i] << " against resonant PDG: " << arrPDGResonant[j];
387-
if (std::abs(arrDaughIndex[i]) == std::abs(arrPDGResonant[j])) {
388-
arrPDGResonant[j] = -1; // Mark as found
389-
LOG(info) << "Matched!";
390-
findDaug = true;
391-
break;
392-
}
393-
}
394-
if (!findDaug) {
395-
LOG(info) << "Returning false";
396-
return false;
390+
bool checkResonantDecay(std::array<int, N> arrPdgResoChn, std::array<int, N> arrPdgDaugs) {
391+
// LOG(info) << "Testing: " << arrPdgResoChn[0] << ", " << arrPdgResoChn[1] << " matching PDG codes: " << arrPdgDaugs[0] << ", " << arrPdgDaugs[1];
392+
for (size_t i = 0; i < N; i++) {
393+
// LOG(info) << "Checking daughter index: " << arrPdgResoChn[i];
394+
bool findDaug = false;
395+
for (size_t j = 0; j < N; j++) {
396+
// LOG(info) << "Checking daughter PDG: " << arrPdgResoChn[i] << " against resonant PDG: " << arrPdgDaugs[j];
397+
if (std::abs(arrPdgResoChn[i]) == std::abs(arrPdgDaugs[j])) {
398+
arrPdgDaugs[j] = -1; // Mark as found
399+
// LOG(info) << "Matched!";
400+
findDaug = true;
401+
break;
397402
}
398403
}
399-
LOG(info) << "Resonant decay found with daughters: " << arrDaughIndex[0] << ", " << arrDaughIndex[1] << " matching PDG codes: " << arrPDGResonant[0] << ", " << arrPDGResonant[1];
400-
return true;
404+
if (!findDaug) {
405+
// LOG(info) << "Returning false";
406+
return false;
407+
}
401408
}
409+
// LOG(info) << "Resonant decay found with daughters: " << arrPdgResoChn[0] << ", " << arrPdgResoChn[1] << " matching PDG codes: " << arrPdgDaugs[0] << ", " << arrPdgDaugs[1];
410+
return true;
411+
}
402412

403-
/// Check if the decay is resonant
404-
/// \tparam arrDaughIndex index of the particle daughters at resonance level
405-
/// \tparam arrPDGResonant PDG code of the resonant decay
406-
/// \return true if the decay is resonant
407-
template <bool is3Prong = false, std::size_t N>
408-
void flagResonantDecay(int motherPdg, int8_t* channel, std::array<int, N> arrDaughIndex) {
409-
if constexpr (is3Prong) {
410-
std::unordered_map<o2::hf_decay::hf_cand_3prong::DecayChannelResonant, std::array<int, 2> > resoStates = getResoChannels3Prong(motherPdg);
411-
for (const auto& [flag, pdgCodes] : resoStates) {
412-
if (abs(motherPdg) == Pdg::kDStar) {
413-
std::cout << "Checking Dstar resonant decay with flag: " << flag << ", pdgCodes: " << pdgCodes[0] << ", " << pdgCodes[1] << " vs " << arrDaughIndex[0] << " " << arrDaughIndex[1] << std::endl;
414-
}
415-
if (checkResonantDecay(arrDaughIndex, pdgCodes)) {
416-
*channel = flag;
417-
if (abs(motherPdg) == Pdg::kDStar) {
418-
LOG(info) << "Dstar resonant decay found with channel: " << static_cast<int>(*channel);
419-
}
420-
break;
421-
}
422-
}
423-
if (abs(motherPdg) == Pdg::kDStar) {
424-
LOG(info) << "Leaving function with channel: " << static_cast<int>(*channel);
425-
}
426-
} else {
427-
if (motherPdg != Pdg::kD0) {
428-
LOG(error) << "Resonant decay flagging is only implemented for D0 resonances in 2-prong decays.";
429-
return;
413+
/// Flag the resonant decays
414+
/// Function documentation:
415+
/// \tparam is3Prong bool to specify if the mother decays with a 3-prong decay
416+
/// \tparam N size of the array of daughter PDG codes
417+
/// \param motherPdg PDG code of the mother particle
418+
/// \param channel decay channel flag to be set
419+
/// \param arrDaughPdgs array of daughter PDG codes
420+
template <bool is3Prong = false, std::size_t N>
421+
void flagResonantDecay(int motherPdg, int8_t* channel, std::array<int, N> arrDaughPdgs) {
422+
if constexpr (is3Prong) {
423+
std::unordered_map<hf_cand_3prong::DecayChannelResonant, std::array<int, 2> > resoStates = getResoChannels3Prong(motherPdg);
424+
if (abs(motherPdg) == Pdg::kDPlus) {
425+
std::cout << "Flagging resonant channel for D+ with daughters: " << arrDaughPdgs[0] << " " << arrDaughPdgs[1] << std::endl;
426+
}
427+
if (abs(motherPdg) == Pdg::kDS) {
428+
std::cout << "Flagging resonant channel for Ds with daughters: " << arrDaughPdgs[0] << " " << arrDaughPdgs[1] << std::endl;
429+
}
430+
if (abs(motherPdg) == Pdg::kDStar) {
431+
std::cout << "Flagging resonant channel for Dstar with daughters: " << arrDaughPdgs[0] << " " << arrDaughPdgs[1] << std::endl;
432+
}
433+
if (abs(motherPdg) == Pdg::kLambdaCPlus) {
434+
std::cout << "Flagging resonant channel for LambdaC with daughters: " << arrDaughPdgs[0] << " " << arrDaughPdgs[1] << std::endl;
435+
}
436+
if (abs(motherPdg) == Pdg::kXiCPlus) {
437+
std::cout << "Flagging resonant channel for XiC with daughters: " << arrDaughPdgs[0] << " " << arrDaughPdgs[1] << std::endl;
438+
}
439+
for (const auto& [flag, pdgCodes] : resoStates) {
440+
if (checkResonantDecay(arrDaughPdgs, pdgCodes)) {
441+
*channel = flag;
442+
// if (abs(motherPdg) == Pdg::kDStar) {
443+
// LOG(info) << "Dstar resonant decay found with channel: " << static_cast<int>(*channel);
444+
// }
445+
break;
430446
}
431-
for (const auto& [flag, pdgCodes] : o2::hf_decay::hf_cand_2prong::resoStatesD0) {
432-
std::cout << "Checking D0 resonant decay with flag: " << flag << ", pdgCodes: " << pdgCodes[0] << ", " << pdgCodes[1] << " vs " << arrDaughIndex[0] << " " << arrDaughIndex[1] << std::endl;
433-
if (checkResonantDecay(arrDaughIndex, pdgCodes)) {
434-
*channel = flag;
435-
LOG(info) << "D0 resonant decay found with channel: " << static_cast<int>(*channel);
436-
break;
437-
}
447+
}
448+
// if (abs(motherPdg) == Pdg::kDStar) {
449+
// LOG(info) << "Leaving function with channel: " << static_cast<int>(*channel);
450+
// }
451+
} else {
452+
if (motherPdg != Pdg::kD0) {
453+
// LOG(error) << "Resonant decay flagging is only implemented for D0 resonances in 2-prong decays.";
454+
return;
455+
}
456+
for (const auto& [flag, pdgCodes] : hf_cand_2prong::resoStatesD0) {
457+
// std::cout << "Checking D0 resonant decay with flag: " << flag << ", pdgCodes: " << pdgCodes[0] << ", " << pdgCodes[1] << " vs " << arrDaughPdgs[0] << " " << arrDaughPdgs[1] << std::endl;
458+
if (checkResonantDecay(arrDaughPdgs, pdgCodes)) {
459+
*channel = flag;
460+
// LOG(info) << "D0 resonant decay found with channel: " << static_cast<int>(*channel);
461+
break;
438462
}
439463
}
440464
}
465+
}
441466
} // namespace o2::hf_corrbkg
442467

443468
#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)