Geant4_10
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
66  tools::waxml::ntuple* GetNtuple(G4int ntupleId) const;
67 
68  // Access to ntuple vector (needed for Write())
69  const std::vector<G4XmlNtupleDescription*>& GetNtupleVector() const;
70 
71  // Virtual functions from base class
72  //
73 
74  // Methods to create ntuples
75  virtual G4int CreateNtuple(const G4String& name, const G4String& title);
76  // Create columns in the last created ntuple
77  virtual G4int CreateNtupleIColumn(const G4String& name);
78  virtual G4int CreateNtupleFColumn(const G4String& name);
79  virtual G4int CreateNtupleDColumn(const G4String& name);
80  virtual void FinishNtuple();
81  // Create columns in the ntuple with given id
82  virtual G4int CreateNtupleIColumn(G4int ntupleId, const G4String& name);
83  virtual G4int CreateNtupleFColumn(G4int ntupleId, const G4String& name);
84  virtual G4int CreateNtupleDColumn(G4int ntupleId, const G4String& name);
85  virtual void FinishNtuple(G4int ntupleId);
86 
87  // Methods to fill ntuples
88  // Methods for ntuple with id = FirstNtupleId
89  virtual G4bool FillNtupleIColumn(G4int columnId, G4int value);
90  virtual G4bool FillNtupleFColumn(G4int columnId, G4float value);
91  virtual G4bool FillNtupleDColumn(G4int columnId, G4double value);
92  virtual G4bool AddNtupleRow();
93  // Methods for ntuple with id > FirstNtupleId (when more ntuples exist)
94  virtual G4bool FillNtupleIColumn(G4int ntupleId, G4int columnId, G4int value);
95  virtual G4bool FillNtupleFColumn(G4int ntupleId, G4int columnId, G4float value);
96  virtual G4bool FillNtupleDColumn(G4int ntupleId, G4int columnId, G4double value);
97  virtual G4bool AddNtupleRow(G4int ntupleId);
98 
99  // Access methods
100  virtual G4int GetNofNtuples() const;
101 
102  private:
103  // methods
104  //
105  tools::waxml::ntuple::column<int>*
106  GetNtupleIColumn(G4int ntupleId, G4int columnId) const;
107  tools::waxml::ntuple::column<float>*
108  GetNtupleFColumn(G4int ntupleId, G4int columnId) const;
109  tools::waxml::ntuple::column<double>*
110  GetNtupleDColumn(G4int ntupleId, G4int columnId) const;
111 
112  virtual G4XmlNtupleDescription* GetNtupleInFunction(G4int id,
113  G4String function,
114  G4bool warn = true,
115  G4bool onlyIfActive = true) const;
116 
117  // data members
118  //
119  G4XmlFileManager* fFileManager;
120  std::vector<G4XmlNtupleDescription*> fNtupleVector;
121 };
122 
123 // inline functions
124 
126 { fFileManager = fileManager; }
127 
129 { return fNtupleVector.size(); }
130 
131 inline const std::vector<G4XmlNtupleDescription*>& G4XmlNtupleManager::GetNtupleVector() const
132 { return fNtupleVector; }
133 
134 
135 #endif
136 
virtual G4int GetNofNtuples() const
virtual G4bool FillNtupleIColumn(G4int columnId, G4int value)
float G4float
Definition: G4Types.hh:77
virtual G4bool AddNtupleRow()
const XML_Char * name
Definition: expat.h:151
TTree * ntuple
Definition: macro.C:6
virtual G4int CreateNtupleFColumn(const G4String &name)
int G4int
Definition: G4Types.hh:78
void SetFileManager(G4XmlFileManager *fileManager)
const std::vector< G4XmlNtupleDescription * > & GetNtupleVector() const
virtual G4int CreateNtupleDColumn(const G4String &name)
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)
subroutine title(NA, NB, NCA, NCB)
Definition: dpm25nuc7.f:1744
virtual G4bool FillNtupleDColumn(G4int columnId, G4double value)
tools::waxml::ntuple * GetNtuple() const
const XML_Char int const XML_Char * value
Definition: expat.h:331
G4XmlNtupleManager(const G4AnalysisManagerState &state)
double G4double
Definition: G4Types.hh:76
virtual G4int CreateNtuple(const G4String &name, const G4String &title)