File: UseRandom.h
Description:
This UseRandom class keeps a static stack of
RandomGenerator 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 objectas argument and that object
will the be used by the static UseRandom functions until
the UseRandom is destructed.
See
also:
namespace Pythia7
CLASS
UseRandom
Public members:
inline UseRandom();
inline UseRandom(const UseRandom &);
Standard constructors do nothing.
inline UseRandom(const RanGenPtr & r);
Construct a new object specifying a new RandomGenerator to be
used during this objects lifetime
inline ~UseRandom();
The destructor removing the RandomGenerator specified in the
constructor from the stack.
inline static RandomGenerator & current();
Return a reference to the currently chosen RandomGenerator object.
inline static double rnd();
inline static double rnd(double xu);
inline static double rnd(double xl, double xu);
Return a simple flat random number (from the current
RandomGenerator object) in the range ]0,1[, ]0,xu[ and ]xl,xu[
respectively.
inline static bool rndbool();
Return 50/50 (from the current RandomGenerator object).
inline static bool rndbool(double p);
Return a true with probability p (from the current
RandomGenerator object).
inline static bool rndbool(double p1, double p2);
Return a true with probability p1/(p1+p2) (from the current
RandomGenerator object).
inline static int rndsign(double p1, double p2, double p2);
Return -1, 0, or 1 with relative probabilities p1, p2, p3 (from
the current RandomGenerator object).
inline static int rnd2(double p0, double p1);
inline static int rnd3(double p0, double p1, double p2);
inline static int rnd4(double p0, double p1, double p2, double p3);
Return a i with probability p_i/sum(p_i) (from the current
RandomGenerator object).
inline static long irnd(long xu = 2);
inline static long irnd(long xl, long xu);
Return a simple flat random integrer number in the range [0,xu[
and [xl,xu[ respectively (from the current RandomGenerator
object).
Private members:
static vector<RanGenPtr> theRandomStack;
The stack of RandomGenerators requested.
bool randomPushed;
True if this object is responsible for pushing a RandomGenerator
onto the stack.
UseRandom & operator=(const UseRandom &);
Private and non-existent assignment operator.
DEFINED MACROS
INCLUDED FILES
Pythia7/Repository/RandomGenerator.h