Warning, file /geant4/examples/extended/medical/dna/chem6/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
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043 #include "RunAction.hh"
0044
0045 #include "Run.hh"
0046
0047 #include "G4Run.hh"
0048 #include "G4RunManager.hh"
0049 #include "G4SystemOfUnits.hh"
0050 #include "G4UnitsTable.hh"
0051 #include "G4DNAChemistryManager.hh"
0052
0053
0054
0055 extern std::ofstream out;
0056
0057
0058
0059 G4Run *RunAction::GenerateRun() {
0060 const auto run = new Run();
0061 return run;
0062 }
0063
0064
0065
0066 void RunAction::BeginOfRunAction(const G4Run *run) {
0067
0068 if (G4DNAChemistryManager::GetInstanceIfExists() != nullptr)
0069 G4DNAChemistryManager::GetInstanceIfExists()->BeginOfRunAction(run);
0070 G4cout << "### Run " << run->GetRunID() << " starts." << G4endl;
0071
0072
0073 G4RunManager::GetRunManager()->SetRandomNumberStore(false);
0074 }
0075
0076
0077
0078 void RunAction::EndOfRunAction(const G4Run *run) {
0079
0080 if (G4DNAChemistryManager::GetInstanceIfExists() != nullptr)
0081 G4DNAChemistryManager::GetInstanceIfExists()->EndOfRunAction(run);
0082
0083 const G4int nofEvents = run->GetNumberOfEvent();
0084 if (nofEvents == 0) { return; }
0085
0086
0087
0088 const auto chem6Run = static_cast<const Run *>(run);
0089 const G4double sumDose = chem6Run->GetSumDose();
0090
0091
0092
0093 if (IsMaster()) {
0094 G4cout << G4endl << "--------------------End of Global Run-----------------------" << G4endl
0095 << " The run has " << nofEvents << " events " << G4endl;
0096
0097 ScoreSpecies *masterScorer = dynamic_cast<ScoreSpecies *>(chem6Run->GetPrimitiveScorer());
0098
0099 G4cout << "Number of events recorded by the species scorer = "
0100 << masterScorer->GetNumberOfRecordedEvents() << G4endl;
0101
0102
0103 const auto aRun = (Run *) run;
0104 const G4THitsMap<G4double> *totLET = aRun->GetLET();
0105 const G4int nOfEvent = totLET->entries();
0106 G4double LET_mean = 0;
0107 G4double LET_square = 0;
0108 for (G4int i = 0; i < nOfEvent; i++) {
0109 const G4double *LET = (*totLET)[i];
0110 if (!LET) continue;
0111 LET_mean += *LET;
0112 LET_square += (*LET) * (*LET);
0113 }
0114 LET_mean /= nOfEvent;
0115 LET_square = std::sqrt(LET_square / nOfEvent - std::pow(LET_mean, 2));
0116
0117 if (nOfEvent > 1) {
0118 out << std::setw(12) << "LET" << std::setw(12) << LET_mean << std::setw(12) << "LET_SD"
0119 << std::setw(12) << LET_square / (nOfEvent - 1) << '\n';
0120 } else {
0121 out << std::setw(12) << "LET" << std::setw(12) << LET_mean << std::setw(12) << "LET_SD"
0122 << std::setw(12) << LET_square << '\n';
0123 }
0124
0125 masterScorer->OutputAndClear();
0126
0127 out << '\n';
0128 } else {
0129 G4cout << G4endl << "--------------------End of Local Run------------------------" << G4endl
0130 << " The run has " << nofEvents << " events" << G4endl;
0131 }
0132
0133 G4cout << " Total energy deposited in the world volume : " << sumDose / eV << " eV" << G4endl
0134 << " ------------------------------------------------------------" << G4endl << G4endl;
0135 }
0136
0137