Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4ScoringManager.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 //
26 //
27 // $Id: G4ScoringManager.cc 94772 2015-12-09 09:46:45Z gcosmo $
28 //
29 
30 #include "G4ScoringManager.hh"
31 #include "G4ScoringMessenger.hh"
33 #include "G4VScoringMesh.hh"
34 #include "G4THitsMap.hh"
35 #include "G4VScoreColorMap.hh"
37 #include "G4ScoreLogColorMap.hh"
38 
40 
42 
44 {
45  if(!fSManager)
46  {
48  }
49  return fSManager;
50 }
51 
53 { return fSManager; }
54 
56  : verboseLevel(0),fCurrentMesh(nullptr)
57 {
58  fMessenger = new G4ScoringMessenger(this);
61  fDefaultLinearColorMap = new G4DefaultLinearColorMap("defaultLinearColorMap");
63  G4VScoreColorMap * logColorMap = new G4ScoreLogColorMap("logColorMap");
64  (*fColorMapDict)[logColorMap->GetName()] = logColorMap;
65  writer = new G4VScoreWriter();
66 }
67 
69 {
70  if (writer) { delete writer; }
72  delete fColorMapDict;
73  delete fQuantityMessenger;
74  delete fMessenger;
75  fSManager = nullptr;
76 }
77 
79 { replicaLevel = lvl; }
81 { return replicaLevel; }
82 
84 {
85  auto sm = FindMesh(map);
86  if(!sm) return;
87  if(verboseLevel>9)
88  { G4cout << "G4ScoringManager::Accumulate() for " << map->GetSDname() << " / " << map->GetName() << G4endl;
89  G4cout << " is calling G4VScoringMesh::Accumulate() of " << sm->GetWorldName() << G4endl; }
90  sm->Accumulate(static_cast<G4THitsMap<double>*>(map));
91 }
92 
94 {
95  auto colID = map->GetColID();
96  G4VScoringMesh* sm = nullptr;
97  auto msh = fMeshMap.find(colID);
98  if(msh==fMeshMap.end())
99  {
100  auto wName = map->GetSDname();
101  sm = FindMesh(wName);
102  fMeshMap[colID] = sm;
103  }
104  else
105  { sm = (*msh).second; }
106  return sm;
107 }
108 
110 {
111  G4VScoringMesh* sm = nullptr;
112  for(auto msh : fMeshVec)
113  { if(msh->GetWorldName()==wName) return msh; }
114  if(!sm && verboseLevel>9)
115  { G4cout << "WARNING : G4ScoringManager::FindMesh() --- <" << wName << "> is not found. Null returned." << G4endl; }
116  return nullptr;
117 }
118 
120 {
121  G4cout << "G4ScoringManager has " << GetNumberOfMesh() << " scoring meshes." << G4endl;
122  for(auto msh : fMeshVec) msh->List();
123 }
124 
126 {
127  for(auto msh : fMeshVec) msh->Dump();
128 }
129 
131  const G4String& psName,
132  const G4String& colorMapName, G4int axflg)
133 {
134  G4VScoringMesh* mesh = FindMesh(meshName);
135  if(mesh)
136  {
137  G4VScoreColorMap* colorMap = GetScoreColorMap(colorMapName);
138  if(!colorMap)
139  {
140  G4cerr << "WARNING : Score color map <" << colorMapName << "> is not found. Default linear color map is used." << G4endl;
141  colorMap = fDefaultLinearColorMap;
142  }
143  mesh->DrawMesh(psName,colorMap,axflg);
144  } else {
145  G4cerr << "ERROR : G4ScoringManager::DrawMesh() --- <"
146  << meshName << "> is not found. Nothing is done." << G4endl;
147  }
148 }
149 
151  const G4String& psName,
152  G4int idxPlane, G4int iColumn,
153  const G4String& colorMapName)
154 {
155  G4VScoringMesh* mesh = FindMesh(meshName);
156  if(mesh)
157  {
158  G4VScoreColorMap* colorMap = GetScoreColorMap(colorMapName);
159  if(!colorMap)
160  {
161  G4cerr << "WARNING : Score color map <" << colorMapName << "> is not found. Default linear color map is used." << G4endl;
162  colorMap = fDefaultLinearColorMap;
163  }
164  mesh->DrawMesh(psName,idxPlane,iColumn,colorMap);
165  } else {
166  G4cerr << "ERROR : G4ScoringManager::DrawMesh() --- <"
167  << meshName << "> is not found. Nothing is done." << G4endl;
168  }
169 }
170 
172  const G4String& psName,
173  const G4String& fileName,
174  const G4String& option)
175 {
176  G4VScoringMesh* mesh = FindMesh(meshName);
177  if(mesh) {
178  writer->SetScoringMesh(mesh);
179  writer->DumpQuantityToFile(psName, fileName, option);
180  } else {
181  G4cerr << "ERROR : G4ScoringManager::DrawQuantityToFile() --- <"
182  << meshName << "> is not found. Nothing is done." << G4endl;
183  }
184 }
185 
187  const G4String& fileName,
188  const G4String& option)
189 {
190  G4VScoringMesh* mesh = FindMesh(meshName);
191  if(mesh) {
192  writer->SetScoringMesh(mesh);
193  writer->DumpAllQuantitiesToFile(fileName, option);
194  } else {
195  G4cerr << "ERROR : G4ScoringManager::DrawAllQuantitiesToFile() --- <"
196  << meshName << "> is not found. Nothing is done." << G4endl;
197  }
198 }
199 
201 {
202  if(fColorMapDict->find(colorMap->GetName()) != fColorMapDict->end())
203  {
204  G4cerr << "ERROR : G4ScoringManager::RegisterScoreColorMap -- "
205  << colorMap->GetName() << " has already been registered. Method ignored." << G4endl;
206  }
207  else
208  {
209  (*fColorMapDict)[colorMap->GetName()] = colorMap;
210  }
211 }
212 
214 {
215  ColorMapDictItr mItr = fColorMapDict->find(mapName);
216  if(mItr == fColorMapDict->end()) { return nullptr; }
217  return (mItr->second);
218 }
219 
221 {
222  G4cout << "Registered Score Color Maps -------------------------------------------------------" << G4endl;
223  ColorMapDictItr mItr = fColorMapDict->begin();
224  for(;mItr!=fColorMapDict->end();mItr++)
225  { G4cout << " " << mItr->first; }
226  G4cout << G4endl;
227 }
228 
230 {
231  for(size_t i = 0; i< GetNumberOfMesh() ; i++)
232  {
233  G4VScoringMesh* fMesh = GetMesh(i);
234  G4VScoringMesh* scMesh = mgr->GetMesh(i);
235  fMesh->Merge(scMesh);
236  }
237 }
238 
239 
G4VScoreColorMap * fDefaultLinearColorMap
void List() const
std::map< G4String, G4VScoreColorMap * >::iterator ColorMapDictItr
size_t GetNumberOfMesh() const
G4ScoreQuantityMessenger * fQuantityMessenger
static void SetReplicaLevel(G4int)
void RegisterScoreColorMap(G4VScoreColorMap *colorMap)
void Merge(const G4VScoringMesh *scMesh)
#define G4endl
Definition: G4ios.hh:61
G4VScoreColorMap * GetScoreColorMap(const G4String &mapName)
void DrawMesh(const G4String &psName, G4VScoreColorMap *colorMap, G4int axflg=111)
#define G4ThreadLocal
Definition: tls.hh:69
virtual void DumpAllQuantitiesToFile(const G4String &fileName, const G4String &option)
void DrawMesh(const G4String &meshName, const G4String &psName, const G4String &colorMapName, G4int axflg=111)
void DumpAllQuantitiesToFile(const G4String &meshName, const G4String &fileName, const G4String &option="")
G4ScoringMessenger * fMessenger
virtual void DumpQuantityToFile(const G4String &psName, const G4String &fileName, const G4String &option)
static G4ScoringManager * GetScoringManagerIfExist()
void Merge(const G4ScoringManager *scMan)
static G4ThreadLocal G4ScoringManager * fSManager
G4GLOB_DLL std::ostream G4cerr
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
void DumpQuantityToFile(const G4String &meshName, const G4String &psName, const G4String &fileName, const G4String &option="")
void Dump() const
G4VScoringMesh * GetMesh(G4int i) const
G4VScoreWriter * writer
void Accumulate(G4VHitsCollection *map)
static G4ThreadLocal G4int replicaLevel
std::map< G4String, G4VScoreColorMap * > ColorMapDict
G4String GetName() const
static G4ScoringManager * GetScoringManager()
G4VScoringMesh * FindMesh(G4VHitsCollection *map)
static G4int GetReplicaLevel()
ColorMapDict * fColorMapDict
void SetScoringMesh(G4VScoringMesh *sm)