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