G4ScoringManager.hh

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 //
00027 // $Id$
00028 //
00029 
00030 #ifndef G4ScoringManager_h
00031 #define G4ScoringManager_h 1
00032 
00033 #include "globals.hh"
00034 #include "G4VScoringMesh.hh"
00035 #include <vector>
00036 #include <map>
00037 class G4ScoringMessenger;
00038 class G4ScoreQuantityMessenger;
00039 class G4VHitsCollection;
00040 class G4VScoreColorMap;
00041 #include "G4VScoreWriter.hh"
00042 
00043 // class description:
00044 //
00045 //  This is a singleton class which manages the interactive scoring.
00046 // The user cannot access to the constructor. The pointer of the
00047 // only existing object can be got via G4ScoringManager::GetScoringManager()
00048 // static method. The first invokation of this static method makes
00049 // the singleton object.
00050 //
00051 
00052 typedef std::vector<G4VScoringMesh*> MeshVec;
00053 typedef std::vector<G4VScoringMesh*>::iterator MeshVecItr;
00054 typedef std::vector<G4VScoringMesh*>::const_iterator MeshVecConstItr;
00055 typedef std::map<G4String,G4VScoreColorMap*> ColorMapDict;
00056 typedef std::map<G4String,G4VScoreColorMap*>::iterator ColorMapDictItr;
00057 typedef std::map<G4String,G4VScoreColorMap*>::const_iterator ColorMapDictConstItr;
00058 
00059 
00060 class G4ScoringManager 
00061 {
00062   public: // with description
00063       static G4ScoringManager* GetScoringManager();
00064       // Returns the pointer to the singleton object.
00065   public:
00066       static G4ScoringManager* GetScoringManagerIfExist();
00067 
00068   public:
00069       static void SetReplicaLevel(G4int);
00070       static G4int GetReplicaLevel();
00071 
00072   protected:
00073       G4ScoringManager();
00074 
00075   public:
00076       ~G4ScoringManager();
00077 
00078   public: // with description
00079       void RegisterScoreColorMap(G4VScoreColorMap* colorMap);
00080       // Register a color map. Once registered, it is available by /score/draw and /score/drawColumn
00081       // commands.
00082 
00083   public:
00084       void Accumulate(G4VHitsCollection* map);
00085       G4VScoringMesh* FindMesh(const G4String&);
00086       void List() const;
00087       void Dump() const;
00088       void DrawMesh(const G4String& meshName, const G4String& psName,
00089                     const G4String& colorMapName, G4int axflg=111);
00090       void DrawMesh(const G4String& meshName, const G4String& psName,
00091                     G4int idxPlane, G4int iColumn, const G4String& colorMapName);
00092       void DumpQuantityToFile(const G4String& meshName, const G4String& psName,
00093                               const G4String& fileName, const G4String& option = "");
00094       void DumpAllQuantitiesToFile(const G4String& meshName,
00095                                    const G4String& fileName,
00096                                    const G4String& option = "");
00097       G4VScoreColorMap* GetScoreColorMap(const G4String& mapName);
00098       void ListScoreColorMaps();
00099 
00100   private: 
00101       static G4ScoringManager * fSManager;
00102       static G4int replicaLevel;
00103       G4int verboseLevel;
00104       G4ScoringMessenger* fMessenger;
00105       G4ScoreQuantityMessenger* fQuantityMessenger;
00106 
00107       MeshVec fMeshVec;
00108       G4VScoringMesh* fCurrentMesh;
00109 
00110       G4VScoreWriter * writer;
00111       G4VScoreColorMap * fDefaultLinearColorMap;
00112       ColorMapDict * fColorMapDict;
00113 
00114   public:
00115       inline void SetCurrentMesh(G4VScoringMesh* scm)
00116       { fCurrentMesh = scm; }
00117       inline G4VScoringMesh* GetCurrentMesh() const
00118       { return fCurrentMesh; }
00119       inline void CloseCurrentMesh()
00120       { fCurrentMesh = 0; }
00121       inline void SetVerboseLevel(G4int vl) 
00122       {
00123         verboseLevel = vl;
00124         for(MeshVecItr itr = fMeshVec.begin(); itr != fMeshVec.end(); itr++) {
00125          (*itr)->SetVerboseLevel(vl);
00126         }
00127         if(writer) writer->SetVerboseLevel(vl);
00128       }
00129       inline G4int GetVerboseLevel() const
00130       { return verboseLevel; }
00131       inline size_t GetNumberOfMesh() const
00132       { return fMeshVec.size(); }
00133       inline void RegisterScoringMesh(G4VScoringMesh * scm)
00134       {
00135         scm->SetVerboseLevel(verboseLevel);
00136         fMeshVec.push_back(scm);
00137         SetCurrentMesh(scm);
00138       }
00139       inline G4VScoringMesh* GetMesh(G4int i) const
00140       { return fMeshVec[i]; }
00141       inline G4String GetWorldName(G4int i) const
00142       { return fMeshVec[i]->GetWorldName(); }
00143 
00144   public: // with description
00145       inline void SetScoreWriter(G4VScoreWriter * sw)
00146       {
00147         if(writer) { delete writer; }
00148         writer = sw;
00149         if(writer) writer->SetVerboseLevel(verboseLevel);
00150       }
00151       // Replace score writers.
00152 };
00153 
00154 
00155 
00156 
00157 #endif
00158 

Generated on Mon May 27 17:49:48 2013 for Geant4 by  doxygen 1.4.7