Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4VAnalysisReader.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 // $Id: G4VAnalysisReader.hh 71635 2013-06-19 13:48:28Z ihrivnac $
27 
28 // The nonvirtual public interface reader class for g4tools based analysis.
29 // It is defined as a composite of object manager base classes.
30 // Individual use of the component managers is disabled
31 // (except for file manager and Hn manager which are also used from
32 // other object managers).
33 // The functions which has to be implemented in concrete managers
34 // are declared as virtual protected.
35 
36 // Author: Ivana Hrivnacova, 09/04/2014 (ivana@ipno.in2p3.fr)
37 
38 #ifndef G4VAnalysisReader_h
39 #define G4VAnalysisReader_h 1
40 
42 #include "globals.hh"
43 
44 #include <vector>
45 #include <memory>
46 
47 class G4HnManager;
48 class G4BaseFileManager;
49 class G4VH1Manager;
50 class G4VH2Manager;
51 class G4VH3Manager;
52 class G4VP1Manager;
53 class G4VP2Manager;
54 class G4VRNtupleManager;
55 
57 {
58  public:
59  G4VAnalysisReader(const G4String& type, G4bool isMaster);
60  virtual ~G4VAnalysisReader();
61 
62  // Methods for handling files
63  // G4bool OpenFile(const G4String& fileName = "");
64 
65  // Methods for handling files and directories names
66  void SetFileName(const G4String& fileName);
67  G4String GetFileName() const;
68 
69  // Methods to read histograms from a file
70  G4int ReadH1(const G4String& h1Name, const G4String& fileName = "", const G4String& dirName = "");
71  G4int ReadH2(const G4String& h2Name, const G4String& fileName = "", const G4String& dirName = "");
72  G4int ReadH3(const G4String& h3Name, const G4String& fileName = "", const G4String& dirName = "");
73  G4int ReadP1(const G4String& h1Name, const G4String& fileName = "", const G4String& dirName = "");
74  G4int ReadP2(const G4String& h2Name, const G4String& fileName = "", const G4String& dirName = "");
75 
76  // The ids of histograms and ntuples are generated automatically
77  // starting from 0; with following functions it is possible to
78  // change the first Id to start from other value
79  G4bool SetFirstHistoId(G4int firstId);
80  G4bool SetFirstH1Id(G4int firstId);
81  G4bool SetFirstH2Id(G4int firstId);
82  G4bool SetFirstH3Id(G4int firstId);
84  G4bool SetFirstP1Id(G4int firstId);
85  G4bool SetFirstP2Id(G4int firstId);
86  G4bool SetFirstNtupleId(G4int firstId);
87 
88  // Methods to read ntuple from a file
89  G4int GetNtuple(const G4String& ntupleName, const G4String& fileName = "", const G4String& dirName = "");
90 
91  // Methods for ntuple with id = FirstNtupleId
92  G4bool SetNtupleIColumn(const G4String& columnName, G4int& value);
93  G4bool SetNtupleFColumn(const G4String& columnName, G4float& value);
94  G4bool SetNtupleDColumn(const G4String& columnName, G4double& value);
95  G4bool SetNtupleSColumn(const G4String& columnName, G4String& value);
96  // Bind the ntuple colums of vector type
97  G4bool SetNtupleIColumn(const G4String& columnName,
98  std::vector<int>& vector);
99  G4bool SetNtupleFColumn(const G4String& columnName,
100  std::vector<float>& vector);
101  G4bool SetNtupleDColumn(const G4String& columnName,
102  std::vector<double>& vector);
103  // Methods for ntuple with id > FirstNtupleId
104  G4bool SetNtupleIColumn(G4int ntupleId, const G4String& columnName,
105  G4int& value);
106  G4bool SetNtupleFColumn(G4int ntupleId, const G4String& columnName,
107  G4float& value);
108  G4bool SetNtupleDColumn(G4int ntupleId, const G4String& columnName,
109  G4double& value);
110  G4bool SetNtupleSColumn(G4int ntupleId, const G4String& columnName,
111  G4String& value);
112  // Bind the ntuple colums of vector type
113  G4bool SetNtupleIColumn(G4int ntupleId, const G4String& columnName,
114  std::vector<int>& vector);
115  G4bool SetNtupleFColumn(G4int ntupleId, const G4String& columnName,
116  std::vector<float>& vector);
117  G4bool SetNtupleDColumn(G4int ntupleId, const G4String& columnName,
118  std::vector<double>& vector);
119 
121  G4bool GetNtupleRow(G4int ntupleId);
122 
123  // ASCII option
124 
125  // Return false if there is no object selected for ASCII output,
126  // return true otherwise
127  G4bool IsAscii() const;
128 
129  // Access methods
130  G4int GetNofH1s() const;
131  G4int GetNofH2s() const;
132  G4int GetNofH3s() const;
133  G4int GetNofP1s() const;
134  G4int GetNofP2s() const;
135  G4int GetNofNtuples() const;
136 
137  // Access methods via names
138  G4int GetH1Id(const G4String& name, G4bool warn = true) const;
139  G4int GetH2Id(const G4String& name, G4bool warn = true) const;
140  G4int GetH3Id(const G4String& name, G4bool warn = true) const;
141  G4int GetP1Id(const G4String& name, G4bool warn = true) const;
142  G4int GetP2Id(const G4String& name, G4bool warn = true) const;
143 
144  // Access to histogram & profiles parameters
145  //
146  G4int GetH1Nbins(G4int id) const;
147  G4double GetH1Xmin(G4int id) const;
148  G4double GetH1Xmax(G4int id) const;
149  G4double GetH1Width(G4int id) const;
150  //
151  G4int GetH2Nxbins(G4int id) const;
152  G4double GetH2Xmin(G4int id) const;
153  G4double GetH2Xmax(G4int id) const;
154  G4double GetH2XWidth(G4int id) const;
155  G4int GetH2Nybins(G4int id) const;
156  G4double GetH2Ymin(G4int id) const;
157  G4double GetH2Ymax(G4int id) const;
158  G4double GetH2YWidth(G4int id) const;
159  //
160  G4int GetH3Nxbins(G4int id) const;
161  G4double GetH3Xmin(G4int id) const;
162  G4double GetH3Xmax(G4int id) const;
163  G4double GetH3XWidth(G4int id) const;
164  G4int GetH3Nybins(G4int id) const;
165  G4double GetH3Ymin(G4int id) const;
166  G4double GetH3Ymax(G4int id) const;
167  G4double GetH3YWidth(G4int id) const;
168  G4int GetH3Nzbins(G4int id) const;
169  G4double GetH3Zmin(G4int id) const;
170  G4double GetH3Zmax(G4int id) const;
171  G4double GetH3ZWidth(G4int id) const;
172  //
173  G4int GetP1Nbins(G4int id) const;
174  G4double GetP1Xmin(G4int id) const;
175  G4double GetP1Xmax(G4int id) const;
176  G4double GetP1XWidth(G4int id) const;
177  G4double GetP1Ymin(G4int id) const;
178  G4double GetP1Ymax(G4int id) const;
179  //
180  G4int GetP2Nxbins(G4int id) const;
181  G4double GetP2Xmin(G4int id) const;
182  G4double GetP2Xmax(G4int id) const;
183  G4double GetP2XWidth(G4int id) const;
184  G4int GetP2Nybins(G4int id) const;
185  G4double GetP2Ymin(G4int id) const;
186  G4double GetP2Ymax(G4int id) const;
187  G4double GetP2YWidth(G4int id) const;
188  G4double GetP2Zmin(G4int id) const;
189  G4double GetP2Zmax(G4int id) const;
190 
191  // Access histogram & profiles attributes for plotting
192  //
193  G4String GetH1Title(G4int id) const;
194  G4String GetH1XAxisTitle(G4int id) const;
195  G4String GetH1YAxisTitle(G4int id) const;
196  //
197  G4String GetH2Title(G4int id) const;
198  G4String GetH2XAxisTitle(G4int id) const;
199  G4String GetH2YAxisTitle(G4int id) const;
200  G4String GetH2ZAxisTitle(G4int id) const;
201  //
202  G4String GetH3Title(G4int id) const;
203  G4String GetH3XAxisTitle(G4int id) const;
204  G4String GetH3YAxisTitle(G4int id) const;
205  G4String GetH3ZAxisTitle(G4int id) const;
206  //
207  G4String GetP1Title(G4int id) const;
208  G4String GetP1XAxisTitle(G4int id) const;
209  G4String GetP1YAxisTitle(G4int id) const;
210  G4String GetP1ZAxisTitle(G4int id) const;
211  //
212  G4String GetP2Title(G4int id) const;
213  G4String GetP2XAxisTitle(G4int id) const;
214  G4String GetP2YAxisTitle(G4int id) const;
215  G4String GetP2ZAxisTitle(G4int id) const;
216 
217  // Verbosity
218  void SetVerboseLevel(G4int verboseLevel);
219  G4int GetVerboseLevel() const;
220 
221  // The manager type (starts with an uppercase letter)
222  G4String GetType() const;
223  // The manager file type (starts with a lowercase letter)
224  G4String GetFileType() const;
225 
226  protected:
227  // virtual methods
228  virtual G4int ReadH1Impl(const G4String& h1Name, const G4String& fileName,
229  const G4String& dirName, G4bool isUserFileName) = 0;
230  virtual G4int ReadH2Impl(const G4String& h2Name, const G4String& fileName,
231  const G4String& dirName, G4bool isUserFileName) = 0;
232  virtual G4int ReadH3Impl(const G4String& h3Name, const G4String& fileName,
233  const G4String& dirName, G4bool isUserFileName) = 0;
234  virtual G4int ReadP1Impl(const G4String& p1Name, const G4String& fileName,
235  const G4String& dirName, G4bool isUserFileName) = 0;
236  virtual G4int ReadP2Impl(const G4String& p2Name, const G4String& fileName,
237  const G4String& dirName, G4bool isUserFileName) = 0;
238  virtual G4int ReadNtupleImpl(const G4String& ntupleName, const G4String& fileName,
239  const G4String& dirName, G4bool isUserFileName) = 0;
240 
241  // methods
242  void SetH1Manager(G4VH1Manager* h1Manager);
243  void SetH2Manager(G4VH2Manager* h2Manager);
244  void SetH3Manager(G4VH3Manager* h3Manager);
245  void SetP1Manager(G4VP1Manager* p1Manager);
246  void SetP2Manager(G4VP2Manager* p2Manager);
247  void SetNtupleManager(G4VRNtupleManager* ntupleManager);
248  void SetFileManager(G4BaseFileManager* fileManager);
249 
250  // data members
252 
253  private:
254  // data members
255  std::unique_ptr<G4VH1Manager> fVH1Manager;
256  std::unique_ptr<G4VH2Manager> fVH2Manager;
257  std::unique_ptr<G4VH3Manager> fVH3Manager;
258  std::unique_ptr<G4VP1Manager> fVP1Manager;
259  std::unique_ptr<G4VP2Manager> fVP2Manager;
260  std::unique_ptr<G4VRNtupleManager> fVNtupleManager;
261  std::unique_ptr<G4BaseFileManager> fFileManager;
262 };
263 
264 // inline functions
265 
266 #include "G4VAnalysisReader.icc"
267 
268 #endif
269 
G4int GetP1Nbins(G4int id) const
G4bool IsAscii() const
const XML_Char * name
Definition: expat.h:151
std::unique_ptr< G4BaseFileManager > fFileManager
G4double GetH3Zmin(G4int id) const
G4double GetP1Ymax(G4int id) const
G4int GetP2Id(const G4String &name, G4bool warn=true) const
G4bool SetFirstNtupleId(G4int firstId)
G4int GetH3Nzbins(G4int id) const
G4VAnalysisReader(const G4String &type, G4bool isMaster)
G4int GetP1Id(const G4String &name, G4bool warn=true) const
G4int GetH3Nybins(G4int id) const
G4int GetH2Id(const G4String &name, G4bool warn=true) const
G4AnalysisManagerState fState
G4String GetH3ZAxisTitle(G4int id) const
G4double GetH2YWidth(G4int id) const
G4String GetP1ZAxisTitle(G4int id) const
G4bool SetFirstP1Id(G4int firstId)
G4int ReadH3(const G4String &h3Name, const G4String &fileName="", const G4String &dirName="")
G4String GetFileName() const
G4String GetFileType() const
G4double GetP1XWidth(G4int id) const
G4bool SetNtupleSColumn(const G4String &columnName, G4String &value)
G4int GetH3Id(const G4String &name, G4bool warn=true) const
G4double GetP1Ymin(G4int id) const
G4double GetH3Xmin(G4int id) const
std::unique_ptr< G4VP1Manager > fVP1Manager
virtual G4int ReadP1Impl(const G4String &p1Name, const G4String &fileName, const G4String &dirName, G4bool isUserFileName)=0
G4String GetP1XAxisTitle(G4int id) const
float G4float
Definition: G4Types.hh:77
G4int GetP2Nxbins(G4int id) const
G4int ReadP2(const G4String &h2Name, const G4String &fileName="", const G4String &dirName="")
G4bool SetFirstProfileId(G4int firstId)
G4int GetH1Id(const G4String &name, G4bool warn=true) const
G4String GetH2YAxisTitle(G4int id) const
G4int ReadH1(const G4String &h1Name, const G4String &fileName="", const G4String &dirName="")
G4int GetNofP2s() const
G4double GetH3Ymax(G4int id) const
G4String GetType() const
G4bool SetNtupleFColumn(const G4String &columnName, G4float &value)
G4int GetNofH3s() const
G4double GetP2XWidth(G4int id) const
G4String GetP2XAxisTitle(G4int id) const
G4double GetP2Zmax(G4int id) const
void SetNtupleManager(G4VRNtupleManager *ntupleManager)
G4double GetH2Ymax(G4int id) const
G4String GetH1Title(G4int id) const
virtual G4int ReadP2Impl(const G4String &p2Name, const G4String &fileName, const G4String &dirName, G4bool isUserFileName)=0
G4double GetH3Zmax(G4int id) const
G4String GetH2XAxisTitle(G4int id) const
void SetFileManager(G4BaseFileManager *fileManager)
std::unique_ptr< G4VH2Manager > fVH2Manager
G4String GetH3YAxisTitle(G4int id) const
virtual G4int ReadNtupleImpl(const G4String &ntupleName, const G4String &fileName, const G4String &dirName, G4bool isUserFileName)=0
double G4double
Definition: G4Types.hh:76
bool G4bool
Definition: G4Types.hh:79
G4double GetH2Xmin(G4int id) const
G4String GetP2Title(G4int id) const
G4double GetH1Xmax(G4int id) const
virtual G4int ReadH3Impl(const G4String &h3Name, const G4String &fileName, const G4String &dirName, G4bool isUserFileName)=0
void SetFileName(const G4String &fileName)
const XML_Char int const XML_Char * value
Definition: expat.h:331
std::unique_ptr< G4VH3Manager > fVH3Manager
G4double GetH3ZWidth(G4int id) const
G4int GetNofH1s() const
G4bool SetFirstH2Id(G4int firstId)
G4double GetP2YWidth(G4int id) const
void SetVerboseLevel(G4int verboseLevel)
G4String GetP1YAxisTitle(G4int id) const
G4int GetH3Nxbins(G4int id) const
G4double GetP2Xmin(G4int id) const
G4double GetH2Ymin(G4int id) const
G4String GetP2ZAxisTitle(G4int id) const
void SetP1Manager(G4VP1Manager *p1Manager)
G4bool SetNtupleIColumn(const G4String &columnName, G4int &value)
void SetP2Manager(G4VP2Manager *p2Manager)
std::unique_ptr< G4VRNtupleManager > fVNtupleManager
G4String GetH3Title(G4int id) const
G4double GetH3Ymin(G4int id) const
G4String GetH3XAxisTitle(G4int id) const
G4int GetNofH2s() const
G4bool SetFirstP2Id(G4int firstId)
G4double GetP2Zmin(G4int id) const
G4bool SetFirstH3Id(G4int firstId)
std::unique_ptr< G4VP2Manager > fVP2Manager
G4bool SetNtupleDColumn(const G4String &columnName, G4double &value)
G4String GetP1Title(G4int id) const
G4String GetH1XAxisTitle(G4int id) const
G4double GetH1Width(G4int id) const
void SetH3Manager(G4VH3Manager *h3Manager)
G4String GetH2ZAxisTitle(G4int id) const
void SetH2Manager(G4VH2Manager *h2Manager)
int G4int
Definition: G4Types.hh:78
G4int GetH2Nxbins(G4int id) const
G4String GetP2YAxisTitle(G4int id) const
G4int GetNofNtuples() const
G4double GetP1Xmax(G4int id) const
G4int GetH1Nbins(G4int id) const
G4int GetNtuple(const G4String &ntupleName, const G4String &fileName="", const G4String &dirName="")
G4double GetP2Ymin(G4int id) const
G4String GetH2Title(G4int id) const
G4double GetH3XWidth(G4int id) const
virtual G4int ReadH1Impl(const G4String &h1Name, const G4String &fileName, const G4String &dirName, G4bool isUserFileName)=0
virtual ~G4VAnalysisReader()
std::unique_ptr< G4VH1Manager > fVH1Manager
G4int ReadP1(const G4String &h1Name, const G4String &fileName="", const G4String &dirName="")
G4int GetP2Nybins(G4int id) const
G4int GetNofP1s() const
G4double GetH3YWidth(G4int id) const
G4int GetH2Nybins(G4int id) const
virtual G4int ReadH2Impl(const G4String &h2Name, const G4String &fileName, const G4String &dirName, G4bool isUserFileName)=0
G4String GetH1YAxisTitle(G4int id) const
G4double GetP2Ymax(G4int id) const
G4bool SetFirstHistoId(G4int firstId)
G4int ReadH2(const G4String &h2Name, const G4String &fileName="", const G4String &dirName="")
G4bool SetFirstH1Id(G4int firstId)
G4double GetH1Xmin(G4int id) const
void SetH1Manager(G4VH1Manager *h1Manager)
G4int GetVerboseLevel() const
G4double GetP2Xmax(G4int id) const
G4double GetP1Xmin(G4int id) const
G4double GetH2XWidth(G4int id) const
G4double GetH2Xmax(G4int id) const
G4double GetH3Xmax(G4int id) const