StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StarRandom.h
1 #ifndef __StarRandom_h__
2 #define __StarRandom_h__
3 
4 #include "TObject.h"
5 #include "Math/GSLRndmEngines.h"
6 #include "TVector2.h"
7 #include "TRandom.h"
8 #include "TArrayC.h"
9 
30 class StarRandom : public TObject
31 {
32  StarRandom();
33  public:
34  ~StarRandom();
35 
37  static StarRandom &Instance();
38 
40  static void set( ROOT::Math::GSLRandomEngine *engine );
41 
43  static void capture();
44 
50  static void seed( UInt_t s );
51 
56  static void seed( UShort_t seed1, UShort_t seed2 );
57 
59  Double_t operator()() const;
61  Double_t operator()( const Double_t mn, const Double_t mx ) const;
62 
64  Double_t operator()( Int_t *idummy ){ return (*this)(); }
65 
66 
68  Double_t flat() const;
70  Double_t flat( const Double_t mn, const Double_t mx ) const;
71 
73  Double_t expo( const Double_t mu ) const;
75  Double_t landau() const;
77  Double_t gauss( const Double_t sigma ) const ;
79  TVector2 gauss2d( const Double_t sx, const Double_t sy, const Double_t rho ) const;
80 
83  UInt_t poisson( const Double_t mu ) const;
84 
85  private:
86  protected:
87 
88  static StarRandom *sInstance;
89  static ROOT::Math::GSLRandomEngine *mEngine;
90 
91  UInt_t mSeed; // Random number seed
92  TArrayC mState; // Random number state
93 
94  ClassDef(StarRandom,1);
95 
96 };
97 
98 #endif
Double_t operator()() const
Return a random number uniformly distributed between 0 and 1.
Definition: StarRandom.cxx:81
Double_t expo(const Double_t mu) const
Return a random number distribted according to exp(-mu)
Definition: StarRandom.cxx:70
Double_t gauss(const Double_t sigma) const
Return a random number distributed according to a gaussian with specified sigma.
Definition: StarRandom.cxx:72
Double_t landau() const
Return a random number distributed according to a landau.
Definition: StarRandom.cxx:71
static StarRandom & Instance()
Obtain the single instance of the random number generator.
Definition: StarRandom.cxx:87
UInt_t poisson(const Double_t mu) const
Definition: StarRandom.cxx:79
A class for providing random number generation.
Definition: StarRandom.h:30
Double_t flat() const
Return a random number uniformly distributed between 0 and 1.
Definition: StarRandom.cxx:68
static void set(ROOT::Math::GSLRandomEngine *engine)
Set the random number generator engine.
Definition: StarRandom.cxx:117
static void seed(UInt_t s)
Definition: StarRandom.cxx:119
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.
Definition: StarRandom.cxx:73
static void capture()
Capture gRandom random number generator.
Definition: StarRandom.cxx:57