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  m_trackManager->setCollapsePrimaryVertices(p.getParameter<bool>("CollapsePrimaryVertices"));
24 }
25 
26 void EventAction::BeginOfEventAction(const G4Event* anEvent) {
28 
29  BeginOfEvent e(anEvent);
31 
32  if (m_printRandom) {
33  edm::LogVerbatim("SimG4CoreApplication")
34  << "BeginOfEvent " << anEvent->GetEventID() << " Random number: " << G4UniformRand();
35  }
36 
37  if (nullptr != m_SteppingVerbose) {
39  }
40 }
41 
42 void EventAction::EndOfEventAction(const G4Event* anEvent) {
43  if (m_printRandom) {
44  edm::LogVerbatim("SimG4CoreApplication")
45  << " EndOfEvent " << anEvent->GetEventID() << " Random number: " << G4UniformRand();
46  }
47  if (!m_stopFile.empty() && std::ifstream(m_stopFile.c_str())) {
48  edm::LogWarning("SimG4CoreApplication")
49  << "EndOfEventAction: termination signal received at event " << anEvent->GetEventID();
50  // soft abort run
51  m_runInterface->abortRun(true);
52  }
53  if (anEvent->GetNumberOfPrimaryVertex() == 0) {
54  edm::LogWarning("SimG4CoreApplication") << "EndOfEventAction: event " << anEvent->GetEventID()
55  << " must have failed (no G4PrimaryVertices found) and will be skipped ";
56  return;
57  }
58 
60 
61  // dispatch now end of event
62  EndOfEvent e(anEvent);
64 
65  // delete transient objects
68 }
69 
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 cleanTkCaloStateInfoMap()
void BeginOfEventAction(const G4Event *evt) override
Definition: EventAction.cc:26
void abortRun(bool softAbort)
CMSSteppingVerbose * m_SteppingVerbose
Definition: EventAction.h:43
void storeTracks(G4SimEvent *simEvent)
void EndOfEventAction(const G4Event *evt) override
Definition: EventAction.cc:42
SimTrackManager * m_trackManager
Definition: EventAction.h:42
EventAction(const edm::ParameterSet &ps, SimRunInterface *, SimTrackManager *, CMSSteppingVerbose *)
Definition: EventAction.cc:13
void abortEvent()
Definition: EventAction.cc:70
Log< level::Warning, false > LogWarning
void setCollapsePrimaryVertices(bool iSet)
SimActivityRegistry::BeginOfEventSignal m_beginOfEventSignal
Definition: EventAction.h:37