CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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) {
26 
27  BeginOfEvent e(anEvent);
29 
30  if (m_printRandom) {
31  edm::LogVerbatim("SimG4CoreApplication")
32  << "BeginOfEvent " << anEvent->GetEventID() << " Random number: " << G4UniformRand();
33  }
34 
35  if (nullptr != m_SteppingVerbose) {
37  }
38 }
39 
40 void EventAction::EndOfEventAction(const G4Event* anEvent) {
41  if (m_printRandom) {
42  edm::LogVerbatim("SimG4CoreApplication")
43  << " EndOfEvent " << anEvent->GetEventID() << " Random number: " << G4UniformRand();
44  }
45  if (!m_stopFile.empty() && std::ifstream(m_stopFile.c_str())) {
46  edm::LogWarning("SimG4CoreApplication")
47  << "EndOfEventAction: termination signal received at event " << anEvent->GetEventID();
48  // soft abort run
49  m_runInterface->abortRun(true);
50  }
51  if (anEvent->GetNumberOfPrimaryVertex() == 0) {
52  edm::LogWarning("SimG4CoreApplication") << "EndOfEventAction: event " << anEvent->GetEventID()
53  << " must have failed (no G4PrimaryVertices found) and will be skipped ";
54  return;
55  }
56 
58 
59  // dispatch now end of event
60  EndOfEvent e(anEvent);
62 
63  // delete transient objects
65 }
66 
Log< level::Info, true > LogVerbatim
std::string m_stopFile
Definition: EventAction.h:44
def rm(path, rec=False)
Definition: eostools.py:363
void beginOfEvent(const G4Event *)
SimRunInterface * m_runInterface
Definition: EventAction.h:41
SimActivityRegistry::EndOfEventSignal m_endOfEventSignal
Definition: EventAction.h:38
bool m_printRandom
Definition: EventAction.h:45
G4SimEvent * simEvent()
void BeginOfEventAction(const G4Event *evt) override
Definition: EventAction.cc:24
void abortRun(bool softAbort)
CMSSteppingVerbose * m_SteppingVerbose
Definition: EventAction.h:43
void storeTracks(G4SimEvent *simEvent)
void EndOfEventAction(const G4Event *evt) override
Definition: EventAction.cc:40
SimTrackManager * m_trackManager
Definition: EventAction.h:42
EventAction(const edm::ParameterSet &ps, SimRunInterface *, SimTrackManager *, CMSSteppingVerbose *)
Definition: EventAction.cc:13
void abortEvent()
Definition: EventAction.cc:67
Log< level::Warning, false > LogWarning
SimActivityRegistry::BeginOfEventSignal m_beginOfEventSignal
Definition: EventAction.h:37