Message: Re: Random Numbers Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Feedback Re: Random Numbers 

Keywords: Random, CLHEP, HepRep, Ranecu
Forum: Run Management
Re: None Random Numbers (Theo DuBose)
Date: 24 Aug, 2007
From: Gumplinger Peter <Gumplinger Peter>

OK, try this in your main program:

int main(int argc,char** argv)
{
  G4int seed = -1;
  if (argc >= 3) seed = atoi(argv[2]);
  if (seed < 0) seed = time(0);
  CLHEP::HepRandom::setTheSeed(seed);

assuming you run your program with

program program.in rand#

where:

macro file: program.in

rand#: any integer; e.g 123456

and if you start without specifying rand#:

program program.in

the seed will change and derived from the time.

Without the above code, HepRandom is internally seeded and always the same and thus your simulation will identically repeat itself.

Some people like to derive the initial seed from the initial event number which is specified sequentially (differently) for long production runs to ensure the simulations are different.

Please also see:

http://geant4.web.cern.ch/geant4/UserDocumentation/UsersGuides/ForApplicationDeveloper/html/ch03s02.html#sect.GlobClass.HEPRandom

Inline Depth:
 1 1
 All All
Outline Depth:
 1 1
 2 2
 All All
Add message: (add)

 Add Message Add Message
to: "Re: Random Numbers"

 Subscribe Subscribe

This site runs SLAC HyperNews version 1.11-slac-98, derived from the original HyperNews


[ Geant 4 Home | Geant 4 HyperNews | Search | Request New Forum | Feedback ]