Geant4 10.7.0
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 ( )
protected

Definition at line 54 of file G4ScoringManager.cc.

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

Referenced by GetScoringManager().

◆ ~G4ScoringManager()

G4ScoringManager::~G4ScoringManager ( )

Definition at line 67 of file G4ScoringManager.cc.

68{
69 if (writer) { delete writer; }
70 delete fDefaultLinearColorMap;
71 delete fColorMapDict;
72 delete fQuantityMessenger;
73 delete fMessenger;
74 fSManager = nullptr;
75}

Member Function Documentation

◆ Accumulate()

void G4ScoringManager::Accumulate ( G4VHitsCollection map)

Definition at line 82 of file G4ScoringManager.cc.

83{
84 auto sm = FindMesh(map);
85 if(!sm) return;
86 if(verboseLevel>9)
87 { G4cout << "G4ScoringManager::Accumulate() for " << map->GetSDname() << " / " << map->GetName() << G4endl;
88 G4cout << " is calling G4VScoringMesh::Accumulate() of " << sm->GetWorldName() << G4endl; }
89 sm->Accumulate(static_cast<G4THitsMap<double>*>(map));
90}
#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 123 of file G4ScoringManager.hh.

124 { fCurrentMesh = 0; }

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 129 of file G4ScoringManager.cc.

132{
133 G4VScoringMesh* mesh = FindMesh(meshName);
134 if(mesh)
135 {
136 G4VScoreColorMap* colorMap = GetScoreColorMap(colorMapName);
137 if(!colorMap)
138 {
139 G4cerr << "WARNING : Score color map <" << colorMapName << "> is not found. Default linear color map is used." << G4endl;
140 colorMap = fDefaultLinearColorMap;
141 }
142 mesh->DrawMesh(psName,colorMap,axflg);
143 } else {
144 G4cerr << "ERROR : G4ScoringManager::DrawMesh() --- <"
145 << meshName << "> is not found. Nothing is done." << G4endl;
146 }
147}
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 149 of file G4ScoringManager.cc.

153{
154 G4VScoringMesh* mesh = FindMesh(meshName);
155 if(mesh)
156 {
157 G4VScoreColorMap* colorMap = GetScoreColorMap(colorMapName);
158 if(!colorMap)
159 {
160 G4cerr << "WARNING : Score color map <" << colorMapName << "> is not found. Default linear color map is used." << G4endl;
161 colorMap = fDefaultLinearColorMap;
162 }
163 mesh->DrawMesh(psName,idxPlane,iColumn,colorMap);
164 } else {
165 G4cerr << "ERROR : G4ScoringManager::DrawMesh() --- <"
166 << meshName << "> is not found. Nothing is done." << G4endl;
167 }
168}

◆ Dump()

void G4ScoringManager::Dump ( ) const

Definition at line 124 of file G4ScoringManager.cc.

125{
126 for(auto msh : fMeshVec) msh->Dump();
127}

Referenced by G4ScoringMessenger::SetNewValue().

◆ DumpAllQuantitiesToFile()

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

Definition at line 185 of file G4ScoringManager.cc.

188{
189 G4VScoringMesh* mesh = FindMesh(meshName);
190 if(mesh) {
191 writer->SetScoringMesh(mesh);
192 writer->DumpAllQuantitiesToFile(fileName, option);
193 } else {
194 G4cerr << "ERROR : G4ScoringManager::DrawAllQuantitiesToFile() --- <"
195 << meshName << "> is not found. Nothing is done." << G4endl;
196 }
197}
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 170 of file G4ScoringManager.cc.

174{
175 G4VScoringMesh* mesh = FindMesh(meshName);
176 if(mesh) {
177 writer->SetScoringMesh(mesh);
178 writer->DumpQuantityToFile(psName, fileName, option);
179 } else {
180 G4cerr << "ERROR : G4ScoringManager::DrawQuantityToFile() --- <"
181 << meshName << "> is not found. Nothing is done." << G4endl;
182 }
183}
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 108 of file G4ScoringManager.cc.

109{
110 G4VScoringMesh* sm = nullptr;
111 for(auto msh : fMeshVec)
112 { if(msh->GetWorldName()==wName) return msh; }
113 if(!sm && verboseLevel>9)
114 { G4cout << "WARNING : G4ScoringManager::FindMesh() --- <" << wName << "> is not found. Null returned." << G4endl; }
115 return nullptr;
116}

◆ FindMesh() [2/2]

G4VScoringMesh * G4ScoringManager::FindMesh ( G4VHitsCollection map)

Definition at line 92 of file G4ScoringManager.cc.

93{
94 auto colID = map->GetColID();
95 G4VScoringMesh* sm = nullptr;
96 auto msh = fMeshMap.find(colID);
97 if(msh==fMeshMap.end())
98 {
99 auto wName = map->GetSDname();
100 sm = FindMesh(wName);
101 fMeshMap[colID] = sm;
102 }
103 else
104 { sm = (*msh).second; }
105 return sm;
106}
G4int GetColID() const

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

◆ GetCurrentMesh()

G4VScoringMesh * G4ScoringManager::GetCurrentMesh ( ) const
inline

Definition at line 121 of file G4ScoringManager.hh.

122 { return fCurrentMesh; }

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

◆ GetFactor()

G4double G4ScoringManager::GetFactor ( ) const
inline

Definition at line 160 of file G4ScoringManager.hh.

161 {
162 if(writer)
163 { return writer->GetFactor(); }
164 else
165 { return -1.0; }
166 }
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 79 of file G4ScoringManager.cc.

80{ return replicaLevel; }

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

◆ GetScoreColorMap()

G4VScoreColorMap * G4ScoringManager::GetScoreColorMap ( const G4String mapName)

Definition at line 212 of file G4ScoringManager.cc.

213{
214 ColorMapDictItr mItr = fColorMapDict->find(mapName);
215 if(mItr == fColorMapDict->end()) { return nullptr; }
216 return (mItr->second);
217}
std::map< G4String, G4VScoreColorMap * >::iterator ColorMapDictItr

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

◆ GetScoringManager()

G4ScoringManager * G4ScoringManager::GetScoringManager ( )
static

Definition at line 42 of file G4ScoringManager.cc.

43{
44 if(!fSManager)
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 133 of file G4ScoringManager.hh.

134 { return verboseLevel; }

Referenced by G4ScoringMessenger::GetCurrentValue().

◆ GetWorldName()

G4String G4ScoringManager::GetWorldName ( G4int  i) const
inline

Definition at line 145 of file G4ScoringManager.hh.

146 { return fMeshVec[i]->GetWorldName(); }

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

◆ List()

void G4ScoringManager::List ( ) const

Definition at line 118 of file G4ScoringManager.cc.

119{
120 G4cout << "G4ScoringManager has " << GetNumberOfMesh() << " scoring meshes." << G4endl;
121 for(auto msh : fMeshVec) msh->List();
122}
size_t GetNumberOfMesh() const

Referenced by G4ScoringMessenger::SetNewValue().

◆ ListScoreColorMaps()

void G4ScoringManager::ListScoreColorMaps ( )

Definition at line 219 of file G4ScoringManager.cc.

220{
221 G4cout << "Registered Score Color Maps -------------------------------------------------------" << G4endl;
222 ColorMapDictItr mItr = fColorMapDict->begin();
223 for(;mItr!=fColorMapDict->end();mItr++)
224 { G4cout << " " << mItr->first; }
225 G4cout << G4endl;
226}

Referenced by G4ScoringMessenger::SetNewValue().

◆ Merge()

void G4ScoringManager::Merge ( const G4ScoringManager scMan)

Definition at line 228 of file G4ScoringManager.cc.

229{
230 for(size_t i = 0; i< GetNumberOfMesh() ; i++)
231 {
232 G4VScoringMesh* fMesh = GetMesh(i);
233 G4VScoringMesh* scMesh = mgr->GetMesh(i);
234 fMesh->Merge(scMesh);
235 }
236}
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 199 of file G4ScoringManager.cc.

200{
201 if(fColorMapDict->find(colorMap->GetName()) != fColorMapDict->end())
202 {
203 G4cerr << "ERROR : G4ScoringManager::RegisterScoreColorMap -- "
204 << colorMap->GetName() << " has already been registered. Method ignored." << G4endl;
205 }
206 else
207 {
208 (*fColorMapDict)[colorMap->GetName()] = colorMap;
209 }
210}

◆ RegisterScoringMesh()

void G4ScoringManager::RegisterScoringMesh ( G4VScoringMesh scm)
inline

Definition at line 137 of file G4ScoringManager.hh.

138 {
139 scm->SetVerboseLevel(verboseLevel);
140 fMeshVec.push_back(scm);
141 SetCurrentMesh(scm);
142 }
void SetCurrentMesh(G4VScoringMesh *scm)
void SetVerboseLevel(G4int vl)

Referenced by G4ScoringMessenger::SetNewValue().

◆ SetCurrentMesh()

void G4ScoringManager::SetCurrentMesh ( G4VScoringMesh scm)
inline

Definition at line 119 of file G4ScoringManager.hh.

120 { fCurrentMesh = scm; }

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

◆ SetFactor()

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

Definition at line 158 of file G4ScoringManager.hh.

159 { if(writer) writer->SetFactor(val); }
void SetFactor(G4double val=1.0)

Referenced by G4ScoringMessenger::SetNewValue().

◆ SetReplicaLevel()

void G4ScoringManager::SetReplicaLevel ( G4int  lvl)
static

Definition at line 77 of file G4ScoringManager.cc.

78{ replicaLevel = lvl; }

◆ SetScoreWriter()

void G4ScoringManager::SetScoreWriter ( G4VScoreWriter sw)
inline

Definition at line 149 of file G4ScoringManager.hh.

150 {
151 if(writer) { delete writer; }
152 writer = sw;
153 if(writer) writer->SetVerboseLevel(verboseLevel);
154 }
void SetVerboseLevel(G4int vl)

◆ SetVerboseLevel()

void G4ScoringManager::SetVerboseLevel ( G4int  vl)
inline

Definition at line 125 of file G4ScoringManager.hh.

126 {
127 verboseLevel = vl;
128 for(MeshVecItr itr = fMeshVec.begin(); itr != fMeshVec.end(); itr++) {
129 (*itr)->SetVerboseLevel(vl);
130 }
131 if(writer) writer->SetVerboseLevel(vl);
132 }
std::vector< G4VScoringMesh * >::iterator MeshVecItr

Referenced by G4ScoringMessenger::SetNewValue().


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