Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4VAnalysisReader.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// The nonvirtual public interface reader class for g4tools based analysis.
28// It is defined as a composite of object manager base classes.
29// Individual use of the component managers is disabled
30// (except for file manager and Hn manager which are also used from
31// other object managers).
32// The functions which has to be implemented in concrete managers
33// are declared as virtual protected.
34
35// Author: Ivana Hrivnacova, 09/04/2014 ([email protected])
36
37#ifndef G4VAnalysisReader_h
38#define G4VAnalysisReader_h 1
39
41#include "globals.hh"
42
43#include "G4VTBaseHnManager.hh" // make forward declaration if possible
44
45#include <vector>
46#include <memory>
47#include <string_view>
48
49class G4HnManager;
51class G4VRFileManager;
52
54{
55 public:
57
58 // Methods for handling files
59 // G4bool OpenFile(const G4String& fileName = "");
60 G4bool CloseFiles(G4bool reset = true);
61
62 // Methods for handling files and directories names
63 void SetFileName(const G4String& fileName);
64 G4String GetFileName() const;
65
66 // Methods to read histograms from a file
67 G4int ReadH1(const G4String& h1Name, const G4String& fileName = "", const G4String& dirName = "");
68 G4int ReadH2(const G4String& h2Name, const G4String& fileName = "", const G4String& dirName = "");
69 G4int ReadH3(const G4String& h3Name, const G4String& fileName = "", const G4String& dirName = "");
70 G4int ReadP1(const G4String& h1Name, const G4String& fileName = "", const G4String& dirName = "");
71 G4int ReadP2(const G4String& h2Name, const G4String& fileName = "", const G4String& dirName = "");
72
73 // The ids of histograms and ntuples are generated automatically
74 // starting from 0; with following functions it is possible to
75 // change the first Id to start from other value
77 G4bool SetFirstH1Id(G4int firstId);
78 G4bool SetFirstH2Id(G4int firstId);
79 G4bool SetFirstH3Id(G4int firstId);
81 G4bool SetFirstP1Id(G4int firstId);
82 G4bool SetFirstP2Id(G4int firstId);
84
85 // Methods to read ntuple from a file
86 G4int GetNtuple(const G4String& ntupleName, const G4String& fileName = "", const G4String& dirName = "");
87
88 // Methods for ntuple with id = FirstNtupleId
89 G4bool SetNtupleIColumn(const G4String& columnName, G4int& value);
90 G4bool SetNtupleFColumn(const G4String& columnName, G4float& value);
91 G4bool SetNtupleDColumn(const G4String& columnName, G4double& value);
92 G4bool SetNtupleSColumn(const G4String& columnName, G4String& value);
93 // Bind the ntuple colums of vector type
94 G4bool SetNtupleIColumn(const G4String& columnName,
95 std::vector<int>& vector);
96 G4bool SetNtupleFColumn(const G4String& columnName,
97 std::vector<float>& vector);
98 G4bool SetNtupleDColumn(const G4String& columnName,
99 std::vector<double>& vector);
100 G4bool SetNtupleSColumn(const G4String& columnName,
101 std::vector<std::string>& vector);
102 // Methods for ntuple with id > FirstNtupleId
103 G4bool SetNtupleIColumn(G4int ntupleId, const G4String& columnName,
104 G4int& value);
105 G4bool SetNtupleFColumn(G4int ntupleId, const G4String& columnName,
106 G4float& value);
107 G4bool SetNtupleDColumn(G4int ntupleId, const G4String& columnName,
108 G4double& value);
109 G4bool SetNtupleSColumn(G4int ntupleId, const G4String& columnName,
110 G4String& value);
111 // Bind the ntuple colums of vector type
112 G4bool SetNtupleIColumn(G4int ntupleId, const G4String& columnName,
113 std::vector<int>& vector);
114 G4bool SetNtupleFColumn(G4int ntupleId, const G4String& columnName,
115 std::vector<float>& vector);
116 G4bool SetNtupleDColumn(G4int ntupleId, const G4String& columnName,
117 std::vector<double>& vector);
118 G4bool SetNtupleSColumn(G4int ntupleId, const G4String& columnName,
119 std::vector<std::string>& vector);
120
122 G4bool GetNtupleRow(G4int ntupleId);
123
124 // ASCII option
125
126 // Return false if there is no object selected for ASCII output,
127 // return true otherwise
129
130 // Access methods
131 G4int GetNofH1s() const;
132 G4int GetNofH2s() const;
133 G4int GetNofH3s() const;
134 G4int GetNofP1s() const;
135 G4int GetNofP2s() const;
136 G4int GetNofNtuples() const;
137
138 // Access methods via names
139 G4int GetH1Id(const G4String& name, G4bool warn = true) const;
140 G4int GetH2Id(const G4String& name, G4bool warn = true) const;
141 G4int GetH3Id(const G4String& name, G4bool warn = true) const;
142 G4int GetP1Id(const G4String& name, G4bool warn = true) const;
143 G4int GetP2Id(const G4String& name, G4bool warn = true) const;
144
145 // Access to histogram & profiles parameters
146 //
151 //
160 //
173 //
180 //
191
192 // Access histogram & profiles attributes for plotting
193 //
197 //
202 //
207 //
212 //
217
218 // Verbosity
219 void SetVerboseLevel(G4int verboseLevel);
221
222 // The manager type (starts with an uppercase letter)
224 // The manager file type (starts with a lowercase letter)
226
227 protected:
228 explicit G4VAnalysisReader(const G4String& type);
229
230 // Virtual methods
231 virtual G4int ReadH1Impl(const G4String& h1Name, const G4String& fileName,
232 const G4String& dirName, G4bool isUserFileName) = 0;
233 virtual G4int ReadH2Impl(const G4String& h2Name, const G4String& fileName,
234 const G4String& dirName, G4bool isUserFileName) = 0;
235 virtual G4int ReadH3Impl(const G4String& h3Name, const G4String& fileName,
236 const G4String& dirName, G4bool isUserFileName) = 0;
237 virtual G4int ReadP1Impl(const G4String& p1Name, const G4String& fileName,
238 const G4String& dirName, G4bool isUserFileName) = 0;
239 virtual G4int ReadP2Impl(const G4String& p2Name, const G4String& fileName,
240 const G4String& dirName, G4bool isUserFileName) = 0;
241 virtual G4bool CloseFilesImpl(G4bool reset) = 0;
242
243 void Message(G4int level,
244 const G4String& action,
245 const G4String& objectType,
246 const G4String& objectName = "",
247 G4bool success = true) const;
248
249 // Methods
250 void SetH1Manager(G4VTBaseHnManager<1>* h1Manager);
251 void SetH2Manager(G4VTBaseHnManager<2>* h2Manager);
252 void SetH3Manager(G4VTBaseHnManager<3>* h3Manager);
253 void SetP1Manager(G4VTBaseHnManager<2>* p1Manager);
254 void SetP2Manager(G4VTBaseHnManager<3>* p2Manager);
255 void SetNtupleManager(std::shared_ptr<G4VRNtupleManager> ntupleManager);
256 void SetFileManager(std::shared_ptr<G4VRFileManager> fileManager);
257
258 // Data members
260
261 protected:
262 std::shared_ptr<G4VRFileManager> fVFileManager { nullptr };
263
264 private:
265 // Static data members
266 static constexpr std::string_view fkClass { "G4VAnalysisReader" };
267
268 // Data members
269 std::unique_ptr<G4VTBaseHnManager<1>> fVH1Manager;
270 std::unique_ptr<G4VTBaseHnManager<2>> fVH2Manager;
271 std::unique_ptr<G4VTBaseHnManager<3>> fVH3Manager;
272 std::unique_ptr<G4VTBaseHnManager<2>> fVP1Manager;
273 std::unique_ptr<G4VTBaseHnManager<3>> fVP2Manager;
274 std::shared_ptr<G4VRNtupleManager> fVNtupleManager { nullptr };
275};
276
277// inline functions
278
279#include "G4VAnalysisReader.icc"
280
281#endif
float G4float
Definition: G4Types.hh:84
double G4double
Definition: G4Types.hh:83
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
G4int GetH3Nybins(G4int id) const
G4bool SetFirstH3Id(G4int firstId)
G4double GetP2XWidth(G4int id) const
G4double GetH2Xmin(G4int id) const
G4int GetVerboseLevel() const
G4int GetH1Nbins(G4int id) const
G4String GetH3Title(G4int id) const
G4int GetP1Nbins(G4int id) const
G4int ReadP2(const G4String &h2Name, const G4String &fileName="", const G4String &dirName="")
G4double GetH3XWidth(G4int id) const
G4double GetP2Zmin(G4int id) const
G4String GetP2Title(G4int id) const
void SetH3Manager(G4VTBaseHnManager< 3 > *h3Manager)
G4int GetH2Id(const G4String &name, G4bool warn=true) const
G4int GetP2Nxbins(G4int id) const
void Message(G4int level, const G4String &action, const G4String &objectType, const G4String &objectName="", G4bool success=true) const
G4double GetP2Xmax(G4int id) const
G4bool SetNtupleFColumn(const G4String &columnName, G4float &value)
G4int GetNofH2s() const
G4bool SetFirstP1Id(G4int firstId)
virtual G4int ReadH3Impl(const G4String &h3Name, const G4String &fileName, const G4String &dirName, G4bool isUserFileName)=0
G4double GetP2Ymax(G4int id) const
G4String GetP2ZAxisTitle(G4int id) const
G4double GetP1Xmax(G4int id) const
G4int GetNofH1s() const
void SetNtupleManager(std::shared_ptr< G4VRNtupleManager > ntupleManager)
G4int GetH3Nxbins(G4int id) const
G4double GetP1XWidth(G4int id) const
G4bool SetNtupleSColumn(const G4String &columnName, G4String &value)
G4double GetH3Zmax(G4int id) const
G4String GetH2XAxisTitle(G4int id) const
G4double GetH3Xmax(G4int id) const
std::shared_ptr< G4VRFileManager > fVFileManager
G4int GetNofP2s() const
G4double GetH3Ymin(G4int id) const
G4bool SetNtupleDColumn(const G4String &columnName, G4double &value)
G4double GetP2Zmax(G4int id) const
G4String GetH1YAxisTitle(G4int id) const
G4String GetH2ZAxisTitle(G4int id) const
G4int GetP1Id(const G4String &name, G4bool warn=true) const
void SetH1Manager(G4VTBaseHnManager< 1 > *h1Manager)
G4String GetH3ZAxisTitle(G4int id) const
G4bool SetFirstHistoId(G4int firstId)
G4double GetP2Ymin(G4int id) const
G4String GetFileName() const
G4String GetFileType() const
G4double GetH3ZWidth(G4int id) const
G4String GetH1XAxisTitle(G4int id) const
G4bool SetFirstH1Id(G4int firstId)
G4double GetH2Ymin(G4int id) const
G4String GetType() const
G4double GetH3Xmin(G4int id) const
G4double GetP1Ymin(G4int id) const
G4AnalysisManagerState fState
G4int GetP2Id(const G4String &name, G4bool warn=true) const
G4double GetH2XWidth(G4int id) const
G4double GetH3Zmin(G4int id) const
virtual G4int ReadP1Impl(const G4String &p1Name, const G4String &fileName, const G4String &dirName, G4bool isUserFileName)=0
G4int ReadH3(const G4String &h3Name, const G4String &fileName="", const G4String &dirName="")
void SetFileName(const G4String &fileName)
virtual G4int ReadH2Impl(const G4String &h2Name, const G4String &fileName, const G4String &dirName, G4bool isUserFileName)=0
G4bool SetFirstNtupleId(G4int firstId)
G4double GetH3YWidth(G4int id) const
G4String GetH1Title(G4int id) const
G4double GetH3Ymax(G4int id) const
G4double GetP1Ymax(G4int id) const
G4double GetP1Xmin(G4int id) const
virtual G4int ReadH1Impl(const G4String &h1Name, const G4String &fileName, const G4String &dirName, G4bool isUserFileName)=0
G4String GetH3YAxisTitle(G4int id) const
G4double GetH1Width(G4int id) const
G4int GetNofNtuples() const
G4int ReadH2(const G4String &h2Name, const G4String &fileName="", const G4String &dirName="")
G4bool SetFirstH2Id(G4int firstId)
void SetP1Manager(G4VTBaseHnManager< 2 > *p1Manager)
G4String GetP1YAxisTitle(G4int id) const
G4double GetH2Xmax(G4int id) const
G4bool CloseFiles(G4bool reset=true)
G4int GetNofP1s() const
G4String GetH2YAxisTitle(G4int id) const
G4int GetH1Id(const G4String &name, G4bool warn=true) const
G4String GetP1Title(G4int id) const
virtual ~G4VAnalysisReader()
G4bool IsAscii() const
G4bool SetFirstProfileId(G4int firstId)
G4String GetP2YAxisTitle(G4int id) const
G4double GetH1Xmin(G4int id) const
virtual G4int ReadP2Impl(const G4String &p2Name, const G4String &fileName, const G4String &dirName, G4bool isUserFileName)=0
G4int GetNtuple(const G4String &ntupleName, const G4String &fileName="", const G4String &dirName="")
G4String GetH3XAxisTitle(G4int id) const
G4bool SetNtupleIColumn(const G4String &columnName, G4int &value)
virtual G4bool CloseFilesImpl(G4bool reset)=0
G4int ReadP1(const G4String &h1Name, const G4String &fileName="", const G4String &dirName="")
G4int GetP2Nybins(G4int id) const
G4int GetH3Nzbins(G4int id) const
G4double GetH1Xmax(G4int id) const
G4int GetNofH3s() const
G4String GetP2XAxisTitle(G4int id) const
G4double GetP2YWidth(G4int id) const
void SetVerboseLevel(G4int verboseLevel)
G4int GetH2Nxbins(G4int id) const
void SetP2Manager(G4VTBaseHnManager< 3 > *p2Manager)
void SetH2Manager(G4VTBaseHnManager< 2 > *h2Manager)
G4bool SetFirstP2Id(G4int firstId)
G4int GetH2Nybins(G4int id) const
G4String GetH2Title(G4int id) const
void SetFileManager(std::shared_ptr< G4VRFileManager > fileManager)
G4String GetP1XAxisTitle(G4int id) const
G4double GetP2Xmin(G4int id) const
G4int ReadH1(const G4String &h1Name, const G4String &fileName="", const G4String &dirName="")
G4int GetH3Id(const G4String &name, G4bool warn=true) const
G4double GetH2YWidth(G4int id) const
G4String GetP1ZAxisTitle(G4int id) const
G4double GetH2Ymax(G4int id) const