HGCal Test Beam  03a93d6239a951948e06fb3ef8dae4cbdebfad30
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
RunAction.cc
Go to the documentation of this file.
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 //
26 //
27 // $Id$
28 //
29 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
30 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
31 
32 #include "HGCal/TBStandaloneSimulator/interface/RunAction.hh"
33 
34 #include "G4Run.hh"
35 #include "G4RunManager.hh"
36 #include "G4UnitsTable.hh"
37 
38 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
39 
40 RunAction::RunAction()
41 {}
42 
43 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
44 
45 RunAction::~RunAction()
46 {}
47 
48 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
49 
50 void RunAction::BeginOfRunAction(const G4Run* aRun)
51 {
52  G4cout << "### Run " << aRun->GetRunID() << " start." << G4endl;
53 
54  //inform the runManager to save random number seed
55  G4RunManager::GetRunManager()->SetRandomNumberStore(true);
56 
57  //initialize cumulative quantities
58  //
59  sumEAbs = sum2EAbs = sumEGap = sum2EGap = 0.;
60  sumLAbs = sum2LAbs = sumLGap = sum2LGap = 0.;
61 }
62 
63 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
64 
65 void RunAction::fillPerEvent(G4double EAbs, G4double EGap,
66  G4double LAbs, G4double LGap)
67 {
68  //accumulate statistic
69  //
70  sumEAbs += EAbs;
71  sum2EAbs += EAbs * EAbs;
72  sumEGap += EGap;
73  sum2EGap += EGap * EGap;
74 
75  sumLAbs += LAbs;
76  sum2LAbs += LAbs * LAbs;
77  sumLGap += LGap;
78  sum2LGap += LGap * LGap;
79 }
80 
81 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
82 
83 void RunAction::EndOfRunAction(const G4Run* aRun)
84 {
85  G4int NbOfEvents = aRun->GetNumberOfEvent();
86 
87  // A hack to avoid compiler warning
88  int hack = CLHEP::HepRandomGenActive;
89  hack = NbOfEvents;
90  NbOfEvents = hack;
91 
92  if (NbOfEvents == 0) return;
93 
94  G4cout
95  << "\n--------------------End of Run------------------------------\n"
96  << " -- Number of events processed = " << NbOfEvents << "\n"
97  << G4endl;
98 
99  // //compute statistics: mean and rms
100  // //
101  // sumEAbs /= NbOfEvents; sum2EAbs /= NbOfEvents;
102  // G4double rmsEAbs = sum2EAbs - sumEAbs*sumEAbs;
103  // if (rmsEAbs >0.) rmsEAbs = std::sqrt(rmsEAbs); else rmsEAbs = 0.;
104 
105  // sumEGap /= NbOfEvents; sum2EGap /= NbOfEvents;
106  // G4double rmsEGap = sum2EGap - sumEGap*sumEGap;
107  // if (rmsEGap >0.) rmsEGap = std::sqrt(rmsEGap); else rmsEGap = 0.;
108 
109  // sumLAbs /= NbOfEvents; sum2LAbs /= NbOfEvents;
110  // G4double rmsLAbs = sum2LAbs - sumLAbs*sumLAbs;
111  // if (rmsLAbs >0.) rmsLAbs = std::sqrt(rmsLAbs); else rmsLAbs = 0.;
112 
113  // sumLGap /= NbOfEvents; sum2LGap /= NbOfEvents;
114  // G4double rmsLGap = sum2LGap - sumLGap*sumLGap;
115  // if (rmsLGap >0.) rmsLGap = std::sqrt(rmsLGap); else rmsLGap = 0.;
116 
117  // //print
118  // //
119  // G4cout
120  // << "\n--------------------End of Run------------------------------\n"
121  // << "\n mean Energy in Absorber : " << G4BestUnit(sumEAbs,"Energy")
122  // << " +- " << G4BestUnit(rmsEAbs,"Energy")
123  // << "\n mean Energy in Gap : " << G4BestUnit(sumEGap,"Energy")
124  // << " +- " << G4BestUnit(rmsEGap,"Energy")
125  // << G4endl;
126 
127  // G4cout
128  // << "\n mean trackLength in Absorber : " << G4BestUnit(sumLAbs,"Length")
129  // << " +- " << G4BestUnit(rmsLAbs,"Length")
130  // << "\n mean trackLength in Gap : " << G4BestUnit(sumLGap,"Length")
131  // << " +- " << G4BestUnit(rmsLGap,"Length")
132  // << "\n------------------------------------------------------------\n"
133  // << G4endl;
134 }
135 
136 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......