ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4TRNtupleManager.hh
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4TRNtupleManager.hh
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 
34 #include "G4BaseRNtupleManager.hh"
35 #include "G4TRNtupleDescription.hh"
36 #include "globals.hh"
37 
38 #include <vector>
39 
40 template <typename TNTUPLE>
42 {
43  protected:
44  explicit G4TRNtupleManager(const G4AnalysisManagerState& state);
45  virtual ~G4TRNtupleManager();
46 
47  // Methods to manipulate ntuples
48  G4bool IsEmpty() const;
49  G4bool Reset();
50 
51  // Access methods
52  TNTUPLE* GetNtuple() const;
53  TNTUPLE* GetNtuple(G4int ntupleId) const;
54 
55  // Functions independent from the output type
56  //
57  // Methods to read ntuple from a file
58  G4int SetNtuple(G4TRNtupleDescription<TNTUPLE>* rntupleDescription);
59 
60  // Methods to bind ntuple (from base class)
65 
66  // Methods to bind ntuple
67  virtual G4bool SetNtupleIColumn(G4int ntupleId,
68  const G4String& columnName, G4int& value) final;
69  virtual G4bool SetNtupleFColumn(G4int ntupleId,
70  const G4String& columnName, G4float& value) final;
71  virtual G4bool SetNtupleDColumn(G4int ntupleId,
72  const G4String& columnName, G4double& value) final;
73  virtual G4bool SetNtupleSColumn(G4int ntupleId,
74  const G4String& columnName, G4String& value) final;
75 
76  // Bind the ntuple columns of vector type
77  virtual G4bool SetNtupleIColumn(G4int ntupleId, const G4String& columnName,
78  std::vector<G4int>& vector) override;
79  virtual G4bool SetNtupleFColumn(G4int ntupleId, const G4String& columnName,
80  std::vector<G4float>& vector) override;
81  virtual G4bool SetNtupleDColumn(G4int ntupleId, const G4String& columnName,
82  std::vector<G4double>& vector) override;
83 
85  virtual G4bool GetNtupleRow(G4int ntupleId) final;
86 
87  // Access methods
88  virtual G4int GetNofNtuples() const final;
89 
90  // Utility method
92  G4String function,
93  G4bool warn = true) const;
94 
95  private:
96  // Fuctions which are specific to output type
97  //
98  virtual G4bool GetTNtupleRow(G4TRNtupleDescription<TNTUPLE>* rntupleDescription) = 0;
99 
100  // Common implementation
101  //
102  template <typename T>
103  G4bool SetNtupleTColumn(G4int ntupleId, const G4String& name,
104  T& value);
105 
106  template <typename T>
107  G4bool SetNtupleTColumn(G4int ntupleId, const G4String& name,
108  std::vector<T>& vector);
109 
110  // data members
111  std::vector<G4TRNtupleDescription<TNTUPLE>*> fNtupleDescriptionVector;
112 };
113 
114 #include "G4TRNtupleManager.icc"
115 
116 #endif
117