00001 // $Header: /cvs/lcd/slic/src/EventAction.cc,v 1.27 2007/04/27 01:54:34 jeremy Exp $ 00002 00003 #include "EventAction.hh" 00004 00005 // lcdd 00006 #include "StringUtil.hh" 00007 00008 // slic 00009 #include "LcioManager.hh" 00010 #include "TrajectoryManager.hh" 00011 #include "EventSourceManager.hh" 00012 #include "SlicApplication.hh" 00013 #include "EventMessenger.hh" 00014 #include "EventDebugger.hh" 00015 00016 // G4 00017 #include "G4RunManager.hh" 00018 #include "G4SDManager.hh" 00019 #include "G4Event.hh" 00020 00021 namespace slic 00022 { 00023 00024 EventAction::EventAction() 00025 : G4UserEventAction(), 00026 Module("EventAction", false), 00027 m_enableEventTimer(false) 00028 { 00029 m_messenger = new EventMessenger(); 00030 } 00031 00032 EventAction::~EventAction() 00033 {} 00034 00035 void EventAction::BeginOfEventAction (const G4Event *anEvent) 00036 { 00037 // check aborted 00038 if (!anEvent->IsAborted() ) { 00039 00040 // debugger 00041 EventDebugger::instance()->beginEvent( anEvent ); 00042 00043 // trj mgr 00044 TrajectoryManager::instance()->beginEvent( anEvent ); 00045 00046 /* MCP begin event */ 00047 LcioMcpManager::instance()->beginEvent(anEvent); 00048 } 00049 #ifdef SLIC_LOG 00050 else { 00051 log().warning("aborted EventAction::BeginOfEventAction"); 00052 } 00053 #endif 00054 } 00055 00056 void EventAction::EndOfEventAction (const G4Event *anEvent) 00057 { 00058 // check aborted 00059 if (!SlicApplication::instance()->isAborting() ) { 00060 00061 // LcioManager's action 00062 LcioManager::instance()->endEvent( anEvent ); 00063 } 00064 00065 // event source (generator) action 00066 EventSourceManager::instance()->endEvent( anEvent ); 00067 00068 // event timer 00069 stopEventTimer(); 00070 00071 // debugger 00072 EventDebugger::instance()->endEvent( anEvent ); 00073 00074 #ifdef SLIC_LOG 00075 // end event mesg 00076 printEndEventMessage( anEvent ); 00077 #endif 00078 } 00079 00080 void EventAction::printEndEventMessage(const G4Event *anEvent) 00081 { 00082 log() << LOG::okay << ">>>> EndEvent <" + StringUtil::toString( anEvent->GetEventID() ) + ">" << LOG::endl << LOG::done; 00083 } 00084 00085 EventAction* EventAction::getEventAction() 00086 { 00087 const EventAction* ea = static_cast<const EventAction*> ( G4RunManager::GetRunManager()->GetUserEventAction() ); 00088 return const_cast<EventAction*> ( ea ); 00089 } 00090 00091 void EventAction::stopEventTimer() 00092 { 00093 if ( m_enableEventTimer ) { 00094 m_eventTimer.Stop(); 00095 #ifdef SLIC_LOG 00096 log() << LOG::okay << "Event Timer: " << m_eventTimer << LOG::done; 00097 #endif 00098 } 00099 } 00100 00101 void EventAction::startEventTimer() 00102 { 00103 if ( m_enableEventTimer ) { 00104 m_eventTimer.Start(); 00105 #ifdef SLIC_LOG 00106 log() << LOG::verbose << "Started Event Timer." << LOG::done; 00107 #endif 00108 } 00109 } 00110 00111 void EventAction::enableEventTimer(bool et) 00112 { 00113 m_enableEventTimer = et; 00114 } 00115 }
1.5.4