File indexing completed on 2024-04-06 12:13:43
0001 #ifndef GeneratorInterface_Herwig7Interface_RandomEngineGlue_h
0002 #define GeneratorInterface_Herwig7Interface_RandomEngineGlue_h
0003
0004 #include <string>
0005
0006 #include <ThePEG/Interface/ClassDocumentation.h>
0007 #include <ThePEG/Interface/InterfacedBase.h>
0008 #include <ThePEG/Interface/Parameter.h>
0009 #include <ThePEG/Utilities/ClassTraits.h>
0010
0011 #include <ThePEG/Repository/StandardRandom.h>
0012
0013 #include "GeneratorInterface/Herwig7Interface/interface/Proxy.h"
0014 #include "CLHEP/Random/RandomEngine.h"
0015
0016 namespace CLHEP {
0017 class HepRandomEngine;
0018 }
0019
0020 namespace ThePEG {
0021
0022 class RandomEngineGlue : public RandomGenerator {
0023 public:
0024 RandomEngineGlue();
0025 ~RandomEngineGlue() override;
0026
0027 void setRandomEngine(CLHEP::HepRandomEngine* v) { randomEngine = v; }
0028 CLHEP::HepRandomEngine* getRandomEngine() const { return randomEngine; }
0029 void flush();
0030
0031 static void Init();
0032
0033 class Proxy : public ThePEG::Proxy<Proxy> {
0034 public:
0035 RandomEngineGlue* getInstance() const { return instance; }
0036
0037 CLHEP::HepRandomEngine* getRandomEngine() const { return randomEngine; }
0038 void setRandomEngine(CLHEP::HepRandomEngine* v) { randomEngine = v; }
0039
0040 private:
0041 friend class RandomEngineGlue;
0042 friend class ThePEG::Proxy<Proxy>;
0043
0044 inline Proxy(ProxyID id) : Base(id), instance(nullptr) {}
0045
0046 RandomEngineGlue* instance;
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056 CLHEP::HepRandomEngine* randomEngine;
0057 };
0058
0059 protected:
0060 void fill() override;
0061 void setSeed(long seed) override;
0062
0063 IBPtr clone() const override { return new_ptr(*this); }
0064 IBPtr fullclone() const override { return new_ptr(*this); }
0065
0066 void doinit() noexcept(false) override;
0067
0068 private:
0069 Proxy::ProxyID proxyID;
0070 CLHEP::HepRandomEngine* randomEngine;
0071
0072 static ClassDescription<RandomEngineGlue> initRandomEngineGlue;
0073 };
0074
0075 template <>
0076 struct BaseClassTrait<RandomEngineGlue, 1> : public ClassTraitsType {
0077
0078 typedef RandomGenerator NthBase;
0079 };
0080
0081
0082
0083 template <>
0084 struct ClassTraits<RandomEngineGlue> : public ClassTraitsBase<RandomEngineGlue> {
0085
0086 static string className() { return "ThePEG::RandomEngineGlue"; }
0087 static string library() { return "libGeneratorInterfaceHerwig7Interface.so"; }
0088 };
0089
0090 }
0091
0092 #endif