diff --git a/MC/config/common/external/generator/CoalescencePythia8.h b/MC/config/common/external/generator/CoalescencePythia8.h index 7e4abc53e..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; @@ -152,26 +153,41 @@ 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) { 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; + } } } }