CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_1/src/GeneratorInterface/Herwig6Interface/interface/Herwig6Instance.h

Go to the documentation of this file.
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         // method to open External Particle Spectra Files
00029         void openParticleSpecFile(const std::string fileName);
00030 
00031     protected:
00032         // intercept HERWIG warnings and errors (default: no)
00033         virtual bool hwwarn(const std::string &fn, int code);
00034 
00035     private:
00036         // list all the Fortran callbacks here
00037         friend double gen::hwrgen_(int*);
00038         friend void gen::cms_hwwarn_(char fn[6], int*, int*);
00039 
00040         // call with timeout
00041         bool timeout(unsigned int secs, void (*fn)());
00042 
00043         // used from timeout
00044         static void _timeout_sighandler(int signr);
00045 
00046         // the random engine
00047         // in order to make sure no one else uses this engine
00048         // the access is only possible if pyr_ is called after
00049         // the current instance has been selected using enter()
00050         // if Herwig is called without an active instance and does
00051         // either a callback or requests a random number an
00052         // an exception will be thrown
00053         CLHEP::HepRandomEngine  *randomEngine;
00054 
00055         // for timeout facility
00056         void                    *timeoutPrivate;
00057 };
00058 
00059 } // namespace gen
00060 
00061 #endif // gen_Herwig6Instance_h