Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4VAnalysisReader.cc
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 // $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 {
127  if ( fileName != "" ) {
128  return ReadH1Impl(h1Name, fileName, true);
129  }
130  else {
131  if ( fFileManager->GetFileName() == "" ) {
132  G4ExceptionDescription description;
133  description
134  << "Cannot get H1. File name has to be set first.";
135  G4Exception("G4VAnalysisReader::ReadH1()",
136  "Analysis_WR011", JustWarning, description);
137  return kInvalidId;
138  }
139  return ReadH1Impl(h1Name, fFileManager->GetFileName(), false);
140  }
141 }
142 
143 //_____________________________________________________________________________
145  const G4String& fileName)
146 {
147  if ( fileName != "" ) {
148  return ReadH2Impl(h2Name, fileName, true);
149  }
150  else {
151  if ( fFileManager->GetFileName() == "" ) {
152  G4ExceptionDescription description;
153  description
154  << "Cannot get H2. File name has to be set first.";
155  G4Exception("G4VAnalysisReader::ReadH2()",
156  "Analysis_WR011", JustWarning, description);
157  return kInvalidId;
158  }
159  return ReadH2Impl(h2Name, fFileManager->GetFileName(), false);
160  }
161 }
162 
163 //_____________________________________________________________________________
165  const G4String& fileName)
166 {
167  if ( fileName != "" ) {
168  return ReadH3Impl(h3Name, fileName, true);
169  }
170  else {
171  if ( fFileManager->GetFileName() == "" ) {
172  G4ExceptionDescription description;
173  description
174  << "Cannot get H3. File name has to be set first.";
175  G4Exception("G4VAnalysisReader::ReadH2()",
176  "Analysis_WR011", JustWarning, description);
177  return kInvalidId;
178  }
179  return ReadH3Impl(h3Name, fFileManager->GetFileName(), false);
180  }
181 }
182 
183 //_____________________________________________________________________________
185  const G4String& fileName)
186 {
187  if ( fileName != "" ) {
188  return ReadP1Impl(p1Name, fileName, true);
189  }
190  else {
191  if ( fFileManager->GetFileName() == "" ) {
192  G4ExceptionDescription description;
193  description
194  << "Cannot get P1. File name has to be set first.";
195  G4Exception("G4VAnalysisReader::ReadP1()",
196  "Analysis_WR011", JustWarning, description);
197  return kInvalidId;
198  }
199  return ReadP1Impl(p1Name, fFileManager->GetFileName(), false);
200  }
201 }
202 
203 //_____________________________________________________________________________
205  const G4String& fileName)
206 {
207  if ( fileName != "" ) {
208  return ReadP2Impl(p2Name, fileName, true);
209  }
210  else {
211  if ( fFileManager->GetFileName() == "" ) {
212  G4ExceptionDescription description;
213  description
214  << "Cannot get P2. File name has to be set first.";
215  G4Exception("G4VAnalysisReader::ReadP2()",
216  "Analysis_WR011", JustWarning, description);
217  return kInvalidId;
218  }
219  return ReadP2Impl(p2Name, fFileManager->GetFileName(), false);
220  }
221 }
222 
223 //_____________________________________________________________________________
225 {
226  G4bool finalResult = true;
227 
228  G4bool result = SetFirstH1Id(firstId);
229  finalResult = finalResult && result;
230 
231  result = SetFirstH2Id(firstId);
232  finalResult = finalResult && result;
233 
234  result = SetFirstH3Id(firstId);
235  finalResult = finalResult && result;
236 
237  return finalResult;
238 }
239 
240 //_____________________________________________________________________________
242 {
243  return fVH1Manager->GetHnManager()->SetFirstId(firstId);
244 }
245 
246 //_____________________________________________________________________________
248 {
249  return fVH2Manager->GetHnManager()->SetFirstId(firstId);
250 }
251 
252 //_____________________________________________________________________________
254 {
255  return fVH3Manager->GetHnManager()->SetFirstId(firstId);
256 }
257 
258 //_____________________________________________________________________________
260 {
261  G4bool finalResult = true;
262 
263  G4bool result = SetFirstP1Id(firstId);
264  finalResult = finalResult && result;
265 
266  result = SetFirstP2Id(firstId);
267  finalResult = finalResult && result;
268 
269  return finalResult;
270 }
271 
272 //_____________________________________________________________________________
274 {
275  return fVP1Manager->GetHnManager()->SetFirstId(firstId);
276 }
277 
278 //_____________________________________________________________________________
280 {
281  return fVP2Manager->GetHnManager()->SetFirstId(firstId);
282 }
283 
284 //_____________________________________________________________________________
286 {
287  return fVNtupleManager->SetFirstId(firstId);
288 }
289 
290 //_____________________________________________________________________________
292  const G4String& fileName)
293 {
294  if ( fileName != "" ) {
295  return ReadNtupleImpl(ntupleName, fileName, true);
296  }
297  else {
298  if ( fFileManager->GetFileName() == "" ) {
299  G4ExceptionDescription description;
300  description
301  << "Cannot get Ntuple. File name has to be set first.";
302  G4Exception("G4VAnalysisReader::GetNtuple()",
303  "Analysis_WR011", JustWarning, description);
304  return kInvalidId;
305  }
306  return ReadNtupleImpl(ntupleName, fFileManager->GetFileName(), false);
307  }
308 }
309 
310 //_____________________________________________________________________________
312  G4int& value)
313 {
314  return fVNtupleManager->SetNtupleIColumn(columnName, value);
315 }
316 
317 //_____________________________________________________________________________
319  G4float& value)
320 {
321  return fVNtupleManager->SetNtupleFColumn(columnName, value);
322 }
323 
324 //_____________________________________________________________________________
326  G4double& value)
327 {
328  return fVNtupleManager->SetNtupleDColumn(columnName, value);
329 }
330 
331 //_____________________________________________________________________________
333  G4String& value)
334 {
335  return fVNtupleManager->SetNtupleSColumn(columnName, value);
336 }
337 
338 //_____________________________________________________________________________
340  std::vector<int>& vector)
341 {
342  return fVNtupleManager->SetNtupleIColumn(columnName, vector);
343 }
344 
345 //_____________________________________________________________________________
347  std::vector<float>& vector)
348 {
349  return fVNtupleManager->SetNtupleFColumn(columnName, vector);
350 }
351 
352 //_____________________________________________________________________________
354  std::vector<double>& vector)
355 {
356  return fVNtupleManager->SetNtupleDColumn(columnName, vector);
357 }
358 
359 //_____________________________________________________________________________
361  const G4String& columnName,
362  G4int& value)
363 {
364  return fVNtupleManager->SetNtupleIColumn(ntupleId, columnName, value);
365 }
366 
367 //_____________________________________________________________________________
369  const G4String& columnName,
370  G4float& value)
371 {
372  return fVNtupleManager->SetNtupleFColumn(ntupleId, columnName, value);
373 }
374 
375 //_____________________________________________________________________________
377  const G4String& columnName,
378  G4double& value)
379 {
380  return fVNtupleManager->SetNtupleDColumn(ntupleId, columnName, value);
381 }
382 
383 //_____________________________________________________________________________
385  const G4String& columnName,
386  G4String& value)
387 {
388  return fVNtupleManager->SetNtupleSColumn(ntupleId, columnName, value);
389 }
390 
391 //_____________________________________________________________________________
393  const G4String& columnName,
394  std::vector<int>& vector)
395 {
396  return fVNtupleManager->SetNtupleIColumn(ntupleId, columnName, vector);
397 }
398 
399 //_____________________________________________________________________________
401  const G4String& columnName,
402  std::vector<float>& vector)
403 {
404  return fVNtupleManager->SetNtupleFColumn(ntupleId, columnName, vector);
405 }
406 
407 //_____________________________________________________________________________
409  const G4String& columnName,
410  std::vector<double>& vector)
411 {
412  return fVNtupleManager->SetNtupleDColumn(ntupleId, columnName, vector);
413 }
414 
415 //_____________________________________________________________________________
417 {
418  return fVNtupleManager->GetNtupleRow();
419 }
420 
421 
422 //_____________________________________________________________________________
424 {
425  return fVNtupleManager->GetNtupleRow(ntupleId);
426 }
427 
428 //_____________________________________________________________________________
430 {
431  return fVH1Manager->GetHnManager()->GetNofHns();
432 }
433 
434 //_____________________________________________________________________________
436 {
437  return fVH2Manager->GetHnManager()->GetNofHns();
438 }
439 
440 //_____________________________________________________________________________
442 {
443  return fVH3Manager->GetHnManager()->GetNofHns();
444 }
445 
446 //_____________________________________________________________________________
448 {
449  return fVP1Manager->GetHnManager()->GetNofHns();
450 }
451 
452 //_____________________________________________________________________________
454 {
455  return fVP2Manager->GetHnManager()->GetNofHns();
456 }
457 
458 //_____________________________________________________________________________
460 {
461  return fVNtupleManager->GetNofNtuples();
462 }
463 
464 // GetH1Id(), GetH2Id in .icc
465 
466 // Access methods in .icc
467 
468 //_____________________________________________________________________________
470 {
471  fState.SetVerboseLevel(verboseLevel);
472 }
473 
474 // GetVerboseLevel() in .icc
G4double G4ParticleHPJENDLHEData::G4double result
void SetP1Manager(G4VP1Manager *p1Manager)
G4int GetNofP2s() const
void SetP2Manager(G4VP2Manager *p2Manager)
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
G4int ReadP1(const G4String &h1Name, const G4String &fileName="")
G4bool SetFirstProfileId(G4int firstId)
virtual ~G4VAnalysisReader()
float G4float
Definition: G4Types.hh:77
virtual G4int ReadH3Impl(const G4String &h3Name, const G4String &fileName, G4bool isUserFileName)=0
G4bool SetNtupleDColumn(const G4String &columnName, G4double &value)
G4VAnalysisReader(const G4String &type, G4bool isMaster)
G4int ReadH2(const G4String &h2Name, const G4String &fileName="")
virtual G4int ReadH1Impl(const G4String &h1Name, const G4String &fileName, G4bool isUserFileName)=0
G4String GetFileName() const
virtual G4int ReadP2Impl(const G4String &p2Name, const G4String &fileName, G4bool isUserFileName)=0
G4AnalysisManagerState fState
virtual G4int ReadNtupleImpl(const G4String &ntupleName, const G4String &fileName, G4bool isUserFileName)=0
int G4int
Definition: G4Types.hh:78
virtual G4int ReadP1Impl(const G4String &p1Name, const G4String &fileName, G4bool isUserFileName)=0
G4bool SetNtupleSColumn(const G4String &columnName, G4String &value)
void SetH3Manager(G4VH3Manager *h3Manager)
G4bool SetNtupleIColumn(const G4String &columnName, G4int &value)
G4bool SetNtupleFColumn(const G4String &columnName, G4float &value)
void SetFileName(const G4String &fileName)
const XML_Char int const XML_Char * value
Definition: expat.h:331
G4int ReadH3(const G4String &h3Name, const G4String &fileName="")
virtual G4int ReadH2Impl(const G4String &h2Name, const G4String &fileName, G4bool isUserFileName)=0
bool G4bool
Definition: G4Types.hh:79
G4int ReadP2(const G4String &h2Name, const G4String &fileName="")
void SetNtupleManager(G4VRNtupleManager *ntupleManager)
G4int ReadH1(const G4String &h1Name, const G4String &fileName="")
G4bool SetFirstHistoId(G4int firstId)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
G4bool SetFirstNtupleId(G4int firstId)
G4int GetNofP1s() const
void SetH1Manager(G4VH1Manager *h1Manager)
G4int GetNofH2s() const
G4int GetNofH1s() const
G4bool SetFirstH1Id(G4int firstId)
G4bool SetFirstH2Id(G4int firstId)
G4bool SetFirstP2Id(G4int firstId)
void SetVerboseLevel(G4int verboseLevel)
G4bool SetFirstH3Id(G4int firstId)
G4int GetNtuple(const G4String &ntupleName, const G4String &fileName="")
double G4double
Definition: G4Types.hh:76
G4bool SetFirstP1Id(G4int firstId)
void SetH2Manager(G4VH2Manager *h2Manager)
G4int GetNofH3s() const
const G4int kInvalidId
void SetFileManager(G4BaseFileManager *fileManager)
G4int GetNofNtuples() const