Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4TNtupleManager.hh
이 파일의 문서화 페이지로 가기
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 // $Id: G4CsvNtupleManager.hh 70604 2013-06-03 11:27:06Z ihrivnac $
27 
28 // Class template for ntuple managers for all output types.
29 //
30 // Author: Ivana Hrivnacova, 19/06/2015 (ivana@ipno.in2p3.fr)
31 
32 #ifndef G4TNtupleManager_h
33 #define G4TNtupleManager_h 1
34 
35 #include "G4BaseNtupleManager.hh"
36 #include "G4TNtupleDescription.hh"
37 #include "globals.hh"
38 
39 #include <vector>
40 
41 template <typename TNTUPLE>
43 
44  public:
45  explicit G4TNtupleManager(const G4AnalysisManagerState& state);
47 
48  protected:
49  // Methods to manipulate ntuples
51  G4bool IsEmpty() const;
52  G4bool Reset(G4bool deleteNtuple);
53 
54  // Methods to create ntuples
55  //
56  virtual G4int CreateNtuple(const G4String& name, const G4String& title) final;
57 
58  // Create columns in the last created ntuple (from base class)
64  // Create columns in the ntuple with given id
65  virtual G4int CreateNtupleIColumn(G4int ntupleId,
66  const G4String& name, std::vector<int>* vector) final;
67  virtual G4int CreateNtupleFColumn(G4int ntupleId,
68  const G4String& name, std::vector<float>* vector) final;
69  virtual G4int CreateNtupleDColumn(G4int ntupleId,
70  const G4String& name, std::vector<double>* vector) final;
71  virtual G4int CreateNtupleSColumn(G4int ntupleId, const G4String& name) final;
72  virtual void FinishNtuple(G4int ntupleId) final;
73 
74  // Methods to fill ntuples
75  // Methods for ntuple with id = FirstNtupleId (from base class)
81  // Methods for ntuple with id > FirstNtupleId (when more ntuples exist)
82  virtual G4bool FillNtupleIColumn(G4int ntupleId, G4int columnId, G4int value) final;
83  virtual G4bool FillNtupleFColumn(G4int ntupleId, G4int columnId, G4float value) final;
84  virtual G4bool FillNtupleDColumn(G4int ntupleId, G4int columnId, G4double value) final;
85  virtual G4bool FillNtupleSColumn(G4int ntupleId, G4int columnId,
86  const G4String& value) final;
87  virtual G4bool AddNtupleRow(G4int ntupleId) final;
88 
89  // Activation option
90  //
91  virtual void SetActivation(G4bool activation) final;
92  virtual void SetActivation(G4int ntupleId, G4bool activation) final;
93  virtual G4bool GetActivation(G4int ntupleId) const final;
94 
95  // Access methods
96  TNTUPLE* GetNtuple() const;
97  TNTUPLE* GetNtuple(G4int ntupleId) const;
98  virtual G4int GetNofNtuples() const final;
99  virtual G4int GetNofNtupleBookings() const override;
100 
101  // Iterators
102  typename std::vector<TNTUPLE*>::iterator BeginNtuple();
103  typename std::vector<TNTUPLE*>::iterator EndNtuple();
104  typename std::vector<TNTUPLE*>::const_iterator BeginConstNtuple() const;
105  typename std::vector<TNTUPLE*>::const_iterator EndConstNtuple() const;
106 
107  // Data members
108  std::vector<G4TNtupleDescription<TNTUPLE>*> fNtupleDescriptionVector;
109  std::vector<TNTUPLE*> fNtupleVector;
110 
111  private:
112  // methods
113 
114  // Fuctions which are specific to output type
115  //
116  virtual void CreateTNtupleFromBooking(
117  G4TNtupleDescription<TNTUPLE>* ntupleDescription) = 0;
118 
119  virtual void FinishTNtuple(
120  G4TNtupleDescription<TNTUPLE>* ntupleDescription) = 0;
121 
122  void FinishTNtupleNew(G4TNtupleDescription<TNTUPLE>* ntupleDescription);
123 
124  // Common implementation
125  //
126 
128  G4String function,
129  G4bool warn = true) const;
130  TNTUPLE* GetNtupleInFunction(G4int id,
131  G4String function,
132  G4bool warn = true) const;
133 
134  // template functions for creating/filling ntuple columns
135 
136  template <typename T>
137  G4int CreateNtupleTColumn(G4int ntupleId,
138  const G4String& name, std::vector<T>* vector);
139 
140  template <typename T>
141  G4bool FillNtupleTColumn(G4int ntupleId, G4int columnId, const T& value);
142 };
143 
144 #include "G4TNtupleManager.icc"
145 
146 #endif
147 
std::vector< G4TNtupleDescription< TNTUPLE > * > fNtupleDescriptionVector
const XML_Char * name
Definition: expat.h:151
virtual G4bool FillNtupleDColumn(G4int id, G4double value) final
TNTUPLE * GetNtuple() const
G4int CreateNtupleTColumn(G4int ntupleId, const G4String &name, std::vector< T > *vector)
virtual void CreateTNtupleFromBooking(G4TNtupleDescription< TNTUPLE > *ntupleDescription)=0
void CreateNtuplesFromBooking()
float G4float
Definition: G4Types.hh:77
virtual G4bool GetActivation(G4int ntupleId) const final
virtual void FinishTNtuple(G4TNtupleDescription< TNTUPLE > *ntupleDescription)=0
std::vector< TNTUPLE * >::const_iterator EndConstNtuple() const
virtual G4int CreateNtupleDColumn(G4int ntupleId, const G4String &name, std::vector< double > *vector) final
virtual G4int CreateNtupleFColumn(G4int ntupleId, const G4String &name, std::vector< float > *vector) final
std::vector< TNTUPLE * >::iterator EndNtuple()
virtual G4bool FillNtupleFColumn(G4int ntupleId, G4int columnId, G4float value) final
virtual G4bool FillNtupleIColumn(G4int ntupleId, G4int columnId, G4int value) final
virtual G4int GetNofNtupleBookings() const override
virtual G4bool FillNtupleIColumn(G4int id, G4int value) final
G4bool IsEmpty() const
TNTUPLE * GetNtupleInFunction(G4int id, G4String function, G4bool warn=true) const
double G4double
Definition: G4Types.hh:76
bool G4bool
Definition: G4Types.hh:79
const XML_Char int const XML_Char * value
Definition: expat.h:331
virtual G4int CreateNtupleIColumn(const G4String &name, std::vector< int > *vector) final
G4bool FillNtupleTColumn(G4int ntupleId, G4int columnId, const T &value)
virtual G4bool FillNtupleSColumn(G4int id, const G4String &value) final
virtual G4int CreateNtupleSColumn(G4int ntupleId, const G4String &name) final
virtual G4int CreateNtupleFColumn(const G4String &name, std::vector< float > *vector) final
std::vector< TNTUPLE * >::const_iterator BeginConstNtuple() const
virtual G4int CreateNtuple(const G4String &name, const G4String &title) final
virtual G4bool FillNtupleDColumn(G4int ntupleId, G4int columnId, G4double value) final
std::vector< TNTUPLE * >::iterator BeginNtuple()
G4bool Reset(G4bool deleteNtuple)
int G4int
Definition: G4Types.hh:78
virtual void SetActivation(G4bool activation) final
virtual G4bool AddNtupleRow() final
virtual G4int GetNofNtuples() const final
virtual void FinishNtuple() final
G4TNtupleDescription< TNTUPLE > * GetNtupleDescriptionInFunction(G4int id, G4String function, G4bool warn=true) const
virtual G4bool FillNtupleSColumn(G4int ntupleId, G4int columnId, const G4String &value) final
void FinishTNtupleNew(G4TNtupleDescription< TNTUPLE > *ntupleDescription)
virtual G4int CreateNtupleSColumn(const G4String &name)
virtual G4bool FillNtupleFColumn(G4int id, G4float value) final
std::vector< TNTUPLE * > fNtupleVector
virtual G4int CreateNtupleIColumn(G4int ntupleId, const G4String &name, std::vector< int > *vector) final
virtual G4int CreateNtupleDColumn(const G4String &name, std::vector< double > *vector) final
G4TNtupleManager(const G4AnalysisManagerState &state)