Class RMGAnalysisReader¶
Defined in File RMGAnalysisReader.hh
Nested Relationships¶
Nested Types¶
Class Documentation¶
-
class RMGAnalysisReader¶
wrapper around G4VAnalysisReader instances with special handling for LH5 files.
notes for threadsafe use:
opening/closing can only be performed on the master thread.
in a multithreaded application, all function calls are guarded by a mutex. Worker threads can use the reader instance after opening, but only one worker can use the reader at a time.
the reader access handles are generally thread-safe, if no other thread uses any G4VAnalysisReader directly.
the reader should only be bound once to variables that are of static storage duration. Example: only bind to static class fields to read the values into. Do only unloack the reader access handle after reading/checking the read data.
Public Functions
-
RMGAnalysisReader() = default¶
-
~RMGAnalysisReader() = default¶
-
RMGAnalysisReader(RMGAnalysisReader const&) = delete¶
-
RMGAnalysisReader &operator=(RMGAnalysisReader const&) = delete¶
-
RMGAnalysisReader(RMGAnalysisReader&&) = delete¶
-
RMGAnalysisReader &operator=(RMGAnalysisReader&&) = delete¶
-
Access OpenFile(const std::string &file_name, std::string ntuple_dir_name, std::string ntuple_name, G4AutoLock lock, std::string force_ext = "")¶
open an input file for reading of one specific ntuple. The return access handle can be used to connect to-be-read column to variables.
This function can only be used on the master thread. This operation acquires a global lock across all readers that will be held until the access handle is discarded.
- Parameters:
file_name – the input file name. the file format is determined from the file extension.
ntuple_dir_name – the first part of the input table name. For the table addressed by “dir/table” this is “dir”.
ntuple_name – the first part of the input table name. For the table addressed by “dir/table” this is “table”.
lock – a lock instance obtained by RMGAnalysisReader::GetLock - optional.
force_ext – force a file extension/reader type. should be a lowercase file extension like
lh5,hdf5,csv,root.
-
Access OpenFile(const std::string &file_name, std::string ntuple_dir_name, std::string ntuple_name, std::string force_ext = "")¶
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
-
void CloseFile()¶
if any file is open for reading, close the reader. Also clean-up temporary files.
This function can only be used on the master thread. This operation acquires a global across all readers. This function will not actually free resources allocated for the reader by Geant4.
-
Access GetLockedReader() const¶
get an access handle to the current underlying G4VAnalysisReader.
The return access handle can be used to read row(s) from the ntuple. This function acquires a global across all readers that will be held until the access handle is discarded.
-
G4AutoLock GetLock() const¶
acquires a global lock to the analysis reader mutex.
-
inline auto &GetFileName() const¶
get the file name of the current open file, or an empty string.
-
class Access¶
thread-safe access handle to the underlying reader. This handle can be used to set-up ntuple reading (in setup mode) or to read rows from the ntuple.
Public Functions
-
inline ~Access()¶
-
inline void unlock()¶
unlock this access handle before it exits the scope.
-
inline void Seek(size_t offset)¶
read and discard a number of rows at the current position.
-
inline auto GetNtupleRow()¶
wraps
GetNtupleRow()of G4VAnalysisReader.
-
inline auto SetNtupleDColumn(const std::string &name, G4double &value, const std::vector<std::string> &allowed_units = {})¶
wraps
SetNtupleDColumn()of G4VAnalysisReader.
-
inline auto SetNtupleFColumn(const std::string &name, G4float &value, const std::vector<std::string> &allowed_units = {})¶
wraps
SetNtupleFColumn()of G4VAnalysisReader.
-
inline auto SetNtupleIColumn(const std::string &name, G4int &value, const std::vector<std::string> &allowed_units = {})¶
wraps
SetNtupleIColumn()of G4VAnalysisReader.
-
std::string GetUnit(const std::string &name) const¶
get unit information for the column. an empty string means either no unit attached or no support by the file format.
-
inline operator bool() const¶
check whether this access handle is still valid.
-
inline ~Access()¶