test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
RandomEngineGlue.h
Go to the documentation of this file.
1 #ifndef GeneratorInterface_ThePEGInterface_RandomEngineGlue_h
2 #define GeneratorInterface_ThePEGInterface_RandomEngineGlue_h
3 
4 #include <string>
5 
6 #include <boost/shared_ptr.hpp>
7 
8 #include <ThePEG/Interface/ClassDocumentation.h>
9 #include <ThePEG/Interface/InterfacedBase.h>
10 #include <ThePEG/Interface/Parameter.h>
11 #include <ThePEG/Utilities/ClassTraits.h>
12 
13 #include <ThePEG/Repository/StandardRandom.h>
14 
16 
17 namespace CLHEP {
18  class HepRandomEngine; // forward declaration
19 }
20 
21 namespace ThePEG {
22 
23 class RandomEngineGlue : public RandomGenerator {
24  public:
26  virtual ~RandomEngineGlue();
27 
28  void setRandomEngine(CLHEP::HepRandomEngine* v) { randomEngine = v; }
29 
30  void flush();
31 
32  static void Init();
33 
34  class Proxy : public ThePEG::Proxy<Proxy> {
35  public:
36  RandomEngineGlue *getInstance() const { return instance; }
37 
38  CLHEP::HepRandomEngine* getRandomEngine() const { return randomEngine; }
39  void setRandomEngine(CLHEP::HepRandomEngine* v) { randomEngine = v; }
40 
41  private:
42  friend class RandomEngineGlue;
43  friend class ThePEG::Proxy<Proxy>;
44 
45  inline Proxy(ProxyID id) : Base(id), instance(0) {}
46 
48 
49  // I do not like putting this here, but I could not
50  // think of an alternative without modifying the
51  // external code in ThePEG. The problem is the
52  // function ThePEG::Repository::makeRun both
53  // sets the pointer in the proxy and uses the
54  // engine. There is no opportunity to set the
55  // engine pointer before it is used without passing
56  // it in through the proxy.
57  CLHEP::HepRandomEngine *randomEngine;
58  };
59 
60  protected:
61  virtual void fill();
62  virtual void setSeed(long seed);
63 
64  virtual IBPtr clone() const { return new_ptr(*this); }
65  virtual IBPtr fullclone() const { return new_ptr(*this); }
66 
67  virtual void doinit() throw(InitException);
68 
69  private:
71  CLHEP::HepRandomEngine *randomEngine;
72 
73  static ClassDescription<RandomEngineGlue> initRandomEngineGlue;
74 };
75 
76 template<>
77 struct BaseClassTrait<RandomEngineGlue, 1> : public ClassTraitsType {
79  typedef RandomGenerator NthBase;
80 };
81 
84 template<>
85 struct ClassTraits<RandomEngineGlue> :
86  public ClassTraitsBase<RandomEngineGlue> {
88  static string className() { return "ThePEG::RandomEngineGlue"; }
89  static string library() { return "libGeneratorInterfaceThePEGInterface.so"; }
90 };
91 
92 } // namespace ThePEG
93 
94 #endif // GeneratorInterface_ThePEGInterface_RandomEngineGlue_h
void setRandomEngine(CLHEP::HepRandomEngine *v)
CLHEP::HepRandomEngine * getRandomEngine() const
RandomEngineGlue * getInstance() const
virtual IBPtr clone() const
virtual IBPtr fullclone() const
CLHEP::HepRandomEngine * randomEngine
virtual void setSeed(long seed)
unsigned long ProxyID
Definition: Proxy.h:16
void setRandomEngine(CLHEP::HepRandomEngine *v)
def template
Definition: svgfig.py:520
CLHEP::HepRandomEngine * randomEngine
static ClassDescription< RandomEngineGlue > initRandomEngineGlue