Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4VAnalysisReader.cc
이 파일의 문서화 페이지로 가기
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.cc 70604 2013-06-03 11:27:06Z ihrivnac $
27 
28 // Author: Ivana Hrivnacova, 09/07/2013 (ivana@ipno.in2p3.fr)
29 
30 #include "G4VAnalysisReader.hh"
31 #include "G4AnalysisUtilities.hh"
32 #include "G4BaseFileManager.hh"
33 #include "G4HnManager.hh"
34 #include "G4VH1Manager.hh"
35 #include "G4VH2Manager.hh"
36 #include "G4VH3Manager.hh"
37 #include "G4VP1Manager.hh"
38 #include "G4VP2Manager.hh"
39 #include "G4VRNtupleManager.hh"
40 
41 #include <iostream>
42 
43 using namespace G4Analysis;
44 
45 //_____________________________________________________________________________
47  : fState(type, isMaster),
48  fVH1Manager(nullptr),
49  fVH2Manager(nullptr),
50  fVH3Manager(nullptr),
51  fVP1Manager(nullptr),
52  fVP2Manager(nullptr),
53  fVNtupleManager(nullptr),
54  fFileManager(nullptr)
55 {}
56 
57 //_____________________________________________________________________________
59 {}
60 
61 //
62 // protected methods
63 //
64 
65 //_____________________________________________________________________________
67 {
68  fVH1Manager.reset(h1Manager);
69 }
70 
71 //_____________________________________________________________________________
73 {
74  fVH2Manager.reset(h2Manager);
75 }
76 
77 //_____________________________________________________________________________
79 {
80  fVH3Manager.reset(h3Manager);
81 }
82 
83 //_____________________________________________________________________________
85 {
86  fVP1Manager.reset(p1Manager);
87 }
88 
89 //_____________________________________________________________________________
91 {
92  fVP2Manager.reset(p2Manager);
93 }
94 
95 //_____________________________________________________________________________
97 {
98  fVNtupleManager.reset(ntupleManager);
99 }
100 
101 //_____________________________________________________________________________
103 {
104  fFileManager.reset(fileManager);
105 }
106 
107 //
108 // public methods
109 //
110 
111 //_____________________________________________________________________________
113 {
114  fFileManager->SetFileName(fileName);
115 }
116 
117 //_____________________________________________________________________________
119 {
120  return fFileManager->GetFileName();
121 }
122 
123 //_____________________________________________________________________________
125  const G4String& fileName,
126  const G4String& dirName)
127 {
128  if ( fileName != "" ) {
129  return ReadH1Impl(h1Name, fileName, dirName, true);
130  }
131  else {
132  if ( fFileManager->GetFileName() == "" ) {
133  G4ExceptionDescription description;
134  description
135  << "Cannot get H1. File name has to be set first.";
136  G4Exception("G4VAnalysisReader::ReadH1()",
137  "Analysis_WR011", JustWarning, description);
138  return kInvalidId;
139  }
140  return ReadH1Impl(h1Name, fFileManager->GetFileName(), dirName, false);
141  }
142 }
143 
144 //_____________________________________________________________________________
146  const G4String& fileName,
147  const G4String& dirName)
148 {
149  if ( fileName != "" ) {
150  return ReadH2Impl(h2Name, fileName, dirName, true);
151  }
152  else {
153  if ( fFileManager->GetFileName() == "" ) {
154  G4ExceptionDescription description;
155  description
156  << "Cannot get H2. File name has to be set first.";
157  G4Exception("G4VAnalysisReader::ReadH2()",
158  "Analysis_WR011", JustWarning, description);
159  return kInvalidId;
160  }
161  return ReadH2Impl(h2Name, fFileManager->GetFileName(), dirName, false);
162  }
163 }
164 
165 //_____________________________________________________________________________
167  const G4String& fileName,
168  const G4String& dirName)
169 {
170  if ( fileName != "" ) {
171  return ReadH3Impl(h3Name, fileName, dirName, true);
172  }
173  else {
174  if ( fFileManager->GetFileName() == "" ) {
175  G4ExceptionDescription description;
176  description
177  << "Cannot get H3. File name has to be set first.";
178  G4Exception("G4VAnalysisReader::ReadH2()",
179  "Analysis_WR011", JustWarning, description);
180  return kInvalidId;
181  }
182  return ReadH3Impl(h3Name, fFileManager->GetFileName(), dirName, false);
183  }
184 }
185 
186 //_____________________________________________________________________________
188  const G4String& fileName,
189  const G4String& dirName)
190 {
191  if ( fileName != "" ) {
192  return ReadP1Impl(p1Name, fileName, dirName, true);
193  }
194  else {
195  if ( fFileManager->GetFileName() == "" ) {
196  G4ExceptionDescription description;
197  description
198  << "Cannot get P1. File name has to be set first.";
199  G4Exception("G4VAnalysisReader::ReadP1()",
200  "Analysis_WR011", JustWarning, description);
201  return kInvalidId;
202  }
203  return ReadP1Impl(p1Name, fFileManager->GetFileName(), dirName, false);
204  }
205 }
206 
207 //_____________________________________________________________________________
209  const G4String& fileName,
210  const G4String& dirName)
211 {
212  if ( fileName != "" ) {
213  return ReadP2Impl(p2Name, fileName, dirName, true);
214  }
215  else {
216  if ( fFileManager->GetFileName() == "" ) {
217  G4ExceptionDescription description;
218  description
219  << "Cannot get P2. File name has to be set first.";
220  G4Exception("G4VAnalysisReader::ReadP2()",
221  "Analysis_WR011", JustWarning, description);
222  return kInvalidId;
223  }
224  return ReadP2Impl(p2Name, fFileManager->GetFileName(), dirName, false);
225  }
226 }
227 
228 //_____________________________________________________________________________
230 {
231  G4bool finalResult = true;
232 
233  G4bool result = SetFirstH1Id(firstId);
234  finalResult = finalResult && result;
235 
236  result = SetFirstH2Id(firstId);
237  finalResult = finalResult && result;
238 
239  result = SetFirstH3Id(firstId);
240  finalResult = finalResult && result;
241 
242  return finalResult;
243 }
244 
245 //_____________________________________________________________________________
247 {
248  return fVH1Manager->GetHnManager()->SetFirstId(firstId);
249 }
250 
251 //_____________________________________________________________________________
253 {
254  return fVH2Manager->GetHnManager()->SetFirstId(firstId);
255 }
256 
257 //_____________________________________________________________________________
259 {
260  return fVH3Manager->GetHnManager()->SetFirstId(firstId);
261 }
262 
263 //_____________________________________________________________________________
265 {
266  G4bool finalResult = true;
267 
268  G4bool result = SetFirstP1Id(firstId);
269  finalResult = finalResult && result;
270 
271  result = SetFirstP2Id(firstId);
272  finalResult = finalResult && result;
273 
274  return finalResult;
275 }
276 
277 //_____________________________________________________________________________
279 {
280  return fVP1Manager->GetHnManager()->SetFirstId(firstId);
281 }
282 
283 //_____________________________________________________________________________
285 {
286  return fVP2Manager->GetHnManager()->SetFirstId(firstId);
287 }
288 
289 //_____________________________________________________________________________
291 {
292  return fVNtupleManager->SetFirstId(firstId);
293 }
294 
295 //_____________________________________________________________________________
297  const G4String& fileName,
298  const G4String& dirName)
299 {
300  if ( fileName != "" ) {
301  return ReadNtupleImpl(ntupleName, fileName, dirName, true);
302  }
303  else {
304  // Check if fileName was set
305  if ( fFileManager->GetFileName() == "" ) {
306  G4ExceptionDescription description;
307  description
308  << "Cannot get Ntuple. File name has to be set first.";
309  G4Exception("G4VAnalysisReader::GetNtuple()",
310  "Analysis_WR011", JustWarning, description);
311  return kInvalidId;
312  }
313  return ReadNtupleImpl(ntupleName, fFileManager->GetFileName(), dirName, false);
314  }
315 }
316 
317 //_____________________________________________________________________________
319  G4int& value)
320 {
321  return fVNtupleManager->SetNtupleIColumn(columnName, value);
322 }
323 
324 //_____________________________________________________________________________
326  G4float& value)
327 {
328  return fVNtupleManager->SetNtupleFColumn(columnName, value);
329 }
330 
331 //_____________________________________________________________________________
333  G4double& value)
334 {
335  return fVNtupleManager->SetNtupleDColumn(columnName, value);
336 }
337 
338 //_____________________________________________________________________________
340  G4String& value)
341 {
342  return fVNtupleManager->SetNtupleSColumn(columnName, value);
343 }
344 
345 //_____________________________________________________________________________
347  std::vector<int>& vector)
348 {
349  return fVNtupleManager->SetNtupleIColumn(columnName, vector);
350 }
351 
352 //_____________________________________________________________________________
354  std::vector<float>& vector)
355 {
356  return fVNtupleManager->SetNtupleFColumn(columnName, vector);
357 }
358 
359 //_____________________________________________________________________________
361  std::vector<double>& vector)
362 {
363  return fVNtupleManager->SetNtupleDColumn(columnName, vector);
364 }
365 
366 //_____________________________________________________________________________
368  const G4String& columnName,
369  G4int& value)
370 {
371  return fVNtupleManager->SetNtupleIColumn(ntupleId, columnName, value);
372 }
373 
374 //_____________________________________________________________________________
376  const G4String& columnName,
377  G4float& value)
378 {
379  return fVNtupleManager->SetNtupleFColumn(ntupleId, columnName, value);
380 }
381 
382 //_____________________________________________________________________________
384  const G4String& columnName,
385  G4double& value)
386 {
387  return fVNtupleManager->SetNtupleDColumn(ntupleId, columnName, value);
388 }
389 
390 //_____________________________________________________________________________
392  const G4String& columnName,
393  G4String& value)
394 {
395  return fVNtupleManager->SetNtupleSColumn(ntupleId, columnName, value);
396 }
397 
398 //_____________________________________________________________________________
400  const G4String& columnName,
401  std::vector<int>& vector)
402 {
403  return fVNtupleManager->SetNtupleIColumn(ntupleId, columnName, vector);
404 }
405 
406 //_____________________________________________________________________________
408  const G4String& columnName,
409  std::vector<float>& vector)
410 {
411  return fVNtupleManager->SetNtupleFColumn(ntupleId, columnName, vector);
412 }
413 
414 //_____________________________________________________________________________
416  const G4String& columnName,
417  std::vector<double>& vector)
418 {
419  return fVNtupleManager->SetNtupleDColumn(ntupleId, columnName, vector);
420 }
421 
422 //_____________________________________________________________________________
424 {
425  return fVNtupleManager->GetNtupleRow();
426 }
427 
428 
429 //_____________________________________________________________________________
431 {
432  return fVNtupleManager->GetNtupleRow(ntupleId);
433 }
434 
435 //_____________________________________________________________________________
437 {
438  return fVH1Manager->GetHnManager()->GetNofHns();
439 }
440 
441 //_____________________________________________________________________________
443 {
444  return fVH2Manager->GetHnManager()->GetNofHns();
445 }
446 
447 //_____________________________________________________________________________
449 {
450  return fVH3Manager->GetHnManager()->GetNofHns();
451 }
452 
453 //_____________________________________________________________________________
455 {
456  return fVP1Manager->GetHnManager()->GetNofHns();
457 }
458 
459 //_____________________________________________________________________________
461 {
462  return fVP2Manager->GetHnManager()->GetNofHns();
463 }
464 
465 //_____________________________________________________________________________
467 {
468  return fVNtupleManager->GetNofNtuples();
469 }
470 
471 // GetH1Id(), GetH2Id in .icc
472 
473 // Access methods in .icc
474 
475 //_____________________________________________________________________________
477 {
478  fState.SetVerboseLevel(verboseLevel);
479 }
480 
481 // GetVerboseLevel() in .icc
std::unique_ptr< G4BaseFileManager > fFileManager
G4bool SetFirstNtupleId(G4int firstId)
G4VAnalysisReader(const G4String &type, G4bool isMaster)
std::ostringstream G4ExceptionDescription
Definition: G4Exception.hh:45
G4AnalysisManagerState fState
G4bool SetFirstP1Id(G4int firstId)
G4int ReadH3(const G4String &h3Name, const G4String &fileName="", const G4String &dirName="")
G4String GetFileName() const
void SetVerboseLevel(G4int verboseLevel)
G4bool SetNtupleSColumn(const G4String &columnName, G4String &value)
std::unique_ptr< G4VP1Manager > fVP1Manager
virtual G4int ReadP1Impl(const G4String &p1Name, const G4String &fileName, const G4String &dirName, G4bool isUserFileName)=0
float G4float
Definition: G4Types.hh:77
G4int ReadP2(const G4String &h2Name, const G4String &fileName="", const G4String &dirName="")
G4bool SetFirstProfileId(G4int firstId)
G4int ReadH1(const G4String &h1Name, const G4String &fileName="", const G4String &dirName="")
G4int GetNofP2s() const
G4bool SetNtupleFColumn(const G4String &columnName, G4float &value)
G4int GetNofH3s() const
void SetNtupleManager(G4VRNtupleManager *ntupleManager)
virtual G4int ReadP2Impl(const G4String &p2Name, const G4String &fileName, const G4String &dirName, G4bool isUserFileName)=0
void SetFileManager(G4BaseFileManager *fileManager)
std::unique_ptr< G4VH2Manager > fVH2Manager
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
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
G4int GetNofH1s() const
G4bool SetFirstH2Id(G4int firstId)
void SetVerboseLevel(G4int verboseLevel)
const G4int kInvalidId
void SetP1Manager(G4VP1Manager *p1Manager)
G4bool SetNtupleIColumn(const G4String &columnName, G4int &value)
void SetP2Manager(G4VP2Manager *p2Manager)
std::unique_ptr< G4VRNtupleManager > fVNtupleManager
G4int GetNofH2s() const
G4double G4ParticleHPJENDLHEData::G4double result
G4bool SetFirstP2Id(G4int firstId)
G4bool SetFirstH3Id(G4int firstId)
G4bool SetNtupleDColumn(const G4String &columnName, G4double &value)
std::unique_ptr< G4VP2Manager > fVP2Manager
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.hh:65
void SetH3Manager(G4VH3Manager *h3Manager)
void SetH2Manager(G4VH2Manager *h2Manager)
int G4int
Definition: G4Types.hh:78
G4int GetNofNtuples() const
G4int GetNtuple(const G4String &ntupleName, const G4String &fileName="", const G4String &dirName="")
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 GetNofP1s() const
virtual G4int ReadH2Impl(const G4String &h2Name, const G4String &fileName, const G4String &dirName, G4bool isUserFileName)=0
G4bool SetFirstHistoId(G4int firstId)
G4int ReadH2(const G4String &h2Name, const G4String &fileName="", const G4String &dirName="")
G4bool SetFirstH1Id(G4int firstId)
void SetH1Manager(G4VH1Manager *h1Manager)