Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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");
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  std::ostream *myout = &G4cout;
163  PrintHeader(myout);
164 
165  for ( G4int iz = 0; iz < 20; iz++){
166  G4double* SumCollisions = (*Collisions)[iz];
167  G4double* SumCollWeight = (*CollWeight)[iz];
168  G4double* Populations = (*Population)[iz];
169  G4double* TrackEnters = (*TrackEnter)[iz];
170  G4double* SLs = (*SL)[iz];
171  G4double* SLWs = (*SLW)[iz];
172  G4double* SLWEs = (*SLWE)[iz];
173  G4double* SLW_Vs = (*SLW_V)[iz];
174  G4double* SLWE_Vs = (*SLWE_V)[iz];
175  if ( !SumCollisions ) SumCollisions = new G4double(0.0);
176  if ( !SumCollWeight ) SumCollWeight = new G4double(0.0);
177  if ( !Populations ) Populations = new G4double(0.0);
178  if ( !TrackEnters ) { G4cout << " NO TRACKS - WHY? " << G4endl;
179  TrackEnters = new G4double(0.0);}
180  if ( !SLs ) SLs = new G4double(0.0);
181  if ( !SLWs ) SLWs = new G4double(0.0);
182  if ( !SLWEs ) SLWEs = new G4double(0.0);
183  if ( !SLW_Vs ) SLW_Vs = new G4double(0.0);
184  if ( !SLWE_Vs ) SLWE_Vs = new G4double(0.0);
185  G4double NumWeightedEnergy =0.0;
186  G4double FluxWeightedEnergy=0.0;
187  G4double AverageTrackWeight=0.0;
188  if ( *SLW_Vs !=0. ) NumWeightedEnergy = (*SLWE_Vs)/(*SLW_Vs);
189  if ( *SLWs !=0. ) FluxWeightedEnergy = (*SLWEs)/(*SLWs);
190  if ( *SLs !=0. ) AverageTrackWeight = (*SLWs)/(*SLs);
191  G4String cname = bdet->GetCellName(iz);
192  G4cout
193  << std::setw(fFieldValue) << cname << " |"
194  << std::setw(fFieldValue) << (*TrackEnters) << " |"
195  << std::setw(fFieldValue) << (*Populations) << " |"
196  << std::setw(fFieldValue) << (*SumCollisions) << " |"
197  << std::setw(fFieldValue) << (*SumCollWeight) << " |"
198  << std::setw(fFieldValue) << NumWeightedEnergy << " |"
199  << std::setw(fFieldValue) << FluxWeightedEnergy << " |"
200  << std::setw(fFieldValue) << AverageTrackWeight << " |"
201  << std::setw(fFieldValue) << (*SLs) << " |"
202  << std::setw(fFieldValue) << (*SLWs) << " |"
203  << std::setw(fFieldValue) << (*SLW_Vs) << " |"
204  << std::setw(fFieldValue) << (*SLWEs) << " |"
205  << std::setw(fFieldValue) << (*SLWE_Vs) << " |"
206  << G4endl;
207  }
208  G4cout << "============================================="<<G4endl;
209  }
210 }
211 
212 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
213 
214 void B03RunAction::PrintHeader(std::ostream *out)
215 {
216  std::vector<G4String> vecScoreName;
217  vecScoreName.push_back("Tr.Entering");
218  vecScoreName.push_back("Population");
219  vecScoreName.push_back("Collisions");
220  vecScoreName.push_back("Coll*WGT");
221  vecScoreName.push_back("NumWGTedE");
222  vecScoreName.push_back("FluxWGTedE");
223  vecScoreName.push_back("Av.Tr.WGT");
224  vecScoreName.push_back("SL");
225  vecScoreName.push_back("SLW");
226  vecScoreName.push_back("SLW_v");
227  vecScoreName.push_back("SLWE");
228  vecScoreName.push_back("SLWE_v");
229 
230  // head line
231  //std::string vname = FillString("Volume", ' ', FieldName+1);
232  //*out << vname << '|';
233  std::string vname;
234  *out << std::setw(fFieldValue) << "Volume" << " |";
235  for (std::vector<G4String>::iterator it = vecScoreName.begin();
236  it != vecScoreName.end(); it++) {
237  //vname = FillString((*it),
238 // ' ',
239 // fFieldValue+1,
240 // false);
241 // *out << vname << '|';
242  *out << std::setw(fFieldValue) << (*it) << " |";
243  }
244  *out << G4endl;
245 }
246 
247 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
248 
249 std::string B03RunAction::FillString(const std::string &name,
250  char c, G4int n, G4bool back)
251 {
252  std::string fname("");
253  G4int k = n - name.size();
254  if (k > 0) {
255  if (back) {
256  fname = name;
257  fname += std::string(k,c);
258  }
259  else {
260  fname = std::string(k,c);
261  fname += name;
262  }
263  }
264  else {
265  fname = name;
266  }
267  return fname;
268 }
269 
270 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
const XML_Char * name
Definition: expat.h:151
virtual ~B03RunAction()
Definition: B03RunAction.cc:65
const G4VUserDetectorConstruction * GetUserDetectorConstruction() const
Definition: B03Run.hh:50
int G4int
Definition: G4Types.hh:78
Definition of the B03RunAction class.
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
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
const G4int n
virtual void BeginOfRunAction(const G4Run *)
Definition: B03RunAction.cc:82
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:79
static const G4double * SL[nLA]
#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