So, I’m not sure whether one would consider this a bug with Geant4, or a bug with CLHEP. I can’t figure out which forum or sub-forum this post belongs on. Maybe it’s not a bug at all and I’m simply doing something very very wrong.
So, I’m running geant4-10-05-patch-01 in multi-threaded mode, and I decided to use the CLHEP::Ranlux64Engine engine to generate a flat distribution. I noticed that the results were coming out very biased. Sometimes.
In an effort to get this down to a minimal example, I took Example B1, commented out the place (in main() ) where it calls “G4Random::setTheEngine(new CLHEP::RanecuEngine);”, replaced it with the Ranlux64Engine, and added in the following chunk of code in the B1EventAction::BeginOfEventAction(const G4Event*) function:
for(int i=0; i<20; i++)
{
double costheta_lab;
costheta_lab = G4RandFlat::shoot(-1.0, 1.0);
cout << costheta_lab << ", ";
}
cout << endl;
The 9th printed random number in every ‘event’ is almost always between -0.90 and -1.0. This seems to only happen when one “edge” of the flat distribution is negative.
It also only happens within B1EventAction::BeginOfEventAction(). If I put the same chunk of code in main(), it comes out fine. This is, incidentally, what makes me suspect that it’s related to multi-threading.
So, obviously that’s not the sort of behavior one wants from a random number generator. Is this a known issue? (I can’t find anyone else complaining about it.) Have I done something foolish here? Should I just pick another random number generator engine and be done with it?