Geant4 11.1.1
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 <string_view>
43
45class G4HnManager;
46class G4HnInformation;
47
48template <typename HT>
50{
51 public:
53 G4THnManager() = delete;
54 virtual ~G4THnManager();
55
56 G4int RegisterT(const G4String& name, HT* ht, G4HnInformation* info = nullptr);
57
58 // Reset data
60
61 // Clear data
62 void ClearData();
63
64 // Return true if the H1 vector is empty
65 G4bool IsEmpty() const;
66
67 // Method for merge (MT)
68 void AddTVector(const std::vector<HT*>& tVector);
69
70 // New method for merge
71 void Merge(G4Mutex& mergeMutex, G4THnManager<HT>* masterInstance);
72 // TO DO: change to shared_ptr<G4THnManager<HT>> masterInstance
73
74 // Get method
75 // HT* GetT(G4int id) const;
76 HT* GetT(G4int id, G4bool warn = true, G4bool onlyIfActive = true) const;
77
78 std::vector<HT*>* GetTVector();
79 const std::vector<HT*>& GetTVectorRef() const;
80 std::vector<std::pair<HT*, G4HnInformation*>>* GetTHnVector();
81 const std::vector<std::pair<HT*, G4HnInformation*>>& GetTHnVectorRef() const;
82
83 // Methods to list/print histograms
84 G4bool List(std::ostream& output, G4bool onlyIfActive) const;
85
86 // Iterators
87 typename std::vector<HT*>::iterator BeginT();
88 typename std::vector<HT*>::iterator EndT();
89 typename std::vector<HT*>::const_iterator BeginConstT() const;
90 typename std::vector<HT*>::const_iterator EndConstT() const;
91
92 protected:
93 std::pair<HT*, G4HnInformation*> GetTHnInFunction(G4int id,
94 std::string_view functionName,
95 G4bool warn = true,
96 G4bool onlyIfActive = true) const;
97
99 std::string_view functionName,
100 G4bool warn = true,
101 G4bool onlyIfActive = true) const;
102
103 G4int GetTId(const G4String& name, G4bool warn = true) const;
104
105 // Methods for verbose
106 G4bool IsVerbose(G4int verboseLevel) const;
107 void Message(G4int level,
108 const G4String& action,
109 const G4String& objectType,
110 const G4String& objectName = "",
111 G4bool success = true) const;
112
113 // Static data members
114 static constexpr std::string_view fkClass { "G4THnManager<T>" };
115
116 // Data members
118 std::vector<HT*> fTVector;
119 std::vector<std::pair<HT*, G4HnInformation*>> fTHnVector;
120 std::map<G4String, G4int> fNameIdMap;
121 std::shared_ptr<G4HnManager> fHnManager { nullptr };
122};
123
124// inline functions
125
126#include "G4THnManager.icc"
127
128#endif
std::mutex G4Mutex
Definition: G4Threading.hh:81
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
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
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