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