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 
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 }
funct::false
false
Definition: Factorize.h:29
ThePEG::Proxy< Proxy >::find
static std::shared_ptr< Proxy > find(ProxyID id)
Definition: Proxy.h:46
edm::errors::LogicError
Definition: EDMException.h:37
ThePEG::RandomEngineGlue::initRandomEngineGlue
static ClassDescription< RandomEngineGlue > initRandomEngineGlue
Definition: RandomEngineGlue.h:72
ThePEG::RandomEngineGlue::flush
void flush()
Definition: RandomEngineGlue.cc:22
EDMException.h
fileCollector.seed
seed
Definition: fileCollector.py:127
ThePEG
Definition: Herwig7Interface.h:24
ThePEG::RandomEngineGlue::RandomEngineGlue
RandomEngineGlue()
Definition: RandomEngineGlue.cc:18
ThePEG::RandomEngineGlue::Init
static void Init()
Definition: RandomEngineGlue.cc:57
ThePEG::RandomEngineGlue::fill
void fill() override
Definition: RandomEngineGlue.cc:27
randomEngine
CLHEP::HepRandomEngine * randomEngine
Definition: Dummies.cc:7
ThePEG::RandomEngineGlue::randomEngine
CLHEP::HepRandomEngine * randomEngine
Definition: RandomEngineGlue.h:70
ThePEG::ProxyBase::ProxyID
unsigned long ProxyID
Definition: Proxy.h:16
ThePEG::RandomEngineGlue::proxyID
Proxy::ProxyID proxyID
Definition: RandomEngineGlue.h:69
Exception
Definition: hltDiff.cc:245
ThePEG::RandomEngineGlue::~RandomEngineGlue
~RandomEngineGlue() override
Definition: RandomEngineGlue.cc:20
ThePEG::RandomEngineGlue::setSeed
void setSeed(long seed) override
Definition: RandomEngineGlue.cc:39
ThePEG::RandomEngineGlue::doinit
void doinit() noexcept(false) override
Definition: RandomEngineGlue.cc:43
RandomEngineGlue.h