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