@@ -562,12 +562,13 @@ class RecoDecay
562562 // / \param depthMax maximum decay tree level; Daughters at this level (or beyond) will be considered final. If -1, all levels are considered.
563563 // / \param stage decay tree level; If different from 0, the particle itself will be added in the list in case it has no daughters.
564564 // / \note Final state is defined as particles from arrPDGFinal plus final daughters of any other decay branch.
565+ // / \note Antiparticles of particles in arrPDGFinal are accepted as well.
565566 template <std::size_t N, typename T>
566567 static void getDaughters (const T& particlesMC,
567568 int index,
568569 std::vector<int >* list,
569570 const array<int , N>& arrPDGFinal,
570- int depthMax = -1 ,
571+ int8_t depthMax = -1 ,
571572 int8_t stage = 0 )
572573 {
573574 if (index <= -1 ) {
@@ -597,11 +598,12 @@ class RecoDecay
597598 // If this is not the original particle, we are at the end of this branch and this particle is final.
598599 isFinal = true ;
599600 }
600- // If the particle has daughters but is considered to be final, we label it as final.
601- auto PDGParticle = particle.pdgCode ();
602- if (!isFinal) {
601+ auto PDGParticle = std::abs (particle.pdgCode ());
602+ // If this is not the original particle, check its PDG code.
603+ if (!isFinal && stage > 0 ) {
604+ // If the particle has daughters but is considered to be final, we label it as final.
603605 for (auto PDGi : arrPDGFinal) {
604- if (std::abs ( PDGParticle) == std::abs (PDGi)) { // Accept antiparticles.
606+ if (PDGParticle == std::abs (PDGi)) { // Accept antiparticles.
605607 isFinal = true ;
606608 break ;
607609 }
@@ -744,12 +746,13 @@ class RecoDecay
744746 // / \param candidate candidate MC particle
745747 // / \param PDGParticle expected particle PDG code
746748 // / \param acceptAntiParticles switch to accept the antiparticle
749+ // / \param sign antiparticle indicator of the candidate w.r.t. PDGParticle; 1 if particle, -1 if antiparticle, 0 if not matched
747750 // / \return true if PDG code of the particle is correct, false otherwise
748751 template <typename T, typename U>
749- static int isMatchedMCGen (const T& particlesMC, const U& candidate, int PDGParticle, bool acceptAntiParticles = false )
752+ static int isMatchedMCGen (const T& particlesMC, const U& candidate, int PDGParticle, bool acceptAntiParticles = false , int8_t * sign = nullptr )
750753 {
751754 array<int , 0 > arrPDGDaughters;
752- return isMatchedMCGen (particlesMC, candidate, PDGParticle, std::move (arrPDGDaughters), acceptAntiParticles);
755+ return isMatchedMCGen (particlesMC, candidate, PDGParticle, std::move (arrPDGDaughters), acceptAntiParticles, sign );
753756 }
754757
755758 // / Check whether the MC particle is the expected one and whether it decayed via the expected decay channel.
@@ -776,8 +779,7 @@ class RecoDecay
776779 sgn = 1 ;
777780 } else if (acceptAntiParticles && PDGCandidate == -PDGParticle) { // antiparticle PDG match
778781 sgn = -1 ;
779- }
780- if (sgn == 0 ) {
782+ } else {
781783 // Printf("MC Gen: Rejected: bad particle PDG: %s%d != %d", acceptAntiParticles ? "abs " : "", PDGCandidate, std::abs(PDGParticle));
782784 return false ;
783785 }
0 commit comments