ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RunAction.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file RunAction.cc
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
28 //
29 //
30 //---------------------------------------------------------------------------
31 //
32 // ClassName: RunAction
33 //
34 // Author: V.Ivanchenko 01.09.2010
35 //
36 //----------------------------------------------------------------------------
37 //
38 
39 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
40 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
41 
42 #include "RunAction.hh"
43 #include "Run.hh"
44 #include "TestParameters.hh"
45 #include "G4Run.hh"
46 #include "G4RunManager.hh"
47 #include "G4SystemOfUnits.hh"
48 
49 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
50 
52  : G4UserRunAction(), fAnalysisManager(nullptr), fRun(nullptr)
53 {
59 }
60 
61 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
62 
64 {}
65 
66 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
67 
68 void RunAction::Book()
69 {
70  // Always creating analysis manager
72  G4int nBinsE = param->GetNumberBins();
73  G4double maxEnergy = param->GetMaxEnergy();
74 
75  // Creating an 1-dimensional histograms in the root directory of the tree
77  fAnalysisManager->CreateH1("h1","Energy deposition in detector (GeV)",
78  nBinsE,0.0,maxEnergy/GeV);
80 }
81 
82 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
83 
85 {
86  fRun = new Run();
87  return fRun;
88 }
89 
90 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
91 
92 void RunAction::BeginOfRunAction(const G4Run* aRun)
93 {
94  G4int id = aRun->GetRunID();
95  G4cout << "### Run " << id << " start analysis activation: "
96  << G4endl;
97 
98  fRun->BeginOfRun();
99 
100  //histograms
101  Book();
102 }
103 
104 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
105 
106 void RunAction::EndOfRunAction(const G4Run*)
107 {
108  // print Run summary
109  G4cout << "RunAction: End of run actions are started " << isMaster
110  << " Nevt= " << fRun->GetNumberOfEvent()
111  << " Edep= " << fRun->GetStat()->mean() << G4endl;
112  if (isMaster) {
113  fRun->EndOfRun();
114  }
115  // save histos and close analysis
116  if (fAnalysisManager->IsActive()) {
119  }
120  //delete fAnalysisManager;
121 }
122 
123 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......