File indexing completed on 2026-05-05 08:06:23
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 "RE02RunAction.hh"
0030
0031 #include "RE02Run.hh"
0032
0033
0034 #include "RE02DetectorConstruction.hh"
0035
0036 #include "G4RunManager.hh"
0037 #include "G4SystemOfUnits.hh"
0038 #include "G4THitsMap.hh"
0039 #include "G4UnitsTable.hh"
0040
0041 #include <fstream>
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051 RE02RunAction::RE02RunAction() : G4UserRunAction(), fNx(0), fNy(0), fNz(0)
0052 {
0053
0054
0055 fSDName.push_back(G4String("PhantomSD"));
0056 }
0057
0058
0059
0060 RE02RunAction::~RE02RunAction()
0061 {
0062 fSDName.clear();
0063 }
0064
0065
0066
0067 G4Run* RE02RunAction::GenerateRun()
0068 {
0069
0070
0071
0072 return new RE02Run(fSDName);
0073 }
0074
0075
0076
0077 void RE02RunAction::BeginOfRunAction(const G4Run* aRun)
0078 {
0079 G4cout << "### Run " << aRun->GetRunID() << " start." << G4endl;
0080 }
0081
0082
0083
0084 void RE02RunAction::EndOfRunAction(const G4Run* aRun)
0085 {
0086 if (!IsMaster()) return;
0087
0088
0089 RE02Run* re02Run = (RE02Run*)aRun;
0090
0091 re02Run->DumpAllScorer();
0092
0093
0094
0095
0096
0097 const RE02DetectorConstruction* detector =
0098 (const RE02DetectorConstruction*)(G4RunManager::GetRunManager()->GetUserDetectorConstruction());
0099 detector->GetNumberOfSegmentsInPhantom(fNx, fNy, fNz);
0100
0101
0102
0103
0104
0105 G4THitsMap<G4double>* totEdep = re02Run->GetHitsMap("PhantomSD/totalEDep");
0106 G4THitsMap<G4double>* proEdep = re02Run->GetHitsMap("PhantomSD/protonEDep");
0107 G4THitsMap<G4double>* proNstep = re02Run->GetHitsMap("PhantomSD/protonNStep");
0108 G4THitsMap<G4double>* passCFx = re02Run->GetHitsMap("PhantomSD/chargedPassCellFlux");
0109 G4THitsMap<G4double>* cFx = re02Run->GetHitsMap("PhantomSD/chargedCellFlux");
0110 G4THitsMap<G4double>* surfFx = re02Run->GetHitsMap("PhantomSD/chargedSurfFlux");
0111 G4THitsMap<G4double>* gCurr00 = re02Run->GetHitsMap("PhantomSD/gammaSurfCurr000");
0112 G4THitsMap<G4double>* gCurr01 = re02Run->GetHitsMap("PhantomSD/gammaSurfCurr001");
0113 G4THitsMap<G4double>* gCurr02 = re02Run->GetHitsMap("PhantomSD/gammaSurfCurr002");
0114 G4THitsMap<G4double>* gCurr03 = re02Run->GetHitsMap("PhantomSD/gammaSurfCurr003");
0115
0116 G4cout << "=============================================================" << G4endl;
0117 G4cout << " Number of event processed : " << aRun->GetNumberOfEvent() << G4endl;
0118 G4cout << "=============================================================" << G4endl;
0119 G4cout << std::setw(8) << "#Z Cell#";
0120 G4cout << std::setw(16) << totEdep->GetName();
0121 G4cout << std::setw(16) << proEdep->GetName();
0122 G4cout << std::setw(12) << proNstep->GetName();
0123 G4cout << std::setw(21) << passCFx->GetName();
0124 G4cout << std::setw(20) << cFx->GetName();
0125 G4cout << std::setw(20) << surfFx->GetName();
0126 G4cout << std::setw(20) << gCurr00->GetName();
0127 G4cout << std::setw(20) << gCurr01->GetName();
0128 G4cout << std::setw(20) << gCurr02->GetName();
0129 G4cout << std::setw(20) << gCurr03->GetName() << G4endl;
0130 G4int ix = fNx / 2;
0131 G4int iy = fNy / 2;
0132 G4int iz;
0133
0134 for (iz = 0; iz < fNz; iz++) {
0135 G4double* totED = (*totEdep)[CopyNo(ix, iy, iz)];
0136 G4double* proED = (*proEdep)[CopyNo(ix, iy, iz)];
0137 G4double* proNS = (*proNstep)[CopyNo(ix, iy, iz)];
0138 G4double* pasCF = (*passCFx)[CopyNo(ix, iy, iz)];
0139 G4double* cF = (*cFx)[CopyNo(ix, iy, iz)];
0140 G4double* sfx = (*surfFx)[CopyNo(ix, iy, iz)];
0141 G4double* gcur0 = (*gCurr00)[CopyNo(ix, iy, iz)];
0142 G4double* gcur1 = (*gCurr01)[CopyNo(ix, iy, iz)];
0143 G4double* gcur2 = (*gCurr02)[CopyNo(ix, iy, iz)];
0144 G4double* gcur3 = (*gCurr03)[CopyNo(ix, iy, iz)];
0145 if (!totED) totED = new G4double(0.0);
0146 if (!proED) proED = new G4double(0.0);
0147 if (!proNS) proNS = new G4double(0.0);
0148 if (!pasCF) pasCF = new G4double(0.0);
0149 if (!cF) cF = new G4double(0.0);
0150 if (!sfx) sfx = new G4double(0.0);
0151 if (!gcur0) gcur0 = new G4double(0.0);
0152 if (!gcur1) gcur1 = new G4double(0.0);
0153 if (!gcur2) gcur2 = new G4double(0.0);
0154 if (!gcur3) gcur3 = new G4double(0.0);
0155 G4cout << std::setw(6) << iz << " " << std::setw(12) << G4BestUnit(*totED, "Energy")
0156 << std::setw(12) << G4BestUnit(*proED, "Energy") << std::setw(12) << (*proNS) << " "
0157 << std::setw(13) << (*pasCF) * cm * cm << " /cm2" << std::setw(15) << (*cF) * cm * cm
0158 << " /cm2" << std::setw(15) << (*sfx) * cm * cm << " /cm2" << std::setw(15)
0159 << (*gcur0) * cm * cm << " /cm2" << std::setw(15) << (*gcur1) * cm * cm << " /cm2"
0160 << std::setw(15) << (*gcur2) * cm * cm << " /cm2" << std::setw(15) << (*gcur3) * cm * cm
0161 << " /cm2" << G4endl;
0162 }
0163 G4cout << "=============================================" << G4endl;
0164
0165 std::ofstream file("totED.txt");
0166 for (iz = 0; iz < fNz; iz++) {
0167 for (iy = 0; iy < fNy; iy++) {
0168 for (ix = 0; ix < fNx; ix++) {
0169 G4double* totED = (*totEdep)[CopyNo(ix, iy, iz)];
0170 if (!totED) totED = new G4double(0.0);
0171 file << ix << " " << iy << " " << iz << " " << *totED / MeV << G4endl;
0172 }
0173 }
0174 }
0175 file.close();
0176 }
0177
0178