Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
B01RunAction.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 "B01RunAction.hh"
33 #include "B01Run.hh"
34 
35 //-- In order to obtain detector information.
36 #include "G4RunManager.hh"
38 #include "G4THitsMap.hh"
39 
40 #include "G4UnitsTable.hh"
41 //=======================================================================
42 // B01RunAction
43 //
44 //
45 //
46 //=======================================================================
47 // Constructor
49  FieldName(15),
50  FieldValue(14)
51 {
52  // - Prepare data member for B01Run.
53  // vector represents a list of MultiFunctionalDetector names.
54  theSDName.push_back(G4String("ConcreteSD"));
55 }
56 
57 // Destructor.
59 {
60  theSDName.clear();
61 }
62 
63 //
64 //==
66 {
67  // Generate new RUN object, which is specially
68  // dedicated for MultiFunctionalDetector scheme.
69  // Detail description can be found in B01Run.hh/cc.
70  return new B01Run(theSDName);
71 }
72 
73 //
74 //==
76 {
77  G4cout << "### Run " << aRun->GetRunID() << " start." << G4endl;
78 }
79 
80 //
81 //==
83 {
84  G4cout << " ###### EndOfRunAction " <<G4endl;
85  //- B01Run object.
86  B01Run* re02Run = (B01Run*)aRun;
87  //--- Dump all socred quantities involved in B01Run.
88  // re02Run->DumpAllScorer();
89  //---
91  //
92 
93  for ( G4int i = 0; i < (G4int)theSDName.size(); i++ ){
96  //
97 
98  //---------------------------------------------
99  // Dump accumulated quantities for this RUN.
100  // (Display only central region of x-y plane)
101  // 0 ConcreteSD/Collisions
102  // 1 ConcreteSD/CollWeight
103  // 2 ConcreteSD/Population
104  // 3 ConcreteSD/TrackEnter
105  // 4 ConcreteSD/SL
106  // 5 ConcreteSD/SLW
107  // 6 ConcreteSD/SLWE
108  // 7 ConcreteSD/SLW_V
109  // 8 ConcreteSD/SLWE_V
110  //---------------------------------------------
111  G4THitsMap<G4double>* Collisions = re02Run->GetHitsMap(theSDName[i]+"/Collisions");
112  G4THitsMap<G4double>* CollWeight = re02Run->GetHitsMap(theSDName[i]+"/CollWeight");
113  G4THitsMap<G4double>* Population = re02Run->GetHitsMap(theSDName[i]+"/Population");
114  G4THitsMap<G4double>* TrackEnter = re02Run->GetHitsMap(theSDName[i]+"/TrackEnter");
115  G4THitsMap<G4double>* SL = re02Run->GetHitsMap(theSDName[i]+"/SL");
116  G4THitsMap<G4double>* SLW = re02Run->GetHitsMap(theSDName[i]+"/SLW");
117  G4THitsMap<G4double>* SLWE = re02Run->GetHitsMap(theSDName[i]+"/SLWE");
118  G4THitsMap<G4double>* SLW_V = re02Run->GetHitsMap(theSDName[i]+"/SLW_V");
119  G4THitsMap<G4double>* SLWE_V = re02Run->GetHitsMap(theSDName[i]+"/SLWE_V");
120 
121 
122  G4cout << "=============================================================" <<G4endl;
123  G4cout << " Number of event processed : "<< aRun->GetNumberOfEvent() << G4endl;
124  G4cout << "=============================================================" <<G4endl;
125 
126  std::ostream *myout = &G4cout;
127  PrintHeader(myout);
128 
129  for ( G4int iz = 0; iz < 20; iz++){
130  G4double* SumCollisions = (*Collisions)[iz];
131  G4double* SumCollWeight = (*CollWeight)[iz];
132  G4double* Populations = (*Population)[iz];
133  G4double* TrackEnters = (*TrackEnter)[iz];
134  G4double* SLs = (*SL)[iz];
135  G4double* SLWs = (*SLW)[iz];
136  G4double* SLWEs = (*SLWE)[iz];
137  G4double* SLW_Vs = (*SLW_V)[iz];
138  G4double* SLWE_Vs = (*SLWE_V)[iz];
139  if ( !SumCollisions ) SumCollisions = new G4double(0.0);
140  if ( !SumCollWeight ) SumCollWeight = new G4double(0.0);
141  if ( !Populations ) Populations = new G4double(0.0);
142  if ( !TrackEnters ) TrackEnters = new G4double(0.0);
143  if ( !SLs ) SLs = new G4double(0.0);
144  if ( !SLWs ) SLWs = new G4double(0.0);
145  if ( !SLWEs ) SLWEs = new G4double(0.0);
146  if ( !SLW_Vs ) SLW_Vs = new G4double(0.0);
147  if ( !SLWE_Vs ) SLWE_Vs = new G4double(0.0);
148  G4double NumWeightedEnergy =0.0;
149  G4double FluxWeightedEnergy=0.0;
150  G4double AverageTrackWeight=0.0;
151  if ( *SLW_Vs !=0. ) NumWeightedEnergy = (*SLWE_Vs)/(*SLW_Vs);
152  if ( *SLWs !=0. ) FluxWeightedEnergy = (*SLWEs)/(*SLWs);
153  if ( *SLs !=0. ) AverageTrackWeight = (*SLWs)/(*SLs);
154  G4String cname = bdet->GetCellName(iz);
155  G4cout
156  << std::setw(FieldValue) << cname << " |"
157  << std::setw(FieldValue) << (*TrackEnters) << " |"
158  << std::setw(FieldValue) << (*Populations) << " |"
159  << std::setw(FieldValue) << (*SumCollisions) << " |"
160  << std::setw(FieldValue) << (*SumCollWeight) << " |"
161  << std::setw(FieldValue) << NumWeightedEnergy << " |"
162  << std::setw(FieldValue) << FluxWeightedEnergy << " |"
163  << std::setw(FieldValue) << AverageTrackWeight << " |"
164  << std::setw(FieldValue) << (*SLs) << " |"
165  << std::setw(FieldValue) << (*SLWs) << " |"
166  << std::setw(FieldValue) << (*SLW_Vs) << " |"
167  << std::setw(FieldValue) << (*SLWEs) << " |"
168  << std::setw(FieldValue) << (*SLWE_Vs) << " |"
169  << G4endl;
170  }
171  G4cout << "============================================="<<G4endl;
172  }
173 }
174 //
175 // --
176 
177 void B01RunAction::PrintHeader(std::ostream *out)
178 {
179  std::vector<G4String> vecScoreName;
180  vecScoreName.push_back("Tr.Entering");
181  vecScoreName.push_back("Population");
182  vecScoreName.push_back("Collisions");
183  vecScoreName.push_back("Coll*WGT");
184  vecScoreName.push_back("NumWGTedE");
185  vecScoreName.push_back("FluxWGTedE");
186  vecScoreName.push_back("Av.Tr.WGT");
187  vecScoreName.push_back("SL");
188  vecScoreName.push_back("SLW");
189  vecScoreName.push_back("SLW_v");
190  vecScoreName.push_back("SLWE");
191  vecScoreName.push_back("SLWE_v");
192 
193  // head line
194  //std::string vname = FillString("Volume", ' ', FieldName+1);
195  //*out << vname << '|';
196  std::string vname;
197  *out << std::setw(FieldValue) << "Volume" << " |";
198  for (std::vector<G4String>::iterator it = vecScoreName.begin();
199  it != vecScoreName.end(); it++) {
200  //vname = FillString((*it),
201 // ' ',
202 // FieldValue+1,
203 // false);
204 // *out << vname << '|';
205  *out << std::setw(FieldValue) << (*it) << " |";
206  }
207  *out << G4endl;
208 }
209 
210 std::string B01RunAction::FillString(const std::string &name,
211  char c, G4int n, G4bool back)
212 {
213  std::string fname("");
214  G4int k = n - name.size();
215  if (k > 0) {
216  if (back) {
217  fname = name;
218  fname += std::string(k,c);
219  }
220  else {
221  fname = std::string(k,c);
222  fname += name;
223  }
224  }
225  else {
226  fname = name;
227  }
228  return fname;
229 }