Geant4  10.00.p01
G4CsvNtupleManager.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: G4CsvNtupleManager.hh 70604 2013-06-03 11:27:06Z ihrivnac $
27 
28 // Manager class for CSV ntuples.
29 //
30 // Author: Ivana Hrivnacova, 18/06/2013 (ivana@ipno.in2p3.fr)
31 
32 #ifndef G4CsvNtupleManager_h
33 #define G4CsvNtupleManager_h 1
34 
35 
36 #include "G4VNtupleManager.hh"
37 #include "globals.hh"
38 
39 #include "tools/wcsv_ntuple"
40 
41 #include <vector>
42 
43 class G4CsvFileManager;
45 
47 {
48  friend class G4CsvAnalysisManager;
49 
50  protected:
53 
54  // Functions specific to the output type
55  //
56 
57  // Methods to manipulate ntuples
59  G4bool IsEmpty() const;
60  G4bool Reset();
61 
62  // Set methods
63  void SetFileManager(G4CsvFileManager* fileManager);
64 
65  // Access methods
66  tools::wcsv::ntuple* GetNtuple() const;
67  tools::wcsv::ntuple* GetNtuple(G4int ntupleId) const;
68 
69  // Access to ntuple vector (needed for Write())
70  const std::vector<G4CsvNtupleDescription*>& GetNtupleVector() const;
71 
72  // Functions independent from the output type
73  //
74 
75  // Methods to create ntuples
76  virtual G4int CreateNtuple(const G4String& name, const G4String& title);
77  // Create columns in the last created ntuple
78  virtual G4int CreateNtupleIColumn(const G4String& name);
79  virtual G4int CreateNtupleFColumn(const G4String& name);
80  virtual G4int CreateNtupleDColumn(const G4String& name);
81  virtual void FinishNtuple();
82  // Create columns in the ntuple with given id
83  virtual G4int CreateNtupleIColumn(G4int ntupleId, const G4String& name);
84  virtual G4int CreateNtupleFColumn(G4int ntupleId, const G4String& name);
85  virtual G4int CreateNtupleDColumn(G4int ntupleId, const G4String& name);
86  virtual void FinishNtuple(G4int ntupleId);
87 
88  // Methods to fill ntuples
89  // Methods for ntuple with id = FirstNtupleId
90  virtual G4bool FillNtupleIColumn(G4int columnId, G4int value);
91  virtual G4bool FillNtupleFColumn(G4int columnId, G4float value);
92  virtual G4bool FillNtupleDColumn(G4int columnId, G4double value);
93  virtual G4bool AddNtupleRow();
94  // Methods for ntuple with id > FirstNtupleId (when more ntuples exist)
95  virtual G4bool FillNtupleIColumn(G4int ntupleId, G4int columnId, G4int value);
96  virtual G4bool FillNtupleFColumn(G4int ntupleId, G4int columnId, G4float value);
97  virtual G4bool FillNtupleDColumn(G4int ntupleId, G4int columnId, G4double value);
98  virtual G4bool AddNtupleRow(G4int ntupleId);
99 
100  // Access methods
101  virtual G4int GetNofNtuples() const;
102 
103  private:
104  // methods
105  //
106  tools::wcsv::ntuple::column<int>*
107  GetNtupleIColumn(G4int ntupleId, G4int columnId) const;
108  tools::wcsv::ntuple::column<float>*
109  GetNtupleFColumn(G4int ntupleId, G4int columnId) const;
110  tools::wcsv::ntuple::column<double>*
111  GetNtupleDColumn(G4int ntupleId, G4int columnId) const;
112 
114  G4String function,
115  G4bool warn = true,
116  G4bool onlyIfActive = true) const;
117 
118  // data members
119  //
121  std::vector<G4CsvNtupleDescription*> fNtupleVector;
122 };
123 
124 // inline functions
125 
127 { fFileManager = fileManager; }
128 
130 { return fNtupleVector.size(); }
131 
132 inline const std::vector<G4CsvNtupleDescription*>& G4CsvNtupleManager::GetNtupleVector() const
133 { return fNtupleVector; }
134 
135 #endif
136 
void SetFileManager(G4CsvFileManager *fileManager)
const std::vector< G4CsvNtupleDescription * > & GetNtupleVector() const
G4String name
Definition: TRTMaterials.hh:40
virtual G4int CreateNtuple(const G4String &name, const G4String &title)
float G4float
Definition: G4Types.hh:77
G4CsvNtupleManager(const G4AnalysisManagerState &state)
int G4int
Definition: G4Types.hh:78
tools::wcsv::ntuple * GetNtuple() const
virtual G4CsvNtupleDescription * GetNtupleInFunction(G4int id, G4String function, G4bool warn=true, G4bool onlyIfActive=true) const
tools::wcsv::ntuple::column< float > * GetNtupleFColumn(G4int ntupleId, G4int columnId) const
G4CsvFileManager * fFileManager
virtual void FinishNtuple()
tools::wcsv::ntuple::column< double > * GetNtupleDColumn(G4int ntupleId, G4int columnId) const
bool G4bool
Definition: G4Types.hh:79
G4bool IsEmpty() const
virtual G4bool FillNtupleFColumn(G4int columnId, G4float value)
virtual G4int CreateNtupleFColumn(const G4String &name)
virtual G4int CreateNtupleDColumn(const G4String &name)
virtual G4int GetNofNtuples() const
virtual G4bool FillNtupleIColumn(G4int columnId, G4int value)
tools::wcsv::ntuple::column< int > * GetNtupleIColumn(G4int ntupleId, G4int columnId) const
virtual G4bool FillNtupleDColumn(G4int columnId, G4double value)
double G4double
Definition: G4Types.hh:76
std::vector< G4CsvNtupleDescription * > fNtupleVector
virtual G4int CreateNtupleIColumn(const G4String &name)
virtual G4bool AddNtupleRow()