12.07.2015 Views

Geant4 User's Guide for Application Developers - Geant4 - CERN

Geant4 User's Guide for Application Developers - Geant4 - CERN

Geant4 User's Guide for Application Developers - Geant4 - CERN

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Toolkit FundamentalsHepRandom::restoreEngineStatus(); // to restore the current engine to a previous// saved configurationHepRandom::showEngineStatus(); // to display the current engine status to stdout...int index=n;long seeds[2];HepRandom::getTheTableSeeds(seeds,index);// fills `seeds' with the values stored in the global// seedTable at position `index'Only one random engine can be active at a time, the user can decide at any time to change it, define a new one(if not done already) and set it. For example:RanecuEngine theNewEngine;HepRandom::setTheEngine(&theNewEngine);...or simply setting it to an old instantiated engine (the old engine status is kept and the new random sequence willstart exactly from the last one previously interrupted). For example:HepRandom::setTheEngine(&myOldEngine);Other static methods defined in this class are:• void setTheSeeds(const G4long* seeds, G4int)• const G4long* getTheSeeds()To set/get an array of seeds <strong>for</strong> the generator, in the case of a RanecuEngine this corresponds also to set/getthe current status of the engine.• HepRandomEngine* getTheEngine()To get a pointer to the current engine used by the static generator.3.2.2.3. HEPRandom distributionsA distribution-class can collect different algorithms and different calling sequences <strong>for</strong> each method to definedistribution parameters or range-intervals; it also collects methods to fill arrays, of specified size, of random values,according to the distribution. This class collects either static and not static methods. A set of distribution classesare defined in HEPRandom. Here is the description of some of them:• RandFlatClass to shoot flat random values (integers or double) within a specified interval. The class provides also methodsto shoot just random bits.• RandExponentialClass to shoot exponential distributed random values, given a mean (default mean = 1)• RandGaussClass to shoot Gaussian distributed random values, given a mean (default = 0) or specifying also a deviation(default = 1). Gaussian random numbers are generated two at the time, so every other time a number is shot,the number returned is the one generated the time be<strong>for</strong>e.• RandBreitWignerClass to shoot numbers according to the Breit-Wigner distribution algorithms (plain or mean^2).• RandPoissonClass to shoot numbers according to the Poisson distribution, given a mean (default = 1) (Algorithm taken from``W.H.Press et al., Numerical Recipes in C, Second Edition'').38

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!