Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4ScoringManager Class Reference

#include <G4ScoringManager.hh>

Public Member Functions

 ~G4ScoringManager ()
 
void RegisterScoreColorMap (G4VScoreColorMap *colorMap)
 
void Accumulate (G4VHitsCollection *map)
 
void Merge (const G4ScoringManager *scMan)
 
G4VScoringMeshFindMesh (G4VHitsCollection *map)
 
G4VScoringMeshFindMesh (const G4String &)
 
void List () const
 
void Dump () const
 
void DrawMesh (const G4String &meshName, const G4String &psName, const G4String &colorMapName, G4int axflg=111)
 
void DrawMesh (const G4String &meshName, const G4String &psName, G4int idxPlane, G4int iColumn, const G4String &colorMapName)
 
void DumpQuantityToFile (const G4String &meshName, const G4String &psName, const G4String &fileName, const G4String &option="")
 
void DumpAllQuantitiesToFile (const G4String &meshName, const G4String &fileName, const G4String &option="")
 
G4VScoreColorMapGetScoreColorMap (const G4String &mapName)
 
void ListScoreColorMaps ()
 
void SetCurrentMesh (G4VScoringMesh *scm)
 
G4VScoringMeshGetCurrentMesh () const
 
void CloseCurrentMesh ()
 
void SetVerboseLevel (G4int vl)
 
G4int GetVerboseLevel () const
 
size_t GetNumberOfMesh () const
 
void RegisterScoringMesh (G4VScoringMesh *scm)
 
G4VScoringMeshGetMesh (G4int i) const
 
G4String GetWorldName (G4int i) const
 
void SetScoreWriter (G4VScoreWriter *sw)
 
void SetFactor (G4double val=1.0)
 
G4double GetFactor () const
 

Static Public Member Functions

static G4ScoringManagerGetScoringManager ()
 
static G4ScoringManagerGetScoringManagerIfExist ()
 
static void SetReplicaLevel (G4int)
 
static G4int GetReplicaLevel ()
 

Protected Member Functions

 G4ScoringManager ()
 

Detailed Description

Definition at line 61 of file G4ScoringManager.hh.

Constructor & Destructor Documentation

◆ ~G4ScoringManager()

G4ScoringManager::~G4ScoringManager ( )

Definition at line 70 of file G4ScoringManager.cc.

71{
72 delete writer;
73 delete fDefaultLinearColorMap;
74 delete fColorMapDict;
75 delete fQuantityMessenger;
76 delete fMessenger;
77 fSManager = nullptr;
78}

◆ G4ScoringManager()

G4ScoringManager::G4ScoringManager ( )
protected

Definition at line 56 of file G4ScoringManager.cc.

57 : verboseLevel(0)
58 , fCurrentMesh(nullptr)
59{
60 fMessenger = new G4ScoringMessenger(this);
61 fQuantityMessenger = new G4ScoreQuantityMessenger(this);
62 fColorMapDict = new ColorMapDict();
63 fDefaultLinearColorMap = new G4DefaultLinearColorMap("defaultLinearColorMap");
64 (*fColorMapDict)[fDefaultLinearColorMap->GetName()] = fDefaultLinearColorMap;
65 G4VScoreColorMap* logColorMap = new G4ScoreLogColorMap("logColorMap");
66 (*fColorMapDict)[logColorMap->GetName()] = logColorMap;
67 writer = new G4VScoreWriter();
68}
std::map< G4String, G4VScoreColorMap * > ColorMapDict
G4String GetName() const

Referenced by GetScoringManager().

Member Function Documentation

◆ Accumulate()

void G4ScoringManager::Accumulate ( G4VHitsCollection map)

Definition at line 83 of file G4ScoringManager.cc.

84{
85 auto sm = FindMesh(map);
86 if(sm == nullptr)
87 return;
88 if(verboseLevel > 9)
89 {
90 G4cout << "G4ScoringManager::Accumulate() for " << map->GetSDname() << " / "
91 << map->GetName() << G4endl;
92 G4cout << " is calling G4VScoringMesh::Accumulate() of "
93 << sm->GetWorldName() << G4endl;
94 }
95 sm->Accumulate(static_cast<G4THitsMap<double>*>(map));
96}
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
G4VScoringMesh * FindMesh(G4VHitsCollection *map)
const G4String & GetSDname() const
const G4String & GetName() const

Referenced by G4RunManager::UpdateScoring().

◆ CloseCurrentMesh()

void G4ScoringManager::CloseCurrentMesh ( )
inline

Definition at line 100 of file G4ScoringManager.hh.

100{ fCurrentMesh = nullptr; }

Referenced by G4ScoringMessenger::SetNewValue().

◆ DrawMesh() [1/2]

void G4ScoringManager::DrawMesh ( const G4String meshName,
const G4String psName,
const G4String colorMapName,
G4int  axflg = 111 
)

Definition at line 146 of file G4ScoringManager.cc.

149{
150 G4VScoringMesh* mesh = FindMesh(meshName);
151 if(mesh != nullptr)
152 {
153 G4VScoreColorMap* colorMap = GetScoreColorMap(colorMapName);
154 if(colorMap == nullptr)
155 {
156 G4cerr << "WARNING : Score color map <" << colorMapName
157 << "> is not found. Default linear color map is used." << G4endl;
158 colorMap = fDefaultLinearColorMap;
159 }
160 mesh->DrawMesh(psName, colorMap, axflg);
161 }
162 else
163 {
164 G4cerr << "ERROR : G4ScoringManager::DrawMesh() --- <" << meshName
165 << "> is not found. Nothing is done." << G4endl;
166 }
167}
G4GLOB_DLL std::ostream G4cerr
G4VScoreColorMap * GetScoreColorMap(const G4String &mapName)
void DrawMesh(const G4String &psName, G4VScoreColorMap *colorMap, G4int axflg=111)

Referenced by G4ScoringMessenger::SetNewValue().

◆ DrawMesh() [2/2]

void G4ScoringManager::DrawMesh ( const G4String meshName,
const G4String psName,
G4int  idxPlane,
G4int  iColumn,
const G4String colorMapName 
)

Definition at line 169 of file G4ScoringManager.cc.

172{
173 G4VScoringMesh* mesh = FindMesh(meshName);
174 if(mesh != nullptr)
175 {
176 G4VScoreColorMap* colorMap = GetScoreColorMap(colorMapName);
177 if(colorMap == nullptr)
178 {
179 G4cerr << "WARNING : Score color map <" << colorMapName
180 << "> is not found. Default linear color map is used." << G4endl;
181 colorMap = fDefaultLinearColorMap;
182 }
183 mesh->DrawMesh(psName, idxPlane, iColumn, colorMap);
184 }
185 else
186 {
187 G4cerr << "ERROR : G4ScoringManager::DrawMesh() --- <" << meshName
188 << "> is not found. Nothing is done." << G4endl;
189 }
190}

◆ Dump()

void G4ScoringManager::Dump ( ) const

Definition at line 140 of file G4ScoringManager.cc.

141{
142 for(auto msh : fMeshVec)
143 msh->Dump();
144}

Referenced by G4ScoringMessenger::SetNewValue().

◆ DumpAllQuantitiesToFile()

void G4ScoringManager::DumpAllQuantitiesToFile ( const G4String meshName,
const G4String fileName,
const G4String option = "" 
)

Definition at line 210 of file G4ScoringManager.cc.

213{
214 G4VScoringMesh* mesh = FindMesh(meshName);
215 if(mesh != nullptr)
216 {
217 writer->SetScoringMesh(mesh);
218 writer->DumpAllQuantitiesToFile(fileName, option);
219 }
220 else
221 {
222 G4cerr << "ERROR : G4ScoringManager::DrawAllQuantitiesToFile() --- <"
223 << meshName << "> is not found. Nothing is done." << G4endl;
224 }
225}
virtual void DumpAllQuantitiesToFile(const G4String &fileName, const G4String &option)
void SetScoringMesh(G4VScoringMesh *sm)

Referenced by G4ScoringMessenger::SetNewValue().

◆ DumpQuantityToFile()

void G4ScoringManager::DumpQuantityToFile ( const G4String meshName,
const G4String psName,
const G4String fileName,
const G4String option = "" 
)

Definition at line 192 of file G4ScoringManager.cc.

196{
197 G4VScoringMesh* mesh = FindMesh(meshName);
198 if(mesh != nullptr)
199 {
200 writer->SetScoringMesh(mesh);
201 writer->DumpQuantityToFile(psName, fileName, option);
202 }
203 else
204 {
205 G4cerr << "ERROR : G4ScoringManager::DrawQuantityToFile() --- <" << meshName
206 << "> is not found. Nothing is done." << G4endl;
207 }
208}
virtual void DumpQuantityToFile(const G4String &psName, const G4String &fileName, const G4String &option)

Referenced by G4ScoringMessenger::SetNewValue().

◆ FindMesh() [1/2]

G4VScoringMesh * G4ScoringManager::FindMesh ( const G4String wName)

Definition at line 116 of file G4ScoringManager.cc.

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::FindMesh() --- <" << wName
127 << "> is not found. Null returned." << G4endl;
128 }
129 return nullptr;
130}

◆ FindMesh() [2/2]

G4VScoringMesh * G4ScoringManager::FindMesh ( G4VHitsCollection map)

Definition at line 98 of file G4ScoringManager.cc.

99{
100 auto colID = map->GetColID();
101 G4VScoringMesh* sm = nullptr;
102 auto msh = fMeshMap.find(colID);
103 if(msh == fMeshMap.end())
104 {
105 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}
G4int GetColID() const

Referenced by Accumulate(), G4GMocrenFileSceneHandler::AddSolid(), DrawMesh(), DumpAllQuantitiesToFile(), DumpQuantityToFile(), FindMesh(), and G4ScoringMessenger::SetNewValue().

◆ GetCurrentMesh()

G4VScoringMesh * G4ScoringManager::GetCurrentMesh ( ) const
inline

Definition at line 99 of file G4ScoringManager.hh.

99{ return fCurrentMesh; }

Referenced by G4ScoreQuantityMessenger::SetNewValue(), and G4ScoringMessenger::SetNewValue().

◆ GetFactor()

G4double G4ScoringManager::GetFactor ( ) const
inline

Definition at line 141 of file G4ScoringManager.hh.

142 {
143 if(writer != nullptr)
144 {
145 return writer->GetFactor();
146 }
147
148 return -1.0;
149 }
G4double GetFactor() const

◆ GetMesh()

G4VScoringMesh * G4ScoringManager::GetMesh ( G4int  i) const
inline

◆ GetNumberOfMesh()

size_t G4ScoringManager::GetNumberOfMesh ( ) const
inline

◆ GetReplicaLevel()

G4int G4ScoringManager::GetReplicaLevel ( )
static

Definition at line 81 of file G4ScoringManager.cc.

81{ return replicaLevel; }

Referenced by G4ScoringBox::SetupGeometry(), and G4ScoringCylinder::SetupGeometry().

◆ GetScoreColorMap()

G4VScoreColorMap * G4ScoringManager::GetScoreColorMap ( const G4String mapName)

Definition at line 241 of file G4ScoringManager.cc.

242{
243 auto mItr = fColorMapDict->find(mapName);
244 if(mItr == fColorMapDict->cend())
245 {
246 return nullptr;
247 }
248 return (mItr->second);
249}

Referenced by DrawMesh(), and G4ScoringMessenger::SetNewValue().

◆ GetScoringManager()

G4ScoringManager * G4ScoringManager::GetScoringManager ( )
static

Definition at line 42 of file G4ScoringManager.cc.

43{
44 if(fSManager == nullptr)
45 {
46 fSManager = new G4ScoringManager;
47 }
48 return fSManager;
49}

Referenced by G4GMocrenFileSceneHandler::AddSolid(), and G4WorkerRunManager::G4WorkerRunManager().

◆ GetScoringManagerIfExist()

◆ GetVerboseLevel()

G4int G4ScoringManager::GetVerboseLevel ( ) const
inline

Definition at line 111 of file G4ScoringManager.hh.

111{ return verboseLevel; }

Referenced by G4ScoringMessenger::GetCurrentValue().

◆ GetWorldName()

G4String G4ScoringManager::GetWorldName ( G4int  i) const
inline

Definition at line 120 of file G4ScoringManager.hh.

121 {
122 return fMeshVec[i]->GetWorldName();
123 }

Referenced by G4RunManager::ConstructScoringWorlds(), and G4WorkerRunManager::ConstructScoringWorlds().

◆ List()

void G4ScoringManager::List ( ) const

Definition at line 132 of file G4ScoringManager.cc.

133{
134 G4cout << "G4ScoringManager has " << GetNumberOfMesh() << " scoring meshes."
135 << G4endl;
136 for(auto msh : fMeshVec)
137 msh->List();
138}
size_t GetNumberOfMesh() const

Referenced by G4ScoringMessenger::SetNewValue().

◆ ListScoreColorMaps()

void G4ScoringManager::ListScoreColorMaps ( )

Definition at line 251 of file G4ScoringManager.cc.

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}

Referenced by G4ScoringMessenger::SetNewValue().

◆ Merge()

void G4ScoringManager::Merge ( const G4ScoringManager scMan)

Definition at line 264 of file G4ScoringManager.cc.

265{
266 for(G4int i = 0; i < (G4int)GetNumberOfMesh(); ++i)
267 {
268 G4VScoringMesh* fMesh = GetMesh(i);
269 G4VScoringMesh* scMesh = mgr->GetMesh(i);
270 fMesh->Merge(scMesh);
271 }
272}
int G4int
Definition: G4Types.hh:85
G4VScoringMesh * GetMesh(G4int i) const
void Merge(const G4VScoringMesh *scMesh)

Referenced by G4MTRunManager::MergeScores(), and G4TaskRunManager::MergeScores().

◆ RegisterScoreColorMap()

void G4ScoringManager::RegisterScoreColorMap ( G4VScoreColorMap colorMap)

Definition at line 227 of file G4ScoringManager.cc.

228{
229 if(fColorMapDict->find(colorMap->GetName()) != fColorMapDict->cend())
230 {
231 G4cerr << "ERROR : G4ScoringManager::RegisterScoreColorMap -- "
232 << colorMap->GetName()
233 << " has already been registered. Method ignored." << G4endl;
234 }
235 else
236 {
237 (*fColorMapDict)[colorMap->GetName()] = colorMap;
238 }
239}

◆ RegisterScoringMesh()

void G4ScoringManager::RegisterScoringMesh ( G4VScoringMesh scm)
inline

Definition at line 113 of file G4ScoringManager.hh.

114 {
115 scm->SetVerboseLevel(verboseLevel);
116 fMeshVec.push_back(scm);
117 SetCurrentMesh(scm);
118 }
void SetCurrentMesh(G4VScoringMesh *scm)
void SetVerboseLevel(G4int vl)

Referenced by G4ScoringMessenger::SetNewValue().

◆ SetCurrentMesh()

void G4ScoringManager::SetCurrentMesh ( G4VScoringMesh scm)
inline

Definition at line 98 of file G4ScoringManager.hh.

98{ fCurrentMesh = scm; }

Referenced by RegisterScoringMesh(), and G4ScoringMessenger::SetNewValue().

◆ SetFactor()

void G4ScoringManager::SetFactor ( G4double  val = 1.0)
inline

Definition at line 136 of file G4ScoringManager.hh.

137 {
138 if(writer != nullptr)
139 writer->SetFactor(val);
140 }
void SetFactor(G4double val=1.0)

Referenced by G4ScoringMessenger::SetNewValue().

◆ SetReplicaLevel()

void G4ScoringManager::SetReplicaLevel ( G4int  lvl)
static

Definition at line 80 of file G4ScoringManager.cc.

80{ replicaLevel = lvl; }

◆ SetScoreWriter()

void G4ScoringManager::SetScoreWriter ( G4VScoreWriter sw)
inline

Definition at line 126 of file G4ScoringManager.hh.

127 {
128 delete writer;
129 writer = sw;
130 if(writer != nullptr)
131 writer->SetVerboseLevel(verboseLevel);
132 }
void SetVerboseLevel(G4int vl)

◆ SetVerboseLevel()

void G4ScoringManager::SetVerboseLevel ( G4int  vl)
inline

Definition at line 101 of file G4ScoringManager.hh.

102 {
103 verboseLevel = vl;
104 for(auto& itr : fMeshVec)
105 {
106 itr->SetVerboseLevel(vl);
107 }
108 if(writer != nullptr)
109 writer->SetVerboseLevel(vl);
110 }

Referenced by G4ScoringMessenger::SetNewValue().


The documentation for this class was generated from the following files: