5 #include <unordered_map> 18 #include "TDirectory.h" 19 #include "TDirectoryFile.h" 24 std::size_t
operator()(
const std::filesystem::path& path)
const {
25 return std::filesystem::hash_value(path);
28 using DirectoryMap = std::unordered_map<std::filesystem::path, TDirectory*, PathHash>;
31 void writeObject( TDirectory* file,
const std::string_view& name,
const T& obj) {
35 if constexpr (!std::is_same_v<decltype(
toRoot6(obj,name)), decltype(
nullptr)>) {
38 std::string(name).c_str()
48 void StoreWriter::writeSelection(
53 TFile root(_path.string().c_str(),
"UPDATE");
58 if(!h.valid()) {
continue; }
60 const std::type_index type = key.
type;
61 std::string path = std::filesystem::relative(key.
path,
"/").remove_filename().string();
64 const char* c_path = path.c_str();
65 TDirectory *file = root.GetDirectory(c_path);
68 file = root.GetDirectory(c_path);
74 if (type == std::type_index(
typeid(
types::H1F))) {
75 writeObject<types::H1F>(file, key.
path.filename().string(), h.handle<
types::H1F>().merged());
76 }
else if (type == std::type_index(
typeid(
types::H1D))){
77 writeObject<types::H1D>(file, key.
path.filename().string(), h.handle<
types::H1D>().merged());
78 }
else if (type == std::type_index(
typeid(
types::H1I))){
79 writeObject<types::H1I>(file, key.
path.filename().string(), h.handle<
types::H1I>().merged());
80 }
else if (type == std::type_index(
typeid(
types::H2F))){
81 writeObject<types::H2F>(file, key.
path.filename().string(), h.handle<
types::H2F>().merged());
82 }
else if (type == std::type_index(
typeid(
types::H2D))){
83 writeObject<types::H2D>(file, key.
path.filename().string(), h.handle<
types::H2D>().merged());
84 }
else if (type == std::type_index(
typeid(
types::H2I))){
85 writeObject<types::H2I>(file, key.
path.filename().string(), h.handle<
types::H2I>().merged());
86 }
else if (type == std::type_index(
typeid(
types::H3F))){
87 writeObject<types::H3F>(file, key.
path.filename().string(), h.handle<
types::H3F>().merged());
88 }
else if (type == std::type_index(
typeid(
types::H3D))){
89 writeObject<types::H3D>(file, key.
path.filename().string(), h.handle<
types::H3D>().merged());
90 }
else if (type == std::type_index(
typeid(
types::H3I))){
91 writeObject<types::H3I>(file, key.
path.filename().string(), h.handle<
types::H3I>().merged());
Data selection to identify and manage an Entry.
#define MARLIN_BOOK_THROW(message)
std::filesystem::path path
virtual Entry path
Generalized histogram class.
Wrapper for weak pointer to Entry.
std::size_t operator()(const std::filesystem::path &path) const
void writeObject(TDirectory *file, const std::string_view &name, const T &obj)
auto toRoot6(const HistT< Config > &hist, const std::string_view &name)
convert histogram to Root-6 Object for serialization
Contains references to entries.
std::unordered_map< std::filesystem::path, TDirectory *, PathHash > DirectoryMap
std::type_index type
Type of object stored in Entry.