Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 /// \file runAndEvent/RE02/src/RE02RunAction.c 26 /// \file runAndEvent/RE02/src/RE02RunAction.cc 27 /// \brief Implementation of the RE02RunAction 27 /// \brief Implementation of the RE02RunAction class 28 // 28 // 29 // 29 // 30 // << 30 // $Id: RE02RunAction.cc 75682 2013-11-05 09:11:19Z gcosmo $ >> 31 // 31 #include "RE02RunAction.hh" 32 #include "RE02RunAction.hh" 32 << 33 #include "RE02Run.hh" 33 #include "RE02Run.hh" 34 34 35 //-- In order to obtain detector information. 35 //-- In order to obtain detector information. 36 #include "RE02DetectorConstruction.hh" << 37 << 38 #include "G4RunManager.hh" 36 #include "G4RunManager.hh" 39 #include "G4SystemOfUnits.hh" << 37 #include "RE02DetectorConstruction.hh" 40 #include "G4THitsMap.hh" 38 #include "G4THitsMap.hh" >> 39 41 #include "G4UnitsTable.hh" 40 #include "G4UnitsTable.hh" >> 41 #include "G4SystemOfUnits.hh" 42 42 43 #include <fstream> 43 #include <fstream> 44 //============================================ 44 //======================================================================= 45 // RE02RunAction 45 // RE02RunAction 46 // << 46 // 47 // 47 // 48 // 48 // 49 //============================================ 49 //======================================================================= 50 50 51 //....oooOO0OOooo........oooOO0OOooo........oo 51 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 52 // Constructor 52 // Constructor 53 RE02RunAction::RE02RunAction() : G4UserRunActi << 53 RE02RunAction::RE02RunAction() >> 54 : G4UserRunAction(), >> 55 fNx(0), fNy(0), fNz(0) 54 { 56 { 55 // - Prepare data member for RE02Run. 57 // - Prepare data member for RE02Run. 56 // vector represents a list of MultiFuncti 58 // vector represents a list of MultiFunctionalDetector names. 57 fSDName.push_back(G4String("PhantomSD")); 59 fSDName.push_back(G4String("PhantomSD")); 58 } 60 } 59 61 60 //....oooOO0OOooo........oooOO0OOooo........oo 62 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 61 // Destructor. 63 // Destructor. 62 RE02RunAction::~RE02RunAction() 64 RE02RunAction::~RE02RunAction() 63 { 65 { 64 fSDName.clear(); 66 fSDName.clear(); 65 } 67 } 66 68 67 //....oooOO0OOooo........oooOO0OOooo........oo 69 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 68 //== << 70 //== 69 G4Run* RE02RunAction::GenerateRun() 71 G4Run* RE02RunAction::GenerateRun() 70 { 72 { 71 // Generate new RUN object, which is special 73 // Generate new RUN object, which is specially 72 // dedicated for MultiFunctionalDetector sch 74 // dedicated for MultiFunctionalDetector scheme. 73 // Detail description can be found in RE02R 75 // Detail description can be found in RE02Run.hh/cc. 74 return new RE02Run(fSDName); 76 return new RE02Run(fSDName); 75 } 77 } 76 78 77 //....oooOO0OOooo........oooOO0OOooo........oo 79 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 78 //== 80 //== 79 void RE02RunAction::BeginOfRunAction(const G4R 81 void RE02RunAction::BeginOfRunAction(const G4Run* aRun) 80 { 82 { 81 G4cout << "### Run " << aRun->GetRunID() << 83 G4cout << "### Run " << aRun->GetRunID() << " start." << G4endl; 82 } 84 } 83 85 84 //....oooOO0OOooo........oooOO0OOooo........oo 86 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 85 //== << 87 //== 86 void RE02RunAction::EndOfRunAction(const G4Run 88 void RE02RunAction::EndOfRunAction(const G4Run* aRun) 87 { 89 { 88 if (!IsMaster()) return; << 90 if(!IsMaster()) return; 89 91 90 //- RE02Run object. 92 //- RE02Run object. 91 RE02Run* re02Run = (RE02Run*)aRun; 93 RE02Run* re02Run = (RE02Run*)aRun; 92 //--- Dump all socred quantities involved in 94 //--- Dump all socred quantities involved in RE02Run. 93 re02Run->DumpAllScorer(); 95 re02Run->DumpAllScorer(); 94 //--- 96 //--- 95 97 96 // 98 // 97 //- water phantom (Detector) Information. 99 //- water phantom (Detector) Information. 98 //-- Number of segments in the water phantom 100 //-- Number of segments in the water phantom. 99 const RE02DetectorConstruction* detector = 101 const RE02DetectorConstruction* detector = 100 (const RE02DetectorConstruction*)(G4RunMan << 102 (const RE02DetectorConstruction*) 101 detector->GetNumberOfSegmentsInPhantom(fNx, << 103 (G4RunManager::GetRunManager()->GetUserDetectorConstruction()); >> 104 detector->GetNumberOfSegmentsInPhantom(fNx,fNy,fNz); //Fill fNx,y,z. 102 105 103 //------------------------------------------ 106 //--------------------------------------------- 104 // Dump accumulated quantities for this RUN. 107 // Dump accumulated quantities for this RUN. 105 // (Display only central region of x-y plan 108 // (Display only central region of x-y plane) 106 //------------------------------------------ 109 //--------------------------------------------- 107 G4THitsMap<G4double>* totEdep = re02Run->Get << 110 G4THitsMap<G4double>* totEdep = re02Run->GetHitsMap("PhantomSD/totalEDep"); 108 G4THitsMap<G4double>* proEdep = re02Run->Get << 111 G4THitsMap<G4double>* proEdep = re02Run->GetHitsMap("PhantomSD/protonEDep"); 109 G4THitsMap<G4double>* proNstep = re02Run->Ge 112 G4THitsMap<G4double>* proNstep = re02Run->GetHitsMap("PhantomSD/protonNStep"); 110 G4THitsMap<G4double>* passCFx = re02Run->Get << 113 G4THitsMap<G4double>* passCFx = 111 G4THitsMap<G4double>* cFx = re02Run->GetHits << 114 re02Run->GetHitsMap("PhantomSD/chargedPassCellFlux"); 112 G4THitsMap<G4double>* surfFx = re02Run->GetH << 115 G4THitsMap<G4double>* cFx = 113 G4THitsMap<G4double>* gCurr00 = re02Run->Get << 116 re02Run->GetHitsMap("PhantomSD/chargedCellFlux"); 114 G4THitsMap<G4double>* gCurr01 = re02Run->Get << 117 G4THitsMap<G4double>* surfFx = 115 G4THitsMap<G4double>* gCurr02 = re02Run->Get << 118 re02Run->GetHitsMap("PhantomSD/chargedSurfFlux"); 116 G4THitsMap<G4double>* gCurr03 = re02Run->Get << 119 G4THitsMap<G4double>* gCurr00 = 117 << 120 re02Run->GetHitsMap("PhantomSD/gammaSurfCurr000"); 118 G4cout << "================================= << 121 G4THitsMap<G4double>* gCurr01 = 119 G4cout << " Number of event processed : " << << 122 re02Run->GetHitsMap("PhantomSD/gammaSurfCurr001"); 120 G4cout << "================================= << 123 G4THitsMap<G4double>* gCurr02 = 121 G4cout << std::setw(8) << "#Z Cell#"; << 124 re02Run->GetHitsMap("PhantomSD/gammaSurfCurr002"); >> 125 G4THitsMap<G4double>* gCurr03 = >> 126 re02Run->GetHitsMap("PhantomSD/gammaSurfCurr003"); >> 127 >> 128 G4cout << "=============================================================" >> 129 << G4endl; >> 130 G4cout << " Number of event processed : "<< aRun->GetNumberOfEvent() << G4endl; >> 131 G4cout << "=============================================================" >> 132 << G4endl; >> 133 G4cout << std::setw( 8) << "#Z Cell#"; 122 G4cout << std::setw(16) << totEdep->GetName( 134 G4cout << std::setw(16) << totEdep->GetName(); 123 G4cout << std::setw(16) << proEdep->GetName( 135 G4cout << std::setw(16) << proEdep->GetName(); 124 G4cout << std::setw(12) << proNstep->GetName 136 G4cout << std::setw(12) << proNstep->GetName(); 125 G4cout << std::setw(21) << passCFx->GetName( 137 G4cout << std::setw(21) << passCFx->GetName(); 126 G4cout << std::setw(20) << cFx->GetName(); 138 G4cout << std::setw(20) << cFx->GetName(); 127 G4cout << std::setw(20) << surfFx->GetName() 139 G4cout << std::setw(20) << surfFx->GetName(); 128 G4cout << std::setw(20) << gCurr00->GetName( 140 G4cout << std::setw(20) << gCurr00->GetName(); 129 G4cout << std::setw(20) << gCurr01->GetName( 141 G4cout << std::setw(20) << gCurr01->GetName(); 130 G4cout << std::setw(20) << gCurr02->GetName( 142 G4cout << std::setw(20) << gCurr02->GetName(); 131 G4cout << std::setw(20) << gCurr03->GetName( << 143 G4cout << std::setw(20) << gCurr03->GetName() 132 G4int ix = fNx / 2; << 144 << G4endl; 133 G4int iy = fNy / 2; << 145 G4int ix = fNx/2; >> 146 G4int iy = fNy/2; 134 G4int iz; 147 G4int iz; 135 // G4double totE, proE, proN,pasCF,CF,surfF, << 148 //G4double totE, proE, proN,pasCF,CF,surfF,gCr0,gCr1,gCr2,gCr3; 136 for (iz = 0; iz < fNz; iz++) { << 149 for ( iz = 0; iz < fNz; iz++){ 137 G4double* totED = (*totEdep)[CopyNo(ix, iy << 150 G4double* totED = (*totEdep)[CopyNo(ix,iy,iz)]; 138 G4double* proED = (*proEdep)[CopyNo(ix, iy << 151 G4double* proED = (*proEdep)[CopyNo(ix,iy,iz)]; 139 G4double* proNS = (*proNstep)[CopyNo(ix, i << 152 G4double* proNS = (*proNstep)[CopyNo(ix,iy,iz)]; 140 G4double* pasCF = (*passCFx)[CopyNo(ix, iy << 153 G4double* pasCF = (*passCFx)[CopyNo(ix,iy,iz)]; 141 G4double* cF = (*cFx)[CopyNo(ix, iy, iz)]; << 154 G4double* cF = (*cFx)[CopyNo(ix,iy,iz)]; 142 G4double* sfx = (*surfFx)[CopyNo(ix, iy, i << 155 G4double* sfx = (*surfFx)[CopyNo(ix,iy,iz)]; 143 G4double* gcur0 = (*gCurr00)[CopyNo(ix, iy << 156 G4double* gcur0 = (*gCurr00)[CopyNo(ix,iy,iz)]; 144 G4double* gcur1 = (*gCurr01)[CopyNo(ix, iy << 157 G4double* gcur1 = (*gCurr01)[CopyNo(ix,iy,iz)]; 145 G4double* gcur2 = (*gCurr02)[CopyNo(ix, iy << 158 G4double* gcur2 = (*gCurr02)[CopyNo(ix,iy,iz)]; 146 G4double* gcur3 = (*gCurr03)[CopyNo(ix, iy << 159 G4double* gcur3 = (*gCurr03)[CopyNo(ix,iy,iz)]; 147 if (!totED) totED = new G4double(0.0); << 160 if ( !totED ) totED = new G4double(0.0); 148 if (!proED) proED = new G4double(0.0); << 161 if ( !proED ) proED = new G4double(0.0); 149 if (!proNS) proNS = new G4double(0.0); << 162 if ( !proNS ) proNS = new G4double(0.0); 150 if (!pasCF) pasCF = new G4double(0.0); << 163 if ( !pasCF ) pasCF = new G4double(0.0); 151 if (!cF) cF = new G4double(0.0); << 164 if ( !cF ) cF = new G4double(0.0); 152 if (!sfx) sfx = new G4double(0.0); << 165 if ( !sfx ) sfx = new G4double(0.0); 153 if (!gcur0) gcur0 = new G4double(0.0); << 166 if ( !gcur0 ) gcur0 = new G4double(0.0); 154 if (!gcur1) gcur1 = new G4double(0.0); << 167 if ( !gcur1 ) gcur1 = new G4double(0.0); 155 if (!gcur2) gcur2 = new G4double(0.0); << 168 if ( !gcur2 ) gcur2 = new G4double(0.0); 156 if (!gcur3) gcur3 = new G4double(0.0); << 169 if ( !gcur3 ) gcur3 = new G4double(0.0); 157 G4cout << std::setw(6) << iz << " " << st << 170 G4cout << std::setw( 6) << iz << " " 158 << std::setw(12) << G4BestUnit(*pro << 171 << std::setw(12) << G4BestUnit(*totED,"Energy") 159 << std::setw(13) << (*pasCF) * cm * << 172 << std::setw(12) << G4BestUnit(*proED,"Energy") 160 << " /cm2" << std::setw(15) << (*sf << 173 << std::setw(12) << (*proNS) << " " 161 << (*gcur0) * cm * cm << " /cm2" << << 174 << std::setw(13) << (*pasCF)*cm*cm <<" /cm2" 162 << std::setw(15) << (*gcur2) * cm * << 175 << std::setw(15) << (*cF)*cm*cm <<" /cm2" 163 << " /cm2" << G4endl; << 176 << std::setw(15) << (*sfx)*cm*cm <<" /cm2" >> 177 << std::setw(15) << (*gcur0)*cm*cm <<" /cm2" >> 178 << std::setw(15) << (*gcur1)*cm*cm <<" /cm2" >> 179 << std::setw(15) << (*gcur2)*cm*cm <<" /cm2" >> 180 << std::setw(15) << (*gcur3)*cm*cm <<" /cm2" >> 181 << G4endl; 164 } 182 } 165 G4cout << "================================= << 183 G4cout << "============================================="<<G4endl; >> 184 >> 185 std::ofstream file("totED.txt"); >> 186 for ( iz = 0; iz < fNz; iz++){ >> 187 for ( iy = 0; iy < fNy; iy++){ >> 188 for ( ix = 0; ix < fNx; ix++){ >> 189 G4double* totED = (*totEdep)[CopyNo(ix,iy,iz)]; >> 190 if ( !totED ) totED = new G4double(0.0); >> 191 file << ix << " "<<iy<<" "<<iz<<" "<< *totED/MeV << G4endl; 166 192 167 std::ofstream file("totED.txt"); << 168 for (iz = 0; iz < fNz; iz++) { << 169 for (iy = 0; iy < fNy; iy++) { << 170 for (ix = 0; ix < fNx; ix++) { << 171 G4double* totED = (*totEdep)[CopyNo(ix << 172 if (!totED) totED = new G4double(0.0); << 173 file << ix << " " << iy << " " << iz < << 174 } 193 } 175 } 194 } 176 } 195 } 177 file.close(); 196 file.close(); 178 } 197 } 179 // 198 // 180 // -- 199 // -- 181 200