Warning, file /include/podio/RNTupleReader.h was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 #ifndef PODIO_RNTUPLEREADER_H
0002 #define PODIO_RNTUPLEREADER_H
0003
0004 #include "podio/ROOTFrameData.h"
0005 #include "podio/podioVersion.h"
0006 #include "podio/utilities/DatamodelRegistryIOHelpers.h"
0007 #include "podio/utilities/RootHelpers.h"
0008
0009 #include <string>
0010 #include <string_view>
0011 #include <unordered_map>
0012 #include <vector>
0013
0014 #include <ROOT/RNTuple.hxx>
0015 #include <ROOT/RNTupleReader.hxx>
0016 #include <RVersion.h>
0017
0018 namespace podio {
0019
0020
0021
0022 namespace root_compat {
0023 #if ROOT_VERSION_CODE < ROOT_VERSION(6, 35, 0)
0024 using RNTupleReader = ROOT::Experimental::RNTupleReader;
0025 #else
0026 using RNTupleReader = ROOT::RNTupleReader;
0027 #endif
0028 }
0029
0030
0031
0032
0033
0034
0035 class RNTupleReader {
0036
0037 public:
0038
0039 RNTupleReader() = default;
0040
0041 ~RNTupleReader() = default;
0042
0043 RNTupleReader(const RNTupleReader&) = delete;
0044
0045 RNTupleReader& operator=(const RNTupleReader&) = delete;
0046
0047
0048
0049
0050 void openFile(const std::string& filename);
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063 void openFiles(const std::vector<std::string>& filenames);
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077 std::unique_ptr<podio::ROOTFrameData> readNextEntry(const std::string& name,
0078 const std::vector<std::string>& collsToRead = {});
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092 std::unique_ptr<podio::ROOTFrameData> readEntry(const std::string& name, const unsigned entry,
0093 const std::vector<std::string>& collsToRead = {});
0094
0095
0096
0097
0098 std::vector<std::string_view> getAvailableCategories() const;
0099
0100
0101
0102
0103
0104
0105 unsigned getEntries(const std::string& name) const;
0106
0107
0108
0109
0110
0111 podio::version::Version currentFileVersion() const {
0112 return m_fileVersion;
0113 }
0114
0115
0116
0117
0118
0119
0120
0121
0122 std::optional<podio::version::Version> currentFileVersion(const std::string& name) const {
0123 return m_datamodelHolder.getDatamodelVersion(name);
0124 }
0125
0126
0127
0128
0129
0130
0131 const std::string_view getDatamodelDefinition(const std::string& name) const {
0132 return m_datamodelHolder.getDatamodelDefinition(name);
0133 }
0134
0135
0136
0137
0138 std::vector<std::string> getAvailableDatamodels() const {
0139 return m_datamodelHolder.getAvailableDatamodels();
0140 }
0141
0142 private:
0143
0144
0145
0146
0147 bool initCategory(const std::string& category);
0148
0149
0150
0151
0152 GenericParameters readEventMetaData(const std::string& name, const unsigned localEntry, const unsigned readerIndex);
0153
0154 template <typename T>
0155 void readParams(const std::string& name, const unsigned entNum, const unsigned readerIndex,
0156 GenericParameters& params);
0157
0158 std::unique_ptr<root_compat::RNTupleReader> m_metadata{};
0159
0160 podio::version::Version m_fileVersion{};
0161 DatamodelDefinitionHolder m_datamodelHolder{};
0162
0163 std::unordered_map<std::string, std::vector<std::unique_ptr<root_compat::RNTupleReader>>> m_readers{};
0164 std::unordered_map<std::string, std::unique_ptr<root_compat::RNTupleReader>> m_metadata_readers{};
0165 std::vector<std::string> m_filenames{};
0166
0167 std::unordered_map<std::string, unsigned> m_entries{};
0168
0169
0170
0171
0172 std::unordered_map<std::string, std::vector<unsigned>> m_readerEntries{};
0173 std::unordered_map<std::string, unsigned> m_totalEntries{};
0174
0175
0176 std::unordered_map<std::string, std::vector<podio::root_utils::CollectionWriteInfo>> m_collectionInfo{};
0177
0178 std::vector<std::string> m_availableCategories{};
0179
0180 std::unordered_map<std::string, std::shared_ptr<podio::CollectionIDTable>> m_idTables{};
0181 };
0182
0183 }
0184
0185 #endif