Geant4
9.6.p02
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
geant4_9_6_p02
examples
basic
B1
src
B1RunAction.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
// $Id$
27
//
30
31
#include "B1RunAction.hh"
32
#include "B1PrimaryGeneratorAction.hh"
33
#include "B1EventAction.hh"
34
#include "B1SteppingAction.hh"
35
// use of other actions
36
// - primary generator: to get info for printing about the primary
37
// - event action: to get and reset accumulated energy sums
38
// - stepping action: to get info about accounting volume
39
40
#include "
G4Run.hh
"
41
#include "
G4RunManager.hh
"
42
#include "
G4UnitsTable.hh
"
43
#include "
G4SystemOfUnits.hh
"
44
45
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
46
47
B1RunAction::B1RunAction
()
48
:
G4UserRunAction
()
49
{
50
// add new units for dose
51
//
52
const
G4double
milligray = 1.e-3*
gray
;
53
const
G4double
microgray = 1.e-6*
gray
;
54
const
G4double
nanogray = 1.e-9*
gray
;
55
const
G4double
picogray = 1.e-12*
gray
;
56
57
new
G4UnitDefinition
(
"milligray"
,
"milliGy"
,
"Dose"
, milligray);
58
new
G4UnitDefinition
(
"microgray"
,
"microGy"
,
"Dose"
, microgray);
59
new
G4UnitDefinition
(
"nanogray"
,
"nanoGy"
,
"Dose"
, nanogray);
60
new
G4UnitDefinition
(
"picogray"
,
"picoGy"
,
"Dose"
, picogray);
61
}
62
63
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
64
65
B1RunAction::~B1RunAction
()
66
{}
67
68
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
69
70
void
B1RunAction::BeginOfRunAction
(
const
G4Run
* aRun)
71
{
72
G4cout
<<
"### Run "
<< aRun->
GetRunID
() <<
" start."
<<
G4endl
;
73
74
//inform the runManager to save random number seed
75
G4RunManager::GetRunManager
()->
SetRandomNumberStore
(
false
);
76
77
//initialize event cumulative quantities
78
B1EventAction::Instance
()->
Reset
();
79
}
80
81
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
82
83
void
B1RunAction::EndOfRunAction
(
const
G4Run
* aRun)
84
{
85
G4int
nofEvents = aRun->
GetNumberOfEvent
();
86
if
(nofEvents == 0)
return
;
87
88
// Compute dose
89
//
90
G4double
energySum =
B1EventAction::Instance
()->
GetEnergySum
();
91
G4double
energy2Sum =
B1EventAction::Instance
()->
GetEnergy2Sum
();
92
G4double
rms = energy2Sum - energySum*energySum/nofEvents;
93
if
(rms > 0.) rms = std::sqrt(rms);
else
rms = 0.;
94
95
G4double
mass =
B1SteppingAction::Instance
()->
GetVolume
()->
GetMass
();
96
G4double
dose
= energySum/mass;
97
G4double
rmsDose = rms/mass;
98
99
// Run conditions
100
//
101
const
G4ParticleGun
* particleGun
102
=
B1PrimaryGeneratorAction::Instance
()->
GetParticleGun
();
103
G4String
particleName
104
= particleGun->
GetParticleDefinition
()->
GetParticleName
();
105
G4double
particleEnergy = particleGun->
GetParticleEnergy
();
106
107
// Print
108
//
109
G4cout
110
<<
"\n--------------------End of Run------------------------------\n"
111
<<
" The run consists of "
<< nofEvents <<
" "
<< particleName <<
" of "
112
<<
G4BestUnit
(particleEnergy,
"Energy"
)
113
<<
"\n Dose in scoring volume "
114
<<
B1SteppingAction::Instance
()->
GetVolume
()->
GetName
() <<
" : "
115
<<
G4BestUnit
(dose,
"Dose"
)
116
<<
" +- "
<<
G4BestUnit
(rmsDose,
"Dose"
)
117
<<
"\n------------------------------------------------------------\n"
118
<<
G4endl
;
119
}
120
121
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Generated on Sat May 25 2013 14:32:16 for Geant4 by
1.8.4