CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Herwig6Instance.h
Go to the documentation of this file.
1 #ifndef gen_Herwig6Instance_h
2 #define gen_Herwig6Instance_h
3 
5 
6 namespace CLHEP { class HepRandomEngine; } // forward declaration
7 
8 namespace gen {
9 
10 // the callbacks from Herwig which are passed on to the Herwig6Instance
11 extern "C" {
12  double hwrgen_(int*);
13  void cms_hwwarn_(char fn[6], int*, int*);
14 }
15 
17  public:
18  Herwig6Instance(CLHEP::HepRandomEngine *randomEngine = 0);
19  Herwig6Instance(int dummy);
20  virtual ~Herwig6Instance();
21 
22  // passes a configuration parameter
23  bool give(const std::string &line);
24 
25  bool callWithTimeout(unsigned int secs, void (*fn)())
26  { InstanceWrapper wrapper(this); return timeout(secs, fn); }
27 
28  protected:
29  // intercept HERWIG warnings and errors (default: no)
30  virtual bool hwwarn(const std::string &fn, int code);
31 
32  private:
33  // list all the Fortran callbacks here
34  friend double gen::hwrgen_(int*);
35  friend void gen::cms_hwwarn_(char fn[6], int*, int*);
36 
37  // call with timeout
38  bool timeout(unsigned int secs, void (*fn)());
39 
40  // used from timeout
41  static void _timeout_sighandler(int signr);
42 
43  // the random engine
44  // in order to make sure no one else uses this engine
45  // the access is only possible if pyr_ is called after
46  // the current instance has been selected using enter()
47  // if Herwig is called without an active instance and does
48  // either a callback or requests a random number an
49  // an exception will be thrown
50  CLHEP::HepRandomEngine *randomEngine;
51 
52  // for timeout facility
54 };
55 
56 } // namespace gen
57 
58 #endif // gen_Herwig6Instance_h
Herwig6Instance(CLHEP::HepRandomEngine *randomEngine=0)
bool timeout(unsigned int secs, void(*fn)())
static void _timeout_sighandler(int signr)
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
double hwrgen_(int *)
static HepMC::HEPEVT_Wrapper wrapper