Class podio::RNTupleReader
-
class RNTupleReader : public podio::ReaderCommon
The RNTupleReader can be used to read files that have been written with the RNTuple backend.
The RNTupleReader provides the data as ROOTFrameData from which a podio::Frame can be constructed. It can be used to read files written by the RNTupleWriter.
Public Functions
-
RNTupleReader() = default
-
~RNTupleReader() = default
-
RNTupleReader(const RNTupleReader&) = delete
-
RNTupleReader &operator=(const RNTupleReader&) = delete
-
RNTupleReader(RNTupleReader&&) = default
-
RNTupleReader &operator=(RNTupleReader&&) = default
-
void openFile(const std::string &filename)
Open a single file for reading.
- Parameters:
filename – The name of the input file
- Throws:
std::logic_error – if files have already been opened with this reader
-
void openFiles(const std::vector<std::string> &filenames)
Open multiple files for reading and then treat them as if they are one file.
Note
All of the files are assumed to have the same structure. Specifically this means:
The same categories are available from all files
The collections that are contained in the individual categories are the same across all files
This usually boils down to “the files have been written with the same
”settings”, e.g. they are outputs of a batched process.
- Parameters:
filenames – The filenames of all input files that should be read
- Throws:
std::logic_error – if files have already been opened with this reader
-
std::unique_ptr<podio::ROOTFrameData> readNextEntry(std::string_view name, const std::vector<std::string> &collsToRead = {})
Read the next data entry for a given category.
- Parameters:
name – The category name for which to read the next entry
collsToRead – (optional) the collection names that should be read. If not provided (or empty) all collections will be read
- Throws:
std::invalid_argument – in case collsToRead contains collection names that are not available
- Returns:
FrameData from which a podio::Frame can be constructed if the category exists and if there are still entries left to read. Otherwise a nullptr
-
std::unique_ptr<podio::ROOTFrameData> readEntry(std::string_view name, const unsigned entry, const std::vector<std::string> &collsToRead = {})
Read the desired data entry for a given category.
- Parameters:
name – The category name for which to read the next entry
entry – The entry number to read
collsToRead – (optional) the collection names that should be read. If not provided (or empty) all collections will be read
- Throws:
std::invalid_argument – in case collsToRead contains collection names that are not available
- Returns:
FrameData from which a podio::Frame can be constructed if the category and the desired entry exist. Otherwise a nullptr
-
unsigned getEntries(std::string_view name) const
Get the number of entries for the given name.
- Parameters:
name – The name of the category
- Returns:
The number of entries that are available for the category
-
inline podio::version::Version currentFileVersion() const
Get the build version of podio that has been used to write the current file.
- Returns:
The podio build version
-
inline std::optional<podio::version::Version> currentFileVersion(std::string_view name) const
Get the (build) version of a datamodel that has been used to write the current file.
- Parameters:
name – The name of the datamodel
- Returns:
The (build) version of the datamodel if available or an empty optional
-
inline const std::string_view getDatamodelDefinition(std::string_view name) const
Get the datamodel definition for the given name.
- Parameters:
name – The name of the datamodel
- Returns:
The high level definition of the datamodel in JSON format
-
inline std::vector<std::string> getAvailableDatamodels() const
Get all names of the datamodels that are available from this reader.
- Returns:
The names of the datamodels
-
inline std::vector<std::string_view> getAvailableCategories() const
Get the names of all the available Frame categories in the current file(s).
- Returns:
The names of the available categories from the file
-
RNTupleReader() = default