CMS 3D CMS Logo

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