File indexing completed on 2025-01-18 09:59:04
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029 #ifndef G4ScoringManager_h
0030 #define G4ScoringManager_h 1
0031
0032 #include "globals.hh"
0033 #include "G4VScoringMesh.hh"
0034 #include <vector>
0035 #include <map>
0036 class G4ScoringMessenger;
0037 class G4ScoreQuantityMessenger;
0038 class G4VHitsCollection;
0039 class G4VScoreColorMap;
0040 #include "G4VScoreWriter.hh"
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051 using MeshVec = std::vector<G4VScoringMesh *>;
0052 using MeshVecItr = MeshVec::iterator;
0053 using MeshVecConstItr = MeshVec::const_iterator;
0054 using ColorMapDict = std::map<G4String, G4VScoreColorMap *>;
0055 using ColorMapDictItr = ColorMapDict::iterator;
0056 using ColorMapDictConstItr = ColorMapDict::const_iterator;
0057 using MeshMap = std::map<G4int, G4VScoringMesh *>;
0058 using MeshMapItr = MeshMap::iterator;
0059 using MeshMapConstItr = MeshMap::const_iterator;
0060
0061 class G4ScoringManager
0062 {
0063 public:
0064 static G4ScoringManager* GetScoringManager();
0065
0066
0067 static G4ScoringManager* GetScoringManagerIfExist();
0068
0069 ~G4ScoringManager();
0070
0071 public:
0072 static void SetReplicaLevel(G4int);
0073 static G4int GetReplicaLevel();
0074
0075 void RegisterScoreColorMap(G4VScoreColorMap* colorMap);
0076
0077
0078
0079 void Accumulate(G4VHitsCollection* map);
0080 void Merge(const G4ScoringManager* scMan);
0081 G4VScoringMesh* FindMesh(G4VHitsCollection* map);
0082 G4VScoringMesh* FindMesh(const G4String&);
0083 void List() const;
0084 void Dump() const;
0085 void DrawMesh(const G4String& meshName, const G4String& psName,
0086 const G4String& colorMapName, G4int axflg = 111);
0087 void DrawMesh(const G4String& meshName, const G4String& psName,
0088 G4int idxPlane, G4int iColumn, const G4String& colorMapName);
0089 void DumpQuantityToFile(const G4String& meshName, const G4String& psName,
0090 const G4String& fileName,
0091 const G4String& option = "");
0092 void DumpAllQuantitiesToFile(const G4String& meshName,
0093 const G4String& fileName,
0094 const G4String& option = "");
0095 G4VScoreColorMap* GetScoreColorMap(const G4String& mapName);
0096 void ListScoreColorMaps();
0097
0098 inline void SetCurrentMesh(G4VScoringMesh* scm) { fCurrentMesh = scm; }
0099 inline G4VScoringMesh* GetCurrentMesh() const { return fCurrentMesh; }
0100 inline void CloseCurrentMesh() { fCurrentMesh = nullptr; }
0101 inline void SetVerboseLevel(G4int vl)
0102 {
0103 verboseLevel = vl;
0104 for(auto& itr : fMeshVec)
0105 {
0106 itr->SetVerboseLevel(vl);
0107 }
0108 if(writer != nullptr)
0109 writer->SetVerboseLevel(vl);
0110 }
0111 inline G4int GetVerboseLevel() const { return verboseLevel; }
0112 inline size_t GetNumberOfMesh() const { return fMeshVec.size(); }
0113 inline void RegisterScoringMesh(G4VScoringMesh* scm)
0114 {
0115 scm->SetVerboseLevel(verboseLevel);
0116 fMeshVec.push_back(scm);
0117 SetCurrentMesh(scm);
0118 }
0119 inline G4VScoringMesh* GetMesh(G4int i) const { return fMeshVec[i]; }
0120 inline G4String GetWorldName(G4int i) const
0121 {
0122 return fMeshVec[i]->GetWorldName();
0123 }
0124
0125 public:
0126 inline void SetScoreWriter(G4VScoreWriter* sw)
0127 {
0128 delete writer;
0129 writer = sw;
0130 if(writer != nullptr)
0131 writer->SetVerboseLevel(verboseLevel);
0132 }
0133
0134
0135 public:
0136 inline void SetFactor(G4double val = 1.0)
0137 {
0138 if(writer != nullptr)
0139 writer->SetFactor(val);
0140 }
0141 inline G4double GetFactor() const
0142 {
0143 if(writer != nullptr)
0144 {
0145 return writer->GetFactor();
0146 }
0147
0148 return -1.0;
0149 }
0150
0151 protected:
0152 G4ScoringManager();
0153
0154 private:
0155
0156 G4ScoringManager(const G4ScoringManager&);
0157 G4ScoringManager& operator=(const G4ScoringManager&);
0158
0159 private:
0160 static G4ThreadLocal G4ScoringManager* fSManager;
0161 static G4ThreadLocal G4int replicaLevel;
0162 G4int verboseLevel;
0163 G4ScoringMessenger* fMessenger;
0164 G4ScoreQuantityMessenger* fQuantityMessenger;
0165
0166 MeshVec fMeshVec;
0167 G4VScoringMesh* fCurrentMesh;
0168
0169 G4VScoreWriter* writer;
0170 G4VScoreColorMap* fDefaultLinearColorMap;
0171 ColorMapDict* fColorMapDict;
0172
0173 MeshMap fMeshMap;
0174 };
0175
0176 #endif