Geant4-11
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 (ivana@ipno.in2p3.fr)
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;
46
47template <typename HT>
49{
50 public:
52 const G4String& hnType);
53 G4THnManager() = delete;
54 virtual ~G4THnManager();
55
56 G4int RegisterT(HT* t, const G4String& name);
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
73 // Get method
74 HT* GetT(G4int id) const;
75
76 protected:
77 // Iterators
78 typename std::vector<HT*>::iterator BeginT();
79 typename std::vector<HT*>::iterator EndT();
80 typename std::vector<HT*>::const_iterator BeginConstT() const;
81 typename std::vector<HT*>::const_iterator EndConstT() const;
82
84 std::string_view functionName,
85 G4bool warn = true,
86 G4bool onlyIfActive = true) const;
87
88 G4int GetTId(const G4String& name, G4bool warn = true) const;
89
90 // Methods for verbose
91 G4bool IsVerbose(G4int verboseLevel) const;
92 void Message(G4int level,
93 const G4String& action,
94 const G4String& objectType,
95 const G4String& objectName = "",
96 G4bool success = true) const;
97
98 // Static data members
99 static constexpr std::string_view fkClass { "G4THnManager<T>" };
100
101 // Data members
103 std::vector<HT*> fTVector;
104 std::map<G4String, G4int> fNameIdMap;
105 std::shared_ptr<G4HnManager> fHnManager { nullptr };
106};
107
108// inline functions
109
110#include "G4THnManager.icc"
111
112#endif
std::mutex G4Mutex
Definition: G4Threading.hh:81
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
std::vector< HT * >::const_iterator BeginConstT() const
std::vector< HT * > fTVector
G4THnManager(const G4AnalysisManagerState &state, const G4String &hnType)
virtual ~G4THnManager()
HT * GetTInFunction(G4int id, std::string_view functionName, G4bool warn=true, G4bool onlyIfActive=true) const
void Merge(G4Mutex &mergeMutex, G4THnManager< HT > *masterInstance)
G4THnManager()=delete
G4bool Reset()
std::map< G4String, G4int > fNameIdMap
void ClearData()
const G4AnalysisManagerState & fState
std::vector< HT * >::iterator EndT()
static constexpr std::string_view fkClass
Definition: G4THnManager.hh:99
G4int GetTId(const G4String &name, G4bool warn=true) const
G4int RegisterT(HT *t, const G4String &name)
std::vector< HT * >::iterator BeginT()
HT * GetT(G4int id) const
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
std::vector< HT * >::const_iterator EndConstT() const
const char * name(G4int ptype)