@@ -107,6 +107,7 @@ bool doCoal(Pythia8::Event& event, int charge, int pdgCode, float mass, bool tri
107107bool CoalescencePythia8 (Pythia8::Event& event, std::vector<unsigned int > inputPdgList = {}, bool trivialCoal = false , double coalMomentum = 0.4 , int firstDauID = -1 , int lastDauId = -1 , float maxRapidity = 1 .)
108108{
109109 const double coalescenceRadius{0.5 * 1.122462 * coalMomentum};
110+
110111 // if coalescence from a heavy hadron, loop only between firstDauID and lastDauID
111112 int loopStart = firstDauID > -1 ? firstDauID : 0 ;
112113 int loopEnd = lastDauId > -1 ? lastDauId : event.size () - 1 ;
@@ -143,7 +144,7 @@ bool CoalescencePythia8(Pythia8::Event& event, std::vector<unsigned int> inputPd
143144 lambdas[event[iPart].id () > 0 ].push_back (iPart);
144145 }
145146 }
146- // run coalescence
147+ // Run coalescence
147148 bool nuclFromDecay = firstDauID > -1 ;
148149 bool coalHappened = false ;
149150
@@ -152,26 +153,41 @@ bool CoalescencePythia8(Pythia8::Event& event, std::vector<unsigned int> inputPd
152153 for (int iN{0 }; iN < neutrons[iC].size (); ++iN) {
153154 if (nuclearMask & (1 << kDeuteron )) {
154155 coalHappened |= doCoal (event, iC, pdgList[kDeuteron ], massList[kDeuteron ], trivialCoal, coalescenceRadius, nuclFromDecay, protons[iC][iP], neutrons[iC][iN]);
156+ if (nuclFromDecay && coalHappened) {
157+ return true ;
158+ }
155159 }
156160 if (nuclearMask & (1 << kTriton )) {
157161 for (int iN2{iN + 1 }; iN2 < neutrons[iC].size (); ++iN2) {
158162 coalHappened |= doCoal (event, iC, pdgList[kTriton ], massList[kTriton ], trivialCoal, coalescenceRadius, nuclFromDecay, protons[iC][iP], neutrons[iC][iN], neutrons[iC][iN2]);
163+ if (nuclFromDecay && coalHappened) {
164+ return true ;
165+ }
159166 }
160167 }
161168 if (nuclearMask & (1 << kHe3 )) {
162169 for (int iP2{iP + 1 }; iP2 < protons[iC].size (); ++iP2) {
163170 coalHappened |= doCoal (event, iC, pdgList[kHe3 ], massList[kHe3 ], trivialCoal, coalescenceRadius, nuclFromDecay, protons[iC][iP], protons[iC][iP2], neutrons[iC][iN]);
171+ if (nuclFromDecay && coalHappened) {
172+ return true ;
173+ }
164174 }
165175 }
166176 if (nuclearMask & (1 << kHyperTriton )) {
167177 for (int iL{0 }; iL < lambdas[iC].size (); ++iL) {
168178 coalHappened |= doCoal (event, iC, pdgList[kHyperTriton ], massList[kHyperTriton ], trivialCoal, coalescenceRadius, nuclFromDecay, protons[iC][iP], neutrons[iC][iN], lambdas[iC][iL]);
179+ if (nuclFromDecay && coalHappened) {
180+ return true ;
181+ }
169182 }
170183 }
171184 if (nuclearMask & (1 << kHe4 )) {
172185 for (int iP2{iP + 1 }; iP2 < protons[iC].size (); ++iP2) {
173186 for (int iN2{iN + 1 }; iN2 < neutrons[iC].size (); ++iN2) {
174187 coalHappened |= doCoal (event, iC, pdgList[kHe4 ], massList[kHe4 ], trivialCoal, coalescenceRadius, nuclFromDecay, protons[iC][iP], protons[iC][iP2], neutrons[iC][iN], neutrons[iC][iN2]);
188+ if (nuclFromDecay && coalHappened) {
189+ return true ;
190+ }
175191 }
176192 }
177193 }
0 commit comments