Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4RootPNtupleManager.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 for Root pntuple management.
28//
29// Author: Ivana Hrivnacova, 04/10/2016 ([email protected])
30
31#ifndef G4RootPNtupleManager_h
32#define G4RootPNtupleManager_h 1
33
38#include "G4AutoLock.hh"
39#include "globals.hh"
40
41#include <vector>
42
44
45namespace tools {
46namespace wroot {
47class file;
48class ntuple;
49class imt_ntuple;
50}
51}
52
53// Mutex implementation as in pwroot.cpp
54// with replacement tools::mutex -> G4Mutex
55
56class mutex : public virtual tools::wroot::imutex {
57 typedef tools::wroot::imutex parent;
58public:
59 virtual bool lock() {
60 // G4cout << "!!! Mutex lock" << G4endl;
61 m_mutex.lock();
62 return true;}
63 virtual bool unlock() {
64 m_mutex.unlock();
65 // G4cout << "!!! Mutex unlock" << G4endl;
66 return true; }
67 //virtual bool trylock() {return m_mutex.trylock();}
68public:
69 mutex(G4AutoLock& a_mutex):m_mutex(a_mutex){}
70 virtual ~mutex(){}
71protected:
72 mutex(const mutex& a_from):parent(a_from),m_mutex(a_from.m_mutex){}
73 mutex& operator=(const mutex&){return *this;}
74protected:
76};
77
79{
82
83 public:
84 explicit G4RootPNtupleManager(const G4AnalysisManagerState& state,
85 std::shared_ptr<G4NtupleBookingManager> bookingManger,
86 std::shared_ptr<G4RootMainNtupleManager> main,
87 G4bool rowWise, G4bool rowMode);
89
90 private:
91 // Methods to manipulate ntuples
92 void CreateNtupleFromMain(G4RootPNtupleDescription* ntupleDescription,
93 tools::wroot::ntuple* mainNtuple);
94 // void CreateNtupleFromMain(G4NtupleBooking* g4NtupleBooking,
95 // tools::wroot::ntuple* mainNtuple);
96 void CreateNtuplesFromMain();
97
98 // Methods to create ntuples
99 //
100 virtual G4int CreateNtuple(G4NtupleBooking* booking) final;
101
102 // Methods to fill ntuples
103 // Methods for ntuple with id = FirstNtupleId (from base class)
109 // Methods for ntuple with id > FirstNtupleId (when more ntuples exist)
110 virtual G4bool FillNtupleIColumn(G4int ntupleId, G4int columnId, G4int value) final;
111 virtual G4bool FillNtupleFColumn(G4int ntupleId, G4int columnId, G4float value) final;
112 virtual G4bool FillNtupleDColumn(G4int ntupleId, G4int columnId, G4double value) final;
113 virtual G4bool FillNtupleSColumn(G4int ntupleId, G4int columnId,
114 const G4String& value) final;
115 virtual G4bool AddNtupleRow(G4int ntupleId) final;
116 virtual G4bool Merge() final;
117
118 // Reset
119 virtual G4bool Reset(G4bool deleteNtuple) final;
120
121 // Activation option
122 //
123 virtual void SetActivation(G4bool activation) final;
124 virtual void SetActivation(G4int ntupleId, G4bool activation) final;
125 virtual G4bool GetActivation(G4int ntupleId) const final;
126
127 // Access methods
128 virtual G4int GetNofNtuples() const final;
129
130 // Set methods
131 void SetNtupleRowWise(G4bool rowWise, G4bool rowMode);
132
133 private:
135 GetNtupleDescriptionInFunction(G4int id, G4String function, G4bool warn = true) const;
136 tools::wroot::base_pntuple*
137 GetNtupleInFunction(G4int id, G4String function, G4bool warn = true) const;
138 tools::wroot::ntuple*
139 GetMainNtupleInFunction(G4int id, G4String function, G4bool warn = true) const;
140
141 template <typename T>
142 G4bool FillNtupleTColumn(G4int ntupleId, G4int columnId, const T& value);
143
144 template <typename T>
145 G4bool FillNtupleTColumn(G4int columnId, const T& value);
146
147 // Data members
148 std::shared_ptr<G4NtupleBookingManager> fBookingManager;
149 std::shared_ptr<G4RootMainNtupleManager> fMainNtupleManager;
150 std::vector<G4RootPNtupleDescription*> fNtupleDescriptionVector;
151 std::vector<tools::wroot::imt_ntuple*> fNtupleVector;
152 G4bool fRowWise;
153 G4bool fRowMode;
154};
155
156#include "G4RootPNtupleManager.icc"
157
158#endif
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 FillNtupleSColumn(G4int id, const G4String &value) final
virtual G4bool FillNtupleFColumn(G4int id, G4float value) final
virtual G4bool FillNtupleDColumn(G4int id, G4double value) final
virtual G4bool FillNtupleIColumn(G4int id, G4int value) final
virtual G4bool AddNtupleRow() final
mutex & operator=(const mutex &)
virtual bool lock()
mutex(const mutex &a_from)
mutex(G4AutoLock &a_mutex)
G4AutoLock & m_mutex
virtual bool unlock()
virtual ~mutex()