40 #include "HepPDT/defs.h"
41 #include "HepPDT/TableBuilder.hh"
42 #include "HepPDT/ParticleDataTable.hh"
45 #include "G4StateManager.hh"
46 #include "G4ApplicationState.hh"
47 #include "G4RunManagerKernel.hh"
48 #include "G4UImanager.hh"
50 #include "G4EventManager.hh"
53 #include "G4TransportationManager.hh"
54 #include "G4ParticleTable.hh"
56 #include "G4GDMLParser.hh"
70 std::vector<boost::shared_ptr<SimWatcher> >& oWatchers,
71 std::vector<boost::shared_ptr<SimProducer> >& oProds
76 vector<ParameterSet> watchers;
78 watchers = iP.
getParameter<vector<ParameterSet> >(
"Watchers");
82 for(vector<ParameterSet>::iterator itWatcher = watchers.begin();
83 itWatcher != watchers.end();
85 std::auto_ptr<SimWatcherMakerBase>
maker(
92 boost::shared_ptr<SimWatcher> watcherTemp;
93 boost::shared_ptr<SimProducer> producerTemp;
94 maker->make(*itWatcher,iReg,watcherTemp,producerTemp);
95 oWatchers.push_back(watcherTemp);
97 oProds.push_back(producerTemp);
119 : m_generator(0), m_nonBeam(p.getParameter<bool>(
"NonBeamEvent")),
120 m_primaryTransformer(0),
121 m_managerInitialized(
false),
125 m_pUseMagneticField(p.getParameter<bool>(
"UseMagneticField")),
126 m_currentRun(0), m_currentEvent(0), m_simEvent(0),
127 m_PhysicsTablesDir(p.getParameter<std::
string>(
"PhysicsTablesDirectory")),
128 m_StorePhysicsTables(p.getParameter<bool>(
"StorePhysicsTables")),
129 m_RestorePhysicsTables(p.getParameter<bool>(
"RestorePhysicsTables")),
130 m_EvtMgrVerbosity(p.getUntrackedParameter<int>(
"G4EventManagerVerbosity",0)),
131 m_Override(p.getParameter<bool>(
"OverrideUserStackingAction")),
132 m_pField(p.getParameter<edm::
ParameterSet>(
"MagneticField")),
133 m_pGenerator(p.getParameter<edm::
ParameterSet>(
"Generator")),
134 m_pPhysics(p.getParameter<edm::
ParameterSet>(
"Physics")),
135 m_pRunAction(p.getParameter<edm::
ParameterSet>(
"RunAction")),
136 m_pEventAction(p.getParameter<edm::
ParameterSet>(
"EventAction")),
137 m_pStackingAction(p.getParameter<edm::
ParameterSet>(
"StackingAction")),
138 m_pTrackingAction(p.getParameter<edm::
ParameterSet>(
"TrackingAction")),
139 m_pSteppingAction(p.getParameter<edm::
ParameterSet>(
"SteppingAction")),
140 m_G4Commands(p.getParameter<std::vector<std::
string> >(
"G4Commands")),
141 m_p(p), m_fieldBuilder(0),
142 m_theLHCTlinkTag(p.getParameter<edm::
InputTag>(
"theLHCTlinkTag"))
144 m_kernel = G4RunManagerKernel::GetRunManagerKernel();
173 <<
"[SimG4Core RunManager]\n"
174 <<
"The Geometry configuration is changed during the job execution\n"
175 <<
"this is not allowed, the geometry must stay unchanged\n";
181 <<
"[SimG4Core RunManager]\n"
182 <<
"The MagneticField configuration is changed during the job execution\n"
183 <<
"this is not allowed, the MagneticField must stay unchanged\n";
212 G4TransportationManager * tM =
213 G4TransportationManager::GetTransportationManager();
223 std::pair< std::vector<SensitiveTkDetector*>,
231 edm::LogInfo(
"SimG4CoreApplication") <<
" RunManager: Sensitive Detector building finished; found " <<
m_sensTkDets.size()
232 <<
" Tk type Producers, and " <<
m_sensCaloDets.size() <<
" Calo type producers ";
243 std::auto_ptr<PhysicsListMakerBase> physicsMaker(
246 if (physicsMaker.get()==0)
throw SimG4Exception(
"Unable to find the Physics list requested");
251 if (phys==0)
throw SimG4Exception(
"Physics list construction failed!");
265 else throw SimG4Exception(
"G4RunManagerKernel initialization failed!");
269 std::ostringstream
dir;
270 dir << tableDir <<
'\0';
273 G4UImanager::GetUIpointer()->ApplyCommand(cmd);
284 edm::LogInfo(
"SimG4CoreApplication") <<
"RunManager:: Requests UI: "
286 G4UImanager::GetUIpointer()->ApplyCommand(
m_G4Commands[it]);
315 <<
" RunManager::produce event " << inpevt.
id().
event()
316 <<
" with no G4PrimaryVertices \n Aborting Run" ;
338 G4Event *
e =
new G4Event(inpevt.
id().
event());
349 if (!HepMCEvt.isValid())
351 throw SimG4Exception(
"Unable to find HepMCProduct(HepMC::GenEvent) in edm::Event ");
379 m_kernel->GetEventManager()->GetTrackingManager()->GetTrack();
380 t->SetTrackStatus(fStopAndKill) ;
401 m_kernel->GetEventManager()->GetStackManager()->clear() ;
402 m_kernel->GetEventManager()->GetTrackingManager()->EventAborted() ;
404 G4StateManager* stateManager = G4StateManager::GetStateManager();
405 stateManager->SetNewState(G4State_GeomClosed);
419 G4EventManager * eventManager =
m_kernel->GetEventManager();
427 eventManager->SetUserAction(userEventAction);
431 eventManager->SetUserAction(userTrackingAction);
435 eventManager->SetUserAction(userSteppingAction);
438 edm::LogInfo(
"SimG4CoreApplication") <<
" RunManager: user StackingAction overridden " ;
444 edm::LogWarning(
"SimG4CoreApplication") <<
" RunManager: WARNING : No generator; initialized only RunAction!";
457 G4StateManager::GetStateManager()->SetNewState(G4State_GeomClosed);
T getParameter(std::string const &) const
EventNumber_t event() const
edm::ParameterSet m_pGenerator
T getUntrackedParameter(std::string const &, T const &) const
std::auto_ptr< SimTrackManager > m_trackManager
std::pair< std::vector< SensitiveTkDetector * >, std::vector< SensitiveCaloDetector * > > create(const DDDWorld &w, const DDCompactView &cpv, SensitiveDetectorCatalog &clg, edm::ParameterSet const &p, const SimTrackManager *m, SimActivityRegistry ®) const
virtual const math::XYZTLorentzVector * genVertex() const
edm::ESWatcher< IdealMagneticFieldRecord > idealMagRcdWatcher_
const G4VPhysicalVolume * GetWorldVolume() const
G4UserRunAction * m_userRunAction
virtual const double eventWeight() const
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< double > > XYZTLorentzVectorD
Lorentz vector with cylindrical internal representation using pseudorapidity.
void abortRun(bool softAbort=false)
G4StepSignal g4StepSignal_
SimActivityRegistry m_registry
virtual const HepMC::GenEvent * genEvent() const
SimActivityRegistry::G4StepSignal m_g4StepSignal
HepPDT::ParticleDataTable ParticleDataTable
void HepMC2G4(const HepMC::GenEvent *g, G4Event *e)
EndOfEventSignal endOfEventSignal_
void initializeUserActions()
SimActivityRegistry::EndOfRunSignal m_endOfRunSignal
void build(G4FieldManager *fM=0, G4PropagatorInField *fP=0)
BeginOfRunSignal beginOfRunSignal_
SimActivityRegistry::EndOfEventSignal m_endOfEventSignal
edm::ESWatcher< IdealGeometryRecord > idealGeomRcdWatcher_
ExceptionHandler * m_CustomExceptionHandler
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
std::vector< SensitiveCaloDetector * > m_sensCaloDets
std::vector< SensitiveTkDetector * > m_sensTkDets
BeginOfJobSignal beginOfJobSignal_
U second(std::pair< T, U > const &p)
std::auto_ptr< PhysicsList > m_physicsList
edm::serviceregistry::AllArgsMaker< DTDataMonitorInterface, DTDataIntegrityTask > maker
bool m_RestorePhysicsTables
void hepEvent(const HepMC::GenEvent *r)
void setGenEvent(const HepMC::GenEvent *inpevt)
BeginOfEventSignal beginOfEventSignal_
SimActivityRegistry::EndOfTrackSignal m_endOfTrackSignal
void resetGenParticleId(edm::Event &inpevt)
EndOfRunSignal endOfRunSignal_
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
edm::ParameterSet m_pStackingAction
unsigned int nTracks() const
void connect(Observer< const T * > *iObs)
does not take ownership of memory
edm::ParameterSet m_pEventAction
unsigned int nVertices() const
edm::ParameterSet m_pField
edm::ParameterSet m_pPhysics
edm::ParameterSet m_pSteppingAction
virtual void PostUserTrackingAction(const G4Track *aTrack)
unsigned int nGenParts() const
DDDWorldSignal dddWorldSignal_
T const * product() const
void nonBeamEvent2G4(const HepMC::GenEvent *g, G4Event *e)
bool check(const edm::EventSetup &iSetup)
G4Event * generateEvent(edm::Event &inpevt)
SimActivityRegistry::BeginOfRunSignal m_beginOfRunSignal
static void createWatchers(const edm::ParameterSet &iP, SimActivityRegistry &iReg, std::vector< boost::shared_ptr< SimWatcher > > &oWatchers, std::vector< boost::shared_ptr< SimProducer > > &oProds)
PrimaryTransformer * m_primaryTransformer
sim::FieldBuilder * m_fieldBuilder
std::string m_PhysicsTablesDir
bool m_StorePhysicsTables
void connect(SimActivityRegistry &iOther)
forwards our signals to slots connected to iOther
EndOfTrackSignal endOfTrackSignal_
std::vector< boost::shared_ptr< SimProducer > > m_producers
std::vector< boost::shared_ptr< SimWatcher > > m_watchers
edm::ParameterSet m_pRunAction
RunManager(edm::ParameterSet const &p)
edm::ParameterSet m_pTrackingAction
void collisionPoint(const math::XYZTLorentzVectorD &v)
std::vector< std::string > m_G4Commands
SimActivityRegistry::BeginOfEventSignal m_beginOfEventSignal
bool m_managerInitialized
void initG4(const edm::EventSetup &es)
T get(const Candidate &c)
edm::InputTag m_theLHCTlinkTag
BeginOfTrackSignal beginOfTrackSignal_
G4RunManagerKernel * m_kernel
void produce(edm::Event &inpevt, const edm::EventSetup &es)
SimActivityRegistry::BeginOfTrackSignal m_beginOfTrackSignal