Go to the documentation of this file.00001 #include "SimG4Core/Application/interface/RunManager.h"
00002 #include "SimG4Core/Application/interface/EventAction.h"
00003 #include "SimG4Core/Application/interface/G4SimVertex.h"
00004 #include "SimG4Core/Application/interface/G4SimTrack.h"
00005 #include "SimG4Core/Notification/interface/BeginOfEvent.h"
00006 #include "SimG4Core/Notification/interface/EndOfEvent.h"
00007
00008 #include <fstream>
00009
00010 using std::cout;
00011 using std::endl;
00012
00013 EventAction::EventAction(const edm::ParameterSet & p,
00014 RunManager* rm,
00015 SimTrackManager* iManager)
00016 : m_runManager(rm),
00017 m_trackManager(iManager),
00018 m_stopFile(p.getParameter<std::string>("StopFile")),
00019 m_debug(p.getUntrackedParameter<bool>("debug",false))
00020 {
00021 m_trackManager->setCollapsePrimaryVertices(p.getParameter<bool>("CollapsePrimaryVertices"));
00022 }
00023
00024 EventAction::~EventAction() {}
00025
00026 void EventAction::BeginOfEventAction(const G4Event * anEvent)
00027 {
00028 if (std::ifstream(m_stopFile.c_str()))
00029 {
00030 cout << "BeginOfEventAction: termination signal received at event "
00031 << anEvent->GetEventID() << endl;
00032
00033 m_runManager->abortRun(true);
00034 }
00035
00036 m_trackManager->reset();
00037 BeginOfEvent e(anEvent);
00038 m_beginOfEventSignal(&e);
00039
00040 }
00041
00042 void EventAction::EndOfEventAction(const G4Event * anEvent)
00043 {
00044 if (std::ifstream(m_stopFile.c_str()))
00045 {
00046 cout << "EndOfEventAction: termination signal received at event "
00047 << anEvent->GetEventID() << endl;
00048
00049 m_runManager->abortRun(true);
00050 }
00051 if (anEvent->GetNumberOfPrimaryVertex()==0)
00052 {
00053 cout << " EndOfEventAction: event " << anEvent->GetEventID()
00054 << " must have failed (no G4PrimaryVertices found) and will be skipped "
00055 << endl;
00056 return;
00057 }
00058
00059
00060 m_trackManager->storeTracks(m_runManager->simEvent());
00061
00062 EndOfEvent e(anEvent);
00063 m_endOfEventSignal(&e);
00064
00065 m_trackManager->deleteTracks();
00066 m_trackManager->cleanTkCaloStateInfoMap();
00067
00068 }
00069
00070 void EventAction::addTrack(TrackWithHistory* iTrack, bool inHistory, bool withAncestor)
00071 {
00072 m_trackManager->addTrack(iTrack, inHistory, withAncestor);
00073 }
00074
00075 void EventAction::addTkCaloStateInfo(uint32_t t,const std::pair< math::XYZVectorD,
00076 math::XYZTLorentzVectorD>& p)
00077 {
00078 m_trackManager->addTkCaloStateInfo(t,p);
00079 }
00080
00081 void EventAction::abortEvent()
00082 {
00083 m_runManager->abortEvent();
00084 }