CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10/src/FastSimulation/Utilities/interface/RandomEngine.h

Go to the documentation of this file.
00001 #ifndef FastSimulation_Utilities_RandomEngine_H
00002 #define FastSimulation_Utilities_RandomEngine_H
00003 
00004 #include "CLHEP/Random/Random.h"
00005 #include "CLHEP/Random/RandFlat.h"
00006 #include "CLHEP/Random/RandGaussQ.h"
00007 #include "CLHEP/Random/RandPoissonQ.h"
00008 #include "TRandom3.h"
00009 
00010 namespace CLHEP { 
00011   class HepRandomEngine;
00012 }
00013 
00014 namespace edm {
00015   class RandomNumberGenerator;
00016 }
00017 
00018 class RandomEngine {
00019 
00020  public:
00021 
00022   edm::RandomNumberGenerator* theRandomNumberGenerator() const {return rng_;}
00023 
00024   CLHEP::HepRandomEngine* theEngine() const { return engine_; }
00025 
00026   RandomEngine(edm::RandomNumberGenerator* rng);
00027 
00028   ~RandomEngine();
00029 
00030   inline double flatShoot(double xmin=0.0, double xmax=1.0) const{ 
00031     return rootEngine_ ? 
00032       xmin + (xmax-xmin) * rootEngine_->Rndm()
00033       :
00034       xmin + (xmax-xmin)*flatDistribution_->fire();
00035   }
00036 
00037   inline double gaussShoot(double mean=0.0, double sigma=1.0) const { 
00038     return rootEngine_ ?
00039       rootEngine_->Gaus(mean,sigma)
00040       : 
00041       mean + sigma*gaussianDistribution_->fire();
00042   }
00043   
00044   inline unsigned int poissonShoot(double mean) const{ 
00045     return rootEngine_ ? 
00046       rootEngine_->Poisson(mean)
00047       :
00048       poissonDistribution_->fire(mean);
00049   }
00050   
00051  private:
00052 
00053   edm::RandomNumberGenerator* rng_;
00054 
00055   CLHEP::RandFlat* flatDistribution_;
00056   CLHEP::RandGauss* gaussianDistribution_;
00057   CLHEP::RandPoisson* poissonDistribution_;
00058   CLHEP::HepRandomEngine* engine_;
00059 
00060   TRandom3* rootEngine_;
00061 
00062 };
00063 
00064 #endif // FastSimulation_Utilities_RandomEngine_H