Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4ScoringManager.hh
Go to the documentation of this file.
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//
28
29#ifndef G4ScoringManager_h
30#define G4ScoringManager_h 1
31
32#include "globals.hh"
33#include "G4VScoringMesh.hh"
34#include <vector>
35#include <map>
40#include "G4VScoreWriter.hh"
41
42// class description:
43//
44// This is a singleton class which manages the interactive scoring.
45// The user cannot access to the constructor. The pointer of the
46// only existing object can be got via G4ScoringManager::GetScoringManager()
47// static method. The first invokation of this static method makes
48// the singleton object.
49//
50
51using MeshVec = std::vector<G4VScoringMesh *>;
52using MeshVecItr = MeshVec::iterator;
53using MeshVecConstItr = MeshVec::const_iterator;
54using ColorMapDict = std::map<G4String, G4VScoreColorMap *>;
55using ColorMapDictItr = ColorMapDict::iterator;
56using ColorMapDictConstItr = ColorMapDict::const_iterator;
57using MeshMap = std::map<G4int, G4VScoringMesh *>;
58using MeshMapItr = MeshMap::iterator;
59using MeshMapConstItr = MeshMap::const_iterator;
60
62{
63 public: // with description
65 // Returns the pointer to the singleton object.
66
68
70
71 public:
72 static void SetReplicaLevel(G4int);
73 static G4int GetReplicaLevel();
74
76 // Register a color map. Once registered, it is available by /score/draw and
77 // /score/drawColumn commands.
78
80 void Merge(const G4ScoringManager* scMan);
83 void List() const;
84 void Dump() const;
85 void DrawMesh(const G4String& meshName, const G4String& psName,
86 const G4String& colorMapName, G4int axflg = 111);
87 void DrawMesh(const G4String& meshName, const G4String& psName,
88 G4int idxPlane, G4int iColumn, const G4String& colorMapName);
89 void DumpQuantityToFile(const G4String& meshName, const G4String& psName,
90 const G4String& fileName,
91 const G4String& option = "");
92 void DumpAllQuantitiesToFile(const G4String& meshName,
93 const G4String& fileName,
94 const G4String& option = "");
96 void ListScoreColorMaps();
97
98 inline void SetCurrentMesh(G4VScoringMesh* scm) { fCurrentMesh = scm; }
99 inline G4VScoringMesh* GetCurrentMesh() const { return fCurrentMesh; }
100 inline void CloseCurrentMesh() { fCurrentMesh = nullptr; }
101 inline void SetVerboseLevel(G4int vl)
102 {
103 verboseLevel = vl;
104 for(auto& itr : fMeshVec)
105 {
106 itr->SetVerboseLevel(vl);
107 }
108 if(writer != nullptr)
109 writer->SetVerboseLevel(vl);
110 }
111 inline G4int GetVerboseLevel() const { return verboseLevel; }
112 inline size_t GetNumberOfMesh() const { return fMeshVec.size(); }
114 {
115 scm->SetVerboseLevel(verboseLevel);
116 fMeshVec.push_back(scm);
117 SetCurrentMesh(scm);
118 }
119 inline G4VScoringMesh* GetMesh(G4int i) const { return fMeshVec[i]; }
121 {
122 return fMeshVec[i]->GetWorldName();
123 }
124
125 public: // with description
127 {
128 delete writer;
129 writer = sw;
130 if(writer != nullptr)
131 writer->SetVerboseLevel(verboseLevel);
132 }
133 // Replace score writers.
134
135 public:
136 inline void SetFactor(G4double val = 1.0)
137 {
138 if(writer != nullptr)
139 writer->SetFactor(val);
140 }
141 inline G4double GetFactor() const
142 {
143 if(writer != nullptr)
144 {
145 return writer->GetFactor();
146 }
147
148 return -1.0;
149 }
150
151 protected:
153
154 private:
155 // Disable copy constructor and assignement operator
157 G4ScoringManager& operator=(const G4ScoringManager&);
158
159 private:
160 static G4ThreadLocal G4ScoringManager* fSManager;
161 static G4ThreadLocal G4int replicaLevel;
162 G4int verboseLevel;
163 G4ScoringMessenger* fMessenger;
164 G4ScoreQuantityMessenger* fQuantityMessenger;
165
166 MeshVec fMeshVec;
167 G4VScoringMesh* fCurrentMesh;
168
169 G4VScoreWriter* writer;
170 G4VScoreColorMap* fDefaultLinearColorMap;
171 ColorMapDict* fColorMapDict;
172
173 MeshMap fMeshMap;
174};
175
176#endif
MeshVec::iterator MeshVecItr
MeshMap::const_iterator MeshMapConstItr
MeshVec::const_iterator MeshVecConstItr
std::map< G4String, G4VScoreColorMap * > ColorMapDict
MeshMap::iterator MeshMapItr
std::vector< G4VScoringMesh * > MeshVec
std::map< G4int, G4VScoringMesh * > MeshMap
ColorMapDict::iterator ColorMapDictItr
ColorMapDict::const_iterator ColorMapDictConstItr
double G4double
Definition G4Types.hh:83
int G4int
Definition G4Types.hh:85
static G4int GetReplicaLevel()
G4VScoringMesh * GetMesh(G4int i) const
void RegisterScoringMesh(G4VScoringMesh *scm)
void Accumulate(G4VHitsCollection *map)
G4int GetVerboseLevel() const
static void SetReplicaLevel(G4int)
void SetVerboseLevel(G4int vl)
size_t GetNumberOfMesh() const
G4VScoreColorMap * GetScoreColorMap(const G4String &mapName)
void DumpAllQuantitiesToFile(const G4String &meshName, const G4String &fileName, const G4String &option="")
static G4ScoringManager * GetScoringManager()
G4VScoringMesh * FindMesh(G4VHitsCollection *map)
G4String GetWorldName(G4int i) const
void SetCurrentMesh(G4VScoringMesh *scm)
void RegisterScoreColorMap(G4VScoreColorMap *colorMap)
void DrawMesh(const G4String &meshName, const G4String &psName, const G4String &colorMapName, G4int axflg=111)
void SetFactor(G4double val=1.0)
G4VScoringMesh * GetCurrentMesh() const
G4double GetFactor() const
void SetScoreWriter(G4VScoreWriter *sw)
void Merge(const G4ScoringManager *scMan)
static G4ScoringManager * GetScoringManagerIfExist()
void DumpQuantityToFile(const G4String &meshName, const G4String &psName, const G4String &fileName, const G4String &option="")
void SetFactor(G4double val=1.0)
G4double GetFactor() const
void SetVerboseLevel(G4int vl)
void SetVerboseLevel(G4int vl)
#define G4ThreadLocal
Definition tls.hh:77