make_DiF_plots.C
Go to the documentation of this file.
1 /////////////////////////////////////////////////
2 // DISCLAIMER
3 
4 
5 // I couldn't find an easy way to automate the yaxis upper limit in a way that
6 // allowed for the legend to not get in the way because of all the rebinning
7 // and normalization.
8 // Therefore, unfortunately, you kind of have to iteratively go through and manually
9 // set the y axis for each plot using the structure created at L87
10 
11 /////////////////////////////////////////////////
12 
13 #include "TLine.h"
14 #include "Rtypes.h"
15 
16 #include "TCanvas.h"
17 #include "TFile.h"
18 #include "TGraph.h"
19 #include "TH1.h"
20 #include "TH2.h"
21 #include "TMath.h"
22 #include "TGaxis.h"
23 #include "TMultiGraph.h"
24 #include "TLegend.h"
25 #include "TLegendEntry.h"
26 #include "TLatex.h"
27 #include "TStyle.h"
28 #include "THStack.h"
29 #include "TPaveText.h"
30 #include "TList.h"
31 #include "TGaxis.h"
32 #include "TAttLine.h"
33 #include "TAttMarker.h"
34 
35 #include <cmath>
36 #include <iostream>
37 #include <vector>
38 #include <list>
39 #include <sstream>
40 #include <string>
41 #include <sstream>
42 #include <fstream>
43 #include <iomanip>
44 
45 #include "CAFAna/Core/Spectrum.h"
46 #include "CAFAna/Analysis/Plots.h"
47 #include "CAFAna/Analysis/Style.h"
48 #include "TColor.h"
49 
50 using namespace ana;
51 
53 {
54  TLatex* prelim = new TLatex(.9, .95, "NOvA Preliminary");
55  prelim->SetTextColor(kBlue);
56  prelim->SetNDC();
57  prelim->SetTextSize(2/30.);
58  prelim->SetTextAlign(32);
59  prelim->Draw();
60 }
61 
62 //the DrawBeamLabel in Plots.h works for the other plots
63 //but not quite for the efficiency plots
65 {
66  TPaveText *pText = new TPaveText (0.1, 0.94, 0.16, 0.98,"NDC");
67  pText->SetFillStyle(0);
68  pText->SetLineColor(0);
69  pText->SetLineWidth(0);
70  pText->SetBorderSize(1);
71  pText->SetTextColor(kGray+2);
72  //pText->SetNDC();
73  if (isFHC) pText->AddText("#nu-beam");
74  else pText->AddText("#bar{#nu}-beam");
75  pText->SetTextSize(2/40.);
76  pText->SetTextAlign(11);
77  pText->Draw();
78 }
79 
80 
81 //same list from the Step 2 macro, but different structure as
82 //we want to automate different things now
83 //rebinAmt = 0 will mean no rebinning
84 struct Plot{const char* savename; const char* XaxisLabel; int rebinAmt; int legSide; int yAxisLimit;};
85 const std::vector<Plot> plots = {
86  {"Shw_Angle", "Cos(#theta_{beam})", 0, 0, 7000},
87  {"NHits_in_slice", "Hits in Slice", 4, 1, 8000},
88  {"NHits_in_shower", "Hits in Shower", 4, 1, 8000},
89  {"Shw_E", "Energy in Shower (GeV)", 8, 1, 6000},
90  {"E_per_Hit", "GeV / Hit", 0, 1, 0},
91  {"CVNe", "CVN #nu_{e} selector", 4, 0, 11000},
92  {"Shw_Width", "Shower Width (cm)", 2, 1, 8000},
93  {"Shw_Length", "Shower Length (cm)", 2, 1, 8000},
94  {"Shw_Start X", "Shower Start X", 32, 0, 3000},
95  {"Shw_Start Y", "Shower Start Y", 32, 0, 0},
96  {"Shw_Start Z", "Shower Start Z", 50, 0, 1500},
97  {"Vtx_X", "Vertex Location X", 32, 0, 3000},
98  {"Vtx_Y", "Vertex Location Y", 32, 0, 0},
99  {"Vtx_Z", "Vertex Location Z", 50, 0, 1500},
100  {"Distance_Top", "Distance to Top (cm)", 100, 1, 4000},
101  {"Distance_Bottom", "Distance to Bottom (cm)", 100, 0, 2500},
102  {"Distance_East", "Distance to East Face", 16, 1, 5000},
103  {"Distance_West", "Distance to West Face", 16, 1, 5000},
104  {"Distance_Front", "Distance to Front", 50, 0, 1500},
105  {"Distance_Back", "Distance to Back", 100, 0, 2800}
106 };
107 
108 void makePlot(TCanvas *c1, TH1 *hCosmicsData, TH1 *hCRYMC, TH1 *hGENIEFluxswap, int sel, int legSide, bool isFHC);
109 void makeWgtdPlot(TCanvas *c1, TH1 *hCosmicsData, TH1 *hCRYMC, TH1 *hGENIEFluxswap, int sel, int legSide, bool isFHC);
110 void makePlot(TCanvas *c1, TH1 *hCosmicsData, TH1 *hCRYMC, int sel, int legSide);
111 void makeWgtdPlot(TCanvas *c1, TH1 *hCosmicsData, TH1 *hCRYMC, int sel, int legSide);
112 void makeDataCryRatio(TCanvas *c1, TH1 *hCosmicsData, TH1 *hCRYMC, int sel, int legSide, bool isFHC, bool isWgtd);
113 void makeEffPlot(TCanvas *c1, TH1 *hCosmicsDataCore, TH1 *hCosmicsDataPresel, TH1 *hCRYMCCore, TH1 *hCRYMCPresel, int legSide, bool isFHC);
114 void makeWgtdEffPlot(TCanvas *c1, TH1 *hCosmicsDataCore, TH1 *hCosmicsDataPresel, TH1 *hCRYMCCore, TH1 *hCRYMCPresel, int legSide, bool isFHC);
115 void makeEffPlotNoRatio(TCanvas *c1, TH1 *hCosmicsDataCEff, TH1 *hCRYMCCoreEff, int legSide, bool isFHC, bool isWgtd);
116 
117 
119 {
120 
121 
122 
123  //get input file opened
124  std::string inFile = "/nova/app/users/amhall/DiF_Cafana_4-6-2020/3FlavorAna/Ana2020/MRstudies/MRDiF_FD_"+beam+"_Step2_v2_clean.root";
125  TFile *f1 = new TFile(inFile.c_str());
126  f1->cd();
127 
128  //get just a couple of the spectra to set our livetime and POT before getting the rest
129  auto sForLivetime=*Spectrum::LoadFrom(f1, "sDataPresel_V0");
130  auto sForPOT=*Spectrum::LoadFrom(f1, "sGENIEPresel_V0");
131 
132  double mylivetime=sForLivetime.Livetime();
133  double myPOT=sForPOT.POT();
134  std::cout<<"myPOT:"<<myPOT<<" mylivetime:"<<mylivetime<<std::endl;
135 
136  std::vector<TH1D*> hDataPresel, hCRYMCPresel, hGENIEPresel, hData, hCRYMC, hGENIE;
137  std::vector<TH1D*> hDataPreselWtd, hCRYMCPreselWtd, hDataWtd, hCRYMCWtd;
138  std::vector<TH1D*> hDataEff, hDataWtdEff, hCRYMCEff, hCRYMCWtdEff;
139  std::vector<TH1D*> hDataPreselEff, hDataPreselWtdEff, hCRYMCPreselEff, hCRYMCPreselWtdEff;
140 
141  char dirname[64];
142  for( unsigned int i =0; i < plots.size(); i++)
143  {
144  //load in Data histos
145 
146  sprintf(dirname, "sDataPresel_V%d", i);
147  std::unique_ptr<Spectrum> sDataPresel = Spectrum::LoadFrom(f1, dirname);
148  hDataPresel.push_back(sDataPresel->ToTH1(mylivetime, kLivetime));
149 
150  sprintf(dirname, "sData_V%d", i);
151  std::unique_ptr<Spectrum> sData = Spectrum::LoadFrom(f1, dirname);
152  hData.push_back(sData->ToTH1(mylivetime, kLivetime));
153 
154  sprintf(dirname, "sDataPreselWtd_V%d", i);
155  std::unique_ptr<Spectrum> sDataPreselWtd = Spectrum::LoadFrom(f1, dirname);
156  hDataPreselWtd.push_back(sDataPreselWtd->ToTH1(mylivetime, kLivetime));
157 
158  sprintf(dirname, "sDataWtd_V%d", i);
159  std::unique_ptr<Spectrum> sDataWtd = Spectrum::LoadFrom(f1, dirname);
160  hDataWtd.push_back(sDataWtd->ToTH1(mylivetime, kLivetime));
161 
162  //and the CRYMC histos
163 
164  sprintf(dirname, "sCRYMCPresel_V%d", i);
165  std::unique_ptr<Spectrum> sCRYMCPresel = Spectrum::LoadFrom(f1, dirname);
166  hCRYMCPresel.push_back(sCRYMCPresel->ToTH1(mylivetime, kLivetime));
167 
168  sprintf(dirname, "sCRYMC_V%d", i);
169  std::unique_ptr<Spectrum> sCRYMC = Spectrum::LoadFrom(f1, dirname);
170  hCRYMC.push_back(sCRYMC->ToTH1(mylivetime, kLivetime));
171 
172  sprintf(dirname, "sCRYMCPreselWtd_V%d", i);
173  std::unique_ptr<Spectrum> sCRYMCPreselWtd = Spectrum::LoadFrom(f1, dirname);
174  hCRYMCPreselWtd.push_back(sCRYMCPreselWtd->ToTH1(mylivetime, kLivetime));
175 
176  sprintf(dirname, "sCRYMCWtd_V%d", i);
177  std::unique_ptr<Spectrum> sCRYMCWtd = Spectrum::LoadFrom(f1, dirname);
178  hCRYMCWtd.push_back(sCRYMCWtd->ToTH1(mylivetime, kLivetime));
179 
180  //and the GENIE histos
181 
182  sprintf(dirname, "sGENIEPresel_V%d", i);
183  std::unique_ptr<Spectrum> sGENIEPresel = Spectrum::LoadFrom(f1, dirname);
184  hGENIEPresel.push_back(sGENIEPresel->ToTH1(myPOT));
185 
186  sprintf(dirname, "sGENIE_V%d", i);
187  std::unique_ptr<Spectrum> sGENIE = Spectrum::LoadFrom(f1, dirname);
188  hGENIE.push_back(sGENIE->ToTH1(myPOT));
189 
190  //and get copies of the data and CRY selected histos to make efficiencies with
191  hDataEff.push_back(sData->ToTH1(mylivetime, kLivetime));
192  hDataWtdEff.push_back(sDataWtd->ToTH1(mylivetime, kLivetime));
193  hDataPreselEff.push_back(sDataPresel->ToTH1(mylivetime, kLivetime));
194  hDataPreselWtdEff.push_back(sDataPreselWtd->ToTH1(mylivetime, kLivetime));
195 
196  hCRYMCEff.push_back(sCRYMC->ToTH1(mylivetime, kLivetime));
197  hCRYMCWtdEff.push_back(sCRYMCWtd->ToTH1(mylivetime, kLivetime));
198  hCRYMCPreselEff.push_back(sCRYMCPresel->ToTH1(mylivetime, kLivetime));
199  hCRYMCPreselWtdEff.push_back(sCRYMCPreselWtd->ToTH1(mylivetime, kLivetime));
200 
201  }
202 
203  //kNormFactor = hDataPresel[0]->Integral(); //will area normalize to the cosmic data preselected number of events
204 
205 
206  std::cout<<"NO NORM FACTORS HERE \n";
207  std::cout<<"===================================== Before reweighting================================================"<<std::endl;
208  std::cout<<" Cosmic Data "<<" CRYMC "<<" GENIE "<<std::endl;
209  std::cout<<"========================================================================================================="<<std::endl;
210  std::cout<<"CorePresel :"<<hDataPresel[0]->Integral()<<" "<<hCRYMCPresel[0]->Integral()<<" "<< hGENIEPresel[0]->Integral()<<std::endl;
211  std::cout<<"Core :"<<hData[0]->Integral()<<" "<<hCRYMC[0]->Integral()<<" "<< hGENIE[0]->Integral()<<std::endl;
212 
213  std::cout<<"NO NORM FACTORS HERE \n";
214  std::cout<<"===================================== After reweighting================================================"<<std::endl;
215  std::cout<<" Cosmic Data "<<" CRYMC "<<" GENIE "<<std::endl;
216  std::cout<<"========================================================================================================="<<std::endl;
217  std::cout<<"CorePresel :"<<hDataPreselWtd[0]->Integral()<<" "<<hCRYMCPreselWtd[0]->Integral()<<" "<< hGENIEPresel[0]->Integral()<<std::endl;
218  std::cout<<"Core :"<<hDataWtd[0]->Integral()<<" "<<hCRYMCWtd[0]->Integral()<<" "<< hGENIE[0]->Integral()<<std::endl;
219 
220 
221  //make any messy variable specific adjustments that have to happen before the plot making-------------------------------------
222 
223  for(unsigned int var=0; var<hData.size(); var++)
224  {
225  //take care of any and all rebinning first
226  if(plots[var].rebinAmt != 0)
227  {
228  hDataPresel[var]->Rebin(plots[var].rebinAmt);
229  hCRYMCPresel[var]->Rebin(plots[var].rebinAmt);
230  hGENIEPresel[var]->Rebin(plots[var].rebinAmt);
231  hData[var]->Rebin(plots[var].rebinAmt);
232  hCRYMC[var]->Rebin(plots[var].rebinAmt);
233  hGENIE[var]->Rebin(plots[var].rebinAmt);
234 
235  hDataPreselWtd[var]->Rebin(plots[var].rebinAmt);
236  hCRYMCPreselWtd[var]->Rebin(plots[var].rebinAmt);
237  hDataWtd[var]->Rebin(plots[var].rebinAmt);
238  hCRYMCWtd[var]->Rebin(plots[var].rebinAmt);
239 
240  hDataPreselEff[var]->Rebin(plots[var].rebinAmt);
241  hCRYMCPreselEff[var]->Rebin(plots[var].rebinAmt);
242  hDataEff[var]->Rebin(plots[var].rebinAmt);
243  hCRYMCEff[var]->Rebin(plots[var].rebinAmt);
244 
245  hDataPreselWtdEff[var]->Rebin(plots[var].rebinAmt);
246  hCRYMCPreselWtdEff[var]->Rebin(plots[var].rebinAmt);
247  hDataWtdEff[var]->Rebin(plots[var].rebinAmt);
248  hCRYMCWtdEff[var]->Rebin(plots[var].rebinAmt);
249  }
250  }
251 
252  //even with our angle cut at the previous stage, a few events still snuck into the last bin by being on the bin edge
253  //so gonna clean those out
254  int lastBin = hData[0]->GetXaxis()->GetLast();
255  hData[0]->SetBinContent(lastBin, 0);
256  hDataPresel[0]->SetBinContent(lastBin, 0);
257  hDataEff[0]->SetBinContent(lastBin, 0);
258  hDataWtd[0]->SetBinContent(lastBin, 0);
259  hDataPreselWtd[0]->SetBinContent(lastBin, 0);
260  hDataWtdEff[0]->SetBinContent(lastBin, 0);
261 
262  hData[0]->SetBinError(lastBin, 0);
263  hDataPresel[0]->SetBinError(lastBin, 0);
264  hDataEff[0]->SetBinError(lastBin, 0);
265  hDataWtd[0]->SetBinError(lastBin, 0);
266  hDataPreselWtd[0]->SetBinError(lastBin, 0);
267  hDataWtdEff[0]->SetBinError(lastBin, 0);
268 
269  hCRYMC[0]->GetXaxis()->SetRangeUser(0.4, 1.0);
270  hCRYMCPresel[0]->GetXaxis()->SetRangeUser(0.4, 1.0);
271  hCRYMCEff[0]->GetXaxis()->SetRangeUser(0.4, 1.0);
272  hCRYMCWtd[0]->GetXaxis()->SetRangeUser(0.4, 1.0);
273  hCRYMCPreselWtd[0]->GetXaxis()->SetRangeUser(0.4, 1.0);
274  hCRYMCWtdEff[0]->GetXaxis()->SetRangeUser(0.4, 1.0);
275 
276  hData[0]->GetXaxis()->SetRangeUser(0.4, 1.0);
277  hDataPresel[0]->GetXaxis()->SetRangeUser(0.4, 1.0);
278  hDataEff[0]->GetXaxis()->SetRangeUser(0.4, 1.0);
279  hDataWtd[0]->GetXaxis()->SetRangeUser(0.4, 1.0);
280  hDataPreselWtd[0]->GetXaxis()->SetRangeUser(0.4, 1.0);
281  hDataWtdEff[0]->GetXaxis()->SetRangeUser(0.4, 1.0);
282 
283  hCRYMC[3]->GetXaxis()->SetRangeUser(0, 4.0);
284  hCRYMCPresel[3]->GetXaxis()->SetRangeUser(0, 4.0);
285  hCRYMCEff[3]->GetXaxis()->SetRangeUser(0, 4.0);
286  hCRYMCWtd[3]->GetXaxis()->SetRangeUser(0, 4.0);
287  hCRYMCPreselWtd[3]->GetXaxis()->SetRangeUser(0, 4.0);
288  hCRYMCWtdEff[3]->GetXaxis()->SetRangeUser(0, 4.0);
289 
290  hData[3]->GetXaxis()->SetRangeUser(0, 4.0);
291  hDataPresel[3]->GetXaxis()->SetRangeUser(0, 4.0);
292  hDataEff[3]->GetXaxis()->SetRangeUser(0, 4.0);
293  hDataWtd[3]->GetXaxis()->SetRangeUser(0, 4.0);
294  hDataPreselWtd[3]->GetXaxis()->SetRangeUser(0, 4.0);
295  hDataWtdEff[3]->GetXaxis()->SetRangeUser(0, 4.0);
296 
297  //this is just because the last energy bin only had data events in it
298  //so clearing it out makes the eff. plots look nicer
299  //as there isn't an eff. for the CRY in this bin
300  lastBin = hDataEff[3]->GetXaxis()->GetLast();
301  hDataEff[3]->SetBinContent(lastBin, 0);
302  hDataWtdEff[3]->SetBinContent(lastBin, 0);
303  hDataEff[3]->SetBinError(lastBin, 0);
304  hDataWtdEff[3]->SetBinError(lastBin, 0);
305 
306  hCRYMC[4]->GetXaxis()->SetRangeUser(0, 0.1);
307  hCRYMCPresel[4]->GetXaxis()->SetRangeUser(0, 0.1);
308  hCRYMCEff[4]->GetXaxis()->SetRangeUser(0, 0.1);
309  hCRYMCWtd[4]->GetXaxis()->SetRangeUser(0, 0.1);
310  hCRYMCPreselWtd[4]->GetXaxis()->SetRangeUser(0, 0.1);
311  hCRYMCWtdEff[4]->GetXaxis()->SetRangeUser(0, 0.1);
312 
313  hCRYMC[5]->GetXaxis()->SetRangeUser(0.3, 1);
314  hCRYMCPresel[5]->GetXaxis()->SetRangeUser(0.3, 1.0);
315  hCRYMCEff[5]->GetXaxis()->SetRangeUser(0.3, 1.0);
316  hCRYMCWtd[5]->GetXaxis()->SetRangeUser(0.3, 1.0);
317  hCRYMCPreselWtd[5]->GetXaxis()->SetRangeUser(0.3, 1.0);
318  hCRYMCWtdEff[5]->GetXaxis()->SetRangeUser(0.3, 1.0);
319 
320  hData[4]->GetXaxis()->SetRangeUser(0, 0.1);
321  hDataPresel[4]->GetXaxis()->SetRangeUser(0, 0.1);
322  hDataEff[4]->GetXaxis()->SetRangeUser(0, 0.1);
323  hDataWtd[4]->GetXaxis()->SetRangeUser(0, 0.1);
324  hDataPreselWtd[4]->GetXaxis()->SetRangeUser(0, 0.1);
325  hDataWtdEff[4]->GetXaxis()->SetRangeUser(0, 0.1);
326 
327  hData[5]->GetXaxis()->SetRangeUser(0.3, 1);
328  hDataPresel[5]->GetXaxis()->SetRangeUser(0.3, 1.0);
329  hDataEff[5]->GetXaxis()->SetRangeUser(0.3, 1.0);
330  hDataWtd[5]->GetXaxis()->SetRangeUser(0.3, 1.0);
331  hDataPreselWtd[5]->GetXaxis()->SetRangeUser(0.3, 1.0);
332  hDataWtdEff[5]->GetXaxis()->SetRangeUser(0.3, 1.0);
333 
334 
335  //and let's make some plots!
336 
337  char saveName[128];
338  for(unsigned int var=0; var < 6; var ++)//var<hData.size(); var++)
339  {
340 
341  //unweighted distributions--------------------------------------------------
342  TCanvas *c1 = new TCanvas("c1", "presel distributions", 800,600);
343  hCRYMCPresel[var]->GetXaxis()->SetTitle(plots[var].XaxisLabel);
344  makePlot(c1, &*hDataPresel[var], &*hCRYMCPresel[var], &*hGENIEPresel[var], 0, plots[var].legSide, beam=="FHC" ? true : false);
345  DrawBeamLabel(beam=="FHC" ? true : false);
346 
347  TCanvas *c2 = new TCanvas("c2", "distributions", 800,600);
348  hCRYMC[var]->GetXaxis()->SetTitle(plots[var].XaxisLabel);
349  makePlot(c2, &*hData[var], &*hCRYMC[var], &*hGENIE[var], 1, plots[var].legSide, beam=="FHC" ? true : false);
350  DrawBeamLabel(beam=="FHC" ? true : false);
351 
352  if(plots[var].yAxisLimit != 0) {
353  hCRYMCPresel[var]->GetYaxis()->SetRangeUser(0, plots[var].yAxisLimit);
354  hCRYMC[var]->GetYaxis()->SetRangeUser(0, plots[var].yAxisLimit);
355  }
356 
357  //weighted distributions-------------------------------------------------------
358  TCanvas *c3 = new TCanvas("c3", "wgtd presel distributions", 800,600);
359  hCRYMCPreselWtd[var]->GetXaxis()->SetTitle(plots[var].XaxisLabel);
360  makeWgtdPlot(c3, &*hDataPreselWtd[var], &*hCRYMCPreselWtd[var], &*hGENIEPresel[var], 0, plots[var].legSide, beam=="FHC" ? true : false);
361  DrawBeamLabel(beam=="FHC" ? true : false);
362 
363  TCanvas *c4 = new TCanvas("c4", "wgtd distributions", 800,600);
364  hCRYMCWtd[var]->GetXaxis()->SetTitle(plots[var].XaxisLabel);
365  makeWgtdPlot(c4, &*hDataWtd[var], &*hCRYMCWtd[var], &*hGENIE[var], 1, plots[var].legSide, beam=="FHC" ? true : false);
366  DrawBeamLabel(beam=="FHC" ? true : false);
367 
368  if(plots[var].yAxisLimit != 0) {
369  hCRYMCPreselWtd[var]->GetYaxis()->SetRangeUser(0, plots[var].yAxisLimit);
370  hCRYMCWtd[var]->GetYaxis()->SetRangeUser(0, plots[var].yAxisLimit);
371  }
372 
373  //unweighted efficiencies------------------------------------------------------
374  TCanvas *c5 =new TCanvas("c5","Eff",800,800);
375  //DrawBeamLabelEff(beam=="FHC" ? true : false);
376  hDataEff[var]->GetXaxis()->SetTitle(plots[var].XaxisLabel);
377 
378  if (var == 3 && beam != "FHC") makeEffPlot(c5, &*hDataEff[var], &*hDataPreselEff[var], &*hCRYMCEff[var], &*hCRYMCPreselEff[var], 0, false);
379  else makeEffPlot(c5, &*hDataEff[var], &*hDataPreselEff[var], &*hCRYMCEff[var], &*hCRYMCPreselEff[var], plots[var].legSide, beam=="FHC" ? true : false);
380  hCRYMCEff[3]->GetYaxis()->SetRangeUser(0,1.2);
381 
382  //weighted efficiencies-------------------------------------------------------------
383  TCanvas *c6 =new TCanvas("c6","Weighted Eff",800,800);
384  //DrawBeamLabelEff(beam=="FHC" ? true : false);
385  hDataWtdEff[var]->GetXaxis()->SetTitle(plots[var].XaxisLabel);
386 
387  if (var == 3 && beam != "FHC") makeWgtdEffPlot(c6, &*hDataWtdEff[var], &*hDataPreselWtdEff[var], &*hCRYMCWtdEff[var], &*hCRYMCPreselWtdEff[var], 0, false);
388  else makeWgtdEffPlot(c6, &*hDataWtdEff[var], &*hDataPreselWtdEff[var], &*hCRYMCWtdEff[var], &*hCRYMCPreselWtdEff[var], plots[var].legSide, beam=="FHC" ? true : false);
389  hCRYMCWtdEff[3]->GetYaxis()->SetRangeUser(0, 2.0);
390 
391  //and repeat the distributions without the GENIE sample
392  //unweighted distributions--------------------------------------------------
393  TCanvas *c7 = new TCanvas("c7", "presel distributions", 800,600);
394  hCRYMCPresel[var]->GetXaxis()->SetTitle(plots[var].XaxisLabel);
395  makePlot(c7, &*hDataPresel[var], &*hCRYMCPresel[var], 0, plots[var].legSide);
396  DrawBeamLabel(beam=="FHC" ? true : false);
397 
398  TCanvas *c8 = new TCanvas("c8", "distributions", 800,600);
399  hCRYMC[var]->GetXaxis()->SetTitle(plots[var].XaxisLabel);
400  makePlot(c8, &*hData[var], &*hCRYMC[var], 1, plots[var].legSide);
401  DrawBeamLabel(beam=="FHC" ? true : false);
402 
403  if(plots[var].yAxisLimit != 0) {
404  hCRYMCPresel[var]->GetYaxis()->SetRangeUser(0, plots[var].yAxisLimit);
405  hCRYMC[var]->GetYaxis()->SetRangeUser(0, plots[var].yAxisLimit);
406  }
407 
408  //weighted distributions-------------------------------------------------------
409  TCanvas *c9 = new TCanvas("c9", "wgtd presel distributions", 800,600);
410  hCRYMCPreselWtd[var]->GetXaxis()->SetTitle(plots[var].XaxisLabel);
411  makeWgtdPlot(c9, &*hDataPreselWtd[var], &*hCRYMCPreselWtd[var], 0, plots[var].legSide);
412  DrawBeamLabel(beam=="FHC" ? true : false);
413 
414  TCanvas *c10 = new TCanvas("c10", "wgtd distributions", 800,600);
415  hCRYMCWtd[var]->GetXaxis()->SetTitle(plots[var].XaxisLabel);
416  makeWgtdPlot(c10, &*hDataWtd[var], &*hCRYMCWtd[var], 1, plots[var].legSide);
417  DrawBeamLabel(beam=="FHC" ? true : false);
418 
419  if(plots[var].yAxisLimit != 0) {
420  hCRYMCPreselWtd[var]->GetYaxis()->SetRangeUser(0, plots[var].yAxisLimit);
421  hCRYMCWtd[var]->GetYaxis()->SetRangeUser(0, plots[var].yAxisLimit);
422  }
423 
424 
425  //and save all the canvases------------------------------------------------------------
426  sprintf(saveName, "EffPlots/%s/%s_Presel_%s.png", beam.c_str(), plots[var].savename, beam.c_str());
427  c1->SaveAs(saveName);
428  sprintf(saveName, "EffPlots/%s/%s_%s.png", beam.c_str(), plots[var].savename, beam.c_str());
429  c2->SaveAs(saveName);
430 
431  sprintf(saveName, "EffPlots/%s/%s_Presel_Wtd_%s.png", beam.c_str(), plots[var].savename, beam.c_str());
432  c3->SaveAs(saveName);
433  sprintf(saveName, "EffPlots/%s/%s_Wtd_%s.png", beam.c_str(), plots[var].savename, beam.c_str());
434  c4->SaveAs(saveName);
435 
436  sprintf(saveName, "EffPlots/%s/%s_Eff_%s.png", beam.c_str(), plots[var].savename, beam.c_str());
437  c5->SaveAs(saveName);
438  sprintf(saveName, "EffPlots/%s/%s_Eff_Wtd_%s.png", beam.c_str(), plots[var].savename, beam.c_str());
439  c6->SaveAs(saveName);
440 
441  sprintf(saveName, "EffPlots/%s/%s_Presel_%s_noGENIE.png", beam.c_str(), plots[var].savename, beam.c_str());
442  c7->SaveAs(saveName);
443  sprintf(saveName, "EffPlots/%s/%s_%s_noGENIE.png", beam.c_str(), plots[var].savename, beam.c_str());
444  c8->SaveAs(saveName);
445 
446  sprintf(saveName, "EffPlots/%s/%s_Presel_Wtd_%s_noGENIE.png", beam.c_str(), plots[var].savename, beam.c_str());
447  c9->SaveAs(saveName);
448  sprintf(saveName, "EffPlots/%s/%s_Wtd_%s_noGENIE.png", beam.c_str(), plots[var].savename, beam.c_str());
449  c10->SaveAs(saveName);
450 
451  // make data/CRY comparison for the CVN spectra
452  if(var == 5){
453  //unweighted
454  TCanvas *c11 =new TCanvas("c11","Eff",800,800);
455  hDataPresel[var]->GetXaxis()->SetTitle(plots[var].XaxisLabel);
456  makeDataCryRatio(c11, &*hDataPresel[var], &*hCRYMCPresel[var], 0, plots[var].legSide, beam=="FHC" ? true : false, false);
457  sprintf(saveName, "EffPlots/%s/%s_%s_Ratio.png", beam.c_str(), plots[var].savename, beam.c_str());
458  c11->SaveAs(saveName);
459 
460  //weighted
461  TCanvas *c12 =new TCanvas("c12","Eff",800,800);
462  hDataPreselWtd[var]->GetXaxis()->SetTitle(plots[var].XaxisLabel);
463  makeDataCryRatio(c12, &*hDataPreselWtd[var], &*hCRYMCPreselWtd[var], 0, plots[var].legSide, beam=="FHC" ? true : false, true);
464  sprintf(saveName, "EffPlots/%s/%s_Wtd_%s_Ratio.png", beam.c_str(), plots[var].savename, beam.c_str());
465  c12->SaveAs(saveName);
466  }
467  //------------
468  //and make the efficiency plots without the ratio on the bottom
469  //unweighted efficiencies------------------------------------------------------
470  TCanvas *c13 =new TCanvas("c13","Eff",800,600);
471  hCRYMCEff[var]->GetXaxis()->SetTitle(plots[var].XaxisLabel);
472  if (var == 3 && beam != "FHC") makeEffPlotNoRatio(c13, &*hDataEff[var], &*hCRYMCEff[var], 0, false, false);
473  else makeEffPlotNoRatio(c13, &*hDataEff[var], &*hCRYMCEff[var], plots[var].legSide, beam=="FHC" ? true : false, false);
474  hCRYMCEff[3]->GetYaxis()->SetRangeUser(0,1.2);
475 
476  //weighted efficiencies-------------------------------------------------------------
477  TCanvas *c14 =new TCanvas("c14","Weighted Eff",800,600);
478  hCRYMCWtdEff[var]->GetXaxis()->SetTitle(plots[var].XaxisLabel);
479  if (var == 3 && beam != "FHC") makeEffPlotNoRatio(c14, &*hDataWtdEff[var], &*hCRYMCWtdEff[var], 0, false, true);
480  else makeEffPlotNoRatio(c14, &*hDataWtdEff[var], &*hCRYMCWtdEff[var], plots[var].legSide, beam=="FHC" ? true : false, true);
481  //hCRYMCWtdEff[3]->GetYaxis()->SetRangeUser(0, 2.0);
482 
483  sprintf(saveName, "EffPlots/%s/%s_Eff_%s_noRatio.png", beam.c_str(), plots[var].savename, beam.c_str());
484  c13->SaveAs(saveName);
485  sprintf(saveName, "EffPlots/%s/%s_Eff_Wtd_%s_noRatio.png", beam.c_str(), plots[var].savename, beam.c_str());
486  c14->SaveAs(saveName);
487 
488 
489  }
490 
491 
492 }
493 
494 
495 void makePlot(TCanvas *c1, TH1 *hCosmicsData, TH1 *hCRYMC, TH1 *hGENIEFluxswap, int sel, int legSide, bool isFHC)
496 {
497  c1->cd();
498 
499  hCRYMC->GetXaxis()->CenterTitle();
500  hCRYMC->GetYaxis()->CenterTitle();
501  hCosmicsData->SetLineColor(kBlack);
502  hCosmicsData->SetMarkerStyle(20);
503  hCRYMC->SetFillColorAlpha(kMagenta+2, 0.5);
504  hCRYMC->SetLineColor(kMagenta+2);
505  hGENIEFluxswap->SetLineColor(kBlue);
506 
507  double kNormFactor = hCosmicsData->Integral();
508  hGENIEFluxswap->Scale(kNormFactor/hGENIEFluxswap->Integral());
509  hCRYMC->Scale(kNormFactor/hCRYMC->Integral());
510 
511  hCRYMC->GetYaxis()->SetTitle("Events");
512  hCRYMC->Draw("E2");
513  //this copy is literally just to be able to have the horizontal line for each bin
514  auto hCRYMC2 = (TH1*)hCRYMC->Clone();
515  for(int bin =0; bin <= hCRYMC2->GetXaxis()->GetLast(); bin ++) hCRYMC2->SetBinError(bin, 0.000001);
516  hCRYMC2->SetFillColor(kWhite);
517  hCRYMC2->SetMarkerColor(kMagenta+2);
518  hCRYMC2->Draw("E hist same");
519  hCosmicsData->Draw("E1 same");
520  hGENIEFluxswap->Draw("hist E1 same");
521  hCRYMC->GetYaxis()->SetLabelSize(0.037);
522  hCRYMC->GetYaxis()->SetTitleOffset(0.95);
523 
524  TLegend * leg;
525  if (legSide ==0) {
526  leg = new TLegend(0.15,0.62,0.75,0.85);
527  leg->SetNColumns(2);
528  leg->AddEntry(hCosmicsData,"Cosmic Data","p");
529  leg->AddEntry((TObject*)0, sel==0 ? "Preselected DiF Events": "Selected DiF Events", "");
530  leg->AddEntry(hCRYMC,"Cosmics MC (CRY)","l");
531  leg->AddEntry((TObject*)0, "Area norm. to data", "");
532  leg->AddEntry(hCRYMC, "Cosmics MC Stat. Err.", "f");
533  leg->AddEntry((TObject*)0, "","");
534  leg->AddEntry(hGENIEFluxswap, isFHC ? "#nu_{e} Signal MC" : "#bar{#nu}_{e} Signal MC","l");
535  }
536  else {
537  leg = new TLegend(0.15,0.62,0.85,0.85);
538  leg->SetNColumns(2);
539  leg->AddEntry((TObject*)0, sel==0 ? "Preselected DiF Events": "Selected DiF Events", "");
540  leg->AddEntry(hCosmicsData,"Cosmic Data","p");
541  leg->AddEntry((TObject*)0, "Area norm. to data", "");
542  leg->AddEntry(hCRYMC,"Cosmics MC (CRY)","l");
543  leg->AddEntry((TObject*)0, "","");
544  leg->AddEntry(hCRYMC, "Cosmics MC Stat. Err.", "f");
545  leg->AddEntry((TObject*)0, "","");
546  leg->AddEntry(hGENIEFluxswap, isFHC ? "#nu_{e} Signal MC" : "#bar{#nu}_{e} Signal MC","l");
547  }
548  leg->SetFillStyle(0);
549  leg->SetTextSize(0.04);
550  leg->Draw("same");
551  myPreliminary();
552 }
553 
554 void makePlot(TCanvas *c1, TH1 *hCosmicsData, TH1 *hCRYMC, int sel, int legSide)
555 {
556  //don't plot the GENIE histo
557  c1->cd();
558 
559  hCRYMC->GetXaxis()->CenterTitle();
560  hCRYMC->GetYaxis()->CenterTitle();
561  hCosmicsData->SetLineColor(kBlack);
562  hCosmicsData->SetMarkerStyle(20);
563  hCRYMC->SetLineColor(kMagenta+2);
564  hCRYMC->SetFillColorAlpha(kMagenta+2, 0.5);
565 
566  double kNormFactor = hCosmicsData->Integral();
567  hCRYMC->Scale(kNormFactor/hCRYMC->Integral());
568 
569  hCRYMC->GetYaxis()->SetTitle("Events");
570  hCRYMC->Draw("E2");
571  //this copy is literally just to be able to have the horizontal line for each bin
572  //without the vertical lines
573  auto hCRYMC2 = (TH1*)hCRYMC->Clone();
574  for(int bin =0; bin <= hCRYMC2->GetXaxis()->GetLast(); bin ++) hCRYMC2->SetBinError(bin, 0.000001);
575  hCRYMC2->SetFillColor(kWhite);
576  hCRYMC2->SetMarkerColor(kMagenta+2);
577  hCRYMC2->Draw("E hist same");
578  hCosmicsData->Draw("E1 same");
579  hCRYMC->GetYaxis()->SetLabelSize(0.037);
580  //hCRYMC->GetYaxis()->SetTitleOffset(0.95);
581 
582  TLegend * leg;
583  if (legSide ==0) {
584  leg = new TLegend(0.15,0.68,0.75,0.85);
585  leg->SetNColumns(2);
586  leg->AddEntry(hCosmicsData,"Cosmic Data","p");
587  leg->AddEntry((TObject*)0, sel==0 ? "Preselected DiF Events": "Selected DiF Events", "");
588  leg->AddEntry(hCRYMC,"Cosmics MC (CRY)","l");
589  leg->AddEntry((TObject*)0, "Area norm. to data", "");
590  leg->AddEntry(hCRYMC, "Cosmics MC Stat. Err.", "f");
591  }
592  else {
593  leg = new TLegend(0.15,0.68,0.85,0.85);
594  leg->SetNColumns(2);
595  leg->AddEntry((TObject*)0, sel==0 ? "Preselected DiF Events": "Selected DiF Events", "");
596  leg->AddEntry(hCosmicsData,"Cosmic Data","p");
597  leg->AddEntry((TObject*)0, "Area norm. to data", "");
598  leg->AddEntry(hCRYMC,"Cosmics MC (CRY)","l");
599  leg->AddEntry((TObject*)0, "","");
600  leg->AddEntry(hCRYMC, "Cosmics MC Stat. Err.", "f");
601  }
602  leg->SetFillStyle(0);
603  leg->SetTextSize(0.04);
604  leg->Draw("same");
605  myPreliminary();
606 }
607 
608 
609 void makeWgtdPlot(TCanvas *c1, TH1 *hCosmicsData, TH1 *hCRYMC, TH1 *hGENIEFluxswap, int sel, int legSide, bool isFHC)
610 {
611  c1->cd();
612 
613  hCRYMC->GetXaxis()->CenterTitle();
614  hCRYMC->GetYaxis()->CenterTitle();
615  hCosmicsData->SetLineColor(kBlack);
616  hCosmicsData->SetMarkerStyle(20);
617  hCRYMC->SetLineColor(kMagenta+2);
618  hCRYMC->SetFillColorAlpha(kMagenta+2, 0.5);
619  hGENIEFluxswap->SetLineColor(kBlue);
620 
621  double kNormFactor = hCosmicsData->Integral();
622  hGENIEFluxswap->Scale(kNormFactor/hGENIEFluxswap->Integral());
623  hCRYMC->Scale(kNormFactor/hCRYMC->Integral());
624 
625  hCRYMC->GetYaxis()->SetTitle("Events (cos#theta_{beam} weighted)");
626  hCRYMC->Draw("E2");
627  //this copy is literally just to be able to have the horizontal line for each bin
628  //without the vertical lines
629  auto hCRYMC2 = (TH1*)hCRYMC->Clone();
630  for(int bin =0; bin <= hCRYMC2->GetXaxis()->GetLast(); bin ++) hCRYMC2->SetBinError(bin, 0.000001);
631  hCRYMC2->SetFillColor(kWhite);
632  hCRYMC2->SetMarkerColor(kMagenta+2);
633  hCRYMC2->Draw("E hist same");
634  hCosmicsData->Draw("E1 same");
635  //hCRYMC->Draw("E2 same");
636  hGENIEFluxswap->Draw("hist E1 same");
637  hCRYMC->GetYaxis()->SetLabelSize(0.037);
638  hCRYMC->GetYaxis()->SetTitleOffset(1.0);
639  hCRYMC->GetYaxis()->SetTitleSize(0.05);
640 
641  TLegend * leg;
642  if (legSide ==0) {
643  leg = new TLegend(0.15,0.62,0.75,0.85);
644  leg->SetNColumns(2);
645  leg->AddEntry(hCosmicsData,"Cosmic Data","p");
646  leg->AddEntry((TObject*)0, sel==0 ? "Preselected DiF Events": "Selected DiF Events", "");
647  leg->AddEntry(hCRYMC,"Cosmics MC (CRY)","l");
648  leg->AddEntry((TObject*)0, "Area norm. to data", "");
649  leg->AddEntry(hCRYMC, "Cosmics MC Stat. Err.", "f");
650  leg->AddEntry((TObject*)0, "","");
651  leg->AddEntry(hGENIEFluxswap, isFHC ? "#nu_{e} Signal MC" : "#bar{#nu}_{e} Signal MC","l");
652  }
653  else {
654  leg = new TLegend(0.15,0.62,0.85,0.85);
655  leg->SetNColumns(2);
656  leg->AddEntry((TObject*)0, sel==0 ? "Preselected DiF Events": "Selected DiF Events", "");
657  leg->AddEntry(hCosmicsData,"Cosmic Data","p");
658  leg->AddEntry((TObject*)0, "Area norm. to data", "");
659  leg->AddEntry(hCRYMC,"Cosmics MC (CRY)","l");
660  leg->AddEntry((TObject*)0, "","");
661  leg->AddEntry(hCRYMC, "Cosmics MC Stat. Err.", "f");
662  leg->AddEntry((TObject*)0, "","");
663  leg->AddEntry(hGENIEFluxswap, isFHC ? "#nu_{e} Signal MC" : "#bar{#nu}_{e} Signal MC","l");
664  }
665  leg->SetFillStyle(0);
666  leg->SetTextSize(0.04);
667  leg->Draw("same");
668  myPreliminary();
669 }
670 
671 void makeWgtdPlot(TCanvas *c1, TH1 *hCosmicsData, TH1 *hCRYMC, int sel, int legSide)
672 {
673  //don't plot the GENIE histo
674  c1->cd();
675 
676  hCRYMC->GetXaxis()->CenterTitle();
677  hCRYMC->GetYaxis()->CenterTitle();
678  hCosmicsData->SetLineColor(kBlack);
679  hCosmicsData->SetMarkerStyle(20);
680  hCRYMC->SetLineColor(kMagenta+2);
681  hCRYMC->SetFillColorAlpha(kMagenta+2, 0.5);
682 
683  double kNormFactor = hCosmicsData->Integral();
684  hCRYMC->Scale(kNormFactor/hCRYMC->Integral());
685  hCRYMC->GetYaxis()->SetTitle("Events (cos#theta_{beam} weighted)");
686  hCRYMC->Draw("E2");
687  //this copy is literally just to be able to have the horizontal line for each bin
688  //without the vertical lines
689  auto hCRYMC2 = (TH1*)hCRYMC->Clone();
690  for(int bin =0; bin <= hCRYMC2->GetXaxis()->GetLast(); bin ++) hCRYMC2->SetBinError(bin, 0.000001);
691  hCRYMC2->SetFillColor(kWhite);
692  hCRYMC2->SetMarkerColor(kMagenta+2);
693  hCRYMC2->Draw("E hist same");
694  hCosmicsData->Draw("E1 same");
695  //hCRYMC->GetYaxis()->SetLabelSize(0.037);
696  //hCRYMC->GetYaxis()->SetTitleOffset(0.95);
697 
698  TLegend * leg;
699  if (legSide ==0) {
700  leg = new TLegend(0.15,0.68,0.75,0.85);
701  leg->SetNColumns(2);
702  leg->AddEntry(hCosmicsData,"Cosmic Data","p");
703  leg->AddEntry((TObject*)0, sel==0 ? "Preselected DiF Events": "Selected DiF Events", "");
704  leg->AddEntry(hCRYMC,"Cosmics MC (CRY)","l");
705  leg->AddEntry((TObject*)0, "Area norm. to data", "");
706  leg->AddEntry(hCRYMC, "Cosmics MC Stat. Err.", "f");
707  }
708  else {
709  leg = new TLegend(0.15,0.68,0.85,0.85);
710  leg->SetNColumns(2);
711  leg->AddEntry((TObject*)0, sel==0 ? "Preselected DiF Events": "Selected DiF Events", "");
712  leg->AddEntry(hCosmicsData,"Cosmic Data","p");
713  leg->AddEntry((TObject*)0, "Area norm. to data", "");
714  leg->AddEntry(hCRYMC,"Cosmics MC (CRY)","l");
715  leg->AddEntry((TObject*)0, "","");
716  leg->AddEntry(hCRYMC, "Cosmics MC Stat. Err.", "f");
717  }
718  leg->SetFillStyle(0);
719  leg->SetTextSize(0.04);
720  leg->Draw("same");
721 
722  myPreliminary();
723 }
724 
725 void makeDataCryRatio(TCanvas *c1, TH1 *hCosmicsData, TH1 *hCRYMC, int sel, int legSide, bool isFHC, bool isWgtd)
726 {
727  c1->cd();
728  TPad * pad1 = new TPad("pad1", "pad1", 0, 0.375, 1, 1.0);
729  pad1->Draw();
730  pad1->SetBottomMargin(0.02);
731  pad1->cd();
732 
733  hCRYMC->GetXaxis()->CenterTitle();
734  hCRYMC->GetYaxis()->CenterTitle();
735  hCosmicsData->SetLineColor(kBlack);
736  hCosmicsData->SetMarkerStyle(20);
737  hCRYMC->SetLineColor(kMagenta+2);
738  hCRYMC->SetFillColorAlpha(kMagenta+2, 0.5);
739 
740  double kNormFactor = hCosmicsData->Integral();
741  hCRYMC->Scale(kNormFactor/hCRYMC->Integral());
742 
743  hCRYMC->GetYaxis()->SetTitle(isWgtd ? "Events (cos#theta_{beam} weighted)" : "Events");
744  hCRYMC->Draw("E2");
745  //this copy is literally just to be able to have the horizontal line for each bin
746  //without the vertical lines
747  auto hCRYMC2 = (TH1*)hCRYMC->Clone();
748  for(int bin =0; bin <= hCRYMC2->GetXaxis()->GetLast(); bin ++) hCRYMC2->SetBinError(bin, 0.000001);
749  hCRYMC2->SetFillColor(kWhite);
750  hCRYMC2->SetMarkerColor(kMagenta+2);
751  hCRYMC2->Draw("E hist same");
752  hCosmicsData->Draw("E1 same");
753  hCRYMC->GetYaxis()->SetLabelSize(0.037);
754  hCRYMC->GetYaxis()->SetTitleOffset(0.95);
755  hCRYMC->GetXaxis()->SetLabelSize(0);
756 
757  TLegend * leg;
758  if (legSide ==0) leg = new TLegend(0.15,0.68,0.75,0.85);
759  else leg = new TLegend(0.5,0.68,0.8,0.85);
760  leg->SetNColumns(2);
761  leg->AddEntry(hCosmicsData,"Cosmic Data","p");
762  leg->AddEntry((TObject*)0, sel==0 ? "Preselected DiF Events": "Selected DiF Events", "");
763  leg->AddEntry(hCRYMC,"Cosmics MC (CRY)","l");
764  leg->AddEntry((TObject*)0, "Area norm. to data", "");
765  leg->AddEntry(hCRYMC, "Cosmics MC Stat. Err.", "f");
766  leg->SetTextSize(0.05);
767  leg->Draw("same");
768  myPreliminary();
769 
770  c1->cd();
771  TPad * pad2 = new TPad("pad2", "pad2", 0, 0.002, 1, 0.375);
772  pad2->SetTopMargin(0);
773  pad2->SetBottomMargin(0.2);
774  pad2->Draw();
775  pad2->cd();
776  pad2->SetGridy();
777 
778  TH1D* hRatio =(TH1D*)hCosmicsData->Clone("hRatio");
779 
780  hRatio->GetXaxis()->CenterTitle();
781  hRatio->GetYaxis()->CenterTitle();
782  hRatio->SetLineColor(kBlack);
783  hRatio->SetMarkerStyle(20);
784  hRatio->SetLineWidth(3);
785  hRatio->Divide(hCRYMC);
786  hRatio->Draw("E1");
787  hRatio->GetXaxis()->SetLabelSize(0.075);
788  hRatio->GetYaxis()->SetLabelSize(0.075);
789  hRatio->GetXaxis()->SetTitleOffset(0.85);
790  hRatio->GetYaxis()->SetTitleOffset(0.55);
791  hRatio->GetXaxis()->SetTitleSize(0.09);
792  hRatio->GetYaxis()->SetTitleSize(0.085);
793  hRatio->GetYaxis()->SetRangeUser(0.,2.0);
794  hRatio->GetYaxis()->SetTitle("#frac{Data}{MC}");
795 
796  hCRYMC->GetXaxis()->SetTitle("");
797  c1->cd();
798  DrawBeamLabelEff(isFHC);
799 }
800 
801 
802 
803 void makeEffPlot(TCanvas *c1, TH1 *hCosmicsDataCore, TH1 *hCosmicsDataPresel, TH1 *hCRYMCCore, TH1 *hCRYMCPresel, int legSide, bool isFHC)
804 {
805  c1->cd();
806  TPad * pad1 = new TPad("pad1", "pad1", 0, 0.375, 1, 1.0);
807  pad1->Draw();
808  pad1->SetBottomMargin(0.02);
809  pad1->cd();
810 
811  hCRYMCCore->GetXaxis()->CenterTitle();
812  hCRYMCCore->GetYaxis()->CenterTitle();
813  hCosmicsDataCore->SetLineColor(kBlack);
814  hCosmicsDataCore->SetMarkerStyle(20);
815  hCosmicsDataCore->SetLineWidth(2);
816  hCRYMCCore->SetLineColor(kMagenta+2);
817  hCRYMCCore->SetFillColorAlpha(kMagenta+2, 0.5);
818  hCRYMCCore->SetLineWidth(2);
819 
820  hCosmicsDataCore->Divide(hCosmicsDataPresel);
821  hCRYMCCore->Divide(hCRYMCPresel);
822  hCRYMCCore->Draw("E2");
823  //this copy is literally just to be able to have the horizontal line for each bin
824  //without the vertical lines
825  auto hCRYMC2 = (TH1*)hCRYMCCore->Clone();
826  for(int bin =0; bin <= hCRYMC2->GetXaxis()->GetLast(); bin ++) hCRYMC2->SetBinError(bin, 0.000001);
827  hCRYMC2->SetFillColor(kWhite);
828  hCRYMC2->SetMarkerColor(kMagenta+2);
829  hCRYMC2->Draw("E hist same");
830  hCosmicsDataCore->Draw("E1 same");
831 
832  //hCRYMCCore->GetYaxis()->SetLabelSize(0.037);
833  hCRYMCCore->GetXaxis()->SetLabelSize(0);
834  hCRYMCCore->GetYaxis()->SetTitle("Selection Efficiency");
835 
836  //hCRYMCCore->GetYaxis()->SetTitleOffset(0.95);
837  hCRYMCCore->GetYaxis()->SetRangeUser(0,1.2*gPad->GetUymax());
838 
839  TLegend * leg;
840  if (legSide ==0) leg = new TLegend(0.15,0.68,0.45,0.85);
841  else leg = new TLegend(0.5,0.68,0.8,0.85);
842  leg->AddEntry(hCosmicsDataCore,"Cosmic Data","p");
843  leg->AddEntry(hCRYMCCore,"Cosmic MC (CRY)","l");
844  leg->AddEntry(hCRYMCCore, "Cosmic MC Stat. Err.", "f");
845  leg->SetTextSize(0.05);
846  leg->Draw("same");
847  myPreliminary();
848 
849  //double dif_label_y = isWgtd ? 1.6 : 1.0;
850  //double dif_label_y = hCRYMCEff->GetYaxis()->GetBinUpEdge(hCRYMCEff->GetYaxis()->GetLast());
851  double dif_label_x = 0.5;//hCRYMCCore->GetXaxis()->GetBinLowEdge(2);
852  TText * tt = new TText(0.9*dif_label_x, 0.6, "FD Decay-in-Flight");
853  tt->SetTextSize(0.06);
854  tt->Draw();
855 
856  //DrawBeamLabelEff(isFHC);
857 
858  c1->cd();
859  TPad * pad2 = new TPad("pad2", "pad2", 0, 0.002, 1, 0.375);
860  pad2->SetTopMargin(0);
861  pad2->SetBottomMargin(0.2);
862  pad2->Draw();
863  pad2->cd();
864  pad2->SetGridy();
865 
866  TH1D* hEffRatio =(TH1D*)hCosmicsDataCore->Clone("hEffRatio");
867 
868  hEffRatio->GetXaxis()->CenterTitle();
869  hEffRatio->GetYaxis()->CenterTitle();
870  hEffRatio->SetLineColor(kBlack);
871  hEffRatio->SetMarkerStyle(20);
872  hEffRatio->SetLineWidth(3);
873  hEffRatio->Divide(hCRYMCCore);
874  hEffRatio->Draw("E1");
875  hEffRatio->GetXaxis()->SetLabelSize(0.075);
876  hEffRatio->GetYaxis()->SetLabelSize(0.075);
877  hEffRatio->GetXaxis()->SetTitleOffset(0.85);
878  hEffRatio->GetYaxis()->SetTitleOffset(0.55);
879  hEffRatio->GetXaxis()->SetTitleSize(0.09);
880  hEffRatio->GetYaxis()->SetTitleSize(0.085);
881  hEffRatio->GetYaxis()->SetRangeUser(0.5,1.5);
882  hEffRatio->GetYaxis()->SetTitle("#frac{Data}{MC}");
883 
884  hCRYMCCore->GetXaxis()->SetTitle("");
885  c1->cd();
886  DrawBeamLabelEff(isFHC);
887 }
888 
889 
890 void makeWgtdEffPlot(TCanvas *c1, TH1 *hCosmicsDataCore, TH1 *hCosmicsDataPresel, TH1 *hCRYMCCore, TH1 *hCRYMCPresel, int legSide, bool isFHC)
891 {
892  c1->cd();
893  TPad * pad1 = new TPad("pad1", "pad1", 0, 0.375, 1, 1.0);
894  pad1->Draw();
895  pad1->SetBottomMargin(0.02);
896  pad1->cd();
897 
898  hCRYMCCore->GetXaxis()->CenterTitle();
899  hCRYMCCore->GetYaxis()->CenterTitle();
900  hCosmicsDataCore->SetLineColor(kBlack);
901  hCosmicsDataCore->SetMarkerStyle(20);
902  hCosmicsDataCore->SetLineWidth(2);
903  hCRYMCCore->SetLineColor(kMagenta+2);
904  hCRYMCCore->SetFillColorAlpha(kMagenta+2, 0.5);
905  hCRYMCCore->SetLineWidth(2);
906 
907  hCosmicsDataCore->Divide(hCosmicsDataPresel);
908  hCRYMCCore->Divide(hCRYMCPresel);
909  hCRYMCCore->Draw("E2");
910  //this copy is literally just to be able to have the horizontal line for each bin
911  //without the vertical lines
912  auto hCRYMC2 = (TH1*)hCRYMCCore->Clone();
913  for(int bin =0; bin <= hCRYMC2->GetXaxis()->GetLast(); bin ++) hCRYMC2->SetBinError(bin, 0.000001);
914  hCRYMC2->SetFillColor(kWhite);
915  hCRYMC2->SetMarkerColor(kMagenta+2);
916  hCRYMC2->SetLineWidth(2);
917  hCRYMC2->Draw("E hist same");
918  hCosmicsDataCore->Draw("E1 same");
919  //hCRYMCCore->Draw("hist E1 same");
920 
921  hCRYMCCore->GetYaxis()->SetLabelSize(0.037);
922  hCRYMCCore->GetXaxis()->SetLabelSize(0);
923  hCRYMCCore->GetYaxis()->SetTitle("cos#theta_{beam} Weighted Efficiency");
924 
925  hCRYMCCore->GetYaxis()->SetRangeUser(0,1.2);
926 
927  TLegend * leg;
928  if (legSide ==0) leg = new TLegend(0.15,0.68,0.45,0.85);
929  else leg = new TLegend(0.5,0.68,0.8,0.85);
930  leg->AddEntry(hCosmicsDataCore,"Cosmic Data","p");
931  leg->AddEntry(hCRYMCCore,"Cosmic MC (CRY)","l");
932  leg->AddEntry(hCRYMCCore, "Cosmic MC Stat. Err.", "f");
933  leg->SetTextSize(0.05);
934  leg->Draw("same");
935  myPreliminary();
936 
937  double dif_label_y = 0.6;
938  //double dif_label_y = isWgtd ? 1.6 : 1.0;
939  //double dif_label_y = hCRYMCEff->GetYaxis()->GetBinUpEdge(hCRYMCEff->GetYaxis()->GetLast());
940  double dif_label_x = 0.5;//hCRYMCCore->GetXaxis()->GetBinLowEdge(2);
941  TText * tt = new TText(0.9*dif_label_x, dif_label_y, "FD Decay-in-Flight");
942  tt->SetTextSize(0.06);
943  tt->Draw();
944 
945  c1->cd();
946  TPad * pad2 = new TPad("pad2", "pad2", 0, 0.002, 1, 0.375);
947  pad2->SetTopMargin(0);
948  pad2->SetBottomMargin(0.2);
949  pad2->Draw();
950  pad2->cd();
951  pad2->SetGridy();
952 
953  TH1D* hEffRatio =(TH1D*)hCosmicsDataCore->Clone("hEffRatio");
954 
955  hEffRatio->GetXaxis()->CenterTitle();
956  hEffRatio->GetYaxis()->CenterTitle();
957  hEffRatio->SetLineColor(kBlack);
958  hEffRatio->SetMarkerStyle(20);
959  hEffRatio->SetLineWidth(3);
960  hEffRatio->Divide(hCRYMCCore);
961  hEffRatio->Draw("E1");
962  hEffRatio->GetXaxis()->SetLabelSize(0.075);
963  hEffRatio->GetYaxis()->SetLabelSize(0.075);
964  hEffRatio->GetXaxis()->SetTitleOffset(0.85);
965  hEffRatio->GetYaxis()->SetTitleOffset(0.55);
966  hEffRatio->GetXaxis()->SetTitleSize(0.09);
967  hEffRatio->GetYaxis()->SetTitleSize(0.085);
968  hEffRatio->GetYaxis()->SetRangeUser(0.5,1.5);
969  hEffRatio->GetYaxis()->SetTitle("#frac{Data}{MC}");
970 
971  hCRYMCCore->GetXaxis()->SetTitle("");
972  c1->cd();
973  DrawBeamLabelEff(isFHC);
974 }
975 
976 
977 void makeEffPlotNoRatio(TCanvas *c1, TH1 *hCosmicsDataEff, TH1 *hCRYMCEff, int legSide, bool isFHC, bool isWgtd)
978 {
979  //should only be used after the regular eff plot functions have been used
980 
981  hCRYMCEff->GetXaxis()->SetLabelSize(0.04);
982  hCRYMCEff->Draw("E2");
983 
984  //this copy is literally just to be able to have the horizontal line for each bin
985  //without the vertical lines
986  auto hCRYMC2 = (TH1*)hCRYMCEff->Clone();
987  for(int bin =0; bin <= hCRYMC2->GetXaxis()->GetLast(); bin ++) hCRYMC2->SetBinError(bin, 0.000001);
988  hCRYMC2->SetFillColor(kWhite);
989  hCRYMC2->SetMarkerColor(kMagenta+2);
990  hCRYMC2->Draw("E hist same");
991  hCosmicsDataEff->Draw("E1 same");
992 
993  TLegend * leg;
994  if (legSide ==0) leg = new TLegend(0.15,0.68,0.45,0.85);
995  else leg = new TLegend(0.5,0.68,0.8,0.85);
996  leg->SetTextSize(0.05);
997  leg->AddEntry(hCosmicsDataEff,"Cosmic Data","p");
998  leg->AddEntry(hCRYMCEff,"Cosmic MC (CRY)","l");
999  leg->AddEntry(hCRYMCEff, "Cosmic MC Stat. Err.", "f");
1000  leg->Draw("same");
1001  myPreliminary();
1002  DrawBeamLabel(isFHC);
1003 
1004  double dif_label_y = 0.6;
1005  double dif_label_x = 0.25;
1006  TText * tt = new TText(dif_label_x, dif_label_y, "FD Decay-in-Flight");
1007  tt->SetTextSize(0.06);
1008  tt->Draw();
1009 
1010  gPad->RedrawAxis();
1011 }
void makeEffPlot(TCanvas *c1, TH1 *hCosmicsDataCore, TH1 *hCosmicsDataPresel, TH1 *hCRYMCCore, TH1 *hCRYMCPresel, int legSide, bool isFHC)
void makePlot(TCanvas *c1, TH1 *hCosmicsData, TH1 *hCRYMC, TH1 *hGENIEFluxswap, int sel, int legSide, bool isFHC)
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
void makeEffPlotNoRatio(TCanvas *c1, TH1 *hCosmicsDataCEff, TH1 *hCRYMCCoreEff, int legSide, bool isFHC, bool isWgtd)
void myPreliminary()
c2
Definition: demo5.py:33
ifstream inFile
Definition: AnaPlotMaker.h:34
Definition: type_traits.h:56
====================================================================== ///
Definition: CutFlow_Data.C:28
static std::unique_ptr< Spectrum > LoadFrom(TDirectory *dir, const std::string &name)
Definition: Spectrum.cxx:535
TPaveText * DrawBeamLabel(bool isFHC)
Put the standardized beam label in the left corner of the active canvas.
Definition: Plots.cxx:1555
const std::vector< Plot > plots
Float_t f1
void makeDataCryRatio(TCanvas *c1, TH1 *hCosmicsData, TH1 *hCRYMC, int sel, int legSide, bool isFHC, bool isWgtd)
float bin[41]
Definition: plottest35.C:14
void DrawBeamLabelEff(bool isFHC)
TLatex * prelim
Definition: Xsec_final.C:133
static bool isFHC
OStream cout
Definition: OStream.cxx:6
void makeWgtdPlot(TCanvas *c1, TH1 *hCosmicsData, TH1 *hCRYMC, TH1 *hGENIEFluxswap, int sel, int legSide, bool isFHC)
c1
Definition: demo5.py:24
void make_eff_plots_areaNorm(std::string beam="FHC")
TPad * pad2
Definition: analysis.C:13
enum BeamMode kBlue
int yAxisLimit
void makeWgtdEffPlot(TCanvas *c1, TH1 *hCosmicsDataCore, TH1 *hCosmicsDataPresel, TH1 *hCRYMCCore, TH1 *hCRYMCPresel, int legSide, bool isFHC)
TPad * pad1
Definition: analysis.C:13
enum BeamMode string