@@ -61,36 +61,38 @@ protected:
6161 bool isPhysicalPrimaryOrFromHF (const Pythia8 ::Particle & p ,
6262 const Pythia8 ::Event & event )
6363 {
64- // Must be final
6564 if (!p .isFinal ()) {
6665 return false;
6766 }
6867
69- // Physical primary: no real mother (or beam)
70- if (p .mother1 () <= 0 ) {
71- return true;
68+ const int absPdg = std ::abs (p .id ());
69+
70+ // Particle species selection
71+ const bool isAcceptedSpecies = (absPdg == 211 || absPdg == 321 || absPdg == 2212 || absPdg == 1000010020 || absPdg == 11 || absPdg == 13 );
72+
73+ if (!isAcceptedSpecies ) {
74+ return false;
7275 }
7376
74- // Walk up ancestry to identify charm or beauty
77+ // Walk up ancestry
7578 int motherIdx = p .mother1 ();
79+
7680 while (motherIdx > 0 ) {
7781 const auto& mother = event [motherIdx ];
78- int absPdg = std ::abs (mother .id ());
82+ const int absMotherPdg = std ::abs (mother .id ());
7983
80- // Charm or beauty hadrons
81- if ((absPdg / 100 == 4 ) || (absPdg / 100 == 5 ) ||
82- (absPdg / 1000 == 4 ) || (absPdg / 1000 == 5 )) {
84+ // Charm or beauty hadron → accept (HF decay)
85+ if ((absMotherPdg / 100 == 4 ) || (absMotherPdg / 100 == 5 ) || (absMotherPdg / 1000 == 4 ) || (absMotherPdg / 1000 == 5 )) {
8386 return true;
8487 }
8588
86- // Stop at beam
87- if (mother .mother1 () <= 0 ) {
88- break ;
89+ // Weakly decaying hadron → reject (non-physical primary)
90+ if (mother .isHadron () && mother . tau0 () > 1. 0 ) {
91+ return false ;
8992 }
9093 motherIdx = mother .mother1 ();
9194 }
92-
93- return false;
95+ return true;
9496 }
9597
9698 bool generateEvent () override {
0 commit comments