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