File indexing completed on 2025-01-18 09:59:11
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031 #ifndef G4THnManager_h
0032 #define G4THnManager_h 1
0033
0034 #include "G4Threading.hh"
0035 #include "G4Fcn.hh"
0036 #include "G4BinScheme.hh"
0037 #include "globals.hh"
0038
0039 #include <vector>
0040 #include <map>
0041 #include <memory>
0042 #include <set>
0043 #include <string_view>
0044
0045 class G4AnalysisManagerState;
0046 class G4HnManager;
0047 class G4HnInformation;
0048
0049 template <typename HT>
0050 class G4THnManager
0051 {
0052 public:
0053 G4THnManager(const G4AnalysisManagerState& state);
0054 G4THnManager() = delete;
0055 virtual ~G4THnManager();
0056
0057 G4int RegisterT(const G4String& name, HT* ht, G4HnInformation* info = nullptr);
0058
0059
0060 G4bool Reset();
0061
0062
0063 void ClearData();
0064
0065
0066 G4bool DeleteT(G4int id, G4bool keepSetting);
0067
0068
0069 G4bool IsEmpty() const;
0070
0071
0072 void AddTVector(const std::vector<HT*>& tVector);
0073
0074
0075 void Merge(G4Mutex& mergeMutex, G4THnManager<HT>* masterInstance);
0076
0077
0078
0079
0080 HT* GetT(G4int id, G4bool warn = true, G4bool onlyIfActive = true) const;
0081
0082 std::vector<HT*>* GetTVector();
0083 const std::vector<HT*>& GetTVectorRef() const;
0084 std::vector<std::pair<HT*, G4HnInformation*>>* GetTHnVector();
0085 const std::vector<std::pair<HT*, G4HnInformation*>>& GetTHnVectorRef() const;
0086 G4int GetNofHns(G4bool onlyIfExist) const;
0087
0088
0089 G4bool List(std::ostream& output, G4bool onlyIfActive) const;
0090
0091
0092 typename std::vector<HT*>::iterator BeginT();
0093 typename std::vector<HT*>::iterator EndT();
0094 typename std::vector<HT*>::const_iterator BeginConstT() const;
0095 typename std::vector<HT*>::const_iterator EndConstT() const;
0096
0097 protected:
0098 std::pair<HT*, G4HnInformation*> GetTHnInFunction(G4int id,
0099 std::string_view functionName,
0100 G4bool warn = true,
0101 G4bool onlyIfActive = true) const;
0102
0103 HT* GetTInFunction(G4int id,
0104 std::string_view functionName,
0105 G4bool warn = true,
0106 G4bool onlyIfActive = true) const;
0107
0108 G4int GetTId(const G4String& name, G4bool warn = true) const;
0109
0110
0111 G4bool IsVerbose(G4int verboseLevel) const;
0112 void Message(G4int level,
0113 const G4String& action,
0114 const G4String& objectType,
0115 const G4String& objectName = "",
0116 G4bool success = true) const;
0117
0118
0119 static constexpr std::string_view fkClass { "G4THnManager<T>" };
0120
0121
0122 const G4AnalysisManagerState& fState;
0123 std::vector<HT*> fTVector;
0124 std::vector<std::pair<HT*, G4HnInformation*>> fTHnVector;
0125 std::set<G4int> fFreeIds;
0126 std::map<G4String, G4int> fNameIdMap;
0127 std::shared_ptr<G4HnManager> fHnManager { nullptr };
0128 };
0129
0130
0131
0132 #include "G4THnManager.icc"
0133
0134 #endif