CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_1/src/SimG4Core/Application/interface/RunManager.h

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