CMS 3D CMS Logo

EventAction.cc

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         //RunManager::instance()->abortRun(true);
00033         m_runManager->abortRun(true);
00034     }
00035 
00036     m_trackManager->reset();
00037     BeginOfEvent e(anEvent);
00038     m_beginOfEventSignal(&e);
00039 }
00040 
00041 void EventAction::EndOfEventAction(const G4Event * anEvent)
00042 {
00043     if (std::ifstream(m_stopFile.c_str()))
00044     {
00045         cout << "EndOfEventAction: termination signal received at event "
00046              << anEvent->GetEventID() << endl;
00047         //RunManager::instance()->abortRun(true);
00048         m_runManager->abortRun(this);
00049     }
00050     if (anEvent->GetNumberOfPrimaryVertex()==0)
00051     {
00052         cout << " EndOfEventAction: event " << anEvent->GetEventID()
00053              << " must have failed (no G4PrimaryVertices found) and will be skipped " << endl;
00054         return;
00055     }
00056 
00057     // m_trackManager->storeTracks(RunManager::instance()->simEvent());
00058     m_trackManager->storeTracks(m_runManager->simEvent());
00059     // dispatch now end of event, and only then delete tracks...
00060     EndOfEvent e(anEvent);
00061     m_endOfEventSignal(&e);
00062 
00063     m_trackManager->deleteTracks();
00064     m_trackManager->cleanTkCaloStateInfoMap();
00065 
00066 }
00067 
00068 void EventAction::addTrack(TrackWithHistory* iTrack, bool inHistory)
00069 {
00070   m_trackManager->addTrack(iTrack, inHistory);
00071 }
00072 
00073 void EventAction::addTkCaloStateInfo(uint32_t t,std::pair< math::XYZVectorD ,math::XYZTLorentzVectorD> p)
00074 {
00075   m_trackManager->addTkCaloStateInfo(t,p);
00076 }

Generated on Tue Jun 9 17:47:00 2009 for CMSSW by  doxygen 1.5.4