MiniTreeDataSet.hpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #ifndef minitreedataset_h
  2. #define minitreedataset_h
  3. #include <string>
  4. #include "filval/filval.hpp"
  5. #include "filval_root/filval_root.hpp"
  6. #include "MiniTree.hpp"
  7. using namespace filval;
  8. using namespace filval::root;
  9. class MiniTreeDataSet : public filval::DataSet,
  10. public MiniTree{
  11. private:
  12. template <typename T>
  13. void track_branch(const std::string bname, T *bval){
  14. values[bname] = new filval::ObservedValue<T>(bval);
  15. fChain->SetBranchStatus(bname.c_str(), true);
  16. }
  17. long next_entry;
  18. long nentries;
  19. bool load_next(){
  20. if (next_entry >= nentries) return false;
  21. fChain->GetEntry(next_entry);
  22. ++next_entry;
  23. return true;
  24. }
  25. public:
  26. MiniTreeDataSet(TTree *tree)
  27. :MiniTree(tree){
  28. fChain->SetBranchStatus("*", false);
  29. track_branch<int>("nLepGood", &nLepGood);
  30. track_branch<int>("nJet", &nJet);
  31. add_value(new FilterGreaterThan<int>(values["nLepGood"], 3), "nLepGoodCut");
  32. add_container(new ContainerTH1I("nLepGood", "Lepton Multiplicity", 10, 0, 10, values["nLepGood"]));
  33. add_container(new ContainerTH1I("nLepGood2", "Lepton Multiplicity", 10, 0, 10, values["nLepGood"]));
  34. containers["nLepGood2"]->add_filter(values["nLepGoodCut"]);
  35. add_value(new DerivedPair<int, int>(&values, "nLepGood", "nJet"), "nLepvsnJet");
  36. add_container(new ContainerTGraph("nLepvsnJet", values["nLepvsnJet"]));
  37. next_entry = 0;
  38. nentries = fChain->GetEntriesFast();
  39. }
  40. void register_container(GenContainer* container){
  41. containers[container->get_name()] = container;
  42. }
  43. };
  44. #endif // minitreedataset_h