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,
17  CMSSteppingVerbose* sv)
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(nullptr != m_SteppingVerbose) { m_SteppingVerbose->BeginOfEvent(anEvent); }
38 }
39 
40 void EventAction::EndOfEventAction(const G4Event * anEvent)
41 {
42  if(m_printRandom)
43  {
44  edm::LogInfo("SimG4CoreApplication") << " Event " << anEvent->GetEventID()
45  << " Random number: " << G4UniformRand();
46  //CLHEP::HepRandom::showEngineStatus();
47  }
48  if (std::ifstream(m_stopFile.c_str()))
49  {
50  edm::LogWarning("SimG4CoreApplication")
51  << "EndOfEventAction: termination signal received at event "
52  << anEvent->GetEventID();
53  // soft abort run
54  m_runInterface->abortRun(true);
55  }
56  if (anEvent->GetNumberOfPrimaryVertex()==0)
57  {
58  edm::LogWarning("SimG4CoreApplication")
59  << "EndOfEventAction: event " << anEvent->GetEventID()
60  << " must have failed (no G4PrimaryVertices found) and will be skipped ";
61  return;
62  }
63 
65 
66  // dispatch now end of event, and only then delete tracks...
67  EndOfEvent e(anEvent);
69 
72 }
73 
75  const std::pair<math::XYZVectorD,math::XYZTLorentzVectorD>& p)
76 {
78 }
79 
81 {
83 }
T getParameter(std::string const &) const
std::string m_stopFile
Definition: EventAction.h:61
SimRunInterface * m_runInterface
Definition: EventAction.h:58
SimActivityRegistry::EndOfEventSignal m_endOfEventSignal
Definition: EventAction.h:54
virtual void EndOfEventAction(const G4Event *evt)
Definition: EventAction.cc:40
bool m_printRandom
Definition: EventAction.h:62
G4SimEvent * simEvent()
void cleanTkCaloStateInfoMap()
void addTkCaloStateInfo(uint32_t t, const std::pair< math::XYZVectorD, math::XYZTLorentzVectorD > &p)
virtual void BeginOfEventAction(const G4Event *evt)
Definition: EventAction.cc:30
void abortRun(bool softAbort)
CMSSteppingVerbose * m_SteppingVerbose
Definition: EventAction.h:60
void storeTracks(G4SimEvent *simEvent)
void BeginOfEvent(const G4Event *)
SimTrackManager * m_trackManager
Definition: EventAction.h:59
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:74
void abortEvent()
Definition: EventAction.cc:80
rm
Definition: submit.py:76
virtual ~EventAction()
Definition: EventAction.cc:28
void setCollapsePrimaryVertices(bool iSet)
SimActivityRegistry::BeginOfEventSignal m_beginOfEventSignal
Definition: EventAction.h:53