00001 #ifndef gen_Herwig6Instance_h 00002 #define gen_Herwig6Instance_h 00003 00004 #include "GeneratorInterface/Core/interface/FortranInstance.h" 00005 00006 namespace CLHEP { class HepRandomEngine; } // forward declaration 00007 00008 namespace gen { 00009 00010 // the callbacks from Herwig which are passed on to the Herwig6Instance 00011 extern "C" { 00012 double hwrgen_(int*); 00013 void cms_hwwarn_(char fn[6], int*, int*); 00014 } 00015 00016 class Herwig6Instance : public FortranInstance { 00017 public: 00018 Herwig6Instance(CLHEP::HepRandomEngine *randomEngine = 0); 00019 Herwig6Instance(int dummy); 00020 virtual ~Herwig6Instance(); 00021 00022 // passes a configuration parameter 00023 bool give(const std::string &line); 00024 00025 bool callWithTimeout(unsigned int secs, void (*fn)()) 00026 { InstanceWrapper wrapper(this); return timeout(secs, fn); } 00027 00028 protected: 00029 // intercept HERWIG warnings and errors (default: no) 00030 virtual bool hwwarn(const std::string &fn, int code); 00031 00032 private: 00033 // list all the Fortran callbacks here 00034 friend double gen::hwrgen_(int*); 00035 friend void gen::cms_hwwarn_(char fn[6], int*, int*); 00036 00037 // call with timeout 00038 bool timeout(unsigned int secs, void (*fn)()); 00039 00040 // used from timeout 00041 static void _timeout_sighandler(int signr); 00042 00043 // the random engine 00044 // in order to make sure no one else uses this engine 00045 // the access is only possible if pyr_ is called after 00046 // the current instance has been selected using enter() 00047 // if Herwig is called without an active instance and does 00048 // either a callback or requests a random number an 00049 // an exception will be thrown 00050 CLHEP::HepRandomEngine *randomEngine; 00051 00052 // for timeout facility 00053 void *timeoutPrivate; 00054 }; 00055 00056 } // namespace gen 00057 00058 #endif // gen_Herwig6Instance_h