EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RunAction.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file RunAction.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2017 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
9 #include "RunAction.hpp"
10 
11 #include <stdexcept>
12 
13 #include <G4Run.hh>
14 
15 #include "EventAction.hpp"
16 
17 using namespace ActsExamples;
18 
20 
22  return s_instance;
23 }
24 
25 RunAction::RunAction() : G4UserRunAction() {
26  if (s_instance) {
27  throw std::logic_error("Attempted to duplicate the RunAction singleton");
28  } else {
29  s_instance = this;
30  }
31 }
32 
34  s_instance = nullptr;
35 }
36 
37 void RunAction::BeginOfRunAction(const G4Run* aRun) {
38  G4cout << "### Run " << aRun->GetRunID() << " start." << G4endl;
39  // initialize event cumulative quantities
41 }
42 
43 void RunAction::EndOfRunAction(const G4Run* aRun) {
44  G4int nofEvents = aRun->GetNumberOfEvent();
45  if (nofEvents == 0)
46  return;
47 
48  // Print
49  G4cout << "\n--------------------End of Run------------------------------\n"
50  << "\n------------------------------------------------------------\n"
51  << G4endl;
52 }