CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
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 }
43 
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 }
60 
62 }
#define nullptr
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...