plots_total.C
Go to the documentation of this file.
1 {
2  const int nexp=1000;
3  TFile *file=new TFile("gsimple_nue_newflux.root");
4  TH1F *hnorm=(TH1F*)file->Get("Enorm");
5 
6  TH1F *hweighted[nexp];
7  for( int i=1; i<nexp+1; ++i ){
8  TString tot_name=Form("Eweight_%i",i);
9  hweighted[i-1]=(TH1F*)file->Get(tot_name);
10  }
11  //hweighted[0]->Draw();
12 
13  float finalweight[40][nexp];
14  for( int ibin=1; ibin<hnorm->GetNbinsX()+1; ++ibin ){
15  for( int j=0; j<nexp; ++j ){
16  float den=hnorm->GetBinContent(ibin);
17  float num=hweighted[j]->GetBinContent(ibin);
18  float weight=0.;
19  cout<<j<<" "<<num<<" "<<den<<endl;
20  if( den>0.0 ) weight=num/den;
21  finalweight[ibin-1][j]=weight;
22  }//loop 100 weighted hists
23  }//loop energy bins
24 
25 
26  TH1F *finalweight_hists[40];
27  for( int i=0; i<40; ++i ){
28  TString name=Form("finalweight_Ebin_%i",i);
29  finalweight_hists[i]=new TH1F(name,"",200,0,2);
30  finalweight_hists[i]->Sumw2();
31  for( int j=0; j<nexp; ++j ){
32  finalweight_hists[i]->Fill(finalweight[i][j]);
33  }//loop 100 items
34 
35  }//loop 40 hists
36 
37  //saving mean weight and corresponding RMS
38  float weightMean[40]={0.};
39  float weightErr[40]={0.};
40  TH1F *hmean=new TH1F("hmean","",40,0,10);
41  for( int i=0; i<40; ++i ){
42  weightMean[i]=finalweight_hists[i]->GetMean();
43  weightErr[i]=finalweight_hists[i]->GetRMS();
44  hmean->SetBinContent(i+1,finalweight_hists[i]->GetMean());
45  hmean->SetBinError(i+1,0.);
46 
47  cout<<i*0.25<<" - "<<(i+1)*0.25<<": ";
48  cout<<finalweight_hists[i]->GetMean()<<" "<<finalweight_hists[i]->GetRMS()<<" ratio is "<<finalweight_hists[i]->GetRMS()/finalweight_hists[i]->GetMean()<<endl;
49  }//
50  TBox *errband[40];
51  for( int i=0; i<40; ++i ){
52  float xlow=i*0.25;
53  float xhigh=(i+1.0)*0.25;
54  float ylow=-1.*weightErr[i]/weightMean[i];
55  float yhigh=weightErr[i]/weightMean[i];
56  errband[i]=new TBox(xlow,ylow,xhigh,yhigh);
57  }
58 
59  gStyle->SetOptStat(0);
60  TCanvas *c1=new TCanvas("fluxweight_total","",700,600);
61  c1->cd();
62  TH2F *h2f=new TH2F("h2f","Flux weight vs. E_{#nu_{e}}",40,0.001,10,10,0.81,1.29);
63  h2f->SetXTitle("E_{#nu_{e}} (GeV)");
64  h2f->SetYTitle("Flux weight");
65  h2f->Draw();
66 
67  hmean->SetLineColor(4);
68  hmean->SetLineWidth(2);
69  hmean->SetLineStyle(2);
70  hmean->Draw("HIST same");
71 
72  TCanvas *c2=new TCanvas("fluxweight_total_uncertainty","",700,600);
73  c2->cd();
74  TH2F *h2f2=new TH2F("h2f2","Flux weight uncertainty vs. E_{#nu_{e}}",40,0.001,10,10,-0.5,0.5);
75  h2f2->SetXTitle("E_{#nu_{e}} (GeV)");
76  h2f2->SetYTitle("Uncertainty on flux weight");
77  h2f2->Draw();
78 
79  for( int i=0; i<40; ++i ){
80  errband[i]->SetFillColor(3);
81  errband[i]->SetLineColor(3);
82  errband[i]->Draw("same");
83  }
84 
85 }
const XML_Char * name
Definition: expat.h:151
TCanvas * c1
Definition: plots_total.C:60
const Var weight
Float_t den
Definition: plot.C:36
TH1F * hweighted[nexp]
Definition: plots_total.C:6
float finalweight[40][nexp]
Definition: plots_total.C:13
float weightErr[40]
Definition: plots_total.C:39
TH1F * hnorm
Definition: plots_total.C:4
const double j
Definition: BetheBloch.cxx:29
TH2F * h2f2
Definition: plots_total.C:74
OStream cout
Definition: OStream.cxx:6
TH1F * hmean
Definition: plots_total.C:40
float weightMean[40]
Definition: plots_total.C:38
int num
Definition: f2_nu.C:119
TBox * errband[40]
Definition: plots_total.C:50
TH1F * finalweight_hists[40]
Definition: plots_total.C:26
TH2F * h2f
Definition: plots_total.C:62
TFile * file
Definition: plots_total.C:3
TCanvas * c2
Definition: plots_total.C:72