Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
B01ScoreTable.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 // ----------------------------------------------------------------------
33 // GEANT 4 class source file
34 //
35 // B01ScoreTable.cc
36 //
37 // ----------------------------------------------------------------------
38 
39 #include "B01ScoreTable.hh"
40 #include <sstream>
41 
42 #include "G4VPhysicalVolume.hh"
43 #include "G4VIStore.hh"
44 #include <set>
45 #include "G4CellScorer.hh"
46 
47 
49  fIStore(aIStore),
50  FieldName(15),
51  FieldValue(12)
52 {}
53 
55 {}
56 void B01ScoreTable::
58  std::ostream *out){
59  if (!out) {
60  out = &G4cout;
61  }
62  PrintHeader(out);
63  PrintTable(cs, out);
64 }
65 
66 void B01ScoreTable::PrintHeader(std::ostream *out)
67 {
68  std::vector<G4String> vecScoreName;
69  vecScoreName.push_back("Importance");
70  vecScoreName.push_back("Tr.Entering");
71  vecScoreName.push_back("Population");
72  vecScoreName.push_back("Collisions");
73  vecScoreName.push_back("Coll*WGT");
74  vecScoreName.push_back("NumWGTedE");
75  vecScoreName.push_back("FluxWGTedE");
76  vecScoreName.push_back("Av.Tr.WGT");
77  vecScoreName.push_back("SL");
78  vecScoreName.push_back("SLW");
79  vecScoreName.push_back("SLW_v");
80  vecScoreName.push_back("SLWE");
81  vecScoreName.push_back("SLWE_v");
82 
83  // head line
84  std::string vname = FillString("Volume name", ' ', FieldName+1);
85  *out << vname << '|';
86  for (std::vector<G4String>::iterator it = vecScoreName.begin();
87  it != vecScoreName.end(); it++) {
88  vname = FillString((*it),
89  ' ',
90  FieldValue+1,
91  false);
92  *out << vname << '|';
93  }
94  *out << G4endl;
95 }
96 
97 G4String B01ScoreTable::CreateName(const G4GeometryCell &gCell) {
98 
99  std::ostringstream os;
100  os << gCell.GetPhysicalVolume().GetName()
101  << "_rep:" << gCell.GetReplicaNumber();
102  G4String name = os.str();
103 
104  return name;
105 }
106 
107 
109  std::ostream *out) {
110 
111  // this lines sort the ScoreValues according to the volume
112  // name they belong to
113  std::map<G4String , G4CellScoreComposer> MapStringSCScorer;
114  for (G4MapGeometryCellCellScorer::const_iterator mit =
115  mcs.begin();
116  mit != mcs.end(); ++mit) {
117  G4GeometryCell gCell = (*mit).first; // get a key identifying a volume
118  G4String name(CreateName(gCell));
119 
120  G4double importance = 1;
121  if (fIStore) {
122  if (fIStore->IsKnown(gCell)) {
123  importance = fIStore->GetImportance(gCell);
124  }
125  }
126  MapStringSCScorer[name] = (*mit).second->GetCellScoreComposer();
127  MapStringSCScorer[name].SetImportnace(importance);
128  }
129  // now do the printing
130  for ( std::map<G4String , G4CellScoreComposer>::iterator
131  it = MapStringSCScorer.begin();
132  it != MapStringSCScorer.end(); ++it) {
133  G4String name((*it).first);
134  PrintLine(name, (*it).second.GetStandardCellScoreValues(), out);
135  }
136  out->flush();
137 }
138 
139 void B01ScoreTable::PrintLine(const G4String &name,
140  const G4CellScoreValues &sc_scores,
141  std::ostream *out)
142 {
143  std::string fname = FillString(name, '.', FieldName);
144  *out << fname << " |";
145  *out << std::setw(FieldValue) << sc_scores.fImportance
146  << " |";
147  *out << std::setw(FieldValue) << sc_scores.fSumTracksEntering
148  << " |";
149  *out << std::setw(FieldValue) << sc_scores.fSumPopulation << " |";
150  *out << std::setw(FieldValue) << sc_scores.fSumCollisions << " |";
151  *out << std::setw(FieldValue) << sc_scores.fSumCollisionsWeight
152  << " |";
153  *out << std::setw(FieldValue) << sc_scores.fNumberWeightedEnergy
154  << " |";
155  *out << std::setw(FieldValue) << sc_scores.fFluxWeightedEnergy
156  << " |";
157  *out << std::setw(FieldValue) << sc_scores.fAverageTrackWeight*
158  sc_scores.fImportance
159  << " |";
160  *out << std::setw(FieldValue) << sc_scores.fSumSL
161  << " |";
162  *out << std::setw(FieldValue) << sc_scores.fSumSLW
163  << " |";
164  *out << std::setw(FieldValue) << sc_scores.fSumSLW_v
165  << " |";
166  *out << std::setw(FieldValue) << sc_scores.fSumSLWE
167  << " |";
168  *out << std::setw(FieldValue) << sc_scores.fSumSLWE_v
169  << " |";
170 
171  *out << G4endl;
172 }
173 
174 
175 std::string B01ScoreTable::FillString(const std::string &name,
176  char c, G4int n, G4bool back)
177 {
178  std::string fname("");
179  G4int k = n - name.size();
180  if (k > 0) {
181  if (back) {
182  fname = name;
183  fname += std::string(k,c);
184  }
185  else {
186  fname = std::string(k,c);
187  fname += name;
188  }
189  }
190  else {
191  fname = name;
192  }
193  return fname;
194 }
195 
196 
197 
198 
199 
200 
201 
202 
203