Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
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
27// Author: Ivana Hrivnacova, 09/07/2013 ([email protected])
28
29#include "G4VAnalysisReader.hh"
31#include "G4BaseFileManager.hh"
32#include "G4HnManager.hh"
33#include "G4VH1Manager.hh"
34#include "G4VH2Manager.hh"
35#include "G4VH3Manager.hh"
36#include "G4VP1Manager.hh"
37#include "G4VP2Manager.hh"
38#include "G4VRNtupleManager.hh"
39
40#include <iostream>
41
42using namespace G4Analysis;
43
44//_____________________________________________________________________________
46 : fState(type, isMaster),
47 fVH1Manager(nullptr),
48 fVH2Manager(nullptr),
49 fVH3Manager(nullptr),
50 fVP1Manager(nullptr),
51 fVP2Manager(nullptr),
52 fVNtupleManager(nullptr),
53 fFileManager(nullptr)
54{}
55
56//_____________________________________________________________________________
58{}
59
60//
61// protected methods
62//
63
64//_____________________________________________________________________________
66{
67 fVH1Manager.reset(h1Manager);
68}
69
70//_____________________________________________________________________________
72{
73 fVH2Manager.reset(h2Manager);
74}
75
76//_____________________________________________________________________________
78{
79 fVH3Manager.reset(h3Manager);
80}
81
82//_____________________________________________________________________________
84{
85 fVP1Manager.reset(p1Manager);
86}
87
88//_____________________________________________________________________________
90{
91 fVP2Manager.reset(p2Manager);
92}
93
94//_____________________________________________________________________________
96{
97 fVNtupleManager.reset(ntupleManager);
98}
99
100//_____________________________________________________________________________
102{
103 fFileManager.reset(fileManager);
104}
105
106//
107// public methods
108//
109
110//_____________________________________________________________________________
112{
113 fFileManager->SetFileName(fileName);
114}
115
116//_____________________________________________________________________________
118{
119 return fFileManager->GetFileName();
120}
121
122//_____________________________________________________________________________
124 const G4String& fileName,
125 const G4String& dirName)
126{
127 if ( fileName != "" ) {
128 return ReadH1Impl(h1Name, fileName, dirName, 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(), dirName, false);
140 }
141}
142
143//_____________________________________________________________________________
145 const G4String& fileName,
146 const G4String& dirName)
147{
148 if ( fileName != "" ) {
149 return ReadH2Impl(h2Name, fileName, dirName, true);
150 }
151 else {
152 if ( fFileManager->GetFileName() == "" ) {
153 G4ExceptionDescription description;
154 description
155 << "Cannot get H2. File name has to be set first.";
156 G4Exception("G4VAnalysisReader::ReadH2()",
157 "Analysis_WR011", JustWarning, description);
158 return kInvalidId;
159 }
160 return ReadH2Impl(h2Name, fFileManager->GetFileName(), dirName, false);
161 }
162}
163
164//_____________________________________________________________________________
166 const G4String& fileName,
167 const G4String& dirName)
168{
169 if ( fileName != "" ) {
170 return ReadH3Impl(h3Name, fileName, dirName, true);
171 }
172 else {
173 if ( fFileManager->GetFileName() == "" ) {
174 G4ExceptionDescription description;
175 description
176 << "Cannot get H3. File name has to be set first.";
177 G4Exception("G4VAnalysisReader::ReadH2()",
178 "Analysis_WR011", JustWarning, description);
179 return kInvalidId;
180 }
181 return ReadH3Impl(h3Name, fFileManager->GetFileName(), dirName, false);
182 }
183}
184
185//_____________________________________________________________________________
187 const G4String& fileName,
188 const G4String& dirName)
189{
190 if ( fileName != "" ) {
191 return ReadP1Impl(p1Name, fileName, dirName, true);
192 }
193 else {
194 if ( fFileManager->GetFileName() == "" ) {
195 G4ExceptionDescription description;
196 description
197 << "Cannot get P1. File name has to be set first.";
198 G4Exception("G4VAnalysisReader::ReadP1()",
199 "Analysis_WR011", JustWarning, description);
200 return kInvalidId;
201 }
202 return ReadP1Impl(p1Name, fFileManager->GetFileName(), dirName, false);
203 }
204}
205
206//_____________________________________________________________________________
208 const G4String& fileName,
209 const G4String& dirName)
210{
211 if ( fileName != "" ) {
212 return ReadP2Impl(p2Name, fileName, dirName, true);
213 }
214 else {
215 if ( fFileManager->GetFileName() == "" ) {
216 G4ExceptionDescription description;
217 description
218 << "Cannot get P2. File name has to be set first.";
219 G4Exception("G4VAnalysisReader::ReadP2()",
220 "Analysis_WR011", JustWarning, description);
221 return kInvalidId;
222 }
223 return ReadP2Impl(p2Name, fFileManager->GetFileName(), dirName, false);
224 }
225}
226
227//_____________________________________________________________________________
229{
230 G4bool finalResult = true;
231
232 G4bool result = SetFirstH1Id(firstId);
233 finalResult = finalResult && result;
234
235 result = SetFirstH2Id(firstId);
236 finalResult = finalResult && result;
237
238 result = SetFirstH3Id(firstId);
239 finalResult = finalResult && result;
240
241 return finalResult;
242}
243
244//_____________________________________________________________________________
246{
247 return fVH1Manager->GetHnManager()->SetFirstId(firstId);
248}
249
250//_____________________________________________________________________________
252{
253 return fVH2Manager->GetHnManager()->SetFirstId(firstId);
254}
255
256//_____________________________________________________________________________
258{
259 return fVH3Manager->GetHnManager()->SetFirstId(firstId);
260}
261
262//_____________________________________________________________________________
264{
265 G4bool finalResult = true;
266
267 G4bool result = SetFirstP1Id(firstId);
268 finalResult = finalResult && result;
269
270 result = SetFirstP2Id(firstId);
271 finalResult = finalResult && result;
272
273 return finalResult;
274}
275
276//_____________________________________________________________________________
278{
279 return fVP1Manager->GetHnManager()->SetFirstId(firstId);
280}
281
282//_____________________________________________________________________________
284{
285 return fVP2Manager->GetHnManager()->SetFirstId(firstId);
286}
287
288//_____________________________________________________________________________
290{
291 return fVNtupleManager->SetFirstId(firstId);
292}
293
294//_____________________________________________________________________________
296 const G4String& fileName,
297 const G4String& dirName)
298{
299 if ( fileName != "" ) {
300 return ReadNtupleImpl(ntupleName, fileName, dirName, true);
301 }
302 else {
303 // Check if fileName was set
304 if ( fFileManager->GetFileName() == "" ) {
305 G4ExceptionDescription description;
306 description
307 << "Cannot get Ntuple. File name has to be set first.";
308 G4Exception("G4VAnalysisReader::GetNtuple()",
309 "Analysis_WR011", JustWarning, description);
310 return kInvalidId;
311 }
312 return ReadNtupleImpl(ntupleName, fFileManager->GetFileName(), dirName, false);
313 }
314}
315
316//_____________________________________________________________________________
318 G4int& value)
319{
320 return fVNtupleManager->SetNtupleIColumn(columnName, value);
321}
322
323//_____________________________________________________________________________
325 G4float& value)
326{
327 return fVNtupleManager->SetNtupleFColumn(columnName, value);
328}
329
330//_____________________________________________________________________________
332 G4double& value)
333{
334 return fVNtupleManager->SetNtupleDColumn(columnName, value);
335}
336
337//_____________________________________________________________________________
339 G4String& value)
340{
341 return fVNtupleManager->SetNtupleSColumn(columnName, value);
342}
343
344//_____________________________________________________________________________
346 std::vector<int>& vector)
347{
348 return fVNtupleManager->SetNtupleIColumn(columnName, vector);
349}
350
351//_____________________________________________________________________________
353 std::vector<float>& vector)
354{
355 return fVNtupleManager->SetNtupleFColumn(columnName, vector);
356}
357
358//_____________________________________________________________________________
360 std::vector<double>& vector)
361{
362 return fVNtupleManager->SetNtupleDColumn(columnName, vector);
363}
364
365//_____________________________________________________________________________
367 const G4String& columnName,
368 G4int& value)
369{
370 return fVNtupleManager->SetNtupleIColumn(ntupleId, columnName, value);
371}
372
373//_____________________________________________________________________________
375 const G4String& columnName,
376 G4float& value)
377{
378 return fVNtupleManager->SetNtupleFColumn(ntupleId, columnName, value);
379}
380
381//_____________________________________________________________________________
383 const G4String& columnName,
384 G4double& value)
385{
386 return fVNtupleManager->SetNtupleDColumn(ntupleId, columnName, value);
387}
388
389//_____________________________________________________________________________
391 const G4String& columnName,
392 G4String& value)
393{
394 return fVNtupleManager->SetNtupleSColumn(ntupleId, columnName, value);
395}
396
397//_____________________________________________________________________________
399 const G4String& columnName,
400 std::vector<int>& vector)
401{
402 return fVNtupleManager->SetNtupleIColumn(ntupleId, columnName, vector);
403}
404
405//_____________________________________________________________________________
407 const G4String& columnName,
408 std::vector<float>& vector)
409{
410 return fVNtupleManager->SetNtupleFColumn(ntupleId, columnName, vector);
411}
412
413//_____________________________________________________________________________
415 const G4String& columnName,
416 std::vector<double>& vector)
417{
418 return fVNtupleManager->SetNtupleDColumn(ntupleId, columnName, vector);
419}
420
421//_____________________________________________________________________________
423{
424 return fVNtupleManager->GetNtupleRow();
425}
426
427
428//_____________________________________________________________________________
430{
431 return fVNtupleManager->GetNtupleRow(ntupleId);
432}
433
434//_____________________________________________________________________________
436{
437 return fVH1Manager->GetHnManager()->GetNofHns();
438}
439
440//_____________________________________________________________________________
442{
443 return fVH2Manager->GetHnManager()->GetNofHns();
444}
445
446//_____________________________________________________________________________
448{
449 return fVH3Manager->GetHnManager()->GetNofHns();
450}
451
452//_____________________________________________________________________________
454{
455 return fVP1Manager->GetHnManager()->GetNofHns();
456}
457
458//_____________________________________________________________________________
460{
461 return fVP2Manager->GetHnManager()->GetNofHns();
462}
463
464//_____________________________________________________________________________
466{
467 return fVNtupleManager->GetNofNtuples();
468}
469
470// GetH1Id(), GetH2Id in .icc
471
472// Access methods in .icc
473
474//_____________________________________________________________________________
476{
477 fState.SetVerboseLevel(verboseLevel);
478}
479
480// GetVerboseLevel() in .icc
@ JustWarning
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
std::ostringstream G4ExceptionDescription
Definition: G4Exception.hh:40
float G4float
Definition: G4Types.hh:84
double G4double
Definition: G4Types.hh:83
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
G4bool SetFirstH3Id(G4int firstId)
G4int ReadP2(const G4String &h2Name, const G4String &fileName="", const G4String &dirName="")
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
void SetFileManager(G4BaseFileManager *fileManager)
G4int GetNofH1s() const
void SetP1Manager(G4VP1Manager *p1Manager)
G4bool SetNtupleSColumn(const G4String &columnName, G4String &value)
G4int GetNofP2s() const
G4bool SetNtupleDColumn(const G4String &columnName, G4double &value)
G4bool SetFirstHistoId(G4int firstId)
void SetP2Manager(G4VP2Manager *p2Manager)
G4String GetFileName() const
void SetNtupleManager(G4VRNtupleManager *ntupleManager)
G4VAnalysisReader(const G4String &type, G4bool isMaster)
G4bool SetFirstH1Id(G4int firstId)
G4AnalysisManagerState fState
virtual G4int ReadNtupleImpl(const G4String &ntupleName, const G4String &fileName, const G4String &dirName, G4bool isUserFileName)=0
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)
virtual G4int ReadH1Impl(const G4String &h1Name, const G4String &fileName, const G4String &dirName, G4bool isUserFileName)=0
G4int GetNofNtuples() const
void SetH2Manager(G4VH2Manager *h2Manager)
G4int ReadH2(const G4String &h2Name, const G4String &fileName="", const G4String &dirName="")
G4bool SetFirstH2Id(G4int firstId)
G4int GetNofP1s() const
virtual ~G4VAnalysisReader()
G4bool SetFirstProfileId(G4int firstId)
void SetH1Manager(G4VH1Manager *h1Manager)
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="")
G4bool SetNtupleIColumn(const G4String &columnName, G4int &value)
G4int ReadP1(const G4String &h1Name, const G4String &fileName="", const G4String &dirName="")
G4int GetNofH3s() const
void SetVerboseLevel(G4int verboseLevel)
G4bool SetFirstP2Id(G4int firstId)
void SetH3Manager(G4VH3Manager *h3Manager)
G4int ReadH1(const G4String &h1Name, const G4String &fileName="", const G4String &dirName="")
const G4int kInvalidId