Geant4.10
 All Data Structures 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 68735 2013-04-05 09:49:13Z 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 
59 
61 {
62  public: // with description
64  // Returns the pointer to the singleton object.
65  public:
67 
68  public:
69  static void SetReplicaLevel(G4int);
70  static G4int GetReplicaLevel();
71 
72  protected:
74 
75  public:
77 
78  public: // with description
80  // Register a color map. Once registered, it is available by /score/draw and /score/drawColumn
81  // commands.
82 
83  public:
84  void Accumulate(G4VHitsCollection* map);
85  void Merge(const G4ScoringManager* scMan);
87  void List() const;
88  void Dump() const;
89  void DrawMesh(const G4String& meshName, const G4String& psName,
90  const G4String& colorMapName, G4int axflg=111);
91  void DrawMesh(const G4String& meshName, const G4String& psName,
92  G4int idxPlane, G4int iColumn, const G4String& colorMapName);
93  void DumpQuantityToFile(const G4String& meshName, const G4String& psName,
94  const G4String& fileName, const G4String& option = "");
95  void DumpAllQuantitiesToFile(const G4String& meshName,
96  const G4String& fileName,
97  const G4String& option = "");
99  void ListScoreColorMaps();
100 
101  private:
102  static G4ThreadLocal G4ScoringManager * fSManager;
103  static G4ThreadLocal G4int replicaLevel;
104  G4int verboseLevel;
105  G4ScoringMessenger* fMessenger;
106  G4ScoreQuantityMessenger* fQuantityMessenger;
107 
108  MeshVec fMeshVec;
109  G4VScoringMesh* fCurrentMesh;
110 
111  G4VScoreWriter * writer;
112  G4VScoreColorMap * fDefaultLinearColorMap;
113  ColorMapDict * fColorMapDict;
114 
115  public:
116  inline void SetCurrentMesh(G4VScoringMesh* scm)
117  { fCurrentMesh = scm; }
119  { return fCurrentMesh; }
120  inline void CloseCurrentMesh()
121  { fCurrentMesh = 0; }
122  inline void SetVerboseLevel(G4int vl)
123  {
124  verboseLevel = vl;
125  for(MeshVecItr itr = fMeshVec.begin(); itr != fMeshVec.end(); itr++) {
126  (*itr)->SetVerboseLevel(vl);
127  }
128  if(writer) writer->SetVerboseLevel(vl);
129  }
130  inline G4int GetVerboseLevel() const
131  { return verboseLevel; }
132  inline size_t GetNumberOfMesh() const
133  { return fMeshVec.size(); }
135  {
136  scm->SetVerboseLevel(verboseLevel);
137  fMeshVec.push_back(scm);
138  SetCurrentMesh(scm);
139  }
140  inline G4VScoringMesh* GetMesh(G4int i) const
141  { return fMeshVec[i]; }
142  inline G4String GetWorldName(G4int i) const
143  { return fMeshVec[i]->GetWorldName(); }
144 
145  public: // with description
146  inline void SetScoreWriter(G4VScoreWriter * sw)
147  {
148  if(writer) { delete writer; }
149  writer = sw;
150  if(writer) writer->SetVerboseLevel(verboseLevel);
151  }
152  // Replace score writers.
153 };
154 
155 
156 
157 
158 #endif
159 
static void SetReplicaLevel(G4int)
void RegisterScoreColorMap(G4VScoreColorMap *colorMap)
G4String GetWorldName(G4int i) const
void Dump() const
std::map< G4String, G4VScoreColorMap * >::const_iterator ColorMapDictConstItr
std::vector< G4VScoringMesh * >::const_iterator MeshVecConstItr
void List() const
#define G4ThreadLocal
Definition: tls.hh:52
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)
G4VScoringMesh * FindMesh(const G4String &)
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
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)