Geant4  10.02.p01
ExG4HbookNtupleManager.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$
27 //
30 
31 // Author: Ivana Hrivnacova, 15/06/2011 (ivana@ipno.in2p3.fr)
32 
33 #ifdef G4_USE_HBOOK
34 
35 #ifndef ExG4HbookNtupleManager_h
36 #define ExG4HbookNtupleManager_h 1
37 
38 #include "G4VNtupleManager.hh"
40 #include "globals.hh"
41 
42 #include <tools/hbook/wntuple>
43 
44 #include <vector>
45 #include <map>
46 
47 class ExG4HbookFileManager;
48 
54 
55 class ExG4HbookNtupleManager : public G4VNtupleManager
56 {
57  friend class ExG4HbookAnalysisManager;
58 
59  protected:
60  ExG4HbookNtupleManager(const G4AnalysisManagerState& state);
61  virtual ~ExG4HbookNtupleManager();
62 
63  // Functions specific to the output type
64  //
65 
66  // Set the offset of NTUPLE ID for ntuples
67  // ( default value = firstNtupleID if firstNtupleID > 0; otherwise = 1)
68  G4bool SetNtupleHbookIdOffset(G4int offset);
69  G4int GetNtupleHbookIdOffset() const;
70 
71  // Set methods
72  void SetFileManager(ExG4HbookFileManager* fileManager);
73 
74  // Access methods
75  tools::hbook::wntuple* GetNtuple() const;
76  tools::hbook::wntuple* GetNtuple(G4int ntupleId) const;
77 
78  // Iterators
79  std::vector<tools::hbook::wntuple*>::iterator BeginNtuple();
80  std::vector<tools::hbook::wntuple*>::iterator EndNtuple();
81  std::vector<tools::hbook::wntuple*>::const_iterator BeginConstNtuple() const;
82  std::vector<tools::hbook::wntuple*>::const_iterator EndConstNtuple() const;
83 
84  // Virtual functions from base class
85  //
86  // Methods to create ntuples
87  virtual G4int CreateNtuple(const G4String& name, const G4String& title);
88  // Create columns in the last created ntuple
89  virtual G4int CreateNtupleIColumn(
90  const G4String& name, std::vector<int>* vector);
91  virtual G4int CreateNtupleFColumn(
92  const G4String& name, std::vector<float>* vector);
93  virtual G4int CreateNtupleDColumn(
94  const G4String& name, std::vector<double>* vector);
95  virtual G4int CreateNtupleSColumn(const G4String& name);
96  virtual void FinishNtuple();
97  // Create columns in the ntuple with given id
98  virtual G4int CreateNtupleIColumn(G4int ntupleId,
99  const G4String& name, std::vector<int>* vector);
100  virtual G4int CreateNtupleFColumn(G4int ntupleId,
101  const G4String& name, std::vector<float>* vector);
102  virtual G4int CreateNtupleDColumn(G4int ntupleId,
103  const G4String& name, std::vector<double>* vector);
104  virtual G4int CreateNtupleSColumn(G4int ntupleId, const G4String& name);
105  virtual void FinishNtuple(G4int ntupleId);
106 
107  // Methods to fill ntuples
108  // Methods for ntuple with id = FirstNtupleId
109  virtual G4bool FillNtupleIColumn(G4int columnId, G4int value);
110  virtual G4bool FillNtupleFColumn(G4int columnId, G4float value);
111  virtual G4bool FillNtupleDColumn(G4int columnId, G4double value);
112  virtual G4bool FillNtupleSColumn(G4int columnId, const G4String& value);
113  virtual G4bool AddNtupleRow();
114  // Methods for ntuple with id > FirstNtupleId (when more ntuples exist)
115  virtual G4bool FillNtupleIColumn(
116  G4int ntupleId, G4int columnId, G4int value);
117  virtual G4bool FillNtupleFColumn(
118  G4int ntupleId, G4int columnId, G4float value);
119  virtual G4bool FillNtupleDColumn(
120  G4int ntupleId, G4int columnId, G4double value);
121  virtual G4bool FillNtupleSColumn(
122  G4int ntupleId, G4int columnId, const G4String& value);
123  virtual G4bool AddNtupleRow(G4int ntupleId);
124 
125  // Activation option
126  virtual void SetActivation(G4bool activation);
127  virtual void SetActivation(G4int ntupleId, G4bool activation);
128  virtual G4bool GetActivation(G4int ntupleId) const;
129 
130  // Access methods
131  virtual G4int GetNofNtuples() const;
132 
133  private:
134  // methods
135  //
136  void SetNtupleHbookIdOffset();
137  void CreateNtuplesFromBooking();
138 
139  tools::hbook::wntuple::column<int>*
140  GetNtupleIColumn(G4int ntupleId, G4int columnId) const;
141  tools::hbook::wntuple::column<float>*
142  GetNtupleFColumn(G4int ntupleId, G4int columnId) const;
143  tools::hbook::wntuple::column<double>*
144  GetNtupleDColumn(G4int ntupleId, G4int columnId) const;
145 
146  void Reset();
147  ExG4HbookNtupleDescription* GetNtupleInFunction(G4int id,
148  G4String function,
149  G4bool warn = true,
150  G4bool onlyIfActive = true) const;
151 
152  // data members
153  //
154  ExG4HbookFileManager* fFileManager;
155  G4int fNtupleHbookIdOffset;
156  std::vector<ExG4HbookNtupleDescription*> fNtupleDescriptionVector;
157  std::vector<tools::hbook::wntuple*> fNtupleVector;
158 };
159 
160 // inline functions
161 
162 inline void ExG4HbookNtupleManager::SetFileManager(ExG4HbookFileManager* fileManager)
163 { fFileManager = fileManager; }
164 
165 inline G4int ExG4HbookNtupleManager::GetNtupleHbookIdOffset() const {
166  return fNtupleHbookIdOffset;
167 }
168 
169 inline std::vector<tools::hbook::wntuple*>::iterator
170 ExG4HbookNtupleManager::BeginNtuple()
171 { return fNtupleVector.begin(); }
172 
173 inline std::vector<tools::hbook::wntuple*>::iterator
174 ExG4HbookNtupleManager::EndNtuple()
175 { return fNtupleVector.end(); }
176 
177 inline std::vector<tools::hbook::wntuple*>::const_iterator
178 ExG4HbookNtupleManager::BeginConstNtuple() const
179 { return fNtupleVector.begin(); }
180 
181 inline std::vector<tools::hbook::wntuple*>::const_iterator
182 ExG4HbookNtupleManager::EndConstNtuple() const
183 { return fNtupleVector.end(); }
184 
185 inline G4int ExG4HbookNtupleManager::GetNofNtuples() const
186 { return fNtupleVector.size(); }
187 
188 
189 #endif
190 
191 #endif
virtual G4int GetNofNtuples() const =0
G4String name
Definition: TRTMaterials.hh:40
float G4float
Definition: G4Types.hh:77
virtual G4int CreateNtupleSColumn(const G4String &name)=0
virtual G4bool FillNtupleSColumn(G4int id, const G4String &value)=0
int G4int
Definition: G4Types.hh:78
virtual G4int CreateNtuple(const G4String &name, const G4String &title)=0
virtual void FinishNtuple()=0
bool G4bool
Definition: G4Types.hh:79
virtual G4int CreateNtupleFColumn(const G4String &name, std::vector< float > *vector)=0
virtual G4int CreateNtupleIColumn(const G4String &name, std::vector< int > *vector)=0
virtual G4bool FillNtupleIColumn(G4int id, G4int value)=0
virtual G4bool AddNtupleRow()=0
virtual G4bool FillNtupleFColumn(G4int id, G4float value)=0
virtual G4bool GetActivation(G4int id) const =0
virtual void SetActivation(G4bool activation)=0
virtual G4bool FillNtupleDColumn(G4int id, G4double value)=0
double G4double
Definition: G4Types.hh:76
virtual G4int CreateNtupleDColumn(const G4String &name, std::vector< double > *vector)=0
Definition of the ExG4HbookNtupleDescription structure.