File indexing completed on 2025-01-18 09:59:12
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 G4ToolsAnalysisManager_h
0032 #define G4ToolsAnalysisManager_h 1
0033
0034 #include "G4VAnalysisManager.hh"
0035 #include "G4TH1ToolsManager.hh"
0036 #include "G4TH2ToolsManager.hh"
0037 #include "G4TH3ToolsManager.hh"
0038 #include "G4TP1ToolsManager.hh"
0039 #include "G4TP2ToolsManager.hh"
0040 #include "globals.hh"
0041
0042 #include "tools/histo/h1d"
0043 #include "tools/histo/h2d"
0044 #include "tools/histo/h3d"
0045 #include "tools/histo/p1d"
0046 #include "tools/histo/p2d"
0047
0048 #include <string_view>
0049
0050 class G4PlotManager;
0051
0052 template <unsigned int DIM, typename HT>
0053 class G4THnToolsManager;
0054
0055 namespace tools {
0056 namespace histo {
0057 class hmpi;
0058 }
0059 }
0060
0061 class G4ToolsAnalysisManager : public G4VAnalysisManager
0062 {
0063 friend class G4ToolsAnalysisMessenger;
0064
0065 public:
0066 ~G4ToolsAnalysisManager() override;
0067
0068
0069 static G4ToolsAnalysisManager* Instance();
0070 static G4bool IsInstance();
0071
0072
0073 tools::histo::h1d* GetH1(G4int id, G4bool warn = true,
0074 G4bool onlyIfActive = true) const;
0075 tools::histo::h2d* GetH2(G4int id, G4bool warn = true,
0076 G4bool onlyIfActive = true) const;
0077 tools::histo::h3d* GetH3(G4int id, G4bool warn = true,
0078 G4bool onlyIfActive = true) const;
0079 tools::histo::p1d* GetP1(G4int id, G4bool warn = true,
0080 G4bool onlyIfActive = true) const;
0081 tools::histo::p2d* GetP2(G4int id, G4bool warn = true,
0082 G4bool onlyIfActive = true) const;
0083
0084
0085 std::vector<tools::histo::h1d*>::iterator BeginH1();
0086 std::vector<tools::histo::h1d*>::iterator EndH1();
0087 std::vector<tools::histo::h1d*>::const_iterator BeginConstH1() const;
0088 std::vector<tools::histo::h1d*>::const_iterator EndConstH1() const;
0089
0090 std::vector<tools::histo::h2d*>::iterator BeginH2();
0091 std::vector<tools::histo::h2d*>::iterator EndH2();
0092 std::vector<tools::histo::h2d*>::const_iterator BeginConstH2() const;
0093 std::vector<tools::histo::h2d*>::const_iterator EndConstH2() const;
0094
0095 std::vector<tools::histo::h3d*>::iterator BeginH3();
0096 std::vector<tools::histo::h3d*>::iterator EndH3();
0097 std::vector<tools::histo::h3d*>::const_iterator BeginConstH3() const;
0098 std::vector<tools::histo::h3d*>::const_iterator EndConstH3() const;
0099
0100 std::vector<tools::histo::p1d*>::iterator BeginP1();
0101 std::vector<tools::histo::p1d*>::iterator EndP1();
0102 std::vector<tools::histo::p1d*>::const_iterator BeginConstP1() const;
0103 std::vector<tools::histo::p1d*>::const_iterator EndConstP1() const;
0104
0105 std::vector<tools::histo::p2d*>::iterator BeginP2();
0106 std::vector<tools::histo::p2d*>::iterator EndP2();
0107 std::vector<tools::histo::p2d*>::const_iterator BeginConstP2() const;
0108 std::vector<tools::histo::p2d*>::const_iterator EndConstP2() const;
0109
0110 protected:
0111 explicit G4ToolsAnalysisManager(const G4String& type);
0112
0113
0114 G4bool OpenFileImpl(const G4String& fileName) override;
0115 G4bool WriteImpl() override;
0116 G4bool CloseFileImpl(G4bool reset) override;
0117 G4bool ResetImpl() override;
0118 void ClearImpl() override;
0119 G4bool PlotImpl() final;
0120 G4bool MergeImpl(tools::histo::hmpi* hmpi) final;
0121 G4bool IsOpenFileImpl() const final;
0122
0123
0124 G4bool IsEmpty();
0125
0126
0127 inline static G4ToolsAnalysisManager* fgMasterToolsInstance { nullptr };
0128 inline static G4ThreadLocal G4ToolsAnalysisManager* fgToolsInstance { nullptr };
0129 static constexpr std::string_view fkClass { "G4ToolsAnalysisManager" };
0130
0131
0132 G4THnToolsManager<kDim1, tools::histo::h1d>* fH1Manager { nullptr };
0133 G4THnToolsManager<kDim2, tools::histo::h2d>* fH2Manager { nullptr };
0134 G4THnToolsManager<kDim3, tools::histo::h3d>* fH3Manager { nullptr };
0135 G4THnToolsManager<kDim2, tools::histo::p1d>* fP1Manager { nullptr };
0136 G4THnToolsManager<kDim3, tools::histo::p2d>* fP2Manager { nullptr };
0137
0138 private:
0139
0140
0141
0142 template <typename HT>
0143 G4bool WriteT(const std::vector<std::pair<HT*, G4HnInformation*>>& hnVector);
0144
0145 G4bool WriteHns();
0146 G4bool ResetHns();
0147 G4bool MergeHns();
0148
0149
0150 std::shared_ptr<G4PlotManager> fPlotManager { nullptr };
0151 };
0152
0153 #include "G4ToolsAnalysisManager.icc"
0154
0155 #endif