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 
25  // This is strongly deprecated, it exists for backward compatibility
26  // for cases where the above two functions cannot be used easily.
27  // It is the intent fix all those cases and delete this function
28  // as soon as possible.
30 
32 
33  CLHEP::HepRandomEngine& theEngine() const { return *engine_; }
34 
35  inline double flatShoot(double xmin=0.0, double xmax=1.0) const {
36  if(rootEngine_) {
37  return xmin + (xmax - xmin) * rootEngine_->Rndm();
38  } else {
39  CLHEP::RandFlat flatDistribution(*engine_);
40  return xmin + (xmax - xmin) * flatDistribution.fire();
41  }
42  }
43 
44  inline double gaussShoot(double mean=0.0, double sigma=1.0) const {
45  if(rootEngine_) {
46  return rootEngine_->Gaus(mean,sigma);
47  } else {
48  CLHEP::RandGaussQ gaussianDistribution(*engine_);
49  return mean + sigma * gaussianDistribution.fire();
50  }
51  }
52 
53  inline unsigned int poissonShoot(double mean) const{
54  if(rootEngine_) {
55  return rootEngine_->Poisson(mean);
56  } else {
57  CLHEP::RandPoissonQ poissonDistribution(*engine_);
58  return poissonDistribution.fire(mean);
59  }
60  }
61 
62  private:
63 
64  CLHEP::HepRandomEngine* engine_;
65  TRandom3* rootEngine_;
66 };
67 #endif // FastSimulation_Utilities_RandomEngineAndDistribution_H
double flatShoot(double xmin=0.0, double xmax=1.0) const
CLHEP::HepRandomEngine & theEngine() const
double gaussShoot(double mean=0.0, double sigma=1.0) const
unsigned int poissonShoot(double mean) const