File indexing completed on 2025-02-23 09:22:48
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030 #include "B1RunAction.hh"
0031
0032 #include "B1DetectorConstruction.hh"
0033 #include "B1PrimaryGeneratorAction.hh"
0034 #include "B1Run.hh"
0035
0036 #include "G4LogicalVolume.hh"
0037 #include "G4LogicalVolumeStore.hh"
0038 #include "G4RunManager.hh"
0039 #include "G4SystemOfUnits.hh"
0040 #include "G4UnitsTable.hh"
0041
0042
0043
0044 B1RunAction::B1RunAction() : G4UserRunAction()
0045 {
0046
0047
0048 const G4double milligray = 1.e-3 * gray;
0049 const G4double microgray = 1.e-6 * gray;
0050 const G4double nanogray = 1.e-9 * gray;
0051 const G4double picogray = 1.e-12 * gray;
0052
0053 new G4UnitDefinition("milligray", "milliGy", "Dose", milligray);
0054 new G4UnitDefinition("microgray", "microGy", "Dose", microgray);
0055 new G4UnitDefinition("nanogray", "nanoGy", "Dose", nanogray);
0056 new G4UnitDefinition("picogray", "picoGy", "Dose", picogray);
0057 }
0058
0059
0060
0061 B1RunAction::~B1RunAction() {}
0062
0063
0064
0065 G4Run* B1RunAction::GenerateRun()
0066 {
0067 return new B1Run;
0068 }
0069
0070
0071
0072 void B1RunAction::BeginOfRunAction(const G4Run*)
0073 {
0074
0075 G4RunManager::GetRunManager()->SetRandomNumberStore(false);
0076 }
0077
0078
0079
0080 void B1RunAction::EndOfRunAction(const G4Run* run)
0081 {
0082 G4int nofEvents = run->GetNumberOfEvent();
0083 if (nofEvents == 0) return;
0084
0085 const B1Run* b1Run = static_cast<const B1Run*>(run);
0086
0087
0088
0089 G4double edep = b1Run->GetEdep();
0090 G4double edep2 = b1Run->GetEdep2();
0091 G4double rms = edep2 - edep * edep / nofEvents;
0092 if (rms > 0.)
0093 rms = std::sqrt(rms);
0094 else
0095 rms = 0.;
0096
0097 const B1DetectorConstruction* detectorConstruction = static_cast<const B1DetectorConstruction*>(
0098 G4RunManager::GetRunManager()->GetUserDetectorConstruction());
0099 G4double mass = detectorConstruction->GetScoringVolume()->GetMass();
0100 G4double dose = edep / mass;
0101 G4double rmsDose = rms / mass;
0102
0103
0104
0105
0106 const B1PrimaryGeneratorAction* generatorAction = static_cast<const B1PrimaryGeneratorAction*>(
0107 G4RunManager::GetRunManager()->GetUserPrimaryGeneratorAction());
0108 G4String runCondition;
0109 if (generatorAction) {
0110 const G4ParticleGun* particleGun = generatorAction->GetParticleGun();
0111 runCondition += particleGun->GetParticleDefinition()->GetParticleName();
0112 runCondition += " of ";
0113 G4double particleEnergy = particleGun->GetParticleEnergy();
0114 runCondition += G4BestUnit(particleEnergy, "Energy");
0115 }
0116
0117
0118
0119 if (IsMaster()) {
0120 G4cout << "\n--------------------End of Global Run-----------------------";
0121 }
0122 else {
0123 G4cout << "\n--------------------End of Local Run------------------------";
0124 }
0125
0126 G4cout << "\n The run consists of " << nofEvents << " " << runCondition
0127 << "\n Dose in scoring volume : " << G4BestUnit(dose, "Dose") << " +- "
0128 << G4BestUnit(rmsDose, "Dose")
0129 << "\n------------------------------------------------------------\n"
0130 << G4endl;
0131 }
0132
0133