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