CMS 3D CMS Logo

RandomEngineAndDistribution.cc
Go to the documentation of this file.
2 
7 
8 #include "CLHEP/Random/RandomEngine.h"
9 
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 }
26 
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 }
43 
45 }
#define nullptr
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
RandomEngineAndDistribution(edm::StreamID const &)
bool isAvailable() const
Definition: Service.h:46