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