CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EventAction.cc
Go to the documentation of this file.
7 
9 
10 #include <fstream>
11 
12 //using std::cout;
13 //using std::endl;
14 
17  SimTrackManager* iManager)
18  : m_runInterface(rm),
19  m_trackManager(iManager),
20  m_stopFile(p.getParameter<std::string>("StopFile")),
21  m_debug(p.getUntrackedParameter<bool>("debug",false))
22 {
23  m_trackManager->setCollapsePrimaryVertices(p.getParameter<bool>("CollapsePrimaryVertices"));
24 }
25 
27 
28 void EventAction::BeginOfEventAction(const G4Event * anEvent)
29 {
30  if (std::ifstream(m_stopFile.c_str()))
31  {
32  edm::LogWarning("SimG4CoreApplication")
33  << "BeginOfEventAction: termination signal received at event "
34  << anEvent->GetEventID();
35  /*
36  cout << "BeginOfEventAction: termination signal received at event "
37  << anEvent->GetEventID() << endl;
38  */
39  m_runInterface->abortRun(true);
40  }
41 
43  BeginOfEvent e(anEvent);
45 
46 }
47 
48 void EventAction::EndOfEventAction(const G4Event * anEvent)
49 {
50  if (std::ifstream(m_stopFile.c_str()))
51  {
52  edm::LogWarning("SimG4CoreApplication")
53  << "EndOfEventAction: termination signal received at event "
54  << anEvent->GetEventID();
55  /*
56  cout << "EndOfEventAction: termination signal received at event "
57  << anEvent->GetEventID() << endl;
58  */
59  // soft abort run
60  m_runInterface->abortRun(true);
61  }
62  if (anEvent->GetNumberOfPrimaryVertex()==0)
63  {
64  edm::LogWarning("SimG4CoreApplication")
65  << "EndOfEventAction: event " << anEvent->GetEventID()
66  << " must have failed (no G4PrimaryVertices found) and will be skipped ";
67  /*
68  cout << " EndOfEventAction: event " << anEvent->GetEventID()
69  << " must have failed (no G4PrimaryVertices found) and will be skipped "
70  << endl;
71  */
72  return;
73  }
74 
76 
77  // dispatch now end of event, and only then delete tracks...
78  EndOfEvent e(anEvent);
80 
83 }
84 
85 void EventAction::addTrack(TrackWithHistory* iTrack, bool inHistory, bool withAncestor)
86 {
87  m_trackManager->addTrack(iTrack, inHistory, withAncestor);
88 }
89 
90 void EventAction::addTkCaloStateInfo(uint32_t t,const std::pair< math::XYZVectorD,
92 {
94 }
95 
97 {
99 }
void addTrack(TrackWithHistory *iTrack, bool inHistory, bool withAncestor)
T getParameter(std::string const &) const
std::string m_stopFile
Definition: EventAction.h:52
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< double > > XYZTLorentzVectorD
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:14
SimRunInterface * m_runInterface
Definition: EventAction.h:50
EventAction(const edm::ParameterSet &ps, SimRunInterface *, SimTrackManager *)
Definition: EventAction.cc:15
SimActivityRegistry::EndOfEventSignal m_endOfEventSignal
Definition: EventAction.h:46
void EndOfEventAction(const G4Event *evt)
Definition: EventAction.cc:48
G4SimEvent * simEvent()
void cleanTkCaloStateInfoMap()
void addTkCaloStateInfo(uint32_t t, const std::pair< math::XYZVectorD, math::XYZTLorentzVectorD > &p)
void BeginOfEventAction(const G4Event *evt)
Definition: EventAction.cc:28
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > XYZVectorD
spatial vector with cartesian internal representation
Definition: Vector3D.h:8
void abortRun(bool softAbort)
string rm
Definition: submit.py:76
void storeTracks(G4SimEvent *simEvent)
SimTrackManager * m_trackManager
Definition: EventAction.h:51
void addTkCaloStateInfo(uint32_t t, const std::pair< math::XYZVectorD, math::XYZTLorentzVectorD > &p)
Definition: EventAction.cc:90
void abortEvent()
Definition: EventAction.cc:96
volatile std::atomic< bool > shutdown_flag false
void addTrack(TrackWithHistory *iTrack, bool inHistory, bool withAncestor)
Definition: EventAction.cc:85
void setCollapsePrimaryVertices(bool iSet)
SimActivityRegistry::BeginOfEventSignal m_beginOfEventSignal
Definition: EventAction.h:45