File indexing completed on 2025-01-31 09:22:18
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 #include "HadrontherapyRunAction.hh"
0030 #include "HadrontherapyEventAction.hh"
0031 #include "G4AnalysisManager.hh"
0032 #include "G4Run.hh"
0033 #include "G4RunManager.hh"
0034 #include "G4UImanager.hh"
0035 #include "G4ios.hh"
0036 #include "HadrontherapyDetectorConstruction.hh"
0037 #include "G4SDManager.hh"
0038 #include "G4Timer.hh"
0039 #include "HadrontherapyRunAction.hh"
0040 #include "HadrontherapyMatrix.hh"
0041 #include "HadrontherapyRBE.hh"
0042 #include "G4UnitsTable.hh"
0043 #include "G4SystemOfUnits.hh"
0044
0045 #include <G4AccumulableManager.hh>
0046
0047
0048 HadrontherapyRunAction::HadrontherapyRunAction()
0049 {
0050 G4AccumulableManager* accumulableManager = G4AccumulableManager::Instance();
0051 accumulableManager->RegisterAccumulable(&fRBEAccumulable);
0052
0053 }
0054
0055
0056 HadrontherapyRunAction::~HadrontherapyRunAction()
0057 {
0058 }
0059
0060
0061 void HadrontherapyRunAction::BeginOfRunAction(const G4Run* aRun)
0062 {
0063 G4AccumulableManager* accumulableManager = G4AccumulableManager::Instance();
0064 accumulableManager->Reset();
0065
0066 G4RunManager::GetRunManager()-> SetRandomNumberStore(true);
0067 G4cout << "Run " << aRun -> GetRunID() << " starts ..." << G4endl;
0068
0069 HadrontherapyRBE *rbe = HadrontherapyRBE::GetInstance();
0070 if (rbe->IsCalculationEnabled() && IsMaster() && rbe->GetVerboseLevel() > 0)
0071 {
0072 rbe->PrintParameters();
0073 }
0074
0075 electromagnetic = 0;
0076 hadronic = 0;
0077 }
0078
0079
0080 void HadrontherapyRunAction::EndOfRunAction(const G4Run*)
0081 {
0082 auto analysisManager = G4AnalysisManager::Instance();
0083
0084 G4AccumulableManager* accumulableManager = G4AccumulableManager::Instance();
0085 accumulableManager->Merge();
0086
0087
0088 HadrontherapyRBE *rbe = HadrontherapyRBE::GetInstance();
0089 if (rbe->IsCalculationEnabled() && IsMaster())
0090 {
0091 if (rbe->IsAccumulationEnabled())
0092 {
0093 rbe->AddAlphaNumerator(fRBEAccumulable.GetAlphaNumerator());
0094 rbe->AddBetaNumerator(fRBEAccumulable.GetBetaNumerator());
0095 rbe->AddDenominator(fRBEAccumulable.GetDenominator());
0096 rbe->AddEnergyDeposit(fRBEAccumulable.GetEnergyDeposit());
0097 }
0098 else
0099 {
0100 rbe->SetAlphaNumerator(fRBEAccumulable.GetAlphaNumerator());
0101 rbe->SetBetaNumerator(fRBEAccumulable.GetBetaNumerator());
0102 rbe->SetDenominator(fRBEAccumulable.GetDenominator());
0103 rbe->SetEnergyDeposit(fRBEAccumulable.GetEnergyDeposit());
0104 }
0105
0106 rbe->StoreAlphaAndBeta();
0107 rbe->StoreRBE();
0108 }
0109
0110 if (analysisManager->IsOpenFile()) {
0111 analysisManager->Write();
0112 analysisManager->CloseFile();
0113 }
0114 }
0115
0116 void HadrontherapyRunAction::AddEMProcess()
0117 {
0118 electromagnetic += 1;
0119 }
0120
0121
0122 void HadrontherapyRunAction::AddHadronicProcess()
0123 {
0124 hadronic += 1;
0125 }