It's a singleton instantiated by default within the HEP Random module. It uses an instantiated HepJamesRandom engine as default algorithm for pseudo-random number generation.

HepRandom defines a static private data member theGenerator and a set of static inlined methods to manipulate it. By means of theGenerator the user can change the underlying engine algorithm, get and set the seeds and use any kind of defined random distribution.

Distribution classes inherit from HepRandom and define both static and not-static interfaces.

A static table of uncorrelated seeds is available in this class.

A static method getTheTableSeeds() is defined to access a couple of seeds at a given index in the table.


Gabriele Cosmo

See also

Engines: HepRandomEngine, DRand48Engine , DualRand, HepJamesRandom, Hurd160Engine, Hurd288Engine, MTwistEngine, RandEngine, RanecuEngine, RanluxEngine, Ranlux64Engine, RanshiEngine, TripleRand

Distributions: RandBinomial, RandBit, RandBreitWigner, RandChiSquare, RandExponential, RandFlat, RandGamma, RandGauss, RandGaussQ, RandGaussT, RandGeneral, RandLandau, RandPoisson, RandPoissonQ, RandPoissonT, RandStudentT

Functions: HepStat


#include "CLHEP/Random/Random.h"

class HepRandom

Public Member Functions

Contructors without a seed using the default engine (JamesRandom).

HepRandom(long seed)
Contructors with a seed using the default engine (JamesRandom).

HepRandom(HepRandomEngine & algorithm)
HepRandom(HepRandomEngine * algorithm)
Constructor taking an alternative engine as argument. If a pointer is given then the corresponding object will be deleted by the HepRandom destructor.
virtual ~HepRandom()
virtual HepDouble operator()()
To get a flat random number using the operator().
static HepInt createInstance()
Create a single instance of the generator, it returns 0 if the singleton is already instantiated.
HepDouble flat()
Returns the flat value ( interval ]0,1[ ).

inline HepDouble flat (HepRandomEngine* theNewEngine)
Returns a flat value, given a defined Random Engine.
void flatArray(const HepInt size, HepDouble* vect)
Fills vect array of flat random values, given the size.

inline void flatArray(HepRandomEngine* theNewEngine, const HepInt size, HepDouble* vect)
Fills vect array of flat random values, given the size and a defined Random Engine.
getTheEngine static HepRandomEngine * getTheEngine()
Returns a pointer to the underlying algorithm object.
static HepRandom * getTheGenerator()
Return the current static generator.
static long getTheSeed()
Gets the current seed of the current generator.
static const long* getTheSeeds()
Gets the current array of seeds of the current generator.
static void getTheTableSeeds(long* seeds, HepInt index)
Gets the array of seeds in the static seedTable at "index" position.
static void restoreEngineStatus(const char filename[] = "Config.conf")
Restores a saved status (if any) for the current engine.
static void saveEngineStatus(const char filename[] = "Config.conf")
Saves to file the current status of the current engine.
static void setTheSeed(long seed, HepInt lux=3)
(Re)Initializes the generator with a seed.
static void setTheSeeds(const long* seeds, HepInt aux=-1)
(Re)Initializes the generator with a zero terminated list of seeds.
static void setTheEngine(HepRandomEngine* theNewEngine)
To set the underlying algorithm object.
static void showEngineStatus()
Dumps the current engine status on screen.

15 May 2000