File indexing completed on 2025-01-18 10:06:09
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 #include "TBranch.h"
0008
0009 #include <string>
0010 #include <tuple>
0011 #include <vector>
0012
0013 namespace podio {
0014 class CollectionBase;
0015
0016 namespace root_utils {
0017
0018
0019
0020
0021 using CollectionWriteInfoT = std::tuple<uint32_t, std::string, bool, unsigned int>;
0022
0023 using CollectionInfoWithoutSchemaT = std::tuple<int, std::string, bool>;
0024
0025
0026 using StoreCollection = std::tuple<const std::string&, podio::CollectionBase*>;
0027
0028
0029
0030
0031 struct CollectionBranches {
0032 CollectionBranches() = default;
0033 ~CollectionBranches() = default;
0034 CollectionBranches(const CollectionBranches&) = delete;
0035 CollectionBranches& operator=(const CollectionBranches&) = delete;
0036 CollectionBranches(CollectionBranches&&) = default;
0037 CollectionBranches& operator=(CollectionBranches&&) = default;
0038
0039 CollectionBranches(TBranch* dataBranch) : data(dataBranch) {
0040 }
0041
0042 TBranch* data{nullptr};
0043 std::vector<TBranch*> refs{};
0044 std::vector<TBranch*> vecs{};
0045 std::vector<std::string> refNames{};
0046 std::vector<std::string> vecNames{};
0047 };
0048
0049
0050
0051 template <typename T>
0052 struct ParamStorage {
0053 ParamStorage() = default;
0054 ~ParamStorage() = default;
0055 ParamStorage(const ParamStorage&) = delete;
0056 ParamStorage& operator=(const ParamStorage&) = delete;
0057 ParamStorage(ParamStorage&&) = default;
0058 ParamStorage& operator=(ParamStorage&&) = default;
0059
0060 ParamStorage(std::tuple<std::vector<std::string>, std::vector<std::vector<T>>> keysValues) :
0061 keys(std::move(std::get<0>(keysValues))), values(std::move(std::get<1>(keysValues))) {
0062 }
0063
0064
0065 auto keysPtr() {
0066 m_keysPtr = &keys;
0067 return &m_keysPtr;
0068 }
0069
0070
0071 auto valuesPtr() {
0072 m_valuesPtr = &values;
0073 return &m_valuesPtr;
0074 }
0075
0076 std::vector<std::string> keys{};
0077 std::vector<std::vector<T>> values{};
0078
0079 private:
0080 std::vector<std::string>* m_keysPtr{nullptr};
0081 std::vector<std::vector<T>>* m_valuesPtr{nullptr};
0082 };
0083
0084 GenericParameters
0085 loadParamsFrom(ROOT::VecOps::RVec<std::string> intKeys, ROOT::VecOps::RVec<std::vector<int>> intValues,
0086 ROOT::VecOps::RVec<std::string> floatKeys, ROOT::VecOps::RVec<std::vector<float>> floatValues,
0087 ROOT::VecOps::RVec<std::string> doubleKeys, ROOT::VecOps::RVec<std::vector<double>> doubleValues,
0088 ROOT::VecOps::RVec<std::string> stringKeys, ROOT::VecOps::RVec<std::vector<std::string>> stringValues);
0089
0090 }
0091 }
0092
0093 #endif