From a603c0c57c9d259827fdfb954d2a67b493e341e0 Mon Sep 17 00:00:00 2001 From: Alberto Caliva Date: Thu, 23 Jul 2026 21:06:42 +0200 Subject: [PATCH 1/3] 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) { From 359c8f96fc193dd8df806ab13c4bd0dcdbf29052 Mon Sep 17 00:00:00 2001 From: Alberto Caliva Date: Mon, 27 Jul 2026 19:25:51 +0200 Subject: [PATCH 2/3] Prevent invalid particle index access after decay coalescence --- .../common/external/generator/CoalescencePythia8.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/MC/config/common/external/generator/CoalescencePythia8.h b/MC/config/common/external/generator/CoalescencePythia8.h index 270184a73..378dcc0b4 100644 --- a/MC/config/common/external/generator/CoalescencePythia8.h +++ b/MC/config/common/external/generator/CoalescencePythia8.h @@ -159,22 +159,34 @@ bool CoalescencePythia8(Pythia8::Event& event, std::vector inputPd if (nuclearMask & (1 << kTriton)) { for (int iN2{iN + 1}; iN2 < neutrons[iC].size(); ++iN2) { coalHappened |= doCoal(event, iC, pdgList[kTriton], massList[kTriton], trivialCoal, coalescenceRadius, nuclFromDecay, protons[iC][iP], neutrons[iC][iN], neutrons[iC][iN2]); + if (nuclFromDecay && coalHappened) { + return true; + } } } if (nuclearMask & (1 << kHe3)) { for (int iP2{iP + 1}; iP2 < protons[iC].size(); ++iP2) { coalHappened |= doCoal(event, iC, pdgList[kHe3], massList[kHe3], trivialCoal, coalescenceRadius, nuclFromDecay, protons[iC][iP], protons[iC][iP2], neutrons[iC][iN]); + if (nuclFromDecay && coalHappened) { + return true; + } } } if (nuclearMask & (1 << kHyperTriton)) { for (int iL{0}; iL < lambdas[iC].size(); ++iL) { coalHappened |= doCoal(event, iC, pdgList[kHyperTriton], massList[kHyperTriton], trivialCoal, coalescenceRadius, nuclFromDecay, protons[iC][iP], neutrons[iC][iN], lambdas[iC][iL]); + if (nuclFromDecay && coalHappened) { + return true; + } } } if (nuclearMask & (1 << kHe4)) { for (int iP2{iP + 1}; iP2 < protons[iC].size(); ++iP2) { for (int iN2{iN + 1}; iN2 < neutrons[iC].size(); ++iN2) { coalHappened |= doCoal(event, iC, pdgList[kHe4], massList[kHe4], trivialCoal, coalescenceRadius, nuclFromDecay, protons[iC][iP], protons[iC][iP2], neutrons[iC][iN], neutrons[iC][iN2]); + if (nuclFromDecay && coalHappened) { + return true; + } } } } From b6a67b84e25745685db5d50dd52b0954f1d80121 Mon Sep 17 00:00:00 2001 From: Alberto Caliva Date: Tue, 28 Jul 2026 21:00:37 +0200 Subject: [PATCH 3/3] restarting the CI --- MC/config/common/external/generator/CoalescencePythia8.h | 1 + 1 file changed, 1 insertion(+) diff --git a/MC/config/common/external/generator/CoalescencePythia8.h b/MC/config/common/external/generator/CoalescencePythia8.h index 378dcc0b4..bfe462521 100644 --- a/MC/config/common/external/generator/CoalescencePythia8.h +++ b/MC/config/common/external/generator/CoalescencePythia8.h @@ -107,6 +107,7 @@ bool doCoal(Pythia8::Event& event, int charge, int pdgCode, float mass, bool tri bool CoalescencePythia8(Pythia8::Event& event, std::vector inputPdgList = {}, bool trivialCoal = false, double coalMomentum = 0.4, int firstDauID = -1, int lastDauId = -1, float maxRapidity = 1.) { const double coalescenceRadius{0.5 * 1.122462 * coalMomentum}; + // if coalescence from a heavy hadron, loop only between firstDauID and lastDauID int loopStart = firstDauID > -1 ? firstDauID : 0; int loopEnd = lastDauId > -1 ? lastDauId : event.size() - 1;