TTTT_Analysis.cpp 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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 "filval_root/filval_root.hpp"
  9. #include "MiniTreeDataSet.hpp"
  10. using namespace std;
  11. using namespace filval;
  12. using namespace filval::root;
  13. void print_pair(Pair<double, double> dp){
  14. pair<double, double> p = dp.get_value();
  15. cout << "(" << p.first << ", " << p.second << ")\n";
  16. }
  17. void test1(){
  18. double x = 12;
  19. double y = 12;
  20. ObservedValue<double> x_val("x", &x);
  21. ObservedValue<double> y_val("y", &y);
  22. Pair<double, double> dp("(x,y)", &x_val, &y_val);
  23. print_pair(dp);
  24. x = 2;
  25. y = 2;
  26. print_pair(dp);
  27. ContainerVector<double> cont(&x_val, "cont");
  28. x = 12;
  29. cont.fill();
  30. x = 2;
  31. cont.fill();
  32. auto *container = cont.get_container();
  33. for( auto v: *container )
  34. cout << v << ", ";
  35. cout << endl;
  36. }
  37. void test2(){
  38. double x = 12;
  39. ObservedValue<double> x_val("x", &x);
  40. ContainerTH1D hist("h1", "Hist", 20, 0, 20, &x_val);
  41. hist.fill();
  42. hist.fill();
  43. hist.fill();
  44. x = 11;
  45. hist.fill();
  46. hist.fill();
  47. hist.fill();
  48. hist.fill();
  49. hist.fill();
  50. hist.fill();
  51. TH1D* h = (TH1D*) hist.get_container();
  52. TCanvas can("c1");
  53. h->Draw();
  54. can.Draw();
  55. can.SaveAs("outfile.png");
  56. }
  57. void test3(){
  58. TFile *f = TFile::Open("./data/TTTT_ext_treeProducerSusyMultilepton_tree.root");
  59. TTree *tree = (TTree*) f->Get("tree");
  60. MiniTreeDataSet mtds(tree);
  61. mtds.process();
  62. TCanvas can("c1");
  63. can.Clear();
  64. TH1* hist = ((ContainerTH1I*)mtds.get_container("nLepGood"))->get_container();
  65. hist->Draw();
  66. can.Draw();
  67. can.SaveAs("outfile.png");
  68. can.Clear();
  69. hist = ((ContainerTH1I*)mtds.get_container("nLepGood2"))->get_container();
  70. hist->Draw();
  71. can.Draw();
  72. can.SaveAs("outfile2.png");
  73. can.Clear();
  74. hist = ((ContainerTH1I*)mtds.get_container("nLepGood3"))->get_container();
  75. hist->Draw();
  76. can.Draw();
  77. can.SaveAs("outfile3.png");
  78. can.Clear();
  79. hist = ((ContainerTH1I*)mtds.get_container("avg_lepton_energy"))->get_container();
  80. hist->Draw();
  81. can.Draw();
  82. can.SaveAs("lepton_energy.png");
  83. can.Clear();
  84. TGraph* graph= ((ContainerTGraph*)mtds.get_container("nLepvsnJet"))->get_container();
  85. graph->Draw("A*");
  86. can.Draw();
  87. can.SaveAs("outfileGraph.png");
  88. delete tree;
  89. f->Close();
  90. delete f;
  91. }
  92. int main(int argc, const char* argv[]){
  93. test3();
  94. }