2525#include < tuple> // std::apply
2626#include < utility> // std::move
2727#include < vector> // std::vector
28+ #include < iostream>
2829
2930// ROOT includes
3031#include < TMCProcess.h> // for VMC Particle Production Process
@@ -918,12 +919,20 @@ struct RecoDecay {
918919 }
919920 // Check the PDG code of the particle.
920921 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+ }
921927 // Printf("MC Gen: Candidate PDG: %d", pdgCandidate);
922928 if (pdgCandidate == pdgParticle) { // exact PDG match
923929 sgn = 1 ;
924930 } else if (acceptAntiParticles && pdgCandidate == -pdgParticle) { // antiparticle PDG match
925931 sgn = -1 ;
926932 } else {
933+ if (debugPrint) {
934+ std::cout << " MC Gen: Rejected: bad particle PDG: " << (acceptAntiParticles ? " abs " : " " ) << pdgCandidate << " != " << pdgParticle << std::endl;
935+ }
927936 // Printf("MC Gen: Rejected: bad particle PDG: %s%d != %d", acceptAntiParticles ? "abs " : "", pdgCandidate, std::abs(pdgParticle));
928937 return false ;
929938 }
@@ -933,25 +942,42 @@ struct RecoDecay {
933942 std::vector<int > arrAllDaughtersIndex; // vector of indices of all daughters
934943 // Check the daughter indices.
935944 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+ }
936948 // Printf("MC Gen: Rejected: bad daughter index range: %d-%d", candidate.daughtersIds().front(), candidate.daughtersIds().back());
937949 return false ;
938950 }
939951 // Check that the number of direct daughters is not larger than the number of expected final daughters.
940952 if constexpr (!checkProcess) {
941953 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+ }
942958 // Printf("MC Gen: Rejected: too many direct daughters: %d (expected %ld final)", candidate.daughtersIds().back() - candidate.daughtersIds().front() + 1, N);
943959 return false ;
944960 }
945961 }
946962 // Get the list of actual final daughters.
947963 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+ }
948971 // printf("MC Gen: Mother %ld has %ld final daughters:", candidate.globalIndex(), arrAllDaughtersIndex.size());
949972 // for (auto i : arrAllDaughtersIndex) {
950973 // printf(" %d", i);
951974 // }
952975 // printf("\n");
953976 // Check whether the number of final daughters is equal to the required number.
954977 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+ }
955981 // Printf("MC Gen: Rejected: incorrect number of final daughters: %ld (expected %ld)", arrAllDaughtersIndex.size(), N);
956982 return false ;
957983 }
@@ -969,16 +995,25 @@ struct RecoDecay {
969995 for (auto indexDaughterI : arrAllDaughtersIndex) { // o2-linter: disable=const-ref-in-for-loop (int elements)
970996 auto candidateDaughterI = particlesMC.rawIteratorAt (indexDaughterI - particlesMC.offset ()); // ith daughter particle
971997 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+ }
9721001 // Printf("MC Gen: Daughter %d PDG: %d", indexDaughterI, pdgCandidateDaughterI);
9731002 bool isPdgFound = false ; // Is the PDG code of this daughter among the remaining expected PDG codes?
9741003 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+ }
9751007 if (pdgCandidateDaughterI == coefFlavourOscillation * sgn * arrPdgDaughters[iProngCp]) {
9761008 arrPdgDaughters[iProngCp] = 0 ; // Remove this PDG code from the array of expected ones.
9771009 isPdgFound = true ;
9781010 break ;
9791011 }
9801012 }
9811013 if (!isPdgFound) {
1014+ if (debugPrint) {
1015+ std::cout << " MC Gen: Rejected: bad daughter PDG: " << pdgCandidateDaughterI << std::endl;
1016+ }
9821017 // Printf("MC Gen: Rejected: bad daughter PDG: %d", pdgCandidateDaughterI);
9831018 return false ;
9841019 }
@@ -987,6 +1022,9 @@ struct RecoDecay {
9871022 *listIndexDaughters = arrAllDaughtersIndex;
9881023 }
9891024 }
1025+ if (debugPrint) {
1026+ std::cout << " MC Gen: Accepted: m: " << candidate.globalIndex () << std::endl;
1027+ }
9901028 // Printf("MC Gen: Accepted: m: %d", candidate.globalIndex());
9911029 if (sign) {
9921030 *sign = sgn;
0 commit comments