1#ifndef FIRE_IO_ROOT_READER_H_
2#define FIRE_IO_ROOT_READER_H_
10#include "fire/io/Reader.h"
11#include "fire/exception/Exception.h"
116 template <
typename DataType>
121 if (attached_.find(branch_name) == attached_.end()) {
123 if (branch_name ==
"RunHeader") tree =
run_tree_;
124 attached_[branch_name] =
attach(tree,branch_name,obj);
126 if (attached_[branch_name]->GetEntry(attached_[branch_name]->GetReadEntry()+1) < 0) {
128 "ROOT was unable to deserialize the branch "+branch_name
129 +
" into the passed type "
130 +boost::core::demangle(
typeid(DataType).
name())
131 +
".\n This error is usually caused by not providing the correct"
132 " ROOT dictionary for the type you are attempting to read.",
false);
169 TBranch* br = tree->GetBranch(branch_name.
c_str());
172 "Branch "+branch_name+
" not found in input ROOT file.");
175 br->SetAddress(&obj);
Standard base exception class with some useful output information.
Definition: Exception.h:18
Empty data base allowing recursion.
Definition: AbstractData.h:30
Prototype for reading files within fire.
Definition: Reader.h:29
Reading ROOT files into our data structures.
Definition: Reader.h:29
virtual std::pair< std::string, int > type(const std::string &path) final override
Get the type of the input object.
Definition: Reader.cxx:58
TBranch * attach(TTree *tree, const std::string &branch_name, T &obj)
Attach the input object to the TTree on the given branch.
Definition: Reader.h:168
void load(const std::string &name, DataType &obj)
Load the data at the input name into the input object.
Definition: Reader.h:117
static std::string transform(const std::string &dir_name)
pull out pass and object name, construct branch name
Definition: Reader.cxx:96
virtual void load_into(BaseData &d) final override
Following the instructions in fire::io::Reader, we simply call the BaseData's load function.
Definition: Reader.cxx:40
virtual std::size_t runs() const final override
Number of runs in the file.
Definition: Reader.cxx:92
virtual std::size_t entries() const final override
Number of entries in the file.
Definition: Reader.cxx:88
void operator=(const Reader &)=delete
no copy assignment of readers
virtual std::vector< std::pair< std::string, std::string > > availableObjects() final override
Get the event objects available in the file.
Definition: Reader.cxx:44
Reader(const Reader &)=delete
no copy constructor of readers
TFile * file_
file being read
Definition: Reader.h:184
TTree * run_tree_
tree of runs in the file
Definition: Reader.h:188
virtual std::string name() const final override
Get the name of the file.
Definition: Reader.cxx:84
TTree * event_tree_
tree of events in the file
Definition: Reader.h:186
Reader(const std::string &file_name)
open input file for reading
Definition: Reader.cxx:13
Reading of ROOT TTree files generated by ROOT-based Framework.
Definition: Reader.h:20