Geant4  9.6.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$
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);
86  void List() const;
87  void Dump() const;
88  void DrawMesh(const G4String& meshName, const G4String& psName,
89  const G4String& colorMapName, G4int axflg=111);
90  void DrawMesh(const G4String& meshName, const G4String& psName,
91  G4int idxPlane, G4int iColumn, const G4String& colorMapName);
92  void DumpQuantityToFile(const G4String& meshName, const G4String& psName,
93  const G4String& fileName, const G4String& option = "");
94  void DumpAllQuantitiesToFile(const G4String& meshName,
95  const G4String& fileName,
96  const G4String& option = "");
98  void ListScoreColorMaps();
99 
100  private:
101  static G4ScoringManager * fSManager;
102  static G4int replicaLevel;
103  G4int verboseLevel;
104  G4ScoringMessenger* fMessenger;
105  G4ScoreQuantityMessenger* fQuantityMessenger;
106 
107  MeshVec fMeshVec;
108  G4VScoringMesh* fCurrentMesh;
109 
110  G4VScoreWriter * writer;
111  G4VScoreColorMap * fDefaultLinearColorMap;
112  ColorMapDict * fColorMapDict;
113 
114  public:
115  inline void SetCurrentMesh(G4VScoringMesh* scm)
116  { fCurrentMesh = scm; }
118  { return fCurrentMesh; }
119  inline void CloseCurrentMesh()
120  { fCurrentMesh = 0; }
121  inline void SetVerboseLevel(G4int vl)
122  {
123  verboseLevel = vl;
124  for(MeshVecItr itr = fMeshVec.begin(); itr != fMeshVec.end(); itr++) {
125  (*itr)->SetVerboseLevel(vl);
126  }
127  if(writer) writer->SetVerboseLevel(vl);
128  }
129  inline G4int GetVerboseLevel() const
130  { return verboseLevel; }
131  inline size_t GetNumberOfMesh() const
132  { return fMeshVec.size(); }
134  {
135  scm->SetVerboseLevel(verboseLevel);
136  fMeshVec.push_back(scm);
137  SetCurrentMesh(scm);
138  }
139  inline G4VScoringMesh* GetMesh(G4int i) const
140  { return fMeshVec[i]; }
141  inline G4String GetWorldName(G4int i) const
142  { return fMeshVec[i]->GetWorldName(); }
143 
144  public: // with description
145  inline void SetScoreWriter(G4VScoreWriter * sw)
146  {
147  if(writer) { delete writer; }
148  writer = sw;
149  if(writer) writer->SetVerboseLevel(verboseLevel);
150  }
151  // Replace score writers.
152 };
153 
154 
155 
156 
157 #endif
158