Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4THnManager.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// Template base class the histograms/profiles objects managers.
28
29// Author: Ivana Hrivnacova, 23/06/2015 ([email protected])
30
31#ifndef G4THnManager_h
32#define G4THnManager_h 1
33
34#include "G4Threading.hh"
35#include "G4Fcn.hh"
36#include "G4BinScheme.hh"
37#include "globals.hh"
38
39#include <vector>
40#include <map>
41#include <memory>
42#include <set>
43#include <string_view>
44
46class G4HnManager;
47class G4HnInformation;
48
49template <typename HT>
51{
52 public:
54 G4THnManager() = delete;
55 virtual ~G4THnManager();
56
57 G4int RegisterT(const G4String& name, HT* ht, G4HnInformation* info = nullptr);
58
59 // Reset data
61
62 // Clear data
63 void ClearData();
64
65 // Delete selected object
66 G4bool DeleteT(G4int id, G4bool keepSetting);
67
68 // Return true if the H1 vector is empty
69 G4bool IsEmpty() const;
70
71 // Method for merge (MT)
72 void AddTVector(const std::vector<HT*>& tVector);
73
74 // New method for merge
75 void Merge(G4Mutex& mergeMutex, G4THnManager<HT>* masterInstance);
76 // TO DO: change to shared_ptr<G4THnManager<HT>> masterInstance
77
78 // Get method
79 // HT* GetT(G4int id) const;
80 HT* GetT(G4int id, G4bool warn = true, G4bool onlyIfActive = true) const;
81
82 std::vector<HT*>* GetTVector();
83 const std::vector<HT*>& GetTVectorRef() const;
84 std::vector<std::pair<HT*, G4HnInformation*>>* GetTHnVector();
85 const std::vector<std::pair<HT*, G4HnInformation*>>& GetTHnVectorRef() const;
86 G4int GetNofHns(G4bool onlyIfExist) const;
87
88 // Methods to list/print histograms
89 G4bool List(std::ostream& output, G4bool onlyIfActive) const;
90
91 // Iterators
92 typename std::vector<HT*>::iterator BeginT();
93 typename std::vector<HT*>::iterator EndT();
94 typename std::vector<HT*>::const_iterator BeginConstT() const;
95 typename std::vector<HT*>::const_iterator EndConstT() const;
96
97 protected:
98 std::pair<HT*, G4HnInformation*> GetTHnInFunction(G4int id,
99 std::string_view functionName,
100 G4bool warn = true,
101 G4bool onlyIfActive = true) const;
102
104 std::string_view functionName,
105 G4bool warn = true,
106 G4bool onlyIfActive = true) const;
107
108 G4int GetTId(const G4String& name, G4bool warn = true) const;
109
110 // Methods for verbose
111 G4bool IsVerbose(G4int verboseLevel) const;
112 void Message(G4int level,
113 const G4String& action,
114 const G4String& objectType,
115 const G4String& objectName = "",
116 G4bool success = true) const;
117
118 // Static data members
119 static constexpr std::string_view fkClass { "G4THnManager<T>" };
120
121 // Data members
123 std::vector<HT*> fTVector;
124 std::vector<std::pair<HT*, G4HnInformation*>> fTHnVector;
125 std::set<G4int> fFreeIds;
126 std::map<G4String, G4int> fNameIdMap;
127 std::shared_ptr<G4HnManager> fHnManager { nullptr };
128};
129
130// inline functions
131
132#include "G4THnManager.icc"
133
134#endif
std::mutex G4Mutex
bool G4bool
Definition G4Types.hh:86
int G4int
Definition G4Types.hh:85
G4THnManager(const G4AnalysisManagerState &state)
std::vector< HT * >::const_iterator BeginConstT() const
std::vector< HT * > fTVector
virtual ~G4THnManager()
const std::vector< HT * > & GetTVectorRef() const
HT * GetTInFunction(G4int id, std::string_view functionName, G4bool warn=true, G4bool onlyIfActive=true) const
std::set< G4int > fFreeIds
G4int GetNofHns(G4bool onlyIfExist) const
void Merge(G4Mutex &mergeMutex, G4THnManager< HT > *masterInstance)
G4THnManager()=delete
std::pair< HT *, G4HnInformation * > GetTHnInFunction(G4int id, std::string_view functionName, G4bool warn=true, G4bool onlyIfActive=true) const
G4int RegisterT(const G4String &name, HT *ht, G4HnInformation *info=nullptr)
G4bool Reset()
G4bool List(std::ostream &output, G4bool onlyIfActive) const
std::map< G4String, G4int > fNameIdMap
void ClearData()
const G4AnalysisManagerState & fState
std::vector< HT * >::iterator EndT()
static constexpr std::string_view fkClass
G4bool DeleteT(G4int id, G4bool keepSetting)
std::vector< std::pair< HT *, G4HnInformation * > > fTHnVector
G4int GetTId(const G4String &name, G4bool warn=true) const
HT * GetT(G4int id, G4bool warn=true, G4bool onlyIfActive=true) const
std::vector< HT * >::iterator BeginT()
std::vector< HT * > * GetTVector()
std::vector< std::pair< HT *, G4HnInformation * > > * GetTHnVector()
void AddTVector(const std::vector< HT * > &tVector)
void Message(G4int level, const G4String &action, const G4String &objectType, const G4String &objectName="", G4bool success=true) const
std::shared_ptr< G4HnManager > fHnManager
G4bool IsEmpty() const
G4bool IsVerbose(G4int verboseLevel) const
const std::vector< std::pair< HT *, G4HnInformation * > > & GetTHnVectorRef() const
std::vector< HT * >::const_iterator EndConstT() const