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  }
42  BeginOfEvent e(anEvent);
44 }
45 
46 void EventAction::EndOfEventAction(const G4Event * anEvent)
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 
74 void EventAction::addTrack(TrackWithHistory* iTrack, bool inHistory,
75  bool withAncestor)
76 {
77  m_trackManager->addTrack(iTrack, inHistory, withAncestor);
78 }
79 
80 void EventAction::addTkCaloStateInfo(uint32_t t,const std::pair< math::XYZVectorD,
82 {
84 }
85 
87 {
89 }
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:46
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:80
void abortEvent()
Definition: EventAction.cc:86
volatile std::atomic< bool > shutdown_flag false
void addTrack(TrackWithHistory *iTrack, bool inHistory, bool withAncestor)
Definition: EventAction.cc:74
void setCollapsePrimaryVertices(bool iSet)
SimActivityRegistry::BeginOfEventSignal m_beginOfEventSignal
Definition: EventAction.h:45