Geant4_10
Run.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 //
28 //
29 // $Id: Run.cc 71376 2013-06-14 07:44:50Z maire $
30 //
31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
33 
34 #include "Run.hh"
35 #include "DetectorConstruction.hh"
36 #include "EventAction.hh"
37 
38 #include "G4UnitsTable.hh"
39 #include "G4SystemOfUnits.hh"
40 #include "G4Event.hh"
41 
42 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
43 
45 : G4Run(),
46  fDetector(detector),
47  fEdeposit(0.), fEdeposit2(0.),
48  fTrackLen(0.), fTrackLen2(0.),
49  fProjRange(0.), fProjRange2(0.),
50  fNbOfSteps(0), fNbOfSteps2(0),
51  fStepSize(0.), fStepSize2(0.)
52 {
53  for (G4int i=0; i<3; ++i) fStatus[i] = 0;
54  for (G4int i=0; i<MaxAbsor; ++i) {
55  fCsdaRange[i] = 0.; fXfrontNorm[i] = 0.;
56  }
57 }
58 
59 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
60 
61 Run::~Run()
62 {
63 }
64 
65 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
66 
68 {
69  std::ios::fmtflags mode = G4cout.flags();
70  G4cout.setf(std::ios::fixed,std::ios::floatfield);
71  G4int prec = G4cout.precision(2);
72 
73  fEdeposit /= numberOfEvent; fEdeposit2 /= numberOfEvent;
74  G4double rms = fEdeposit2 - fEdeposit*fEdeposit;
75  if (rms>0.) rms = std::sqrt(rms); else rms = 0.;
76 
77  G4cout.precision(3);
78  G4cout
79  << "\n Total Energy deposited = " << G4BestUnit(fEdeposit,"Energy")
80  << " +- " << G4BestUnit( rms,"Energy")
81  << G4endl;
82 
83  //compute track length of primary track
84  //
85  fTrackLen /= numberOfEvent; fTrackLen2 /= numberOfEvent;
86  rms = fTrackLen2 - fTrackLen*fTrackLen;
87  if (rms>0.) rms = std::sqrt(rms); else rms = 0.;
88 
89  G4cout.precision(3);
90  G4cout
91  << "\n Track length of primary track = " << G4BestUnit(fTrackLen,"Length")
92  << " +- " << G4BestUnit( rms,"Length");
93 
94  //compare with csda range
95  //
96  G4int NbOfAbsor = fDetector->GetNbOfAbsor();
97  if (NbOfAbsor == 1) {
98  G4cout
99  << "\n Range from EmCalculator = " << G4BestUnit(fCsdaRange[1],"Length")
100  << " (from full dE/dx)" << G4endl;
101  }
102 
103  //compute projected range of primary track
104  //
105  fProjRange /= numberOfEvent; fProjRange2 /= numberOfEvent;
106  rms = fProjRange2 - fProjRange*fProjRange;
107  if (rms>0.) rms = std::sqrt(rms); else rms = 0.;
108 
109  G4cout
110  << "\n Projected range = " << G4BestUnit(fProjRange,"Length")
111  << " +- " << G4BestUnit( rms,"Length")
112  << G4endl;
113 
114  //nb of steps and step size of primary track
115  //
116  G4double dNofEvents = double(numberOfEvent);
117  G4double fNbSteps = fNbOfSteps/dNofEvents,
118  fNbSteps2 = fNbOfSteps2/dNofEvents;
119  rms = fNbSteps2 - fNbSteps*fNbSteps;
120  if (rms>0.) rms = std::sqrt(rms); else rms = 0.;
121 
122  G4cout.precision(2);
123  G4cout << "\n Nb of steps of primary track = " << fNbSteps << " +- " << rms;
124 
125  fStepSize /= numberOfEvent; fStepSize2 /= numberOfEvent;
126  rms = fStepSize2 - fStepSize*fStepSize;
127  if (rms>0.) rms = std::sqrt(rms); else rms = 0.;
128 
129  G4cout.precision(3);
130  G4cout
131  << "\t Step size= " << G4BestUnit(fStepSize,"Length")
132  << " +- " << G4BestUnit( rms,"Length")
133  << G4endl;
134 
135  //transmission coefficients
136  //
137  G4double absorbed = 100.*fStatus[0]/dNofEvents;
138  G4double transmit = 100.*fStatus[1]/dNofEvents;
139  G4double reflected = 100.*fStatus[2]/dNofEvents;
140 
141  G4cout.precision(2);
142  G4cout
143  << "\n absorbed = " << absorbed << " %"
144  << " transmit = " << transmit << " %"
145  << " reflected = " << reflected << " %" << G4endl;
146 
147  // reset default formats
148  G4cout.setf(mode,std::ios::floatfield);
149  G4cout.precision(prec);
150 }
151 
152 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
153 
154 void Run::Merge(const G4Run* run)
155 {
156  const Run* localRun = static_cast<const Run*>(run);
157 
158  // accumulate sums
159  fEdeposit += localRun->fEdeposit;
160  fEdeposit2 += localRun->fEdeposit2;
161  fTrackLen += localRun->fTrackLen;
162  fTrackLen2 += localRun->fTrackLen2;
163  fProjRange += localRun->fProjRange;
164  fProjRange2 += localRun->fProjRange2;
165  fNbOfSteps += localRun->fNbOfSteps ;
166  fNbOfSteps2 += localRun->fNbOfSteps2;
167  fStepSize += localRun->fStepSize;
168  fStepSize2 += localRun->fStepSize2;
169 
170  G4int nbOfAbsor = fDetector->GetNbOfAbsor();
171  for (G4int i=1; i<=nbOfAbsor; ++i) {
172  fCsdaRange[i] = localRun->fCsdaRange[i];
173  fXfrontNorm[i] = localRun->fXfrontNorm[i];
174  }
175 
176  for (G4int i=0; i<3; ++i) fStatus[i] += localRun->fStatus[i];
177 
178  G4Run::Merge(run);
179 }
180 
181 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
virtual void Merge(const G4Run *)
Definition: G4Run.cc:54
G4int numberOfEvent
Definition: G4Run.hh:59
const G4int MaxAbsor
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
Definition: G4Run.hh:46
void ComputeStatistics()
Definition: Run.cc:97
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
Definition: Run.hh:46
virtual void Merge(const G4Run *)
Definition: Run.cc:180
~Run()
Definition: Run.cc:60
Run(DetectorConstruction *)
Definition: Run.cc:46