Warning, file /geant4/examples/basic/B3/B3b/src/RunAction.cc was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
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 "RunAction.hh"
0031
0032 #include "PrimaryGeneratorAction.hh"
0033 #include "Run.hh"
0034
0035 #include "G4ParticleGun.hh"
0036 #include "G4Run.hh"
0037 #include "G4RunManager.hh"
0038 #include "G4SystemOfUnits.hh"
0039 #include "G4UnitsTable.hh"
0040
0041 using namespace B3;
0042
0043 namespace B3b
0044 {
0045
0046
0047
0048 RunAction::RunAction()
0049 {
0050
0051
0052 const G4double milligray = 1.e-3 * gray;
0053 const G4double microgray = 1.e-6 * gray;
0054 const G4double nanogray = 1.e-9 * gray;
0055 const G4double picogray = 1.e-12 * gray;
0056
0057 new G4UnitDefinition("milligray", "milliGy", "Dose", milligray);
0058 new G4UnitDefinition("microgray", "microGy", "Dose", microgray);
0059 new G4UnitDefinition("nanogray", "nanoGy", "Dose", nanogray);
0060 new G4UnitDefinition("picogray", "picoGy", "Dose", picogray);
0061 }
0062
0063
0064
0065 G4Run* RunAction::GenerateRun()
0066 {
0067 return new Run;
0068 }
0069
0070
0071
0072 void RunAction::BeginOfRunAction(const G4Run* run)
0073 {
0074 G4cout << "### Run " << run->GetRunID() << " start." << G4endl;
0075
0076
0077 G4RunManager::GetRunManager()->SetRandomNumberStore(false);
0078 }
0079
0080
0081
0082 void RunAction::EndOfRunAction(const G4Run* run)
0083 {
0084 G4int nofEvents = run->GetNumberOfEvent();
0085 if (nofEvents == 0) return;
0086
0087
0088
0089
0090 const auto generatorAction = static_cast<const PrimaryGeneratorAction*>(
0091 G4RunManager::GetRunManager()->GetUserPrimaryGeneratorAction());
0092 G4String partName;
0093 if (generatorAction) {
0094 G4ParticleDefinition* particle = generatorAction->GetParticleGun()->GetParticleDefinition();
0095 partName = particle->GetParticleName();
0096 }
0097
0098
0099
0100 const Run* b3Run = static_cast<const Run*>(run);
0101 G4int nbGoodEvents = b3Run->GetNbGoodEvents();
0102 G4double sumDose = b3Run->GetSumDose();
0103 G4StatAnalysis statDose = b3Run->GetStatDose();
0104
0105
0106
0107 if (IsMaster()) {
0108 G4cout << G4endl << "--------------------End of Global Run-----------------------" << G4endl
0109 << " The run was " << nofEvents << " events ";
0110 }
0111 else {
0112 G4cout << G4endl << "--------------------End of Local Run------------------------" << G4endl
0113 << " The run was " << nofEvents << " " << partName;
0114 }
0115 statDose /= gray;
0116 G4cout << "; Nb of 'good' e+ annihilations: " << nbGoodEvents << G4endl
0117 << " Total dose in patient : " << G4BestUnit(sumDose, "Dose") << G4endl
0118 << " Total dose in patient : " << statDose << " Gy" << G4endl
0119 << "------------------------------------------------------------" << G4endl << G4endl;
0120 }
0121
0122
0123
0124 }