TTTT_Analysis.cpp 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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(DerivedPair<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);
  21. ObservedValue<double> y_val(&y);
  22. DerivedPair<double, double> dp(&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);
  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. TH1* hist = ((ContainerTH1I*)mtds.get_container("nLepGood"))->get_container();
  63. TCanvas can("c1");
  64. hist->Draw();
  65. can.Draw();
  66. can.SaveAs("outfile.png");
  67. can.Clear();
  68. TGraph* graph= ((ContainerTGraph*)mtds.get_container("nLepvsnJet"))->get_container();
  69. graph->Draw("A*");
  70. can.Draw();
  71. can.SaveAs("outfile3.png");
  72. delete tree;
  73. f->Close();
  74. delete f;
  75. }
  76. int main(int argc, const char* argv[]){
  77. test3();
  78. }