-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WIP] Make the TTree based ROOT backend store the GenericParameters t…
…he same way as the RNTuple based one (#615) * Refactor root utilities and reduce code duplication - Lift common type defs into one header to not redefine them - Keep all root related utilitie classes in one header * Rename CollectionInfo to CategoryInfo to better convey intention * Remove unnecessary member variables * Add functionality to get all values for a type to GenericParameters * Move some global state into category state * Avoid unnecessary copy * Fix include guards to conform to style guide * Make sure to take lock long enough * Switch to tuple for consistency * Remove obsolete reset * Make the ROOTWriter write split GenericParameters * Make the ROOTReader read the files again * Add tests to make sure that v00-99 files stay readable * Make older compilers happy with in place construction * Make sure to only run SIO legacy tests when input data is available * Make tests work by hiding forward declaration from CLING * Add comment for reasoning about excluding forward decl for CLING
- Loading branch information
Showing
20 changed files
with
380 additions
and
193 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
#ifndef PODIO_UTILITIES_ROOTHELPERS_H | ||
#define PODIO_UTILITIES_ROOTHELPERS_H | ||
|
||
#include "TBranch.h" | ||
|
||
#include <string> | ||
#include <tuple> | ||
#include <vector> | ||
|
||
namespace podio { | ||
class CollectionBase; | ||
|
||
namespace root_utils { | ||
|
||
// A collection of additional information that describes the collection: the | ||
// collectionID, the collection (data) type, whether it is a subset | ||
// collection, and its schema version | ||
using CollectionWriteInfoT = std::tuple<uint32_t, std::string, bool, unsigned int>; | ||
// for backwards compatibility | ||
using CollectionInfoWithoutSchemaT = std::tuple<int, std::string, bool>; | ||
|
||
/// A collection name and a base pointer grouped together for writing | ||
using StoreCollection = std::tuple<const std::string&, podio::CollectionBase*>; | ||
|
||
/// Small helper struct to collect all branches that are necessary to read or | ||
/// write a collection. Needed to cache the branch pointers and avoid having to | ||
/// get them from a TTree/TChain for every event. | ||
struct CollectionBranches { | ||
CollectionBranches() = default; | ||
~CollectionBranches() = default; | ||
CollectionBranches(const CollectionBranches&) = delete; | ||
CollectionBranches& operator=(const CollectionBranches&) = delete; | ||
CollectionBranches(CollectionBranches&&) = default; | ||
CollectionBranches& operator=(CollectionBranches&&) = default; | ||
|
||
CollectionBranches(TBranch* dataBranch) : data(dataBranch) { | ||
} | ||
|
||
TBranch* data{nullptr}; | ||
std::vector<TBranch*> refs{}; | ||
std::vector<TBranch*> vecs{}; | ||
std::vector<std::string> refNames{}; ///< The names of the relation branches | ||
std::vector<std::string> vecNames{}; ///< The names of the vector member branches | ||
}; | ||
|
||
/// Pair of keys and values for one type of the ones that can be stored in | ||
/// GenericParameters | ||
template <typename T> | ||
struct ParamStorage { | ||
ParamStorage() = default; | ||
~ParamStorage() = default; | ||
ParamStorage(const ParamStorage&) = delete; | ||
ParamStorage& operator=(const ParamStorage&) = delete; | ||
ParamStorage(ParamStorage&&) = default; | ||
ParamStorage& operator=(ParamStorage&&) = default; | ||
|
||
ParamStorage(const std::vector<std::string>& ks, const std::vector<std::vector<T>>& vs) : keys(ks), values(vs) { | ||
} | ||
|
||
auto keysPtr() { | ||
m_keysPtr = &keys; | ||
return &m_keysPtr; | ||
} | ||
|
||
auto valuesPtr() { | ||
m_valuesPtr = &values; | ||
return &m_valuesPtr; | ||
} | ||
|
||
std::vector<std::string> keys{}; | ||
std::vector<std::vector<T>> values{}; | ||
|
||
private: | ||
std::vector<std::string>* m_keysPtr{nullptr}; | ||
std::vector<std::vector<T>>* m_valuesPtr{nullptr}; | ||
}; | ||
|
||
} // namespace root_utils | ||
} // namespace podio | ||
|
||
#endif // PODIO_UTILITIES_ROOTHELPERS_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.