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 RandomGenerator & | current () |
Return a reference to the currently chosen RandomGenerator object. | |
static double | rnd () |
Return a pointer to the currently chosen RandomGenerator object. | |
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). | |
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). | |
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. | |
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 int | rnd5 (double p0, double p1, double p2, double p3, double p4) |
Return an integer/ \(i\) with probability p \(i\)(p0+p1+p2+p3+p4). | |
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. | |
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. | |
static long | rndPoisson (double mean) |
Return a non-negative number generated according to a Poissonian distribution with a given mean. | |
Private Member Functions | |
UseRandom & | operator= (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< RanGenPtr > | theRandomStack |
The stack of RandomGenerators requested. | |
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.
Definition at line 33 of file UseRandom.h.
|
inline |
Default constructor does nothing.
Definition at line 40 of file UseRandom.h.
|
inline |
Copy-constructor does nothing.
Definition at line 45 of file UseRandom.h.
|
inline |
Construct a new object specifying a new RandomGenerator, r, to be used during this objects lifetime.
Definition at line 51 of file UseRandom.h.
References randomPushed, and theRandomStack.
|
inline |
The destructor removing the RandomGenerator specified in the constructor from the stack.
Definition at line 62 of file UseRandom.h.
References randomPushed, and theRandomStack.
|
inlinestatic |
Return a reference to the currently chosen RandomGenerator object.
Definition at line 69 of file UseRandom.h.
References theRandomStack.
Referenced by prndbool(), prndsign(), rnd(), rnd2(), rnd3(), rnd4(), rnd5(), rndbool(), rndBW(), rndExp(), rndGauss(), rndPoisson(), rndRelBW(), rndsign(), and rndvec().
|
inlinestatic |
Return a simple flat random integrer number in the range [xl,xu[.
Definition at line 194 of file UseRandom.h.
References irnd().
Referenced by irnd().
|
inlinestatic |
Return a simple flat random integrer number in the range [0,xu[.
Definition at line 189 of file UseRandom.h.
References rnd().
|
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().
|
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().
|
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().
|
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().
|
inlinestatic |
Return a simple flat random number (from the current RandomGenerator object) in the range ]xl,xu[.
Definition at line 104 of file UseRandom.h.
References current(), and ThePEG::RandomGenerator::rnd().
|
inlinestatic |
Return a simple flat random number (from the current RandomGenerator object) in the range ]0,xu[.
Definition at line 97 of file UseRandom.h.
References current(), and ThePEG::RandomGenerator::rnd().
|
inlinestatic |
Return an integer \(i\) with probability p \(i\)/(p0+p1).
Definition at line 158 of file UseRandom.h.
References current(), and ThePEG::RandomGenerator::rnd2().
|
inlinestatic |
Return an integer \(i\) with probability p \(i\)/(p0+p1+p2).
Definition at line 166 of file UseRandom.h.
References current(), and ThePEG::RandomGenerator::rnd3().
|
inlinestatic |
Return an integer/ \(i\) with probability p \(i\)(p0+p1+p2+p3).
Definition at line 174 of file UseRandom.h.
References current(), and ThePEG::RandomGenerator::rnd4().
|
inlinestatic |
Return an integer/ \(i\) with probability p \(i\)(p0+p1+p2+p3+p4).
Definition at line 182 of file UseRandom.h.
References current(), and ThePEG::RandomGenerator::rnd5().
|
inlinestatic |
Return a true with probability p1/(p1+p2).
Definition at line 126 of file UseRandom.h.
References current(), and ThePEG::RandomGenerator::rndbool().
|
inlinestatic |
Return a true with probability p (default 0.5).
Definition at line 111 of file UseRandom.h.
References current(), and ThePEG::RandomGenerator::rndbool().
|
inlinestatic |
Return a positive number distributed according to a non-relativistic Breit-Wigner with a given width, gamma, and a given mean.
Definition at line 230 of file UseRandom.h.
References current(), and ThePEG::RandomGenerator::rndBW().
|
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 241 of file UseRandom.h.
References current(), and ThePEG::RandomGenerator::rndBW().
|
inlinestatic |
Return a number between zero and infinity, distributed according to \(e^-x\).
Definition at line 200 of file UseRandom.h.
References current(), and ThePEG::RandomGenerator::rndExp().
|
inlinestatic |
Return a number between zero and infinity, distributed according to \(e^-{x/\mu}\) where \(\mu\) is the mean value.
Definition at line 207 of file UseRandom.h.
References current(), and ThePEG::RandomGenerator::rndExp().
|
inlinestatic |
Return a number distributed according to a Gaussian distribution with zero mean and unit variance.
Definition at line 213 of file UseRandom.h.
References current(), and ThePEG::RandomGenerator::rndGauss().
|
inlinestatic |
Return a number distributed according to a Gaussian distribution with a given standard deviation, sigma, and a given mean.
Definition at line 220 of file UseRandom.h.
References current(), and ThePEG::RandomGenerator::rndGauss().
|
inlinestatic |
Return a non-negative number generated according to a Poissonian distribution with a given mean.
Definition at line 269 of file UseRandom.h.
References current(), and ThePEG::RandomGenerator::rndPoisson().
|
inlinestatic |
Return a positive number distributed according to a relativistic Breit-Wigner with a given width, gamma, and a given mean.
Definition at line 250 of file UseRandom.h.
References current(), and ThePEG::RandomGenerator::rndRelBW().
|
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 261 of file UseRandom.h.
References current(), and ThePEG::RandomGenerator::rndRelBW().
|
inlinestatic |
Return -1, 0, or 1 with relative probabilities p1, p2, p3.
Definition at line 142 of file UseRandom.h.
References current(), and ThePEG::RandomGenerator::rndsign().
|
inlinestatic |
Return n simple flat random number (from the current RandomGenerator object) in the range ]0,1[.
Definition at line 88 of file UseRandom.h.
References current(), and ThePEG::RandomGenerator::rndvec().
|
private |
True if this object is responsible for pushing a RandomGenerator onto the stack.
Definition at line 284 of file UseRandom.h.
Referenced by UseRandom(), and ~UseRandom().
|
staticprivate |
The stack of RandomGenerators requested.
Definition at line 278 of file UseRandom.h.
Referenced by current(), UseRandom(), and ~UseRandom().