From a603c0c57c9d259827fdfb954d2a67b493e341e0 Mon Sep 17 00:00:00 2001 From: Alberto Caliva Date: Thu, 23 Jul 2026 21:06:42 +0200 Subject: [PATCH] Fix seg fault caused by stale particle indices after coalescence from HF decays --- MC/config/common/external/generator/CoalescencePythia8.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/MC/config/common/external/generator/CoalescencePythia8.h b/MC/config/common/external/generator/CoalescencePythia8.h index 7e4abc53e..270184a73 100644 --- a/MC/config/common/external/generator/CoalescencePythia8.h +++ b/MC/config/common/external/generator/CoalescencePythia8.h @@ -152,6 +152,9 @@ bool CoalescencePythia8(Pythia8::Event& event, std::vector inputPd for (int iN{0}; iN < neutrons[iC].size(); ++iN) { if (nuclearMask & (1 << kDeuteron)) { coalHappened |= doCoal(event, iC, pdgList[kDeuteron], massList[kDeuteron], trivialCoal, coalescenceRadius, nuclFromDecay, protons[iC][iP], neutrons[iC][iN]); + if (nuclFromDecay && coalHappened) { + return true; + } } if (nuclearMask & (1 << kTriton)) { for (int iN2{iN + 1}; iN2 < neutrons[iC].size(); ++iN2) {