File indexing completed on 2026-11-18 10:42:34
0001 #ifndef PODIO_UTILITIES_ROOTHELPERS_H
0002 #define PODIO_UTILITIES_ROOTHELPERS_H
0003
0004 #include "podio/GenericParameters.h"
0005
0006 #include "ROOT/RVec.hxx"
0007
0008 #include <cstdint>
0009 #include <string>
0010 #include <tuple>
0011 #include <utility>
0012 #include <vector>
0013
0014 class TBranch;
0015
0016 namespace podio {
0017 class CollectionBase;
0018
0019 namespace root_utils {
0020
0021
0022
0023
0024 struct CollectionWriteInfo {
0025 uint32_t collectionID{static_cast<uint32_t>(-1)};
0026 std::string dataType{};
0027 bool isSubset{false};
0028 unsigned int schemaVersion{0};
0029 std::string name{};
0030 std::string storageType{};
0031 };
0032
0033 using CollectionWriteInfoT = std::tuple<uint32_t, std::string, bool, unsigned int>;
0034
0035
0036 using CollectionInfoWithoutSchemaT = std::tuple<int, std::string, bool>;
0037
0038
0039 using StoreCollection = std::tuple<const std::string&, podio::CollectionBase*>;
0040
0041
0042
0043
0044 struct CollectionBranches {
0045 CollectionBranches() = default;
0046 ~CollectionBranches() = default;
0047 CollectionBranches(const CollectionBranches&) = delete;
0048 CollectionBranches& operator=(const CollectionBranches&) = delete;
0049 CollectionBranches(CollectionBranches&&) = default;
0050 CollectionBranches& operator=(CollectionBranches&&) = default;
0051
0052 CollectionBranches(TBranch* dataBranch) : data(dataBranch) {
0053 }
0054
0055 TBranch* data{nullptr};
0056 std::vector<TBranch*> refs{};
0057 std::vector<TBranch*> vecs{};
0058 std::vector<std::string> refNames{};
0059 std::vector<std::string> vecNames{};
0060 };
0061
0062
0063
0064 template <typename T>
0065 struct ParamStorage {
0066 ParamStorage() = default;
0067 ~ParamStorage() = default;
0068 ParamStorage(const ParamStorage&) = delete;
0069 ParamStorage& operator=(const ParamStorage&) = delete;
0070 ParamStorage(ParamStorage&&) = default;
0071 ParamStorage& operator=(ParamStorage&&) = default;
0072
0073 ParamStorage(std::tuple<std::vector<std::string>, std::vector<std::vector<T>>> keysValues) :
0074 keys(std::move(std::get<0>(keysValues))), values(std::move(std::get<1>(keysValues))) {
0075 }
0076
0077
0078 auto keysPtr() {
0079 m_keysPtr = &keys;
0080 return &m_keysPtr;
0081 }
0082
0083
0084 auto valuesPtr() {
0085 m_valuesPtr = &values;
0086 return &m_valuesPtr;
0087 }
0088
0089 std::vector<std::string> keys{};
0090 std::vector<std::vector<T>> values{};
0091
0092 private:
0093 std::vector<std::string>* m_keysPtr{nullptr};
0094 std::vector<std::vector<T>>* m_valuesPtr{nullptr};
0095 };
0096
0097 GenericParameters
0098 loadParamsFrom(ROOT::VecOps::RVec<std::string> intKeys, ROOT::VecOps::RVec<std::vector<int>> intValues,
0099 ROOT::VecOps::RVec<std::string> floatKeys, ROOT::VecOps::RVec<std::vector<float>> floatValues,
0100 ROOT::VecOps::RVec<std::string> doubleKeys, ROOT::VecOps::RVec<std::vector<double>> doubleValues,
0101 ROOT::VecOps::RVec<std::string> stringKeys, ROOT::VecOps::RVec<std::vector<std::string>> stringValues);
0102
0103 }
0104 }
0105
0106 #endif