31 #ifndef minitreedataset_h 32 #define minitreedataset_h 37 #include "filval/filval.hpp" 38 #include "filval_root/filval_root.hpp" 45 class MiniTreeDataSet :
public DataSet,
48 std::string input_filename;
49 std::string output_filename;
55 if (next_entry >= nentries)
return false;
56 fChain->GetEntry(next_entry);
63 int get_current_event(){
68 MiniTreeDataSet(
const std::string& input_filename,
const std::string output_filename)
69 :input_filename(input_filename),
70 output_filename(output_filename),
72 input_file = TFile::Open(input_filename.c_str());
73 Init((TTree*) input_file->Get(
"tree"));
74 nentries = fChain->GetEntriesFast();
75 output_file = TFile::Open(output_filename.c_str(),
"RECREATE");
84 Value<T>* track_branch(
const std::string& bname){
85 TBranch* branch = fChain->GetBranch(bname.c_str());
86 if (branch ==
nullptr){
87 CRITICAL(
"Branch: " << bname <<
" does not exist in input tree.", -1);
89 T* bref = (T*) branch->GetAddress();
90 fChain->SetBranchStatus(bname.c_str(),
true);
91 INFO(
"Registering branch \"" << bname
92 <<
"\" with address " << bref
93 <<
" and type " <<
typeid(bref).name());
98 Value<T*>* track_branch_ptr(
const std::string& bname){
99 TBranch* branch = fChain->GetBranch(bname.c_str());
100 if (branch ==
nullptr){
101 CRITICAL(
"Branch: " << bname <<
" does not exist in input tree.", -1);
103 T* bref = (T*) branch->GetAddress();
104 fChain->SetBranchStatus(bname.c_str(),
true);
105 INFO(
"Registering pointer branch \"" << bname
106 <<
"\" with address " << bref
107 <<
" and type " <<
typeid(bref).name());
111 template <
typename T>
112 WrapperVector<T>* track_branch_vec(
const std::string& size_bname,
const std::string& bname){
113 track_branch_ptr<T>(bname);
114 return new WrapperVector<T>(lookup<int>(size_bname), lookup<T*>(bname), bname);
119 for(
auto container : containers){
120 container.second->save_as(
"outfile", SaveOption::ROOT);
124 #endif // minitreedataset_h A std::vector wrapper around a C-style array.
Definition: value.hpp:446
A value supplied by the dataset, not derived.
Definition: value.hpp:372
The namespace containing all filval classes and functions.
Definition: api.hpp:6
A generic value.
Definition: value.hpp:352
A Value of a pointer.
Definition: value.hpp:923