Geant4  10.02.p01
B3bRunAction.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: B3bRunAction.cc 94031 2015-11-05 11:54:38Z ihrivnac $
27 //
30 
31 #include "B3bRunAction.hh"
32 #include "B3bRun.hh"
33 #include "B3PrimaryGeneratorAction.hh"
34 
35 #include "G4Run.hh"
36 #include "G4RunManager.hh"
37 #include "G4UnitsTable.hh"
38 #include "G4SystemOfUnits.hh"
39 
40 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
41 
43  : G4UserRunAction()
44 {
45  //add new units for dose
46  //
47  const G4double milligray = 1.e-3*gray;
48  const G4double microgray = 1.e-6*gray;
49  const G4double nanogray = 1.e-9*gray;
50  const G4double picogray = 1.e-12*gray;
51 
52  new G4UnitDefinition("milligray", "milliGy" , "Dose", milligray);
53  new G4UnitDefinition("microgray", "microGy" , "Dose", microgray);
54  new G4UnitDefinition("nanogray" , "nanoGy" , "Dose", nanogray);
55  new G4UnitDefinition("picogray" , "picoGy" , "Dose", picogray);
56 }
57 
58 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
59 
61 { }
62 
63 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
64 
66 { return new B3bRun; }
67 
68 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
69 
71 {
72  G4cout << "### Run " << run->GetRunID() << " start." << G4endl;
73 
74  //inform the runManager to save random number seed
76 }
77 
78 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
79 
81 {
82  G4int nofEvents = run->GetNumberOfEvent();
83  if (nofEvents == 0) return;
84 
85  // Run conditions
86  // note: There is no primary generator action object for "master"
87  // run manager for multi-threaded mode.
88  const B3PrimaryGeneratorAction* generatorAction
89  = static_cast<const B3PrimaryGeneratorAction*>(
91  G4String partName;
92  if (generatorAction)
93  {
94  G4ParticleDefinition* particle
95  = generatorAction->GetParticleGun()->GetParticleDefinition();
96  partName = particle->GetParticleName();
97  }
98 
99  //results
100  //
101  const B3bRun* b3Run = static_cast<const B3bRun*>(run);
102  G4int nbGoodEvents = b3Run->GetNbGoodEvents();
103  G4double sumDose = b3Run->GetSumDose();
104 
105  //print
106  //
107  if (IsMaster())
108  {
109  G4cout
110  << G4endl
111  << "--------------------End of Global Run-----------------------"
112  << G4endl
113  << " The run was " << nofEvents << " events ";
114  }
115  else
116  {
117  G4cout
118  << G4endl
119  << "--------------------End of Local Run------------------------"
120  << G4endl
121  << " The run was " << nofEvents << " "<< partName;
122  }
123  G4cout
124  << "; Nb of 'good' e+ annihilations: " << nbGoodEvents << G4endl
125  << " Total dose in patient : " << G4BestUnit(sumDose,"Dose") << G4endl
126  << "------------------------------------------------------------" << G4endl
127  << G4endl;
128 }
129 
130 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
const G4VUserPrimaryGeneratorAction * GetUserPrimaryGeneratorAction() const
Definition of the B3bRunAction class.
const G4ParticleGun * GetParticleGun() const
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
void SetRandomNumberStore(G4bool flag)
virtual ~B3bRunAction()
Definition: B3bRunAction.cc:60
int G4int
Definition: G4Types.hh:78
static const double milligray
Definition: G4SIunits.hh:308
const G4String & GetParticleName() const
G4double GetSumDose() const
Definition: B3bRun.hh:53
Run class.
Definition: B3bRun.hh:42
static const double microgray
Definition: G4SIunits.hh:309
The primary generator action class with particle gum.
G4GLOB_DLL std::ostream G4cout
G4int GetNumberOfEvent() const
Definition: G4Run.hh:79
G4bool IsMaster() const
G4int GetRunID() const
Definition: G4Run.hh:76
Definition: G4Run.hh:46
Definition of the B3bRun class.
virtual void EndOfRunAction(const G4Run *)
Definition: B3bRunAction.cc:80
static const double gray
Definition: G4SIunits.hh:306
virtual void BeginOfRunAction(const G4Run *)
Definition: B3bRunAction.cc:70
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:79
G4int GetNbGoodEvents() const
Definition: B3bRun.hh:52
virtual G4Run * GenerateRun()
Definition: B3bRunAction.cc:65
G4ParticleDefinition * GetParticleDefinition() const
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76