Class podio::Reader
-
class Reader
Generic (type erased) reader class that can handle different I/O backends transparently.
Offers some more high level functionality compared to the lower level backend specific readers that this class wraps. In contrast to the lower level readers that usually return arbitrary FrameData, this interface class will return fully constructed Frames. In addition, it provides convenience methods to deal specifically with the “events” frame category.
Note
The recommended way to construct is to use the makeReader() functions since they handle the instantiation of the correct low level readers
Public Functions
-
template<typename T>
Reader(std::unique_ptr<T> actualReader) Create a reader from a low level reader.
- Template Parameters:
T – The type of the low level reader (will be deduced)
- Parameters:
actualReader – a low level reader that provides access to FrameDataT
-
~Reader() = default
-
inline podio::Frame readNextFrame(const std::string &name, const std::vector<std::string> &collsToRead = {})
Read the next frame of a given category.
- Parameters:
name – The category name for which to read the next frame
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 the category is not available or in case no more entries are available
- Returns:
A fully constructed Frame with the contents read from file
-
inline podio::Frame readNextEvent(const std::vector<std::string> &collsToRead = {})
Read the next frame of the “events” category.
- Parameters:
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 no (more) events are available
- Returns:
A fully constructed Frame with the contents read from file
-
inline podio::Frame readFrame(const std::string &name, size_t index, const std::vector<std::string> &collsToRead = {})
Read a specific frame for a given category.
- Parameters:
name – The category name for which to read the next entry
index – 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 the category is not available or in case the specified entry is not available
- Returns:
A fully constructed Frame with the contents read from file
-
inline podio::Frame readEvent(size_t index, const std::vector<std::string> &collsToRead = {})
Read a specific frame of the “events” category.
- Parameters:
index – The event 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 the desired event is not available
- Returns:
A fully constructed Frame with the contents read from file
-
inline size_t getEntries(const std::string &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 size_t getEvents() const
Get the number of events.
- 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(const std::string &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 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
-
inline const std::string_view getDatamodelDefinition(const std::string &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
-
template<typename T>