@@ -11,6 +11,23 @@ R__ADD_INCLUDE_PATH($STARlight_ROOT/include)
1111
1212// usage: o2-sim -g external --configKeyValues 'GeneratorExternal.fileName=GeneratorStarlight.C;GeneratorExternal.funcName=GeneratorStarlight("kCohJpsiToMu")'
1313
14+ unsigned int generateRandomSeed () {
15+ // Use high-resolution clock for time-based seed
16+ auto timeNow = std ::chrono ::high_resolution_clock ::now ();
17+ auto timeSeed = static_cast < unsigned int > (timeNow .time_since_epoch ().count ());
18+
19+ // Random device for system entropy
20+ std ::random_device rd ;
21+
22+ // Add process ID and thread ID for additional entropy
23+ unsigned int pid = static_cast < unsigned int > (getpid ());
24+ unsigned int tid = static_cast < unsigned int > (std ::hash < std ::thread ::id > ( )(std ::this_thread ::get_id ()));
25+
26+ // Combine all entropy sources
27+ unsigned int seed = timeSeed ^ (rd () << 1 ) ^ (pid << 2 ) ^ (tid << 3 );
28+ return seed ;
29+ }
30+
1431namespace o2
1532{
1633namespace eventgen
@@ -104,7 +121,8 @@ class GeneratorStarlight_class : public Generator
104121 {"kIncohPsi2sToElPi" , 4 , 444011 , 20 , -1.0 , -1.0 , 100443 , 1 }, //
105122 {"kIncohUpsilonToMu" , 4 , 553013 , 20 , -1.0 , -1.0 , 553 , 0 }, //
106123 {"kIncohUpsilonToEl" , 4 , 553011 , 20 , -1.0 , -1.0 , 553 , 0 }, //
107- {"kDpmjetSingle" , 5 , 113 , 20 , -1.0 , -1.0 , -1 , 0 }, //
124+ {"kDpmjetSingleA" , 5 , 113 , 20 , -1.0 , -1.0 , -1 , 0 }, //
125+ {"kDpmjetSingleC" , 5 , 113 , 20 , -1.0 , -1.0 , -1 , 0 }, //
108126 {"kTauLowToEl3Pi" , 1 , 15 , 990 , 3.5 , 20.0 , -1 , 1 }, // from 0.4 to 15 GeV
109127 {"kTauLowToPo3Pi" , 1 , 15 , 990 , 3.5 , 20.0 , -1 , 1 }, // from 0.4 to 15 GeV
110128 {"kTauLowToElMu" , 1 , 15 , 990 , 3.5 , 20.0 , -1 , 1 }, // from 0.4 to 15 GeV
@@ -128,12 +146,9 @@ class GeneratorStarlight_class : public Generator
128146
129147 mPdgMother = slConfig [idx ].pdg_mother ;
130148 mDecayEvtGen = slConfig [idx ].decay_EvtGen ;
131-
132- uint random_seed ;
133- unsigned long long int random_value = 0 ;
134- ifstream urandom ("/dev/urandom" , ios ::in |ios ::binary );
135- urandom .read (reinterpret_cast < char * > (& random_value ), sizeof (random_seed ));
136-
149+
150+ unsigned int random_seed = generateRandomSeed ();
151+
137152 setParameter (Form ("BEAM_1_Z = %3i #Z of target" ,targZ ));
138153 setParameter (Form ("BEAM_1_A = %3i #A of target" ,targA ));
139154 setParameter (Form ("BEAM_2_Z = %3i #Z of projectile" ,projZ ));
@@ -278,7 +293,7 @@ class GeneratorStarlight_class : public Generator
278293 -1 ,
279294 slPart -> GetPx (),
280295 slPart -> GetPy (),
281- slPart -> GetPz (),
296+ ( mSelectedConfiguration . compare ( "kDpmjetSingleC" ) == 0 ? -1.0 * slPart -> GetPz () : slPart -> GetPz () ),
282297 slPart -> GetE (),
283298 vtx ,vty ,vtz ,vtt );
284299 //particle.Print();
@@ -321,8 +336,7 @@ FairGenerator*
321336 system (TString ::Format ("cp %s ./my.input" ,dpmjetconf .c_str ()));
322337
323338 //Reset four seeds of the DPMJET random generator in the config
324- std ::random_device rd ;
325- std ::mt19937 gen (rd ());
339+ std ::mt19937 gen (generateRandomSeed ());
326340 std ::uniform_int_distribution < > dist (1 , 168 );
327341
328342 std ::string command = "awk -i inplace -v nums=\"" ;
0 commit comments