Geant4  10.03.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 // $Id: G4ScoringManager.hh 94772 2015-12-09 09:46:45Z gcosmo $
28 //
29 
30 #ifndef G4ScoringManager_h
31 #define G4ScoringManager_h 1
32 
33 #include "globals.hh"
34 #include "G4VScoringMesh.hh"
35 #include <vector>
36 #include <map>
37 class G4ScoringMessenger;
39 class G4VHitsCollection;
41 #include "G4VScoreWriter.hh"
42 
43 // class description:
44 //
45 // This is a singleton class which manages the interactive scoring.
46 // The user cannot access to the constructor. The pointer of the
47 // only existing object can be got via G4ScoringManager::GetScoringManager()
48 // static method. The first invokation of this static method makes
49 // the singleton object.
50 //
51 
52 typedef std::vector<G4VScoringMesh*> MeshVec;
53 typedef std::vector<G4VScoringMesh*>::iterator MeshVecItr;
54 typedef std::vector<G4VScoringMesh*>::const_iterator MeshVecConstItr;
55 typedef std::map<G4String,G4VScoreColorMap*> ColorMapDict;
56 typedef std::map<G4String,G4VScoreColorMap*>::iterator ColorMapDictItr;
57 typedef std::map<G4String,G4VScoreColorMap*>::const_iterator ColorMapDictConstItr;
58 typedef std::map<G4int,G4VScoringMesh*> MeshMap;
59 typedef std::map<G4int,G4VScoringMesh*>::iterator MeshMapItr;
60 typedef std::map<G4int,G4VScoringMesh*>::const_iterator MeshMapConstItr;
61 
63 {
64  public: // with description
66  // Returns the pointer to the singleton object.
67  public:
69 
70  public:
71  static void SetReplicaLevel(G4int);
72  static G4int GetReplicaLevel();
73 
74  protected:
76 
77  public:
79 
80  public: // with description
82  // Register a color map. Once registered, it is available by /score/draw and /score/drawColumn
83  // commands.
84 
85  public:
86  void Accumulate(G4VHitsCollection* map);
87  void Merge(const G4ScoringManager* scMan);
90  void List() const;
91  void Dump() const;
92  void DrawMesh(const G4String& meshName, const G4String& psName,
93  const G4String& colorMapName, G4int axflg=111);
94  void DrawMesh(const G4String& meshName, const G4String& psName,
95  G4int idxPlane, G4int iColumn, const G4String& colorMapName);
96  void DumpQuantityToFile(const G4String& meshName, const G4String& psName,
97  const G4String& fileName, const G4String& option = "");
98  void DumpAllQuantitiesToFile(const G4String& meshName,
99  const G4String& fileName,
100  const G4String& option = "");
101  G4VScoreColorMap* GetScoreColorMap(const G4String& mapName);
102  void ListScoreColorMaps();
103 
104  private:
105  static G4ThreadLocal G4ScoringManager * fSManager;
106  static G4ThreadLocal G4int replicaLevel;
107  G4int verboseLevel;
108  G4ScoringMessenger* fMessenger;
109  G4ScoreQuantityMessenger* fQuantityMessenger;
110 
111  MeshVec fMeshVec;
112  G4VScoringMesh* fCurrentMesh;
113 
114  G4VScoreWriter * writer;
115  G4VScoreColorMap * fDefaultLinearColorMap;
116  ColorMapDict * fColorMapDict;
117 
118  MeshMap fMeshMap;
119  public:
120  inline void SetCurrentMesh(G4VScoringMesh* scm)
121  { fCurrentMesh = scm; }
123  { return fCurrentMesh; }
124  inline void CloseCurrentMesh()
125  { fCurrentMesh = 0; }
126  inline void SetVerboseLevel(G4int vl)
127  {
128  verboseLevel = vl;
129  for(MeshVecItr itr = fMeshVec.begin(); itr != fMeshVec.end(); itr++) {
130  (*itr)->SetVerboseLevel(vl);
131  }
132  if(writer) writer->SetVerboseLevel(vl);
133  }
134  inline G4int GetVerboseLevel() const
135  { return verboseLevel; }
136  inline size_t GetNumberOfMesh() const
137  { return fMeshVec.size(); }
139  {
140  scm->SetVerboseLevel(verboseLevel);
141  fMeshVec.push_back(scm);
142  SetCurrentMesh(scm);
143  }
144  inline G4VScoringMesh* GetMesh(G4int i) const
145  { return fMeshVec[i]; }
146  inline G4String GetWorldName(G4int i) const
147  { return fMeshVec[i]->GetWorldName(); }
148 
149  public: // with description
150  inline void SetScoreWriter(G4VScoreWriter * sw)
151  {
152  if(writer) { delete writer; }
153  writer = sw;
154  if(writer) writer->SetVerboseLevel(verboseLevel);
155  }
156  // Replace score writers.
157 private:
158  //Disable copy constructor and assignement operator
160  G4ScoringManager& operator=(const G4ScoringManager&);
161 };
162 
163 
164 
165 
166 #endif
167 
static void SetReplicaLevel(G4int)
void RegisterScoreColorMap(G4VScoreColorMap *colorMap)
std::map< G4int, G4VScoringMesh * > MeshMap
G4String GetWorldName(G4int i) const
void Dump() const
std::map< G4String, G4VScoreColorMap * >::const_iterator ColorMapDictConstItr
std::vector< G4VScoringMesh * >::const_iterator MeshVecConstItr
void List() const
G4VScoringMesh * FindMesh(G4VHitsCollection *map)
std::map< G4int, G4VScoringMesh * >::const_iterator MeshMapConstItr
#define G4ThreadLocal
Definition: tls.hh:89
int G4int
Definition: G4Types.hh:78
void DumpAllQuantitiesToFile(const G4String &meshName, const G4String &fileName, const G4String &option="")
std::vector< G4VScoringMesh * >::iterator MeshVecItr
G4int GetVerboseLevel() const
static G4ScoringManager * GetScoringManagerIfExist()
static G4int GetReplicaLevel()
void SetScoreWriter(G4VScoreWriter *sw)
std::map< G4String, G4VScoreColorMap * > ColorMapDict
void Accumulate(G4VHitsCollection *map)
G4VScoreColorMap * GetScoreColorMap(const G4String &mapName)
void Merge(const G4ScoringManager *scMan)
void DrawMesh(const G4String &meshName, const G4String &psName, const G4String &colorMapName, G4int axflg=111)
std::vector< G4VScoringMesh * > MeshVec
G4VScoringMesh * GetCurrentMesh() const
std::map< G4int, G4VScoringMesh * >::iterator MeshMapItr
void SetCurrentMesh(G4VScoringMesh *scm)
void DumpQuantityToFile(const G4String &meshName, const G4String &psName, const G4String &fileName, const G4String &option="")
void SetVerboseLevel(G4int vl)
static G4ScoringManager * GetScoringManager()
size_t GetNumberOfMesh() const
std::map< G4String, G4VScoreColorMap * >::iterator ColorMapDictItr
void SetVerboseLevel(G4int vl)
void RegisterScoringMesh(G4VScoringMesh *scm)
G4VScoringMesh * GetMesh(G4int i) const
void SetVerboseLevel(G4int vl)