CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
RandomEngineAndDistribution.h
Go to the documentation of this file.
1 #ifndef FastSimulation_Utilities_RandomEngineAndDistribution_H
2 #define FastSimulation_Utilities_RandomEngineAndDistribution_H
3 
4 #include "CLHEP/Random/RandFlat.h"
5 #include "CLHEP/Random/RandGaussQ.h"
6 #include "CLHEP/Random/RandPoissonQ.h"
7 #include "TRandom3.h"
8 
9 namespace CLHEP {
10  class HepRandomEngine;
11 }
12 
13 namespace edm {
14  class LuminosityBlockIndex;
15  class StreamID;
16 }
17 
19 
20  public:
21 
24 
26 
27  CLHEP::HepRandomEngine& theEngine() const { return *engine_; }
28 
29  inline double flatShoot(double xmin=0.0, double xmax=1.0) const {
30  if(rootEngine_) {
31  return xmin + (xmax - xmin) * rootEngine_->Rndm();
32  } else {
33  CLHEP::RandFlat flatDistribution(*engine_);
34  return xmin + (xmax - xmin) * flatDistribution.fire();
35  }
36  }
37 
38  inline double gaussShoot(double mean=0.0, double sigma=1.0) const {
39  if(rootEngine_) {
40  return rootEngine_->Gaus(mean,sigma);
41  } else {
42  CLHEP::RandGaussQ gaussianDistribution(*engine_);
43  return mean + sigma * gaussianDistribution.fire();
44  }
45  }
46 
47  inline unsigned int poissonShoot(double mean) const{
48  if(rootEngine_) {
49  return rootEngine_->Poisson(mean);
50  } else {
51  CLHEP::RandPoissonQ poissonDistribution(*engine_);
52  return poissonDistribution.fire(mean);
53  }
54  }
55 
56  private:
57 
58  CLHEP::HepRandomEngine* engine_;
59  TRandom3* rootEngine_;
60 };
61 #endif // FastSimulation_Utilities_RandomEngineAndDistribution_H
double flatShoot(double xmin=0.0, double xmax=1.0) const
RandomEngineAndDistribution(edm::StreamID const &)
CLHEP::HepRandomEngine & theEngine() const
double gaussShoot(double mean=0.0, double sigma=1.0) const
unsigned int poissonShoot(double mean) const