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 G4TNtupleManager_h
0032 #define G4TNtupleManager_h 1
0033
0034 #include "G4BaseNtupleManager.hh"
0035 #include "G4TNtupleDescription.hh"
0036 #include "globals.hh"
0037
0038 #include <vector>
0039 #include <string_view>
0040
0041
0042 template <typename NT, typename FT>
0043 class G4TNtupleManager : public G4BaseNtupleManager {
0044
0045 public:
0046 explicit G4TNtupleManager(const G4AnalysisManagerState& state);
0047 G4TNtupleManager() = delete;
0048 ~G4TNtupleManager() override;
0049
0050 protected:
0051
0052 G4int CreateNtuple(G4NtupleBooking* ntupleBooking) override;
0053
0054 virtual void CreateNtuplesFromBooking(
0055 const std::vector<G4NtupleBooking*>& ntupleBookings);
0056
0057 virtual G4bool Reset();
0058 void Clear() override;
0059
0060
0061 G4bool Delete(G4int id) override;
0062
0063
0064
0065
0066
0067
0068 using G4BaseNtupleManager::FillNtupleIColumn;
0069 using G4BaseNtupleManager::FillNtupleFColumn;
0070 using G4BaseNtupleManager::FillNtupleDColumn;
0071 using G4BaseNtupleManager::FillNtupleSColumn;
0072 using G4BaseNtupleManager::AddNtupleRow;
0073
0074 G4bool FillNtupleIColumn(G4int ntupleId, G4int columnId, G4int value) final;
0075 G4bool FillNtupleFColumn(G4int ntupleId, G4int columnId, G4float value) final;
0076 G4bool FillNtupleDColumn(G4int ntupleId, G4int columnId, G4double value) final;
0077 G4bool FillNtupleSColumn(G4int ntupleId, G4int columnId, const G4String& value) final;
0078 G4bool AddNtupleRow(G4int ntupleId) override;
0079
0080
0081
0082 void SetActivation(G4bool activation) final;
0083 void SetActivation(G4int ntupleId, G4bool activation) final;
0084 G4bool GetActivation(G4int ntupleId) const final;
0085
0086
0087 void SetNewCycle(G4bool value) override;
0088 G4bool GetNewCycle() const override;
0089
0090
0091 NT* GetNtuple() const;
0092 NT* GetNtuple(G4int ntupleId) const;
0093
0094
0095 typename std::vector<NT*>::iterator BeginNtuple();
0096 typename std::vector<NT*>::iterator EndNtuple();
0097 typename std::vector<NT*>::const_iterator BeginConstNtuple() const;
0098 typename std::vector<NT*>::const_iterator EndConstNtuple() const;
0099
0100
0101 std::vector<G4TNtupleDescription<NT, FT>*> fNtupleDescriptionVector;
0102 std::vector<NT*> fNtupleVector;
0103 const std::vector<G4NtupleBooking*>* fNtupleBookingVector { nullptr };
0104 G4bool fNewCycle { false };
0105
0106 private:
0107
0108
0109
0110
0111 virtual void CreateTNtupleFromBooking(
0112 G4TNtupleDescription<NT, FT>* ntupleDescription) = 0;
0113
0114 virtual void FinishTNtuple(
0115 G4TNtupleDescription<NT, FT>* ntupleDescription,
0116 G4bool fromBooking) = 0;
0117
0118
0119
0120
0121 G4TNtupleDescription<NT, FT>* GetNtupleDescriptionInFunction(G4int id,
0122 std::string_view function,
0123 G4bool warn = true) const;
0124 NT* GetNtupleInFunction(G4int id,
0125 std::string_view function,
0126 G4bool warn = true) const;
0127
0128
0129 template <typename T>
0130 G4bool FillNtupleTColumn(G4int ntupleId, G4int columnId, const T& value);
0131
0132
0133 static constexpr std::string_view fkClass { "G4TNtupleManager<NT,FT>" };
0134 };
0135
0136 #include "G4TNtupleManager.icc"
0137
0138 #endif
0139