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  {
12  if ( ! rng.isAvailable() ) {
13  throw cms::Exception("Configuration") <<
14  "RandomNumberGenerator service is not available.\n"
15  "You must add the service in the configuration file\n"
16  "or remove the module that requires it.";
17  }
18  engine_ = &rng->getEngine(streamID);
19 
20  // Get the TRandom3 egine, to benefit from Root functional random generation
21  if ( engine_->name() == "TRandom3" )
22  rootEngine_ = ( (edm::TRandomAdaptor*) engine_ )->getRootEngine();
23 }
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 25 of file RandomEngineAndDistribution.cc.

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

25  {
27  if ( ! rng.isAvailable() ) {
28  throw cms::Exception("Configuration") <<
29  "RandomNumberGenerator service is not available.\n"
30  "You must add the service in the configuration file\n"
31  "or remove the module that requires it.";
32  }
33  engine_ = &rng->getEngine(luminosityBlockIndex);
34 
35  // Get the TRandom3 egine, to benefit from Root functional random generation
36  if ( engine_->name() == "TRandom3" )
37  rootEngine_ = ( (edm::TRandomAdaptor*) engine_ )->getRootEngine();
38 }
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 40 of file RandomEngineAndDistribution.cc.

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

40  {
42  if ( ! rng.isAvailable() ) {
43  throw cms::Exception("Configuration") <<
44  "RandomNumberGenerator service is not available.\n"
45  "You must add the service in the configuration file\n"
46  "or remove the module that requires it.";
47  }
48  engine_ = &rng->getEngine();
49 
50  // Get the TRandom3 egine, to benefit from Root functional random generation
51  if ( engine_->name() == "TRandom3" )
52  rootEngine_ = ( (edm::TRandomAdaptor*) engine_ )->getRootEngine();
53 }
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 55 of file RandomEngineAndDistribution.cc.

55  {
56 }

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