ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
B3aRunAction.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file B3aRunAction.cc
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 //
29 
30 #include "B3aRunAction.hh"
31 #include "B3PrimaryGeneratorAction.hh"
32 
33 #include "G4RunManager.hh"
34 #include "G4Run.hh"
35 #include "G4AccumulableManager.hh"
36 #include "G4UnitsTable.hh"
37 #include "G4SystemOfUnits.hh"
38 
39 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
40 
42  : G4UserRunAction(),
43  fGoodEvents(0),
44  fSumDose(0.)
45 {
46  //add new units for dose
47  //
48  const G4double milligray = 1.e-3*gray;
49  const G4double microgray = 1.e-6*gray;
50  const G4double nanogray = 1.e-9*gray;
51  const G4double picogray = 1.e-12*gray;
52 
53  new G4UnitDefinition("milligray", "milliGy" , "Dose", milligray);
54  new G4UnitDefinition("microgray", "microGy" , "Dose", microgray);
55  new G4UnitDefinition("nanogray" , "nanoGy" , "Dose", nanogray);
56  new G4UnitDefinition("picogray" , "picoGy" , "Dose", picogray);
57 
58  // Register accumulable to the accumulable manager
60  accumulableManager->RegisterAccumulable(fGoodEvents);
61  accumulableManager->RegisterAccumulable(fSumDose);
62 }
63 
64 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
65 
67 { }
68 
69 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
70 
72 {
73  G4cout << "### Run " << run->GetRunID() << " start." << G4endl;
74 
75  // reset accumulables to their initial values
77  accumulableManager->Reset();
78 
79  //inform the runManager to save random number seed
81 }
82 
83 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
84 
86 {
87  G4int nofEvents = run->GetNumberOfEvent();
88  if (nofEvents == 0) return;
89 
90  // Merge accumulables
92  accumulableManager->Merge();
93 
94  // Run conditions
95  // note: There is no primary generator action object for "master"
96  // run manager for multi-threaded mode.
97  const B3PrimaryGeneratorAction* generatorAction
98  = static_cast<const B3PrimaryGeneratorAction*>(
100  G4String partName;
101  if (generatorAction)
102  {
104  = generatorAction->GetParticleGun()->GetParticleDefinition();
105  partName = particle->GetParticleName();
106  }
107 
108  // Print results
109  //
110  if (IsMaster())
111  {
112  G4cout
113  << G4endl
114  << "--------------------End of Global Run-----------------------"
115  << G4endl
116  << " The run was " << nofEvents << " events ";
117  }
118  else
119  {
120  G4cout
121  << G4endl
122  << "--------------------End of Local Run------------------------"
123  << G4endl
124  << " The run was " << nofEvents << " "<< partName;
125  }
126  G4cout
127  << "; Nb of 'good' e+ annihilations: " << fGoodEvents.GetValue() << G4endl
128  << " Total dose in patient : " << G4BestUnit(fSumDose.GetValue(),"Dose")
129  << G4endl
130  << "------------------------------------------------------------" << G4endl
131  << G4endl;
132 }
133 
134 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......