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");
76 this->fChain->SetBranchStatus(
"*",
false);
85 Value<T>* track_branch(
const std::string& bname){
86 TBranch* branch = fChain->GetBranch(bname.c_str());
87 if (branch ==
nullptr){
88 CRITICAL(
"Branch: " << bname <<
" does not exist in input tree.", -1);
90 T* bref = (T*) branch->GetAddress();
91 fChain->SetBranchStatus(bname.c_str(),
true);
92 INFO(
"Registering branch \"" << bname
93 <<
"\" with address " << bref
94 <<
" and type " <<
typeid(bref).name());
99 Value<T*>* track_branch_ptr(
const std::string& bname){
100 TBranch* branch = fChain->GetBranch(bname.c_str());
101 if (branch ==
nullptr){
102 CRITICAL(
"Branch: " << bname <<
" does not exist in input tree.", -1);
104 T* bref = (T*) branch->GetAddress();
105 fChain->SetBranchStatus(bname.c_str(),
true);
106 INFO(
"Registering pointer branch \"" << bname
107 <<
"\" with address " << bref
108 <<
" and type " <<
typeid(bref).name());
112 template <
typename T>
113 WrapperVector<T>* track_branch_vec(
const std::string& size_bname,
const std::string& bname){
114 track_branch_ptr<T>(bname);
115 return new WrapperVector<T>(lookup<int>(size_bname), lookup<T*>(bname), bname);
120 for(
auto container : containers){
121 container.second->save_as(
"outfile", SaveOption::ROOT);
125 std::map<string,string> value_lookup = this->get_container_name_value_map();
126 gDirectory->WriteObjectAny(&value_lookup,
"std::map<std::string,std::string>",
"_value_lookup");
128 std::map<string,string> fn_impl_lookup = this->get_function_name_impl_map();
129 gDirectory->WriteObjectAny(&fn_impl_lookup,
"std::map<std::string,std::string>",
"_function_impl_lookup");
132 #endif // minitreedataset_h A std::vector wrapper around a C-style array.
Definition: value.hpp:539
A value supplied by the dataset, not derived.
Definition: value.hpp:448
The namespace containing all filval classes and functions.
Definition: api.hpp:38
A generic value.
Definition: value.hpp:415
A Value of a pointer.
Definition: value.hpp:1131