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] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /digits_hits/utils/src/G4ScoringManager.cc (Version 11.3.0) and /digits_hits/utils/src/G4ScoringManager.cc (Version 10.1.p3)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 // G4ScoringManager                            <<  26 //
 27 // ------------------------------------------- <<  27 // $Id: G4ScoringManager.cc 78004 2013-12-02 08:28:23Z gcosmo $
                                                   >>  28 //
 28                                                    29 
 29 #include "G4ScoringManager.hh"                     30 #include "G4ScoringManager.hh"
 30 #include "G4ScoringMessenger.hh"                   31 #include "G4ScoringMessenger.hh"
 31 #include "G4ScoreQuantityMessenger.hh"             32 #include "G4ScoreQuantityMessenger.hh"
 32 #include "G4VScoringMesh.hh"                       33 #include "G4VScoringMesh.hh"
 33 #include "G4THitsMap.hh"                           34 #include "G4THitsMap.hh"
 34 #include "G4VScoreColorMap.hh"                     35 #include "G4VScoreColorMap.hh"
 35 #include "G4DefaultLinearColorMap.hh"              36 #include "G4DefaultLinearColorMap.hh"
 36 #include "G4ScoreLogColorMap.hh"                   37 #include "G4ScoreLogColorMap.hh"
 37                                                    38 
 38 G4ThreadLocal G4ScoringManager* G4ScoringManag <<  39 G4ThreadLocal G4ScoringManager* G4ScoringManager::fSManager = 0;
 39                                                    40 
 40 G4ThreadLocal G4int G4ScoringManager::replicaL     41 G4ThreadLocal G4int G4ScoringManager::replicaLevel = 3;
 41                                                    42 
 42 G4ScoringManager* G4ScoringManager::GetScoring     43 G4ScoringManager* G4ScoringManager::GetScoringManager()
 43 {                                                  44 {
 44   if(fSManager == nullptr)                     <<  45   if(!fSManager)
 45   {                                                46   {
 46     fSManager = new G4ScoringManager;              47     fSManager = new G4ScoringManager;
 47   }                                                48   }
 48   return fSManager;                                49   return fSManager;
 49 }                                                  50 }
 50                                                    51 
 51 G4ScoringManager* G4ScoringManager::GetScoring     52 G4ScoringManager* G4ScoringManager::GetScoringManagerIfExist()
 52 {                                              <<  53 { return fSManager; }
 53   return fSManager;                            << 
 54 }                                              << 
 55                                                    54 
 56 G4ScoringManager::G4ScoringManager()               55 G4ScoringManager::G4ScoringManager()
 57   : verboseLevel(0)                            <<  56   : verboseLevel(0),fCurrentMesh(0)
 58   , fCurrentMesh(nullptr)                      << 
 59 {                                                  57 {
 60   fMessenger             = new G4ScoringMessen <<  58   fMessenger = new G4ScoringMessenger(this);
 61   fQuantityMessenger     = new G4ScoreQuantity <<  59   fQuantityMessenger = new G4ScoreQuantityMessenger(this);
 62   fColorMapDict          = new ColorMapDict(); <<  60   fColorMapDict = new ColorMapDict();
 63   fDefaultLinearColorMap = new G4DefaultLinear     61   fDefaultLinearColorMap = new G4DefaultLinearColorMap("defaultLinearColorMap");
 64   (*fColorMapDict)[fDefaultLinearColorMap->Get     62   (*fColorMapDict)[fDefaultLinearColorMap->GetName()] = fDefaultLinearColorMap;
 65   G4VScoreColorMap* logColorMap = new G4ScoreL <<  63   G4VScoreColorMap * logColorMap = new G4ScoreLogColorMap("logColorMap");
 66   (*fColorMapDict)[logColorMap->GetName()] = l     64   (*fColorMapDict)[logColorMap->GetName()] = logColorMap;
 67   writer                                   = n <<  65   writer = new G4VScoreWriter();
 68 }                                                  66 }
 69                                                    67 
 70 G4ScoringManager::~G4ScoringManager()              68 G4ScoringManager::~G4ScoringManager()
 71 {                                              <<  69 {
 72   delete writer;                               <<  70   if (writer) { delete writer; }
 73   delete fDefaultLinearColorMap;                   71   delete fDefaultLinearColorMap;
 74   delete fColorMapDict;                            72   delete fColorMapDict;
 75   delete fQuantityMessenger;                       73   delete fQuantityMessenger;
 76   delete fMessenger;                               74   delete fMessenger;
 77   fSManager = nullptr;                         <<  75   fSManager = 0;
 78 }                                                  76 }
 79                                                    77 
 80 void G4ScoringManager::SetReplicaLevel(G4int l <<  78 void G4ScoringManager::SetReplicaLevel(G4int lvl)
 81 G4int G4ScoringManager::GetReplicaLevel() { re <<  79 { replicaLevel = lvl; }
                                                   >>  80 G4int G4ScoringManager::GetReplicaLevel()
                                                   >>  81 { return replicaLevel; }
 82                                                    82 
 83 void G4ScoringManager::Accumulate(G4VHitsColle     83 void G4ScoringManager::Accumulate(G4VHitsCollection* map)
 84 {                                                  84 {
 85   auto sm = FindMesh(map);                     <<  85   G4String wName = map->GetSDname();
 86   if(sm == nullptr)                            <<  86   G4VScoringMesh* sm = FindMesh(wName);
 87     return;                                    <<  87   if(sm == 0) return;
 88   if(verboseLevel > 9)                         <<  88   if(verboseLevel>9)
 89   {                                            <<  89   { G4cout << "G4ScoringManager::Accumulate() for " << map->GetSDname() << " / " << map->GetName() << G4endl;
 90     G4cout << "G4ScoringManager::Accumulate()  <<  90     G4cout << "  is calling G4VScoringMesh::Accumulate() of " << sm->GetWorldName() << G4endl; }
 91            << map->GetName() << G4endl;        << 
 92     G4cout << "  is calling G4VScoringMesh::Ac << 
 93            << sm->GetWorldName() << G4endl;    << 
 94   }                                            << 
 95   sm->Accumulate(static_cast<G4THitsMap<double     91   sm->Accumulate(static_cast<G4THitsMap<double>*>(map));
 96 }                                                  92 }
 97                                                    93 
 98 G4VScoringMesh* G4ScoringManager::FindMesh(G4V << 
 99 {                                              << 
100   auto colID         = map->GetColID();        << 
101   G4VScoringMesh* sm = nullptr;                << 
102   auto msh           = fMeshMap.find(colID);   << 
103   if(msh == fMeshMap.end())                    << 
104   {                                            << 
105     const auto& wName = map->GetSDname();      << 
106     sm              = FindMesh(wName);         << 
107     fMeshMap[colID] = sm;                      << 
108   }                                            << 
109   else                                         << 
110   {                                            << 
111     sm = (*msh).second;                        << 
112   }                                            << 
113   return sm;                                   << 
114 }                                              << 
115                                                << 
116 G4VScoringMesh* G4ScoringManager::FindMesh(con     94 G4VScoringMesh* G4ScoringManager::FindMesh(const G4String& wName)
117 {                                                  95 {
118   G4VScoringMesh* sm = nullptr;                <<  96   G4VScoringMesh* sm = 0;
119   for(auto msh : fMeshVec)                     <<  97   for(MeshVecItr itr = fMeshVec.begin(); itr != fMeshVec.end(); itr++) {
120   {                                            <<  98     G4String smName = (*itr)->GetWorldName();
121     if(msh->GetWorldName() == wName)           <<  99     if(wName == smName) {
122       return msh;                              << 100       sm = *itr;
123   }                                            << 101       break;
124   if((sm == nullptr) && verboseLevel > 9)      << 102     }
125   {                                            << 
126     G4cout << "WARNING : G4ScoringManager::Fin << 
127            << "> is not found. Null returned." << 
128   }                                               103   }
129   return nullptr;                              << 104   if(!sm && verboseLevel>9)
                                                   >> 105   { G4cout << "WARNING : G4ScoringManager::FindMesh() --- <" << wName << "> is not found. Null returned." << G4endl; }
                                                   >> 106 
                                                   >> 107   return sm;
130 }                                                 108 }
131                                                   109 
132 void G4ScoringManager::List() const               110 void G4ScoringManager::List() const
133 {                                                 111 {
134   G4cout << "G4ScoringManager has " << GetNumb << 112   G4cout << "G4ScoringManager has " << GetNumberOfMesh() << " scoring meshes." << G4endl;
135          << G4endl;                            << 113   for(MeshVecConstItr itr = fMeshVec.begin(); itr != fMeshVec.end(); itr++) {
136   for(auto msh : fMeshVec)                     << 114    (*itr)->List();
137     msh->List();                               << 115   }
138 }                                                 116 }
139                                                   117 
140 void G4ScoringManager::Dump() const               118 void G4ScoringManager::Dump() const
141 {                                                 119 {
142   for(auto msh : fMeshVec)                     << 120   for(MeshVecConstItr itr = fMeshVec.begin(); itr != fMeshVec.end(); itr++) {
143     msh->Dump();                               << 121    (*itr)->Dump();
                                                   >> 122   }
144 }                                                 123 }
145                                                   124 
146 void G4ScoringManager::DrawMesh(const G4String    125 void G4ScoringManager::DrawMesh(const G4String& meshName,
147                                 const G4String    126                                 const G4String& psName,
148                                 const G4String    127                                 const G4String& colorMapName, G4int axflg)
149 {                                                 128 {
150   G4VScoringMesh* mesh = FindMesh(meshName);      129   G4VScoringMesh* mesh = FindMesh(meshName);
151   if(mesh != nullptr)                          << 130   if(mesh) 
152   {                                               131   {
153     G4VScoreColorMap* colorMap = GetScoreColor    132     G4VScoreColorMap* colorMap = GetScoreColorMap(colorMapName);
154     if(colorMap == nullptr)                    << 133     if(!colorMap)
155     {                                             134     {
156       G4cerr << "WARNING : Score color map <"  << 135       G4cerr << "WARNING : Score color map <" << colorMapName << "> is not found. Default linear color map is used." << G4endl;
157              << "> is not found. Default linea << 
158       colorMap = fDefaultLinearColorMap;          136       colorMap = fDefaultLinearColorMap;
159     }                                             137     }
160     mesh->DrawMesh(psName, colorMap, axflg);   << 138     mesh->DrawMesh(psName,colorMap,axflg);
161   }                                            << 139   } else {
162   else                                         << 140     G4cerr << "ERROR : G4ScoringManager::DrawMesh() --- <"
163   {                                            << 141      << meshName << "> is not found. Nothing is done." << G4endl;
164     G4cerr << "ERROR : G4ScoringManager::DrawM << 
165            << "> is not found. Nothing is done << 
166   }                                               142   }
167 }                                                 143 }
168                                                   144 
169 void G4ScoringManager::DrawMesh(const G4String    145 void G4ScoringManager::DrawMesh(const G4String& meshName,
170                                 const G4String << 146                                 const G4String& psName,
171                                 G4int iColumn, << 147                                       G4int idxPlane, G4int iColumn,
                                                   >> 148                                 const G4String& colorMapName)
172 {                                                 149 {
173   G4VScoringMesh* mesh = FindMesh(meshName);      150   G4VScoringMesh* mesh = FindMesh(meshName);
174   if(mesh != nullptr)                          << 151   if(mesh) 
175   {                                               152   {
176     G4VScoreColorMap* colorMap = GetScoreColor    153     G4VScoreColorMap* colorMap = GetScoreColorMap(colorMapName);
177     if(colorMap == nullptr)                    << 154     if(!colorMap)
178     {                                             155     {
179       G4cerr << "WARNING : Score color map <"  << 156       G4cerr << "WARNING : Score color map <" << colorMapName << "> is not found. Default linear color map is used." << G4endl;
180              << "> is not found. Default linea << 
181       colorMap = fDefaultLinearColorMap;          157       colorMap = fDefaultLinearColorMap;
182     }                                             158     }
183     mesh->DrawMesh(psName, idxPlane, iColumn,  << 159     mesh->DrawMesh(psName,idxPlane,iColumn,colorMap);
184   }                                            << 160   } else {
185   else                                         << 161     G4cerr << "ERROR : G4ScoringManager::DrawMesh() --- <"
186   {                                            << 162      << meshName << "> is not found. Nothing is done." << G4endl;
187     G4cerr << "ERROR : G4ScoringManager::DrawM << 
188            << "> is not found. Nothing is done << 
189   }                                               163   }
190 }                                                 164 }
191                                                   165 
192 void G4ScoringManager::DumpQuantityToFile(cons    166 void G4ScoringManager::DumpQuantityToFile(const G4String& meshName,
193                                           cons    167                                           const G4String& psName,
194                                           cons    168                                           const G4String& fileName,
195                                           cons    169                                           const G4String& option)
196 {                                                 170 {
197   G4VScoringMesh* mesh = FindMesh(meshName);      171   G4VScoringMesh* mesh = FindMesh(meshName);
198   if(mesh != nullptr)                          << 172   if(mesh) {
199   {                                            << 
200     writer->SetScoringMesh(mesh);                 173     writer->SetScoringMesh(mesh);
201     writer->DumpQuantityToFile(psName, fileNam    174     writer->DumpQuantityToFile(psName, fileName, option);
202   }                                            << 175   } else {
203   else                                         << 176     G4cerr << "ERROR : G4ScoringManager::DrawQuantityToFile() --- <"
204   {                                            << 177      << meshName << "> is not found. Nothing is done." << G4endl;
205     G4cerr << "ERROR : G4ScoringManager::DrawQ << 
206            << "> is not found. Nothing is done << 
207   }                                               178   }
208 }                                                 179 }
209                                                   180 
210 void G4ScoringManager::DumpAllQuantitiesToFile    181 void G4ScoringManager::DumpAllQuantitiesToFile(const G4String& meshName,
211                                                   182                                                const G4String& fileName,
212                                                   183                                                const G4String& option)
213 {                                                 184 {
214   G4VScoringMesh* mesh = FindMesh(meshName);      185   G4VScoringMesh* mesh = FindMesh(meshName);
215   if(mesh != nullptr)                          << 186   if(mesh) {
216   {                                            << 
217     writer->SetScoringMesh(mesh);                 187     writer->SetScoringMesh(mesh);
218     writer->DumpAllQuantitiesToFile(fileName,     188     writer->DumpAllQuantitiesToFile(fileName, option);
219   }                                            << 189   } else {
220   else                                         << 
221   {                                            << 
222     G4cerr << "ERROR : G4ScoringManager::DrawA    190     G4cerr << "ERROR : G4ScoringManager::DrawAllQuantitiesToFile() --- <"
223            << meshName << "> is not found. Not << 191      << meshName << "> is not found. Nothing is done." << G4endl;
224   }                                               192   }
225 }                                                 193 }
226                                                   194 
227 void G4ScoringManager::RegisterScoreColorMap(G    195 void G4ScoringManager::RegisterScoreColorMap(G4VScoreColorMap* colorMap)
228 {                                                 196 {
229   if(fColorMapDict->find(colorMap->GetName())  << 197   if(fColorMapDict->find(colorMap->GetName()) != fColorMapDict->end())
230   {                                               198   {
231     G4cerr << "ERROR : G4ScoringManager::Regis    199     G4cerr << "ERROR : G4ScoringManager::RegisterScoreColorMap -- "
232            << colorMap->GetName()              << 200            << colorMap->GetName() << " has already been registered. Method ignored." << G4endl;
233            << " has already been registered. M << 
234   }                                               201   }
235   else                                            202   else
236   {                                               203   {
237     (*fColorMapDict)[colorMap->GetName()] = co    204     (*fColorMapDict)[colorMap->GetName()] = colorMap;
238   }                                               205   }
239 }                                                 206 }
240                                                   207 
241 G4VScoreColorMap* G4ScoringManager::GetScoreCo    208 G4VScoreColorMap* G4ScoringManager::GetScoreColorMap(const G4String& mapName)
242 {                                                 209 {
243   auto mItr = fColorMapDict->find(mapName);    << 210   ColorMapDictItr mItr = fColorMapDict->find(mapName);
244   if(mItr == fColorMapDict->cend())            << 211   if(mItr == fColorMapDict->end()) { return 0; }
245   {                                            << 
246     return nullptr;                            << 
247   }                                            << 
248   return (mItr->second);                          212   return (mItr->second);
249 }                                                 213 }
250                                                   214 
251 void G4ScoringManager::ListScoreColorMaps()       215 void G4ScoringManager::ListScoreColorMaps()
252 {                                                 216 {
253   G4cout << "Registered Score Color Maps "     << 217   G4cout << "Registered Score Color Maps -------------------------------------------------------" << G4endl;
254             "--------------------------------- << 218   ColorMapDictItr mItr = fColorMapDict->begin();
255          << G4endl;                            << 219   for(;mItr!=fColorMapDict->end();mItr++)
256   auto mItr = fColorMapDict->cbegin();         << 220   { G4cout << "   " << mItr->first; }
257   for(; mItr != fColorMapDict->cend(); ++mItr) << 
258   {                                            << 
259     G4cout << "   " << mItr->first;            << 
260   }                                            << 
261   G4cout << G4endl;                               221   G4cout << G4endl;
262 }                                                 222 }
263                                                   223 
264 void G4ScoringManager::Merge(const G4ScoringMa << 224 void G4ScoringManager::Merge(const G4ScoringManager * mgr)
265 {                                              << 225 {  
266   for(auto i = 0; i < (G4int)GetNumberOfMesh() << 226   for(size_t i = 0; i< GetNumberOfMesh() ; i++)
267   {                                               227   {
268     G4VScoringMesh* fMesh  = GetMesh(i);       << 228     G4VScoringMesh* fMesh = GetMesh(i);
269     G4VScoringMesh* scMesh = mgr->GetMesh(i);     229     G4VScoringMesh* scMesh = mgr->GetMesh(i);
270     fMesh->Merge(scMesh);                         230     fMesh->Merge(scMesh);
271   }                                               231   }
272 }                                                 232 }
                                                   >> 233 
                                                   >> 234 
273                                                   235