Geant4_10
B03RunAction.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: B03RunAction.cc 72953 2013-08-14 14:13:36Z gcosmo $
31 //
32 #include "B03RunAction.hh"
33 #include "B03Run.hh"
34 
35 //-- In order to obtain detector information.
36 #include "G4RunManager.hh"
38 #include "G4THitsMap.hh"
39 
40 #include "G4UnitsTable.hh"
41 
42 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
43 
44 // B03RunAction
45 //
46 //
47 //
48 
49 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
50 
51 // Constructor
54  // fFieldName(15),
55  fFieldValue(14)
56 {
57  // - Prepare data member for B03Run.
58  // vector represents a list of MultiFunctionalDetector names.
59  fSDName.push_back(G4String("ConcreteSD"));
60 }
61 
62 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
63 
64 // Destructor.
66 {
67  fSDName.clear();
68 }
69 
70 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
71 
73 {
74  // Generate new RUN object, which is specially
75  // dedicated for MultiFunctionalDetector scheme.
76  // Detail description can be found in B03Run.hh/cc.
77  return new B03Run(fSDName);
78 }
79 
80 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
81 
83 {
84  G4cout << "### Run " << aRun->GetRunID() << " start." << G4endl;
85 }
86 
87 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
88 
90 {
91  G4cout << " ###### EndOfRunAction " <<G4endl;
92  //- B03Run object.
93  B03Run* b02Run = (B03Run*)aRun;
94  //--- Dump all socred quantities involved in B03Run.
95  // b02Run->DumpAllScorer();
96  //---
98  //
99 
100  for ( G4int i = 0; i < (G4int)fSDName.size(); i++ ){
101  const G4VUserDetectorConstruction* vdet =
103  // B03DetectorConstruction* bdet = (B03DetectorConstruction*)vdet;
106  //
107 
108  //---------------------------------------------
109  // Dump accumulated quantities for this RUN.
110  // (Display only central region of x-y plane)
111  // 0 ConcreteSD/Collisions
112  // 1 ConcreteSD/CollWeight
113  // 2 ConcreteSD/Population
114  // 3 ConcreteSD/TrackEnter
115  // 4 ConcreteSD/SL
116  // 5 ConcreteSD/SLW
117  // 6 ConcreteSD/SLWE
118  // 7 ConcreteSD/SLW_V
119  // 8 ConcreteSD/SLWE_V
120  //---------------------------------------------
121  G4THitsMap<G4double>* Collisions =
122  b02Run->GetHitsMap(fSDName[i]+"/Collisions");
123  G4THitsMap<G4double>* CollWeight =
124  b02Run->GetHitsMap(fSDName[i]+"/CollWeight");
125  G4THitsMap<G4double>* Population =
126  b02Run->GetHitsMap(fSDName[i]+"/Population");
127  G4THitsMap<G4double>* TrackEnter =
128  b02Run->GetHitsMap(fSDName[i]+"/TrackEnter");
129  G4THitsMap<G4double>* SL =
130  b02Run->GetHitsMap(fSDName[i]+"/SL");
131  G4THitsMap<G4double>* SLW =
132  b02Run->GetHitsMap(fSDName[i]+"/SLW");
133  G4THitsMap<G4double>* SLWE =
134  b02Run->GetHitsMap(fSDName[i]+"/SLWE");
135  G4THitsMap<G4double>* SLW_V =
136  b02Run->GetHitsMap(fSDName[i]+"/SLW_V");
137  G4THitsMap<G4double>* SLWE_V =
138  b02Run->GetHitsMap(fSDName[i]+"/SLWE_V");
139 
140  if (IsMaster())
141  {
142  G4cout <<
143  "\n--------------------End of Global Run-----------------------" <<
144  G4endl;
145  G4cout <<
146  " Number of event processed : "<< aRun->GetNumberOfEvent() << G4endl;
147  }
148  else
149  {
150  G4cout <<
151  "\n--------------------End of Local Run------------------------" <<
152  G4endl;
153  G4cout << " Number of event processed : "<< aRun->GetNumberOfEvent() <<
154  G4endl;
155  }
156 
157  G4cout << "============================================================="
158  <<G4endl;
159  G4cout << "============================================================="
160  <<G4endl;
161 
162 
163  std::ostream *myout = &G4cout;
164  PrintHeader(myout);
165 
166  for ( G4int iz = 0; iz < 20; iz++){
167  G4double* SumCollisions = (*Collisions)[iz];
168  G4double* SumCollWeight = (*CollWeight)[iz];
169  G4double* Populations = (*Population)[iz];
170  G4double* TrackEnters = (*TrackEnter)[iz];
171  G4double* SLs = (*SL)[iz];
172  G4double* SLWs = (*SLW)[iz];
173  G4double* SLWEs = (*SLWE)[iz];
174  G4double* SLW_Vs = (*SLW_V)[iz];
175  G4double* SLWE_Vs = (*SLWE_V)[iz];
176  if ( !SumCollisions ) SumCollisions = new G4double(0.0);
177  if ( !SumCollWeight ) SumCollWeight = new G4double(0.0);
178  if ( !Populations ) Populations = new G4double(0.0);
179  if ( !TrackEnters ) { G4cout << " NO TRACKS - WHY? " << G4endl;
180  TrackEnters = new G4double(0.0);}
181  if ( !SLs ) SLs = new G4double(0.0);
182  if ( !SLWs ) SLWs = new G4double(0.0);
183  if ( !SLWEs ) SLWEs = new G4double(0.0);
184  if ( !SLW_Vs ) SLW_Vs = new G4double(0.0);
185  if ( !SLWE_Vs ) SLWE_Vs = new G4double(0.0);
186  G4double NumWeightedEnergy =0.0;
187  G4double FluxWeightedEnergy=0.0;
188  G4double AverageTrackWeight=0.0;
189  if ( *SLW_Vs !=0. ) NumWeightedEnergy = (*SLWE_Vs)/(*SLW_Vs);
190  if ( *SLWs !=0. ) FluxWeightedEnergy = (*SLWEs)/(*SLWs);
191  if ( *SLs !=0. ) AverageTrackWeight = (*SLWs)/(*SLs);
192  G4String cname = bdet->GetCellName(iz);
193  G4cout
194  << std::setw(fFieldValue) << cname << " |"
195  << std::setw(fFieldValue) << (*TrackEnters) << " |"
196  << std::setw(fFieldValue) << (*Populations) << " |"
197  << std::setw(fFieldValue) << (*SumCollisions) << " |"
198  << std::setw(fFieldValue) << (*SumCollWeight) << " |"
199  << std::setw(fFieldValue) << NumWeightedEnergy << " |"
200  << std::setw(fFieldValue) << FluxWeightedEnergy << " |"
201  << std::setw(fFieldValue) << AverageTrackWeight << " |"
202  << std::setw(fFieldValue) << (*SLs) << " |"
203  << std::setw(fFieldValue) << (*SLWs) << " |"
204  << std::setw(fFieldValue) << (*SLW_Vs) << " |"
205  << std::setw(fFieldValue) << (*SLWEs) << " |"
206  << std::setw(fFieldValue) << (*SLWE_Vs) << " |"
207  << G4endl;
208  }
209  G4cout << "============================================="<<G4endl;
210  }
211 }
212 
213 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
214 
215 void B03RunAction::PrintHeader(std::ostream *out)
216 {
217  std::vector<G4String> vecScoreName;
218  vecScoreName.push_back("Tr.Entering");
219  vecScoreName.push_back("Population");
220  vecScoreName.push_back("Collisions");
221  vecScoreName.push_back("Coll*WGT");
222  vecScoreName.push_back("NumWGTedE");
223  vecScoreName.push_back("FluxWGTedE");
224  vecScoreName.push_back("Av.Tr.WGT");
225  vecScoreName.push_back("SL");
226  vecScoreName.push_back("SLW");
227  vecScoreName.push_back("SLW_v");
228  vecScoreName.push_back("SLWE");
229  vecScoreName.push_back("SLWE_v");
230 
231  // head line
232  //std::string vname = FillString("Volume", ' ', FieldName+1);
233  //*out << vname << '|';
234  std::string vname;
235  *out << std::setw(fFieldValue) << "Volume" << " |";
236  for (std::vector<G4String>::iterator it = vecScoreName.begin();
237  it != vecScoreName.end(); it++) {
238  //vname = FillString((*it),
239 // ' ',
240 // fFieldValue+1,
241 // false);
242 // *out << vname << '|';
243  *out << std::setw(fFieldValue) << (*it) << " |";
244  }
245  *out << G4endl;
246 }
247 
248 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
249 
250 std::string B03RunAction::FillString(const std::string &name,
251  char c, G4int n, G4bool back)
252 {
253  std::string fname("");
254  G4int k = n - name.size();
255  if (k > 0) {
256  if (back) {
257  fname = name;
258  fname += std::string(k,c);
259  }
260  else {
261  fname = std::string(k,c);
262  fname += name;
263  }
264  }
265  else {
266  fname = name;
267  }
268  return fname;
269 }
270 
271 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
virtual ~B03RunAction()
Definition: B03RunAction.cc:65
const G4VUserDetectorConstruction * GetUserDetectorConstruction() const
Definition: B03Run.hh:50
const XML_Char * name
Definition: expat.h:151
int G4int
Definition: G4Types.hh:78
Definition of the B03RunAction class.
Char_t n[5]
void PrintHeader(std::ostream *out)
G4GLOB_DLL std::ostream G4cout
std::string FillString(const std::string &name, char c, G4int n, G4bool back=true)
G4int GetNumberOfEvent() const
Definition: G4Run.hh:79
bool G4bool
Definition: G4Types.hh:79
G4double iz
Definition: TRTMaterials.hh:39
G4bool IsMaster() const
G4int GetRunID() const
Definition: G4Run.hh:76
Definition: G4Run.hh:46
virtual void EndOfRunAction(const G4Run *)
Definition: B03RunAction.cc:89
virtual G4Run * GenerateRun()
Definition: B03RunAction.cc:72
virtual void BeginOfRunAction(const G4Run *)
Definition: B03RunAction.cc:82
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:74
#define G4endl
Definition: G4ios.hh:61
Definition of the B03Run class.
string fname
Definition: test.py:308
double G4double
Definition: G4Types.hh:76
tuple c
Definition: test.py:13
Definition of the B03ImportanceDetectorConstruction class.
G4THitsMap< G4double > * GetHitsMap(G4int i)
Definition: B03Run.hh:70