Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:11:26

0001 #ifndef FastSimulation_Utilities_RandomEngineAndDistribution_H
0002 #define FastSimulation_Utilities_RandomEngineAndDistribution_H
0003 
0004 #include "CLHEP/Random/RandFlat.h"
0005 #include "CLHEP/Random/RandGaussQ.h"
0006 #include "CLHEP/Random/RandPoissonQ.h"
0007 #include "TRandom3.h"
0008 
0009 namespace CLHEP {
0010   class HepRandomEngine;
0011 }
0012 
0013 namespace edm {
0014   class LuminosityBlockIndex;
0015   class StreamID;
0016 }  // namespace edm
0017 
0018 class RandomEngineAndDistribution {
0019 public:
0020   RandomEngineAndDistribution(edm::StreamID const&);
0021   RandomEngineAndDistribution(edm::LuminosityBlockIndex const&);
0022 
0023   ~RandomEngineAndDistribution();
0024 
0025   CLHEP::HepRandomEngine& theEngine() const { return *engine_; }
0026 
0027   inline double flatShoot(double xmin = 0.0, double xmax = 1.0) const { return xmin + (xmax - xmin) * engine_->flat(); }
0028 
0029   inline double gaussShoot(double mean = 0.0, double sigma = 1.0) const {
0030     return CLHEP::RandGauss::shoot(engine_, mean, sigma);
0031   }
0032 
0033   inline unsigned int poissonShoot(double mean) const { return CLHEP::RandPoissonQ::shoot(engine_, mean); }
0034 
0035 private:
0036   CLHEP::HepRandomEngine* engine_;
0037 };
0038 #endif  // FastSimulation_Utilities_RandomEngineAndDistribution_H