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 
27 
28 void EventAction::BeginOfEventAction(const G4Event* anEvent) {
30 
31  BeginOfEvent e(anEvent);
33 
34  if (m_printRandom) {
35  edm::LogVerbatim("SimG4CoreApplication")
36  << "BeginOfEvent " << anEvent->GetEventID() << " Random number: " << G4UniformRand();
37  }
38 
39  if (nullptr != m_SteppingVerbose) {
41  }
42 }
43 
44 void EventAction::EndOfEventAction(const G4Event* anEvent) {
45  if (m_printRandom) {
46  edm::LogVerbatim("SimG4CoreApplication")
47  << " EndOfEvent " << anEvent->GetEventID() << " Random number: " << G4UniformRand();
48  }
49  if (!m_stopFile.empty() && std::ifstream(m_stopFile.c_str())) {
50  edm::LogWarning("SimG4CoreApplication")
51  << "EndOfEventAction: termination signal received at event " << anEvent->GetEventID();
52  // soft abort run
53  m_runInterface->abortRun(true);
54  }
55  if (anEvent->GetNumberOfPrimaryVertex() == 0) {
56  edm::LogWarning("SimG4CoreApplication") << "EndOfEventAction: event " << anEvent->GetEventID()
57  << " must have failed (no G4PrimaryVertices found) and will be skipped ";
58  return;
59  }
60 
62 
63  // dispatch now end of event, and only then delete tracks...
64  EndOfEvent e(anEvent);
66 
69 }
70 
71 void EventAction::addTkCaloStateInfo(uint32_t t, const std::pair<math::XYZVectorD, math::XYZTLorentzVectorD>& p) {
73 }
74 
Log< level::Info, true > LogVerbatim
std::string m_stopFile
Definition: EventAction.h:53
def rm(path, rec=False)
Definition: eostools.py:363
SimRunInterface * m_runInterface
Definition: EventAction.h:50
SimActivityRegistry::EndOfEventSignal m_endOfEventSignal
Definition: EventAction.h:47
bool m_printRandom
Definition: EventAction.h:54
G4SimEvent * simEvent()
void cleanTkCaloStateInfoMap()
void BeginOfEventAction(const G4Event *evt) override
Definition: EventAction.cc:28
void addTkCaloStateInfo(uint32_t t, const std::pair< math::XYZVectorD, math::XYZTLorentzVectorD > &p)
void abortRun(bool softAbort)
CMSSteppingVerbose * m_SteppingVerbose
Definition: EventAction.h:52
void storeTracks(G4SimEvent *simEvent)
void BeginOfEvent(const G4Event *)
void EndOfEventAction(const G4Event *evt) override
Definition: EventAction.cc:44
SimTrackManager * m_trackManager
Definition: EventAction.h:51
EventAction(const edm::ParameterSet &ps, SimRunInterface *, SimTrackManager *, CMSSteppingVerbose *)
Definition: EventAction.cc:13
void addTkCaloStateInfo(uint32_t t, const std::pair< math::XYZVectorD, math::XYZTLorentzVectorD > &p)
Definition: EventAction.cc:71
void abortEvent()
Definition: EventAction.cc:75
Log< level::Warning, false > LogWarning
void setCollapsePrimaryVertices(bool iSet)
SimActivityRegistry::BeginOfEventSignal m_beginOfEventSignal
Definition: EventAction.h:46
~EventAction() override
Definition: EventAction.cc:26