thepeg is hosted by Hepforge, IPPP Durham
ThePEG  2.1.5
ThePEG::UseRandom Class Reference

This UseRandom class keeps a static stack of RandomGenerator objects which can be used anywhere by any class. More...

#include <UseRandom.h>

Public Member Functions

 UseRandom ()
 Default constructor does nothing.
 
 UseRandom (const UseRandom &)
 Copy-constructor does nothing.
 
 UseRandom (const RanGenPtr &r)
 Construct a new object specifying a new RandomGenerator, r, to be used during this objects lifetime.
 
 ~UseRandom ()
 The destructor removing the RandomGenerator specified in the constructor from the stack.
 

Static Public Member Functions

static RandomGeneratorcurrent ()
 Return a reference to the currently chosen RandomGenerator object.
 
static double rnd ()
 Return a pointer to the currently chosen RandomGenerator object. More...
 
static RandomGenerator::RndVector rndvec (int n)
 Return n simple flat random number (from the current RandomGenerator object) in the range ]0,1[.
 
template<typename Unit >
static Unit rnd (Unit xu)
 Return a simple flat random number (from the current RandomGenerator object) in the range ]0,xu[.
 
template<typename Unit >
static Unit rnd (Unit xl, Unit xu)
 Return a simple flat random number (from the current RandomGenerator object) in the range ]xl,xu[.
 
static bool rndbool (double p=0.5)
 Return a true with probability p (default 0.5).
 
static bool prndbool (double p=0.5)
 Return a true with probability p (default 0.5). More...
 
static bool rndbool (double p1, double p2)
 Return a true with probability p1/(p1+p2).
 
static bool prndbool (double p1, double p2)
 Return a true with probability p1/(p1+p2). More...
 
static int rndsign (double p1, double p2, double p3)
 Return -1, 0, or 1 with relative probabilities p1, p2, p3.
 
static int prndsign (double p1, double p2, double p3)
 Return -1, 0, or 1 with relative probabilities p1, p2, p3. More...
 
static int rnd2 (double p0, double p1)
 Return an integer $i$ with probability p $i$/(p0+p1).
 
static int rnd3 (double p0, double p1, double p2)
 Return an integer $i$ with probability p $i$/(p0+p1+p2).
 
static int rnd4 (double p0, double p1, double p2, double p3)
 Return an integer/ $i$ with probability p $i$(p0+p1+p2+p3).
 
static long irnd (long xu=2)
 Return a simple flat random integrer number in the range [0,xu[.
 
static long irnd (long xl, long xu)
 Return a simple flat random integrer number in the range [xl,xu[.
 
static double rndExp ()
 Return a number between zero and infinity, distributed according to $e^-x$.
 
template<typename Unit >
static Unit rndExp (Unit mean)
 Return a number between zero and infinity, distributed according to $e^-{x/\mu}$ where $\mu$ is the mean value.
 
static double rndGauss ()
 Return a number distributed according to a Gaussian distribution with zero mean and unit variance.
 
template<typename Unit >
static Unit rndGauss (Unit sigma, Unit mean=Unit())
 Return a number distributed according to a Gaussian distribution with a given standard deviation, sigma, and a given mean.
 
template<typename Unit >
static Unit rndBW (Unit mean, Unit gamma)
 Return a positive number distributed according to a non-relativistic Breit-Wigner with a given width, gamma, and a given mean.
 
template<typename Unit >
static Unit rndBW (Unit mean, Unit gamma, Unit cut)
 Return a positive number distributed according to a non-relativistic Breit-Wigner with a given width, gamma, and a given mean. More...
 
template<typename Unit >
static Unit rndRelBW (Unit mean, Unit gamma)
 Return a positive number distributed according to a relativistic Breit-Wigner with a given width, gamma, and a given mean.
 
template<typename Unit >
static Unit rndRelBW (Unit mean, Unit gamma, Unit cut)
 Return a positive number distributed according to a relativistic Breit-Wigner with a given width, gamma, and a given mean. More...
 
static long rndPoisson (double mean)
 Return a non-negative number generated according to a Poissonian distribution with a given mean.
 

Private Member Functions

UseRandomoperator= (const UseRandom &)=delete
 Private and non-existent assignment operator.
 

Private Attributes

bool randomPushed
 True if this object is responsible for pushing a RandomGenerator onto the stack.
 

Static Private Attributes

static vector< RanGenPtrtheRandomStack
 The stack of RandomGenerators requested.
 

Detailed Description

This UseRandom class keeps a static stack of RandomGenerator objects which can be used anywhere by any class.

When an EventGenerator is initialized or run it adds a RandomGenerator object to the stack which can be used by any other object being initialized or run through the static functions of the UseRandom class. If someone needs to use an alternative RandomGenerator object a new UseRandom object can be constructed with a pointer to the desired RandomGenerator object as argument and that object will the be used by the static UseRandom functions until the UseRandom object is destructed.

See also
RandomGenerator
EventGenerator

Definition at line 33 of file UseRandom.h.

Member Function Documentation

◆ prndbool() [1/2]

static bool ThePEG::UseRandom::prndbool ( double  p = 0.5)
inlinestatic

Return a true with probability p (default 0.5).

Uses push_back to reuse random number.

Definition at line 119 of file UseRandom.h.

References current(), and ThePEG::RandomGenerator::rndbool().

◆ prndbool() [2/2]

static bool ThePEG::UseRandom::prndbool ( double  p1,
double  p2 
)
inlinestatic

Return a true with probability p1/(p1+p2).

Uses push_back to reuse random number.

Definition at line 134 of file UseRandom.h.

References current(), and ThePEG::RandomGenerator::rndbool().

◆ prndsign()

static int ThePEG::UseRandom::prndsign ( double  p1,
double  p2,
double  p3 
)
inlinestatic

Return -1, 0, or 1 with relative probabilities p1, p2, p3.

Uses push_back to reuse random number.

Definition at line 150 of file UseRandom.h.

References current(), and ThePEG::RandomGenerator::rndsign().

◆ rnd()

static double ThePEG::UseRandom::rnd ( )
inlinestatic

Return a pointer to the currently chosen RandomGenerator object.

Return a simple flat random number (from the current RandomGenerator object) in the range ]0,1[.

Definition at line 82 of file UseRandom.h.

References current(), and ThePEG::RandomGenerator::rnd().

Referenced by irnd().

◆ rndBW()

template<typename Unit >
static Unit ThePEG::UseRandom::rndBW ( Unit  mean,
Unit  gamma,
Unit  cut 
)
inlinestatic

Return a positive number distributed according to a non-relativistic Breit-Wigner with a given width, gamma, and a given mean.

The distribution is cut-off so that the number is between mean - cut and mean + cut

Definition at line 233 of file UseRandom.h.

References current(), and ThePEG::RandomGenerator::rndBW().

◆ rndRelBW()

template<typename Unit >
static Unit ThePEG::UseRandom::rndRelBW ( Unit  mean,
Unit  gamma,
Unit  cut 
)
inlinestatic

Return a positive number distributed according to a relativistic Breit-Wigner with a given width, gamma, and a given mean.

The distribution is cut-off so that the number is between mean - cut and mean + cut

Definition at line 253 of file UseRandom.h.

References current(), and ThePEG::RandomGenerator::rndRelBW().


The documentation for this class was generated from the following file: