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 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 virtual ~G4THnToolsManager() = 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 virtual G4bool Scale(G4int id, G4double factor) override;
0074 virtual G4int GetNofHns(G4bool onlyIfExist) const override;
0075
0076
0077 virtual G4bool Fill(G4int id, std::array<G4double, DIM> value, G4double weight = 1.0) override;
0078
0079
0080 virtual G4int GetId(const G4String& name, G4bool warn = true) const override;
0081
0082
0083 virtual G4int GetNbins(unsigned int idim, G4int id) const override;
0084 virtual G4double GetMinValue(unsigned int idim, G4int id) const override;
0085 virtual G4double GetMaxValue(unsigned int idim, G4int id) const override;
0086 virtual G4double GetWidth(unsigned int idim, G4int id) const override;
0087
0088
0089 virtual G4bool SetTitle(G4int id, const G4String& title) override;
0090 virtual G4bool SetAxisTitle(unsigned int idim, G4int id, const G4String& title) override;
0091
0092
0093 virtual G4String GetTitle(G4int id) const override;
0094 virtual G4String GetAxisTitle(unsigned int idim, G4int id) const override;
0095
0096
0097 virtual G4bool WriteOnAscii(std::ofstream& output) override;
0098
0099 virtual G4bool List(std::ostream& output, G4bool onlyIfActive = true) override;
0100
0101
0102 virtual G4bool Delete(G4int id, G4bool keepSetting) override;
0103
0104
0105 virtual std::shared_ptr<G4HnManager> GetHnManager() override;
0106 virtual const std::shared_ptr<G4HnManager> GetHnManager() const override;
0107
0108 protected:
0109
0110 using G4THnManager<HT>::RegisterT;
0111 using G4THnManager<HT>::GetTHnInFunction;
0112 using G4THnManager<HT>::GetTInFunction;
0113 using G4THnManager<HT>::GetTId;
0114 using G4THnManager<HT>::IsVerbose;
0115 using G4THnManager<HT>::Message;
0116
0117 static constexpr std::string_view fkClass { "G4THnToolsManager" };
0118
0119 private:
0120 void UpdateInformation(G4HnInformation* hnInformation,
0121 const std::array<G4HnDimensionInformation, DIM>& hnInfo);
0122
0123 G4HnInformation* CreateInformation(const G4String& name,
0124 const std::array<G4HnDimensionInformation, DIM>& hnInfo);
0125
0126 void AddAnnotation(HT* ht,
0127 const std::array<G4HnDimensionInformation, DIM>& hnInfo);
0128
0129 G4bool CheckName(const G4String& name) const;
0130
0131
0132
0133 HT* CreateToolsHT(const G4String& title,
0134 const std::array<G4HnDimension, DIM>& bins,
0135 const std::array<G4HnDimensionInformation, DIM>& hnInfo);
0136
0137 void ConfigureToolsHT(HT* ht,
0138 const std::array<G4HnDimension, DIM>& bins,
0139 const std::array<G4HnDimensionInformation, DIM>& hnInfo);
0140
0141 G4bool FillHT(HT* ht, const G4HnInformation& hnInformation,
0142 std::array<G4double, DIM>& value,
0143 G4double weight = 1.0);
0144
0145
0146 static const std::array<std::string, G4Analysis::kMaxDim> fkKeyAxisTitle;
0147
0148 std::unique_ptr<G4UImessenger> fMessenger;
0149 };
0150
0151
0152
0153 #include "G4THnMessenger.hh"
0154 #include "G4THnToolsManager.icc"
0155 #include "G4THnMessenger.icc"
0156
0157
0158 #endif