CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
RandomEngineAndDistribution Class Reference

#include <RandomEngineAndDistribution.h>

Public Member Functions

double flatShoot (double xmin=0.0, double xmax=1.0) const
 
double gaussShoot (double mean=0.0, double sigma=1.0) const
 
unsigned int poissonShoot (double mean) const
 
 RandomEngineAndDistribution (edm::StreamID const &)
 
 RandomEngineAndDistribution (edm::LuminosityBlockIndex const &)
 
CLHEP::HepRandomEngine & theEngine () const
 
 ~RandomEngineAndDistribution ()
 

Private Attributes

CLHEP::HepRandomEngine * engine_
 
TRandom3 * rootEngine_
 

Detailed Description

Definition at line 18 of file RandomEngineAndDistribution.h.

Constructor & Destructor Documentation

RandomEngineAndDistribution::RandomEngineAndDistribution ( edm::StreamID const &  streamID)

Definition at line 10 of file RandomEngineAndDistribution.cc.

References engine_, edm::hlt::Exception, edm::RandomNumberGenerator::getEngine(), edm::Service< T >::isAvailable(), and rootEngine_.

10  :
11  engine_(nullptr),
12  rootEngine_(nullptr) {
14  if ( ! rng.isAvailable() ) {
15  throw cms::Exception("Configuration") <<
16  "RandomNumberGenerator service is not available.\n"
17  "You must add the service in the configuration file\n"
18  "or remove the module that requires it.";
19  }
20  engine_ = &rng->getEngine(streamID);
21 
22  // Get the TRandom3 egine, to benefit from Root functional random generation
23  if ( engine_->name() == "TRandom3" )
24  rootEngine_ = ( (edm::TRandomAdaptor*) engine_ )->getRootEngine();
25 }
bool isAvailable() const
Definition: Service.h:46
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &) const =0
Use this engine in event methods.
RandomEngineAndDistribution::RandomEngineAndDistribution ( edm::LuminosityBlockIndex const &  luminosityBlockIndex)

Definition at line 27 of file RandomEngineAndDistribution.cc.

References engine_, edm::hlt::Exception, edm::RandomNumberGenerator::getEngine(), edm::Service< T >::isAvailable(), and rootEngine_.

27  :
28  engine_(nullptr),
29  rootEngine_(nullptr) {
31  if ( ! rng.isAvailable() ) {
32  throw cms::Exception("Configuration") <<
33  "RandomNumberGenerator service is not available.\n"
34  "You must add the service in the configuration file\n"
35  "or remove the module that requires it.";
36  }
37  engine_ = &rng->getEngine(luminosityBlockIndex);
38 
39  // Get the TRandom3 egine, to benefit from Root functional random generation
40  if ( engine_->name() == "TRandom3" )
41  rootEngine_ = ( (edm::TRandomAdaptor*) engine_ )->getRootEngine();
42 }
bool isAvailable() const
Definition: Service.h:46
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &) const =0
Use this engine in event methods.
RandomEngineAndDistribution::~RandomEngineAndDistribution ( )

Definition at line 44 of file RandomEngineAndDistribution.cc.

44  {
45 }

Member Function Documentation

double RandomEngineAndDistribution::flatShoot ( double  xmin = 0.0,
double  xmax = 1.0 
) const
inline

Definition at line 29 of file RandomEngineAndDistribution.h.

References engine_, rootEngine_, SiStripMonitorClusterAlca_cfi::xmax, and SiStripMonitorClusterAlca_cfi::xmin.

Referenced by EcalHitMaker::addHit(), BremsstrahlungSimulator::brem(), MuonBremsstrahlungSimulator::brem(), MultipleScatteringSimulator::compute(), PairProductionSimulator::compute(), HFShower::compute(), HDShower::compute(), EMShower::compute(), NuclearInteractionFTFSimulator::compute(), NuclearInteractionSimulator::compute(), HDRShower::computeShower(), CalorimetryManager::EMShowerSimulation(), GammaFunctionGenerator::gammaFrac(), GammaFunctionGenerator::gammaInt(), SiTrackerGaussianSmearingRecHitConverter::gaussianSmearing(), PairProductionSimulator::gbteth(), BremsstrahlungSimulator::gbteth(), MuonBremsstrahlungSimulator::gbteth(), FlatPrimaryVertexGenerator::generate(), SimpleHistogramGenerator::generate(), BaseNumericalRandomGenerator::generate(), BaseNumericalRandomGenerator::generateExp(), BaseNumericalRandomGenerator::generateLin(), HDRShower::getR(), HDShower::HDShower(), HFShower::HFShower(), ParticlePropagator::initProperDecayTime(), HCALResponse::interHD(), HCALResponse::interMU(), HFShower::makeSteps(), HDShower::makeSteps(), BremsstrahlungSimulator::poisson(), HDRShower::setHit(), DoubleCrystalBallGenerator::shoot(), GaussianTail::shoot(), SiPixelGaussianSmearingRecHitConverterAlgorithm::smearHit(), and HDRShower::thetaFunction().

29  {
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  }
double RandomEngineAndDistribution::gaussShoot ( double  mean = 0.0,
double  sigma = 1.0 
) const
inline
unsigned int RandomEngineAndDistribution::poissonShoot ( double  mean) const
inline

Definition at line 47 of file RandomEngineAndDistribution.h.

References engine_, and rootEngine_.

Referenced by EMShower::compute(), MuonBremsstrahlungSimulator::compute(), HCALResponse::interHD(), and HCALResponse::PoissonShootNoNegative().

47  {
48  if(rootEngine_) {
49  return rootEngine_->Poisson(mean);
50  } else {
51  CLHEP::RandPoissonQ poissonDistribution(*engine_);
52  return poissonDistribution.fire(mean);
53  }
54  }
CLHEP::HepRandomEngine& RandomEngineAndDistribution::theEngine ( ) const
inline

Definition at line 27 of file RandomEngineAndDistribution.h.

References engine_.

Referenced by TrajectoryManager::updateWithDaughters().

27 { return *engine_; }

Member Data Documentation

CLHEP::HepRandomEngine* RandomEngineAndDistribution::engine_
private
TRandom3* RandomEngineAndDistribution::rootEngine_
private