File indexing completed on 2025-09-17 08:59:32
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 G4THnToolsManager_h
0032 #define G4THnToolsManager_h 1
0033
0034 #include "G4AnalysisUtilities.hh"
0035 #include "G4VTBaseHnManager.hh"
0036 #include "G4THnManager.hh"
0037 #include "globals.hh"
0038
0039 #include <memory>
0040 #include <array>
0041 #include <string_view>
0042
0043 class G4AnalysisManagerState;
0044 class G4HnManager;
0045 class G4UImessenger;
0046
0047 template <unsigned int DIM, typename HT>
0048 class G4THnToolsManager : public G4VTBaseHnManager<DIM>,
0049 public G4THnManager<HT>
0050
0051 {
0052
0053 friend class G4VAnalysisManager;
0054 friend class G4VAnalysisReader;
0055
0056 public:
0057 G4THnToolsManager(const G4AnalysisManagerState& state);
0058 ~G4THnToolsManager() override = default;
0059
0060
0061 G4THnToolsManager(const G4THnToolsManager& rhs) = delete;
0062 G4THnToolsManager& operator=(const G4THnToolsManager& rhs) = delete;
0063
0064
0065 G4int Create(const G4String& name, const G4String& title,
0066 const std::array<G4HnDimension, DIM>& bins,
0067 const std::array<G4HnDimensionInformation, DIM>& hnInfo) override;
0068
0069 G4bool Set(G4int id,
0070 const std::array<G4HnDimension, DIM>& bins,
0071 const std::array<G4HnDimensionInformation, DIM>& hnInfo) override;
0072
0073 G4bool Scale(G4int id, G4double factor) override;
0074 G4int GetNofHns(G4bool onlyIfExist) const override;
0075
0076
0077 G4bool Fill(G4int id, std::array<G4double, DIM> value,
0078 G4double weight = 1.0) override;
0079
0080
0081 G4int GetId(const G4String &name, G4bool warn = true) const override;
0082
0083
0084 G4int GetNbins(unsigned int idim, G4int id) const override;
0085 G4double GetMinValue(unsigned int idim, G4int id) const override;
0086 G4double GetMaxValue(unsigned int idim, G4int id) const override;
0087 G4double GetWidth(unsigned int idim, G4int id) const override;
0088
0089
0090 G4bool SetTitle(G4int id, const G4String &title) override;
0091 G4bool SetAxisTitle(unsigned int idim, G4int id,
0092 const G4String &title) override;
0093
0094
0095 G4String GetTitle(G4int id) const override;
0096 G4String GetAxisTitle(unsigned int idim, G4int id) const override;
0097
0098
0099 G4bool WriteOnAscii(std::ofstream &output) override;
0100
0101 G4bool List(std::ostream &output, G4bool onlyIfActive = true) override;
0102
0103
0104 G4bool Delete(G4int id, G4bool keepSetting) override;
0105
0106
0107 std::shared_ptr<G4HnManager> GetHnManager() override;
0108 const std::shared_ptr<G4HnManager> GetHnManager() const override;
0109
0110 protected:
0111
0112 using G4THnManager<HT>::RegisterT;
0113 using G4THnManager<HT>::GetTHnInFunction;
0114 using G4THnManager<HT>::GetTInFunction;
0115 using G4THnManager<HT>::GetTId;
0116 using G4THnManager<HT>::IsVerbose;
0117 using G4THnManager<HT>::Message;
0118
0119 static constexpr std::string_view fkClass { "G4THnToolsManager" };
0120
0121 private:
0122 void UpdateInformation(G4HnInformation* hnInformation,
0123 const std::array<G4HnDimensionInformation, DIM>& hnInfo);
0124
0125 G4HnInformation* CreateInformation(const G4String& name,
0126 const std::array<G4HnDimensionInformation, DIM>& hnInfo);
0127
0128 void AddAnnotation(HT* ht,
0129 const std::array<G4HnDimensionInformation, DIM>& hnInfo);
0130
0131 G4bool CheckName(const G4String& name) const;
0132
0133
0134
0135 HT* CreateToolsHT(const G4String& title,
0136 const std::array<G4HnDimension, DIM>& bins,
0137 const std::array<G4HnDimensionInformation, DIM>& hnInfo);
0138
0139 void ConfigureToolsHT(HT* ht,
0140 const std::array<G4HnDimension, DIM>& bins,
0141 const std::array<G4HnDimensionInformation, DIM>& hnInfo);
0142
0143 G4bool FillHT(HT* ht, const G4HnInformation& hnInformation,
0144 std::array<G4double, DIM>& value,
0145 G4double weight = 1.0);
0146
0147
0148 static const std::array<std::string, G4Analysis::kMaxDim> fkKeyAxisTitle;
0149
0150 std::unique_ptr<G4UImessenger> fMessenger;
0151 };
0152
0153
0154
0155 #include "G4THnMessenger.hh"
0156 #include "G4THnToolsManager.icc"
0157 #include "G4THnMessenger.icc"
0158
0159
0160 #endif