ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
B03RunAction.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file B03RunAction.cc
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 //
31 #include "B03RunAction.hh"
32 #include "B03Run.hh"
33 
34 //-- In order to obtain detector information.
35 #include "G4RunManager.hh"
37 #include "G4THitsMap.hh"
38 
39 #include "G4UnitsTable.hh"
40 
41 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
42 
43 // B03RunAction
44 //
45 //
46 //
47 
48 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
49 
50 // Constructor
53  // fFieldName(15),
54  fFieldValue(14)
55 {
56  // - Prepare data member for B03Run.
57  // vector represents a list of MultiFunctionalDetector names.
58  fSDName.push_back(G4String("ConcreteSD"));
59 }
60 
61 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
62 
63 // Destructor.
65 {
66  fSDName.clear();
67 }
68 
69 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
70 
72 {
73  // Generate new RUN object, which is specially
74  // dedicated for MultiFunctionalDetector scheme.
75  // Detail description can be found in B03Run.hh/cc.
76  return new B03Run(fSDName);
77 }
78 
79 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
80 
82 {
83  G4cout << "### Run " << aRun->GetRunID() << " start." << G4endl;
84 }
85 
86 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
87 
89 {
90  G4cout << " ###### EndOfRunAction " <<G4endl;
91  //- B03Run object.
92  B03Run* b02Run = (B03Run*)aRun;
93  //--- Dump all socred quantities involved in B03Run.
94  // b02Run->DumpAllScorer();
95  //---
97  //
98 
99  for ( G4int i = 0; i < (G4int)fSDName.size(); i++ ){
100  const G4VUserDetectorConstruction* vdet =
102  // B03DetectorConstruction* bdet = (B03DetectorConstruction*)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");
129  b02Run->GetHitsMap(fSDName[i]+"/SL");
130  G4THitsMap<G4double>* SLW =
131  b02Run->GetHitsMap(fSDName[i]+"/SLW");
132  G4THitsMap<G4double>* SLWE =
133  b02Run->GetHitsMap(fSDName[i]+"/SLWE");
134  G4THitsMap<G4double>* SLW_V =
135  b02Run->GetHitsMap(fSDName[i]+"/SLW_V");
136  G4THitsMap<G4double>* SLWE_V =
137  b02Run->GetHitsMap(fSDName[i]+"/SLWE_V");
138 
139  if (IsMaster())
140  {
141  G4cout <<
142  "\n--------------------End of Global Run-----------------------" <<
143  G4endl;
144  G4cout <<
145  " Number of event processed : "<< aRun->GetNumberOfEvent() << G4endl;
146  }
147  else
148  {
149  G4cout <<
150  "\n--------------------End of Local Run------------------------" <<
151  G4endl;
152  G4cout << " Number of event processed : "<< aRun->GetNumberOfEvent() <<
153  G4endl;
154  }
155 
156  G4cout << "============================================================="
157  <<G4endl;
158  G4cout << "============================================================="
159  <<G4endl;
160 
161  std::ostream *myout = &G4cout;
162  PrintHeader(myout);
163 
164  for ( G4int iz = 0; iz < 20; iz++){
165  G4double* SumCollisions = (*Collisions)[iz];
166  G4double* SumCollWeight = (*CollWeight)[iz];
167  G4double* Populations = (*Population)[iz];
168  G4double* TrackEnters = (*TrackEnter)[iz];
169  G4double* SLs = (*SL)[iz];
170  G4double* SLWs = (*SLW)[iz];
171  G4double* SLWEs = (*SLWE)[iz];
172  G4double* SLW_Vs = (*SLW_V)[iz];
173  G4double* SLWE_Vs = (*SLWE_V)[iz];
174  if ( !SumCollisions ) SumCollisions = new G4double(0.0);
175  if ( !SumCollWeight ) SumCollWeight = new G4double(0.0);
176  if ( !Populations ) Populations = new G4double(0.0);
177  if ( !TrackEnters ) { G4cout << " NO TRACKS - WHY? " << G4endl;
178  TrackEnters = new G4double(0.0);}
179  if ( !SLs ) SLs = new G4double(0.0);
180  if ( !SLWs ) SLWs = new G4double(0.0);
181  if ( !SLWEs ) SLWEs = new G4double(0.0);
182  if ( !SLW_Vs ) SLW_Vs = new G4double(0.0);
183  if ( !SLWE_Vs ) SLWE_Vs = new G4double(0.0);
184  G4double NumWeightedEnergy =0.0;
185  G4double FluxWeightedEnergy=0.0;
186  G4double AverageTrackWeight=0.0;
187  if ( *SLW_Vs !=0. ) NumWeightedEnergy = (*SLWE_Vs)/(*SLW_Vs);
188  if ( *SLWs !=0. ) FluxWeightedEnergy = (*SLWEs)/(*SLWs);
189  if ( *SLs !=0. ) AverageTrackWeight = (*SLWs)/(*SLs);
190  G4String cname = bdet->GetCellName(iz);
191  G4cout
192  << std::setw(fFieldValue) << cname << " |"
193  << std::setw(fFieldValue) << (*TrackEnters) << " |"
194  << std::setw(fFieldValue) << (*Populations) << " |"
195  << std::setw(fFieldValue) << (*SumCollisions) << " |"
196  << std::setw(fFieldValue) << (*SumCollWeight) << " |"
197  << std::setw(fFieldValue) << NumWeightedEnergy << " |"
198  << std::setw(fFieldValue) << FluxWeightedEnergy << " |"
199  << std::setw(fFieldValue) << AverageTrackWeight << " |"
200  << std::setw(fFieldValue) << (*SLs) << " |"
201  << std::setw(fFieldValue) << (*SLWs) << " |"
202  << std::setw(fFieldValue) << (*SLW_Vs) << " |"
203  << std::setw(fFieldValue) << (*SLWEs) << " |"
204  << std::setw(fFieldValue) << (*SLWE_Vs) << " |"
205  << G4endl;
206  }
207  G4cout << "============================================="<<G4endl;
208  }
209 }
210 
211 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
212 
213 void B03RunAction::PrintHeader(std::ostream *out)
214 {
215  std::vector<G4String> vecScoreName;
216  vecScoreName.push_back("Tr.Entering");
217  vecScoreName.push_back("Population");
218  vecScoreName.push_back("Collisions");
219  vecScoreName.push_back("Coll*WGT");
220  vecScoreName.push_back("NumWGTedE");
221  vecScoreName.push_back("FluxWGTedE");
222  vecScoreName.push_back("Av.Tr.WGT");
223  vecScoreName.push_back("SL");
224  vecScoreName.push_back("SLW");
225  vecScoreName.push_back("SLW_v");
226  vecScoreName.push_back("SLWE");
227  vecScoreName.push_back("SLWE_v");
228 
229  // head line
230  //std::string vname = FillString("Volume", ' ', FieldName+1);
231  //*out << vname << '|';
232  std::string vname;
233  *out << std::setw(fFieldValue) << "Volume" << " |";
234  for (std::vector<G4String>::iterator it = vecScoreName.begin();
235  it != vecScoreName.end(); it++) {
236  //vname = FillString((*it),
237 // ' ',
238 // fFieldValue+1,
239 // false);
240 // *out << vname << '|';
241  *out << std::setw(fFieldValue) << (*it) << " |";
242  }
243  *out << G4endl;
244 }
245 
246 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
247 
248 std::string B03RunAction::FillString(const std::string &name,
249  char c, G4int n, G4bool back)
250 {
251  std::string fname("");
252  G4int k = n - name.size();
253  if (k > 0) {
254  if (back) {
255  fname = name;
256  fname += std::string(k,c);
257  }
258  else {
259  fname = std::string(k,c);
260  fname += name;
261  }
262  }
263  else {
264  fname = name;
265  }
266  return fname;
267 }
268 
269 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......