14 #include "CLHEP/Random/EngineFactory.h"
15 #include "CLHEP/Random/DualRand.h"
16 #include "CLHEP/Random/JamesRandom.h"
17 #include "CLHEP/Random/MixMaxRng.h"
18 #include "CLHEP/Random/MTwistEngine.h"
19 #include "CLHEP/Random/RanecuEngine.h"
20 #include "CLHEP/Random/Ranlux64Engine.h"
21 #include "CLHEP/Random/RanluxEngine.h"
22 #include "CLHEP/Random/RanshiEngine.h"
23 #include "CLHEP/Random/NonRandomEngine.h"
24 #include "CLHEP/Random/engineIDulong.h"
31 static HepRandomEngine*
34 if ( tag != E::beginTag() )
return 0;
35 HepRandomEngine* eptr =
new E;
42 static HepRandomEngine*
44 if ( (v[0] & 0xffffffffUL) != engineIDulong<E>() )
return 0;
45 HepRandomEngine* eptr =
new E;
46 bool success = eptr->getState(v);
47 if (!success)
return 0;
52 HepRandomEngine* EngineFactory::newEngine(std::istream& is) {
53 HepRandomEngine* eptr;
56 eptr = makeAnEngine <HepJamesRandom> (tag, is);
if (eptr)
return eptr;
57 eptr = makeAnEngine <RanecuEngine> (tag, is);
if (eptr)
return eptr;
58 eptr = makeAnEngine <Ranlux64Engine> (tag, is);
if (eptr)
return eptr;
59 eptr = makeAnEngine <MixMaxRng> (tag, is);
if (eptr)
return eptr;
60 eptr = makeAnEngine <MTwistEngine> (tag, is);
if (eptr)
return eptr;
61 eptr = makeAnEngine <DualRand> (tag, is);
if (eptr)
return eptr;
62 eptr = makeAnEngine <RanluxEngine> (tag, is);
if (eptr)
return eptr;
63 eptr = makeAnEngine <RanshiEngine> (tag, is);
if (eptr)
return eptr;
64 eptr = makeAnEngine <NonRandomEngine> (tag, is);
if (eptr)
return eptr;
65 is.clear(std::ios::badbit | is.rdstate());
67 "Input mispositioned or bad in reading anonymous engine\n"
68 <<
"\nBegin-tag read was: " << tag
69 <<
"\nInput stream is probably fouled up\n";
74 EngineFactory::newEngine(std::vector<unsigned long>
const & v) {
75 HepRandomEngine* eptr;
76 eptr = makeAnEngine <HepJamesRandom> (v);
if (eptr)
return eptr;
77 eptr = makeAnEngine <RanecuEngine> (v);
if (eptr)
return eptr;
78 eptr = makeAnEngine <Ranlux64Engine> (v);
if (eptr)
return eptr;
79 eptr = makeAnEngine <MixMaxRng> (v);
if (eptr)
return eptr;
80 eptr = makeAnEngine <MTwistEngine> (v);
if (eptr)
return eptr;
81 eptr = makeAnEngine <DualRand> (v);
if (eptr)
return eptr;
82 eptr = makeAnEngine <RanluxEngine> (v);
if (eptr)
return eptr;
83 eptr = makeAnEngine <RanshiEngine> (v);
if (eptr)
return eptr;
84 eptr = makeAnEngine <NonRandomEngine> (v);
if (eptr)
return eptr;
86 "Cannot correctly get anonymous engine from vector\n"
87 <<
"First unsigned long was: " << v[0]
88 <<
" Vector size was: " << v.size() <<
"\n";
static HepRandomEngine * makeAnEngine(const std::string &tag, std::istream &is)