sphenix-software-l AT lists.bnl.gov
Subject: sPHENIX discussion of software
List archive
[Sphenix-software-l] random number generators, , seeding the simulations and single particle generators
- From: pinkenburg <pinkenburg AT bnl.gov>
- To: "sphenix-software-l AT lists.bnl.gov" <sphenix-software-l AT lists.bnl.gov>
- Subject: [Sphenix-software-l] random number generators, , seeding the simulations and single particle generators
- Date: Thu, 3 Sep 2015 10:08:52 -0400
Hi folks,
so far we had a bit of a mess when it came to seeding our random number generators with the default being more or less that one had to set a random seed in the macro to avoid getting identical results.
I went through our G4 interface and our single particle generators and replaced the various seedings by something more manageable. By default each random number generator (including the one used in G4) gets its seed now from /dev/urandom (I know this is not available everywhere - once we switch to c++11, there is a std::random_device or take something from boost if this is a really urgent issue). That code is in a single place (offline/framework/phool/PHRandonSeed.cc) so it's easy to adapt. If one sets the RANDOMSEED flag its value will be used as the seed for all random number generators.
That change turned out to be a bit more invasive for the single particle generators than I initially thought. I removed the various random number generators (TRandom3, rand()) from the implementations and added a gsl random number generator (Mersenne Twister - just like TRandom3) to the particle generator base class (PHG4ParticleGeneratorBase). Just try to figure out how TRandom3 sets its seed from the source code and you'll see why we shouldn't use that one - it also seem to behave differently when used under CINT vs compiled code. Interestingly while the uniform distributions are absolutely identical using the same seed (it's the same algorithm after all), derived distributions (Gaussian, exponential,spherical) are very similar but not identical and I just would trust gsl more than root. The only exception was the PHG4ParticleGeneratorVectorMeson which uses a Breit-Wigner distribution which doesn't exist in gsl.
Some of the single particle generators did not use the base class and had lots of duplicated code - I modified them to use the base class and removed duplicated methods/data members.
All of this made small changes in the Fun4All_G4_sPHENIX.C macro necessary and the old macro will not work with the newest build (3 subsequent lines 141-143 need to change)
from:
gen->set_embedflag(1);
gen->set_seed(uniqueseed);
gen->set_verbosity(0);
to:
gen->Embed(1);
gen->Verbosity(0);
and you might want to take out the RANDOMSEED gymnastics but that's not required.
Chris
--
*************************************************************
Christopher H. Pinkenburg ; pinkenburg AT bnl.gov
; http://www.phenix.bnl.gov/~pinkenbu
Brookhaven National Laboratory ; phone: (631) 344-5692
Physics Department Bldg 510 C ; fax: (631) 344-3253
Upton, NY 11973-5000
*************************************************************
- [Sphenix-software-l] random number generators, , seeding the simulations and single particle generators, pinkenburg, 09/03/2015
Archive powered by MHonArc 2.6.24.