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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 8.3.p2)


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