StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
StarRandom Class Reference

A class for providing random number generation. More...

#include <StarRandom.h>

Inheritance diagram for StarRandom:

Public Member Functions

Double_t operator() () const
 Return a random number uniformly distributed between 0 and 1.
 
Double_t operator() (const Double_t mn, const Double_t mx) const
 Return a random number uniformly distributed between mn and mx.
 
Double_t operator() (Int_t *idummy)
 
Double_t flat () const
 Return a random number uniformly distributed between 0 and 1.
 
Double_t flat (const Double_t mn, const Double_t mx) const
 Return a random number uniformly distributed between mn and mx.
 
Double_t expo (const Double_t mu) const
 Return a random number distribted according to exp(-mu)
 
Double_t landau () const
 Return a random number distributed according to a landau.
 
Double_t gauss (const Double_t sigma) const
 Return a random number distributed according to a gaussian with specified sigma.
 
TVector2 gauss2d (const Double_t sx, const Double_t sy, const Double_t rho) const
 Returns a pair of random numbers generated according to a 2D gaussian.
 
UInt_t poisson (const Double_t mu) const
 

Static Public Member Functions

static StarRandomInstance ()
 Obtain the single instance of the random number generator.
 
static void set (ROOT::Math::GSLRandomEngine *engine)
 Set the random number generator engine.
 
static void capture ()
 Capture gRandom random number generator.
 
static void seed (UInt_t s)
 
static void seed (UShort_t seed1, UShort_t seed2)
 

Protected Member Functions

 ClassDef (StarRandom, 1)
 

Protected Attributes

UInt_t mSeed
 
TArrayC mState
 

Static Protected Attributes

static StarRandomsInstance = 0
 
static
ROOT::Math::GSLRandomEngine * 
mEngine = 0
 

Detailed Description

A class for providing random number generation.

StarRandom is a singleton class which allows users to implement a common random number generator interface across multiple physics event generators.

Example: Remap pythia 6's random number generator

extern "C" { Double_t pyr( Int_t *idummy ){ return StarRandom::Instance().flat(); }; };

Author
Jason C. Webb

Definition at line 30 of file StarRandom.h.

Member Function Documentation

UInt_t StarRandom::poisson ( const Double_t  mu) const

Returns an integer sampled from a possion distribution with expected value mu

Definition at line 79 of file StarRandom.cxx.

void StarRandom::seed ( UInt_t  s)
static

Set the seed for this simulation. Note: Most RNG engines in GSL utilize a 32-bit seed. Those which use a smaller seed will take the provided seed modulo 32 bits. There may not be a warning issued when this occurs.

Parameters
seedis an unsigned integer (32-bit word) providing a seed for tne RNG.

Definition at line 119 of file StarRandom.cxx.

References Instance().

Referenced by Instance(), and seed().

void StarRandom::seed ( UShort_t  seed1,
UShort_t  seed2 
)
static

Set a pair of seeds for this simulation. The two seeds will be combined into a single 32-bit word, and passed to the RNG engine.

Parameters
seed1is the first RNG seed.
seed2is the second RNG seed.

Definition at line 126 of file StarRandom.cxx.

References seed().


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