CMS 3D CMS Logo

RunAction.cc
Go to the documentation of this file.
3 
6 
8 
9 #include "G4Timer.hh"
10 #include <iostream>
11 #include <fstream>
12 
14  : m_runInterface(rm),
15  m_stopFile(p.getParameter<std::string>("StopFile")),
16  m_timer(nullptr), m_isMaster(master)
17 {}
18 
20 {}
21 
22 void RunAction::BeginOfRunAction(const G4Run * aRun)
23 {
24  if (std::ifstream(m_stopFile.c_str()))
25  {
26  edm::LogWarning("SimG4CoreApplication")
27  << "RunAction::BeginOfRunAction: termination signal received";
28  m_runInterface->abortRun(true);
29  }
30  BeginOfRun r(aRun);
32  /*
33  if (m_isMaster) {
34  m_timer = new G4Timer();
35  m_timer->Start();
36  }
37  */
38 }
39 
40 void RunAction::EndOfRunAction(const G4Run * aRun)
41 {
42  if (isMaster) {
43  edm::LogInfo("SimG4CoreApplication")
44  << "RunAction: total number of events " << aRun->GetNumberOfEvent();
45  if(m_timer) {
46  m_timer->Stop();
47  edm::LogInfo("SimG4CoreApplication")
48  << "RunAction: Master thread time " << *m_timer;
49  // std::cout << "\n" << "Master thread time: " << *m_timer << std::endl;
50  delete m_timer;
51  }
52  }
53  if (std::ifstream(m_stopFile.c_str()))
54  {
55  edm::LogWarning("SimG4CoreApplication")
56  << "RunAction::EndOfRunAction: termination signal received";
57  m_runInterface->abortRun(true);
58  }
59  EndOfRun r(aRun);
60  m_endOfRunSignal(&r);
61 }
62 
Master< F > master(const F &f)
Definition: FunctClone.h:68
void BeginOfRunAction(const G4Run *aRun) override
Definition: RunAction.cc:22
RunAction(const edm::ParameterSet &ps, SimRunInterface *, bool master)
Definition: RunAction.cc:13
G4Timer * m_timer
Definition: RunAction.h:31
SimActivityRegistry::EndOfRunSignal m_endOfRunSignal
Definition: RunAction.h:26
~RunAction() override
Definition: RunAction.cc:19
#define nullptr
void abortRun(bool softAbort)
std::string m_stopFile
Definition: RunAction.h:30
SimActivityRegistry::BeginOfRunSignal m_beginOfRunSignal
Definition: RunAction.h:25
rm
Definition: submit.py:76
void EndOfRunAction(const G4Run *aRun) override
Definition: RunAction.cc:40
SimRunInterface * m_runInterface
Definition: RunAction.h:29