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 &)
 
 RandomEngineAndDistribution ()
 
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() const =0
Use this to get the random number engine, this is the only function most users should call...
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() const =0
Use this to get the random number engine, this is the only function most users should call...
RandomEngineAndDistribution::RandomEngineAndDistribution ( )

Definition at line 44 of file RandomEngineAndDistribution.cc.

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

44  :
45  engine_(nullptr),
46  rootEngine_(nullptr) {
48  if ( ! rng.isAvailable() ) {
49  throw cms::Exception("Configuration") <<
50  "RandomNumberGenerator service is not available.\n"
51  "You must add the service in the configuration file\n"
52  "or remove the module that requires it.";
53  }
54  engine_ = &rng->getEngine();
55 
56  // Get the TRandom3 egine, to benefit from Root functional random generation
57  if ( engine_->name() == "TRandom3" )
58  rootEngine_ = ( (edm::TRandomAdaptor*) engine_ )->getRootEngine();
59 }
bool isAvailable() const
Definition: Service.h:46
virtual CLHEP::HepRandomEngine & getEngine() const =0
Use this to get the random number engine, this is the only function most users should call...
RandomEngineAndDistribution::~RandomEngineAndDistribution ( )

Definition at line 61 of file RandomEngineAndDistribution.cc.

61  {
62 }

Member Function Documentation

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

Definition at line 35 of file RandomEngineAndDistribution.h.

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

Referenced by EcalHitMaker::addHit(), PileUpProducer::beginRun(), BremsstrahlungSimulator::brem(), MuonBremsstrahlungSimulator::brem(), MultipleScatteringSimulator::compute(), PairProductionSimulator::compute(), HFShower::compute(), HDShower::compute(), EMShower::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(), HcalRecHitsMaker::noisifySubdet(), EcalPreshowerRecHitsMaker::noisifySubdet(), NuclearInteractionSimulator::NuclearInteractionSimulator(), BremsstrahlungSimulator::poisson(), EcalBarrelRecHitsMaker::randomNoisifier(), EcalEndcapRecHitsMaker::randomNoisifier(), HDRShower::setHit(), DoubleCrystalBallGenerator::shoot(), GaussianTail::shoot(), SiPixelGaussianSmearingRecHitConverterAlgorithm::smearHit(), and HDRShower::thetaFunction().

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

Definition at line 33 of file RandomEngineAndDistribution.h.

References engine_.

Referenced by TrajectoryManager::updateWithDaughters().

33 { return *engine_; }

Member Data Documentation

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