Loading...
Searching...
No Matches
RunAction.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//
27/// \file B3/B3a/src/RunAction.cc
28/// \brief Implementation of the B3a::RunAction class
29
30#include "RunAction.hh"
31#include "PrimaryGeneratorAction.hh"
32
33#include "G4RunManager.hh"
34#include "G4Run.hh"
35#include "G4AccumulableManager.hh"
36#include "G4UnitsTable.hh"
37#include "G4SystemOfUnits.hh"
38
39using namespace B3;
40
41namespace B3a
42{
43
44//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
45
47{
48 //add new units for dose
49 //
50 const G4double milligray = 1.e-3*gray;
51 const G4double microgray = 1.e-6*gray;
52 const G4double nanogray = 1.e-9*gray;
53 const G4double picogray = 1.e-12*gray;
54
55 new G4UnitDefinition("milligray", "milliGy" , "Dose", milligray);
56 new G4UnitDefinition("microgray", "microGy" , "Dose", microgray);
57 new G4UnitDefinition("nanogray" , "nanoGy" , "Dose", nanogray);
58 new G4UnitDefinition("picogray" , "picoGy" , "Dose", picogray);
59
60 // Register accumulable to the accumulable manager
61 G4AccumulableManager* accumulableManager = G4AccumulableManager::Instance();
62 accumulableManager->RegisterAccumulable(fGoodEvents);
63 accumulableManager->RegisterAccumulable(fSumDose);
64}
65
66//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
67
69{
70 G4cout << "### Run " << run->GetRunID() << " start." << G4endl;
71
72 // reset accumulables to their initial values
73 G4AccumulableManager* accumulableManager = G4AccumulableManager::Instance();
74 accumulableManager->Reset();
75
76 //inform the runManager to save random number seed
77 G4RunManager::GetRunManager()->SetRandomNumberStore(false);
78}
79
80//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
81
83{
84 G4int nofEvents = run->GetNumberOfEvent();
85 if (nofEvents == 0) return;
86
87 // Merge accumulables
88 G4AccumulableManager* accumulableManager = G4AccumulableManager::Instance();
89 accumulableManager->Merge();
90
91 // Run conditions
92 // note: There is no primary generator action object for "master"
93 // run manager for multi-threaded mode.
94 const auto generatorAction = static_cast<const PrimaryGeneratorAction*>(
95 G4RunManager::GetRunManager()->GetUserPrimaryGeneratorAction());
96 G4String partName;
97 if (generatorAction)
98 {
99 G4ParticleDefinition* particle
100 = generatorAction->GetParticleGun()->GetParticleDefinition();
101 partName = particle->GetParticleName();
102 }
103
104 // Print results
105 //
106 if (IsMaster())
107 {
108 G4cout
109 << G4endl
110 << "--------------------End of Global Run-----------------------"
111 << G4endl
112 << " The run was " << nofEvents << " events ";
113 }
114 else
115 {
116 G4cout
117 << G4endl
118 << "--------------------End of Local Run------------------------"
119 << G4endl
120 << " The run was " << nofEvents << " "<< partName;
121 }
122 G4cout
123 << "; Nb of 'good' e+ annihilations: " << fGoodEvents.GetValue() << G4endl
124 << " Total dose in patient : " << G4BestUnit(fSumDose.GetValue(),"Dose")
125 << G4endl
126 << "------------------------------------------------------------" << G4endl
127 << G4endl;
128}
129
130//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
131
132}
133
The primary generator action class with particle gum.
void BeginOfRunAction(const G4Run *) override
Definition RunAction.cc:68
G4Accumulable< G4double > fSumDose
Definition RunAction.hh:56
void EndOfRunAction(const G4Run *) override
Definition RunAction.cc:82
G4Accumulable< G4int > fGoodEvents
Definition RunAction.hh:55

Applications | User Support | Publications | Collaboration