CMS 3D CMS Logo

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)())
31  { InstanceWrapper wrapper(this); return timeout(secs, fn); }
32 
33  // method to open External Particle Spectra Files
34  void openParticleSpecFile(const std::string fileName);
35 
36  void setHerwigRandomEngine(CLHEP::HepRandomEngine* v) { randomEngine = v; }
37 
38  protected:
39  // intercept HERWIG warnings and errors (default: no)
40  virtual bool hwwarn(const std::string &fn, int code);
41 
42  private:
43  // list all the Fortran callbacks here
44  friend double gen::hwrgen_(int*);
45  friend void gen::cms_hwwarn_(char fn[6], int*, int*);
46 
47  // call with timeout
48  bool timeout(unsigned int secs, void (*fn)());
49 
50  // used from timeout
51  static void _timeout_sighandler(int signr);
52 
53  // the random engine
54  // in order to make sure no one else uses this engine
55  // the access is only possible if pyr_ is called after
56  // the current instance has been selected using enter()
57  // if Herwig is called without an active instance and does
58  // either a callback or requests a random number an
59  // an exception will be thrown
60  CLHEP::HepRandomEngine *randomEngine;
61 
62  // for timeout facility
63  std::unique_ptr<TimeoutHolder> timeoutPrivate;
64 };
65 
66 } // namespace gen
67 
68 #endif // gen_Herwig6Instance_h
CLHEP::HepRandomEngine * randomEngine
Definition: Dummies.cc:7
int timeout
Definition: mps_check.py:53
bool callWithTimeout(unsigned int secs, void(*fn)())
void cms_hwwarn_(char fn[6], int *, int *)
CLHEP::HepRandomEngine * randomEngine
void setHerwigRandomEngine(CLHEP::HepRandomEngine *v)
double hwrgen_(int *)
std::unique_ptr< TimeoutHolder > timeoutPrivate
double hwrgen_(int *idummy)
Definition: Dummies.cc:17
static HepMC::HEPEVT_Wrapper wrapper