CLHEP VERSION Reference Documentation
   
CLHEP Home Page     CLHEP Documentation     CLHEP Bug Reports

EngineFactory.cc
Go to the documentation of this file.
1 // $Id:
2 // -*- C++ -*-
3 //
4 // -----------------------------------------------------------------------
5 // HEP Random
6 // --- EngineFactory ---
7 // class implementation file
8 // -----------------------------------------------------------------------
9 //
10 // =======================================================================
11 // Mark Fischler - Created: Dec. 21, 2004
12 // =======================================================================
13 
14 #include "CLHEP/Random/defs.h"
15 #include "CLHEP/Random/EngineFactory.h"
16 #include "CLHEP/Random/DRand48Engine.h"
17 #include "CLHEP/Random/DualRand.h"
18 #include "CLHEP/Random/Hurd160Engine.h"
19 #include "CLHEP/Random/Hurd288Engine.h"
20 #include "CLHEP/Random/JamesRandom.h"
21 #include "CLHEP/Random/JamesRandom.h"
22 #include "CLHEP/Random/MTwistEngine.h"
23 #include "CLHEP/Random/RandEngine.h"
24 #include "CLHEP/Random/RanecuEngine.h"
25 #include "CLHEP/Random/Ranlux64Engine.h"
26 #include "CLHEP/Random/RanluxEngine.h"
27 #include "CLHEP/Random/RanshiEngine.h"
28 #include "CLHEP/Random/TripleRand.h"
29 #include "CLHEP/Random/NonRandomEngine.h"
30 #include "CLHEP/Random/engineIDulong.h"
31 #include <iostream>
32 #include <string>
33 
34 namespace CLHEP {
35 
36 template<class E>
37 static HepRandomEngine*
38 makeAnEngine (const std::string & tag,
39  std::istream & is) {
40  if ( tag != E::beginTag() ) return 0;
41  HepRandomEngine* eptr = new E;
42  eptr->getState(is);
43  if (!is) return 0;
44  return eptr;
45 }
46 
47 template<class E>
48 static HepRandomEngine*
49 makeAnEngine (const std::vector<unsigned long> & v) {
50  if ( (v[0] & 0xffffffffUL) != engineIDulong<E>() ) return 0;
51  HepRandomEngine* eptr = new E;
52  bool success = eptr->getState(v);
53  if (!success) return 0;
54  // std::cerr << "makeAnEngine made " << E::engineName() << "\n";
55  return eptr;
56 }
57 
59  HepRandomEngine* eptr;
60  std::string tag;
61  is >> tag;
62  eptr = makeAnEngine <HepJamesRandom> (tag, is); if (eptr) return eptr;
63  eptr = makeAnEngine <RanecuEngine> (tag, is); if (eptr) return eptr;
64  eptr = makeAnEngine <Ranlux64Engine> (tag, is); if (eptr) return eptr;
65  eptr = makeAnEngine <MTwistEngine> (tag, is); if (eptr) return eptr;
66  eptr = makeAnEngine <DRand48Engine> (tag, is); if (eptr) return eptr;
67  eptr = makeAnEngine <TripleRand> (tag, is); if (eptr) return eptr;
68  eptr = makeAnEngine <DualRand> (tag, is); if (eptr) return eptr;
69  eptr = makeAnEngine <Hurd160Engine> (tag, is); if (eptr) return eptr;
70  eptr = makeAnEngine <Hurd288Engine> (tag, is); if (eptr) return eptr;
71  eptr = makeAnEngine <RandEngine> (tag, is); if (eptr) return eptr;
72  eptr = makeAnEngine <RanluxEngine> (tag, is); if (eptr) return eptr;
73  eptr = makeAnEngine <RanshiEngine> (tag, is); if (eptr) return eptr;
74  eptr = makeAnEngine <NonRandomEngine> (tag, is); if (eptr) return eptr;
75  is.clear(std::ios::badbit | is.rdstate());
76  std::cerr <<
77  "Input mispositioned or bad in reading anonymous engine\n"
78  << "\nBegin-tag read was: " << tag
79  << "\nInput stream is probably fouled up\n";
80  return eptr;
81 }
82 
84 EngineFactory::newEngine(std::vector<unsigned long> const & v) {
85  HepRandomEngine* eptr;
86  eptr = makeAnEngine <HepJamesRandom> (v); if (eptr) return eptr;
87  eptr = makeAnEngine <RanecuEngine> (v); if (eptr) return eptr;
88  eptr = makeAnEngine <Ranlux64Engine> (v); if (eptr) return eptr;
89  eptr = makeAnEngine <MTwistEngine> (v); if (eptr) return eptr;
90  eptr = makeAnEngine <DRand48Engine> (v); if (eptr) return eptr;
91  eptr = makeAnEngine <TripleRand> (v); if (eptr) return eptr;
92  eptr = makeAnEngine <DualRand> (v); if (eptr) return eptr;
93  eptr = makeAnEngine <Hurd160Engine> (v); if (eptr) return eptr;
94  eptr = makeAnEngine <Hurd288Engine> (v); if (eptr) return eptr;
95  eptr = makeAnEngine <RandEngine> (v); if (eptr) return eptr;
96  eptr = makeAnEngine <RanluxEngine> (v); if (eptr) return eptr;
97  eptr = makeAnEngine <RanshiEngine> (v); if (eptr) return eptr;
98  eptr = makeAnEngine <NonRandomEngine> (v); if (eptr) return eptr;
99  std::cerr <<
100  "Cannot correctly get anonymous engine from vector\n"
101  << "First unsigned long was: " << v[0]
102  << " Vector size was: " << v.size() <<"\n";
103  return eptr;
104 }
105 
106 } // namespace CLHEP
107 
CLHEP::HepRandomEngine::getState
virtual std::istream & getState(std::istream &is)
Definition: RandomEngine.cc:71
CLHEP::HepRandomEngine
Definition: Matrix/CLHEP/Random/RandomEngine.h:55
is
HepRotation and so forth isNear() norm2() rectify() static Rotation row1 row4(To avoid bloat in the code pulled in for programs which don 't use all these features, we split the implementation .cc files. Only isNear() goes into the original Rotation.cc) --------------------------------------- HepAxisAngle and HepEulerAngles classes --------------------------------------- These classes are very useful and simple structures for holding the result of a nice intuituve decomposition of a rotation there is no longer much content in the distinct ZOOM PhysicsVectors library The only content left in the library is the object files representing the various Exception objects When we build the CLHEP classes for the ZOOM we will set up so as to use ZOOM SpaceVector is(but we can disable namespace usage and most of our users do so at this point). What I do is leave Hep3Vector in the global namespace
CLHEP
Definition: ClhepVersion.h:13
v
they are gone ZOOM Features Discontinued The following features of the ZOOM package were felt to be extreme overkill These have been after checking that no existing user code was utilizing as in SpaceVector v
Definition: keyMergeIssues.doc:324
CLHEP::EngineFactory::newEngine
static HepRandomEngine * newEngine(std::istream &is)
Definition: EngineFactory.cc:58