source: trunk/geant4/N03/src/ExN03RunAction.cc@ 610

Last change on this file since 610 was 609, checked in by garnier, 18 years ago

r659@mac-90108: laurentgarnier | 2007-11-16 12:02:01 +0100
mise a jour de Geant4 au head ET qq mise a jour pour Qt de mon cote

File size: 4.9 KB
Line 
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: ExN03RunAction.cc,v 1.18 2006/06/29 17:49:11 gunter Exp $
28// GEANT4 tag $Name: $
29//
30//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
31//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
32
33#include "ExN03RunAction.hh"
34
35#include "G4Run.hh"
36#include "G4RunManager.hh"
37#include "G4UnitsTable.hh"
38
39//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
40
41ExN03RunAction::ExN03RunAction()
42{}
43
44//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
45
46ExN03RunAction::~ExN03RunAction()
47{}
48
49//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
50
51void ExN03RunAction::BeginOfRunAction(const G4Run* aRun)
52{
53 G4cout << "### Run " << aRun->GetRunID() << " start." << G4endl;
54
55 //inform the runManager to save random number seed
56 G4RunManager::GetRunManager()->SetRandomNumberStore(true);
57
58 //initialize cumulative quantities
59 //
60 sumEAbs = sum2EAbs =sumEGap = sum2EGap = 0.;
61 sumLAbs = sum2LAbs =sumLGap = sum2LGap = 0.;
62}
63
64//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
65
66void ExN03RunAction::fillPerEvent(G4double EAbs, G4double EGap,
67 G4double LAbs, G4double LGap)
68{
69 //accumulate statistic
70 //
71 sumEAbs += EAbs; sum2EAbs += EAbs*EAbs;
72 sumEGap += EGap; sum2EGap += EGap*EGap;
73
74 sumLAbs += LAbs; sum2LAbs += LAbs*LAbs;
75 sumLGap += LGap; sum2LGap += LGap*LGap;
76}
77
78//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
79
80void ExN03RunAction::EndOfRunAction(const G4Run* aRun)
81{
82 G4int NbOfEvents = aRun->GetNumberOfEvent();
83 if (NbOfEvents == 0) return;
84
85 //compute statistics: mean and rms
86 //
87 sumEAbs /= NbOfEvents; sum2EAbs /= NbOfEvents;
88 G4double rmsEAbs = sum2EAbs - sumEAbs*sumEAbs;
89 if (rmsEAbs >0.) rmsEAbs = std::sqrt(rmsEAbs); else rmsEAbs = 0.;
90
91 sumEGap /= NbOfEvents; sum2EGap /= NbOfEvents;
92 G4double rmsEGap = sum2EGap - sumEGap*sumEGap;
93 if (rmsEGap >0.) rmsEGap = std::sqrt(rmsEGap); else rmsEGap = 0.;
94
95 sumLAbs /= NbOfEvents; sum2LAbs /= NbOfEvents;
96 G4double rmsLAbs = sum2LAbs - sumLAbs*sumLAbs;
97 if (rmsLAbs >0.) rmsLAbs = std::sqrt(rmsLAbs); else rmsLAbs = 0.;
98
99 sumLGap /= NbOfEvents; sum2LGap /= NbOfEvents;
100 G4double rmsLGap = sum2LGap - sumLGap*sumLGap;
101 if (rmsLGap >0.) rmsLGap = std::sqrt(rmsLGap); else rmsLGap = 0.;
102
103 //print
104 //
105 G4cout
106 << "\n--------------------End of Run------------------------------\n"
107 << "\n mean Energy in Absorber : " << G4BestUnit(sumEAbs,"Energy")
108 << " +- " << G4BestUnit(rmsEAbs,"Energy")
109 << "\n mean Energy in Gap : " << G4BestUnit(sumEGap,"Energy")
110 << " +- " << G4BestUnit(rmsEGap,"Energy")
111 << G4endl;
112
113 G4cout
114 << "\n mean trackLength in Absorber : " << G4BestUnit(sumLAbs,"Length")
115 << " +- " << G4BestUnit(rmsLAbs,"Length")
116 << "\n mean trackLength in Gap : " << G4BestUnit(sumLGap,"Length")
117 << " +- " << G4BestUnit(rmsLGap,"Length")
118 << "\n------------------------------------------------------------\n"
119 << G4endl;
120}
121
122//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Note: See TracBrowser for help on using the repository browser.