CMS 3D CMS Logo

RandomEngineGlue.cc
Go to the documentation of this file.
1 #include <string>
2 
3 #include <CLHEP/Random/RandomEngine.h>
4 
5 #include <ThePEG/Interface/ClassDocumentation.h>
6 #include <ThePEG/Interface/InterfacedBase.h>
7 #include <ThePEG/Interface/Parameter.h>
8 #include <ThePEG/Utilities/ClassTraits.h>
9 
10 #include <ThePEG/Repository/StandardRandom.h>
11 
13 
15 
16 using namespace ThePEG;
17 
18 RandomEngineGlue::RandomEngineGlue() : randomEngine(nullptr) {}
19 
21 
23  RandomGenerator::flush();
24  gaussSaved = false;
25 }
26 
28  if (randomEngine == nullptr) {
29  throw edm::Exception(edm::errors::LogicError) << "The PEG code attempted to a generate random number while\n"
30  << "the engine pointer was null. This might mean that the code\n"
31  << "was tried to generate a random number outside the event and\n"
32  << "beginLuminosityBlock methods, which is not allowed.\n";
33  }
34  nextNumber = theNumbers.begin();
35  for (RndVector::iterator it = nextNumber; it != theNumbers.end(); ++it)
36  *it = randomEngine->flat();
37 }
38 
40  // we ignore this, CMSSW overrides the seed from ThePEG
41 }
42 
43 void RandomEngineGlue::doinit() noexcept(false) {
44  RandomGenerator::doinit();
45 
46  std::shared_ptr<Proxy> proxy = Proxy::find(proxyID);
47  if (!proxy)
48  throw InitException();
49 
50  proxy->instance = this;
51  randomEngine = proxy->getRandomEngine();
52  flush();
53 }
54 
55 ClassDescription<RandomEngineGlue> RandomEngineGlue::initRandomEngineGlue;
56 
58  typedef Proxy::ProxyID ProxyID;
59 
60  static ClassDocumentation<RandomEngineGlue> documentation("Interface to the CMSSW RandomNumberEngine.");
61  static Parameter<RandomEngineGlue, ProxyID> interfaceProxyID(
62  "ProxyID", "The ProxyID.", &RandomEngineGlue::proxyID, ProxyID(), ProxyID(), ProxyID(), false, false, false);
63 
64  interfaceProxyID.rank(11);
65 }
void setSeed(long seed) override
void doinit() noexcept(false) override
static std::shared_ptr< Proxy > find(ProxyID id)
Definition: Proxy.h:46
unsigned long ProxyID
Definition: Proxy.h:16
CLHEP::HepRandomEngine * randomEngine
static ClassDescription< RandomEngineGlue > initRandomEngineGlue