fnex_vs_fnex_data_mc.C
Go to the documentation of this file.
1 //Author Prabhjot Singh
2 //Dated: June 27, 2017
3 //Comapres foloowing for both nue only and numu-nue joint analysis
4  //1. FNEX ND Data vs. FNEX ND Data,
5  //2. FNEX ND MC vs. FNEX ND MC
6  //3. FNEX ND Data vs. FNEX ND MC
7  //5. FNEX ND Data/MC vs. FNEX ND Data/MC and their double ratios
8  //
9  //
10  //6. FNEX FD Data vs. FNEX FD Data,
11  //7. FNEX FD MC vs. FNEX FD MC
12  //8. FNEX FD Data vs. FNEX FD MC
13  //10. FNEX FD Data/MC vs. FNEX FD Data/MC and their double ratios
14 
15 
16 //#include <Header.h>
17 #include <HistogramAttr.h>
18 
19 void CompareHistos_Here(TH1*, TH1*, TH1*
20  TString, TString,
21  int, int,
22  int, int,
23  float, float, float, float,
24  std::vector<TString>,
25  TString, TString, TString,
26  TCanvas*,
27  TString,
28  TString
29  );
30 
32  gStyle->SetOptStat(" ");
33 
34  //FNEX file old: GENIE
35  //1. join fit stats only
36  std::string f_fnex_old = "/nova/ana/users/prabhjot/FNEX/numu_nue_joint_analysis/BestFitPoint/StatOnly/RealData/NH/LO/from_interactive/latest/FNEX_prediction_at_FNEX_BFP/fnex_plotpoint_hist.root";
37 
38  TFile* file_fnex_old = new TFile(f_fnex_old.c_str());
39 
40  //FNEXfile new: NO GENIE
41  std::string f_fnex_new = "/nova/ana/users/prabhjot/FNEX/numu_nue_joint_analysis/BestFitPoint/StatOnly/RealData/NH/LO/from_interactive/latest/fnex_fitpoint_hist.root";
42 
43  TFile* file_fnex_new = new TFile(f_fnex_new.c_str());
44 
45  TString savefile; //Output pdf or png file
46 
47  TString fit_or_plot;
48  TString analysis = "joint";
49  TString syst = "stats";
50 
51  TString corr_uncorr = "Corrected"; // "Corrected" or "Uncorrected"
52 
53 
54 
55  TString PID[] = {"Low", "Mid", "High"}; //LOW, MID or HIGH PID bins
56  TString det[] = {"ND", "FD"};
57  TH1F* hfnex_old_data;
58  TH1F* hfnex_old_mc;
59  TH1F* hfnex_old_datamc_ratio;
60  TH1F* hfnex_new_data;
61  TH1F* hfnex_new_mc;
62  TH1F* hfnex_new_datamc_ratio;
63 
64  //loop over ND and FD detectors.
65  for(int idet = 0; idet < sizeof(det)/sizeof(det[0]); idet++){
66 
67  //Canvas for Data/MC ratio and double ratios
68  TCanvas* can_datamc_ratios = new TCanvas("can_"+det[idet]+"_datamcratios", " ", 1200, 600);
69  if(analysis=="nue") can_datamc_ratios ->Divide(3, 1);
70  else can_datamc_ratios ->Divide(4, 1);
71 
72  //Canvas for FNEX based Data and MC and their ratios: GENIE RW
73  TCanvas* can_datamc_fnex_old = new TCanvas("can_fnex_old_"+det[idet]+"_datamc", " ", 1200, 600);
74  if(analysis=="nue") can_datamc_fnex_old ->Divide(3, 1);
75  else can_datamc_fnex_old ->Divide(4, 1);
76 
77  //Canvas for FNEX based Data and MC and their ratios : NO GENIE RW
78  TCanvas* can_datamc_fnex = new TCanvas("can_fnex_"+det[idet]+"_datamc", " ", 1200, 600);
79  if(analysis=="nue") can_datamc_fnex ->Divide(3, 1);
80  else can_datamc_fnex ->Divide(4, 1);
81 
82  //Canvas for FNEX Data (including) vs. FNEX (excluding) Data and their ratios
83  TCanvas* can_data = new TCanvas("can_fnex_"+det[idet]+"_data", " ", 1200, 600);
84  if(analysis=="nue") can_data ->Divide(3, 1);
85  else can_data ->Divide(4, 1);
86 
87  //Canvas for FNEX MC (including) vs. FNEX MC (excluding) and their ratios
88  TCanvas* can_mc = new TCanvas("can_fnex_"+det[idet]+"_mc", " ", 1200, 600);
89  if(analysis=="nue") can_mc ->Divide(3, 1);
90  else can_mc ->Divide(4, 1);
91 
92  savefile=analysis+"_"+syst+"_fnex_vs_fnex_"+det[idet];
93 
94  if(analysis=="joint"){
95  //numu selected plots
96  //FNEX histograms
97  //GENIE RW
98  if(f_fnex_old.find("plotpoint") != std::string::npos) fit_or_plot = "plot" ; else fit_or_plot = "fit/Fit";
99  TH1F* hfnex_old_data = (TH1F*)file_fnex_old->Get(fit_or_plot+"/MultiExperiment/NOvA_NuMuSel/"+corr_uncorr+"Stacks/"+det[idet]+"Data"+corr_uncorr);
100  TH1F* hfnex_old_mc = (TH1F*)file_fnex_old->Get(fit_or_plot+"/MultiExperiment/NOvA_NuMuSel/"+corr_uncorr+"Stacks/"+det[idet]+"MC"+corr_uncorr);
101 
102  TH1F* hfnex_old_datamc_ratio = (TH1F*)ratio(hfnex_old_mc, hfnex_old_data);
103 
104  //FNEX histograms
105  //NO GENIE RW
106  if(f_fnex_new.find("plotpoint") != std::string::npos) fit_or_plot = "plot" ; else fit_or_plot = "fit/Fit";
107  TH1F* hfnex_new_data = (TH1F*)file_fnex_new->Get(fit_or_plot+"/MultiExperiment/NOvA_NuMuSel/"+corr_uncorr+"Stacks/"+det[idet]+"Data"+corr_uncorr);
108  TH1F* hfnex_new_mc = (TH1F*)file_fnex_new->Get(fit_or_plot+"/MultiExperiment/NOvA_NuMuSel/"+corr_uncorr+"Stacks/"+det[idet]+"MC"+corr_uncorr);
109 
110  TH1F* hfnex_new_datamc_ratio = (TH1F*)ratio(hfnex_new_mc, hfnex_new_data);
111 
112  //Draw Data/MC of FNEX (GENIE RW) vs. Data/MC of FNEX (NO GENIE RW) and their double ratios
113  can_datamc_ratios->cd(1);
114  std::vector<TString> legends;
115  legends.push_back(det[idet]);
116  legends.push_back("#nu_{#mu} Sel.");
118  hfnex_old_datamc_ratio,
119  hfnex_new_datamc_ratio,
120  "E^{reco}_{#nu} (GeV)",
121  "Data/MC",
122  632,
123  600,
124  2,
125  1,
126  0.55,
127  0.53,
128  0.80,
129  0.88,
130  legends,
131  "GENIE",
132  "NO GENIE",
133  "Double ratio",
134  can_datamc_ratios,
135  "P",
136  "no_scaling"
137  );
138 
139  //FNEX based Data and MC and their ratios: GENIE RW
140  can_datamc_fnex_old->cd(1);
141  std::vector<TString> legends;
142  legends.push_back("GENIE RW");
143  legends.push_back(det[idet]);
144  legends.push_back("#nu_{#mu} Sel.");
146  hfnex_old_mc,
147  hfnex_old_data,
148  "E^{reco}_{#nu} (GeV)",
149  "Events",
150  632,
151  600,
152  2,
153  1,
154  0.55,
155  0.53,
156  0.80,
157  0.88,
158  legends,
159  "MC",
160  "Data",
161  "ratio",
162  can_datamc_fnex_old,
163  "P",
164  "no_scaling"
165  );
166 
167  //FNEX Data vs. MC
168  //NO GENIE RW
169  can_datamc_fnex->cd(1);
170  std::vector<TString> legends;
171  legends.push_back("NO GENIE RW");
172  legends.push_back(det[idet]);
173  legends.push_back("#nu_{#mu} Sel.");
175  hfnex_new_mc,
176  hfnex_new_data,
177  "E^{reco}_{#nu} (GeV)",
178  "Events",
179  632,
180  600,
181  2,
182  1,
183  0.55,
184  0.53,
185  0.80,
186  0.88,
187  legends,
188  "MC",
189  "Data",
190  "ratio",
191  can_datamc_fnex,
192  "P",
193  "no_scaling"
194  );
195 
196  //FNEX Data (GENIE RW) vs. FNEX Data (NO GENIE RW)
197  can_data ->cd(1);
198  std::vector<TString> legends;
199  legends.push_back(det[idet]+" Data");
200  legends.push_back("#nu_{#mu} Sel.");
202  hfnex_old_data,
203  hfnex_new_data,
204  "E^{reco}_{#nu} (GeV)",
205  "Events",
206  632,
207  600,
208  2,
209  1,
210  0.55,
211  0.53,
212  0.80,
213  0.88,
214  legends,
215  "GENIE",
216  "NO GENIE",
217  "ratio",
218  can_data,
219  "HIST",
220  "yes_scaliing"
221  );
222 
223  //FNEX MC (GENIE RW) vs. FNEX MC (NO GENIE RW)
224  can_mc ->cd(1);
225  std::vector<TString> legends;
226  legends.push_back(det[idet]+" MC");
227  legends.push_back("#nu_{#mu} Sel.");
228 // if(det[idet]=="FD" && (hfnex_old_mc->GetName()).find("MC") != std::string::npos)
229 // CompareHistos_Here(
231  hfnex_old_mc,
232  hfnex_new_mc,
233 // h_fnex_fdmc,
234  "E^{reco}_{#nu} (GeV)",
235  "Events",
236  632,
237  600,
238  2,
239  1,
240  0.55,
241  0.53,
242  0.80,
243  0.88,
244  legends,
245  "GENIE",
246  "NO GENIE",
247  "ratio",
248  can_mc,
249  "HIST",
250  "yes_scaliing"
251  );
252 
253  delete hfnex_old_data;
254  delete hfnex_old_mc;
255  delete hfnex_new_data;
256  delete hfnex_new_mc;
257  delete hfnex_old_datamc_ratio;
258  delete hfnex_new_datamc_ratio;
259 // delete h_fnex_fdmc;
260  }//condition that it was joint fit
261 
262  //loop over three PIDs
263  for(int ipid = 0; ipid < sizeof(PID)/sizeof(PID[0]); ipid++){
264 
265  //FNEX histograms
266  //GENIE RW
267  if(f_fnex_old.find("plotpoint") != std::string::npos) fit_or_plot = "plot" ; else fit_or_plot = "fit/Fit";
268  TH1F* hfnex_old_data = (TH1F*)file_fnex_old->Get(fit_or_plot+"/MultiExperiment/NOvA_NuESel_"+PID[ipid]+"PID_NuMuSel/"+corr_uncorr+"Stacks/"+det[idet]+"Data"+corr_uncorr);
269 
270  TH1F* hfnex_old_mc = (TH1F*)file_fnex_old->Get(fit_or_plot+"/MultiExperiment/NOvA_NuESel_"+PID[ipid]+"PID_NuMuSel/"+corr_uncorr+"Stacks/"+det[idet]+"MC"+corr_uncorr);
271 
272  TH1F* hfnex_old_datamc_ratio = (TH1F*)ratio(hfnex_old_mc, hfnex_old_data);
273 
274  //FNEX histograms
275  //NO GENIE RW
276  if(f_fnex_new.find("plotpoint") != std::string::npos) fit_or_plot = "plot" ; else fit_or_plot = "fit/Fit";
277  TH1F* hfnex_new_data = (TH1F*)file_fnex_new->Get(fit_or_plot+"/MultiExperiment/NOvA_NuESel_"+PID[ipid]+"PID_NuMuSel/"+corr_uncorr+"Stacks/"+det[idet]+"Data"+corr_uncorr);
278  TH1F* hfnex_new_mc = (TH1F*)file_fnex_new->Get(fit_or_plot+"/MultiExperiment/NOvA_NuESel_"+PID[ipid]+"PID_NuMuSel/"+corr_uncorr+"Stacks/"+det[idet]+"MC"+corr_uncorr);
279 
280  TH1F* hfnex_new_datamc_ratio = (TH1F*)ratio(hfnex_new_mc, hfnex_new_data);
281 
282  //Draw Data/MC of FNEX (GENIE RW) vs. Data/MC of FNEX (NO GENIE RW) and their double ratios
283  if(analysis == "nue") can_datamc_ratios->cd(1+ipid);
284  else can_datamc_ratios->cd(2+ipid);
285  std::vector<TString> legends;
286  legends.push_back(det[idet]);
287  legends.push_back("#nu_{e} Sel.");
288  legends.push_back(PID[ipid]+ " CVN");
289 
291  hfnex_old_datamc_ratio,
292  hfnex_new_datamc_ratio,
293  "E^{reco}_{#nu} (GeV)",
294  "Data/MC",
295  632,
296  600,
297  2,
298  1,
299  0.55,
300  0.53,
301  0.80,
302  0.88,
303  legends,
304  "GENIE",
305  "NO GENIE",
306  "Double ratio",
307  can_datamc_ratios,
308  "P",
309  "no_scaling"
310  );
311 
312  //FNEX based Data and MC and their ratios: NO GENIE RW
313  if(analysis == "nue") can_datamc_fnex->cd(1+ipid);
314  else can_datamc_fnex->cd(2+ipid);
315  std::vector<TString> legends;
316  legends.push_back("NO GENIE RW");
317  legends.push_back(det[idet]);
318  legends.push_back("#nu_{e} Sel.");
319  legends.push_back(PID[ipid]+ " CVN");
321  hfnex_new_mc,
322  hfnex_new_data,
323  "E^{reco}_{#nu} (GeV)",
324  "Events",
325  632,
326  600,
327  2,
328  1,
329  0.55,
330  0.53,
331  0.80,
332  0.88,
333  legends,
334  "MC",
335  "Data",
336  "ratio",
337  can_datamc_fnex,
338  "P",
339  "no_scaling"
340  );
341 
342  //FNEX based Data and MC and their ratios: GENIE RW
343  if(analysis == "nue") can_datamc_fnex_old->cd(1+ipid);
344  else can_datamc_fnex_old->cd(2+ipid);
345  std::vector<TString> legends;
346  legends.push_back("GENIE RW");
347  legends.push_back(det[idet]);
348  legends.push_back("#nu_{e} Sel.");
349  legends.push_back(PID[ipid]+ " CVN");
351  hfnex_old_mc,
352  hfnex_old_data,
353  "E^{reco}_{#nu} (GeV)",
354  "Events",
355  632,
356  600,
357  2,
358  1,
359  0.55,
360  0.53,
361  0.80,
362  0.88,
363  legends,
364  "MC",
365  "Data",
366  "ratio",
367  can_datamc_fnex_old,
368  "P",
369  "no_scaling"
370  );
371 
372  //FNEX Data (GENIE RW) vs. FNEX Data (NO GENIE RW)
373  if(analysis == "nue") can_data ->cd(1+ipid);
374  else can_data ->cd(2+ipid);
375  std::vector<TString> legends;
376  legends.push_back(det[idet]+" Data");
377  legends.push_back("#nu_{e} Sel.");
378  legends.push_back(PID[ipid]+ " CVN");
380  hfnex_old_data,
381  hfnex_new_data,
382  "E^{reco}_{#nu} (GeV)",
383  "Events",
384  632,
385  600,
386  2,
387  1,
388  0.55,
389  0.53,
390  0.80,
391  0.88,
392  legends,
393  "GENIE",
394  "NO GENIE",
395  "ratio",
396  can_data,
397  "HIST",
398  "no_scaling"
399  );
400 //
401  //FNEX MC (GENIE) vs. FNEX MC (NO GENIE)
402  if(analysis == "nue") can_mc ->cd(1+ipid);
403  else can_mc ->cd(2+ipid);
404  std::vector<TString> legends;
405  legends.push_back(det[idet]+" MC ");
406  legends.push_back("#nu_{e} Sel.");
407  legends.push_back(PID[ipid]+ " CVN");
408  // if(det[idet]=="FD" && PID[ipid]=="Low")
409  // CompareHistos_Here(
411  hfnex_old_mc,
412  hfnex_new_mc,
413  // h_fnex_fdmc,
414  "E^{reco}_{#nu} (GeV)",
415  "Events",
416  632,
417  600,
418  2,
419  1,
420  0.55,
421  0.53,
422  0.80,
423  0.88,
424  legends,
425  "GENIE",
426  "NO GENIE",
427  "ratio",
428  can_mc,
429  "HIST",
430  "yes_scaling"
431  );
432 
433  delete hfnex_old_data;
434  delete hfnex_old_mc;
435  delete hfnex_new_data;
436  delete hfnex_new_mc;
437  delete hfnex_old_datamc_ratio;
438  delete hfnex_new_datamc_ratio;
439  //delete h_fnex_fdmc;
440 
441  }//end of loop over three CVN pids
442 
443  can_datamc_ratios ->cd();
444  can_datamc_ratios ->SaveAs("/nova/app/users/prabhjot/mrb_build/srcs/novasoft/FNEX/macros/Images/fnexvscaf/"+savefile+"_datamcratios.png");
445 
446  can_datamc_fnex_old ->cd();
447  can_datamc_fnex_old ->SaveAs("/nova/app/users/prabhjot/mrb_build/srcs/novasoft/FNEX/macros/Images/fnexvscaf/"+savefile+"_FNEX_GENIERW_DataMC.png");
448 
449  can_datamc_fnex ->cd();
450  can_datamc_fnex ->SaveAs("/nova/app/users/prabhjot/mrb_build/srcs/novasoft/FNEX/macros/Images/fnexvscaf/"+savefile+"_FNEX_NOGENIERW_DataMC.png");
451 
452 
453  can_data ->cd();
454  can_data ->SaveAs("/nova/app/users/prabhjot/mrb_build/srcs/novasoft/FNEX/macros/Images/fnexvscaf/"+savefile+"_Data.png");
455 
456  can_mc ->cd();
457  can_mc ->SaveAs("/nova/app/users/prabhjot/mrb_build/srcs/novasoft/FNEX/macros/Images/fnexvscaf/"+savefile+"_MC.png");
458 
459  }//end of loop over detectors
460 
461 }//end of main function
462 
463 //////////////////////////////////////////////////////////////////////////////////////
464 void CompareHistos_Here(TH1* hbase_orig,
465  TH1* hsec_orig,
466  TH1* h_fnex_fdmc,
467  TString xlabel,
468  TString ylabel,
469  int cbase,
470  int csec,
471  int lbase,
472  int lsec,
473  float x1,
474  float y1,
475  float x2,
476  float y2,
477  std::vector<TString> legtitle,
478  TString legbase,
479  TString legsec,
480  TString leg_ratio,
481  TCanvas* c1,
482  TString draw_option,
483  TString scaling ){
484 
485  TH1F* hbase = (TH1F*)hbase_orig ->Clone("hbase");
486  TH1F* hsec = (TH1F*)hsec_orig ->Clone("hsec");
487 
488  double ymax = 0.;
489 
490  TPad* pad1 = new TPad("pad1", " ", 0.05, 0.40, 0.95, 1.00);
491  TPad* pad2 = new TPad("pad2", " ", 0.05, 0.05, 0.95, 0.46);
492  pad1->Draw();
493  pad2->Draw();
494 
495  pad1->cd();
496  gPad->SetLeftMargin(0.20);
497 
498  if(hsec->GetBinContent(hsec->GetMaximumBin()) > hbase->GetBinContent(hbase->GetMaximumBin()) )
499  ymax = 1.1*hsec->GetBinContent(hsec->GetMaximumBin());
500  else if(hsec->GetBinContent(hsec->GetMaximumBin()) <= hbase->GetBinContent(hbase->GetMaximumBin()) )
501  ymax = 1.1*hbase->GetBinContent(hbase->GetMaximumBin());
502 
503  hsec ->Draw(draw_option + "same");
504  hbase->Draw(draw_option + "same");
505 
506  hsec->GetXaxis()->SetRangeUser(0, 5);
507  hsec->GetYaxis()->SetRangeUser(0, 2*ymax);
508  hsec->GetYaxis()->SetTitle(ylabel);
509  hsec->GetYaxis()->CenterTitle();
510  hsec->GetYaxis()->SetTitleSize(0.09);
511  hsec->GetYaxis()->SetTitleOffset(1.15);
512  hsec->GetYaxis()->SetLabelSize(0.06);
513  hsec->GetYaxis()->SetDecimals();
514  hsec->GetXaxis()->SetDecimals();
515  hsec->GetXaxis()->SetTitle(xlabel);
516  hsec->SetLineColor(csec);
517  hsec->SetFillColor(0);
518  hsec->SetLineWidth(3);
519  hsec->SetLineStyle(lsec);
520  hsec->SetMarkerStyle(20);
521  hsec->SetMarkerColor(csec);
522 
523  hbase->SetLineColor(cbase);
524  hbase->SetFillColor(0);
525  hbase->SetLineWidth(3);
526  hbase->SetLineStyle(lbase);
527  hbase->SetMarkerStyle(20);
528  hbase->SetMarkerColor(cbase);
529  hsec->GetXaxis()->SetNdivisions(508);
530  hsec->GetXaxis()->CenterTitle();
531  hsec->GetXaxis()->SetTitleSize(0.06);
532  hsec->GetXaxis()->SetTitleOffset(0.84);
533  hsec->GetXaxis()->SetLabelSize(0.06);
534  hsec->GetXaxis()->SetRangeUser(0, 5);
535 
536  TLegend* legend = new TLegend(x1, y1 ,x2, y2);
537  legend->SetBorderSize(0);
538  legend->SetFillStyle(0);
539  legend->SetTextSize(0.030);
540  for(int i = 0; i < legtitle.size(); ++i)
541  legend->AddEntry((TObject*)0, legtitle[i]," ");
542  legend->AddEntry(hsec, legsec, "l");
543  legend->AddEntry(hbase, legbase, "l");
544  legend->SetTextSize(0.05);
545  legend->Draw();
546 
547  TLine* one = new TLine(0, 1, 5, 1);
548  one->SetLineWidth(2);
549  one->SetLineStyle(7);
550  //one->Draw();
551  //Use random number to make unique name for ratio histogram
552  //initialize random seed:
553 
554  TH1F* hist_ratio = new TH1F(TString::Format("hist_ratio_%i", rand()), "", hbase->GetNbinsX(), hbase->GetXaxis()->GetXmin(), hbase->GetXaxis()->GetXmax());
555 
556  hist_ratio->Sumw2();
557  legend->AddEntry(hist_ratio, legsec+"/"+legbase, "lep");
558  double ratio = 0.;
559  double ratio_error = 0.;
560  double fractional_error_num = 0;
561  double fractional_error_deno = 0;
562 
563  std::cout << " " << std::endl;
564  std::cout << "name of the FNEX FD MC histogram = " << h_fnex_fdmc->GetName() << std::endl;
565  std::cout << " " << std::endl;
566 
567  for(int i = 1; i < hbase->GetNbinsX()+1; ++i){
568  if(h_fnex_fdmc->GetBinContent(i) == 0){
569  fractional_error_num = 0;
570  fractional_error_deno = 0;
571  }
572  else{
573  fractional_error_num = std::sqrt(h_fnex_fdmc->GetBinContent(i))*(hsec->GetBinContent(i)/h_fnex_fdmc->GetBinContent(i)) ;
574  fractional_error_deno = std::sqrt(h_fnex_fdmc->GetBinContent(i))*(hbase ->GetBinContent(i)/h_fnex_fdmc->GetBinContent(i)) ;
575  }
576  // if(hbase->GetBinContent(i)==0) ratio = 0.;
577  // else ratio = hsec->GetBinContent(i)/hbase->GetBinContent(i);
578  if(hbase->GetBinContent(i)==0 || hsec->GetBinContent(i)==0 || fractional_error_deno==0) ratio_error = 0.;
579  // else ratio_error = error_division_here(h_fnex_fdmc->GetBinContent(i), h_fnex_fdmc->GetBinContent(i));
580  else ratio_error = (hsec->GetBinContent(i)/hbase->GetBinContent(i))*std::sqrt(std::pow(fractional_error_num/hsec->GetBinContent(i), 2 ) + std::pow(fractional_error_deno/hbase->GetBinContent(i), 2 ) );
581  // hist_ratio->SetBinContent(i, ratio);
582  hist_ratio->SetBinError(i, ratio_error);
583  if(hbase->GetBinContent(i)!=0 && hsec->GetBinContent(i)!=0 && fractional_error_deno!=0)
584  std::cout
585  << " Bin " << i
586  << " BinContent (FDMC) " << h_fnex_fdmc->GetBinContent(i)
587  << " BinContent: (FNEX) " << hsec ->GetBinContent(i)
588  << " BinContent: (CAF) " << hbase ->GetBinContent(i)
589  << " BinError (FDMC) " << h_fnex_fdmc->GetBinError(i)
590  // << " BinError (FNEX) " << hsec ->GetBinError(i)
591  // << " BinError (CAF ) " << hbase ->GetBinError(i)
592  << " FractionalError (FNEX) " << fractional_error_num
593  << " FractionalError (CAF) " << fractional_error_deno
594  << " Modified Error: " << ratio_error << std::endl;
595  }//end of bin by bin ratio
596 
597  pad2->cd();
598  gPad->SetBottomMargin(0.40);
599  gPad->SetLeftMargin(0.20);
600  hist_ratio->Draw("P");
601  hist_ratio->SetLineColor(kBlack);
602  hist_ratio->SetMarkerColor(kBlack);
603  hist_ratio->SetMarkerStyle(20);
604  hist_ratio->GetYaxis()->SetTitle(leg_ratio);
605  hist_ratio->GetYaxis()->CenterTitle();
606  hist_ratio->GetYaxis()->SetTitleSize(0.10);
607  hist_ratio->GetYaxis()->SetTitleOffset(1.06);
608  hist_ratio->GetYaxis()->SetLabelSize(0.08);
609  hist_ratio->GetYaxis()->SetDecimals();
610  //hist_ratio->GetYaxis()->SetRangeUser(0.9, 1.05*hist_ratio->GetBinContent(hist_ratio->GetMaximumBin()));
611  //hist_ratio->GetYaxis()->SetRangeUser(0.8, 1.2);
612  hist_ratio->GetXaxis()->SetTitle(xlabel);
613  hist_ratio->GetXaxis()->CenterTitle();
614  hist_ratio->GetXaxis()->SetTitleSize(0.10);
615  hist_ratio->GetXaxis()->SetTitleOffset(0.84);
616  hist_ratio->GetXaxis()->SetLabelSize(0.09);
617  hist_ratio->GetXaxis()->SetRangeUser(0, 5);
618 
619  TLine* one = new TLine(0, 1, 5, 1);
620  one->SetLineWidth(2);
621  one->SetLineStyle(7);
622  one->Draw();
623 
624  //Scale hsec wrt to base
625  if(scaling.Contains("yes"))
626  hsec->Scale(hbase->Integral()/hsec->Integral());
627 
628  //Find ratios post-normalization
629  for(int i = 0; i < hbase->GetNbinsX()+1; ++i){
630  if(hbase->GetBinContent(i)==0) ratio = 0.;
631  else ratio = hsec->GetBinContent(i)/hbase->GetBinContent(i);
632  hist_ratio->SetBinContent(i, ratio);
633  }//end of bin by bin ratio
634 
635 }//end of CompareHistos function
636 
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
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
OStream cout
Definition: OStream.cxx:6
void CompareHistos_Here(TH1 *, TH1 *, TH1 *TString, TString, int, int, int, int, float, float, float, float, std::vector< TString >, TString, TString, TString, TCanvas *, TString, TString)
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
auto one()
Definition: PMNS.cxx:49
TPad * pad2
Definition: analysis.C:13
void fnex_vs_fnex_data_mc()
TPad * pad1
Definition: analysis.C:13
enum BeamMode string