From f8b243202bcf3adf1ee430699ab39e44d0249ed1 Mon Sep 17 00:00:00 2001 From: Fabrizio Grosa Date: Fri, 26 Jun 2026 18:17:45 +0200 Subject: [PATCH] Fix seed initialisation of c-deuteron gun and status codes --- .../generator_pythia8_embed_charmnuclei.C | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/MC/config/PWGHF/external/generator/generator_pythia8_embed_charmnuclei.C b/MC/config/PWGHF/external/generator/generator_pythia8_embed_charmnuclei.C index 4e6f69ba0..94c9c0b80 100644 --- a/MC/config/PWGHF/external/generator/generator_pythia8_embed_charmnuclei.C +++ b/MC/config/PWGHF/external/generator/generator_pythia8_embed_charmnuclei.C @@ -22,7 +22,7 @@ class GeneratorPythia8HFEmbedCharmNuclei : public o2::eventgen::GeneratorPythia8 public: /// constructor - GeneratorPythia8HFEmbedCharmNuclei(int pdgCode = 2010010020, float lifetime = 1.f, int nCharmNucleiPerEvent = 10, float yMin = -1.f, float yMax = 1.f, float ptMax = 25.f, bool trivialCoal = false, float coalMomentum = 0.2, float fracFromB = 0.f) + GeneratorPythia8HFEmbedCharmNuclei(int pdgCode = 2010010020, float lifetime = 1.f, int nCharmNucleiPerEvent = 10, float yMin = -1.f, float yMax = 1.f, float ptMax = 25.f, bool trivialCoal = false, float coalMomentum = 0.2, float fracFromB = 0.f, unsigned int seed = 0u) { nNumberOfCharmNucleiPerEvent = nCharmNucleiPerEvent; mRapidityMinCharmNuclei = yMin; @@ -33,6 +33,7 @@ class GeneratorPythia8HFEmbedCharmNuclei : public o2::eventgen::GeneratorPythia8 mFractionFromBeauty = fracFromB; mPdgCharmNucleus = pdgCode; mSign = 1; + mUsedSeed = seed; if (std::abs(mPdgCharmNucleus) == 2010010020) { mMassCharmNucleus = 3.226f; } else { @@ -63,6 +64,9 @@ class GeneratorPythia8HFEmbedCharmNuclei : public o2::eventgen::GeneratorPythia8 LOG(fatal) << "Failed to init \'GeneratorPythia8\': problems with configuration file " << cfg; } + mPythiaGun.readString("Random:setSeed = on"); + mPythiaGun.readString("Random:seed = " + std::to_string(seed)); + if (!mPythiaGun.init()) { LOG(fatal) << "Failed to init \'GeneratorPythia8\': init returned with error"; } @@ -170,7 +174,8 @@ class GeneratorPythia8HFEmbedCharmNuclei : public o2::eventgen::GeneratorPythia8 mPythiaGun.moreDecays(); std::array dausToCoal = {-1, -1}; std::vector pdgShortLivedResos = {313, 2224, 102134}; - std::map statusResoDecay = {{313, 95}, {2224, 96}, {102134, 97}}; // do not use 94, it is used by default for no resonances + std::map statusResoDecay = {{313, -85}, {2224, -86}, {102134, -87}}; // do not use 94, it is used by default for no resonances + std::map statusResoDecayFromB = {{313, -95}, {2224, -96}, {102134, -97}}; // do not use 94, it is used by default for no resonances int whichReso{0}; int idxCharmNucleus{-1}; for (int iPart{0}; iPart{1000010020}, mTrivialCoal, mCoalMomentum, dausToCoal[0], dausToCoal[1], 10.); if (whichReso > 0) { - mPythiaGun.event[idxCharmNucleus].status(statusResoDecay[whichReso]); + if (isFromB) { + mPythiaGun.event[idxCharmNucleus].status(statusResoDecayFromB[whichReso]); + } else { + mPythiaGun.event[idxCharmNucleus].status(statusResoDecay[whichReso]); + } } if (isCoalSuccess) { restoreEnergyConservation(mPythiaGun.event, idxCharmNucleus); @@ -332,8 +341,8 @@ private: ///___________________________________________________________ FairGenerator *GenerateHFEmbedCDeuteron(float lifetime = 1.f, int nCharmNucleiPerEvent = 10, float yMin = -1.f, float yMax = 1.f, float ptMax = 25.f, bool trivialCoal = false, float coalMomentum = 0.2f, float fracFromB = 0.25f) { - auto myGen = new GeneratorPythia8HFEmbedCharmNuclei(2010010020, lifetime, nCharmNucleiPerEvent, yMin, yMax, ptMax, trivialCoal, coalMomentum, fracFromB); auto seed = (gRandom->TRandom::GetSeed() % 900000000); + auto myGen = new GeneratorPythia8HFEmbedCharmNuclei(2010010020, lifetime, nCharmNucleiPerEvent, yMin, yMax, ptMax, trivialCoal, coalMomentum, fracFromB, seed); myGen->readString("Random:setSeed on"); myGen->readString("Random:seed " + std::to_string(seed)); return myGen;