StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
doErrorRatio.C
1 void doErrorRatio(char *file,char *fileplus,char *filemin){
2 
3  TFile *f_nom=new TFile(file,"OPEN");
4  TFile *f_plus=new TFile(fileplus,"OPEN");
5  TFile *f_min=new TFile(filemin,"OPEN");
6  TH1F *h_nom=(TH1F*)f_nom->Get("gamma");
7  TH1F *h_plus=(TH1F*)f_plus->Get("gamma");
8  TH1F *h_min=(TH1F*)f_min->Get("gamma");
9 
10  for(Int_t i=1;i<=h_nom->GetNbinsX();i++){
11  Float_t error=fabs(h_plus->GetBinContent(i)-h_min->GetBinContent(i))/2.;
12  cout<<i<<" err: "<<error<<endl;
13  h_nom->SetBinError(i,error);
14  }
15 
16  TCanvas *c=new TCanvas("c","c",400,300);
17  TH1F *h_divplus=new TH1F(*h_plus);
18  h_divplus->Divide(h_nom);
19  h_divplus->SetLineColor(4);
20  h_divplus->SetLineWidth(2);
21  h_divplus->SetMaximum(1.1);
22  h_divplus->SetMinimum(.9);
23  h_divplus->SetTitle("error on ratio from fit;p_{T}");
24  h_divplus->Draw("hist");
25  TH1F *h_divmin=new TH1F(*h_min);
26  h_divmin->Divide(h_nom);
27  h_divmin->SetLineColor(4);
28  h_divmin->SetLineWidth(2);
29  h_divmin->Draw("histsame");
30  c->SaveAs("gammaDecayWithErrors2sigma.root");
31  c->SaveAs("gammaDecayWithErrors2sigma.pdf");
32 
33 }