Geant4 Cross Reference |
1 // 1 2 // ******************************************* 3 // * License and Disclaimer 4 // * 5 // * The Geant4 software is copyright of th 6 // * the Geant4 Collaboration. It is provided 7 // * conditions of the Geant4 Software License 8 // * LICENSE and available at http://cern.ch/ 9 // * include a list of copyright holders. 10 // * 11 // * Neither the authors of this software syst 12 // * institutes,nor the agencies providing fin 13 // * work make any representation or warran 14 // * regarding this software system or assum 15 // * use. Please see the license in the file 16 // * for the full disclaimer and the limitatio 17 // * 18 // * This code implementation is the result 19 // * technical work of the GEANT4 collaboratio 20 // * By using, copying, modifying or distri 21 // * any work based on the software) you ag 22 // * use in resulting scientific publicati 23 // * acceptance of all terms of the Geant4 Sof 24 // ******************************************* 25 // 26 // 27 /// \file B1/src/RunAction.cc 28 /// \brief Implementation of the B1::RunAction 29 30 #include "RunAction.hh" 31 32 #include "DetectorConstruction.hh" 33 #include "PrimaryGeneratorAction.hh" 34 35 #include "G4AccumulableManager.hh" 36 #include "G4LogicalVolume.hh" 37 #include "G4ParticleDefinition.hh" 38 #include "G4ParticleGun.hh" 39 #include "G4Run.hh" 40 #include "G4RunManager.hh" 41 #include "G4SystemOfUnits.hh" 42 #include "G4UnitsTable.hh" 43 44 namespace B1 45 { 46 47 //....oooOO0OOooo........oooOO0OOooo........oo 48 49 RunAction::RunAction() 50 { 51 // add new units for dose 52 // 53 const G4double milligray = 1.e-3 * gray; 54 const G4double microgray = 1.e-6 * gray; 55 const G4double nanogray = 1.e-9 * gray; 56 const G4double picogray = 1.e-12 * gray; 57 58 new G4UnitDefinition("milligray", "milliGy", 59 new G4UnitDefinition("microgray", "microGy", 60 new G4UnitDefinition("nanogray", "nanoGy", " 61 new G4UnitDefinition("picogray", "picoGy", " 62 63 // Register accumulable to the accumulable m 64 G4AccumulableManager* accumulableManager = G 65 accumulableManager->Register(fEdep); 66 accumulableManager->Register(fEdep2); 67 } 68 69 //....oooOO0OOooo........oooOO0OOooo........oo 70 71 void RunAction::BeginOfRunAction(const G4Run*) 72 { 73 // inform the runManager to save random numb 74 G4RunManager::GetRunManager()->SetRandomNumb 75 76 // reset accumulables to their initial value 77 G4AccumulableManager* accumulableManager = G 78 accumulableManager->Reset(); 79 } 80 81 //....oooOO0OOooo........oooOO0OOooo........oo 82 83 void RunAction::EndOfRunAction(const G4Run* ru 84 { 85 G4int nofEvents = run->GetNumberOfEvent(); 86 if (nofEvents == 0) return; 87 88 // Merge accumulables 89 G4AccumulableManager* accumulableManager = G 90 accumulableManager->Merge(); 91 92 // Compute dose = total energy deposit in a 93 // 94 G4double edep = fEdep.GetValue(); 95 G4double edep2 = fEdep2.GetValue(); 96 97 G4double rms = edep2 - edep * edep / nofEven 98 if (rms > 0.) 99 rms = std::sqrt(rms); 100 else 101 rms = 0.; 102 103 const auto detConstruction = static_cast<con 104 G4RunManager::GetRunManager()->GetUserDete 105 G4double mass = detConstruction->GetScoringV 106 G4double dose = edep / mass; 107 G4double rmsDose = rms / mass; 108 109 // Run conditions 110 // note: There is no primary generator acti 111 // run manager for multi-threaded mod 112 const auto generatorAction = static_cast<con 113 G4RunManager::GetRunManager()->GetUserPrim 114 G4String runCondition; 115 if (generatorAction) { 116 const G4ParticleGun* particleGun = generat 117 runCondition += particleGun->GetParticleDe 118 runCondition += " of "; 119 G4double particleEnergy = particleGun->Get 120 runCondition += G4BestUnit(particleEnergy, 121 } 122 123 // Print 124 // 125 if (IsMaster()) { 126 G4cout << G4endl << "--------------------E 127 } 128 else { 129 G4cout << G4endl << "--------------------E 130 } 131 132 G4cout << G4endl << " The run consists of " 133 << " Cumulated dose per run, in scori 134 << " rms = " << G4BestUnit(rmsDose, " 135 << "--------------------------------- 136 } 137 138 //....oooOO0OOooo........oooOO0OOooo........oo 139 140 void RunAction::AddEdep(G4double edep) 141 { 142 fEdep += edep; 143 fEdep2 += edep * edep; 144 } 145 146 //....oooOO0OOooo........oooOO0OOooo........oo 147 148 } // namespace B1 149