Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
extended/visualization/userVisAction/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: B1RunAction.cc 69587 2013-05-08 14:26:03Z gcosmo $
27 //
28 /// \file B1RunAction.cc
29 /// \brief Implementation of the B1RunAction class
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 
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 
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
76 
77  //initialize event cumulative quantities
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  //
92  G4double rms = energy2Sum - energySum*energySum/nofEvents;
93  if (rms > 0.) rms = std::sqrt(rms); else rms = 0.;
94 
96  G4double dose = energySum/mass;
97  G4double rmsDose = rms/mass;
98 
99  // Run conditions
100  //
101  const G4ParticleGun* particleGun
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......
virtual void EndOfRunAction(const G4Run *)
G4String GetName() 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
G4GLOB_DLL std::ostream G4cout
G4int GetNumberOfEvent() const
Definition: G4Run.hh:79
G4int GetRunID() const
Definition: G4Run.hh:76
Definition: G4Run.hh:46
virtual void BeginOfRunAction(const G4Run *)
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:74
G4ParticleDefinition * GetParticleDefinition() const
#define G4endl
Definition: G4ios.hh:61
G4double GetMass(G4bool forced=false, G4bool propagate=true, G4Material *parMaterial=0)
double G4double
Definition: G4Types.hh:76
G4double GetParticleEnergy() const