Thursday, December 1, 2011

Make random number seeds different in different runs in Geant4 simulation

Add below headers in main file.

#include "Randomize.hh"
#include "time.h"

Add below lines in main() function.

//choose the Random engine
CLHEP::HepRandom::setTheEngine(new CLHEP::RanecuEngine());
//set random seed with system time
G4long seed = time(NULL);
CLHEP::HepRandom::setTheSeed(seed);

The running results will be different though you use the same number of events in different runs.

3 comments:

  1. thanks a lot, there should be a stronger community and better documentation for geant4

    ReplyDelete

happy time