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
0032 #ifndef G4TNtupleDescription_h
0033 #define G4TNtupleDescription_h 1
0034
0035 #include "G4NtupleBookingManager.hh"
0036 #include "globals.hh"
0037
0038 #include <fstream>
0039
0040 template <typename NT, typename FT>
0041 class G4TNtupleDescription
0042 {
0043 public:
0044 G4TNtupleDescription(G4NtupleBooking* g4NtupleBooking)
0045 : fG4NtupleBooking(g4NtupleBooking)
0046 {}
0047
0048 G4TNtupleDescription() = delete;
0049 ~G4TNtupleDescription()
0050 {
0051 if ( fIsNtupleOwner ) delete fNtuple;
0052 }
0053
0054
0055 void SetFile(std::shared_ptr<FT> file);
0056 void SetNtuple(NT* ntuple);
0057 void SetFileName(const G4String& fileName);
0058 void SetActivation(G4bool activation);
0059 void SetIsNtupleOwner(G4bool isNtupleOwner);
0060 void SetHasFill(G4bool hasFill);
0061 void Reset();
0062
0063
0064 std::shared_ptr<FT> GetFile() const;
0065 NT* GetNtuple() const;
0066 G4NtupleBooking* GetG4NtupleBooking() const;
0067 const tools::ntuple_booking& GetNtupleBooking() const;
0068
0069 G4String GetFileName() const;
0070 G4bool GetActivation() const;
0071 G4bool GetIsNtupleOwner() const;
0072 G4bool GetHasFill() const;
0073
0074 private:
0075 std::shared_ptr<FT> fFile { nullptr };
0076 NT* fNtuple { nullptr };
0077 G4NtupleBooking* fG4NtupleBooking { nullptr };
0078 G4bool fIsNtupleOwner { true };
0079 G4bool fHasFill { false };
0080 };
0081
0082
0083
0084 template <typename NT, typename FT>
0085 void G4TNtupleDescription<NT, FT>::SetFile(std::shared_ptr<FT> file)
0086 { fFile = file; }
0087
0088 template <typename NT, typename FT>
0089 void G4TNtupleDescription<NT, FT>::SetNtuple(NT* ntuple)
0090 { fNtuple = ntuple; }
0091
0092 template <typename NT, typename FT>
0093 void G4TNtupleDescription<NT, FT>::SetFileName(const G4String& fileName)
0094 { fG4NtupleBooking->fFileName = fileName; }
0095
0096 template <typename NT, typename FT>
0097 void G4TNtupleDescription<NT, FT>::SetActivation(G4bool activation)
0098 { fG4NtupleBooking->fActivation = activation; }
0099
0100 template <typename NT, typename FT>
0101 void G4TNtupleDescription<NT, FT>::SetIsNtupleOwner(G4bool isNtupleOwner)
0102 { fIsNtupleOwner = isNtupleOwner; }
0103
0104 template <typename NT, typename FT>
0105 void G4TNtupleDescription<NT, FT>::SetHasFill(G4bool hasFill)
0106 { fHasFill = hasFill; }
0107
0108 template <typename NT, typename FT>
0109 void G4TNtupleDescription<NT, FT>::Reset()
0110 {
0111 if (fIsNtupleOwner) delete fNtuple;
0112 fNtuple = nullptr;
0113 }
0114
0115 template <typename NT, typename FT>
0116 std::shared_ptr<FT> G4TNtupleDescription<NT, FT>::GetFile() const
0117 { return fFile; }
0118
0119 template <typename NT, typename FT>
0120 NT* G4TNtupleDescription<NT, FT>::GetNtuple() const
0121 { return fNtuple; }
0122
0123 template <typename NT, typename FT>
0124 G4NtupleBooking*
0125 G4TNtupleDescription<NT, FT>::GetG4NtupleBooking() const
0126 { return fG4NtupleBooking; }
0127
0128 template <typename NT, typename FT>
0129 const tools::ntuple_booking&
0130 G4TNtupleDescription<NT, FT>::GetNtupleBooking() const
0131 { return fG4NtupleBooking->fNtupleBooking; }
0132
0133 template <typename NT, typename FT>
0134 G4String G4TNtupleDescription<NT, FT>::GetFileName() const
0135 { return fG4NtupleBooking->fFileName; }
0136
0137 template <typename NT, typename FT>
0138 G4bool G4TNtupleDescription<NT, FT>::GetActivation() const
0139 { return fG4NtupleBooking->fActivation; }
0140
0141 template <typename NT, typename FT>
0142 G4bool G4TNtupleDescription<NT, FT>::GetIsNtupleOwner() const
0143 { return fIsNtupleOwner; }
0144
0145 template <typename NT, typename FT>
0146 G4bool G4TNtupleDescription<NT, FT>::GetHasFill() const
0147 { return fHasFill; }
0148
0149 #endif