Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
B3aRunAction.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: B3aRunAction.cc 99559 2016-09-27 07:02:21Z gcosmo $
27 //
30 
31 #include "B3aRunAction.hh"
32 #include "B3PrimaryGeneratorAction.hh"
33 
34 #include "G4RunManager.hh"
35 #include "G4Run.hh"
36 #include "G4AccumulableManager.hh"
37 #include "G4UnitsTable.hh"
38 #include "G4SystemOfUnits.hh"
39 
40 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
41 
43  : G4UserRunAction(),
44  fGoodEvents(0),
45  fSumDose(0.)
46 {
47  //add new units for dose
48  //
49  const G4double milligray = 1.e-3*gray;
50  const G4double microgray = 1.e-6*gray;
51  const G4double nanogray = 1.e-9*gray;
52  const G4double picogray = 1.e-12*gray;
53 
54  new G4UnitDefinition("milligray", "milliGy" , "Dose", milligray);
55  new G4UnitDefinition("microgray", "microGy" , "Dose", microgray);
56  new G4UnitDefinition("nanogray" , "nanoGy" , "Dose", nanogray);
57  new G4UnitDefinition("picogray" , "picoGy" , "Dose", picogray);
58 
59  // Register accumulable to the accumulable manager
61  accumulableManager->RegisterAccumulable(fGoodEvents);
62  accumulableManager->RegisterAccumulable(fSumDose);
63 }
64 
65 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
66 
68 { }
69 
70 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
71 
73 {
74  G4cout << "### Run " << run->GetRunID() << " start." << G4endl;
75 
76  // reset accumulables to their initial values
78  accumulableManager->Reset();
79 
80  //inform the runManager to save random number seed
82 }
83 
84 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
85 
87 {
88  G4int nofEvents = run->GetNumberOfEvent();
89  if (nofEvents == 0) return;
90 
91  // Merge accumulables
93  accumulableManager->Merge();
94 
95  // Run conditions
96  // note: There is no primary generator action object for "master"
97  // run manager for multi-threaded mode.
98  const B3PrimaryGeneratorAction* generatorAction
99  = static_cast<const B3PrimaryGeneratorAction*>(
101  G4String partName;
102  if (generatorAction)
103  {
104  G4ParticleDefinition* particle
105  = generatorAction->GetParticleGun()->GetParticleDefinition();
106  partName = particle->GetParticleName();
107  }
108 
109  // Print results
110  //
111  if (IsMaster())
112  {
113  G4cout
114  << G4endl
115  << "--------------------End of Global Run-----------------------"
116  << G4endl
117  << " The run was " << nofEvents << " events ";
118  }
119  else
120  {
121  G4cout
122  << G4endl
123  << "--------------------End of Local Run------------------------"
124  << G4endl
125  << " The run was " << nofEvents << " "<< partName;
126  }
127  G4cout
128  << "; Nb of 'good' e+ annihilations: " << fGoodEvents.GetValue() << G4endl
129  << " Total dose in patient : " << G4BestUnit(fSumDose.GetValue(),"Dose")
130  << G4endl
131  << "------------------------------------------------------------" << G4endl
132  << G4endl;
133 }
134 
135 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
const G4VUserPrimaryGeneratorAction * GetUserPrimaryGeneratorAction() const
Definition of the B3aRunAction class.
const G4ParticleGun * GetParticleGun() const
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
void SetRandomNumberStore(G4bool flag)
int G4int
Definition: G4Types.hh:78
const G4String & GetParticleName() const
static G4AccumulableManager * Instance()
static constexpr double microgray
Definition: G4SIunits.hh:312
virtual void BeginOfRunAction(const G4Run *)
Definition: B3aRunAction.cc:72
G4bool RegisterAccumulable(G4Accumulable< T > &accumulable)
G4GLOB_DLL std::ostream G4cout
G4int GetNumberOfEvent() const
Definition: G4Run.hh:79
static constexpr double gray
Definition: G4SIunits.hh:309
G4bool IsMaster() const
G4int GetRunID() const
Definition: G4Run.hh:76
T GetValue() const
Definition: G4Run.hh:46
static constexpr double milligray
Definition: G4SIunits.hh:311
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:79
virtual void EndOfRunAction(const G4Run *)
Definition: B3aRunAction.cc:86
G4ParticleDefinition * GetParticleDefinition() const
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
virtual ~B3aRunAction()
Definition: B3aRunAction.cc:67