remage
Simulation framework for HPGe-based experiments
 
Loading...
Searching...
No Matches
RMGAnalysisReader Class Referencefinal

wrapper around G4VAnalysisReader instances with special handling for LH5 files. More...

#include <RMGAnalysisReader.hh>

Classes

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. More...
 

Public Member Functions

 RMGAnalysisReader (RMGAnalysisReader const &)=delete
 
RMGAnalysisReaderoperator= (RMGAnalysisReader const &)=delete
 
 RMGAnalysisReader (RMGAnalysisReader &&)=delete
 
RMGAnalysisReaderoperator= (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.
 
Access OpenFile (const std::string &file_name, std::string ntuple_dir_name, std::string ntuple_name, std::string force_ext="")
 
void CloseFile ()
 if any file is open for reading, close the reader. Also clean-up temporary files.
 
Access GetLockedReader () const
 get an access handle to the current underlying G4VAnalysisReader.
 
G4AutoLock GetLock () const
 acquires a global lock to the analysis reader mutex.
 
auto & GetFileName () const
 get the file name of the current open file, or an empty string.
 

Detailed Description

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.

Member Function Documentation

◆ CloseFile()

void RMGAnalysisReader::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.

◆ GetLockedReader()

RMGAnalysisReader::Access RMGAnalysisReader::GetLockedReader ( ) const
nodiscard

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.

◆ OpenFile() [1/2]

RMGAnalysisReader::Access RMGAnalysisReader::OpenFile ( const std::string & file_name,
std::string ntuple_dir_name,
std::string ntuple_name,
G4AutoLock lock,
std::string force_ext = "" )
nodiscard

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_namethe input file name. the file format is determined from the file extension.
ntuple_dir_namethe first part of the input table name. For the table addressed by "dir/table" this is "dir".
ntuple_namethe first part of the input table name. For the table addressed by "dir/table" this is "table".
locka lock instance obtained by RMGAnalysisReader::GetLock - optional.
force_extforce a file extension/reader type. should be a lowercase file extension like lh5, hdf5, csv, root.

◆ OpenFile() [2/2]

RMGAnalysisReader::Access RMGAnalysisReader::OpenFile ( const std::string & file_name,
std::string ntuple_dir_name,
std::string ntuple_name,
std::string force_ext = "" )
nodiscard

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.


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