File ROOTFrameReader.h
-
namespace podio
-
class ROOTFrameReader
- #include <podio/ROOTFrameReader.h>
This class has the function to read available data from disk and to prepare collections and buffers.
Public Functions
-
ROOTFrameReader() = default
-
~ROOTFrameReader() = default
-
ROOTFrameReader(const ROOTFrameReader&) = delete
-
ROOTFrameReader &operator=(const ROOTFrameReader&) = delete
-
void openFile(const std::string &filename)
Open a single file for reading.
- Parameters:
filename – The name of the input file
-
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
-
std::unique_ptr<podio::ROOTFrameData> readNextEntry(const std::string &name)
Read the next data entry from which a Frame can be constructed for the given name.
In case there are no more entries left for this name or in case there is no data for this name, this returns a nullptr.
-
std::unique_ptr<podio::ROOTFrameData> readEntry(const std::string &name, const unsigned entry)
Read the specified data entry from which a Frame can be constructed for the given name.
In case the entry does not exist for this name or in case there is no data for this name, this returns a nullptr.
-
unsigned getEntries(const std::string &name) const
Returns number of entries for the given name.
-
inline podio::version::Version currentFileVersion() const
Get the build version of podio that has been used to write the current file.
-
std::vector<std::string_view> getAvailableCategories() const
Get the names of all the available Frame categories in the current file(s)
-
inline const std::string_view getDatamodelDefinition(const std::string &name) const
Get the datamodel definition for the given name.
-
inline std::vector<std::string> getAvailableDatamodels() const
Get all names of the datamodels that ara available from this reader.
Private Functions
-
void initCategory(CategoryInfo &catInfo, const std::string &name)
Initialize the passed CategoryInfo by setting up the necessary branches, collection infos and all necessary meta data to be able to read entries with this name.
-
CategoryInfo &getCategoryInfo(const std::string &name)
Get the category information for the given name.
In case there is no TTree with contents for the given name this will return a CategoryInfo with an uninitialized chain (nullptr) member
-
GenericParameters readEntryParameters(CategoryInfo &catInfo, bool reloadBranches, unsigned int localEntry)
Read the parameters for the entry specified in the passed CategoryInfo.
-
std::unique_ptr<podio::ROOTFrameData> readEntry(ROOTFrameReader::CategoryInfo &catInfo)
Read the data entry specified in the passed CategoryInfo, and increase the counter afterwards.
In case the requested entry is larger than the available number of entries, return a nullptr.
-
podio::CollectionReadBuffers getCollectionBuffers(CategoryInfo &catInfo, size_t iColl, bool reloadBranches, unsigned int localEntry)
Get / read the buffers at index iColl in the passed category information.
Private Members
-
std::unique_ptr<TChain> m_metaChain = {nullptr}
The metadata tree.
-
std::unordered_map<std::string, CategoryInfo> m_categories = {}
All categories.
-
std::vector<std::string> m_availCategories = {}
All available categories from this file.
-
DatamodelDefinitionHolder m_datamodelHolder = {}
-
struct CategoryInfo
Helper struct to group together all the necessary state to read / process a given category.
A “category” in this case describes all frames with the same name which are constrained by the ROOT file structure that we use to have the same contents. It encapsulates all state that is necessary for reading from a TTree / TChain (i.e. collection infos, branches, …)
Public Functions
-
inline CategoryInfo(std::unique_ptr<TChain> &&c)
constructor from chain for more convenient map insertion
Public Members
-
std::unique_ptr<TChain> chain = {nullptr}
The TChain with the data.
-
unsigned entry = {0}
The next entry to read.
-
std::vector<std::pair<std::string, detail::CollectionInfo>> storedClasses = {}
The stored collections in this category.
-
std::vector<root_utils::CollectionBranches> branches = {}
The branches for this category.
-
std::shared_ptr<CollectionIDTable> table = {nullptr}
The collection ID table for this category.
-
inline CategoryInfo(std::unique_ptr<TChain> &&c)
-
ROOTFrameReader() = default
-
class ROOTFrameReader