Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // >> 26 // $Id: B1RunAction.cc 69587 2013-05-08 14:26:03Z gcosmo $ 26 // 27 // 27 /// \file B1RunAction.cc 28 /// \file B1RunAction.cc 28 /// \brief Implementation of the B1RunAction c 29 /// \brief Implementation of the B1RunAction class 29 30 30 #include "B1RunAction.hh" 31 #include "B1RunAction.hh" 31 << 32 #include "B1DetectorConstruction.hh" << 33 #include "B1PrimaryGeneratorAction.hh" 32 #include "B1PrimaryGeneratorAction.hh" 34 #include "B1Run.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 35 39 36 #include "G4LogicalVolume.hh" << 40 #include "G4Run.hh" 37 #include "G4LogicalVolumeStore.hh" << 38 #include "G4RunManager.hh" 41 #include "G4RunManager.hh" 39 #include "G4SystemOfUnits.hh" << 40 #include "G4UnitsTable.hh" 42 #include "G4UnitsTable.hh" >> 43 #include "G4SystemOfUnits.hh" 41 44 42 //....oooOO0OOooo........oooOO0OOooo........oo 45 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 43 46 44 B1RunAction::B1RunAction() : G4UserRunAction() << 47 B1RunAction::B1RunAction() >> 48 : G4UserRunAction() 45 { 49 { 46 // add new units for dose 50 // add new units for dose 47 // << 51 // 48 const G4double milligray = 1.e-3 * gray; << 52 const G4double milligray = 1.e-3*gray; 49 const G4double microgray = 1.e-6 * gray; << 53 const G4double microgray = 1.e-6*gray; 50 const G4double nanogray = 1.e-9 * gray; << 54 const G4double nanogray = 1.e-9*gray; 51 const G4double picogray = 1.e-12 * gray; << 55 const G4double picogray = 1.e-12*gray; 52 << 56 53 new G4UnitDefinition("milligray", "milliGy", << 57 new G4UnitDefinition("milligray", "milliGy" , "Dose", milligray); 54 new G4UnitDefinition("microgray", "microGy", << 58 new G4UnitDefinition("microgray", "microGy" , "Dose", microgray); 55 new G4UnitDefinition("nanogray", "nanoGy", " << 59 new G4UnitDefinition("nanogray" , "nanoGy" , "Dose", nanogray); 56 new G4UnitDefinition("picogray", "picoGy", " << 60 new G4UnitDefinition("picogray" , "picoGy" , "Dose", picogray); 57 } 61 } 58 62 59 //....oooOO0OOooo........oooOO0OOooo........oo 63 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 60 64 61 B1RunAction::~B1RunAction() {} << 65 B1RunAction::~B1RunAction() >> 66 {} 62 67 63 //....oooOO0OOooo........oooOO0OOooo........oo 68 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 64 69 65 G4Run* B1RunAction::GenerateRun() << 70 void B1RunAction::BeginOfRunAction(const G4Run* aRun) 66 { << 71 { 67 return new B1Run; << 72 G4cout << "### Run " << aRun->GetRunID() << " start." << G4endl; 68 } << 69 << 70 //....oooOO0OOooo........oooOO0OOooo........oo << 71 73 72 void B1RunAction::BeginOfRunAction(const G4Run << 74 //inform the runManager to save random number seed 73 { << 74 // inform the runManager to save random numb << 75 G4RunManager::GetRunManager()->SetRandomNumb 75 G4RunManager::GetRunManager()->SetRandomNumberStore(false); >> 76 >> 77 //initialize event cumulative quantities >> 78 B1EventAction::Instance()->Reset(); 76 } 79 } 77 80 78 //....oooOO0OOooo........oooOO0OOooo........oo 81 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 79 82 80 void B1RunAction::EndOfRunAction(const G4Run* << 83 void B1RunAction::EndOfRunAction(const G4Run* aRun) 81 { 84 { 82 G4int nofEvents = run->GetNumberOfEvent(); << 85 G4int nofEvents = aRun->GetNumberOfEvent(); 83 if (nofEvents == 0) return; 86 if (nofEvents == 0) return; 84 << 87 85 const B1Run* b1Run = static_cast<const B1Run << 86 << 87 // Compute dose 88 // Compute dose 88 // 89 // 89 G4double edep = b1Run->GetEdep(); << 90 G4double energySum = B1EventAction::Instance()->GetEnergySum(); 90 G4double edep2 = b1Run->GetEdep2(); << 91 G4double energy2Sum = B1EventAction::Instance()->GetEnergy2Sum(); 91 G4double rms = edep2 - edep * edep / nofEven << 92 G4double rms = energy2Sum - energySum*energySum/nofEvents; 92 if (rms > 0.) << 93 if (rms > 0.) rms = std::sqrt(rms); else rms = 0.; 93 rms = std::sqrt(rms); << 94 94 else << 95 G4double mass = B1SteppingAction::Instance()->GetVolume()->GetMass(); 95 rms = 0.; << 96 G4double dose = energySum/mass; 96 << 97 G4double rmsDose = rms/mass; 97 const B1DetectorConstruction* detectorConstr << 98 G4RunManager::GetRunManager()->GetUserDete << 99 G4double mass = detectorConstruction->GetSco << 100 G4double dose = edep / mass; << 101 G4double rmsDose = rms / mass; << 102 98 103 // Run conditions 99 // Run conditions 104 // note: There is no primary generator acti << 105 // run manager for multi-threaded mod << 106 const B1PrimaryGeneratorAction* generatorAct << 107 G4RunManager::GetRunManager()->GetUserPrim << 108 G4String runCondition; << 109 if (generatorAction) { << 110 const G4ParticleGun* particleGun = generat << 111 runCondition += particleGun->GetParticleDe << 112 runCondition += " of "; << 113 G4double particleEnergy = particleGun->Get << 114 runCondition += G4BestUnit(particleEnergy, << 115 } << 116 << 117 // Print << 118 // 100 // 119 if (IsMaster()) { << 101 const G4ParticleGun* particleGun 120 G4cout << "\n--------------------End of Gl << 102 = B1PrimaryGeneratorAction::Instance()->GetParticleGun(); 121 } << 103 G4String particleName 122 else { << 104 = particleGun->GetParticleDefinition()->GetParticleName(); 123 G4cout << "\n--------------------End of Lo << 105 G4double particleEnergy = particleGun->GetParticleEnergy(); 124 } << 106 125 << 107 // Print 126 G4cout << "\n The run consists of " << nofEv << 108 // 127 << "\n Dose in scoring volume : " << << 109 G4cout 128 << G4BestUnit(rmsDose, "Dose") << 110 << "\n--------------------End of Run------------------------------\n" 129 << "\n------------------------------- << 111 << " The run consists of " << nofEvents << " "<< particleName << " of " 130 << G4endl; << 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; 131 } 119 } 132 120 133 //....oooOO0OOooo........oooOO0OOooo........oo 121 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 134 122