CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
RandomEngine.h
Go to the documentation of this file.
1 #ifndef FastSimulation_Utilities_RandomEngine_H
2 #define FastSimulation_Utilities_RandomEngine_H
3 
4 #include "CLHEP/Random/Random.h"
5 #include "CLHEP/Random/RandFlat.h"
6 #include "CLHEP/Random/RandGaussQ.h"
7 #include "CLHEP/Random/RandPoissonQ.h"
8 #include "TRandom3.h"
9 
10 namespace CLHEP {
11  class HepRandomEngine;
12 }
13 
14 namespace edm {
15  class RandomNumberGenerator;
16 }
17 
18 class RandomEngine {
19 
20  public:
21 
23 
24  CLHEP::HepRandomEngine* theEngine() const { return engine_; }
25 
27 
28  ~RandomEngine();
29 
30  inline double flatShoot(double xmin=0.0, double xmax=1.0) const{
31  return rootEngine_ ?
32  xmin + (xmax-xmin) * rootEngine_->Rndm()
33  :
34  xmin + (xmax-xmin)*flatDistribution_->fire();
35  }
36 
37  inline double gaussShoot(double mean=0.0, double sigma=1.0) const {
38  return rootEngine_ ?
39  rootEngine_->Gaus(mean,sigma)
40  :
42  }
43 
44  inline unsigned int poissonShoot(double mean) const{
45  return rootEngine_ ?
46  rootEngine_->Poisson(mean)
47  :
48  poissonDistribution_->fire(mean);
49  }
50 
51  private:
52 
54 
55  CLHEP::RandFlat* flatDistribution_;
56  CLHEP::RandGauss* gaussianDistribution_;
57  CLHEP::RandPoisson* poissonDistribution_;
58  CLHEP::HepRandomEngine* engine_;
59 
60  TRandom3* rootEngine_;
61 
62 };
63 
64 #endif // FastSimulation_Utilities_RandomEngine_H
TRandom3 * rootEngine_
Definition: RandomEngine.h:60
edm::RandomNumberGenerator * rng_
Definition: RandomEngine.h:53
RandomEngine(edm::RandomNumberGenerator *rng)
Definition: RandomEngine.cc:5
double gaussShoot(double mean=0.0, double sigma=1.0) const
Definition: RandomEngine.h:37
CLHEP::HepRandomEngine * theEngine() const
Definition: RandomEngine.h:24
CLHEP::RandPoisson * poissonDistribution_
Definition: RandomEngine.h:57
unsigned int poissonShoot(double mean) const
Definition: RandomEngine.h:44
CLHEP::RandFlat * flatDistribution_
Definition: RandomEngine.h:55
double flatShoot(double xmin=0.0, double xmax=1.0) const
Definition: RandomEngine.h:30
CLHEP::HepRandomEngine * engine_
Definition: RandomEngine.h:58
CLHEP::RandGauss * gaussianDistribution_
Definition: RandomEngine.h:56
edm::RandomNumberGenerator * theRandomNumberGenerator() const
Definition: RandomEngine.h:22