1 #ifndef minitreedataset_h 2 #define minitreedataset_h 7 #include "filval/filval.hpp" 8 #include "filval_root/filval_root.hpp" 9 #include "MiniTree.hpp" 21 if (next_entry >= nentries)
return false;
22 fChain->GetEntry(next_entry);
29 int get_current_event(){
33 void enable_branches(){
34 fChain->SetBranchStatus(
"*",
false);
35 track_branch<int>(
"nJet");
36 track_branch<int>(
"nLepGood");
37 track_branch_ptr<float>(
"LepGood_pt");
38 track_branch_ptr<float>(
"LepGood_eta");
39 track_branch_ptr<float>(
"LepGood_phi");
40 track_branch_ptr<float>(
"LepGood_mass");
46 auto lookup = [](
const string& name){
return GenValue::get_value(name);};
47 auto lookup_filter = [](
const string& name){
return dynamic_cast<Filter*
>(GenValue::get_value(name));};
48 auto mean = [](vector<float> v){
55 return n>0 ? sum / n : 0;
63 auto get_energy = [](
float pt,
float eta,
float phi,
float m){
65 t.SetPtEtaPhiM(pt, eta, phi, m);
70 new Reduce<float>(
"avg_lepton_energy", mean ,
"lepton_energy");
73 new Filter(
"nLepGood>=3", [nLepGood=lookup(
"nLepGood")](){
74 return dynamic_cast<Value<int>*
>(nLepGood)->get_value() >=3;});
76 new Filter(
"nLepGood<=4", [nLepGood=lookup(
"nLepGood")](){
77 return dynamic_cast<Value<int>*
>(nLepGood)->get_value() <=4;});
81 add_container(
new ContainerTH1I(
"nLepGood",
"Lepton Multiplicity", 10, 0, 10, lookup(
"nLepGood")));
83 add_container(
new ContainerTH1I(
"nLepGood2",
"Lepton Multiplicity", 10, 0, 10, lookup(
"nLepGood")));
84 containers.at(
"nLepGood2")->add_filter(lookup_filter(
"3<=nLepGood<5"));
86 add_container(
new ContainerTH1I(
"nLepGood3",
"Lepton Multiplicity", 10, 0, 10, lookup(
"nLepGood")));
87 containers.at(
"nLepGood3")->add_filter(!(*lookup_filter(
"3<=nLepGood<5")));
90 add_container(
new ContainerTGraph(
"nLepvsnJet", lookup(
"(nLepGood,nJet)")));
92 add_container(
new ContainerTH1F(
"avg_lepton_energy",
"Average Lepton Energy", 50, 0, 500, lookup(
"avg_lepton_energy")));
93 add_container(
new ContainerTH1F(
"max_lepton_energy",
"Maximum Lepton Energy", 50, 0, 500, lookup(
"max_lepton_energy")));
96 nentries = fChain->GetEntriesFast();
100 Value<T>* track_branch(
const std::string& bname){
101 T* bref = (T*) fChain->GetBranch(bname.c_str())->GetAddress();
102 fChain->SetBranchStatus(bname.c_str(),
true);
103 cout <<
"Registering branch \"" << bname
104 <<
"\" with address " << bref
105 <<
" and type " <<
typeid(bref).name() << endl;
109 template <
typename T>
110 Value<T*>* track_branch_ptr(
const std::string& bname){
111 T* bref = (T*) fChain->GetBranch(bname.c_str())->GetAddress();
112 fChain->SetBranchStatus(bname.c_str(),
true);
113 cout <<
"Registering pointer branch \"" << bname
114 <<
"\" with address " << bref
115 <<
" and type " <<
typeid(bref).name() << endl;
120 containers[container->get_name()] = container;
140 #endif // minitreedataset_h Definition: container.hpp:10
Definition: filter.hpp:43
A Value which always returns the same value, supplied in the constructor.
Definition: value.hpp:481
The namespace containing all filval classes and functions.
Definition: container.hpp:7
Definition: MiniTreeDataSet.hpp:15
A std::vector wrapper around a C-style array.
Definition: value.hpp:218
Definition: MiniTree.hpp:18
Creates a std::pair type from a two other Value objects.
Definition: value.hpp:247
Definition: container.hpp:8
Takes a set of four Value<std::vector<T> > objects and a function of four Ts and returns a std::vecto...
Definition: value.hpp:278
Definition: container.hpp:34
Definition: container.hpp:43
Definition: container.hpp:89
Reduce a Value of type vector<T> to just a T.
Definition: value.hpp:325
A generic, observed, value.
Definition: value.hpp:144
Definition: filter.hpp:12
Definition: dataset.hpp:8