Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4Hdf5AnalysisReader Class Reference

#include <G4Hdf5AnalysisReader.hh>

+ Inheritance diagram for G4Hdf5AnalysisReader:

Public Member Functions

 G4Hdf5AnalysisReader (G4bool isMaster=true)
 
virtual ~G4Hdf5AnalysisReader ()
 
tools::hdf5::ntuple * GetNtuple () const
 
tools::hdf5::ntuple * GetNtuple (G4int ntupleId) const
 
G4int GetNtuple (const G4String &ntupleName, const G4String &fileName="", const G4String &dirName="")
 
- Public Member Functions inherited from G4ToolsAnalysisReader
 G4ToolsAnalysisReader (const G4String &type, G4bool isMaster=true)
 
virtual ~G4ToolsAnalysisReader ()
 
tools::histo::h1d * GetH1 (G4int id, G4bool warn=true) const
 
tools::histo::h2d * GetH2 (G4int id, G4bool warn=true) const
 
tools::histo::h3d * GetH3 (G4int id, G4bool warn=true) const
 
tools::histo::p1d * GetP1 (G4int id, G4bool warn=true) const
 
tools::histo::p2d * GetP2 (G4int id, G4bool warn=true) const
 
- Public Member Functions inherited from G4VAnalysisReader
 G4VAnalysisReader (const G4String &type, G4bool isMaster)
 
virtual ~G4VAnalysisReader ()
 
void SetFileName (const G4String &fileName)
 
G4String GetFileName () const
 
G4int ReadH1 (const G4String &h1Name, const G4String &fileName="", const G4String &dirName="")
 
G4int ReadH2 (const G4String &h2Name, const G4String &fileName="", const G4String &dirName="")
 
G4int ReadH3 (const G4String &h3Name, const G4String &fileName="", const G4String &dirName="")
 
G4int ReadP1 (const G4String &h1Name, const G4String &fileName="", const G4String &dirName="")
 
G4int ReadP2 (const G4String &h2Name, const G4String &fileName="", const G4String &dirName="")
 
G4bool SetFirstHistoId (G4int firstId)
 
G4bool SetFirstH1Id (G4int firstId)
 
G4bool SetFirstH2Id (G4int firstId)
 
G4bool SetFirstH3Id (G4int firstId)
 
G4bool SetFirstProfileId (G4int firstId)
 
G4bool SetFirstP1Id (G4int firstId)
 
G4bool SetFirstP2Id (G4int firstId)
 
G4bool SetFirstNtupleId (G4int firstId)
 
G4int GetNtuple (const G4String &ntupleName, const G4String &fileName="", const G4String &dirName="")
 
G4bool SetNtupleIColumn (const G4String &columnName, G4int &value)
 
G4bool SetNtupleFColumn (const G4String &columnName, G4float &value)
 
G4bool SetNtupleDColumn (const G4String &columnName, G4double &value)
 
G4bool SetNtupleSColumn (const G4String &columnName, G4String &value)
 
G4bool SetNtupleIColumn (const G4String &columnName, std::vector< int > &vector)
 
G4bool SetNtupleFColumn (const G4String &columnName, std::vector< float > &vector)
 
G4bool SetNtupleDColumn (const G4String &columnName, std::vector< double > &vector)
 
G4bool SetNtupleIColumn (G4int ntupleId, const G4String &columnName, G4int &value)
 
G4bool SetNtupleFColumn (G4int ntupleId, const G4String &columnName, G4float &value)
 
G4bool SetNtupleDColumn (G4int ntupleId, const G4String &columnName, G4double &value)
 
G4bool SetNtupleSColumn (G4int ntupleId, const G4String &columnName, G4String &value)
 
G4bool SetNtupleIColumn (G4int ntupleId, const G4String &columnName, std::vector< int > &vector)
 
G4bool SetNtupleFColumn (G4int ntupleId, const G4String &columnName, std::vector< float > &vector)
 
G4bool SetNtupleDColumn (G4int ntupleId, const G4String &columnName, std::vector< double > &vector)
 
G4bool GetNtupleRow ()
 
G4bool GetNtupleRow (G4int ntupleId)
 
G4bool IsAscii () const
 
G4int GetNofH1s () const
 
G4int GetNofH2s () const
 
G4int GetNofH3s () const
 
G4int GetNofP1s () const
 
G4int GetNofP2s () const
 
G4int GetNofNtuples () const
 
G4int GetH1Id (const G4String &name, G4bool warn=true) const
 
G4int GetH2Id (const G4String &name, G4bool warn=true) const
 
G4int GetH3Id (const G4String &name, G4bool warn=true) const
 
G4int GetP1Id (const G4String &name, G4bool warn=true) const
 
G4int GetP2Id (const G4String &name, G4bool warn=true) const
 
G4int GetH1Nbins (G4int id) const
 
G4double GetH1Xmin (G4int id) const
 
G4double GetH1Xmax (G4int id) const
 
G4double GetH1Width (G4int id) const
 
G4int GetH2Nxbins (G4int id) const
 
G4double GetH2Xmin (G4int id) const
 
G4double GetH2Xmax (G4int id) const
 
G4double GetH2XWidth (G4int id) const
 
G4int GetH2Nybins (G4int id) const
 
G4double GetH2Ymin (G4int id) const
 
G4double GetH2Ymax (G4int id) const
 
G4double GetH2YWidth (G4int id) const
 
G4int GetH3Nxbins (G4int id) const
 
G4double GetH3Xmin (G4int id) const
 
G4double GetH3Xmax (G4int id) const
 
G4double GetH3XWidth (G4int id) const
 
G4int GetH3Nybins (G4int id) const
 
G4double GetH3Ymin (G4int id) const
 
G4double GetH3Ymax (G4int id) const
 
G4double GetH3YWidth (G4int id) const
 
G4int GetH3Nzbins (G4int id) const
 
G4double GetH3Zmin (G4int id) const
 
G4double GetH3Zmax (G4int id) const
 
G4double GetH3ZWidth (G4int id) const
 
G4int GetP1Nbins (G4int id) const
 
G4double GetP1Xmin (G4int id) const
 
G4double GetP1Xmax (G4int id) const
 
G4double GetP1XWidth (G4int id) const
 
G4double GetP1Ymin (G4int id) const
 
G4double GetP1Ymax (G4int id) const
 
G4int GetP2Nxbins (G4int id) const
 
G4double GetP2Xmin (G4int id) const
 
G4double GetP2Xmax (G4int id) const
 
G4double GetP2XWidth (G4int id) const
 
G4int GetP2Nybins (G4int id) const
 
G4double GetP2Ymin (G4int id) const
 
G4double GetP2Ymax (G4int id) const
 
G4double GetP2YWidth (G4int id) const
 
G4double GetP2Zmin (G4int id) const
 
G4double GetP2Zmax (G4int id) const
 
G4String GetH1Title (G4int id) const
 
G4String GetH1XAxisTitle (G4int id) const
 
G4String GetH1YAxisTitle (G4int id) const
 
G4String GetH2Title (G4int id) const
 
G4String GetH2XAxisTitle (G4int id) const
 
G4String GetH2YAxisTitle (G4int id) const
 
G4String GetH2ZAxisTitle (G4int id) const
 
G4String GetH3Title (G4int id) const
 
G4String GetH3XAxisTitle (G4int id) const
 
G4String GetH3YAxisTitle (G4int id) const
 
G4String GetH3ZAxisTitle (G4int id) const
 
G4String GetP1Title (G4int id) const
 
G4String GetP1XAxisTitle (G4int id) const
 
G4String GetP1YAxisTitle (G4int id) const
 
G4String GetP1ZAxisTitle (G4int id) const
 
G4String GetP2Title (G4int id) const
 
G4String GetP2XAxisTitle (G4int id) const
 
G4String GetP2YAxisTitle (G4int id) const
 
G4String GetP2ZAxisTitle (G4int id) const
 
void SetVerboseLevel (G4int verboseLevel)
 
G4int GetVerboseLevel () const
 
G4String GetType () const
 
G4String GetFileType () const
 

Static Public Member Functions

static G4Hdf5AnalysisReaderInstance ()
 

Protected Member Functions

virtual G4int ReadH1Impl (const G4String &h1Name, const G4String &fileName, const G4String &dirName, G4bool isUserFileName) final
 
virtual G4int ReadH2Impl (const G4String &h2Name, const G4String &fileName, const G4String &dirName, G4bool isUserFileName) final
 
virtual G4int ReadH3Impl (const G4String &h3Name, const G4String &fileName, const G4String &dirName, G4bool isUserFileName) final
 
virtual G4int ReadP1Impl (const G4String &p1Name, const G4String &fileName, const G4String &dirName, G4bool isUserFileName) final
 
virtual G4int ReadP2Impl (const G4String &p2Name, const G4String &fileName, const G4String &dirName, G4bool isUserFileName) final
 
virtual G4int ReadNtupleImpl (const G4String &ntupleName, const G4String &fileName, const G4String &dirName, G4bool isUserFileName) final
 
- Protected Member Functions inherited from G4ToolsAnalysisReader
G4bool Reset ()
 
- Protected Member Functions inherited from G4VAnalysisReader
virtual G4int ReadH1Impl (const G4String &h1Name, const G4String &fileName, const G4String &dirName, G4bool isUserFileName)=0
 
virtual G4int ReadH2Impl (const G4String &h2Name, const G4String &fileName, const G4String &dirName, G4bool isUserFileName)=0
 
virtual G4int ReadH3Impl (const G4String &h3Name, const G4String &fileName, const G4String &dirName, G4bool isUserFileName)=0
 
virtual G4int ReadP1Impl (const G4String &p1Name, const G4String &fileName, const G4String &dirName, G4bool isUserFileName)=0
 
virtual G4int ReadP2Impl (const G4String &p2Name, const G4String &fileName, const G4String &dirName, G4bool isUserFileName)=0
 
virtual G4int ReadNtupleImpl (const G4String &ntupleName, const G4String &fileName, const G4String &dirName, G4bool isUserFileName)=0
 
void SetH1Manager (G4VH1Manager *h1Manager)
 
void SetH2Manager (G4VH2Manager *h2Manager)
 
void SetH3Manager (G4VH3Manager *h3Manager)
 
void SetP1Manager (G4VP1Manager *p1Manager)
 
void SetP2Manager (G4VP2Manager *p2Manager)
 
void SetNtupleManager (G4VRNtupleManager *ntupleManager)
 
void SetFileManager (G4BaseFileManager *fileManager)
 

Additional Inherited Members

- Protected Attributes inherited from G4ToolsAnalysisReader
G4H1ToolsManagerfH1Manager
 
G4H2ToolsManagerfH2Manager
 
G4H3ToolsManagerfH3Manager
 
G4P1ToolsManagerfP1Manager
 
G4P2ToolsManagerfP2Manager
 
- Protected Attributes inherited from G4VAnalysisReader
G4AnalysisManagerState fState
 

Detailed Description

Definition at line 53 of file G4Hdf5AnalysisReader.hh.

Constructor & Destructor Documentation

◆ G4Hdf5AnalysisReader()

G4Hdf5AnalysisReader::G4Hdf5AnalysisReader ( G4bool  isMaster = true)
explicit

Definition at line 55 of file G4Hdf5AnalysisReader.cc.

56 : G4ToolsAnalysisReader("Hdf5", isMaster),
57 fNtupleManager(nullptr),
58 fFileManager(nullptr)
59{
60 if ( ( isMaster && fgMasterInstance ) || ( fgInstance ) ) {
61 G4ExceptionDescription description;
62 description
63 << " "
64 << "G4Hdf5AnalysisReader already exists."
65 << "Cannot create another instance.";
66 G4Exception("G4Hdf5AnalysisReader::G4Hdf5AnalysisReader()",
67 "Analysis_F001", FatalException, description);
68 }
69 if ( isMaster ) fgMasterInstance = this;
70 fgInstance = this;
71
72 // Create managers
73 fNtupleManager = new G4Hdf5RNtupleManager(fState);
74 fFileManager = new G4Hdf5RFileManager(fState);
75
76 // Set managers to base class
77 SetNtupleManager(fNtupleManager);
78 SetFileManager(fFileManager);
79}
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
std::ostringstream G4ExceptionDescription
Definition: G4Exception.hh:40
void SetFileManager(G4BaseFileManager *fileManager)
void SetNtupleManager(G4VRNtupleManager *ntupleManager)
G4AnalysisManagerState fState

◆ ~G4Hdf5AnalysisReader()

G4Hdf5AnalysisReader::~G4Hdf5AnalysisReader ( )
virtual

Definition at line 82 of file G4Hdf5AnalysisReader.cc.

83{
84 if ( fState.GetIsMaster() ) fgMasterInstance = nullptr;
85 fgInstance = nullptr;
86}

Member Function Documentation

◆ GetNtuple() [1/3]

tools::hdf5::ntuple * G4Hdf5AnalysisReader::GetNtuple ( ) const

◆ GetNtuple() [2/3]

G4int G4VAnalysisReader::GetNtuple ( const G4String ntupleName,
const G4String fileName = "",
const G4String dirName = "" 
)

Definition at line 88 of file G4VAnalysisReader.cc.

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}
@ JustWarning
G4String GetFileName() const
virtual G4int ReadNtupleImpl(const G4String &ntupleName, const G4String &fileName, const G4String &dirName, G4bool isUserFileName) final
const G4int kInvalidId

◆ GetNtuple() [3/3]

tools::hdf5::ntuple * G4Hdf5AnalysisReader::GetNtuple ( G4int  ntupleId) const

◆ Instance()

G4Hdf5AnalysisReader * G4Hdf5AnalysisReader::Instance ( )
static

Definition at line 44 of file G4Hdf5AnalysisReader.cc.

45{
46 if ( fgInstance == nullptr ) {
48 fgInstance = new G4Hdf5AnalysisReader(isMaster);
49 }
50
51 return fgInstance;
52}
bool G4bool
Definition: G4Types.hh:86
G4bool IsWorkerThread()
Definition: G4Threading.cc:123

◆ ReadH1Impl()

G4int G4Hdf5AnalysisReader::ReadH1Impl ( const G4String h1Name,
const G4String fileName,
const G4String dirName,
G4bool  isUserFileName 
)
finalprotectedvirtual

Implements G4VAnalysisReader.

Definition at line 113 of file G4Hdf5AnalysisReader.cc.

117{
118#ifdef G4VERBOSE
119 if ( fState.GetVerboseL4() )
120 fState.GetVerboseL4()->Message("read", "h1", h1Name);
121#endif
122
123 auto h1 = ReadHnImpl<tools::histo::h1d>(h1Name, fileName, dirName);
124
125 if ( ! h1 ) return kInvalidId;
126
127 auto id = fH1Manager->AddH1(h1Name, h1);
128
129#ifdef G4VERBOSE
130 if ( fState.GetVerboseL2() )
131 fState.GetVerboseL2()->Message("read", "h1", h1Name, id > kInvalidId);
132#endif
133
134 return id;
135}
const G4AnalysisVerbose * GetVerboseL2() const
const G4AnalysisVerbose * GetVerboseL4() const
void Message(const G4String &action, const G4String &object, const G4String &objectName, G4bool success=true) const
G4int AddH1(const G4String &name, tools::histo::h1d *h1d)
G4H1ToolsManager * fH1Manager

◆ ReadH2Impl()

G4int G4Hdf5AnalysisReader::ReadH2Impl ( const G4String h2Name,
const G4String fileName,
const G4String dirName,
G4bool  isUserFileName 
)
finalprotectedvirtual

Implements G4VAnalysisReader.

Definition at line 138 of file G4Hdf5AnalysisReader.cc.

142{
143#ifdef G4VERBOSE
144 if ( fState.GetVerboseL4() )
145 fState.GetVerboseL4()->Message("read", "h2", h2Name);
146#endif
147
148 auto h2 = ReadHnImpl<tools::histo::h2d>(h2Name, fileName, dirName);
149
150 if ( ! h2 ) return kInvalidId;
151
152 auto id = fH2Manager->AddH2(h2Name, h2);
153
154#ifdef G4VERBOSE
155 if ( fState.GetVerboseL2() )
156 fState.GetVerboseL2()->Message("read", "h2", h2Name, id > kInvalidId);
157#endif
158
159 return id;
160}
G4int AddH2(const G4String &name, tools::histo::h2d *h2d)
G4H2ToolsManager * fH2Manager

◆ ReadH3Impl()

G4int G4Hdf5AnalysisReader::ReadH3Impl ( const G4String h3Name,
const G4String fileName,
const G4String dirName,
G4bool  isUserFileName 
)
finalprotectedvirtual

Implements G4VAnalysisReader.

Definition at line 163 of file G4Hdf5AnalysisReader.cc.

167{
168
169#ifdef G4VERBOSE
170 if ( fState.GetVerboseL4() )
171 fState.GetVerboseL4()->Message("read", "h3", h3Name);
172#endif
173
174 auto h3 = ReadHnImpl<tools::histo::h3d>(h3Name, fileName, dirName);
175
176 if ( ! h3 ) return kInvalidId;
177
178 auto id = fH3Manager->AddH3(h3Name, h3);
179
180#ifdef G4VERBOSE
181 if ( fState.GetVerboseL2() )
182 fState.GetVerboseL2()->Message("read", "h3", h3Name, id > kInvalidId);
183#endif
184
185 return id;
186}
G4int AddH3(const G4String &name, tools::histo::h3d *h3d)
G4H3ToolsManager * fH3Manager

◆ ReadNtupleImpl()

G4int G4Hdf5AnalysisReader::ReadNtupleImpl ( const G4String ntupleName,
const G4String fileName,
const G4String dirName,
G4bool  isUserFileName 
)
finalprotectedvirtual

Implements G4VAnalysisReader.

Definition at line 240 of file G4Hdf5AnalysisReader.cc.

244{
245#ifdef G4VERBOSE
246 if ( fState.GetVerboseL4() )
247 fState.GetVerboseL4()->Message("read", "ntuple", ntupleName);
248#endif
249
250 // Ntuples are saved in files per thread
251 // but apply thethe thread suffix only if fileName is not provided explicitly
252 G4String fullFileName = fileName;
253 if ( ! isUserFileName ) {
254 fullFileName = fFileManager->GetFullFileName();
255 }
256
257 // Get directory
258 auto directory = fFileManager->GetNtupleRDirectory(fullFileName, dirName, false);
259 if ( directory < 0 ) return kInvalidId;
260
261 // Create ntuple
262 auto rntuple = new tools::hdf5::ntuple(G4cout, directory, ntupleName);
263 auto rntupleDescription = new G4TRNtupleDescription<tools::hdf5::ntuple>(rntuple);
264 auto id = fNtupleManager->SetNtuple(rntupleDescription);
265
266#ifdef G4VERBOSE
267 if ( fState.GetVerboseL2() )
268 fState.GetVerboseL2()->Message("read", "ntuple", ntupleName, id > kInvalidId);
269#endif
270
271 return id;
272}
G4GLOB_DLL std::ostream G4cout
G4String GetFullFileName(const G4String &baseFileName="", G4bool isPerThread=true) const
hid_t GetNtupleRDirectory(const G4String &fileName, const G4String &dirName, G4bool isPerThread)
G4int SetNtuple(G4TRNtupleDescription< TNTUPLE > *rntupleDescription)

◆ ReadP1Impl()

G4int G4Hdf5AnalysisReader::ReadP1Impl ( const G4String p1Name,
const G4String fileName,
const G4String dirName,
G4bool  isUserFileName 
)
finalprotectedvirtual

Implements G4VAnalysisReader.

Definition at line 189 of file G4Hdf5AnalysisReader.cc.

193{
194#ifdef G4VERBOSE
195 if ( fState.GetVerboseL4() )
196 fState.GetVerboseL4()->Message("read", "p1", p1Name);
197#endif
198
199 auto p1 = ReadPnImpl<tools::histo::p1d>(p1Name, fileName, dirName);
200
201 if ( ! p1 ) return kInvalidId;
202
203 auto id = fP1Manager->AddP1(p1Name, p1);
204
205#ifdef G4VERBOSE
206 if ( fState.GetVerboseL2() )
207 fState.GetVerboseL2()->Message("read", "p1", p1Name, id > kInvalidId);
208#endif
209
210 return id;
211}
G4int AddP1(const G4String &name, tools::histo::p1d *p1d)
G4P1ToolsManager * fP1Manager

◆ ReadP2Impl()

G4int G4Hdf5AnalysisReader::ReadP2Impl ( const G4String p2Name,
const G4String fileName,
const G4String dirName,
G4bool  isUserFileName 
)
finalprotectedvirtual

Implements G4VAnalysisReader.

Definition at line 214 of file G4Hdf5AnalysisReader.cc.

218{
219
220#ifdef G4VERBOSE
221 if ( fState.GetVerboseL4() )
222 fState.GetVerboseL4()->Message("read", "p2", p2Name);
223#endif
224
225 auto p2 = ReadPnImpl<tools::histo::p2d>(p2Name, fileName, dirName);
226
227 if ( ! p2 ) return kInvalidId;
228
229 auto id = fP2Manager->AddP2(p2Name, p2);
230
231#ifdef G4VERBOSE
232 if ( fState.GetVerboseL2() )
233 fState.GetVerboseL2()->Message("read", "p2", p2Name, id > kInvalidId);
234#endif
235
236 return id;
237}
G4int AddP2(const G4String &name, tools::histo::p2d *p2d)
G4P2ToolsManager * fP2Manager

The documentation for this class was generated from the following files: