DESY Hbb Analysis Framework
Workflow.cc
Go to the documentation of this file.
1 #include <string>
2 #include <iostream>
3 #include <vector>
4 
5 #include "TFile.h"
6 #include "TH1.h"
7 
8 
9 // =============================================================================================
10 int main(int argc, char * argv[])
11 {
12  if ( argc <= 1 ) return -1;
13 
14  const char * rootfile = argv[1];
15 
16  TFile f(rootfile,"old");
17 
18  TH1F * h = (TH1F*) f.Get("workflow");
19 
20 
21  printf("+%s+\n", std::string(170,'-').c_str());
22  printf("| %-108s | %10s | %16s | %16s |\n",h->GetTitle(),"n events","ratio wrt first","ratio wrt previous");
23  printf("+%s+\n", std::string(170,'-').c_str());
24  int firstbin = 2;
25  for ( int i = 1; i <= h ->GetNbinsX(); ++i )
26  {
27  std::string label = std::string(h->GetXaxis()->GetBinLabel(i));
28  if ( label == "" ) continue;
29 // if ( firstbin < 0 ) firstbin = i;
30  float n = h->GetBinContent(i);
31  float rn1 = h->GetBinContent(i)/h->GetBinContent(firstbin);
32  float rni = 0;
33  if ( i == 1 )
34  {
35  printf("| %2d - %-103s | %10.1f | %16s | %19s |\n",i-1,label.c_str(),n,"-","-");
36  }
37  else if ( i == 2 )
38  {
39  printf("| %2d - %-103s | %10.1f | %16.6f | %19s |\n",i-1,label.c_str(),n,rn1,"-");
40  }
41  else
42  {
43  rni = h-> GetBinContent(i)/h->GetBinContent(i-1);
44  printf("| %2d - %-103s | %10.1f | %16.6f | %16.6f |\n",i-1,label.c_str(),n,rn1,rni);
45  }
46 
47  }
48  printf("+%s+\n", std::string(170,'-').c_str());
49 
50  return 0;
51 
52 }
53 
TH1F * h[10]
Definition: PlotsCompare.cc:25
TFile * f[10]
Definition: PlotsCompare.cc:24
int main(int argc, char *argv[])
Definition: Workflow.cc:10