CMS 3D CMS Logo

EventAction.cc
Go to the documentation of this file.
8 
10 
11 #include <fstream>
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  m_trackManager->setCollapsePrimaryVertices(p.getParameter<bool>("CollapsePrimaryVertices"));
26 }
27 
29 
30 void EventAction::BeginOfEventAction(const G4Event * anEvent)
31 {
33 
34  BeginOfEvent e(anEvent);
36 
37  if(m_printRandom)
38  {
39  edm::LogVerbatim("SimG4CoreApplication")
40  << "BeginOfEvent " << anEvent->GetEventID()
41  << " Random number: " << G4UniformRand();
42  }
43 
44  if(nullptr != m_SteppingVerbose) { m_SteppingVerbose->BeginOfEvent(anEvent); }
45 }
46 
47 void EventAction::EndOfEventAction(const G4Event * anEvent)
48 {
49  if(m_printRandom)
50  {
51  edm::LogVerbatim("SimG4CoreApplication")
52  << " EndOfEvent " << anEvent->GetEventID()
53  << " Random number: " << G4UniformRand();
54  }
55  if (!m_stopFile.empty() && std::ifstream(m_stopFile.c_str()))
56  {
57  edm::LogWarning("SimG4CoreApplication")
58  << "EndOfEventAction: termination signal received at event "
59  << anEvent->GetEventID();
60  // soft abort run
61  m_runInterface->abortRun(true);
62  }
63  if (anEvent->GetNumberOfPrimaryVertex()==0)
64  {
65  edm::LogWarning("SimG4CoreApplication")
66  << "EndOfEventAction: event " << anEvent->GetEventID()
67  << " must have failed (no G4PrimaryVertices found) and will be skipped ";
68  return;
69  }
70 
72 
73  // dispatch now end of event, and only then delete tracks...
74  EndOfEvent e(anEvent);
76 
79 }
80 
82  const std::pair<math::XYZVectorD,math::XYZTLorentzVectorD>& p)
83 {
85 }
86 
88 {
90 }
T getParameter(std::string const &) const
std::string m_stopFile
Definition: EventAction.h:58
SimRunInterface * m_runInterface
Definition: EventAction.h:55
SimActivityRegistry::EndOfEventSignal m_endOfEventSignal
Definition: EventAction.h:51
bool m_printRandom
Definition: EventAction.h:59
G4SimEvent * simEvent()
void cleanTkCaloStateInfoMap()
void BeginOfEventAction(const G4Event *evt) override
Definition: EventAction.cc:30
void addTkCaloStateInfo(uint32_t t, const std::pair< math::XYZVectorD, math::XYZTLorentzVectorD > &p)
void abortRun(bool softAbort)
CMSSteppingVerbose * m_SteppingVerbose
Definition: EventAction.h:57
void storeTracks(G4SimEvent *simEvent)
void BeginOfEvent(const G4Event *)
void EndOfEventAction(const G4Event *evt) override
Definition: EventAction.cc:47
SimTrackManager * m_trackManager
Definition: EventAction.h:56
EventAction(const edm::ParameterSet &ps, SimRunInterface *, SimTrackManager *, CMSSteppingVerbose *)
Definition: EventAction.cc:14
void addTkCaloStateInfo(uint32_t t, const std::pair< math::XYZVectorD, math::XYZTLorentzVectorD > &p)
Definition: EventAction.cc:81
void abortEvent()
Definition: EventAction.cc:87
rm
Definition: submit.py:77
void setCollapsePrimaryVertices(bool iSet)
SimActivityRegistry::BeginOfEventSignal m_beginOfEventSignal
Definition: EventAction.h:50
~EventAction() override
Definition: EventAction.cc:28