CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Herwig6Instance.h
Go to the documentation of this file.
1 #ifndef gen_Herwig6Instance_h
2 #define gen_Herwig6Instance_h
3 
5 #include <memory>
6 
7 namespace CLHEP {
8  class HepRandomEngine;
9 }
10 
11 namespace gen {
12 
13  // the callbacks from Herwig which are passed on to the Herwig6Instance
14  extern "C" {
15  double hwrgen_(int *);
16  void cms_hwwarn_(char fn[6], int *, int *);
17  }
18 
19  //Forward declare here to avoid system dependency
20  struct TimeoutHolder;
21 
23  public:
25  ~Herwig6Instance() override;
26 
27  // passes a configuration parameter
28  bool give(const std::string &line);
29 
30  bool callWithTimeout(unsigned int secs, void (*fn)()) {
32  return timeout(secs, fn);
33  }
34 
35  // method to open External Particle Spectra Files
37 
38  void setHerwigRandomEngine(CLHEP::HepRandomEngine *v) { randomEngine = v; }
39 
40  protected:
41  // intercept HERWIG warnings and errors (default: no)
42  virtual bool hwwarn(const std::string &fn, int code);
43 
44  private:
45  // list all the Fortran callbacks here
46  friend double gen::hwrgen_(int *);
47  friend void gen::cms_hwwarn_(char fn[6], int *, int *);
48 
49  // call with timeout
50  bool timeout(unsigned int secs, void (*fn)());
51 
52  // used from timeout
53  static void _timeout_sighandler(int signr);
54 
55  // the random engine
56  // in order to make sure no one else uses this engine
57  // the access is only possible if pyr_ is called after
58  // the current instance has been selected using enter()
59  // if Herwig is called without an active instance and does
60  // either a callback or requests a random number an
61  // an exception will be thrown
62  CLHEP::HepRandomEngine *randomEngine;
63 
64  // for timeout facility
65  std::unique_ptr<TimeoutHolder> timeoutPrivate;
66  };
67 
68 } // namespace gen
69 
70 #endif // gen_Herwig6Instance_h
bool timeout(unsigned int secs, void(*fn)())
static void _timeout_sighandler(int signr)
void openParticleSpecFile(const std::string fileName)
double v[5][pyjets_maxn]
bool callWithTimeout(unsigned int secs, void(*fn)())
bool give(const std::string &line)
void cms_hwwarn_(char fn[6], int *, int *)
virtual bool hwwarn(const std::string &fn, int code)
CLHEP::HepRandomEngine * randomEngine
void setHerwigRandomEngine(CLHEP::HepRandomEngine *v)
double hwrgen_(int *)
std::unique_ptr< TimeoutHolder > timeoutPrivate
static HepMC::HEPEVT_Wrapper wrapper