CMS 3D CMS Logo

RandomEngineGlue.h
Go to the documentation of this file.
1 #ifndef GeneratorInterface_Herwig7Interface_RandomEngineGlue_h
2 #define GeneratorInterface_Herwig7Interface_RandomEngineGlue_h
3 
4 #include <string>
5 
6 #include <ThePEG/Interface/ClassDocumentation.h>
7 #include <ThePEG/Interface/InterfacedBase.h>
8 #include <ThePEG/Interface/Parameter.h>
9 #include <ThePEG/Utilities/ClassTraits.h>
10 
11 #include <ThePEG/Repository/StandardRandom.h>
12 
14 #include "CLHEP/Random/RandomEngine.h"
15 
16 namespace CLHEP {
17  class HepRandomEngine; // forward declaration
18 }
19 
20 namespace ThePEG {
21 
22  class RandomEngineGlue : public RandomGenerator {
23  public:
25  ~RandomEngineGlue() override;
26 
27  void setRandomEngine(CLHEP::HepRandomEngine* v) { randomEngine = v; }
28  CLHEP::HepRandomEngine* getRandomEngine() const { return randomEngine; }
29  void flush();
30 
31  static void Init();
32 
33  class Proxy : public ThePEG::Proxy<Proxy> {
34  public:
35  RandomEngineGlue* getInstance() const { return instance; }
36 
37  CLHEP::HepRandomEngine* getRandomEngine() const { return randomEngine; }
38  void setRandomEngine(CLHEP::HepRandomEngine* v) { randomEngine = v; }
39 
40  private:
41  friend class RandomEngineGlue;
42  friend class ThePEG::Proxy<Proxy>;
43 
44  inline Proxy(ProxyID id) : Base(id), instance(nullptr) {}
45 
47 
48  // I do not like putting this here, but I could not
49  // think of an alternative without modifying the
50  // external code in ThePEG. The problem is the
51  // function ThePEG::Repository::makeRun both
52  // sets the pointer in the proxy and uses the
53  // engine. There is no opportunity to set the
54  // engine pointer before it is used without passing
55  // it in through the proxy.
56  CLHEP::HepRandomEngine* randomEngine;
57  };
58 
59  protected:
60  void fill() override;
61  void setSeed(long seed) override;
62 
63  IBPtr clone() const override { return new_ptr(*this); }
64  IBPtr fullclone() const override { return new_ptr(*this); }
65 
66  void doinit() noexcept(false) override;
67 
68  private:
70  CLHEP::HepRandomEngine* randomEngine;
71 
72  static ClassDescription<RandomEngineGlue> initRandomEngineGlue;
73  };
74 
75  template <>
76  struct BaseClassTrait<RandomEngineGlue, 1> : public ClassTraitsType {
78  typedef RandomGenerator NthBase;
79  };
80 
83  template <>
84  struct ClassTraits<RandomEngineGlue> : public ClassTraitsBase<RandomEngineGlue> {
86  static string className() { return "ThePEG::RandomEngineGlue"; }
87  static string library() { return "libGeneratorInterfaceHerwig7Interface.so"; }
88  };
89 
90 } // namespace ThePEG
91 
92 #endif // GeneratorInterface_Herwig7Interface_RandomEngineGlue_h
funct::false
false
Definition: Factorize.h:29
ThePEG::RandomEngineGlue::Proxy::getRandomEngine
CLHEP::HepRandomEngine * getRandomEngine() const
Definition: RandomEngineGlue.h:37
ThePEG::ClassTraits< RandomEngineGlue >::className
static string className()
Definition: RandomEngineGlue.h:86
ThePEG::RandomEngineGlue::Proxy
Definition: RandomEngineGlue.h:33
ThePEG::RandomEngineGlue::Proxy::setRandomEngine
void setRandomEngine(CLHEP::HepRandomEngine *v)
Definition: RandomEngineGlue.h:38
ThePEG::ClassTraits< RandomEngineGlue >::library
static string library()
Definition: RandomEngineGlue.h:87
ThePEG::RandomEngineGlue::clone
IBPtr clone() const override
Definition: RandomEngineGlue.h:63
findQualityFiles.v
v
Definition: findQualityFiles.py:179
ThePEG::RandomEngineGlue::initRandomEngineGlue
static ClassDescription< RandomEngineGlue > initRandomEngineGlue
Definition: RandomEngineGlue.h:72
ThePEG::RandomEngineGlue::flush
void flush()
Definition: RandomEngineGlue.cc:22
fileCollector.seed
seed
Definition: fileCollector.py:127
ThePEG::RandomEngineGlue::setRandomEngine
void setRandomEngine(CLHEP::HepRandomEngine *v)
Definition: RandomEngineGlue.h:27
ThePEG::RandomEngineGlue::getRandomEngine
CLHEP::HepRandomEngine * getRandomEngine() const
Definition: RandomEngineGlue.h:28
ThePEG::Proxy
Definition: Proxy.h:12
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::Proxy::getInstance
RandomEngineGlue * getInstance() const
Definition: RandomEngineGlue.h:35
ThePEG::RandomEngineGlue::fill
void fill() override
Definition: RandomEngineGlue.cc:27
CLHEP
Definition: CocoaGlobals.h:27
ThePEG::ProxyBase::id
const ProxyID id
Definition: Proxy.h:37
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
Proxy.h
svgfig.template
def template(fileName, svg, replaceme="REPLACEME")
Definition: svgfig.py:521
ThePEG::RandomEngineGlue
Definition: RandomEngineGlue.h:22
ThePEG::RandomEngineGlue::Proxy::randomEngine
CLHEP::HepRandomEngine * randomEngine
Definition: RandomEngineGlue.h:56
ThePEG::RandomEngineGlue::Proxy::instance
RandomEngineGlue * instance
Definition: RandomEngineGlue.h:46
ThePEG::RandomEngineGlue::Proxy::Proxy
Proxy(ProxyID id)
Definition: RandomEngineGlue.h:44
ThePEG::RandomEngineGlue::fullclone
IBPtr fullclone() const override
Definition: RandomEngineGlue.h:64
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
ThePEG::BaseClassTrait< RandomEngineGlue, 1 >::NthBase
RandomGenerator NthBase
Definition: RandomEngineGlue.h:78