File indexing completed on 2025-09-18 09:25:08
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 struct CollectionWriteInfo {
0022 uint32_t collectionID{static_cast<uint32_t>(-1)};
0023 std::string dataType{};
0024 bool isSubset{false};
0025 unsigned int schemaVersion{0};
0026 std::string name{};
0027 std::string storageType{};
0028 };
0029
0030 using CollectionWriteInfoT = std::tuple<uint32_t, std::string, bool, unsigned int>;
0031
0032
0033 using CollectionInfoWithoutSchemaT = std::tuple<int, std::string, bool>;
0034
0035
0036 using StoreCollection = std::tuple<const std::string&, podio::CollectionBase*>;
0037
0038
0039
0040
0041 struct CollectionBranches {
0042 CollectionBranches() = default;
0043 ~CollectionBranches() = default;
0044 CollectionBranches(const CollectionBranches&) = delete;
0045 CollectionBranches& operator=(const CollectionBranches&) = delete;
0046 CollectionBranches(CollectionBranches&&) = default;
0047 CollectionBranches& operator=(CollectionBranches&&) = default;
0048
0049 CollectionBranches(TBranch* dataBranch) : data(dataBranch) {
0050 }
0051
0052 TBranch* data{nullptr};
0053 std::vector<TBranch*> refs{};
0054 std::vector<TBranch*> vecs{};
0055 std::vector<std::string> refNames{};
0056 std::vector<std::string> vecNames{};
0057 };
0058
0059
0060
0061 template <typename T>
0062 struct ParamStorage {
0063 ParamStorage() = default;
0064 ~ParamStorage() = default;
0065 ParamStorage(const ParamStorage&) = delete;
0066 ParamStorage& operator=(const ParamStorage&) = delete;
0067 ParamStorage(ParamStorage&&) = default;
0068 ParamStorage& operator=(ParamStorage&&) = default;
0069
0070 ParamStorage(std::tuple<std::vector<std::string>, std::vector<std::vector<T>>> keysValues) :
0071 keys(std::move(std::get<0>(keysValues))), values(std::move(std::get<1>(keysValues))) {
0072 }
0073
0074
0075 auto keysPtr() {
0076 m_keysPtr = &keys;
0077 return &m_keysPtr;
0078 }
0079
0080
0081 auto valuesPtr() {
0082 m_valuesPtr = &values;
0083 return &m_valuesPtr;
0084 }
0085
0086 std::vector<std::string> keys{};
0087 std::vector<std::vector<T>> values{};
0088
0089 private:
0090 std::vector<std::string>* m_keysPtr{nullptr};
0091 std::vector<std::vector<T>>* m_valuesPtr{nullptr};
0092 };
0093
0094 GenericParameters
0095 loadParamsFrom(ROOT::VecOps::RVec<std::string> intKeys, ROOT::VecOps::RVec<std::vector<int>> intValues,
0096 ROOT::VecOps::RVec<std::string> floatKeys, ROOT::VecOps::RVec<std::vector<float>> floatValues,
0097 ROOT::VecOps::RVec<std::string> doubleKeys, ROOT::VecOps::RVec<std::vector<double>> doubleValues,
0098 ROOT::VecOps::RVec<std::string> stringKeys, ROOT::VecOps::RVec<std::vector<std::string>> stringValues);
0099
0100 }
0101 }
0102
0103 #endif