00001 #ifndef BESRNDMGENSVC_H 00002 #define BESRNDMGENSVC_H 00003 00004 #ifndef _CPP_MAP 00005 #include <map> 00006 #endif 00007 00008 //base classes 00009 #ifndef BESKERNEL_IBESRNDMGENSVC_H 00010 #include "BesKernel/IBesRndmGenSvc.h" 00011 #endif 00012 #ifndef GAUDIKERNEL_IINCIDENTLISTENER_H 00013 #include "GaudiKernel/IIncidentListener.h" 00014 #endif 00015 #ifndef GAUDIKERNEL_SERVICE_H 00016 #include "GaudiKernel/Service.h" 00017 #endif 00018 00019 #ifndef KERNEL_STATUSCODES_H 00020 #include "GaudiKernel/StatusCode.h" 00021 #endif 00022 00023 //#include "IBesRndmGenSvc.h" 00024 #include "CLHEP/Random/RanecuEngine.h" 00025 #include "CLHEP/Random/RanluxEngine.h" 00026 00027 class IAlgorithm; 00028 class ISvcLocator; 00029 class IIncident; 00030 00031 00032 template <class TYPE> class SvcFactory; 00033 00034 class BesRndmGenSvc : virtual public IBesRndmGenSvc, 00035 virtual public IIncidentListener, 00036 public Service 00037 { 00038 public: 00040 00041 CLHEP::HepRandomEngine* GetEngine ( const std::string& StreamName ); 00042 void CreateStream ( long seed, const std::string& StreamName ); 00044 00046 //typedef std::map<std::string, CLHEP::RanecuEngine*> engineMap; 00047 typedef std::map<std::string, CLHEP::RanluxEngine*> engineMap; 00048 typedef engineMap::iterator engineIter; 00049 typedef engineMap::const_iterator engineConstIter; 00050 typedef engineMap::value_type engineValType; 00051 00052 engineConstIter begin (void) const; 00053 engineConstIter end (void) const; 00054 unsigned int number_of_streams (void) const; 00055 00056 //caogf for random seed 00057 void setGenseed(long i) { genSeed = i; } 00058 long getGenseed() { return genSeed; } 00059 00061 void print ( const std::string& StreamName ); 00062 void print ( void ); 00063 00065 CLHEP::HepRandomEngine* setOnDefinedSeeds (int EventNumber, 00066 const std::string& StreamName); 00067 00069 00070 StatusCode initialize(); 00071 StatusCode finalize(); 00072 virtual StatusCode queryInterface( const InterfaceID& riid, void** ppvInterface ); 00074 00076 void handle(const Incident&); 00077 00078 00079 private: 00081 typedef std::vector< std::string > VStrings; 00082 VStrings m_streams_seeds; 00083 00085 std::map<std::string, std::vector<long int> > m_engines_copy; 00086 00087 bool m_read_from_file; 00088 std::string m_file_to_read; 00089 std::string ofile; 00090 long genSeed; //caogf for random seed 00091 engineMap* m_engines; 00092 00094 00095 long m_default_seed; 00096 long m_EVTGEN_default_seed; 00097 long m_PYTHIA_default_seed; 00098 long m_HERWIG_default_seed; 00099 long m_LUNDCRM_default_seed; 00100 long m_SIM_default_seed; 00101 long m_MIX_default_seed; 00102 long m_KKMC_default_seed; 00103 std::string m_StreamName; 00104 std::string Stream_EVTGEN; 00105 std::string Stream_PYTHIA; 00106 std::string Stream_HERWIG; 00107 std::string Stream_LUNDCRM; 00108 std::string Stream_SIM; 00109 std::string Stream_MIX; 00110 std::string Stream_KKMC; 00112 00113 void SetStreamSeeds ( const std::string& StreamName ); 00114 00115 protected: 00116 00117 friend class SvcFactory<BesRndmGenSvc>; 00118 00119 // Standard Constructor 00120 BesRndmGenSvc(const std::string& name, ISvcLocator* svc); 00121 00122 // Standard Destructor 00123 virtual ~BesRndmGenSvc(); 00124 00125 }; 00126 00127 inline BesRndmGenSvc::engineConstIter 00128 BesRndmGenSvc::begin (void) const 00129 { return m_engines->begin(); } 00130 00131 inline BesRndmGenSvc::engineConstIter 00132 BesRndmGenSvc::end (void) const 00133 { return m_engines->end(); } 00134 00135 inline unsigned int 00136 BesRndmGenSvc::number_of_streams (void) const 00137 { return m_engines->size(); } 00138 00139 #endif // BESRNDMGENSVC_H 00140 00141