From df8845990ba47583428c25882b0baeae6950199e Mon Sep 17 00:00:00 2001 From: mjkim525 Date: Wed, 9 Sep 2026 15:55:34 +0900 Subject: [PATCH] Fix independent LF resonance gun RNG seeding 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. --- .../pythia8/generator_pythia8_LF_rapidity_width.C | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/MC/config/PWGLF/pythia8/generator_pythia8_LF_rapidity_width.C b/MC/config/PWGLF/pythia8/generator_pythia8_LF_rapidity_width.C index 7caf0fdd3..ed0a8c990 100644 --- a/MC/config/PWGLF/pythia8/generator_pythia8_LF_rapidity_width.C +++ b/MC/config/PWGLF/pythia8/generator_pythia8_LF_rapidity_width.C @@ -153,6 +153,12 @@ class GeneratorPythia8LFRapidity : public o2::eventgen::GeneratorPythia8 /** switch off process level **/ mPythiaGun.readString("ProcessLevel:all off"); + // The gun owns a separate RNG: seeding the inherited mPythia does not + // seed its mass sampler or decays. Derive a valid, nonzero Pythia seed + // from ROOT's RNG; explicit decayer configuration can still override it. + mPythiaGun.readString("Random:setSeed = on"); + mPythiaGun.readString("Random:seed = " + std::to_string(1 + gRandom->Integer(900000000))); + auto& param = o2::eventgen::DecayerPythia8Param::Instance(); LOG(info) << "Init \'GeneratorPythia8LFRapidity\' with following parameters"; LOG(info) << param; @@ -177,6 +183,13 @@ class GeneratorPythia8LFRapidity : public o2::eventgen::GeneratorPythia8 mPythiaGun.readString(std::string("Init:showChangedParticleData off")); } + LOG(info) << "LF gun RNG: Random:setSeed=" << mPythiaGun.settings.flag("Random:setSeed") + << ", Random:seed=" << mPythiaGun.settings.mode("Random:seed"); + if (!mPythiaGun.settings.flag("Random:setSeed") || mPythiaGun.settings.mode("Random:seed") <= 0) { + LOG(warn) << "Decayer configuration overrides the ROOT-derived gun seed; " + << "the gun may use default or time-based seeding"; + } + /** initialise **/ if (!mPythiaGun.init()) { LOG(fatal) << "Failed to init \'DecayerPythia8\': init returned with error";