example2.cpp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #include <iostream>
  2. #include <vector>
  3. #include <utility>
  4. #include "TFile.h"
  5. #include "TTree.h"
  6. #include "TCanvas.h"
  7. #include "filval/filval.hpp"
  8. #include "MiniTreeDataSet.hpp"
  9. void test2(){
  10. double x = 12;
  11. ObservedValue<double> x_val("x", &x);
  12. ContainerTH1D hist("h1", "Hist", &x_val, 20, 0, 20);
  13. hist.fill();
  14. hist.fill();
  15. hist.fill();
  16. x = 11;
  17. hist.fill();
  18. hist.fill();
  19. hist.fill();
  20. hist.fill();
  21. hist.fill();
  22. hist.fill();
  23. TH1D* h = (TH1D*) hist.get_container();
  24. TCanvas can("c1");
  25. h->Draw();
  26. can.Draw();
  27. can.SaveAs("outfile.png");
  28. }
  29. void test3(){
  30. TFile *f = TFile::Open("./data/TTTT_ext_treeProducerSusyMultilepton_tree.root");
  31. TTree *tree = (TTree*) f->Get("tree");
  32. MiniTreeDataSet mtds(tree);
  33. mtds.process();
  34. TCanvas can("c1");
  35. can.Clear();
  36. TH1* hist = ((ContainerTH1I*)mtds.get_container("nLepGood"))->get_container();
  37. hist->Draw();
  38. can.Draw();
  39. can.SaveAs("outfile.png");
  40. can.Clear();
  41. hist = ((ContainerTH1I*)mtds.get_container("nLepGood2"))->get_container();
  42. hist->Draw();
  43. can.Draw();
  44. can.SaveAs("outfile2.png");
  45. can.Clear();
  46. hist = ((ContainerTH1I*)mtds.get_container("nLepGood3"))->get_container();
  47. hist->Draw();
  48. can.Draw();
  49. can.SaveAs("outfile3.png");
  50. can.Clear();
  51. hist = ((ContainerTH1I*)mtds.get_container("avg_lepton_energy"))->get_container();
  52. hist->Draw();
  53. can.Draw();
  54. can.SaveAs("lepton_energy.png");
  55. can.Clear();
  56. TGraph* graph= ((ContainerTGraph*)mtds.get_container("nLepvsnJet"))->get_container();
  57. graph->Draw("A*");
  58. can.Draw();
  59. can.SaveAs("outfileGraph.png");
  60. delete tree;
  61. f->Close();
  62. delete f;
  63. }