Geant4_10
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  // Virtual functions from base class
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(const G4String& name);
84  virtual G4int CreateNtupleFColumn(const G4String& name);
85  virtual G4int CreateNtupleDColumn(const G4String& name);
86  virtual void FinishNtuple();
87  // Create columns in the ntuple with given id
88  virtual G4int CreateNtupleIColumn(G4int ntupleId, const G4String& name);
89  virtual G4int CreateNtupleFColumn(G4int ntupleId, const G4String& name);
90  virtual G4int CreateNtupleDColumn(G4int ntupleId, const G4String& name);
91  virtual void FinishNtuple(G4int ntupleId);
92 
93  // Methods to fill ntuples
94  // Methods for ntuple with id = FirstNtupleId
95  virtual G4bool FillNtupleIColumn(G4int columnId, G4int value);
96  virtual G4bool FillNtupleFColumn(G4int columnId, G4float value);
97  virtual G4bool FillNtupleDColumn(G4int columnId, G4double value);
98  virtual G4bool AddNtupleRow();
99  // Methods for ntuple with id > FirstNtupleId (when more ntuples exist)
100  virtual G4bool FillNtupleIColumn(
101  G4int ntupleId, G4int columnId, G4int value);
102  virtual G4bool FillNtupleFColumn(
103  G4int ntupleId, G4int columnId, G4float value);
104  virtual G4bool FillNtupleDColumn(
105  G4int ntupleId, G4int columnId, G4double value);
106  virtual G4bool AddNtupleRow(G4int ntupleId);
107 
108  // Access methods
109  virtual G4int GetNofNtuples() const;
110 
111  private:
112  // methods
113  //
114  void SetNtupleHbookIdOffset();
115  void CreateNtuplesFromBooking();
116 
117  tools::hbook::wntuple::column<int>*
118  GetNtupleIColumn(G4int ntupleId, G4int columnId) const;
119  tools::hbook::wntuple::column<float>*
120  GetNtupleFColumn(G4int ntupleId, G4int columnId) const;
121  tools::hbook::wntuple::column<double>*
122  GetNtupleDColumn(G4int ntupleId, G4int columnId) const;
123 
124  void Reset();
125  ExG4HbookNtupleDescription* GetNtupleInFunction(G4int id,
126  G4String function,
127  G4bool warn = true,
128  G4bool onlyIfActive = true) const;
129 
130  // data members
131  //
132  ExG4HbookFileManager* fFileManager;
133  G4int fNtupleHbookIdOffset;
134  std::vector<ExG4HbookNtupleDescription*> fNtupleVector;
135 };
136 
137 // inline functions
138 
139 inline void ExG4HbookNtupleManager::SetFileManager(ExG4HbookFileManager* fileManager)
140 { fFileManager = fileManager; }
141 
142 inline G4int ExG4HbookNtupleManager::GetNtupleHbookIdOffset() const {
143  return fNtupleHbookIdOffset;
144 }
145 
146 inline G4int ExG4HbookNtupleManager::GetNofNtuples() const
147 { return fNtupleVector.size(); }
148 
149 
150 #endif
151 
152 #endif
virtual G4int GetNofNtuples() const =0
virtual G4int CreateNtupleIColumn(const G4String &name)=0
float G4float
Definition: G4Types.hh:77
const XML_Char * name
Definition: expat.h:151
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)=0
virtual G4int CreateNtupleDColumn(const G4String &name)=0
ntupleExperimental Reset()
virtual G4bool FillNtupleIColumn(G4int id, G4int value)=0
subroutine title(NA, NB, NCA, NCB)
Definition: dpm25nuc7.f:1744
virtual G4bool AddNtupleRow()=0
virtual G4bool FillNtupleFColumn(G4int id, G4float value)=0
const XML_Char int const XML_Char * value
Definition: expat.h:331
virtual G4bool FillNtupleDColumn(G4int id, G4double value)=0
double G4double
Definition: G4Types.hh:76