Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:59:04

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
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 // class description:
0043 //
0044 //  This is a singleton class which manages the interactive scoring.
0045 // The user cannot access to the constructor. The pointer of the
0046 // only existing object can be got via G4ScoringManager::GetScoringManager()
0047 // static method. The first invokation of this static method makes
0048 // the singleton object.
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:  // with description
0064   static G4ScoringManager* GetScoringManager();
0065   // Returns the pointer to the singleton object.
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   // Register a color map. Once registered, it is available by /score/draw and
0077   // /score/drawColumn commands.
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:  // with description
0126   inline void SetScoreWriter(G4VScoreWriter* sw)
0127   {
0128     delete writer;
0129     writer = sw;
0130     if(writer != nullptr)
0131       writer->SetVerboseLevel(verboseLevel);
0132   }
0133   // Replace score writers.
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   // Disable copy constructor and assignement operator
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