CMS 3D CMS Logo

EventAction.cc
Go to the documentation of this file.
8 
10 
11 #include "Randomize.hh"
12 
15  SimTrackManager* iManager,
17  : m_runInterface(rm),
18  m_trackManager(iManager),
19  m_SteppingVerbose(sv),
20  m_stopFile(p.getParameter<std::string>("StopFile")),
21  m_printRandom(p.getParameter<bool>("PrintRandomSeed")),
22  m_debug(p.getUntrackedParameter<bool>("debug", false)) {}
23 
24 void EventAction::BeginOfEventAction(const G4Event* anEvent) {
25  BeginOfEvent e(anEvent);
27 
28  if (m_printRandom) {
29  edm::LogVerbatim("SimG4CoreApplication")
30  << "BeginOfEvent " << anEvent->GetEventID() << " Random number: " << G4UniformRand();
31  }
32 
33  if (nullptr != m_SteppingVerbose) {
35  }
36 }
37 
38 void EventAction::EndOfEventAction(const G4Event* anEvent) {
39  if (m_printRandom) {
40  edm::LogVerbatim("SimG4CoreApplication")
41  << "EventACtion::EndOfEventAction: " << anEvent->GetEventID() << " Random number: " << G4UniformRand();
42  }
43  if (!m_stopFile.empty() && std::ifstream(m_stopFile.c_str())) {
44  edm::LogWarning("SimG4CoreApplication")
45  << "EventACtion::EndOfEventAction: termination signal received at event " << anEvent->GetEventID();
46  // soft abort run
47  m_runInterface->abortRun(true);
48  }
49  if (anEvent->GetNumberOfPrimaryVertex() == 0) {
50  edm::LogWarning("SimG4CoreApplication") << "EventACtion::EndOfEventAction: event " << anEvent->GetEventID()
51  << " must have failed (no G4PrimaryVertices found) and will be skipped";
52  return;
53  }
54 
56 
57  // dispatch now end of event
58  EndOfEvent e(anEvent);
60 
61  // delete transient objects
63 }
64 
Log< level::Info, true > LogVerbatim
std::string m_stopFile
Definition: EventAction.h:43
def rm(path, rec=False)
Definition: eostools.py:363
void beginOfEvent(const G4Event *)
SimRunInterface * m_runInterface
Definition: EventAction.h:40
SimActivityRegistry::EndOfEventSignal m_endOfEventSignal
Definition: EventAction.h:37
bool m_printRandom
Definition: EventAction.h:44
void BeginOfEventAction(const G4Event *evt) override
Definition: EventAction.cc:24
void abortRun(bool softAbort)
CMSSteppingVerbose * m_SteppingVerbose
Definition: EventAction.h:42
void EndOfEventAction(const G4Event *evt) override
Definition: EventAction.cc:38
SimTrackManager * m_trackManager
Definition: EventAction.h:41
EventAction(const edm::ParameterSet &ps, SimRunInterface *, SimTrackManager *, CMSSteppingVerbose *)
Definition: EventAction.cc:13
void abortEvent()
Definition: EventAction.cc:65
Log< level::Warning, false > LogWarning
SimActivityRegistry::BeginOfEventSignal m_beginOfEventSignal
Definition: EventAction.h:36