HistogramAttr.cxx
Go to the documentation of this file.
1 //Program writen by Prabhjot Singh on August 11, 2016 at 12:15 pm.
2 
3 //Purpose:
4 //1. Important functions that can be called by the main macros for different purposes.
5 //2. Make ND prediction over MC histograms and their ratios.
6 //3. ND prediction over MC histograms helps to make FD prediction for the nue signal (numu to nue signal)
7 //4. Make FD signal prediction for the numu to nue oscillations.
8 //
9 //
10 
11 
12 #include "Header.h"
13 #include "HistogramAttr.h"
14 #include<vector>
15 
16 /////////////////////////////////////////////////////////////////////////////////////////////
17 void HistogramAttr1D(TH1* h, char* title_x, char* title_y){
18 
19  h->GetXaxis()->SetTitle(title_x);
20  h->GetXaxis()->CenterTitle();
21  h->GetXaxis()->SetTitleSize(.06);
22  h->GetXaxis()->SetLabelSize(.05);
23  h->GetXaxis()->SetTitleOffset(1.);
24  h->GetXaxis()->SetDecimals();
25 
26  h->GetYaxis()->SetTitle(title_y);
27  h->GetYaxis()->CenterTitle();
28  h->GetYaxis()->SetTitleOffset(1.16);
29  h->GetYaxis()->SetTitleSize(.06);
30  h->GetYaxis()->SetLabelSize(.04);
31  h->GetYaxis()->SetDecimals();
32 }//end of HistogramAttr1D(TH2* h, char*, char*, char*)
33 ///////////////////////////////////////////////////////////////////////////////////////
34 void HistogramAttr2D(TH2* h, char* title_x, char* title_y, char* title_z){
35 
36  h->GetXaxis()->SetTitle(title_x);
37  h->GetXaxis()->CenterTitle();
38  h->GetXaxis()->SetTitleSize(.06);
39  h->GetXaxis()->SetLabelSize(.05);
40  h->GetXaxis()->SetTitleOffset(1.00);
41  h->GetXaxis()->SetDecimals();
42 
43  h->GetYaxis()->SetTitle(title_y);
44  h->GetYaxis()->CenterTitle();
45  h->GetYaxis()->SetTitleOffset(1.00);
46  h->GetYaxis()->SetTitleSize(.06);
47  h->GetYaxis()->SetLabelSize(.05);
48  h->GetYaxis()->SetDecimals();
49 
50  h->GetZaxis()->SetTitle(title_z);
51  h->GetZaxis()->CenterTitle();
52  h->GetZaxis()->SetTitleOffset(1.0);
53  h->GetZaxis()->SetTitleSize(.06);
54  h->GetZaxis()->SetLabelSize(.06);
55  h->GetZaxis()->SetDecimals();
56 }//end of HistogramAttr1D(TH2* h, char*, char*, char*)
57 //////////////////////////////////////////////////////////////////////////
58 //function to take ratios of two 1D histograms
59 TH1* ratio(TH1* h1, TH1* h2){
60  //always take ratio of second histogram (second argument) to the first histogram (first argument).
61  TH1* hist_ratio = (TH1*)h2->Clone("hist_ratio");
62 // hist_ratio ->Sumw2();
63 
64  double ratio = 0.;
65  double ratio_error = 0.;
66 
67  for(int i = 0; i < h1->GetNbinsX()+1; ++i){
68  if(h1 ->GetBinContent(i)==0) ratio = 0.;
69  else ratio = h2 ->GetBinContent(i)/h1 ->GetBinContent(i);
70  if(h1 ->GetBinContent(i)==0) ratio_error = 0.;
71  else ratio_error = error_division(h2 ->GetBinContent(i), h1 ->GetBinContent(i));
72  hist_ratio->SetBinContent(i, ratio);
73  hist_ratio->SetBinError(i, ratio_error);
74  }//end of loop over bins
75 
76  return hist_ratio;
77 }//end of ratio(TH1F* h1, TH1F* h2)
78 //---------------------------------------------------------------------------//
79 
80 //function to take ratios of two 2D histograms
81 TH2F* ratio2D(TH2F* h1, TH2F* h2){
82  //always take ratio of second histogram (second argument) to the first histogram (first argument).
83  TH2F* hist_ratio = (TH2F*)h2->Clone("hist_ratio");
84  hist_ratio->Sumw2();
85  hist_ratio->Divide(h1);
86  return hist_ratio;
87 }//end of ratio2D(TH2F* h1, TH2F* h2)
88 //---------------------------------------------------------------------------------//
89 
90 //function to make a new 2D histogram and modify its bin content according to the ratio of ND data/MC.
91 TH2F* modify2D(TH2F* h2D, TH1F* h1D, TString prediction){
92  //a new 2D histogram which has same number of bins and same ranges.
93  TH2F* h2D_modify = new TH2F("h2D_modify", "", h2D->GetNbinsX(), h2D->GetXaxis()->GetXmin(), h2D->GetXaxis()->GetXmax(), h2D->GetNbinsY(), h2D->GetYaxis()->GetXmin(), h2D->GetYaxis()->GetXmax());
94 
95  Int_t binsX_1D = h1D->GetNbinsX();
96  Int_t binsX_2D = h2D->GetNbinsX();
97  Int_t binsY_2D = h2D->GetNbinsY();
98  Int_t binsX_new2D = h2D_modify->GetNbinsX();
99  Int_t binsY_new2D = h2D_modify->GetNbinsY();
100 
101  Double_t binX_1D;
102  Double_t bincontent_2D;
103  Double_t bincontent_modify2D;
104 
105  if(binsX_1D != binsY_2D){
106  std::cout << "NUMBER OF RECO BINS ARE NOT SAME...." << std::endl;
107  std::cout << "..........Aborting........." << std::endl;
108  Abort();
109  }
110  else if(binsX_1D == binsY_2D){
111  //k is loop over reco energy bins;
112  for(int k = 1; k < binsY_new2D; ++k){
113  binX_1D = h1D->GetBinContent(k);
114  // i is loop over true energy bins
115  for(int i = 1; i < binsX_new2D; ++i){
116  if(prediction.CompareTo("NDPrediction")==0){
117  bincontent_2D = h2D->GetBinContent(i, k);
118  h2D_modify->SetBinContent(i, k, bincontent_2D*binX_1D);
119  bincontent_modify2D = h2D_modify->GetBinContent(i, k);
120  }//end of NDPrediction condition
121  else if(prediction.CompareTo("FDPrediction")==0){
122  bincontent_2D = h2D->GetBinContent(k, i);
123  h2D_modify->SetBinContent(k, i, bincontent_2D*binX_1D);
124  bincontent_modify2D = h2D_modify->GetBinContent(k, i);
125  }//end of FDPrediction condition
126  }//end of loop over true energy bins i
127  }//end of loop over reco energy bins k
128  }
129  return h2D_modify;
130 }//end of modify2D(TH2F* h2D, TH1F* h1D)
131 //-------------------------------------------------------------------------------//
132 
133 //function to make ND prediction by summing over all reco energy bins
134 TH1F* NDPrediction(TH2F* h){
135 
136  Double_t addedbincontent = 0;
137 
138  TH1F* ND_prediction = new TH1F("ND_prediction", "", h->GetNbinsX(), h->GetXaxis()->GetXmin(), h->GetXaxis()->GetXmax());
139 
140  //loop over true energy bins for both the input 2D histogram and output 1D prediction histogram.
141  //i is loop over true energy bins
142  for(int i = 1; i < h->GetNbinsX(); ++i){
143  addedbincontent = 0;
144  //loop over reco energy bins and sum them.
145  //k is loop over reco energy bins.
146  for(int k = 1; k < h->GetNbinsY(); ++k){
147  addedbincontent += h->GetBinContent(i, k);
148  }//end of loop over true energy bins
149  ND_prediction->SetBinContent(i, addedbincontent);
150  }//end of loop over i, true energy bins
151  return ND_prediction;
152 }//end of NDPrediction(TH2F* h)
153 //-------------------------------------------------------------------------------//
154 
155 //function to calculate goodPOT ND MC.
156 Double_t POTinformationMC(){
157  Double_t goodPOT;
158 
159  Double_t epoch1 = 4.3e+18;
160  Double_t epoch2 = 2.92e+19;
161  Double_t epoch3 = 1.87e+19;
162  Double_t epoch4 = 7.82e+18;
163  Double_t epoch5 = 3.79e+18;
164  Double_t epoch6 = 1.758e+19;
165 
166  goodPOT = (epoch1 + epoch2 + epoch3 + epoch4 + epoch5 + epoch6);
167 
168  std::cout << "Total goodPOT for the ND MC = " << goodPOT << std::endl;
169 
170  return goodPOT;
171 }//end of POTinformationMC()
172 //-------------------------------------------------------------//
173 //function to calculate goodPOT ND Data.
175  Double_t goodPOT;
176 
177  Double_t epoch1 = 12054324.;
178  Double_t epoch2 = 126952955.;
179  Double_t epoch3 = 83087234;
180  Double_t epoch4 = 33601026;
181  Double_t epoch5 = 16260138.;
182  Double_t epoch6 = 76439029.;
183 
184  goodPOT = (epoch1 + epoch2 + epoch3 + epoch4 + epoch5 + epoch6)*1e12;
185 
186  std::cout << "Total goodPOT for the ND Data = " << goodPOT << std::endl;
187 
188  return goodPOT;
189 }//end of POTinformationData()
190 //-------------------------------------------------------------//
191 //function to make the exact same ND prediction/MC for true energy but this time just use the bin content of the ND data and ND MC truereco energy histograms.
192 void ND_predictionbyMC(TH1F* h1, TH2F* h2){
193  std::cout << ">>>>>>>>>>>>>>>> Here are the new histograms using only bin contents >>>>>>>>>>" << std::endl;
194  int Nbinsx_h1 = h1->GetNbinsX();
195  int Nbinsx_h2 = h2->GetNbinsX();
196  int Nbinsy_h2 = h2->GetNbinsY();
197 
198  double data_mc_ratio = 0.;
199  double bins_data_reco = 0.;
200  double bins_mc_reco = 0.;
201  double bins_mc_true = 0.;
202  double bincontent_2D = 0.;
203  double new_bincontent_2D = 0.;
204  double bins_sum = 0.;
205 
206  //data histogram
207  //new TCanvas;
208  //h1->Draw();
209 
210 
211  //reco energy histogram.
212  TH1D* hreco = (TH1D*)h2->ProjectionY();
213  //new TCanvas;
214  //hreco->Draw();
215 
216  // true energy histogram.
217  TH1D* htrue = (TH1D*)h2->ProjectionX();
218  //new TCanvas;
219  //htrue->Draw();
220 
221  //A 2D vector to store reco and true energy variables for the modified 2D plot.
222  std::vector<std::vector<double> > vec_reco;
223 
224  TH1D* h = new TH1D("h", "", Nbinsx_h1, h1->GetXaxis()->GetXmin(), h1->GetXaxis()->GetXmax());
225  h->Sumw2();
226 
227  //k is loop over reco energy bins of the 2D histogram h2;
228  for(int k = 1; k < Nbinsx_h1; ++k){
229  bins_data_reco = h1->GetBinContent(k);
230  bins_mc_reco = hreco->GetBinContent(k);
231  bins_mc_true = htrue->GetBinContent(k);
232  if(bins_mc_reco==0) data_mc_ratio = 0.;
233  else data_mc_ratio = bins_data_reco/bins_mc_reco;
234  std::vector<double> vec_true;
235  //apply near detector data MC ratio for a given reco bin to all the true energy bins for that reco bin.
236  //i is loop over true energy bins
237  for(int i = 1; i < Nbinsx_h2; ++i){
238  bincontent_2D = h2->GetBinContent(i, k);
239  new_bincontent_2D = bincontent_2D*data_mc_ratio;
240  vec_true.push_back(new_bincontent_2D);
241  // if(bincontent_2D==0) continue;
242  }//end of loop over i true energy bins.
243  vec_reco.push_back(vec_true);
244  }//end of loop over k bins.
245 
246  //loop over bins to make the ND prediction
247  //true energy bin
248  for (int i = 0; i < vec_reco.size(); ++i)
249  {
250  bins_sum = 0.0;
251  //reco energy bins
252  for (int k = 0; k < vec_reco[i].size(); ++k)
253  {
254  // cout << "Vec [" << k << ", " << i << "] = " << vec_reco[k][i] << std::endl;
255  bins_sum += vec_reco[k][i];
256  }
257  h->SetBinContent(k+1, bins_sum);
258  if(htrue->GetBinContent(i+1)==0){
259  h->SetBinContent(i+1, 0);
260  h->SetBinError(i+1, 0);
261  }
262  else{
263  h->SetBinContent(i+1, bins_sum/htrue->GetBinContent(i+1));
264  h->SetBinError(i+1, error_division(bins_sum, htrue->GetBinContent(i+1)));
265  }
266  }
267 
268  new TCanvas;
269  h->Draw("P E");
270  h->SetMarkerStyle(20);
271 
272  //delete pointers;
273  delete hreco;
274  delete htrue;
275 }//end of ND_predictionbyMC(TH1F h1, TH2F h2)
276 //-----------------------------------------------------------------------
277 //function to calculate error for ratio
278 double error_division(double num, double deno){
279 
280  if(num == 0. || deno == 0) return 0;
281 
282  else return (num/deno)*std::sqrt(std::pow(std::sqrt(num)/num, 2) + std::pow(std::sqrt(deno)/deno, 2));
283 // else return std::sqrt(std::pow(std::sqrt(num)/num, 2) + std::pow(std::sqrt(deno)/deno, 2));
284 
285 }//end of error_division(double num, double deno)
286 //--------------------------------------------------------------------------
287 
288 //function to make the exact same ND prediction/MC for true energy but this time just use the bin content of the ND data and ND MC truereco energy histograms.
289 //Using flat arrays for the 2D truevsreco histogram.
290 void ND_predictionbyMC_usingbincontent(TH1F* hdata, TH2F* htruereco){
291  TAxis* axis = hdata->GetXaxis();
292  //static const int bins = hdata->GetNbinsX();
293  static const int bins = 119;
294 
295  double datasum[bins] = {0.};
296  double mcrecosum[bins] = {0.};
297  double mctruesum[bins] = {0.};
298  double binVal[bins] = {0.};
299  double data_mc_ratio[bins] = {0.};
300  double predictionsum[bins] = {0.};
301  double prediction_mc_ratio[bins] = {0.};
302  double prediction_mc_ratio_error[bins] = {0.};
303 
304  double recovstrueBi[bins*bins] = {0.};
305  double recovstrue_weightedBi[bins*bins] = {0.};
306 
307  //TH1D* hreco = nullptr;
308  //TH1D* htrue = nullptr;
309 
310  TH1D* htrue = htruereco->ProjectionX();
311  TH1D* hreco = htruereco->ProjectionY();
312 
313  TH1D* hratio = new TH1D("h", "", bins, hdata->GetXaxis()->GetXmin(), hdata->GetXaxis()->GetXmax());
314  hratio->Sumw2();
315 
316  //--------------LOOP 1----------------------------------------------------//
317  //loop over x axis bins to add them for all the epochs
318  //In this case I have only one epoch.
319  for(int k = 1; k < bins+1; ++k){
320  datasum[k-1] += hdata->GetBinContent(k);
321  mcrecosum[k-1] += hreco->GetBinContent(k);
322  mctruesum[k-1] += htrue->GetBinContent(k);
323  //loop over true energy bins i to sum up bin contents of the 2D recovstrue histogram
324  for(int i = 1; i < bins+1; ++i){
325  recovstrueBi[(k-1)*bins+(i-1)] += htruereco->GetBinContent(i, k);
326  }//end of loop over true energy bins i
327  }//end of loop over x axis bins
328  //----------------LOOP 2----------------------------------------//
329  //another for loop to loop over the the data and mc arrays to get the data/mc ratios and fill the weighted 2D truevsreco_weighted array.
330  //loop over reco energy bins k
331  for(int k = 0; k < bins; ++k){
332  if(mcrecosum[k]==0) data_mc_ratio[k] = 0.;
333  else data_mc_ratio[k] = datasum[k]/mcrecosum[k];
334  //loop over true energy bins i
335  for(int i = 0; i < bins; ++i){
336  recovstrue_weightedBi[k*bins+i] = recovstrueBi[k*bins+i]*data_mc_ratio[k];
337  }//end of loop over true energy bins i
338  }//end of loop over reco energy bins k
339  //-------------------------LOOP 3-----------------------------------------//
340  //for loop to make the ND prediction
341  //loop over first argument of the 2D array (true energy)
342  for(int t = 0; t < bins; ++t){
343  //loop over second argument of the 2D array (reco energy)
344  for(int r = 0; r < bins; ++r){
345  if(recovstrue_weightedBi[r*bins+t]==0) continue;
346  predictionsum[t] += recovstrue_weightedBi[r*bins+t];
347  }//end of loop over second argument of the 2D array
348  if(mctruesum[t]==0) prediction_mc_ratio[t] = 0.;
349  else prediction_mc_ratio[t] = predictionsum[t]/mctruesum[t];
350  binVal[t] = hdata->GetBinLowEdge(t);
351  if(mctruesum[t]==0) prediction_mc_ratio_error[t] = 0.;
352  else prediction_mc_ratio_error[t] = error_division(predictionsum[t], mctruesum[t]);
353 
354  hratio->SetBinContent(t+1, prediction_mc_ratio[t]);
355  hratio->SetBinError(t+1, prediction_mc_ratio_error[t]);
356  }//end of loop over first argument of the 2D array
357  //--------------------LOOP 4-----------------------------------------//
358  //loop to cout values of the ratios and the prediction numbers
359 
360  for(int l = 0; l < bins; ++l){
361  // std::cout << "Sum of " << l+1 << "th bin = " << predictionsum[l] << std::endl;
362  // std::cout << "MC true bin content = " << mcrecosum[l] << std::endl;
363  // std::cout << "Ratio: Prediction to MC true = " << prediction_mc_ratio[l] << std::endl;
364  // std::cout << " " << std::endl;
365  }//end of loop over l bins
366 
367  new TCanvas;
368  hratio->Draw("P E");
369  hratio->SetMarkerStyle(20);
370 }//end of function ND_predictionbyMC_usingbincontent(TH1F*, TH2F* h2)
371 //------------------------------------------------------------------------------
372 
373 //function to make probability of numu to nue oscillation.
374 TH1F* Prob_me(TH1F* h){
375  double s2t13 = 0.085; //sin^{2}(2theta13) = 0.085 from docdb 15956, page 26: Chris
376  double st23 = 0.40; //sin^{2}(theta23) = 0.40 from docdb 15956, page 26 and 12: Chris
377  double m32 = 2.67e-3; //DeltaM^{2}(32) = 2.67e-3 from docdb 15956, page 26 and 12: Chris
378  double L = 810.;
379 
380  double P = 0.0;
381 
382  TH1F* prob = new TH1F("prob", "", h->GetNbinsX(), h->GetXaxis()->GetXmin(), h->GetXaxis()->GetXmax());
383 
384  for(int i = 1; i < prob->GetNbinsX(); ++i){
385  P = s2t13*st23*std::pow(TMath::Sin((1.27*m32*L)/prob->GetBinCenter(i)), 2);
386  prob->SetBinContent(i, P);
387  P = 0.0;
388  }//end of loop over bins i
389  return prob;
390 }//end of Prob_me(TH1F* h)
391 //------------------------------------------------------------------------------
392 //function to make FD prediction by summing over all true energy bins
393 TH1F* FDPrediction(TH2F* h){
394 
395  Double_t addedbincontent = 0;
396 
397  TH1F* FD_prediction = new TH1F("FD_prediction", "", h->GetNbinsX(), h->GetXaxis()->GetXmin(), h->GetXaxis()->GetXmax());
398 
399  //i is loop over reco energy bins
400  for(int i = 1; i < h->GetNbinsY(); ++i){
401  addedbincontent = 0;
402  //loop over true energy bins and sum them.
403  //k is loop over true energy bins.
404  for(int k = 1; k < h->GetNbinsX(); ++k){
405  addedbincontent += h->GetBinContent(k, i);
406  }//end of loop over true energy bins
407  FD_prediction->SetBinContent(i, addedbincontent);
408  }//end of loop over i, true energy bins
409  return FD_prediction;
410 
411 }//end of FDPrediction(TH2F* h2, TH1F* h1)
412 //------------------------------------------------------------------------------
413 //
414 //function CompareHistos() to compare any two histograms and make their ratios as well.
415 //The first histogram passed to the function is always a base histogram and ratios are calculated on the bases of base histogram. Base histogram goes into the numeraor.
416 //
417 //
418 void CompareHistos(TH1* hbase_orig, TH1* hsec_orig, TString xlabel, TString ylabel, int cbase, int csec, int lbase, int lsec, float x1, float y1, float x2, float y2, TString legtitle, TString legbase, TString legsec, TString savefile){
419 
420  TH1F* hbase = (TH1F*)hbase_orig ->Clone("hbase");
421  TH1F* hsec = (TH1F*)hsec_orig ->Clone("hsec");
422 
423  double ymax = 0.;
424 
425  TH1F* hbase = (TH1F*)hbase_orig ->Clone("hbase");
426  TH1F* hsec = (TH1F*)hsec_orig ->Clone("hsec");
427 
428  TCanvas* c1 = new TCanvas("c1", " ", 800, 600);
429  TPad* pad1 = new TPad("pad1", " ", 0.05, 0.40, 0.95, 1.00);
430  TPad* pad2 = new TPad("pad2", " ", 0.05, 0.05, 0.95, 0.46);
431  pad1->Draw();
432  pad2->Draw();
433  pad1->cd();
434  gPad->SetLeftMargin(0.15);
435 
436  if(hsec->GetBinContent(hsec->GetMaximumBin()) > hbase->GetBinContent(hbase->GetMaximumBin()) )
437  ymax = 1.1*hsec->GetBinContent(hsec->GetMaximumBin());
438  else if(hsec->GetBinContent(hsec->GetMaximumBin()) <= hbase->GetBinContent(hbase->GetMaximumBin()) )
439  ymax = 1.1*hbase->GetBinContent(hbase->GetMaximumBin());
440 
441  hsec->Draw("HIST same");
442  hbase->Draw("HIST same");
443  hsec->GetXaxis()->SetRangeUser(0, 5);
444  hsec->GetYaxis()->SetRangeUser(0, ymax);
445  hsec->GetYaxis()->SetTitle(ylabel);
446  hsec->GetYaxis()->CenterTitle();
447  hsec->GetYaxis()->SetTitleSize(0.09);
448  hsec->GetYaxis()->SetTitleOffset(0.75);
449  hsec->GetYaxis()->SetLabelSize(0.09);
450  hsec->GetYaxis()->SetDecimals();
451  hsec->GetXaxis()->SetDecimals();
452  hsec->GetXaxis()->SetTitle(xlabel);
453  hsec->SetLineColor(csec);
454  hsec->SetFillColor(0);
455  hsec->SetLineWidth(3);
456  hsec->SetLineStyle(lsec);
457 
458  hbase->SetLineColor(cbase);
459  hbase->SetFillColor(0);
460  hbase->SetLineWidth(3);
461  hbase->SetLineStyle(lbase);
462 
463  TLegend* legend = new TLegend(x1, y1 ,x2, y2);
464  legend->SetBorderSize(0);
465  legend->SetFillStyle(0);
466  legend->SetTextSize(0.035);
467  legend->AddEntry((TObject*)0, legtitle," ");
468  legend->AddEntry(hsec, legsec, "l");
469  legend->AddEntry(hbase, legbase, "l");
470  legend->SetTextSize(0.04);
471  legend->Draw();
472 
473  TH1F* hist_ratio = new TH1F("hist_ratio", "", hbase->GetNbinsX(), hbase->GetXaxis()->GetXmin(), hbase->GetXaxis()->GetXmax());
474  hist_ratio->Sumw2();
475  legend->AddEntry(hist_ratio, legsec+"/"+legbase, "lep");
476  double ratio = 0.;
477  double ratio_error = 0.;
478  for(int i = 0; i < hbase->GetNbinsX()+1; ++i){
479  if(hbase->GetBinContent(i)==0) ratio = 0.;
480  else ratio = hsec->GetBinContent(i)/hbase->GetBinContent(i);
481  if(hbase->GetBinContent(i)==0) ratio_error = 0.;
482  else ratio_error = error_division(hsec->GetBinContent(i), hbase->GetBinContent(i));
483  hist_ratio->SetBinContent(i, ratio);
484  hist_ratio->SetBinError(i, ratio_error);
485  }//end of bin by bin ratio
486 
487 pad2->cd();
488 gPad->SetBottomMargin(0.40);
489 gPad->SetLeftMargin(0.15);
490 hist_ratio->Draw("P");
491 hist_ratio->SetLineColor(kBlack);
492 hist_ratio->SetMarkerColor(kBlack);
493 hist_ratio->SetMarkerStyle(20);
494 hist_ratio->GetYaxis()->SetTitle("Ratio");
495 hist_ratio->GetYaxis()->CenterTitle();
496 hist_ratio->GetYaxis()->SetTitleSize(0.20);
497 hist_ratio->GetYaxis()->SetTitleOffset(0.35);
498 hist_ratio->GetYaxis()->SetLabelSize(0.12);
499 hist_ratio->GetYaxis()->SetDecimals();
500 //hist_ratio->GetYaxis()->SetRangeUser(0.70, 1.20);
501  hist_ratio->GetYaxis()->SetRangeUser(0.9, 1.05*hist_ratio->GetBinContent(hist_ratio->GetMaximumBin()));
502 hist_ratio->GetXaxis()->SetTitle(xlabel);
503 hist_ratio->GetXaxis()->CenterTitle();
504 hist_ratio->GetXaxis()->SetTitleSize(0.13);
505 hist_ratio->GetXaxis()->SetTitleOffset(0.84);
506 hist_ratio->GetXaxis()->SetLabelSize(0.12);
507 hist_ratio->GetXaxis()->SetRangeUser(0, 5);
508 
509 TLine* one = new TLine(0, 1, 5, 1);
510 one->SetLineWidth(2);
511 one->SetLineStyle(7);
512 one->Draw();
513 
514 c1->cd();
515 c1->SaveAs("/nova/app/users/prabhjot/mrb_build/srcs/novasoft/FNEX/macros/Images/fnexvscaf/"+savefile+".pdf");
516 c1->SaveAs("/nova/app/users/prabhjot/mrb_build/srcs/novasoft/FNEX/macros/Images/fnexvscaf/"+savefile+".C");
517 c1->SaveAs("/nova/app/users/prabhjot/mrb_build/srcs/novasoft/FNEX/macros/Images/fnexvscaf/"+savefile+".png");
518 
519 delete hbase;
520 delete hsec;
521 delete hist_ratio;
522 delete c1;
523 }//end of CompareHistos
524 //------------------------------------------------------------------------------
525 //
526 //function CompareHistos() to compare any three histograms and make their ratios as well.
527 //The first histogram passed to the function is always a base histogram and ratios are calculated on the bases of base histogram. Base histogram goes into the numeraor.
528 //
529 void CompareHistos(TH1* hbase_orig, TH1* hsec_orig, TH1* third, TString xlabel, TString ylabel, int cbase, int csec, int lbase, int lsec, float x1, float y1, float x2, float y2, TString legtitle, TString legbase, TString legsec, TString legthird, TString savefile){
530  double ymax = 0.;
531 
532  TH1F* hbase = (TH1F*)hbase_orig ->Clone("hbase");
533  TH1F* hsec = (TH1F*)hsec_orig ->Clone("hsec");
534  TH1F* hthird = (TH1F*)third ->Clone("hthird");
535 
536  ymax = 1.1*hbase->GetBinContent(hbase->GetMaximumBin());
537 
538  if(1.1*hsec->GetBinContent(hsec->GetMaximumBin()) > ymax)
539  ymax = 1.1*hsec->GetBinContent(hsec->GetMaximumBin());
540 
541  else if(1.1*hthird->GetBinContent(hthird->GetMaximumBin()) > ymax)
542  ymax = 1.1*hthird->GetBinContent(hthird->GetMaximumBin());
543 
544  TCanvas* c1 = new TCanvas("c1", " ", 800, 600);
545  TPad* pad1 = new TPad("pad1", " ", 0.05, 0.20, 0.95, 1 );
546  TPad* pad2 = new TPad("pad2", " ", 0.05, 0.05, 0.95, 0.25);
547  pad1->Draw();
548  pad2->Draw();
549  pad1->cd();
550  gPad->SetLeftMargin(0.15);
551 
552  hsec ->Draw("HIST same");
553  hbase ->Draw("HIST same");
554  hthird ->Draw("HIST same");
555 
556  hsec->GetXaxis()->SetRangeUser(0, 5);
557  hsec->GetYaxis()->SetRangeUser(0, ymax);
558  hsec->GetYaxis()->SetTitle(ylabel);
559  hsec->GetYaxis()->CenterTitle();
560  hsec->GetYaxis()->SetTitleSize(0.06);
561  hsec->GetYaxis()->SetTitleOffset(1.);
562  hsec->GetYaxis()->SetLabelSize(0.05);
563  hsec->GetYaxis()->SetDecimals();
564  hsec->GetXaxis()->SetDecimals();
565  hsec->GetXaxis()->SetTitle(xlabel);
566  hsec->SetLineColor(csec);
567  hsec->SetFillColor(0);
568  hsec->SetLineWidth(3);
569  hsec->SetLineStyle(lsec);
570 
571  hbase->SetLineColor(cbase);
572  hbase->SetFillColor(0);
573  hbase->SetLineWidth(3);
574  hbase->SetLineStyle(lbase);
575 
576  hthird->SetLineColor(kBlack);
577  hthird->SetFillColor(0);
578  hthird->SetLineWidth(3);
579  hthird->SetLineStyle(9);
580 
581  TLegend* legend = new TLegend(x1, y1 ,x2, y2);
582  legend->SetBorderSize(0);
583  legend->SetFillStyle(0);
584  legend->SetTextSize(0.035);
585  legend->AddEntry((TObject*)0, legtitle," ");
586  legend->AddEntry(hbase, legbase, "l");
587  legend->AddEntry(hthird, legthird, "l");
588  legend->AddEntry(hsec, legsec, "l");
589  legend->Draw();
590 
591  TH1F* hist_ratio = new TH1F("hist_ratio", "", hbase->GetNbinsX(), hbase->GetXaxis()->GetXmin(), hbase->GetXaxis()->GetXmax());
592  hist_ratio->Sumw2();
593  legend->AddEntry(hist_ratio, legsec+"/"+legbase, "lep");
594  double ratio = 0.;
595  double ratio_error = 0.;
596  for(int i = 0; i < hbase->GetNbinsX()+1; ++i){
597  if(hbase->GetBinContent(i)==0) ratio = 0.;
598  else ratio = hsec->GetBinContent(i)/hbase->GetBinContent(i);
599  if(hbase->GetBinContent(i)==0) ratio_error = 0.;
600  else ratio_error = error_division(hsec->GetBinContent(i), hbase->GetBinContent(i));
601  hist_ratio->SetBinContent(i, ratio);
602  hist_ratio->SetBinError(i, ratio_error);
603  }//end of bin by bin ratio
604 
605  TH1F* hist_ratio_third = new TH1F("hist_ratio_third", "", hbase->GetNbinsX(), hbase->GetXaxis()->GetXmin(), hbase->GetXaxis()->GetXmax());
606  hist_ratio_third->Sumw2();
607  legend->AddEntry(hist_ratio_third, legthird+"/"+legbase, "lep");
608  double ratio_third = 0.;
609  double ratio_error_third = 0.;
610  for(int i = 0; i < hbase->GetNbinsX()+1; ++i){
611  if(hbase->GetBinContent(i)==0) ratio_third = 0.;
612  else ratio_third = hthird->GetBinContent(i)/hbase->GetBinContent(i);
613  if(hbase->GetBinContent(i)==0) ratio_error_third = 0.;
614  else ratio_error_third = error_division(hthird->GetBinContent(i), hbase->GetBinContent(i));
615  hist_ratio_third->SetBinContent(i, ratio_third);
616  hist_ratio_third->SetBinError(i, ratio_error_third);
617  }//end of bin by bin ratio
618 
619 pad2->cd();
620 gPad->SetBottomMargin(0.40);
621 gPad->SetLeftMargin(0.15);
622 hist_ratio->Draw("P");
623 hist_ratio->SetLineColor(csec);
624 hist_ratio->SetMarkerColor(csec);
625 hist_ratio->SetMarkerStyle(20);
626 hist_ratio->GetYaxis()->SetTitle("Ratio");
627 hist_ratio->GetYaxis()->CenterTitle();
628 hist_ratio->GetYaxis()->SetTitleSize(0.23);
629 hist_ratio->GetYaxis()->SetTitleOffset(0.20);
630 hist_ratio->GetYaxis()->SetLabelSize(0.17);
631 hist_ratio->GetYaxis()->SetDecimals();
632 hist_ratio->GetYaxis()->SetRangeUser(0.70, 1.20);
633 hist_ratio->GetXaxis()->SetTitle(xlabel);
634 hist_ratio->GetXaxis()->CenterTitle();
635 hist_ratio->GetXaxis()->SetTitleSize(0.23);
636 hist_ratio->GetXaxis()->SetTitleOffset(0.7);
637 hist_ratio->GetXaxis()->SetLabelSize(0.17);
638 hist_ratio->GetXaxis()->SetRangeUser(0, 5);
639 
640 hist_ratio_third->Draw("P same");
641 hist_ratio_third->SetLineColor(hthird->GetLineColor());
642 hist_ratio_third->SetMarkerColor(hthird->GetMarkerColor());
643 hist_ratio_third->SetMarkerStyle(20);
644 
645 TLine* one = new TLine(0, 1, 5, 1);
646 one->SetLineWidth(2);
647 one->SetLineStyle(7);
648 one->Draw();
649 
650 c1->cd();
651 c1->SaveAs("/nova/app/users/prabhjot/mrb_build/srcs/novasoft/FNEX/macros/Images/fnexvscaf/"+savefile+".pdf");
652 c1->SaveAs("/nova/app/users/prabhjot/mrb_build/srcs/novasoft/FNEX/macros/Images/fnexvscaf/"+savefile+".C");
653 
654 delete hbase;
655 delete hsec;
656 delete hthird;
657 delete hist_ratio;
658 delete c1;
659 delete hist_ratio_third;
660 }//end of CompareHistos
661 //---------------------------------------------------------------//
662 TH1* CorrectRange(TH1* h, TString PID){
663  int firstbin = 0;
664  if(PID=="Low") firstbin = 0;
665  if(PID=="Mid") firstbin = 10;
666  if(PID=="High") firstbin = 20;
667  TH1D* hlow = new TH1D(TString::Format("hlow_%i", rand()), "", 10, 0, 5);
668  for(unsigned int i = 1; i < h->GetNbinsX()+1; i++){
669  hlow->SetBinContent(i, h->GetBinContent(i+firstbin));
670  hlow->SetBinError(i, h->GetBinError(i+firstbin));
671  }
672  return hlow;
673 }//end of CorrectRange
674 /////////////////////////////////////////////////////////////////////////////////////////////
675 void GraphAttr1D(TGraph* h, char* title_x, char* title_y){
676 
677  h->GetXaxis()->SetTitle(title_x);
678  h->GetXaxis()->CenterTitle();
679  h->GetXaxis()->SetTitleSize(.06);
680  h->GetXaxis()->SetLabelSize(.05);
681  h->GetXaxis()->SetTitleOffset(1.);
682  h->GetXaxis()->SetDecimals();
683 
684  h->GetYaxis()->SetTitle(title_y);
685  h->GetYaxis()->CenterTitle();
686  h->GetYaxis()->SetTitleOffset(0.85);
687  h->GetYaxis()->SetTitleSize(.06);
688  h->GetYaxis()->SetLabelSize(.04);
689  h->GetYaxis()->SetDecimals();
690 }//end of HistogramAttr1D(TH2* h, char*, char*, char*)
691 ///////////////////////////////////////////////////////////////////////////////////////
692 //---------------------------------------------------------------//
693 void CompareHistos(TH1* hbase_orig,
694  TH1* hsec_orig,
695  TString xlabel,
696  TString ylabel,
697  int cbase,
698  int csec,
699  int lbase,
700  int lsec,
701  float x1,
702  float y1,
703  float x2,
704  float y2,
705  std::vector<TString> legtitle,
706  TString legbase,
707  TString legsec,
708  TString leg_ratio,
709  TCanvas* c1,
710  TString draw_option,
711  TString scaling ){
712 
713  TH1F* hbase = (TH1F*)hbase_orig ->Clone("hbase");
714  TH1F* hsec = (TH1F*)hsec_orig ->Clone("hsec");
715 
716  double ymax = 0.;
717 
718  TPad* pad1 = new TPad("pad1", " ", 0.05, 0.40, 0.95, 1.00);
719  TPad* pad2 = new TPad("pad2", " ", 0.05, 0.05, 0.95, 0.46);
720  pad1->Draw();
721  pad2->Draw();
722 
723  pad1->cd();
724  gPad->SetLeftMargin(0.20);
725 
726  if(hsec->GetBinContent(hsec->GetMaximumBin()) > hbase->GetBinContent(hbase->GetMaximumBin()) )
727  ymax = 1.1*hsec->GetBinContent(hsec->GetMaximumBin());
728  else if(hsec->GetBinContent(hsec->GetMaximumBin()) <= hbase->GetBinContent(hbase->GetMaximumBin()) )
729  ymax = 1.1*hbase->GetBinContent(hbase->GetMaximumBin());
730 
731  hsec ->Draw(draw_option + "same");
732  hbase->Draw(draw_option + "same");
733 
734  hsec->GetYaxis()->SetRangeUser(0, 2*ymax);
735  hsec->GetYaxis()->SetTitle(ylabel);
736  hsec->GetYaxis()->CenterTitle();
737  hsec->GetYaxis()->SetTitleSize(0.09);
738  hsec->GetYaxis()->SetTitleOffset(1.15);
739  hsec->GetYaxis()->SetLabelSize(0.06);
740  hsec->GetYaxis()->SetDecimals();
741  hsec->GetXaxis()->SetDecimals();
742  hsec->GetXaxis()->SetTitle(xlabel);
743  hsec->SetLineColor(csec);
744  hsec->SetFillColor(0);
745  hsec->SetLineWidth(3);
746  hsec->SetLineStyle(lsec);
747  hsec->SetMarkerStyle(20);
748  hsec->SetMarkerColor(csec);
749 
750  hbase->SetLineColor(cbase);
751  hbase->SetFillColor(0);
752  hbase->SetLineWidth(3);
753  hbase->SetLineStyle(lbase);
754  hbase->SetMarkerStyle(20);
755  hbase->SetMarkerColor(cbase);
756  hsec->GetXaxis()->SetNdivisions(508);
757  hsec->GetXaxis()->CenterTitle();
758  hsec->GetXaxis()->SetTitleSize(0.06);
759  hsec->GetXaxis()->SetTitleOffset(0.84);
760  hsec->GetXaxis()->SetLabelSize(0.06);
761 
762  TLegend* legend = new TLegend(x1, y1 ,x2, y2);
763  legend->SetBorderSize(0);
764  legend->SetFillStyle(0);
765  legend->SetTextSize(0.025);
766  for(int i = 0; i < legtitle.size(); ++i)
767  legend->AddEntry((TObject*)0, legtitle[i]," ");
768  legend->AddEntry(hsec, legsec, "l");
769  legend->AddEntry(hbase, legbase, "l");
770  legend->SetTextSize(0.05);
771  legend->Draw();
772 
773 TLine* one = new TLine(0, 1, 5, 1);
774 one->SetLineWidth(2);
775 one->SetLineStyle(7);
776 one->Draw();
777  //Use random number to make unique name for ratio histogram
778  //initialize random seed:
779  TH1F* hist_ratio = new TH1F(TString::Format("hist_ratio_%i", rand()), "", hbase->GetNbinsX(), hbase->GetXaxis()->GetXmin(), hbase->GetXaxis()->GetXmax());
780 
781  hist_ratio->Sumw2();
782  legend->AddEntry(hist_ratio, legsec+"/"+legbase, "lep");
783  double ratio = 0.;
784  double ratio_error = 0.;
785  for(int i = 0; i < hbase->GetNbinsX()+1; ++i){
786 // if(hbase->GetBinContent(i)==0) ratio = 0.;
787 // else ratio = hsec->GetBinContent(i)/hbase->GetBinContent(i);
788  if(hbase->GetBinContent(i)==0) ratio_error = 0.;
789  else ratio_error = error_division(hsec->GetBinContent(i), hbase->GetBinContent(i));
790 // hist_ratio->SetBinContent(i, ratio);
791  hist_ratio->SetBinError(i, ratio_error);
792  }//end of bin by bin ratio
793 pad2->cd();
794 gPad->SetBottomMargin(0.40);
795 gPad->SetLeftMargin(0.20);
796 hist_ratio->Draw("P");
797 hist_ratio->SetLineColor(kBlack);
798 hist_ratio->SetMarkerColor(kBlack);
799 hist_ratio->SetMarkerStyle(20);
800 hist_ratio->GetYaxis()->SetTitle(leg_ratio);
801 hist_ratio->GetYaxis()->CenterTitle();
802 hist_ratio->GetYaxis()->SetTitleSize(0.10);
803 hist_ratio->GetYaxis()->SetTitleOffset(1.06);
804 hist_ratio->GetYaxis()->SetLabelSize(0.08);
805 hist_ratio->GetYaxis()->SetDecimals();
806 //hist_ratio->GetYaxis()->SetRangeUser(0.9, 1.05*hist_ratio->GetBinContent(hist_ratio->GetMaximumBin()));
807 //hist_ratio->GetYaxis()->SetRangeUser(0.9, 1.1);
808 hist_ratio->GetXaxis()->SetTitle(xlabel);
809 hist_ratio->GetXaxis()->CenterTitle();
810 hist_ratio->GetXaxis()->SetTitleSize(0.10);
811 hist_ratio->GetXaxis()->SetTitleOffset(0.84);
812 hist_ratio->GetXaxis()->SetLabelSize(0.09);
813 hist_ratio->GetXaxis()->SetRangeUser(0, 5);
814 
815 TLine* one = new TLine(0, 1, 5, 1);
816 one->SetLineWidth(2);
817 one->SetLineStyle(7);
818 one->Draw();
819 
820 //Scale hsec wrt to base
821  if(scaling.Contains("yes"))
822  hsec->Scale(hbase->Integral()/hsec->Integral());
823 
824  //Find ratios post-normalization
825  for(int i = 0; i < hbase->GetNbinsX()+1; ++i){
826  if(hbase->GetBinContent(i)==0) ratio = 0.;
827  else ratio = hsec->GetBinContent(i)/hbase->GetBinContent(i);
828  hist_ratio->SetBinContent(i, ratio);
829  }//end of bin by bin ratio
830 hsec->GetXaxis()->SetRangeUser(0, 5);
831 }//end of CompareHistos function
832 //---------------------------------------------------------------//
833 void CompareHistos(TH1* hbase_orig,
834  TH1* hsec_orig,
835  TH1* third,
836  TString xlabel,
837  TString ylabel,
838  int cbase,
839  int csec,
840  int lbase,
841  int lsec,
842  float x1,
843  float y1,
844  float x2,
845  float y2,
846  std::vector<TString> legtitle,
847  TString legbase,
848  TString legsec,
849  TString legthird,
850  TCanvas* c1){
851 
852  double ymax = 0.;
853 
854  TH1F* hbase = (TH1F*)hbase_orig ->Clone("hbase");
855  TH1F* hsec = (TH1F*)hsec_orig ->Clone("hsec");
856  TH1F* hthird = (TH1F*)third ->Clone("hthird");
857 
858  ymax = 1.1*hbase->GetBinContent(hbase->GetMaximumBin());
859 
860  if(1.1*hsec->GetBinContent(hsec->GetMaximumBin()) > ymax)
861  ymax = 1.1*hsec->GetBinContent(hsec->GetMaximumBin());
862 
863  else if(1.1*hthird->GetBinContent(hthird->GetMaximumBin()) > ymax)
864  ymax = 1.1*hthird->GetBinContent(hthird->GetMaximumBin());
865 
866  TPad* pad1 = new TPad("pad1", " ", 0.05, 0.40, 0.95, 1.00);
867  TPad* pad2 = new TPad("pad2", " ", 0.05, 0.05, 0.95, 0.46);
868  pad1->Draw();
869  pad2->Draw();
870  pad1->cd();
871  gPad->SetLeftMargin(0.20);
872 
873  hsec ->Draw("HIST same");
874  hbase ->Draw("HIST same");
875  hthird ->Draw("HIST same");
876 
877  hsec->GetXaxis()->SetRangeUser(0, 5);
878  hsec->GetYaxis()->SetRangeUser(0, ymax);
879  hsec->GetYaxis()->SetTitle(ylabel);
880  hsec->GetYaxis()->CenterTitle();
881  hsec->GetYaxis()->SetTitleSize(0.09);
882  hsec->GetYaxis()->SetTitleOffset(1.15);
883  hsec->GetYaxis()->SetLabelSize(0.06);
884  hsec->GetYaxis()->SetDecimals();
885  hsec->GetXaxis()->SetDecimals();
886  hsec->GetXaxis()->SetTitle(xlabel);
887  hsec->SetLineColor(csec);
888  hsec->SetFillColor(0);
889  hsec->SetLineWidth(3);
890  hsec->SetLineStyle(lsec);
891 
892  hbase->SetLineColor(cbase);
893  hbase->SetFillColor(0);
894  hbase->SetLineWidth(3);
895  hbase->SetLineStyle(lbase);
896 
897  hthird->SetLineColor(kBlack);
898  hthird->SetFillColor(0);
899  hthird->SetLineWidth(3);
900  hthird->SetLineStyle(9);
901 
902  TLegend* legend = new TLegend(x1, y1 ,x2, y2);
903  legend->SetBorderSize(0);
904  legend->SetFillStyle(0);
905  legend->SetTextSize(0.040);
906  for(int i = 0; i < legtitle.size(); ++i)
907  legend->AddEntry((TObject*)0, legtitle[i]," ");
908  legend->AddEntry(hbase, legbase, "l");
909  legend->AddEntry(hsec, legsec, "l");
910  legend->AddEntry(hthird, legthird, "l");
911  legend->Draw();
912 
913  TH1F* hist_ratio = new TH1F(TString::Format("hist_ratio_%i", rand()), "", hbase->GetNbinsX(), hbase->GetXaxis()->GetXmin(), hbase->GetXaxis()->GetXmax());
914  hist_ratio->Sumw2();
915  legend->AddEntry(hist_ratio, legsec+"/"+legbase, "lep");
916  double ratio = 0.;
917  double ratio_error = 0.;
918  for(int i = 0; i < hbase->GetNbinsX()+1; ++i){
919  if(hbase->GetBinContent(i)==0) ratio = 0.;
920  else ratio = hsec->GetBinContent(i)/hbase->GetBinContent(i);
921  if(hbase->GetBinContent(i)==0) ratio_error = 0.;
922  else ratio_error = error_division(hsec->GetBinContent(i), hbase->GetBinContent(i));
923  hist_ratio->SetBinContent(i, ratio);
924  hist_ratio->SetBinError(i, ratio_error);
925  }//end of bin by bin ratio
926 
927  TH1F* hist_ratio_third = new TH1F(TString::Format("hist_ratio_third_%i", rand()), "", hbase->GetNbinsX(), hbase->GetXaxis()->GetXmin(), hbase->GetXaxis()->GetXmax());
928  hist_ratio_third->Sumw2();
929  legend->AddEntry(hist_ratio_third, legthird+"/"+legbase, "lep");
930  double ratio_third = 0.;
931  double ratio_error_third = 0.;
932  for(int i = 0; i < hbase->GetNbinsX()+1; ++i){
933  if(hbase->GetBinContent(i)==0) ratio_third = 0.;
934  else ratio_third = hthird->GetBinContent(i)/hbase->GetBinContent(i);
935  if(hbase->GetBinContent(i)==0) ratio_error_third = 0.;
936  else ratio_error_third = error_division(hthird->GetBinContent(i), hbase->GetBinContent(i));
937  hist_ratio_third->SetBinContent(i, ratio_third);
938  hist_ratio_third->SetBinError(i, ratio_error_third);
939  }//end of bin by bin ratio
940 
941 pad2->cd();
942 gPad->SetBottomMargin(0.40);
943 gPad->SetLeftMargin(0.20);
944 hist_ratio->Draw("P");
945 hist_ratio->SetLineColor(csec);
946 hist_ratio->SetMarkerColor(csec);
947 hist_ratio->SetMarkerStyle(20);
948 hist_ratio->GetYaxis()->SetTitle("Ratio");
949 hist_ratio->GetYaxis()->CenterTitle();
950 hist_ratio->GetYaxis()->SetTitleSize(0.10);
951 hist_ratio->GetYaxis()->SetTitleOffset(1.06);
952 hist_ratio->GetYaxis()->SetLabelSize(0.08);
953 hist_ratio->GetYaxis()->SetDecimals();
954 //hist_ratio->GetYaxis()->SetRangeUser(0.95, 1.05*hist_ratio->GetBinContent(hist_ratio->GetMaximumBin()));
955 hist_ratio->GetYaxis()->SetRangeUser(0.5, 1.5);
956 hist_ratio->GetXaxis()->SetTitle(xlabel);
957 hist_ratio->GetXaxis()->CenterTitle();
958 hist_ratio->GetXaxis()->SetTitleSize(0.10);
959 hist_ratio->GetXaxis()->SetTitleOffset(0.84);
960 hist_ratio->GetXaxis()->SetLabelSize(0.09);
961 hist_ratio->GetXaxis()->SetRangeUser(0, 5);
962 
963 hist_ratio_third->Draw("P same");
964 hist_ratio_third->SetLineColor(hthird->GetLineColor());
965 hist_ratio_third->SetMarkerColor(hthird->GetMarkerColor());
966 hist_ratio_third->SetMarkerStyle(20);
967 
968 TLine* one = new TLine(0, 1, 5, 1);
969 one->SetLineWidth(2);
970 one->SetLineStyle(7);
971 one->Draw();
972 
973 }//end of CompareHistos
974 //---------------------------------------------------------------//
975 //end of CompareHistos function
976 
977 void CompareHistosVec(TH1* hbase_orig, std::vector<TH1*> vec_hsec_orig){//, TString xlabel, TString ylabel, int cbase, int csec, int lbase, int lsec, float x1, float y1, float x2, float y2, TString legtitle, TString legbase, TString legsec, TString savefile){
978 
979 }
Float_t y1[n_points_granero]
Definition: compare.C:5
Float_t x1[n_points_granero]
Definition: compare.C:5
T sqrt(T number)
Definition: d0nt_math.hpp:156
TH1 * ratio(TH1 *h1, TH1 *h2)
constexpr T pow(T x)
Definition: pow.h:75
TH2F * modify2D(TH2F *h2D, TH1F *h1D, TString prediction)
void GraphAttr1D(TGraph *h, char *title_x, char *title_y)
double error_division(double num, double deno)
void CompareHistosVec(TH1 *hbase_orig, std::vector< TH1 * > vec_hsec_orig)
void CompareHistos(TH1 *hbase_orig, TH1 *hsec_orig, TString xlabel, TString ylabel, int cbase, int csec, int lbase, int lsec, float x1, float y1, float x2, float y2, TString legtitle, TString legbase, TString legsec, TString savefile)
void scaling(TH1D *hIn, const double shape_scale)
Double_t ymax
Definition: plot.C:25
#define P(a, b, c, d, e, x)
static constexpr double L
void ND_predictionbyMC(TH1F *h1, TH2F *h2)
TH1 * CorrectRange(TH1 *h, TString PID)
const Binning bins
OStream cout
Definition: OStream.cxx:6
TH1F * h2
Definition: plot.C:45
Double_t POTinformationMC()
TH1F * NDPrediction(TH2F *h)
void ND_predictionbyMC_usingbincontent(TH1F *hdata, TH2F *htruereco)
TH1F * h1
TH2F * ratio2D(TH2F *h1, TH2F *h2)
void HistogramAttr2D(TH2 *h, char *titlx_x, char *titlx_y, char *titlx_z, Double_t binlowx, Double_t binhighx, Double_t binlowy, Double_t binhighy)
int num
Definition: f2_nu.C:119
Double_t POTinformationData()
TH1F * Prob_me(TH1F *h)
TRandom3 r(0)
c1
Definition: demo5.py:24
void Format(TGraph *gr, int lcol, int lsty, int lwid, int mcol, int msty, double msiz)
Definition: Style.cxx:154
TH1F * FDPrediction(TH2F *h)
auto one()
Definition: PMNS.cxx:49
TPad * pad2
Definition: analysis.C:13
HistogramAttr1D(TH1 *h, char *title_x, char *title_y, Double_t binlowx, Double_t binhighx, Double_t binlowy, Double_t binhighy, Color_t lcolor)
TPad * pad1
Definition: analysis.C:13