00001 #ifndef SimG4Core_RunManager_H 00002 #define SimG4Core_RunManager_H 00003 00004 #include <memory> 00005 #include "FWCore/Framework/interface/Event.h" 00006 // #include "DataFormats/Common/interface/Handle.h" 00007 #include "DataFormats/Common/interface/Handle.h" 00008 #include "FWCore/Framework/interface/EventSetup.h" 00009 #include "FWCore/ParameterSet/interface/ParameterSet.h" 00010 #include "FWCore/Utilities/interface/InputTag.h" 00011 00012 #include "SimG4Core/SensitiveDetector/interface/AttachSD.h" 00013 #include "SimG4Core/SensitiveDetector/interface/SensitiveDetector.h" 00014 #include "SimG4Core/SensitiveDetector/interface/SensitiveTkDetector.h" 00015 #include "SimG4Core/SensitiveDetector/interface/SensitiveCaloDetector.h" 00016 00017 #include "SimG4Core/Notification/interface/SimActivityRegistry.h" 00018 00019 #include <memory> 00020 #include "boost/shared_ptr.hpp" 00021 00022 #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h" 00023 #include "Geometry/Records/interface/IdealGeometryRecord.h" 00024 00025 #include "FWCore/Framework/interface/ESWatcher.h" 00026 00027 namespace CLHEP { 00028 class HepJamesRandom; 00029 } 00030 00031 namespace sim { 00032 class FieldBuilder; 00033 } 00034 00035 class PrimaryTransformer; 00036 class Generator; 00037 class PhysicsList; 00038 00039 class SimWatcher; 00040 class SimProducer; 00041 class G4SimEvent; 00042 class SimTrackManager; 00043 00044 class DDDWorld; 00045 00046 class G4RunManagerKernel; 00047 class G4Run; 00048 class G4Event; 00049 class G4UserRunAction; 00050 00051 class ExceptionHandler ; 00052 00053 class RunManager 00054 { 00055 public: 00056 RunManager(edm::ParameterSet const & p); 00057 //static RunManager * instance(); 00058 //static RunManager * init(edm::ParameterSet const & p); 00059 virtual ~RunManager(); 00060 void initG4(const edm::EventSetup & es); 00061 void initializeUserActions(); 00062 void initializeRun(); 00063 void terminateRun(); 00064 void abortRun(bool softAbort=false); 00065 const G4Run * currentRun() const { return m_currentRun; } 00066 void produce(edm::Event& inpevt, const edm::EventSetup& es); 00067 void abortEvent(); 00068 const Generator * generator() const { return m_generator; } 00069 const G4Event * currentEvent() const { return m_currentEvent; } 00070 G4SimEvent * simEvent() { return m_simEvent; } 00071 std::vector<SensitiveTkDetector*>& sensTkDetectors() { return m_sensTkDets; } 00072 std::vector<SensitiveCaloDetector*>& sensCaloDetectors() { return m_sensCaloDets; } 00073 00074 std::vector<boost::shared_ptr<SimProducer> > producers() const { 00075 return m_producers; 00076 } 00077 protected: 00078 G4Event * generateEvent( edm::Event& inpevt ); 00079 00080 void resetGenParticleId( edm::Event& inpevt ); 00081 private: 00082 00083 // static RunManager * me; 00084 // explicit RunManager(edm::ParameterSet const & p); 00085 00086 G4RunManagerKernel * m_kernel; 00087 00088 Generator * m_generator; 00089 // edm::InputTag m_InTag ; 00090 std::string m_InTag ; 00091 00092 bool m_nonBeam; 00093 std::auto_ptr<PhysicsList> m_physicsList; 00094 PrimaryTransformer * m_primaryTransformer; 00095 bool m_managerInitialized; 00096 // bool m_geometryInitialized; 00097 // bool m_physicsInitialized; 00098 bool m_runInitialized; 00099 bool m_runTerminated; 00100 bool m_runAborted; 00101 bool firstRun; 00102 bool m_pUseMagneticField; 00103 G4Run * m_currentRun; 00104 G4Event * m_currentEvent; 00105 G4SimEvent * m_simEvent; 00106 G4UserRunAction * m_userRunAction; 00107 std::string m_PhysicsTablesDir; 00108 bool m_StorePhysicsTables; 00109 bool m_RestorePhysicsTables; 00110 int m_EvtMgrVerbosity; 00111 bool m_Override; 00112 bool m_check; 00113 edm::ParameterSet m_pGeometry; 00114 edm::ParameterSet m_pField; 00115 edm::ParameterSet m_pGenerator; 00116 edm::ParameterSet m_pVertexGenerator; 00117 edm::ParameterSet m_pPhysics; 00118 edm::ParameterSet m_pRunAction; 00119 edm::ParameterSet m_pEventAction; 00120 edm::ParameterSet m_pStackingAction; 00121 edm::ParameterSet m_pTrackingAction; 00122 edm::ParameterSet m_pSteppingAction; 00123 std::vector<std::string> m_G4Commands; 00124 edm::ParameterSet m_p; 00125 ExceptionHandler* m_CustomExceptionHandler ; 00126 00127 AttachSD * m_attach; 00128 std::vector<SensitiveTkDetector*> m_sensTkDets; 00129 std::vector<SensitiveCaloDetector*> m_sensCaloDets; 00130 00131 SimActivityRegistry m_registry; 00132 std::vector<boost::shared_ptr<SimWatcher> > m_watchers; 00133 std::vector<boost::shared_ptr<SimProducer> > m_producers; 00134 00135 std::auto_ptr<SimTrackManager> m_trackManager; 00136 sim::FieldBuilder *m_fieldBuilder; 00137 00138 edm::ESWatcher<IdealGeometryRecord> idealGeomRcdWatcher_; 00139 edm::ESWatcher<IdealMagneticFieldRecord> idealMagRcdWatcher_; 00140 00141 edm::InputTag m_theLHCTlinkTag; 00142 00143 std::string m_WriteFile; 00144 }; 00145 00146 #endif