Skip to content

Commit 359c8f9

Browse files
committed
Prevent invalid particle index access after decay coalescence
1 parent a603c0c commit 359c8f9

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

MC/config/common/external/generator/CoalescencePythia8.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,22 +159,34 @@ bool CoalescencePythia8(Pythia8::Event& event, std::vector<unsigned int> inputPd
159159
if (nuclearMask & (1 << kTriton)) {
160160
for (int iN2{iN + 1}; iN2 < neutrons[iC].size(); ++iN2) {
161161
coalHappened |= doCoal(event, iC, pdgList[kTriton], massList[kTriton], trivialCoal, coalescenceRadius, nuclFromDecay, protons[iC][iP], neutrons[iC][iN], neutrons[iC][iN2]);
162+
if (nuclFromDecay && coalHappened) {
163+
return true;
164+
}
162165
}
163166
}
164167
if (nuclearMask & (1 << kHe3)) {
165168
for (int iP2{iP + 1}; iP2 < protons[iC].size(); ++iP2) {
166169
coalHappened |= doCoal(event, iC, pdgList[kHe3], massList[kHe3], trivialCoal, coalescenceRadius, nuclFromDecay, protons[iC][iP], protons[iC][iP2], neutrons[iC][iN]);
170+
if (nuclFromDecay && coalHappened) {
171+
return true;
172+
}
167173
}
168174
}
169175
if (nuclearMask & (1 << kHyperTriton)) {
170176
for (int iL{0}; iL < lambdas[iC].size(); ++iL) {
171177
coalHappened |= doCoal(event, iC, pdgList[kHyperTriton], massList[kHyperTriton], trivialCoal, coalescenceRadius, nuclFromDecay, protons[iC][iP], neutrons[iC][iN], lambdas[iC][iL]);
178+
if (nuclFromDecay && coalHappened) {
179+
return true;
180+
}
172181
}
173182
}
174183
if (nuclearMask & (1 << kHe4)) {
175184
for (int iP2{iP + 1}; iP2 < protons[iC].size(); ++iP2) {
176185
for (int iN2{iN + 1}; iN2 < neutrons[iC].size(); ++iN2) {
177186
coalHappened |= doCoal(event, iC, pdgList[kHe4], massList[kHe4], trivialCoal, coalescenceRadius, nuclFromDecay, protons[iC][iP], protons[iC][iP2], neutrons[iC][iN], neutrons[iC][iN2]);
187+
if (nuclFromDecay && coalHappened) {
188+
return true;
189+
}
178190
}
179191
}
180192
}

0 commit comments

Comments
 (0)