File indexing completed on 2025-02-23 09:22:11
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 #include "RunAction.hh"
0027
0028 #include "Run.hh"
0029
0030 #include "G4AnalysisManager.hh"
0031 #include "G4DNAEventScheduler.hh"
0032 #include "G4DNAScavengerMaterial.hh"
0033 #include "G4Run.hh"
0034 #include "G4RunManager.hh"
0035 #include "G4Scheduler.hh"
0036 #include "G4SystemOfUnits.hh"
0037 #include "G4VChemistryWorld.hh"
0038
0039
0040 RunAction::RunAction() : G4UserRunAction() {}
0041
0042
0043 void RunAction::SetEventScheduler(G4DNAEventScheduler* pEventScheduler)
0044 {
0045 fpEventScheduler = pEventScheduler;
0046 }
0047
0048
0049 G4Run* RunAction::GenerateRun()
0050 {
0051 Run* run = new Run();
0052 return run;
0053 }
0054
0055
0056
0057 void RunAction::BeginOfRunAction(const G4Run* run)
0058 {
0059 G4cout << "### Run " << run->GetRunID() << " starts." << G4endl;
0060 if (G4Threading::IsMultithreadedApplication() && IsMaster()) {
0061 return;
0062 }
0063 auto runInfo = dynamic_cast<const Run*>(run);
0064 auto GvaluesScorer = dynamic_cast<Scorer<Gvalues>*>(runInfo->GetGvaluesScorer());
0065
0066 if (fpEventScheduler != nullptr) {
0067 for (const auto& it : GvaluesScorer->GetpScorer()->fTimeToRecord) {
0068 fpEventScheduler->AddTimeToRecord(it);
0069 }
0070 }
0071 GvaluesScorer->SetEventScheduler(fpEventScheduler);
0072 }
0073
0074
0075
0076 void RunAction::EndOfRunAction(const G4Run* run)
0077 {
0078 G4int nofEvents = run->GetNumberOfEvent();
0079 if (nofEvents == 0) {
0080 return;
0081 }
0082 auto chem6Run = dynamic_cast<const Run*>(run);
0083 G4double sumDose = chem6Run->GetSumDose();
0084
0085 if (G4Threading::IsMultithreadedApplication() && IsMaster()) {
0086 G4cout << G4endl << "--------------------------End of Global Run------------------------------"
0087 << G4endl << "The run has " << nofEvents << " events " << G4endl;
0088
0089 auto masterGvaluesScorer = dynamic_cast<Scorer<Gvalues>*>(chem6Run->GetGvaluesScorer());
0090
0091 auto masterDoseLimite = dynamic_cast<Scorer<Dose>*>(chem6Run->GetSumDoseLimit());
0092
0093 G4cout << "Number of events recorded by the species scorer : "
0094 << masterGvaluesScorer->GetpScorer()->GetNumberOfRecordedEvents() << " events "
0095 << G4endl;
0096 G4double dose_mean = masterDoseLimite->GetpScorer()->fDosesCutOff / gray;
0097 auto boundingBox = masterDoseLimite->GetChemistryWorld()->GetChemistryBoundary();
0098 G4double V = boundingBox->Volume() / cm3;
0099 G4double DoseInGray = (sumDose / eV) / (0.001 * V * 6.242e+18);
0100 G4cout << "Cut-off dose for each beam line : " << dose_mean << " Gy " << G4endl;
0101 G4cout << "Actual dose : " << DoseInGray << " Gy for " << nofEvents
0102 << " events. Actual average dose : " << DoseInGray / nofEvents << " Gy" << G4endl;
0103 masterGvaluesScorer->OutputAndClear(std::to_string(dose_mean));
0104 }
0105 else {
0106 G4cout << G4endl << "--------------------------End of Local Run------------------------------"
0107 << G4endl << "The run has " << nofEvents << " events. Scavenger info:" << G4endl;
0108 auto pScavengerMaterial =
0109 dynamic_cast<G4DNAScavengerMaterial*>(G4Scheduler::Instance()->GetScavengerMaterial());
0110 pScavengerMaterial->PrintInfo();
0111 }
0112
0113 G4cout << "Total energy deposited in the world volume : " << sumDose / keV << " keV" << G4endl
0114 << "-------------------------------------------------------------------------" << G4endl
0115 << G4endl;
0116 }
0117
0118