Geant4-11
G4TRNtupleManager.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
27// Class template for read ntuple managers for all output types.
28//
29// Author: Ivana Hrivnacova, 20/07/2017 (ivana@ipno.in2p3.fr)
30
31#ifndef G4TRNtupleManager_h
32#define G4TRNtupleManager_h 1
33
36#include "globals.hh"
37
38#include <vector>
39#include <string_view>
40
41template <typename NT>
43{
44 protected:
48
49 // Methods to manipulate ntuples
50 G4bool IsEmpty() const;
52
53 // Access methods
54 NT* GetNtuple() const;
55 NT* GetNtuple(G4int ntupleId) const;
56
57 // Functions independent from the output type
58 //
59 // Methods to read ntuple from a file
61
62 // Methods to bind ntuple (from base class)
67
68 // Methods to bind ntuple
69 virtual G4bool SetNtupleIColumn(G4int ntupleId,
70 const G4String& columnName, G4int& value) final;
71 virtual G4bool SetNtupleFColumn(G4int ntupleId,
72 const G4String& columnName, G4float& value) final;
73 virtual G4bool SetNtupleDColumn(G4int ntupleId,
74 const G4String& columnName, G4double& value) final;
75 virtual G4bool SetNtupleSColumn(G4int ntupleId,
76 const G4String& columnName, G4String& value) final;
77
78 // Bind the ntuple columns of vector type
79 virtual G4bool SetNtupleIColumn(G4int ntupleId, const G4String& columnName,
80 std::vector<G4int>& vector) override;
81 virtual G4bool SetNtupleFColumn(G4int ntupleId, const G4String& columnName,
82 std::vector<G4float>& vector) override;
83 virtual G4bool SetNtupleDColumn(G4int ntupleId, const G4String& columnName,
84 std::vector<G4double>& vector) override;
85 virtual G4bool SetNtupleSColumn(G4int ntupleId, const G4String& columnName,
86 std::vector<std::string>& vector) override;
87
89 virtual G4bool GetNtupleRow(G4int ntupleId) final;
90
91 // Access methods
92 virtual G4int GetNofNtuples() const final;
93
94 // Utility method
96 std::string_view function,
97 G4bool warn = true) const;
98
99 private:
100 // Fuctions which are specific to output type
101 //
102 virtual G4bool GetTNtupleRow(G4TRNtupleDescription<NT>* rntupleDescription) = 0;
103
104 // Common implementation
105 //
106 template <typename T>
108 T& value);
109
110 template <typename T>
112 std::vector<T>& vector);
113
114 // Static data members
115 static constexpr std::string_view fkClass { "G4TRNtupleManager<NT>" };
116
117 // Data members
118 std::vector<G4TRNtupleDescription<NT>*> fNtupleDescriptionVector;
119};
120
121#include "G4TRNtupleManager.icc"
122
123#endif
124
G4double(* function)(G4double)
float G4float
Definition: G4Types.hh:84
double G4double
Definition: G4Types.hh:83
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
virtual G4bool SetNtupleSColumn(const G4String &columnName, G4String &value) final
virtual G4bool GetNtupleRow() final
virtual G4bool SetNtupleFColumn(const G4String &columnName, G4float &value) final
virtual G4bool SetNtupleDColumn(const G4String &columnName, G4double &value) final
virtual G4bool SetNtupleIColumn(const G4String &columnName, G4int &value) final
G4TRNtupleManager(const G4AnalysisManagerState &state)
std::vector< G4TRNtupleDescription< NT > * > fNtupleDescriptionVector
virtual G4bool SetNtupleDColumn(G4int ntupleId, const G4String &columnName, G4double &value) final
static constexpr std::string_view fkClass
G4bool IsEmpty() const
NT * GetNtuple(G4int ntupleId) const
G4TRNtupleDescription< NT > * GetNtupleDescriptionInFunction(G4int id, std::string_view function, G4bool warn=true) const
virtual G4int GetNofNtuples() const final
virtual G4bool SetNtupleIColumn(G4int ntupleId, const G4String &columnName, std::vector< G4int > &vector) override
virtual G4bool GetNtupleRow(G4int ntupleId) final
virtual G4bool GetTNtupleRow(G4TRNtupleDescription< NT > *rntupleDescription)=0
virtual G4bool SetNtupleSColumn(G4int ntupleId, const G4String &columnName, std::vector< std::string > &vector) override
G4bool SetNtupleTColumn(G4int ntupleId, const G4String &name, T &value)
virtual G4bool SetNtupleDColumn(G4int ntupleId, const G4String &columnName, std::vector< G4double > &vector) override
virtual G4bool SetNtupleFColumn(G4int ntupleId, const G4String &columnName, G4float &value) final
G4TRNtupleManager()=delete
virtual G4bool SetNtupleIColumn(G4int ntupleId, const G4String &columnName, G4int &value) final
virtual G4bool SetNtupleFColumn(G4int ntupleId, const G4String &columnName, std::vector< G4float > &vector) override
virtual ~G4TRNtupleManager()
NT * GetNtuple() const
G4int SetNtuple(G4TRNtupleDescription< NT > *rntupleDescription)
virtual G4bool SetNtupleSColumn(G4int ntupleId, const G4String &columnName, G4String &value) final
const char * name(G4int ptype)