Geant4  10.01
G4XmlNtupleManager.hh
Go to the documentation of this file.
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: G4XmlNtupleManager.hh 70604 2013-06-03 11:27:06Z ihrivnac $
27 
28 // Manager class for Xml ntuples
29 //
30 // Author: Ivana Hrivnacova, 18/06/2013 (ivana@ipno.in2p3.fr)
31 
32 #ifndef G4XmlNtupleManager_h
33 #define G4XmlNtupleManager_h 1
34 
35 #include "G4VNtupleManager.hh"
36 #include "globals.hh"
37 
38 #include "tools/waxml/ntuple"
39 
40 #include <vector>
41 
42 class G4XmlFileManager;
44 
46 {
47  friend class G4XmlAnalysisManager;
48 
49  protected:
52 
53  // Functions specific to the output type
54  //
55 
56  // Methods to manipulate ntuples
58  G4bool IsEmpty() const;
59  G4bool Reset();
60 
61  // Set methods
62  void SetFileManager(G4XmlFileManager* fileManager);
63 
64  // Access methods
65  tools::waxml::ntuple* GetNtuple() const;
66  tools::waxml::ntuple* GetNtuple(G4int ntupleId) const;
67 
68  // Iterators
69  std::vector<tools::waxml::ntuple*>::iterator BeginNtuple();
70  std::vector<tools::waxml::ntuple*>::iterator EndNtuple();
71  std::vector<tools::waxml::ntuple*>::const_iterator BeginConstNtuple() const;
72  std::vector<tools::waxml::ntuple*>::const_iterator EndConstNtuple() const;
73 
74  // Access to ntuple vector (needed for Write())
75  const std::vector<G4XmlNtupleDescription*>& GetNtupleDescriptionVector() const;
76 
77  // Virtual functions from base class
78  //
79 
80  // Methods to create ntuples
81  virtual G4int CreateNtuple(const G4String& name, const G4String& title);
82  // Create columns in the last created ntuple
83  virtual G4int CreateNtupleIColumn(
84  const G4String& name, std::vector<int>* vector);
85  virtual G4int CreateNtupleFColumn(
86  const G4String& name, std::vector<float>* vector);
87  virtual G4int CreateNtupleDColumn(
88  const G4String& name, std::vector<double>* vector);
89  virtual G4int CreateNtupleSColumn(const G4String& name);
90  virtual void FinishNtuple();
91  // Create columns in the ntuple with given id
92  // Create columns in the ntuple with given id
93  virtual G4int CreateNtupleIColumn(G4int ntupleId,
94  const G4String& name, std::vector<int>* vector);
95  virtual G4int CreateNtupleFColumn(G4int ntupleId,
96  const G4String& name, std::vector<float>* vector);
97  virtual G4int CreateNtupleDColumn(G4int ntupleId,
98  const G4String& name, std::vector<double>* vector);
99  virtual G4int CreateNtupleSColumn(G4int ntupleId, const G4String& name);
100  virtual void FinishNtuple(G4int ntupleId);
101 
102  // Methods to fill ntuples
103  // Methods for ntuple with id = FirstNtupleId
104  virtual G4bool FillNtupleIColumn(G4int columnId, G4int value);
105  virtual G4bool FillNtupleFColumn(G4int columnId, G4float value);
106  virtual G4bool FillNtupleDColumn(G4int columnId, G4double value);
107  virtual G4bool FillNtupleSColumn(G4int columnId, const G4String& value);
108  virtual G4bool AddNtupleRow();
109  // Methods for ntuple with id > FirstNtupleId (when more ntuples exist)
110  virtual G4bool FillNtupleIColumn(G4int ntupleId, G4int columnId, G4int value);
111  virtual G4bool FillNtupleFColumn(G4int ntupleId, G4int columnId, G4float value);
112  virtual G4bool FillNtupleDColumn(G4int ntupleId, G4int columnId, G4double value);
113  virtual G4bool FillNtupleSColumn(G4int ntupleId, G4int columnId,
114  const G4String& value);
115  virtual G4bool AddNtupleRow(G4int ntupleId);
116 
117  // Access methods
118  virtual G4int GetNofNtuples() const;
119 
120  private:
121  // methods
122  //
123  tools::waxml::ntuple::column<int>*
124  GetNtupleIColumn(G4int ntupleId, G4int columnId) const;
125  tools::waxml::ntuple::column<float>*
126  GetNtupleFColumn(G4int ntupleId, G4int columnId) const;
127  tools::waxml::ntuple::column<double>*
128  GetNtupleDColumn(G4int ntupleId, G4int columnId) const;
129  tools::waxml::ntuple::column<std::string>*
130  GetNtupleSColumn(G4int ntupleId, G4int columnId) const;
131 
133  G4String function,
134  G4bool warn = true,
135  G4bool onlyIfActive = true) const;
136 
137  // data members
138  //
140  std::vector<G4XmlNtupleDescription*> fNtupleDescriptionVector;
141  std::vector<tools::waxml::ntuple*> fNtupleVector;
142 };
143 
144 // inline functions
145 
147 { fFileManager = fileManager; }
148 
149 inline std::vector<tools::waxml::ntuple*>::iterator
151 { return fNtupleVector.begin(); }
152 
153 inline std::vector<tools::waxml::ntuple*>::iterator
155 { return fNtupleVector.end(); }
156 
157 inline std::vector<tools::waxml::ntuple*>::const_iterator
159 { return fNtupleVector.begin(); }
160 
161 inline std::vector<tools::waxml::ntuple*>::const_iterator
163 { return fNtupleVector.end(); }
164 
166 { return fNtupleVector.size(); }
167 
168 inline const std::vector<G4XmlNtupleDescription*>&
170 { return fNtupleDescriptionVector; }
171 
172 
173 #endif
174 
std::vector< tools::waxml::ntuple * >::const_iterator EndConstNtuple() const
virtual G4int GetNofNtuples() const
virtual G4int CreateNtupleFColumn(const G4String &name, std::vector< float > *vector)
virtual G4int CreateNtupleDColumn(const G4String &name, std::vector< double > *vector)
virtual G4bool FillNtupleIColumn(G4int columnId, G4int value)
G4String name
Definition: TRTMaterials.hh:40
std::vector< tools::waxml::ntuple * > fNtupleVector
float G4float
Definition: G4Types.hh:77
virtual G4bool AddNtupleRow()
std::vector< G4XmlNtupleDescription * > fNtupleDescriptionVector
int G4int
Definition: G4Types.hh:78
virtual G4bool FillNtupleSColumn(G4int columnId, const G4String &value)
std::vector< tools::waxml::ntuple * >::iterator EndNtuple()
G4XmlFileManager * fFileManager
void SetFileManager(G4XmlFileManager *fileManager)
const std::vector< G4XmlNtupleDescription * > & GetNtupleDescriptionVector() const
std::vector< tools::waxml::ntuple * >::const_iterator BeginConstNtuple() const
std::vector< tools::waxml::ntuple * >::iterator BeginNtuple()
bool G4bool
Definition: G4Types.hh:79
G4bool IsEmpty() const
virtual G4bool FillNtupleFColumn(G4int columnId, G4float value)
virtual void FinishNtuple()
virtual G4int CreateNtupleIColumn(const G4String &name, std::vector< int > *vector)
tools::waxml::ntuple::column< float > * GetNtupleFColumn(G4int ntupleId, G4int columnId) const
virtual G4bool FillNtupleDColumn(G4int columnId, G4double value)
virtual G4int CreateNtupleSColumn(const G4String &name)
virtual G4XmlNtupleDescription * GetNtupleInFunction(G4int id, G4String function, G4bool warn=true, G4bool onlyIfActive=true) const
tools::waxml::ntuple::column< std::string > * GetNtupleSColumn(G4int ntupleId, G4int columnId) const
tools::waxml::ntuple * GetNtuple() const
G4XmlNtupleManager(const G4AnalysisManagerState &state)
double G4double
Definition: G4Types.hh:76
tools::waxml::ntuple::column< int > * GetNtupleIColumn(G4int ntupleId, G4int columnId) const
virtual G4int CreateNtuple(const G4String &name, const G4String &title)
tools::waxml::ntuple::column< double > * GetNtupleDColumn(G4int ntupleId, G4int columnId) const