Skip to content

Commit 5afa943

Browse files
authored
Fix independent LF resonance gun RNG seeding (#2456)
Seed the separate Pythia gun RNG from ROOT before reading decayer settings. Preserve ROOT SetSeed(0) and explicit decayer configuration priority. Log the effective gun seed once during construction and warn when seeding is disabled or nonpositive.
1 parent 3418de0 commit 5afa943

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

MC/config/PWGLF/pythia8/generator_pythia8_LF_rapidity_width.C

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,12 @@ class GeneratorPythia8LFRapidity : public o2::eventgen::GeneratorPythia8
153153
/** switch off process level **/
154154
mPythiaGun.readString("ProcessLevel:all off");
155155

156+
// The gun owns a separate RNG: seeding the inherited mPythia does not
157+
// seed its mass sampler or decays. Derive a valid, nonzero Pythia seed
158+
// from ROOT's RNG; explicit decayer configuration can still override it.
159+
mPythiaGun.readString("Random:setSeed = on");
160+
mPythiaGun.readString("Random:seed = " + std::to_string(1 + gRandom->Integer(900000000)));
161+
156162
auto& param = o2::eventgen::DecayerPythia8Param::Instance();
157163
LOG(info) << "Init \'GeneratorPythia8LFRapidity\' with following parameters";
158164
LOG(info) << param;
@@ -177,6 +183,13 @@ class GeneratorPythia8LFRapidity : public o2::eventgen::GeneratorPythia8
177183
mPythiaGun.readString(std::string("Init:showChangedParticleData off"));
178184
}
179185

186+
LOG(info) << "LF gun RNG: Random:setSeed=" << mPythiaGun.settings.flag("Random:setSeed")
187+
<< ", Random:seed=" << mPythiaGun.settings.mode("Random:seed");
188+
if (!mPythiaGun.settings.flag("Random:setSeed") || mPythiaGun.settings.mode("Random:seed") <= 0) {
189+
LOG(warn) << "Decayer configuration overrides the ROOT-derived gun seed; "
190+
<< "the gun may use default or time-based seeding";
191+
}
192+
180193
/** initialise **/
181194
if (!mPythiaGun.init()) {
182195
LOG(fatal) << "Failed to init \'DecayerPythia8\': init returned with error";

0 commit comments

Comments
 (0)