ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/cbrown/Development/Plotting/Modules/Plotting_Functions.C
(Generate patch)

Comparing UserCode/cbrown/Development/Plotting/Modules/Plotting_Functions.C (file contents):
Revision 1.84 by buchmann, Mon Feb 18 18:55:58 2013 UTC vs.
Revision 1.98 by buchmann, Fri May 31 09:45:15 2013 UTC

# Line 15 | Line 15
15   #include <TSQLResult.h>
16   #include <TProfile.h>
17   #include <TLegendEntry.h>
18 + #include "TMath.h"
19 + #include "Math/DistFunc.h"
20  
21   using namespace std;
22  
# Line 32 | Line 34 | void todo() {
34   }  
35  
36  
37 + namespace PeakLibrary {
38 +  bool StoreHistos=false;
39 +  vector<TH1F*> DataHistogram;
40 +  vector<TH1F*> MCHistogram;
41 + }
42 +
43  
44   void find_one_peak_combination(TCut specialcut, bool SwitchOffNJetsCut, float &MCPeak,float &MCPeakError, float &DataPeak, float &DataPeakError, float &MCSigma, float &MCSigmaError, float &DataSigma, float& DataSigmaError, stringstream &result, bool doPUreweighting = true, string saveas="")
45   {
# Line 45 | Line 53 | void find_one_peak_combination(TCut spec
53    TCut nJetsCut(cutnJets);
54    if(SwitchOffNJetsCut) nJetsCut=specialcut;
55    
56 +  
57    TCanvas *tempcan = new TCanvas("tempcan","Temporary canvas for peak finding preparations");
58    TH1F *rawJZBeemmMC      = allsamples.Draw("rawJZBeemmMC",jzbvariablemc,nbins,-50,50, "JZB [GeV]", "events", cutmass&&cutOSSF&&nJetsCut&&specialcut,mc, luminosity);
59    TH1F *rawJZBeemmData    = allsamples.Draw("rawJZBeemmData",jzbvariabledata,nbins, -50,50, "JZB [GeV]", "events", cutmass&&cutOSSF&&nJetsCut&&specialcut,data, luminosity);
# Line 80 | Line 89 | void find_one_peak_combination(TCut spec
89    result << "   We have found the peak in Data at " << DataPeak << " +/- " << DataPeakError << " with sigma=" << DataSigma << " +/- " << DataSigmaError << endl;
90    dout   << "   We have found the peak in MC at " << MCPeak << " +/- " << MCPeakError << " with sigma=" << MCSigma << " +/- " << MCSigmaError << endl;
91    result << "   We have found the peak in MC at " << MCPeak << " +/- " << MCPeakError << " with sigma=" << MCSigma << " +/- " << MCSigmaError << endl;
92 <  delete rawJZBeemmData;
93 <  delete rawJZBeemmMC;
92 >  
93 >  if(!PeakLibrary::StoreHistos) {
94 >    delete rawJZBeemmData;
95 >    delete rawJZBeemmMC;
96 >  } else {
97 >    rawJZBeemmMC->SetName(GetNumericHistoName().c_str());
98 >    rawJZBeemmData->SetName(GetNumericHistoName().c_str());
99 >    rawJZBeemmMC->Add(rawJZBemMC,-1);
100 >    rawJZBeemmData->Add(rawJZBemData,-1);
101 >    PeakLibrary::DataHistogram.push_back(rawJZBeemmData);
102 >    PeakLibrary::MCHistogram.push_back(rawJZBeemmMC);
103 >  }
104 >  
105 >
106 >  
107    delete rawJZBemData;
108    delete rawJZBemMC;
109    delete tempcan;
110   }
111  
112 +
113 + void FindPeakPileUpCorrection() {
114 +  bool StoreResultsInSeparateFile=true;
115 +  PeakLibrary::StoreHistos=true;
116 +  
117 +  
118 +  dout << "Finding peak position as a function of PU" << endl;
119 +  float MCPeak, MCPeakError, DataPeak, DataPeakError;
120 +  stringstream result, datajzb, mcjzb;
121 +  bool doPUreweighting=true;
122 +  bool SwitchOffNJetsCut=false;
123 +  
124 +  
125 +  TCanvas *can = new TCanvas("can","can");
126 +  float mcSigma,mcSigmaError,dataSigma,dataSigmaError;
127 +  
128 +  const int nbins=10;
129 +  float NumVtxBin[nbins] = {0,7,9,11,13,15,17,19,21,50};
130 +  
131 +  stringstream NowCut;
132 +  
133 +
134 +  Double_t mc_peak_x[nbins];
135 +  Double_t mc_peak_y[nbins];
136 +  Double_t mc_peak_dxh[nbins];
137 +  Double_t mc_peak_dxl[nbins];
138 +  Double_t mc_peak_dy[nbins];
139 +  
140 +  Double_t data_peak_x[nbins];
141 +  Double_t data_peak_y[nbins];
142 +  Double_t data_peak_dxh[nbins];
143 +  Double_t data_peak_dxl[nbins];
144 +  Double_t data_peak_dy[nbins];
145 +  
146 +  Double_t mc_width_x[nbins];
147 +  Double_t mc_width_y[nbins];
148 +  Double_t mc_width_dxh[nbins];
149 +  Double_t mc_width_dxl[nbins];
150 +  Double_t mc_width_dy[nbins];
151 +  
152 +  Double_t data_width_x[nbins];
153 +  Double_t data_width_y[nbins];
154 +  Double_t data_width_dxh[nbins];
155 +  Double_t data_width_dxl[nbins];
156 +  Double_t data_width_dy[nbins];
157 +
158 +  for(int i=0;i<nbins-1;i++) {
159 +    NowCut.str("");
160 +    NowCut << "numVtx>" << NumVtxBin[i] << "&&numVtx<=" << NumVtxBin[i+1];
161 +    cout << "NVtx cut is now : " << NowCut.str() << endl;
162 +    find_one_peak_combination(TCut(NowCut.str().c_str()),SwitchOffNJetsCut,MCPeak,MCPeakError, DataPeak,DataPeakError,mcSigma,mcSigmaError, dataSigma,dataSigmaError,result,doPUreweighting,"");
163 +    cout << "    " << MCPeak << " +/- " << MCPeakError << endl;
164 +    cout << "    " << DataPeak << " +/- " << DataPeakError << endl;
165 +    
166 +    TH1F *hDataSFNumVtx = allsamples.Draw("hDataSFNumVtx","numVtx",100,-0.5,49.5, "N_{vtx}", "events", cutmass&&cutOSSF&&cutnJets&&TCut(NowCut.str().c_str()),data, luminosity);
167 +    TH1F *hDataOFNumVtx = allsamples.Draw("hDataOFNumVtx","numVtx",100,-0.5,49.5, "N_{vtx}", "events", cutmass&&cutOSOF&&cutnJets&&TCut(NowCut.str().c_str()),data, luminosity);
168 +    TH1F *hMCSFNumVtx = allsamples.Draw("hMCSFNumVtx","numVtx",100,-0.5,49.5, "N_{vtx}", "events", cutmass&&cutOSSF&&cutnJets&&TCut(NowCut.str().c_str()),mc, luminosity);
169 +    TH1F *hMCOFNumVtx = allsamples.Draw("hMCOFNumVtx","numVtx",100,-0.5,49.5, "N_{vtx}", "events", cutmass&&cutOSOF&&cutnJets&&TCut(NowCut.str().c_str()),mc, luminosity);
170 +    
171 +    hDataSFNumVtx->Add(hDataOFNumVtx,-1);
172 +    hMCSFNumVtx->Add(hMCOFNumVtx,-1);
173 +    
174 +    mc_peak_x[i]=hMCSFNumVtx->GetMean();
175 +    mc_peak_y[i]=MCPeak;
176 +    mc_peak_dy[i]=MCPeakError;
177 +    
178 +    data_peak_x[i]=hDataSFNumVtx->GetMean();
179 +    data_peak_y[i]=DataPeak;
180 +    data_peak_dy[i]=DataPeakError;
181 +    
182 +    mc_width_x[i]=hMCSFNumVtx->GetMean();
183 +    mc_width_y[i]=mcSigma;
184 +    mc_width_dy[i]=mcSigmaError;
185 +    
186 +    data_width_x[i]=hDataSFNumVtx->GetMean();
187 +    data_width_y[i]=dataSigma;
188 +    data_width_dy[i]=dataSigmaError;
189 +    
190 +    delete hDataSFNumVtx;
191 +    delete hDataOFNumVtx;
192 +    delete hMCSFNumVtx;
193 +    delete hMCOFNumVtx;
194 +  }
195 +  
196 +  for(int i=0;i<nbins-1;i++) {
197 +    if(i==0) {
198 +      data_width_dxl[i]=data_width_x[i];
199 +      data_peak_dxl[i]=data_peak_x[i];
200 +      data_width_dxh[i]=0.5*(data_width_x[i+1]-data_width_x[i]);
201 +      data_peak_dxh[i]=0.5*(data_peak_x[i+1]-data_peak_x[i]);
202 +      
203 +      mc_width_dxl[i]=mc_width_x[i];
204 +      mc_peak_dxl[i]=mc_peak_x[i];
205 +      mc_width_dxh[i]=0.5*(mc_width_x[i+1]-mc_width_x[i]);
206 +      mc_peak_dxh[i]=0.5*(mc_peak_x[i+1]-mc_peak_x[i]);
207 +    } else if(i==nbins-2) {
208 +      data_width_dxl[i]=0.5*(data_width_x[i]-data_width_x[i-1]);
209 +      data_peak_dxl[i]=0.5*(data_peak_x[i]-data_peak_x[i-1]);
210 +      data_width_dxh[i]=50-data_width_x[i];
211 +      data_peak_dxh[i]=50-data_peak_x[i];
212 +      
213 +      mc_width_dxl[i]=0.5*(mc_width_x[i]-mc_width_x[i-1]);
214 +      mc_peak_dxl[i]=0.5*(mc_peak_x[i]-mc_peak_x[i-1]);
215 +      mc_width_dxh[i]=50-mc_width_x[i];
216 +      mc_peak_dxh[i]=50-mc_peak_x[i];
217 +    } else {
218 +      data_width_dxl[i]=0.5*(data_width_x[i]-data_width_x[i-1]);
219 +      data_peak_dxl[i]=0.5*(data_peak_x[i]-data_peak_x[i-1]);
220 +      data_width_dxh[i]=0.5*(data_width_x[i+1]-data_width_x[i]);
221 +      data_peak_dxh[i]=0.5*(data_peak_x[i+1]-data_peak_x[i]);
222 +      
223 +      mc_width_dxl[i]=0.5*(mc_width_x[i]-mc_width_x[i-1]);
224 +      mc_peak_dxl[i]=0.5*(mc_peak_x[i]-mc_peak_x[i-1]);
225 +      mc_width_dxh[i]=0.5*(mc_width_x[i+1]-mc_width_x[i]);
226 +      mc_peak_dxh[i]=0.5*(mc_peak_x[i+1]-mc_peak_x[i]);
227 +    }
228 +  }
229 +  
230 +  TGraphAsymmErrors *gMCPeak = new TGraphAsymmErrors(nbins-1,mc_peak_x,mc_peak_y,mc_peak_dxl,mc_peak_dxh,mc_peak_dy,mc_peak_dy);
231 +  gMCPeak->SetTitle("gMCPeak");
232 +  gMCPeak->SetName("gMCPeak");
233 +  
234 +  TGraphAsymmErrors *gDataPeak = new TGraphAsymmErrors(nbins-1,data_peak_x,data_peak_y,data_peak_dxl,data_peak_dxh,data_peak_dy,data_peak_dy);
235 +  gDataPeak->SetTitle("gDataPeak");
236 +  gDataPeak->SetName("gDataPeak");
237 +  
238 +  TGraphAsymmErrors *gMCWidth = new TGraphAsymmErrors(nbins-1,mc_width_x,mc_width_y,mc_width_dxl,mc_width_dxh,mc_width_dy,mc_width_dy);
239 +  gMCWidth->SetTitle("gMCWidth");
240 +  gMCWidth->SetName("gMCWidth");
241 +  
242 +  TGraphAsymmErrors *gDataWidth = new TGraphAsymmErrors(nbins-1,data_width_x,data_width_y,data_width_dxl,data_width_dxh,data_width_dy,data_width_dy);
243 +  gDataWidth->SetTitle("gDataWidth");
244 +  gDataWidth->SetName("gDataWidth");
245 +  
246 +  can->cd();
247 +  gMCPeak->GetXaxis()->SetTitle("N(Vertices)");
248 +  gMCPeak->GetYaxis()->SetTitle("Peak position");
249 +  gMCPeak->GetXaxis()->CenterTitle();
250 +  gMCPeak->GetYaxis()->CenterTitle();
251 +  gDataPeak->GetXaxis()->SetTitle("N(Vertices)");
252 +  gDataPeak->GetYaxis()->SetTitle("Peak position");
253 +  gDataPeak->GetXaxis()->CenterTitle();
254 +  gDataPeak->GetYaxis()->CenterTitle();
255 +  
256 +  gDataWidth->GetXaxis()->SetTitle("N(Vertices)");
257 +  gDataWidth->GetYaxis()->SetTitle("#sigma_{JZB}");
258 +  gDataWidth->GetXaxis()->CenterTitle();
259 +  gDataWidth->GetYaxis()->CenterTitle();
260 +  gMCWidth->GetXaxis()->SetTitle("N(Vertices)");
261 +  gMCWidth->GetYaxis()->SetTitle("#sigma_{JZB}");
262 +  gMCWidth->GetXaxis()->CenterTitle();
263 +  gMCWidth->GetYaxis()->CenterTitle();
264 +  
265 +  gMCPeak->SetFillColor(TColor::GetColor("#2E9AFE"));
266 +  gDataPeak->SetFillColor(TColor::GetColor("#2E9AFE"));
267 +  gDataWidth->SetFillColor(TColor::GetColor("#2E9AFE"));
268 +  gMCWidth->SetFillColor(TColor::GetColor("#2E9AFE"));
269 +  
270 +  can->cd();
271 +  gMCPeak->Draw("A2");
272 +  DrawMCPrelim();
273 +  CompleteSave(can,"PUStudy/MCPeak");
274 +  
275 +  can->cd();
276 +  gStyle->SetOptFit(0);
277 +  gMCPeak->Fit("pol1");
278 +  gMCPeak->GetYaxis()->SetRangeUser(0,15);
279 +  TF1 *MCFit = (TF1*)gMCPeak->GetFunction("pol1");
280 +  
281 +  gMCPeak->Draw("A2");
282 +  MCFit->SetLineColor(kBlue);
283 +  MCFit->SetLineWidth(2);
284 +  MCFit->Draw("same");
285 +  stringstream mresult;
286 +  mresult << "Slope: " << std::setprecision(2) << MCFit->GetParameter(1) << " +/- " << MCFit->GetParError(1);
287 +  TText* mrestitle = write_text(0.7,0.2,mresult.str());
288 +  mrestitle->Draw();
289 +  DrawMCPrelim();
290 +  CompleteSave(can,"PUStudy/MCPeak_Fit");
291 +  
292 +  gMCPeak->Draw("A2");
293 +  DrawMCPrelim();
294 +  CompleteSave(can,"PUStudy/MCWidth");
295 +  
296 +  
297 +  can->cd();
298 +  gDataPeak->Draw("A2");
299 +  DrawPrelim();
300 +  CompleteSave(can,"PUStudy/DataPeak");
301 +  
302 +  can->cd();
303 +  gStyle->SetOptFit(0);
304 +  gDataPeak->GetYaxis()->SetRangeUser(0,15);
305 +  gDataPeak->Fit("pol1");
306 +  
307 +  TF1 *DataFit = (TF1*)gDataPeak->GetFunction("pol1");
308 +  DataFit->SetLineColor(kBlue);
309 +  DataFit->SetLineWidth(2);
310 +  DataFit->Draw("same");
311 +  stringstream dresult;
312 +  dresult << "Slope: " << std::setprecision(2) << DataFit->GetParameter(1) << " +/- " << DataFit->GetParError(1);
313 +  TText* drestitle = write_text(0.7,0.2,dresult.str());
314 +  drestitle->Draw();
315 +  DrawPrelim();
316 +  CompleteSave(can,"PUStudy/DataPeak_Fit");
317 +  
318 +  can->cd();
319 +  gDataWidth->Draw("A2");
320 +  DrawPrelim();
321 +  CompleteSave(can,"PUStudy/DataWidth");
322 +  
323 +  if(StoreResultsInSeparateFile) {
324 +    TFile *PeakFinding = new TFile("PeakFindingWithPeakCorrection.root","RECREATE");
325 +    gMCPeak->Write();
326 +    gDataPeak->Write();
327 +    gMCWidth->Write();
328 +    gDataWidth->Write();
329 +    PeakFinding->Close();
330 +  }
331 +  
332 +  
333 +  dout << "The suggested correction for Data is : " << DataFit->GetParameter(1) << endl;
334 +  dout << "The suggested correction for MC is   : " << MCFit->GetParameter(1) << endl;
335 +  
336 +  TLegend *leg = make_legend();
337 +  can->cd();
338 +  int j=0;
339 +  for(int i=PeakLibrary::DataHistogram.size()-5;i<PeakLibrary::DataHistogram.size();i++) {
340 +    PeakLibrary::DataHistogram[i]->Rebin(5);
341 +    PeakLibrary::DataHistogram[i]->SetLineColor(j+1);
342 +    if(i==PeakLibrary::DataHistogram.size()-5) PeakLibrary::DataHistogram[i]->DrawNormalized("histo");
343 +    else PeakLibrary::DataHistogram[i]->DrawNormalized("histo,same");
344 +    stringstream name;
345 +    name << NumVtxBin[j] << " < N_{vtx} < " << NumVtxBin[j+1];
346 +    leg->AddEntry(PeakLibrary::DataHistogram[i],name.str().c_str(),"l");
347 +    j++;
348 +  }
349 +  
350 +  leg->Draw();
351 +  DrawPrelim();
352 +  CompleteSave(can,"PUStudy/DataOverview");
353 +  
354 +  TLegend *leg2 = make_legend();
355 +  can->cd();
356 +  j=0;
357 +  for(int i=PeakLibrary::MCHistogram.size()-5;i<PeakLibrary::MCHistogram.size();i++) {
358 +    PeakLibrary::MCHistogram[i]->Rebin(5);
359 +    PeakLibrary::MCHistogram[i]->SetLineColor(j+1);
360 +    if(i==PeakLibrary::MCHistogram.size()-5) PeakLibrary::MCHistogram[i]->DrawNormalized("histo");
361 +    else PeakLibrary::MCHistogram[i]->DrawNormalized("histo,same");
362 +    stringstream name;
363 +    name << NumVtxBin[j] << " < N_{vtx} < " << NumVtxBin[j+1];
364 +    leg->AddEntry(PeakLibrary::MCHistogram[i],name.str().c_str(),"l");
365 +    j++;
366 +  }
367 +  
368 +  leg->Draw();
369 +  DrawPrelim();
370 +  CompleteSave(can,"PUStudy/MCOverview");
371 +  
372 +  delete can;
373 +  PeakLibrary::StoreHistos=false;
374 + }
375 +
376 +
377 +
378   void find_peaks(float &MCPeak,float &MCPeakError, float &DataPeak, float &DataPeakError, stringstream &result, bool doPUreweighting, stringstream &datajzb, stringstream &mcjzb, string sSpecialCut="", bool SwitchOffNJetsCut=false)
379   {
380    bool overunderflowstatus=addoverunderflowbins;
# Line 144 | Line 432 | void find_peaks(float &MCPeak,float &MCP
432      
433    } else {
434      datajzb << "(" << jzbvariabledata;
435 <      mcjzb << "(" << jzbvariablemc;
435 >    mcjzb   << "(" << jzbvariablemc;
436      
437      if(datapeak>0) datajzb << "- " << TMath::Abs(datapeak) << " ";
438      else datajzb << "+ " << TMath::Abs(datapeak) << " ";
# Line 164 | Line 452 | void find_peaks(float &MCPeak,float &MCP
452      switch_overunderflow(overunderflowstatus);
453   }
454  
455 < void make_special_obs_pred_mll_plot(string datajzb, string mcjzb, float jzbthreshold, float binWidth = 5.0) {
455 > void make_special_obs_pred_mll_plot(string datajzb, string mcjzb, float jzbthreshold, float binWidth, int MCorData) {
456    float min=70.0;
457    float max=115.0;
458    if(!PlottingSetup::RestrictToMassPeak) {
# Line 173 | Line 461 | void make_special_obs_pred_mll_plot(stri
461    }
462    int nbins=int((max-min)/binWidth);
463    
464 +  string prefix="";
465 +  if(MCorData==mc) prefix="MC__";
466 +  
467 +  
468 +  if(MCorData==mc) datajzb=mcjzb;
469 +  
470    TCanvas *ckin = new TCanvas("ckin","Kinematic Plots (in the making)",600,600);
471    
472    stringstream largerzeroS;
# Line 188 | Line 482 | void make_special_obs_pred_mll_plot(stri
482    largerzeroMS << "(" << mcjzb << ">" << jzbthreshold << ")";
483    TCut largerzeroM(largerzeroMS.str().c_str());
484    
485 <  TH1F *RcorrJZBeemm     = allsamples.Draw("RcorrJZBeemm",       "mll",nbins,min,max, "m_{ll} [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&largerzeroD,data,luminosity);
486 <  THStack mcRcorrJZBeemm = allsamples.DrawStack("mcRcorrJZBeemm","mll",nbins,min,max, "m_{ll} [GeV}", "events", cutmass&&cutOSSF&&cutnJets&&largerzeroM,mc,luminosity);
487 <  TH1F *LcorrJZBeemm     = allsamples.Draw("LcorrJZBeemm",       "mll",nbins,min,max, "m_{ll} [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&smallerzeroD,data,luminosity);
488 <  TH1F *RcorrJZBem       = allsamples.Draw("RcorrJZBem",         "mll",nbins,min,max, "m_{ll} [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&largerzeroD,data,luminosity);
489 <  TH1F *LcorrJZBem       = allsamples.Draw("LcorrJZBem",         "mll",nbins,min,max, "m_{ll} [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&smallerzeroD,data,luminosity);
485 >
486 >  stringstream smallerzeroMS;
487 >  smallerzeroMS << "(" << mcjzb << "<-" << jzbthreshold << ")";
488 >  TCut smallerzeroM(smallerzeroMS.str().c_str());
489 >  
490 >  TH1F *RcorrJZBeemm     = allsamples.Draw("RcorrJZBeemm",       "mll",nbins,min,max, "m_{ll} [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&largerzeroD,MCorData,luminosity);
491 >  THStack mcRcorrJZBeemm = allsamples.DrawStack("mcRcorrJZBeemm","mll",nbins,min,max, "m_{ll} [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&largerzeroM,mc,luminosity);
492 >  TH1F *LcorrJZBeemm     = allsamples.Draw("LcorrJZBeemm",       "mll",nbins,min,max, "m_{ll} [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&smallerzeroD,MCorData,luminosity);
493 >  TH1F *RcorrJZBem       = allsamples.Draw("RcorrJZBem",         "mll",nbins,min,max, "m_{ll} [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&largerzeroD,MCorData,luminosity);
494 >  TH1F *LcorrJZBem       = allsamples.Draw("LcorrJZBem",         "mll",nbins,min,max, "m_{ll} [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&smallerzeroD,MCorData,luminosity);
495  
496    TH1F *RcorrJZBSBem;
497    TH1F *LcorrJZBSBem;
# Line 202 | Line 501 | void make_special_obs_pred_mll_plot(stri
501   //  TH1F *RcorrJZBeemmNoS;
502  
503    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
504 <    RcorrJZBSBem   = allsamples.Draw("RcorrJZBSBem",  "mll",nbins,min,max, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets&&largerzeroD,data, luminosity);
505 <    LcorrJZBSBem   = allsamples.Draw("LcorrJZBSBem",  "mll",nbins,min,max, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets&&smallerzeroD,data, luminosity);
506 <    RcorrJZBSBeemm = allsamples.Draw("RcorrJZBSBeemm","mll",nbins,min,max, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets&&largerzeroD,data, luminosity);
507 <    LcorrJZBSBeemm = allsamples.Draw("LcorrJZBSBeemm","mll",nbins,min,max, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets&&smallerzeroD,data, luminosity);
504 >    RcorrJZBSBem   = allsamples.Draw("RcorrJZBSBem",  "mll",nbins,min,max, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets&&largerzeroD,MCorData, luminosity);
505 >    LcorrJZBSBem   = allsamples.Draw("LcorrJZBSBem",  "mll",nbins,min,max, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets&&smallerzeroD,MCorData, luminosity);
506 >    RcorrJZBSBeemm = allsamples.Draw("RcorrJZBSBeemm","mll",nbins,min,max, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets&&largerzeroD,MCorData, luminosity);
507 >    LcorrJZBSBeemm = allsamples.Draw("LcorrJZBSBeemm","mll",nbins,min,max, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets&&smallerzeroD,MCorData, luminosity);
508    }
509 <  
510 <  // Separate predictions
509 >
510 >    // Separate predictions
511    TH1F* SFN = (TH1F*)LcorrJZBeemm->Clone("SFN");
512    TH1F* OFP = (TH1F*)RcorrJZBem->Clone("OFP");
513    TH1F* OFN = (TH1F*)LcorrJZBem->Clone("OFN");
514 +  
515 +  TH1F *BpredSys = (TH1F*)SFN->Clone("BpredSys");
516 +  ClearHisto(BpredSys);
517 +  AddSquared(BpredSys,SFN,pow(PlottingSetup::zjetsestimateuncertOFFPEAK,2));
518 +
519    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
520      OFP->Scale(1.0/3.0);
521      OFP->Add(RcorrJZBSBem,1.0/3.);
# Line 219 | Line 523 | void make_special_obs_pred_mll_plot(stri
523      OFN->Scale(1.0/3.0);
524      OFN->Add(LcorrJZBSBem,1.0/3.);
525      OFN->Add(LcorrJZBSBeemm,1.0/3.);
526 <  }
526 >    AddSquared(BpredSys,RcorrJZBem,pow((1.0/3) * PlottingSetup::emuncertOFFPEAK,2));  
527 >    AddSquared(BpredSys,RcorrJZBSBem,pow((1.0/3) * PlottingSetup::emuncertOFFPEAK,2));  
528 >    AddSquared(BpredSys,RcorrJZBSBeemm,pow((1.0/3) * PlottingSetup::emuncertOFFPEAK,2));  
529 >  } else {
530 >    AddSquared(BpredSys,OFN,pow(PlottingSetup::emuncertOFFPEAK,2));  
531 >  }
532  
533 +  SQRT(BpredSys);
534 +  
535 +  TGraphErrors *BpredSysBand = new TGraphErrors();
536 + //  TH1F *BpredSysBand = (TH1F*)BpredSys->Clone("BpredSysBand");
537 +  
538 +  for(int i=1;i<=BpredSys->GetNbinsX();i++) {
539 +    /*BpredSysBand->SetBinError(i,BpredSysBand->GetBinContent(i));
540 +    BpredSysBand->SetBinContent(i,0);*/
541 +    float dx=0.5*BpredSys->GetBinWidth(i);
542 +    float dy=BpredSys->GetBinContent(i);
543 +    BpredSysBand->SetPoint(i-1,BpredSys->GetBinCenter(i),0);
544 +    BpredSysBand->SetPointError(i-1,dx,dy);
545 +  }
546 +  
547 +  delete BpredSys;
548 +  BpredSysBand->SetFillColor(TColor::GetColor("#2E9AFE"));
549 +  
550    TH1F* Bpred = (TH1F*)SFN->Clone("Bpred");
551    Bpred->Add(OFP);
552    Bpred->Add(OFN,-1);
# Line 234 | Line 560 | void make_special_obs_pred_mll_plot(stri
560    
561    TLegend *leg = allsamples.allbglegend();
562    leg->SetX1(0.58);
563 <  leg->AddEntry(RcorrJZBeemm,"observed (data)","l");
563 > //  leg->AddEntry(RcorrJZBeemm,"observed (data)","l");
564    leg->AddEntry(Bpred,"predicted (data)","l");
565    leg->Draw("same");
566    
567    stringstream saveas;
568 <  saveas << "kin/Mll_After_Cut/Cut_At" << jzbthreshold;
568 >  saveas << "kin/Mll_After_Cut/" << prefix << "Cut_At" << jzbthreshold;
569    CompleteSave(ckin,saveas.str());
570    
571    // Draw all predictions overlayed
# Line 262 | Line 588 | void make_special_obs_pred_mll_plot(stri
588    RcorrJZBeemm->Draw("same");
589    
590    TLegend *leg2 = make_legend("",0.52,0.7);
591 <  leg2->AddEntry(RcorrJZBeemm,"observed (data)","lp");
592 <  leg2->AddEntry(Bpred,"predicted (data)","l");
593 <  leg2->AddEntry(SFN,  "  SF JZB<0","l");
594 <  leg2->AddEntry(OFN,  "  OF JZB<0","l");
595 <  leg2->AddEntry(OFP,  "  OF JZB>0","l");
591 >  if(MCorData==data) {
592 >    leg2->AddEntry(RcorrJZBeemm,"observed (data)","lp");
593 >    leg2->AddEntry(Bpred,"predicted (data)","l");
594 >  } else {
595 >    leg2->AddEntry(RcorrJZBeemm,"true (MC)","lp");
596 >    leg2->AddEntry(Bpred,"predicted (MC)","l");
597 >  }
598 >
599 >  if(jzbthreshold>0) {
600 >    leg2->AddEntry(SFN,  ("  SF JZB<-"+any2string(jzbthreshold)).c_str(),"l");
601 >    leg2->AddEntry(OFN,  ("  OF JZB<-"+any2string(jzbthreshold)).c_str(),"l");
602 >  } else {
603 >    leg2->AddEntry(SFN,  "  SF JZB<0","l");
604 >    leg2->AddEntry(OFN,  "  OF JZB<0","l");
605 >  }
606 >  leg2->AddEntry(OFP,  ("  OF JZB>"+any2string(jzbthreshold)).c_str(),"l");
607    leg2->Draw("same");
608    
609    saveas.str("");
610 <  saveas << "kin/Mll_After_Cut/Cut_At" << jzbthreshold << "_nomc";
610 >  saveas << "kin/Mll_After_Cut/" << prefix << "Cut_At" << jzbthreshold << "_nomc";
611 >  CompleteSave(ckin,saveas.str());
612 >  
613 >  
614 >  TH1F *diff = (TH1F*)RcorrJZBeemm->Clone("diff");
615 >  diff->Add(Bpred,-1);
616 >  
617 >  TLegend *dleg = make_legend();
618 >  if(MCorData==data) dleg->AddEntry(diff,"Obs-predicted","p");
619 >  else dleg->AddEntry(diff,"True-predicted","p");
620 >  dleg->AddEntry(BpredSysBand,"Sys. envelope","f");
621 >  dleg->SetY1(0.7);
622 >  
623 >  
624 >  diff->GetYaxis()->SetTitle("true - predicted");
625 >  if(MCorData==data) diff->GetYaxis()->SetTitle("observed - predicted");
626 >  diff->Draw("e1");
627 >  BpredSysBand->Draw("e2");
628 >  diff->Draw("e1,same");
629 >  dleg->Draw();
630 >  
631 >  if(MCorData==data) DrawPrelim();
632 >  else DrawMCPrelim();
633 >  
634 >  saveas.str("");
635 >  saveas << "kin/Mll_After_Cut/" << prefix << "Cut_At" << jzbthreshold << "_nomc_Diff";
636    CompleteSave(ckin,saveas.str());
637 +
638 +  delete BpredSysBand;
639 +  delete diff;
640    
641    delete RcorrJZBeemm;
642    delete LcorrJZBeemm;
643    delete RcorrJZBem;
644    delete LcorrJZBem;
645 +
646    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
647      delete RcorrJZBSBeemm;
648      delete LcorrJZBSBeemm;
# Line 285 | Line 651 | void make_special_obs_pred_mll_plot(stri
651    }
652    delete Bpred;
653    delete ckin;
654 +  CleanLegends();
655   }
656  
657   void make_special_mll_plot(int nbins, float min, float max, bool logscale,string xlabel) {
# Line 331 | Line 698 | void make_special_mll_plot(int nbins, fl
698    delete datahistoOSOF;
699    delete datahistoOSSF;
700    delete ckin;
701 +  CleanLegends();
702   }
703    
704  
# Line 382 | Line 750 | float make_one_OFSF_plot(string variable
750    TCut cutSF;
751    TCut cutOF;
752  
753 +  cout << "Going to use cutOSSF " << (const char*) cutOSSF << " and cutnJets " << (const char*) cutnJets << " and ibasiccut " << (const char*) ibasiccut << endl;
754    cutOF = cutOSOF&&cutnJets&&ibasiccut;
755    cutSF = cutOSSF&&cutnJets&&ibasiccut;
756    
# Line 403 | Line 772 | float make_one_OFSF_plot(string variable
772   //   signalhisto->SetLineStyle(2);
773    datahistoSF->SetMarkerSize(DataMarkerSize);
774    datahistoOF->SetLineColor(kRed);
775 +  datahistoOF->SetLineWidth(2);
776 +  
777 +  datahistoOF->Scale(1.02); // R(SF/OF)
778  
779    if ( !logscale ) {
780      datahistoSF->SetMinimum(0); // Defaults
# Line 423 | Line 795 | float make_one_OFSF_plot(string variable
795    datahistoSF->GetXaxis()->CenterTitle();
796    datahistoSF->GetYaxis()->CenterTitle();
797  
798 <  TLegend *mleg = make_legend(legendTitle.c_str(),legendPosition,0.7,false,legendPosition+0.2);
798 >  TLegend *mleg = make_legend(legendTitle.c_str(),legendPosition,0.6,false,legendPosition+0.2);
799    mleg->AddEntry(datahistoSF, "Same-flavor", "PL");
800    if (datahistoOF->Integral()>0) {
801 <    mleg->AddEntry(datahistoOF, "Opposite-flavor", "L");
801 >    mleg->AddEntry(datahistoOF, "OF based estimate", "L");
802    } else {
803      mleg->AddEntry((TObject*)0, "", "");
804    }
805    //mleg->AddEntry(signalhisto, "LM3", "L");
806  
807    datahistoSF->Draw("E1");
808 +  
809 +  TH1F *syshisto = (TH1F*)datahistoOF->Clone("syshisto");
810 +  TGraphAsymmErrors *datahistoOFboxes = produce_ratio_graph(datahistoOF);
811 +  for(int i=0;i<datahistoOFboxes->GetN();i++) {
812 +    float ex=datahistoOFboxes->GetErrorX(i);
813 +    float ey=datahistoOFboxes->GetErrorY(i);
814 +    double x,y;
815 +    datahistoOFboxes->GetPoint(i,x,y);
816 +    float pey = sqrt(pow(y*0.07,2)+pow(datahistoOF->GetBinError(i+1),2));
817 +    datahistoOFboxes->SetPointError(ex,ex,pey,pey);
818 +    syshisto->SetBinContent(i+1,0.07);
819 +    syshisto->SetBinError(i+1,0.07);
820 +    if(y<0.01) datahistoOF->SetBinContent(i+1,0);
821 +  }
822 +  mleg->AddEntry(datahistoOFboxes,"Total uncert.","F");
823 +  datahistoOFboxes->SetFillColor(TColor::GetColor("#2E9AFE"));
824 +  
825 +  if (datahistoOF->Integral()>0) datahistoOFboxes->Draw("20");
826    if (datahistoOF->Integral()>0) datahistoOF->Draw("HIST,SAMES");
827 +  
828 +  datahistoSF->Draw("E1,same");
829 +  
830    //signalhisto->Draw("HIST,SAMES");
831    mleg->Draw();
832    DrawPrelim();
833    if (datahistoOF->Integral()>0) {
834 <    Save_With_Ratio( datahistoSF, datahistoOF, rcan, "SFOF/" + filename, false, false, "SF/OF" );
834 > //    Save_With_Ratio( datahistoSF, datahistoOF, rcan, "SFOF/" + filename, false, false, "SF/OF" );
835 >    save_with_ratio_and_sys_band(0, datahistoSF, datahistoOF, rcan, "SFOF/" + filename, false, false, "SF/OF",syshisto);
836    } else {
837      CompleteSave(rcan, "SFOF/" + filename);
838    }
# Line 446 | Line 840 | float make_one_OFSF_plot(string variable
840    datahistoSF->Delete();
841    datahistoOF->Delete();
842    //signalhisto->Delete();
843 +  delete datahistoOFboxes;
844 +  delete syshisto;
845    delete mleg;
846    delete rcan;
847    delete ofsf_can;
452
848    return ymaxSet;
454
849   }
850  
851   // Compare data to data
# Line 512 | Line 906 | float make_data_comparison_plot(string v
906   }
907  
908   void make_OFSF_plots(string variable, string addcut, int nbins, float min, float max, bool logscale,
909 <                     string xlabel, string filename, float legendPosition=0.55) {
909 >                     string xlabel, string filename, float tymax=-1, float legendPosition=0.55) {
910  
911    string mllcuts[] = { "mll>20","mll>15&&mll<70", "mll>75&&mll<105", "mll>120" };
912    string mllcutname[] = { "m_{ll} > 20 GeV", "20 < m_{ll} < 70 GeV", "70 < m_{ll} < 110 GeV", "m_{ll} > 120 GeV" };
913    string plotname[] = {"_all","_low","_peak","_high"};
914    float ymax;
915 +  if(tymax>0) ymax=tymax;
916  
917    int start = 0;
918    if ( !PlottingSetup::openBox ) start = 3;
919  
920    for ( int i=start; i<4; ++i ) {
921      if ( addcut != "" ) mllcuts[i] += "&&"+addcut;
922 <    if ( i==start ) {
922 >    if ( i==start && !(tymax>0) ) {
923        ymax = make_one_OFSF_plot(variable, mllcuts[i], mllcutname[i], nbins, min, max, -1, logscale, xlabel,
924                           filename+plotname[i], legendPosition );
925      } else {
# Line 618 | Line 1013 | void DoMCSystPlot(string datavariable, s
1013    string saveas="kin/"+filename;
1014    
1015    cout << "Passing filename to be saved : " << filename << " as " << saveas << endl;
1016 <  save_with_ratio_and_sys_band( datahisto, CollapseStack(mcstack), kinpad->cd(), saveas, false, false, "data/mc",Systematic );
1016 >  save_with_ratio_and_sys_band(0.0, datahisto, CollapseStack(mcstack), kinpad->cd(), saveas, false, false, "data/mc",Systematic );
1017    
1018    ckin->cd();
1019    MCcentral->SetFillColor(kWhite);
# Line 927 | Line 1322 | void make_JES_plot(TCut cut, string name
1322    CompleteSave(ckin,"Systematics/JES"+name);
1323    datahisto->Delete();
1324    delete ckin;
1325 <
1325 >  delete JESunc;
1326 >  delete JESup;
1327 >  delete JESdn;
1328 >  CleanLegends();
1329   }
1330  
1331   string Cut2Str(TCut cut) {
# Line 946 | Line 1344 | void MakeElegantTwoThreeComparisons() {
1344      string xlabel="m_{ll} [GeV]";
1345      
1346      TCanvas *can2 = new TCanvas("can2","can2");
1347 <    TH1F *TwoOF = allsamples.Draw("TwoOF","mll",nbins,min,max, xlabel, "events",cutOSOF&&signal&&TwoJets,mc,luminosity,allsamples.FindSample("TTJets_"));
1348 <    TH1F *TwoSF = allsamples.Draw("TwoSF","mll",nbins,min,max, xlabel, "events",cutOSSF&&signal&&TwoJets,mc,luminosity,allsamples.FindSample("TTJets_"));
1349 <    TH1F *ThreeOF = allsamples.Draw("ThreeOF","mll",nbins,min,max, xlabel, "events",cutOSOF&&signal&&ThreeJets,mc,luminosity,allsamples.FindSample("TTJets_"));
1350 <    TH1F *ThreeSF = allsamples.Draw("ThreeSF","mll",nbins,min,max, xlabel, "events",cutOSSF&&signal&&ThreeJets,mc,luminosity,allsamples.FindSample("TTJets_"));
1347 >    TH1F *TwoOF = allsamples.Draw("TwoOF","mll",nbins,min,max, xlabel, "events",cutOSOF&&signal&&TwoJets,mc,luminosity,allsamples.FindSample("/TT_"));
1348 >    TH1F *TwoSF = allsamples.Draw("TwoSF","mll",nbins,min,max, xlabel, "events",cutOSSF&&signal&&TwoJets,mc,luminosity,allsamples.FindSample("/TT_"));
1349 >    TH1F *ThreeOF = allsamples.Draw("ThreeOF","mll",nbins,min,max, xlabel, "events",cutOSOF&&signal&&ThreeJets,mc,luminosity,allsamples.FindSample("/TT_"));
1350 >    TH1F *ThreeSF = allsamples.Draw("ThreeSF","mll",nbins,min,max, xlabel, "events",cutOSSF&&signal&&ThreeJets,mc,luminosity,allsamples.FindSample("/TT_"));
1351      
1352      can2->cd(1);
1353      
# Line 1053 | Line 1451 | void make_ttbar_comparison(string datava
1451    
1452    TCanvas *ckin = new TCanvas("ckin","Kinematic Plots (in the making)",600,600);
1453    ckin->SetLogy(dolog);
1454 <  cout << "\r Creating " << filename << " : data   (1/11)" << std::flush;
1454 >  cout << "\r Creating " << filename << " : data   (1/7)" << std::flush;
1455    TH1F *datahisto = allsamples.Draw("datahisto",datavariable,nbins,min,max, xlabel, "events",cut,data,luminosity);
1456    datahisto->SetMarkerSize(DataMarkerSize);
1457    if ( !dolog ) datahisto->SetMinimum(0); // Defaults
1458    else datahisto->SetMinimum(0.5);
1459    if (dolog) datahisto->SetMaximum(5.3*datahisto->GetMaximum());
1460    else datahisto->SetMaximum(1.3*datahisto->GetMaximum());
1461 <  cout << "\r Creating " << filename << " : MC central  (stack) (2/11)" << std::flush;
1461 >  cout << "\r Creating " << filename << " : MC central  (stack) (2/7)" << std::flush;
1462    THStack mcstack   = allsamples.DrawStack("mcstack",  mcvariable,nbins,min,max,xlabel,"events",cut,mc,luminosity);
1463    TH1F *MCcentral = CollapseStack(mcstack);
1464  
1465 <  cout << "\r Creating " << filename << " : MC central (histo)   (3/11)" << std::flush;
1466 <  TH1F *TCentral        = allsamples.Draw ("TCentral",     mcvariable,nbins,min,max,xlabel,"events",cut,mc,luminosity,allsamples.FindSample("TTJets_"));
1465 >  cout << "\r Creating " << filename << " : MC central (histo)   (3/7)" << std::flush;
1466 >  TH1F *TCentral        = allsamples.Draw ("TCentral",     mcvariable,nbins,min,max,xlabel,"events",cut,mc,luminosity,allsamples.FindSample("/TT_"));
1467    TH1F *RCentral        = ProduceTTbarRatio(datahisto,MCcentral,TCentral,TCentral);
1468    
1469 <  cout << "\r Creating " << filename << " : MC Matching up   (4/11)" << std::flush;
1469 >  cout << "\r Creating " << filename << " : MC Matching up   (4/7)" << std::flush;
1470    TH1F *TMatchingUp     = systsamples.Draw("TMatchingUp",  mcvariable,nbins,min,max,xlabel,"events",cut,mc,luminosity,systsamples.FindSample("TTJets_matchingup"));
1471    TH1F *RMatchingUp     = ProduceTTbarRatio(datahisto,MCcentral,TCentral,TMatchingUp);
1472    
1473 <  cout << "\r Creating " << filename << " : MC Matching down   (5/11)" << std::flush;
1473 >  cout << "\r Creating " << filename << " : MC Matching down   (5/7)" << std::flush;
1474    TH1F *TMatchingDown   = systsamples.Draw("TMatchingDown",mcvariable,nbins,min,max,xlabel,"events",cut,mc,luminosity,systsamples.FindSample("TTJets_matchingdown"));
1475    TH1F *RMatchingDown   = ProduceTTbarRatio(datahisto,MCcentral,TCentral,TMatchingDown);
1476    
1477 <  cout << "\r Creating " << filename << " : MC Scale up   (6/11)" << std::flush;
1477 >  cout << "\r Creating " << filename << " : MC Scale up   (6/7)" << std::flush;
1478    TH1F *TScaleUp        = systsamples.Draw("TScaleUp",     mcvariable,nbins,min,max,xlabel,"events",cut,mc,luminosity,systsamples.FindSample("TTJets_scaleup"));
1479    TH1F *RScaleUp        = ProduceTTbarRatio(datahisto,MCcentral,TCentral,TScaleUp);
1480    
1481 <  cout << "\r Creating " << filename << " : MC Scale down   (7/11)" << std::flush;
1481 >  cout << "\r Creating " << filename << " : MC Scale down   (7/7)" << std::flush;
1482    TH1F *TScaleDown      = systsamples.Draw("TScaleDown",   mcvariable,nbins,min,max,xlabel,"events",cut,mc,luminosity,systsamples.FindSample("TTJets_scaledown"));
1483    TH1F *RScaleDown      = ProduceTTbarRatio(datahisto,MCcentral,TCentral,TScaleDown);
1484    
1087  cout << "\r Creating " << filename << " : MC mass=166   (8/11)" << std::flush;
1088  TH1F *Ttmass166       = systsamples.Draw("Ttmass166",    mcvariable,nbins,min,max,xlabel,"events",cut,mc,luminosity,systsamples.FindSample("TTJets_mass166"));
1089  TH1F *Rtmass166       = ProduceTTbarRatio(datahisto,MCcentral,TCentral,Ttmass166);
1090  
1091  cout << "\r Creating " << filename << " : MC mass=169   (9/11)" << std::flush;
1092  TH1F *Ttmass169       = systsamples.Draw("Ttmass169",    mcvariable,nbins,min,max,xlabel,"events",cut,mc,luminosity,systsamples.FindSample("TTJets_mass169"));
1093  TH1F *Rtmass169       = ProduceTTbarRatio(datahisto,MCcentral,TCentral,Ttmass169);
1094  
1095  cout << "\r Creating " << filename << " : MC mass=175   (10/11)" << std::flush;
1096  TH1F *Ttmass175       = systsamples.Draw("Ttmass175",    mcvariable,nbins,min,max,xlabel,"events",cut,mc,luminosity,systsamples.FindSample("TTJets_mass175"));
1097  TH1F *Rtmass175       = ProduceTTbarRatio(datahisto,MCcentral,TCentral,Ttmass175);
1098  
1099  cout << "\r Creating " << filename << " : MC mass=178   (11/11)" << std::flush;
1100  TH1F *Ttmass178       = systsamples.Draw("Ttmass178",    mcvariable,nbins,min,max,xlabel,"events",cut,mc,luminosity,systsamples.FindSample("TTJets_mass178"));
1101  TH1F *Rtmass178       = ProduceTTbarRatio(datahisto,MCcentral,TCentral,Ttmass178);
1102  
1103  
1485    datahisto->Draw("e1");
1486    ckin->Update();
1487    mcstack.Draw("histo,same");
# Line 1138 | Line 1519 | void make_ttbar_comparison(string datava
1519    TScaleDown->SetLineColor(TColor::GetColor("#FF8500"));
1520    TScaleDown->SetLineStyle(3);//dotted
1521    
1141  Ttmass166->SetLineColor(TColor::GetColor("#0acf00"));//green
1142  Ttmass166->SetLineStyle(3);//dotted
1143  Ttmass178->SetLineColor(TColor::GetColor("#0acf00"));
1144  Ttmass178->SetLineStyle(2);//dashed
1145  
1146  
1147  Ttmass169->SetLineColor(TColor::GetColor("#FF52F1"));//purple
1148  Ttmass169->SetLineStyle(3);//dotted
1149  Ttmass175->SetLineColor(TColor::GetColor("#FF52F1"));
1150  Ttmass175->SetLineStyle(2);//dashed
1151  
1152  
1153  
1154  
1522    MCcentral->SetLineStyle(3);
1523    MCcentral->SetLineColor(kRed);
1524    
# Line 1161 | Line 1528 | void make_ttbar_comparison(string datava
1528    TMatchingDown->Draw("histo,same");
1529    TScaleUp->Draw("histo,same");
1530    TScaleDown->Draw("histo,same");
1164  Ttmass166->Draw("histo,same");
1165  Ttmass169->Draw("histo,same");
1166  Ttmass175->Draw("histo,same");
1167  Ttmass178->Draw("histo,same");
1531    
1532    TLegend *sleg = make_legend();
1533    sleg->AddEntry(TCentral,"Central","L");
# Line 1172 | Line 1535 | void make_ttbar_comparison(string datava
1535    sleg->AddEntry(TMatchingDown,"matching down","L");
1536    sleg->AddEntry(TScaleUp,"scale up","L");
1537    sleg->AddEntry(TScaleDown,"scale down","L");
1175  sleg->AddEntry(Ttmass166,"m_{t}=166","L");
1176  sleg->AddEntry(Ttmass169,"m_{t}=169","L");
1177  sleg->AddEntry(Ttmass175,"m_{t}=175","L");
1178  sleg->AddEntry(Ttmass178,"m_{t}=178","L");
1538    sleg->Draw();
1539    
1540    CompleteSave(ckin,saveas+"___AllLines");
# Line 1194 | Line 1553 | void make_ttbar_comparison(string datava
1553    RScaleDown->SetLineColor(TColor::GetColor("#FF8500"));
1554    RScaleDown->SetLineStyle(3);//dotted
1555    
1197  Rtmass166->SetLineColor(TColor::GetColor("#0acf00"));//green
1198  Rtmass166->SetLineStyle(3);//dotted
1199  Rtmass178->SetLineColor(TColor::GetColor("#0acf00"));
1200  Rtmass178->SetLineStyle(2);//dashed
1201  
1202  
1203  Rtmass169->SetLineColor(TColor::GetColor("#FF52F1"));//purple
1204  Rtmass169->SetLineStyle(3);//dotted
1205  Rtmass175->SetLineColor(TColor::GetColor("#FF52F1"));
1206  Rtmass175->SetLineStyle(2);//dashed
1207
1208  
1556    RCentral->GetYaxis()->SetRangeUser(0,2);
1557    RCentral->Draw("e1");
1558    RMatchingUp->Draw("histo,same");
1559    RMatchingDown->Draw("histo,same");
1560    RScaleUp->Draw("histo,same");
1561    RScaleDown->Draw("histo,same");
1215  Rtmass166->Draw("histo,same");
1216  Rtmass169->Draw("histo,same");
1217  Rtmass175->Draw("histo,same");
1218  Rtmass178->Draw("histo,same");
1562    
1563    CompleteSave(ckin,saveas+"___AllRatios");
1564  
1565 <  TCanvas *multicanvas = new TCanvas("multicanvas","multicanvas",1000,1000);
1566 <  multicanvas->Divide(2,2);
1565 >  TCanvas *multicanvas = new TCanvas("multicanvas","multicanvas",1400,700);
1566 >  multicanvas->Divide(2,1);
1567    PresentRange(RMatchingUp,RMatchingDown,RCentral,multicanvas->cd(1),"Matching");
1568    PresentRange(RScaleUp,RScaleDown,RCentral,multicanvas->cd(2),"Scale");
1226  PresentRange(Rtmass166,Rtmass178,RCentral,multicanvas->cd(3),"m_{t} (2#sigma)");
1227  PresentRange(Rtmass169,Rtmass175,RCentral,multicanvas->cd(4),"m_{t} (1#sigma)");
1569    CompleteSave(multicanvas,saveas+"___RangeIllustration");
1570    
1571    
# Line 1234 | Line 1575 | void make_ttbar_comparison(string datava
1575    delete   TMatchingDown;
1576    delete   TScaleUp;
1577    delete   TScaleDown;
1578 <  delete   Ttmass166;
1579 <  delete   Ttmass169;
1580 <  delete   Ttmass175;
1581 <  delete   Ttmass178;
1578 > //   delete   Ttmass166;
1579 > //   delete   Ttmass169;
1580 > //   delete   Ttmass175;
1581 > //   delete   Ttmass178;
1582    
1583    delete ckin;
1584    
# Line 1310 | Line 1651 | THStack MakeOneSystematicsPlot(TCut cut,
1651      }
1652    }
1653      
1313  
1654    TLegend *fullleg = allsamples.allbglegend();
1655    fullleg->SetHeader(variation.c_str());
1656    TPad *kinpad = new TPad("kinpad","kinpad",0,0,1,1);
# Line 1380 | Line 1720 | void ProduceMCSystematicPlot(string vari
1720    
1721    DrawPrelim();
1722    
1723 <  save_with_ratio_and_sys_band( hdata, HCentral, kinpad->cd(), saveas, false, false, "data/mc",Systematic );
1723 >  save_with_ratio_and_sys_band( 0.0, hdata, HCentral, kinpad->cd(), saveas, false, false, "data/mc",Systematic );
1724    
1725    kinpad->cd();
1726    tCentral->SetFillColor(kWhite);
# Line 1481 | Line 1821 | void ProduceMCSystematicPlot(string vari
1821    delete ca;
1822   }
1823  
1824 + TH1F* ImposeBinning(TH1F *binninghisto, TH1F* histo) {
1825 +  float val=0,err=0;
1826 +  vector<float> bins;
1827 +  vector<float> vals;
1828 +  vector<float> errs;
1829 +  
1830 +  bins.push_back(binninghisto->GetBinLowEdge(1));
1831 +  int iBin=1;
1832 +  
1833 +  for(unsigned int i=1;i<histo->GetNbinsX();i++) {//going to second last one on purpose!
1834 +    if((histo->GetBinLowEdge(i)+0.00001>=binninghisto->GetBinLowEdge(iBin)+binninghisto->GetBinWidth(iBin))) {
1835 +      bins.push_back(histo->GetBinLowEdge(i));
1836 +      vals.push_back(val);val=0;
1837 +      errs.push_back(err);err=0;
1838 +      iBin++;
1839 +    }
1840 +    val+=histo->GetBinContent(i);
1841 +    err=sqrt(err*err+histo->GetBinError(i)*histo->GetBinError(i));
1842 +  }
1843 +  bins.push_back(histo->GetBinLowEdge(histo->GetNbinsX())+histo->GetBinWidth(histo->GetNbinsX()));
1844 +  vals.push_back(val);val=0;
1845 +  errs.push_back(err);err=0;
1846 +  
1847 +  TH1F *h = new TH1F(("r"+(string)histo->GetName()).c_str(),("r"+(string)histo->GetName()).c_str(),bins.size()-1,&bins[0]);
1848 +  for(unsigned int i=0;i<vals.size();i++) {
1849 +    h->SetBinContent(i+1,vals[i]);
1850 +    h->SetBinError(i+1,errs[i]);
1851 +  }
1852 +  
1853 +  h->GetXaxis()->SetTitle(histo->GetXaxis()->GetTitle());
1854 +  h->GetYaxis()->SetTitle(histo->GetYaxis()->GetTitle());
1855 +  
1856 +  h->GetXaxis()->CenterTitle();
1857 +  h->GetYaxis()->CenterTitle();
1858 +
1859 +  return h;
1860 + }
1861 +
1862 +
1863 + TH1F* ReBinOptimizingStats(int nbins, TH1F *histo) {
1864 +  float statsperbin = (1/(float)nbins) * histo->Integral();
1865 +  float val=0,err=0;
1866 +  vector<float> bins;
1867 +  vector<float> vals;
1868 +  vector<float> errs;
1869 +  
1870 +  bins.push_back(histo->GetBinLowEdge(1));
1871 +  for(unsigned int i=1;i<=histo->GetNbinsX();i++) {
1872 +    val+=histo->GetBinContent(i);
1873 +    err=sqrt(err*err+histo->GetBinError(i)*histo->GetBinError(i));
1874 +    if( val/statsperbin > 0.85) {
1875 +      if(bins.size()<nbins) {
1876 +        bins.push_back(histo->GetBinLowEdge(i)+histo->GetBinWidth(i));
1877 +        vals.push_back(val);val=0;
1878 +        errs.push_back(err);err=0;
1879 +      }
1880 +    }
1881 +    if(i==histo->GetNbinsX()) {
1882 +      bins.push_back(histo->GetBinLowEdge(i)+histo->GetBinWidth(i));
1883 +      vals.push_back(val);val=0;
1884 +      errs.push_back(err);err=0;
1885 +    }
1886 +  }
1887 +  TH1F *h = new TH1F(("r"+(string)histo->GetName()).c_str(),("r"+(string)histo->GetName()).c_str(),bins.size()-1,&bins[0]);
1888 +  
1889 +  h->GetXaxis()->SetTitle(histo->GetXaxis()->GetTitle());
1890 +  h->GetYaxis()->SetTitle(histo->GetYaxis()->GetTitle());
1891 +  
1892 +  h->GetXaxis()->CenterTitle();
1893 +  h->GetYaxis()->CenterTitle();
1894 +  
1895 +  for(unsigned int i=0;i<vals.size();i++) {
1896 +    h->SetBinContent(i+1,vals[i]);
1897 +    h->SetBinError(i+1,errs[i]);
1898 +  }
1899 +  
1900 +  return h;
1901 + }
1902 +
1903 +
1904 +  
1905 + void ShowBinning(TH1F *histo) {
1906 +  cout << "Showing binning for " << histo->GetName() << " (\" " << histo->GetTitle() << "\")" << endl;
1907 +  for(unsigned int i=1;i<=histo->GetNbinsX();i++) cout << "   Bin " << i << " : " << histo->GetBinLowEdge(i) << " , " << histo->GetBinLowEdge(i) + histo->GetBinWidth(i) << "  : " << histo->GetBinContent(i) << endl;
1908 + }
1909 +  
1910   void QuickProduceMCSystematicPlot(string variable, int nbins, float bmin, float bmax, string label, TCut thiscut, string saveas) {
1911    TCanvas *ca = new TCanvas("ca","ca");
1912    TH1F *tScaleUp = systsamples.Draw("tScaleUp",variable,nbins,bmin,bmax,label,"events",thiscut,mc,luminosity,systsamples.FindSample("scaleup"));
# Line 1493 | Line 1919 | void QuickProduceMCSystematicPlot(string
1919    tScaleDown->Scale(1.0/tScaleDown->Integral());
1920    tMatchingDown->Scale(1.0/tMatchingDown->Integral());
1921    tMatchingUp->Scale(1.0/tMatchingUp->Integral());
1922 +  tCentral->Scale(1.0/tCentral->Integral());
1923 +  
1924 +  cout << "At this point we want to rebin the scale/matching histograms so we get decent stats!" << endl;
1925 +  
1926 +  
1927 +  TH1F *rtScaleUp = ReBinOptimizingStats(7,tScaleUp); // using the scale up sample to get the binning (shouldn't use the central one for obvious reasons)
1928 +  TH1F *rtScaleDown = ImposeBinning(rtScaleUp,tScaleDown);
1929 +  TH1F *rtMatchingDown = ImposeBinning(rtScaleUp,tMatchingDown);
1930 +  TH1F *rtMatchingUp = ImposeBinning(rtScaleUp,tMatchingUp);
1931 +  TH1F *rtCentral = ImposeBinning(rtScaleUp,tCentral);
1932 +  
1933 +  float min=rtScaleUp->GetMinimum();
1934 +  float max=rtScaleUp->GetMaximum();
1935 +  
1936 +  if(rtScaleDown->GetMinimum()<min) min=rtScaleDown->GetMinimum();
1937 +  if(rtMatchingDown->GetMinimum()<min) min=rtMatchingDown->GetMinimum();
1938 +  if(rtMatchingDown->GetMinimum()<min) min=rtMatchingDown->GetMinimum();
1939 +  if(rtMatchingUp->GetMinimum()<min) min=rtMatchingUp->GetMinimum();
1940 +  if(rtCentral->GetMinimum()<min) min=rtCentral->GetMinimum();
1941 +  
1942 +  if(rtScaleDown->GetMaximum()<min) max=rtScaleDown->GetMaximum();
1943 +  if(rtMatchingDown->GetMaximum()<min) max=rtMatchingDown->GetMaximum();
1944 +  if(rtMatchingDown->GetMaximum()<min) max=rtMatchingDown->GetMaximum();
1945 +  if(rtMatchingUp->GetMaximum()<min) max=rtMatchingUp->GetMaximum();
1946 +  if(rtCentral->GetMaximum()<min) max=rtCentral->GetMaximum();
1947 +  
1948 +  rtCentral->SetMaximum(1.2*max);
1949 +  rtCentral->SetMinimum(0.8*min);
1950 +  
1951 + /*  tScaleUp->Rebin(40);
1952 +  tScaleDown->Rebin(40);
1953 +  tMatchingDown->Rebin(40);
1954 +  tMatchingUp->Rebin(40);
1955 +  tCentral->Rebin(40);*/
1956    
1957    TPad *kinpad = new TPad("kinpad","kinpad",0,0,1,1);
1958    kinpad->SetLogy(1);
# Line 1508 | Line 1968 | void QuickProduceMCSystematicPlot(string
1968    tMatchingUp->SetLineStyle(2);
1969    tMatchingDown->SetLineStyle(3);
1970    
1971 +  rtScaleDown->SetLineColor(kRed);
1972 +  rtMatchingUp->SetLineColor(kBlue);
1973 +  rtMatchingDown->SetLineColor(kBlue);
1974 +  rtScaleUp->SetLineStyle(2);
1975 +  rtScaleDown->SetLineStyle(3);
1976 +  rtMatchingUp->SetLineStyle(2);
1977 +  rtMatchingDown->SetLineStyle(3);
1978 +  
1979    TLegend *leg2 = make_legend();
1980    leg2->AddEntry(tCentral,"Central (ttbar)","l");
1981    leg2->AddEntry(tScaleUp,"ScaleUp (ttbar)","l");
# Line 1521 | Line 1989 | void QuickProduceMCSystematicPlot(string
1989    tMatchingUp->Draw("histo,same");
1990    tMatchingDown->Draw("histo,same");
1991    leg2->Draw();
1992 <  
1992 >  DrawMCPrelim();
1993    CompleteSave(kinpad,saveas+"__TTbarComparison");
1994 +  kinpad->cd();
1995 +  kinpad->SetLogy(0);
1996 +  rtCentral->Draw("histo");
1997 +  rtScaleUp->Draw("histo,same");
1998 +  rtScaleDown->Draw("histo,same");
1999 +  rtMatchingUp->Draw("histo,same");
2000 +  rtMatchingDown->Draw("histo,same");
2001 +  leg2->Draw();
2002 +  DrawMCPrelim();
2003 +  CompleteSave(kinpad,saveas+"__TTbarComparison__REBINNED");
2004    
1527  gStyle->SetOptFit(0);
2005    
2006 +  gStyle->SetOptFit(0);
2007 +
2008    kinpad->cd();
2009    kinpad->SetLogy(0);
2010 <  TH1F *MatchingRatio = (TH1F*)tMatchingUp->Clone("MatchingRatio");
2011 <  MatchingRatio->Divide(tMatchingDown);
2010 >  TH1F *MatchingRatio = (TH1F*)rtMatchingUp->Clone("MatchingRatio");
2011 >  MatchingRatio->Divide(rtMatchingDown);
2012    TLine *lone = new TLine(tScaleUp->GetBinLowEdge(1),1,tScaleUp->GetBinLowEdge(tScaleUp->GetNbinsX())+tScaleUp->GetBinWidth(tScaleUp->GetNbinsX()),1);
2013    lone->SetLineColor(TColor::GetColor("#01DF01"));
2014    lone->SetLineStyle(2);
2015 <  TH1F *ScaleRatio = (TH1F*)tScaleUp->Clone("ScaleRatio");
2016 <  ScaleRatio->Divide(tScaleDown);
2015 >  TH1F *ScaleRatio = (TH1F*)rtScaleUp->Clone("ScaleRatio");
2016 >  ScaleRatio->Divide(rtScaleDown);
2017    MatchingRatio->GetYaxis()->SetRangeUser(0,3);
2018    MatchingRatio->Draw("e1");
2019    TF1 *QP1 = new TF1("QP1","[0]+[1]*x",50,200);//simple linear function ranging from 50 to 200
2020 <  MatchingRatio->Fit("QP1","RQ");
2020 >  if(variable=="genMET" || variable=="met[4]" || variable=="met[1]") MatchingRatio->Fit("QP1","RQ");
2021    lone->Draw();
2022    stringstream summary;
2023    summary << " #splitline{Fit result for f(x) = a+bx :}{#splitline{a=" << DigitsAfterComma(QP1->GetParameter(0),4) << " +/- " << DigitsAfterComma(QP1->GetParError(0),4) << "}{b=" << DigitsAfterComma(QP1->GetParameter(1),4);
# Line 1547 | Line 2026 | void QuickProduceMCSystematicPlot(string
2026    infobox->SetX(0.75);
2027    infobox->SetTextSize(0.03);
2028    infobox->SetY(0.75);
2029 <  infobox->Draw();
2029 >  if(variable=="genMET" || variable=="met[4]" || variable=="met[1]") infobox->Draw();
2030 >  DrawMCPrelim();
2031    CompleteSave(kinpad,saveas+"__TTbarComparison_MatchingUpDividedMatchingDown");
2032    kinpad->cd();
2033    ScaleRatio->GetYaxis()->SetRangeUser(0,3);
2034    ScaleRatio->Draw("e1");
2035 <  ScaleRatio->Fit("QP1","RQ");
2035 >  if(variable=="genMET" || variable=="met[4]" || variable=="met[1]") ScaleRatio->Fit("QP1","RQ");
2036    summary.str("");
2037    summary << " #splitline{Fit result for f(x) = a+bx :}{#splitline{a=" << DigitsAfterComma(QP1->GetParameter(0),4) << " +/- " << DigitsAfterComma(QP1->GetParError(0),4) << "}{b=" << DigitsAfterComma(QP1->GetParameter(1),4);
2038    summary << " +/- " << DigitsAfterComma(QP1->GetParError(1),4) << "}}";
# Line 1560 | Line 2040 | void QuickProduceMCSystematicPlot(string
2040    infobox2->SetX(0.75);
2041    infobox2->SetTextSize(0.03);
2042    infobox2->SetY(0.75);
2043 <  infobox2->Draw();
2043 >  if(variable=="genMET" || variable=="met[4]" || variable=="met[1]") infobox2->Draw();
2044  
2045    lone->Draw();
2046 +  DrawMCPrelim();
2047    CompleteSave(kinpad,saveas+"__TTbarComparison_ScaleUpDividedScaleDown");
2048    
2049 +  kinpad->cd();
2050 +  TH1F *SysMatching = (TH1F*)rtMatchingDown->Clone("SysMatching");
2051 +  TH1F *SysScale = (TH1F*)rtScaleDown->Clone("SysMatching");
2052 +  TH1F *SysHisto = (TH1F*)rtScaleDown->Clone("SysHisto");
2053 +  
2054 +  for(int i=1;i<=SysScale->GetNbinsX();i++) {
2055 +    float matching, scale;
2056 +    bool AssumeFactor=false;
2057 +    if(AssumeFactor) {
2058 +      // assume that an upward/downward variation means a change by a constant factor, i.e. f(up) = alpha * f(central)
2059 +      matching=0.;
2060 +      scale=0.;
2061 +    } else {
2062 +      // assume that the central value is exactly between up & down, i.e. central = (up-down)/2
2063 +      matching = fabs(    ( rtMatchingUp->GetBinContent(i) - rtMatchingDown->GetBinContent(i)) / (rtMatchingUp->GetBinContent(i) + rtMatchingDown->GetBinContent(i)) );
2064 +      scale    = fabs(    ( rtScaleUp->GetBinContent(i) - rtScaleDown->GetBinContent(i)) / (rtScaleUp->GetBinContent(i) + rtScaleDown->GetBinContent(i)) );
2065 +    }
2066 +    
2067 +    SysMatching->SetBinContent(i,1+matching);
2068 +    SysScale->SetBinContent(i,1+scale);
2069 +    SysHisto->SetBinContent(i,sqrt(matching*matching+scale*scale)+1);
2070 +  }
2071 +  
2072 +  SysHisto->SetLineColor(kGreen);
2073 +  
2074 +  SysMatching->SetMaximum(3.0);
2075 +  SysMatching->SetMinimum(0.0);
2076 +  SysMatching->Draw("histo");
2077 +  SysScale->Draw("histo,same");
2078 +  SysHisto->Draw("histo,same");
2079 +  CompleteSave(kinpad,saveas+"__TTbarComparison_DerivedSystematic");
2080 +  
2081 +  delete SysMatching;
2082 +  delete SysScale;
2083 +  
2084 +  if(!Contains(variable,"gen")) {
2085 +    TH1F *hdata  = allsamples.Draw("hdata",   variable,nbins,bmin,bmax,label,"events",thiscut,data,luminosity);
2086 +    THStack smc = allsamples.DrawStack("smc",variable,nbins,bmin,bmax,label,"events",thiscut,mc,luminosity);
2087 +    
2088 +    TH1F *Systematic = (TH1F*)hdata->Clone("Systematic");
2089 +    
2090 +    for(int i=1;i<=Systematic->GetNbinsX();i++) {
2091 +      int iBin=SysHisto->FindBin(Systematic->GetBinCenter(i));
2092 +      if(iBin>SysHisto->GetNbinsX()) --iBin; // if we're over the end of the histo, use the last bin
2093 +      float sys = SysHisto->GetBinContent(iBin)-1;
2094 +      Systematic->SetBinContent(i,sys);
2095 +    }
2096 +    
2097 +    kinpad->cd();
2098 +    TLegend *leg = allsamples.allbglegend();
2099 +    hdata->Draw();
2100 +    smc.Draw("histo,same");
2101 +    hdata->Draw("same");
2102 +    leg->Draw();
2103 +    DrawPrelim();
2104 +    save_with_ratio_and_sys_band( 0.0, hdata, CollapseStack(smc), kinpad->cd(), saveas+"__DataVsMC", false, false, "data/mc",Systematic );
2105 +    
2106 +    delete Systematic;
2107 +    delete hdata;
2108 +  }
2109 +  
2110 +  
2111 +  delete SysHisto;
2112    delete tScaleUp;
2113    delete tScaleDown;
2114    delete tCentral;
2115    delete tMatchingUp;
2116    delete tMatchingDown;
2117 +  delete rtScaleUp;
2118 +  delete rtScaleDown;
2119 +  delete rtCentral;
2120 +  delete rtMatchingUp;
2121 +  delete rtMatchingDown;
2122    delete QP1;
2123    delete infobox;
2124    delete infobox2;
# Line 1584 | Line 2133 | void ProduceMCSystematicPlots() {
2133    cout << "Getting ready to produce systematic plots " << endl;
2134    TCut cutweightBKP = cutWeight;
2135    
2136 <  QuickProduceMCSystematicPlot("genMET",20,0,200,"genMET [GeV]",cutOSSF&&cutnJets&&TCut("mll>20&&mll<70"),"MCSystPlots/genMET/ETH_SameFlavor");
2137 <  QuickProduceMCSystematicPlot("genMET",20,0,200,"genMET [GeV]",cutOSOF&&cutnJets&&TCut("mll>20&&mll<70"),"MCSystPlots/genMET/ETH_OppositeFlavor");  
2138 <  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PFMET [GeV]",cutOSSF&&cutnJets&&TCut("mll>20&&mll<70"),"MCSystPlots/MET/ETH_SameFlavor");
2139 <  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PFMET [GeV]",cutOSOF&&cutnJets&&TCut("mll>20&&mll<70"),"MCSystPlots/MET/ETH_OppositeFlavor");
2140 <  
2141 <  QuickProduceMCSystematicPlot("genMET",20,0,200,"genMET [GeV]",cutOSSF&&TCut("mll>20&&mll<70"),"MCSystPlots/genMET/ETH_SameFlavor_INCLUSIVE");
2142 <  QuickProduceMCSystematicPlot("genMET",20,0,200,"genMET [GeV]",cutOSOF&&TCut("mll>20&&mll<70"),"MCSystPlots/genMET/ETH_OppositeFlavor_INCLUSIVE");  
2143 <  QuickProduceMCSystematicPlot("genMET",20,0,200,"genMET [GeV]",cutOSSF&&TCut("mll>120"),"MCSystPlots/genMET/ETH_SameFlavor_INCLUSIVE_HighMass");
2144 <  QuickProduceMCSystematicPlot("genMET",20,0,200,"genMET [GeV]",cutOSOF&&TCut("mll>120"),"MCSystPlots/genMET/ETH_OppositeFlavor_INCLUSIVE_HighMass");  
2145 <  
2146 <  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PFMET [GeV]",cutOSSF&&TCut("mll>20&&mll<70"),"MCSystPlots/MET/ETH_SameFlavor_INCLUSIVE");
2147 <  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PFMET [GeV]",cutOSOF&&TCut("mll>20&&mll<70"),"MCSystPlots/MET/ETH_OppositeFlavor_INCLUSIVE");
2148 <  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PFMET [GeV]",cutOSSF&&TCut("mll>120"),"MCSystPlots/MET/ETH_SameFlavor_INCLUSIVE_HighMass");
2149 <  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PFMET [GeV]",cutOSOF&&TCut("mll>120"),"MCSystPlots/MET/ETH_OppositeFlavor_INCLUSIVE_HighMass");
2136 >  QuickProduceMCSystematicPlot("genMET",20,0,200,"gen#slash{E}_{T} [GeV]",cutOSSF&&cutnJets&&TCut("mll>20&&mll<70"),"MCSystPlots/genMET/ETH_SameFlavor");
2137 >  QuickProduceMCSystematicPlot("genMET",20,0,200,"gen#slash{E}_{T} [GeV]",cutOSOF&&cutnJets&&TCut("mll>20&&mll<70"),"MCSystPlots/genMET/ETH_OppositeFlavor");
2138 >  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PF#slash{E}_{T} [GeV]",cutOSSF&&cutnJets&&TCut("mll>20&&mll<70"),"MCSystPlots/MET/ETH_SameFlavor");
2139 >  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PF#slash{E}_{T} [GeV]",cutOSOF&&cutnJets&&TCut("mll>20&&mll<70"),"MCSystPlots/MET/ETH_OppositeFlavor");
2140 >  
2141 >  QuickProduceMCSystematicPlot("genMET",20,0,200,"gen#slash{E}_{T} [GeV]",cutOSSF&&TCut("mll>20&&mll<70"),"MCSystPlots/genMET/ETH_SameFlavor_INCLUSIVE");
2142 >  QuickProduceMCSystematicPlot("genMET",20,0,200,"gen#slash{E}_{T} [GeV]",cutOSOF&&TCut("mll>20&&mll<70"),"MCSystPlots/genMET/ETH_OppositeFlavor_INCLUSIVE");  
2143 >  QuickProduceMCSystematicPlot("genMET",20,0,200,"gen#slash{E}_{T} [GeV]",cutOSSF&&TCut("mll>120"),"MCSystPlots/genMET/ETH_SameFlavor_INCLUSIVE_HighMass");
2144 >  QuickProduceMCSystematicPlot("genMET",20,0,200,"gen#slash{E}_{T} [GeV]",cutOSOF&&TCut("mll>120"),"MCSystPlots/genMET/ETH_OppositeFlavor_INCLUSIVE_HighMass");  
2145 >  
2146 >  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PF#slash{E}_{T} [GeV]",cutOSSF&&TCut("mll>20&&mll<70"),"MCSystPlots/MET/ETH_SameFlavor_INCLUSIVE");
2147 >  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PF#slash{E}_{T} [GeV]",cutOSOF&&TCut("mll>20&&mll<70"),"MCSystPlots/MET/ETH_OppositeFlavor_INCLUSIVE");
2148 >  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PF#slash{E}_{T} [GeV]",cutOSSF&&TCut("mll>120"),"MCSystPlots/MET/ETH_SameFlavor_INCLUSIVE_HighMass");
2149 >  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PF#slash{E}_{T} [GeV]",cutOSOF&&TCut("mll>120"),"MCSystPlots/MET/ETH_OppositeFlavor_INCLUSIVE_HighMass");
2150    QuickProduceMCSystematicPlot("pfJetGoodNum40",8,-0.5,7.5,"NJets",cutOSSF&&cutnJets&&TCut("mll>20&&mll<70&&met[4]>100"),"MCSystPlots/NJets/ETH_SameFlavor");
2151    QuickProduceMCSystematicPlot("pfJetGoodNum40",8,-0.5,7.5,"NJets",cutOSOF&&cutnJets&&TCut("mll>20&&mll<70&&met[4]>100"),"MCSystPlots/NJets/ETH_OppositeFlavor");
2152    
# Line 1607 | Line 2156 | void ProduceMCSystematicPlots() {
2156    cout << "Keeping OSSF cut " << (const char*)cutOSSF << endl;
2157    cutWeight="1.0";
2158    
2159 <  QuickProduceMCSystematicPlot("genMET",20,0,200,"genMET [GeV]",cutOSSF&&TCut("mll>20&&mll<70"),"MCSystPlots/genMET/ETH_SameFlavor_INCLUSIVE__NOPURW");
2160 <  QuickProduceMCSystematicPlot("genMET",20,0,200,"genMET [GeV]",cutOSOF&&TCut("mll>20&&mll<70"),"MCSystPlots/genMET/ETH_OppositeFlavor_INCLUSIVE__NOPURW");  
2161 <  QuickProduceMCSystematicPlot("genMET",20,0,200,"genMET [GeV]",cutOSSF&&TCut("mll>120"),"MCSystPlots/genMET/ETH_SameFlavor_INCLUSIVE_HighMass__NOPURW");
2162 <  QuickProduceMCSystematicPlot("genMET",20,0,200,"genMET [GeV]",cutOSOF&&TCut("mll>120"),"MCSystPlots/genMET/ETH_OppositeFlavor_INCLUSIVE_HighMass__NOPURW");  
2163 <  
2164 <  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PFMET [GeV]",cutOSSF&&TCut("mll>20&&mll<70"),"MCSystPlots/MET/ETH_SameFlavor_INCLUSIVE__NOPURW");
2165 <  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PFMET [GeV]",cutOSOF&&TCut("mll>20&&mll<70"),"MCSystPlots/MET/ETH_OppositeFlavor_INCLUSIVE__NOPURW");
2166 <  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PFMET [GeV]",cutOSSF&&TCut("mll>120"),"MCSystPlots/MET/ETH_SameFlavor_INCLUSIVE_HighMass__NOPURW");
2167 <  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PFMET [GeV]",cutOSOF&&TCut("mll>120"),"MCSystPlots/MET/ETH_OppositeFlavor_INCLUSIVE_HighMass__NOPURW");
2159 >  QuickProduceMCSystematicPlot("genMET",20,0,200,"gen#slash{E}_{T} [GeV]",cutOSSF&&TCut("mll>20&&mll<70"),"MCSystPlots/genMET/ETH_SameFlavor_INCLUSIVE__NOPURW");
2160 >  QuickProduceMCSystematicPlot("genMET",20,0,200,"gen#slash{E}_{T} [GeV]",cutOSOF&&TCut("mll>20&&mll<70"),"MCSystPlots/genMET/ETH_OppositeFlavor_INCLUSIVE__NOPURW");  
2161 >  QuickProduceMCSystematicPlot("genMET",20,0,200,"gen#slash{E}_{T} [GeV]",cutOSSF&&TCut("mll>120"),"MCSystPlots/genMET/ETH_SameFlavor_INCLUSIVE_HighMass__NOPURW");
2162 >  QuickProduceMCSystematicPlot("genMET",20,0,200,"gen#slash{E}_{T} [GeV]",cutOSOF&&TCut("mll>120"),"MCSystPlots/genMET/ETH_OppositeFlavor_INCLUSIVE_HighMass__NOPURW");  
2163 >  
2164 >  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PF#slash{E}_{T} [GeV]",cutOSSF&&TCut("mll>20&&mll<70"),"MCSystPlots/MET/ETH_SameFlavor_INCLUSIVE__NOPURW");
2165 >  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PF#slash{E}_{T} [GeV]",cutOSOF&&TCut("mll>20&&mll<70"),"MCSystPlots/MET/ETH_OppositeFlavor_INCLUSIVE__NOPURW");
2166 >  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PF#slash{E}_{T} [GeV]",cutOSSF&&TCut("mll>120"),"MCSystPlots/MET/ETH_SameFlavor_INCLUSIVE_HighMass__NOPURW");
2167 >  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PF#slash{E}_{T} [GeV]",cutOSOF&&TCut("mll>120"),"MCSystPlots/MET/ETH_OppositeFlavor_INCLUSIVE_HighMass__NOPURW");
2168    
2169    
2170    // --------------------------------------    ***** AACHEN *****      --------------------------------------    
2171    
2172 <  
2172 >  /*
2173    cutWeight=cutweightBKP;
2174    TCut essentialcutBKP = essentialcut;
2175    cout << (const char*) essentialcut << endl;
# Line 1635 | Line 2184 | void ProduceMCSystematicPlots() {
2184    cutnJets = TCut((ReplaceAll((const char*)cutnJets,"abs(eta2)<1.4","abs(eta2)<2.4")).c_str());
2185    cutnJets = TCut((ReplaceAll((const char*)cutnJets,"abs(eta1)<1.4","abs(eta1)<2.4")).c_str());
2186    
2187 <  QuickProduceMCSystematicPlot("genMET",20,0,200,"genMET [GeV]",cutOSSF&&cutnJets&&TCut("mll>20&&mll<70"),"MCSystPlots/genMET/Aachen_SameFlavor");
2188 <  QuickProduceMCSystematicPlot("genMET",20,0,200,"genMET [GeV]",cutOSOF&&cutnJets&&TCut("mll>20&&mll<70"),"MCSystPlots/genMET/Aachen_OppositeFlavor");  
2189 <  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PFMET [GeV]",cutOSSF&&cutnJets&&TCut("mll>20&&mll<70"),"MCSystPlots/MET/Aachen_SameFlavor");
2190 <  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PFMET [GeV]",cutOSOF&&cutnJets&&TCut("mll>20&&mll<70"),"MCSystPlots/MET/Aachen_OppositeFlavor");
2191 <  
2192 <  QuickProduceMCSystematicPlot("genMET",20,0,200,"genMET [GeV]",cutOSSF&&TCut("mll>20&&mll<70"),"MCSystPlots/genMET/Aachen_SameFlavor_INCLUSIVE");
2193 <  QuickProduceMCSystematicPlot("genMET",20,0,200,"genMET [GeV]",cutOSOF&&TCut("mll>20&&mll<70"),"MCSystPlots/genMET/Aachen_OppositeFlavor_INCLUSIVE");  
2194 <  QuickProduceMCSystematicPlot("genMET",20,0,200,"genMET [GeV]",cutOSSF&&TCut("mll>120"),"MCSystPlots/genMET/Aachen_SameFlavor_INCLUSIVE_HighMass");
2195 <  QuickProduceMCSystematicPlot("genMET",20,0,200,"genMET [GeV]",cutOSOF&&TCut("mll>120"),"MCSystPlots/genMET/Aachen_OppositeFlavor_INCLUSIVE_HighMass");  
2196 <  
2197 <  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PFMET [GeV]",cutOSSF&&TCut("mll>20&&mll<70"),"MCSystPlots/MET/Aachen_SameFlavor_INCLUSIVE");
2198 <  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PFMET [GeV]",cutOSOF&&TCut("mll>20&&mll<70"),"MCSystPlots/MET/Aachen_OppositeFlavor_INCLUSIVE");
2199 <  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PFMET [GeV]",cutOSSF&&TCut("mll>120"),"MCSystPlots/MET/Aachen_SameFlavor_INCLUSIVE_HighMass");
2200 <  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PFMET [GeV]",cutOSOF&&TCut("mll>120"),"MCSystPlots/MET/Aachen_OppositeFlavor_INCLUSIVE_HighMass");
2187 >  QuickProduceMCSystematicPlot("genMET",20,0,200,"gen#slash{E}_{T} [GeV]",cutOSSF&&cutnJets&&TCut("mll>20&&mll<70"),"MCSystPlots/genMET/Aachen_SameFlavor");
2188 >  QuickProduceMCSystematicPlot("genMET",20,0,200,"gen#slash{E}_{T} [GeV]",cutOSOF&&cutnJets&&TCut("mll>20&&mll<70"),"MCSystPlots/genMET/Aachen_OppositeFlavor");  
2189 >  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PF#slash{E}_{T} [GeV]",cutOSSF&&cutnJets&&TCut("mll>20&&mll<70"),"MCSystPlots/MET/Aachen_SameFlavor");
2190 >  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PF#slash{E}_{T} [GeV]",cutOSOF&&cutnJets&&TCut("mll>20&&mll<70"),"MCSystPlots/MET/Aachen_OppositeFlavor");
2191 >  
2192 >  QuickProduceMCSystematicPlot("genMET",20,0,200,"gen#slash{E}_{T} [GeV]",cutOSSF&&TCut("mll>20&&mll<70"),"MCSystPlots/genMET/Aachen_SameFlavor_INCLUSIVE");
2193 >  QuickProduceMCSystematicPlot("genMET",20,0,200,"gen#slash{E}_{T} [GeV]",cutOSOF&&TCut("mll>20&&mll<70"),"MCSystPlots/genMET/Aachen_OppositeFlavor_INCLUSIVE");  
2194 >  QuickProduceMCSystematicPlot("genMET",20,0,200,"gen#slash{E}_{T} [GeV]",cutOSSF&&TCut("mll>120"),"MCSystPlots/genMET/Aachen_SameFlavor_INCLUSIVE_HighMass");
2195 >  QuickProduceMCSystematicPlot("genMET",20,0,200,"gen#slash{E}_{T} [GeV]",cutOSOF&&TCut("mll>120"),"MCSystPlots/genMET/Aachen_OppositeFlavor_INCLUSIVE_HighMass");  
2196 >  
2197 >  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PF#slash{E}_{T} [GeV]",cutOSSF&&TCut("mll>20&&mll<70"),"MCSystPlots/MET/Aachen_SameFlavor_INCLUSIVE");
2198 >  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PF#slash{E}_{T} [GeV]",cutOSOF&&TCut("mll>20&&mll<70"),"MCSystPlots/MET/Aachen_OppositeFlavor_INCLUSIVE");
2199 >  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PF#slash{E}_{T} [GeV]",cutOSSF&&TCut("mll>120"),"MCSystPlots/MET/Aachen_SameFlavor_INCLUSIVE_HighMass");
2200 >  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PF#slash{E}_{T} [GeV]",cutOSOF&&TCut("mll>120"),"MCSystPlots/MET/Aachen_OppositeFlavor_INCLUSIVE_HighMass");
2201    QuickProduceMCSystematicPlot("pfJetGoodNum40",8,-0.5,7.5,"NJets",cutOSSF&&cutnJets&&TCut("mll>20&&mll<70&&met[4]>100"),"MCSystPlots/NJets/Aachen_SameFlavor");
2202    QuickProduceMCSystematicPlot("pfJetGoodNum40",8,-0.5,7.5,"NJets",cutOSOF&&cutnJets&&TCut("mll>20&&mll<70&&met[4]>100"),"MCSystPlots/NJets/Aachen_OppositeFlavor");
2203    
# Line 1658 | Line 2207 | void ProduceMCSystematicPlots() {
2207    cout << "Keeping OSSF cut " << (const char*)cutOSSF << endl;
2208    cutWeight="1.0";
2209    
2210 <  QuickProduceMCSystematicPlot("genMET",20,0,200,"genMET [GeV]",cutOSSF&&TCut("mll>20&&mll<70"),"MCSystPlots/genMET/Aachen_SameFlavor_INCLUSIVE__NOPURW");
2211 <  QuickProduceMCSystematicPlot("genMET",20,0,200,"genMET [GeV]",cutOSOF&&TCut("mll>20&&mll<70"),"MCSystPlots/genMET/Aachen_OppositeFlavor_INCLUSIVE__NOPURW");  
2212 <  QuickProduceMCSystematicPlot("genMET",20,0,200,"genMET [GeV]",cutOSSF&&TCut("mll>120"),"MCSystPlots/genMET/Aachen_SameFlavor_INCLUSIVE_HighMass__NOPURW");
2213 <  QuickProduceMCSystematicPlot("genMET",20,0,200,"genMET [GeV]",cutOSOF&&TCut("mll>120"),"MCSystPlots/genMET/Aachen_OppositeFlavor_INCLUSIVE_HighMass__NOPURW");  
2214 <  
2215 <  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PFMET [GeV]",cutOSSF&&TCut("mll>20&&mll<70"),"MCSystPlots/MET/Aachen_SameFlavor_INCLUSIVE__NOPURW");
2216 <  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PFMET [GeV]",cutOSOF&&TCut("mll>20&&mll<70"),"MCSystPlots/MET/Aachen_OppositeFlavor_INCLUSIVE__NOPURW");
2217 <  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PFMET [GeV]",cutOSSF&&TCut("mll>120"),"MCSystPlots/MET/Aachen_SameFlavor_INCLUSIVE_HighMass__NOPURW");
2218 <  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PFMET [GeV]",cutOSOF&&TCut("mll>120"),"MCSystPlots/MET/Aachen_OppositeFlavor_INCLUSIVE_HighMass__NOPURW");
2210 >  QuickProduceMCSystematicPlot("genMET",20,0,200,"gen#slash{E}_{T} [GeV]",cutOSSF&&TCut("mll>20&&mll<70"),"MCSystPlots/genMET/Aachen_SameFlavor_INCLUSIVE__NOPURW");
2211 >  QuickProduceMCSystematicPlot("genMET",20,0,200,"gen#slash{E}_{T} [GeV]",cutOSOF&&TCut("mll>20&&mll<70"),"MCSystPlots/genMET/Aachen_OppositeFlavor_INCLUSIVE__NOPURW");  
2212 >  QuickProduceMCSystematicPlot("genMET",20,0,200,"gen#slash{E}_{T} [GeV]",cutOSSF&&TCut("mll>120"),"MCSystPlots/genMET/Aachen_SameFlavor_INCLUSIVE_HighMass__NOPURW");
2213 >  QuickProduceMCSystematicPlot("genMET",20,0,200,"gen#slash{E}_{T} [GeV]",cutOSOF&&TCut("mll>120"),"MCSystPlots/genMET/Aachen_OppositeFlavor_INCLUSIVE_HighMass__NOPURW");  
2214 >  
2215 >  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PF#slash{E}_{T} [GeV]",cutOSSF&&TCut("mll>20&&mll<70"),"MCSystPlots/MET/Aachen_SameFlavor_INCLUSIVE__NOPURW");
2216 >  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PF#slash{E}_{T} [GeV]",cutOSOF&&TCut("mll>20&&mll<70"),"MCSystPlots/MET/Aachen_OppositeFlavor_INCLUSIVE__NOPURW");
2217 >  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PF#slash{E}_{T} [GeV]",cutOSSF&&TCut("mll>120"),"MCSystPlots/MET/Aachen_SameFlavor_INCLUSIVE_HighMass__NOPURW");
2218 >  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PF#slash{E}_{T} [GeV]",cutOSOF&&TCut("mll>120"),"MCSystPlots/MET/Aachen_OppositeFlavor_INCLUSIVE_HighMass__NOPURW");
2219    
2220    cutnJets  = cutnJetsBKP;
2221    cutWeight = cutweightBKP;
2222    essentialcut = essentialcutBKP;
2223 <  
2223 >  */
2224    write_error(__FUNCTION__,"Still need to add systematic shape");assert(0);
2225   }
2226  
# Line 1750 | Line 2299 | void TauQuestion() {
2299    MakeTauPlot("b-tag veto, 50<MET<100",TCut("pfJetGoodNumBtag30==0&&met[4]>50&&met[4]<100"),"TauQ/ControlPlots",false);
2300   }
2301  
2302 + void ProduceOFSFPlots(string mcjzb, string datajzb, bool isAachen) {
2303 +  string BaseMetCut="met[4]>100";
2304 +  string Prefix="ETH/";
2305 +  if(isAachen) {
2306 +    BaseMetCut="met[4]>150";
2307 +    Prefix="Aachen/";
2308 +  }
2309 +  
2310 + //       make_OFSF_plots("met[4]",  BaseMetCut, 30, 100., 400., true, "E_{T}^{miss}", Prefix+"MET",1500);
2311 + //      make_OFSF_plots("pfJetGoodNumBtag30", BaseMetCut, 6, -0.5, 5.5, true, "N_{b-jets}", Prefix+"nbjets",5000);
2312 +      make_OFSF_plots("max(eta1,eta2)", BaseMetCut, 20, -2.4, 2.4, true, "max(#eta_{l1},#eta_{l2})", Prefix+"MaxEta",-1);
2313 + //       make_OFSF_plots("st", BaseMetCut, 20, 0, 2000., false, "#tilde{S}_{T}", Prefix+"FrankT",120);
2314 + //       make_OFSF_plots("pt1+pt2+met[4]+Sum$(pfJetGoodPt)", BaseMetCut, 20, 0, 2000., false, "#tilde{S}_{T}", Prefix+"POOR_FrankT",120);
2315 +      
2316 +      
2317 + //       make_OFSF_plots("mt2j", BaseMetCut, 35, 0, 700., false, "M_{T2J}", Prefix+"MT2J");
2318 + //
2319 + //       make_OFSF_plots("ml1b", BaseMetCut, 20, 0, 800., false, "m_{l_{1}b}", Prefix+"ML1B");
2320 + //       make_OFSF_plots("ml2b", BaseMetCut, 20, 0, 400., false, "m_{l_{2}b}", Prefix+"ML2B");
2321 + //       make_OFSF_plots("min(ml1b,ml2b)", BaseMetCut, 20, 0, 400., false, "m_{lb}", Prefix+"MLB");
2322 + //  
2323 + //       make_OFSF_plots(datajzb, BaseMetCut, 55, -100, 450., false, "JZB", Prefix+"JZB_In_Signal_Region");
2324 + //       make_OFSF_plots("mt2", BaseMetCut, 15, 0, 150., false, "M_{T2}", Prefix+"MT2");
2325 + //       make_OFSF_plots("d2", BaseMetCut, 20, 0, 200., true, "D2", Prefix+"D2");
2326 +       make_OFSF_plots("pfJetGoodNum40", BaseMetCut, 10, -0.5, 9.5, true, "N_{jets}", Prefix+"nJets");
2327 + //      
2328 + //       make_OFSF_plots("mll", BaseMetCut, 60, 20., 320., false, "m_{ll}", Prefix+"mll");
2329 + //       make_OFSF_plots("leptonNum", BaseMetCut, 3, 2, 5., false, "N(leptons)", Prefix+"NLeptons");
2330 + //
2331 + //       make_OFSF_plots("pfJetGoodNum40", BaseMetCut,                        7, 3, 10, true, "#(jets)", Prefix+"njets");
2332 + //       make_OFSF_plots("pfJetGoodNum40", BaseMetCut+"&&pfJetGoodNumBtag30==0", 7, 3, 10, true, "#(jets)", Prefix+"njets_btagVeto");
2333 + //       make_OFSF_plots("pfJetGoodNum40", BaseMetCut"&&pfJetGoodNumBtag30>0",  7, 3, 10, true, "#(jets)", Prefix+"njets_AtLeastOneBJet30");
2334 + //
2335 + //       make_OFSF_plots("pfJetGoodPtBtag[0]", BaseMetCut+"&&pfJetGoodNumBtag30>0", 20, 0, 400, true, "p_{T}(leading b-jet)", Prefix+"ptb1");
2336 +       make_OFSF_plots("pfJetGoodPt",  BaseMetCut, 30, 0., 400., true, "p_{T}^{J}", Prefix+"ptJet");
2337 + //
2338 + //       make_OFSF_plots("iso1", BaseMetCut, 20, 0, 0.3, true, "lepton 1 isolation", Prefix+"iso1");
2339 + //       make_OFSF_plots("iso2", BaseMetCut, 20, 0, 0.3, true, "lepton 2 isolation", Prefix+"iso2");
2340 +       make_OFSF_plots("pt",  BaseMetCut, 30, 0., 300., true, "p_{ll}", Prefix+"pt");
2341 +       make_OFSF_plots("pt1",  BaseMetCut, 30, 0., 300., true, "p_{T,1}", Prefix+"pt1");
2342 +       make_OFSF_plots("pt2",  BaseMetCut, 22, 0., 220., true, "p_{T,2}", Prefix+"pt2");
2343 + //       make_OFSF_plots("eta1", BaseMetCut, 10, -2.5, 2.5, false, "#eta_{1}", Prefix+"eta1", -1, 0.15);
2344 + //      make_OFSF_plots("eta2", BaseMetCut, 10, -2.5, 2.5, false, "#eta_{2}", Prefix+"eta2", -1, 0.15);
2345 + //      make_OFSF_plots("phi1", BaseMetCut, 10, -TMath::Pi(), TMath::Pi(), false, "#phi_{1}", Prefix+"phi1", -1, 0.2);
2346 + //      make_OFSF_plots("phi2", BaseMetCut, 10, -TMath::Pi(), TMath::Pi(), false, "#phi_{2}", Prefix+"phi2", -1, 0.2);
2347 + //      make_OFSF_plots("pfJetGoodPt[0]/pfJetGoodPt[1]", BaseMetCut, 20, 1, 10, true, "pt_{j}^{1}/pt_{j}^{2}", Prefix+"jpt1pt2", -1, 0.2);
2348 +      make_OFSF_plots("TMath::Abs(pfJetDphiMet[0])", BaseMetCut, 16, 0, 3.2, false, "|#Delta#phi(jet1,MET)|", Prefix+"dphij1met", -1, 0.2);
2349 +    
2350 + //      make_OFSF_plots("TMath::Abs(dphi)", BaseMetCut, 16, 0, 3.2, false, "|#Delta#phi(l1,l2)|", Prefix+"dphi", -1, 0.2);
2351 + //      make_OFSF_plots("TMath::Abs(dphiMet1)", BaseMetCut, 16, 0, 3.2, false, "|#Delta#phi(l1,MET)|", Prefix+"dphiMet1", -1, 0.2);
2352 + //      make_OFSF_plots("TMath::Abs(dphiMet2)", BaseMetCut, 16, 0, 3.2, false, "|#Delta#phi(l2,MET)|", Prefix+"dphiMet2", -1, 0.2);
2353 + //      make_OFSF_plots("TMath::Min(TMath::Abs(dphiMet1), TMath::Abs(dphiMet2))", BaseMetCut, 16, 0, 3.2, false, "Min(|#Delta#phi(l,MET)|)", Prefix+"dphilc");
2354 + //      make_OFSF_plots("TMath::Min(TMath::Abs(pfJetDphiMet[0]), TMath::Min(TMath::Abs(pfJetDphiMet[1]), TMath::Abs(pfJetDphiMet[2])))", BaseMetCut, 16, 0, 3.2, false, "Min(|#Delta#phi(jet,MET)|)", Prefix+"dphijc");
2355 + //      make_OFSF_plots("TMath::Min((TMath::Pi()-TMath::Abs(dphiMet1)), (TMath::Pi() - TMath::Abs(dphiMet2)))", BaseMetCut, 16, 0, 3.2, false, "Min(#pi - |#Delta#phi(l,MET)|)", Prefix+"dphilco");
2356 + //      make_OFSF_plots("TMath::Min((TMath::Pi()-TMath::Abs(pfJetDphiMet[0])), TMath::Min( (TMath::Pi()-TMath::Abs(pfJetDphiMet[1])), (TMath::Pi() - TMath::Abs(pfJetDphiMet[2]))))", BaseMetCut, 16, 0, 3.2, false, "Min(#pi - |#Delta#phi(jet,MET)|)", Prefix+"dphijco");
2357 +      
2358 + }
2359 +
2360 + void ProduceOFSFPlots(string mcjzb, string datajzb) {
2361 +  
2362 +  
2363 +  //FIRST : ETH SELECTION
2364 +  ProduceOFSFPlots(mcjzb,datajzb,0); // this is the ETH selection
2365 +  
2366 +  string backup_cutnJets = (const char*)cutnJets;
2367 +  cutnJets = ReplaceInCut(cutnJets,"pfJetGoodNum40>=3","pfJetGoodNum40>=2");
2368 +  cutnJets = ReplaceInCut(cutnJets,"1.4","2.4");
2369 +  
2370 +  string backup_basiccut = (const char*)basiccut;
2371 +  basiccut = ReplaceInCut(basiccut,"1.4","2.4");
2372 +  
2373 +  string backup_essential = (const char*) essentialcut;
2374 +  essentialcut = ReplaceInCut(essentialcut,"1.4","2.4");
2375 +  
2376 +  ProduceOFSFPlots(mcjzb,datajzb,1); // this is the Aachen selection
2377 +  
2378 +  cutnJets     = TCut(backup_cutnJets.c_str());
2379 +  basiccut     = TCut(backup_basiccut.c_str());
2380 +  essentialcut = TCut(backup_essential.c_str());
2381 + }
2382 +  
2383 +
2384   void do_kinematic_plots(string mcjzb, string datajzb, bool doPF=false)
2385   {
2386   //  switch_overunderflow(true);
# Line 1757 | Line 2388 | void do_kinematic_plots(string mcjzb, st
2388    bool nolog=false;
2389  
2390    bool doOFSF = false;
2391 <  bool doKin  = true;
2391 >  bool doKin  = false;
2392    bool doDataComp = false;
2393    bool MakeTwoThreeJetComparison = false;
2394    
# Line 1776 | Line 2407 | void do_kinematic_plots(string mcjzb, st
2407  
2408    //ProduceJanPlots();
2409    //ProduceMCSystematicPlots();
2410 +  //assert(0);
2411   //  make_plain_kin_plot("pt",Cut2Str(cutOSSF&&TCut("mll>20&&pfJetGoodNumBtag30>=2")),40,0,200,nolog,"Z p_{T}","PlotForKostas",doPF,true);
2412    
2413 <  if ( doOFSF ) {
1782 <     make_OFSF_plots("mll", "met[4]>100", 60, 20., 320., false, "m_{ll}", "mll");
1783 <     make_OFSF_plots("met[4]", "met[4]>100", 30, 100., 400., false, "PFMET", "met");
1784 <     make_OFSF_plots("leptonNum", "met[4]>100", 3, 2, 5., false, "N(leptons)", "NLeptons");
1785 <
1786 <     make_OFSF_plots("pfJetGoodNum40", "met[4]>100",                        7, 3, 10, true, "#(jets)", "njets");
1787 <     make_OFSF_plots("pfJetGoodNum40", "met[4]>100&&pfJetGoodNumBtag30==0", 7, 3, 10, true, "#(jets)", "njets_btagVeto");
1788 <     make_OFSF_plots("pfJetGoodNum40", "met[4]>100&&pfJetGoodNumBtag30>0",  7, 3, 10, true, "#(jets)", "njets_AtLeastOneBJet30");
1789 <
1790 <     make_OFSF_plots("pfJetGoodNumBtag30", "met[4]>100", 5, 0, 5, true, "#(b-jets)", "nbjets");
1791 <     make_OFSF_plots("pfJetGoodPtBtag[0]", "met[4]>100&&pfJetGoodNumBtag30>0", 20, 0, 400, true, "p_{T}(leading b-jet)", "ptb1");
1792 <
1793 <     make_OFSF_plots("iso1", "met[4]>100", 20, 0, 0.3, true, "lepton 1 isolation", "iso1");
1794 <     make_OFSF_plots("iso2", "met[4]>100", 20, 0, 0.3, true, "lepton 2 isolation", "iso2");
1795 <     make_OFSF_plots("pt1",  "met[4]>100", 30, 0., 300., true, "p_{T,1}", "pt1");
1796 <     make_OFSF_plots("pt2",  "met[4]>100", 22, 0., 220., true, "p_{T,2}", "pt2");
1797 <     make_OFSF_plots("eta1", "met[4]>100", 10, -2.5, 2.5, false, "#eta_{1}", "eta1", 0.15);
1798 <     make_OFSF_plots("eta2", "met[4]>100", 10, -2.5, 2.5, false, "#eta_{2}", "eta2", 0.15);
1799 <     make_OFSF_plots("phi1", "met[4]>100", 10, -TMath::Pi(), TMath::Pi(), false, "#phi_{1}", "phi1", 0.2);
1800 <     make_OFSF_plots("phi2", "met[4]>100", 10, -TMath::Pi(), TMath::Pi(), false, "#phi_{2}", "phi2", 0.2);
1801 <     make_OFSF_plots("pfJetGoodPt[0]/pfJetGoodPt[1]", "met[4]>100", 20, 1, 10, true, "pt_{j}^{1}/pt_{j}^{2}", "jpt1pt2", 0.2);
1802 <     make_OFSF_plots("TMath::Abs(pfJetDphiMet[0])", "met[4]>100", 16, 0, 3.2, false, "|#Delta#phi(jet1,MET)|", "dphij1met", 0.2);
1803 <    make_OFSF_plots("TMath::Abs(dphi)", "met[4]>100", 16, 0, 3.2, false, "|#Delta#phi(l1,l2)|", "dphi", 0.2);
1804 <    make_OFSF_plots("TMath::Abs(dphiMet1)", "met[4]>100", 16, 0, 3.2, false, "|#Delta#phi(l1,MET)|", "dphiMet1", 0.2);
1805 <    make_OFSF_plots("TMath::Abs(dphiMet2)", "met[4]>100", 16, 0, 3.2, false, "|#Delta#phi(l2,MET)|", "dphiMet2", 0.2);
1806 <    make_OFSF_plots("TMath::Min(TMath::Abs(dphiMet1), TMath::Abs(dphiMet2))", "met[4]>100", 16, 0, 3.2, false, "Min(|#Delta#phi(l,MET)|)", "dphilc");
1807 <    make_OFSF_plots("TMath::Min(TMath::Abs(pfJetDphiMet[0]), TMath::Min(TMath::Abs(pfJetDphiMet[1]), TMath::Abs(pfJetDphiMet[2])))", "met[4]>100", 16, 0, 3.2, false, "Min(|#Delta#phi(jet,MET)|)", "dphijc");
1808 <    make_OFSF_plots("TMath::Min((TMath::Pi()-TMath::Abs(dphiMet1)), (TMath::Pi() - TMath::Abs(dphiMet2)))", "met[4]>100", 16, 0, 3.2, false, "Min(#pi - |#Delta#phi(l,MET)|)", "dphilco");
1809 <    make_OFSF_plots("TMath::Min((TMath::Pi()-TMath::Abs(pfJetDphiMet[0])), TMath::Min( (TMath::Pi()-TMath::Abs(pfJetDphiMet[1])), (TMath::Pi() - TMath::Abs(pfJetDphiMet[2]))))", "met[4]>100", 16, 0, 3.2, false, "Min(#pi - |#Delta#phi(jet,MET)|)", "dphijco");
1810 <  }
2413 >  if ( doOFSF ) ProduceOFSFPlots(mcjzb,datajzb);
2414  
2415    if ( doDataComp) {
2416      TCut mllCut("");
# Line 1901 | Line 2504 | void do_kinematic_plots(string mcjzb, st
2504  
2505    if ( doKin ) {
2506      string mllCut("");
2507 +    /*
2508 +    make_plain_kin_plot("mll",Cut2Str(cutOSSF&&TCut("mll>20")),56,20,300,dolog,"m_{ll}","NoPreselection/mll_SF",doPF,true);
2509 +    make_plain_kin_plot("mll",Cut2Str(cutOSOF&&TCut("mll>20")),56,20,300,dolog,"m_{ll}","NoPreselection/mll_OF",doPF,true);
2510 +
2511 +    make_plain_kin_plot("met[4]",Cut2Str(cutOSSF&&TCut("mll>20")),80,0,400,dolog,"E_{T}^{miss}","NoPreselection/met_SF",doPF,true);
2512 +    make_plain_kin_plot("met[4]",Cut2Str(cutOSOF&&TCut("mll>20")),80,0,400,dolog,"E_{T}^{miss}","NoPreselection/met_OF",doPF,true);
2513 +
2514 +    make_plain_kin_plot("pfTightHT",Cut2Str(cutOSSF&&TCut("mll>20")),20,0,800,dolog,"H_{T}","NoPreselection/HT_SF",doPF,true);
2515 +    make_plain_kin_plot("pfTightHT",Cut2Str(cutOSOF&&TCut("mll>20")),20,0,800,dolog,"H_{T}","NoPreselection/HT_OF",doPF,true);
2516 +    
2517 +    make_plain_kin_plot("pfJetGoodNum40",Cut2Str(cutOSSF&&TCut("mll>20")),10,-0.5,9.5,dolog,"n_{jets}","NoPreselection/NJets_SF",doPF,true);
2518 +    make_plain_kin_plot("pfJetGoodNum40",Cut2Str(cutOSOF&&TCut("mll>20")),10,-0.5,9.5,dolog,"n_{jets}","NoPreselection/NJets_OF",doPF,true);
2519 +    
2520 +    make_plain_kin_plot("pfJetGoodNumBtag30",Cut2Str(cutOSSF&&TCut("mll>20")),10,-0.5,9.5,dolog,"n_{btags}","NoPreselection/NBTags_SF",doPF,true);
2521 +    make_plain_kin_plot("pfJetGoodNumBtag30",Cut2Str(cutOSOF&&TCut("mll>20")),10,-0.5,9.5,dolog,"n_{btags}","NoPreselection/NBTags_OF",doPF,true);
2522 +    
2523 +    make_plain_kin_plot("pt1",Cut2Str(cutOSSF&&TCut("mll>20")),80,0,400,dolog,"p_{T}^{1}","NoPreselection/Pt1_SF",doPF,true);
2524 +    make_plain_kin_plot("pt1",Cut2Str(cutOSOF&&TCut("mll>20")),80,0,400,dolog,"p_{T}^{1}","NoPreselection/Pt1_OF",doPF,true);
2525      
2526 +    make_plain_kin_plot("pt2",Cut2Str(cutOSSF&&TCut("mll>20")),80,0,400,dolog,"p_{T}^{2}","NoPreselection/Pt2_SF",doPF,true);
2527 +    make_plain_kin_plot("pt2",Cut2Str(cutOSOF&&TCut("mll>20")),80,0,400,dolog,"p_{T}^{2}","NoPreselection/Pt2_OF",doPF,true);
2528      
2529 +    
2530 +    assert(0);
2531 +    make_plain_kin_plot("mll",Cut2Str(cutOSSF&&TCut("mll>60&&mll<120")),60,60,120,dolog,"m_{ll}","TestingLuminosity_SF",doPF,true);
2532 +    make_plain_kin_plot("mll",Cut2Str(cutOSOF&&TCut("mll>60&&mll<120")),60,60,120,dolog,"m_{ll}","TestingLuminosity_OF",doPF,true);
2533    
2534      make_plain_kin_plot("met[4]",Cut2Str(cutOSOF&&TCut("mll>30&&mll<70&&pfJetGoodNum40==0")),40,0,400,dolog,"PFMET","Debunking/MET_OF_30to70_0j",doPF,true);
2535      make_plain_kin_plot("met[4]",Cut2Str(cutOSOF&&TCut("mll>30&&mll<70&&pfJetGoodNum40==1")),40,0,400,dolog,"PFMET","Debunking/MET_OF_30to70_1j",doPF,true);
# Line 1947 | Line 2574 | void do_kinematic_plots(string mcjzb, st
2574      make_kin_plot("pfJetGoodPt[0]/pfJetGoodPt[1]","",45,1,10,dolog,"pt_{j}^{1}/pt_{j}^{2}","j1j2ratio",doPF,true);
2575      make_kin_plot("TMath::Abs(pfJetDphiMet[0])","",32,0,3.2,nolog,"|#Delta#phi(jet1,MET)|","dphiJ1MET",doPF,true);
2576      // Plots in signal region
2577 <    make_kin_plot("met[4]","",70,0,350,dolog,"MET [GeV]","met",doPF,true);
2577 >    make_kin_plot("met[4]","",70,0,350,dolog,"#slash{E}_{T} [GeV]","met",doPF,true);
2578  
2579  
2580      make_kin_plot("MetFactor","",20,0,2,nolog,"MetFactor","MetFactor",doPF,true);
# Line 2050 | Line 2677 | void do_kinematic_plots(string mcjzb, st
2677      //make_kin_plot("mll","met[4]>150&&id1==0",(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ee} [GeV] (MET>150GeV)","mll_met150_ee",doPF,true);
2678      //make_kin_plot("mll","met[4]>150&&id1==1",(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{#mu#mu} [GeV] (MET>150GeV)","mll_met150_mm",doPF,true);*/
2679    }
2680 <    /*
2681 <   make_special_obs_pred_mll_plot(datajzb,mcjzb,0);
2682 <   make_special_obs_pred_mll_plot(datajzb,mcjzb,50);
2683 <   make_special_obs_pred_mll_plot(datajzb,mcjzb,80);
2684 <   make_special_obs_pred_mll_plot(datajzb,mcjzb,100);
2685 <   make_special_obs_pred_mll_plot(datajzb,mcjzb,150);
2686 <   make_special_obs_pred_mll_plot(datajzb,mcjzb,200);
2687 <   make_special_obs_pred_mll_plot(datajzb,mcjzb,250);
2688 <
2680 >    
2681 >   int jzbcuts[7]={0,50,80,100,150,200,250};
2682 >   int MCorData[2]={data,mc};
2683 >  
2684 >   for(int d=0;d<2;d++) {
2685 >     for(int j=0;j<7;j++) {
2686 >       make_special_obs_pred_mll_plot(datajzb,mcjzb,jzbcuts[j],5.0,MCorData[d]); // 5.0 is the binwidth
2687 >     }
2688 >   }
2689 >  
2690 > /*
2691     make_JES_plot(cutmass&&cutOSSF&&basiccut,"_ossf");
2692     make_JES_plot(cutmass&&cutOSOF&&basiccut,"_osof");
2693   */
# Line 2083 | Line 2712 | void make_comp_plot( string var, string
2712    }
2713    
2714    string sRegions[] = { "SFZP","OFZP","SFSB","OFSB" };
2715 +  if(!RestrictToMassPeak) {
2716 +    sRegions[0]="SF";
2717 +    sRegions[1]="OF";
2718 +  }
2719    TCut kRegions[] = { cutOSSF&&cutnJets&&cutmass,     cutOSOF&&cutnJets&&cutmass,
2720                        cutOSSF&&cutnJets&&sidebandcut, cutOSOF&&cutnJets&&sidebandcut };
2721    
# Line 2145 | Line 2778 | void region_comparison_plots(string mcjz
2778      make_comp_plot("TMath::Abs(pfJetDphiMet[0])","|#Delta#phi(jet1,MET)|","dphiJ1MET",jzbcut,mcjzb,datajzb,32,0,3.2,false,0,0,true);
2779  
2780      make_comp_plot("mll","m_{ll} [GeV]","mll",jzbcut,mcjzb,datajzb,56,mll_low,mll_high,false,0,16.);
2781 <    make_comp_plot("met[4]","pfMET [GeV]","pfmet",jzbcut,mcjzb,datajzb,18,0,360,false,0,16.);
2781 >    make_comp_plot("met[4]","E_{T}^{miss} [GeV]","pfmet",jzbcut,mcjzb,datajzb,18,0,360,false,0,16.);
2782      make_comp_plot("pfJetGoodNum40","#(jets)","njets",jzbcut,mcjzb,datajzb,10,0,10, false,0,35.);
2783      make_comp_plot("pfJetGoodNumBtag","#(b-jets)","nBjets",jzbcut,mcjzb,datajzb,10,0,10, false,0,35.);
2784      make_comp_plot("pt","Z p_{T} [GeV]","Zpt",jzbcut,mcjzb,datajzb,26,0,525,false,0.,21.);
# Line 2177 | Line 2810 | void signal_bg_comparison()
2810    
2811    float simulatedlumi=luminosity;//in pb please - adjust to your likings
2812    
2813 <  TH1F *JZBplotZJETs = allsamples.Draw("JZBplotZJETs",jzbvariablemc,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("/DY"));
2813 >  TH1F *JZBplotZJETs = allsamples.Draw("JZBplotZJETs",jzbvariablemc,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("DYJetsToLL"));
2814    TH1F *JZBplotLM4;
2815    if(PlottingSetup::RestrictToMassPeak) JZBplotLM4 = allsamples.Draw("JZBplotLM4",jzbvariablemc,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("LM4"));
2816    else JZBplotLM4 = allsamples.Draw("JZBplotLM4",jzbvariablemc,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("LM3"));
2817 <  TH1F *JZBplotTtbar = allsamples.Draw("JZBplotTtbar",jzbvariablemc,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("TTJets"));
2817 >  TH1F *JZBplotTtbar = allsamples.Draw("JZBplotTtbar",jzbvariablemc,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("TT_"));
2818    
2819    JZBplotTtbar->SetLineColor(allsamples.GetColor("TTJet"));
2820    JZBplotZJETs->SetFillColor(allsamples.GetColor("DY"));
# Line 2192 | Line 2825 | void signal_bg_comparison()
2825  
2826    JZBplotTtbar->SetMaximum(JZBplotZJETs->GetMaximum());
2827    JZBplotTtbar->SetMinimum(0.01);
2828 <  JZBplotTtbar->SetFillColor(allsamples.GetColor("TTJets"));
2828 >  JZBplotTtbar->SetFillColor(allsamples.GetColor("TT_"));
2829    JZBplotTtbar->DrawClone("histo");
2830    JZBplotZJETs->Draw("histo,same");
2831    JZBplotTtbar->SetFillColor(0);
2832    JZBplotTtbar->DrawClone("histo,same");
2833 <  JZBplotTtbar->SetFillColor(allsamples.GetColor("TTJets"));
2833 >  JZBplotTtbar->SetFillColor(allsamples.GetColor("TT_"));
2834    JZBplotLM4->Draw("histo,same");
2835  
2836  
# Line 2235 | Line 2868 | void signal_bg_comparison()
2868    // Draw all plots overlaid
2869    JZBplotTtbar->SetMaximum(JZBplotZJETs->GetMaximum());
2870    JZBplotTtbar->SetMinimum(0.01);
2871 <  JZBplotTtbar->SetFillColor(allsamples.GetColor("TTJets"));
2871 >  JZBplotTtbar->SetFillColor(allsamples.GetColor("TT_"));
2872    JZBplotTtbar->DrawClone("histo");
2873    JZBplotZJETs->Draw("histo,same");
2874    JZBplotTtbar->SetFillColor(0);
2875    JZBplotTtbar->DrawClone("histo,same");
2876 <  JZBplotTtbar->SetFillColor(allsamples.GetColor("TTJets"));
2876 >  JZBplotTtbar->SetFillColor(allsamples.GetColor("TT_"));
2877  
2878    JZBplotSMS1->SetLineColor(kRed+1);
2879    JZBplotSMS2->SetLineColor(kBlue+1);
# Line 2447 | Line 3080 | if you want to start from scratch (witho
3080    return return_functions;
3081   }
3082  
3083 < void do_prediction_plot(string jzb, TCanvas *globalcanvas, float high, int use_data, bool overlay_signal = false,string subdir="" )
3083 > void do_prediction_plot(TCut addcut, string Cname, string jzb, TCanvas *globalcanvas, float high, int use_data, bool overlay_signal = false,string subdir="" )
3084   {
3085    
3086    bool is_data=false;
# Line 2468 | Line 3101 | void do_prediction_plot(string jzb, TCan
3101    
3102    
3103    TH1F *blankback = new TH1F("blankback","blankback",int(high/10),0,high);
3104 <  TH1F *RcorrJZBeemm   = allsamples.Draw("RcorrJZBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutpositive&&cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
3105 <  TH1F *LcorrJZBeemm   = allsamples.Draw("LcorrJZBeemm",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutnegative&&cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
3106 <  TH1F *RcorrJZBem     = allsamples.Draw("RcorrJZBem",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutpositive&&cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
3107 <  TH1F *LcorrJZBem     = allsamples.Draw("LcorrJZBem",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutnegative&&cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
3104 >  TH1F *RcorrJZBeemm   = allsamples.Draw("RcorrJZBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", addcut&&cutpositive&&cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
3105 >  TH1F *LcorrJZBeemm   = allsamples.Draw("LcorrJZBeemm",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", addcut&&cutnegative&&cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
3106 >  TH1F *RcorrJZBem     = allsamples.Draw("RcorrJZBem",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", addcut&&cutpositive&&cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
3107 >  TH1F *LcorrJZBem     = allsamples.Draw("LcorrJZBem",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", addcut&&cutnegative&&cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
3108  
3109    blankback->GetXaxis()->SetTitle(RcorrJZBeemm->GetXaxis()->GetTitle());
3110    blankback->GetYaxis()->SetTitle(RcorrJZBeemm->GetYaxis()->GetTitle());
# Line 2487 | Line 3120 | void do_prediction_plot(string jzb, TCan
3120    TH1F *RcorrJZBeemmNoS;
3121  
3122    //these are for the ratio
3123 <  TH1F *JRcorrJZBeemm   = allsamples.Draw("JRcorrJZBeemm",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutpositive&&cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
3124 <  TH1F *JLcorrJZBeemm   = allsamples.Draw("JLcorrJZBeemm",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutnegative&&cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
3125 <  TH1F *JRcorrJZBem     = allsamples.Draw("JRcorrJZBem",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutpositive&&cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
3126 <  TH1F *JLcorrJZBem     = allsamples.Draw("JLcorrJZBem",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutnegative&&cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
3123 >  TH1F *JRcorrJZBeemm   = allsamples.Draw("JRcorrJZBeemm",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", addcut&&cutpositive&&cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
3124 >  TH1F *JLcorrJZBeemm   = allsamples.Draw("JLcorrJZBeemm",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", addcut&&cutnegative&&cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
3125 >  TH1F *JRcorrJZBem     = allsamples.Draw("JRcorrJZBem",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", addcut&&cutpositive&&cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
3126 >  TH1F *JLcorrJZBem     = allsamples.Draw("JLcorrJZBem",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", addcut&&cutnegative&&cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
3127    
3128    TH1F *JRcorrJZBSBem;
3129    TH1F *JLcorrJZBSBem;
3130    TH1F *JRcorrJZBSBeemm;
3131    TH1F *JLcorrJZBSBeemm;
3132    
3133 <  if(use_data==2 || overlay_signal) RcorrJZBeemmNoS = allsamples.Draw("RcorrJZBeemmNoS",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutpositive&&cutmass&&cutOSSF&&cutnJets,is_data, luminosity,false);
3133 >  if(use_data==2 || overlay_signal) RcorrJZBeemmNoS = allsamples.Draw("RcorrJZBeemmNoS",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", addcut&&cutpositive&&cutmass&&cutOSSF&&cutnJets,is_data, luminosity,false);
3134  
3135    
3136    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
3137 <    RcorrJZBSBem   = allsamples.Draw("RcorrJZBSBem",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutpositive&&sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
3138 <    LcorrJZBSBem   = allsamples.Draw("LcorrJZBSBem",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutnegative&&sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
3139 <    RcorrJZBSBeemm = allsamples.Draw("RcorrJZBSBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutpositive&&sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
3140 <    LcorrJZBSBeemm = allsamples.Draw("LcorrJZBSBeemm",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutnegative&&sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
3137 >    RcorrJZBSBem   = allsamples.Draw("RcorrJZBSBem",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", addcut&&cutpositive&&sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
3138 >    LcorrJZBSBem   = allsamples.Draw("LcorrJZBSBem",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", addcut&&cutnegative&&sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
3139 >    RcorrJZBSBeemm = allsamples.Draw("RcorrJZBSBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", addcut&&cutpositive&&sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
3140 >    LcorrJZBSBeemm = allsamples.Draw("LcorrJZBSBeemm",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", addcut&&cutnegative&&sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
3141      
3142      //these are for the ratio
3143 <    JRcorrJZBSBem   = allsamples.Draw("JRcorrJZBSBem",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutpositive&&sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
3144 <    JLcorrJZBSBem   = allsamples.Draw("JLcorrJZBSBem",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutnegative&&sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
3145 <    JRcorrJZBSBeemm = allsamples.Draw("JRcorrJZBSBeemm",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutpositive&&sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
3146 <    JLcorrJZBSBeemm = allsamples.Draw("JLcorrJZBSBeemm",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutnegative&&sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
3143 >    JRcorrJZBSBem   = allsamples.Draw("JRcorrJZBSBem",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", addcut&&cutpositive&&sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
3144 >    JLcorrJZBSBem   = allsamples.Draw("JLcorrJZBSBem",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", addcut&&cutnegative&&sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
3145 >    JRcorrJZBSBeemm = allsamples.Draw("JRcorrJZBSBeemm",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", addcut&&cutpositive&&sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
3146 >    JLcorrJZBSBeemm = allsamples.Draw("JLcorrJZBSBeemm",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", addcut&&cutnegative&&sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
3147    }
3148    
3149    TH1F *lm4RcorrJZBeemm;
3150 <  if(overlay_signal || use_data == 2 || use_data == 1) lm4RcorrJZBeemm = allsamples.Draw("lm4RcorrJZBSBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutpositive&&cutmass&&cutOSSF&&cutnJets,is_data, luminosity,allsamples.FindSample("LM"));
3150 >  if(overlay_signal || use_data == 2 || use_data == 1) lm4RcorrJZBeemm = allsamples.Draw("lm4RcorrJZBSBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", addcut&&cutpositive&&cutmass&&cutOSSF&&cutnJets,is_data, luminosity,allsamples.FindSample("LM"));
3151    
3152    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- prediction changed.
3153    
# Line 2651 | Line 3284 | void do_prediction_plot(string jzb, TCan
3284      
3285      jzbnegative->SetFillColor(allsamples.GetColor((allsamples.FindSample("DY"))[0]));
3286      jzbnegative->SetLineColor(allsamples.GetColor((allsamples.FindSample("DY"))[0]));
3287 <    sidebandsemu->SetLineColor(allsamples.GetColor((allsamples.FindSample("TTJets"))[0]));
3288 <    sidebandsemu->SetFillColor(allsamples.GetColor((allsamples.FindSample("TTJets"))[0]));
3287 >    sidebandsemu->SetLineColor(allsamples.GetColor((allsamples.FindSample("TT_"))[0]));
3288 >    sidebandsemu->SetFillColor(allsamples.GetColor((allsamples.FindSample("TT_"))[0]));
3289      
3290      THStack predcomposition("predcomposition","prediction composition");
3291      predcomposition.Add(sidebandsemu);
# Line 2678 | Line 3311 | void do_prediction_plot(string jzb, TCan
3311   //    speciallegBpred->AddEntry(lm4RcorrJZBeemmC,"LM4","l");
3312   //     speciallegBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
3313      speciallegBpred->Draw();
3314 <    Save_With_Ratio(JRcorrJZBeemm,JBpred,predcomppad,subdir+"Bpred_Data_____PredictionComposition",true,true,"data/pred",BpredSys);
3314 >    Save_With_Ratio(JRcorrJZBeemm,JBpred,predcomppad,subdir+"Bpred_Data_____PredictionComposition"+Cname,true,true,"data/pred",BpredSys);
3315      delete predcomppad;
3316      
3317      TCanvas *specialcanv = new TCanvas("specialcanv","specialcanv");
# Line 2745 | Line 3378 | void do_prediction_plot(string jzb, TCan
3378        
3379        RcorrJZBeemmNoS->SetLineStyle(2);
3380        legBpred2->AddEntry(RcorrJZBeemmNoS,"MC B","l");
3381 < //       legBpred2->AddEntry(lm4RcorrJZBeemm,"MC S","l");
3381 >      legBpred2->AddEntry(lm4RcorrJZBeemm,"MC S","l");
3382        legBpred2->Draw();
3383        RcorrJZBeemmNoS->SetLineColor(TColor::GetColor("#61210B"));
3384        RcorrJZBeemmNoS->Draw("histo,same");
# Line 2758 | Line 3391 | void do_prediction_plot(string jzb, TCan
3391    }
3392  
3393  
3394 +  Bpredsaveas+="_"+Cname+"_";
3395    //3rd last argument: do special bpred ratio, 2nd last argument: extended range!, last: y-axis title
3396    string ytitle("ratio");
3397    if ( use_data==1 ) ytitle = "data/pred";
# Line 2806 | Line 3440 | void do_prediction_plot(string jzb, TCan
3440      if(use_data==1)
3441      {
3442        legBpredc->AddEntry(RcorrJZBeemm,"observed","p");
3443 <      legBpredc->AddEntry(Bpredem,"OFZP","l");
3444 <      legBpredc->AddEntry(BpredSBem,"OFSB","l");
3445 <      legBpredc->AddEntry(BpredSBeemm,"SFSB","l");
3443 >      if(RestrictToMassPeak) {
3444 >        legBpredc->AddEntry(Bpredem,"OFZP","l");
3445 >        legBpredc->AddEntry(BpredSBem,"OFSB","l");
3446 >        legBpredc->AddEntry(BpredSBeemm,"SFSB","l");
3447 >      } else legBpredc->AddEntry(Bpredem,"OF","l");
3448 >        
3449 >        
3450        legBpredc->Draw();
3451        CompleteSave(globalcanvas,subdir+"Bpred_Data_comparison");
3452      }
3453      if(use_data==0) {
3454        legBpredc->AddEntry(RcorrJZBeemm,"MC true","p");
3455 <      legBpredc->AddEntry(Bpredem,"MC OFZP","l");
3456 <      legBpredc->AddEntry(BpredSBem,"MC OFSB","l");
3457 <      legBpredc->AddEntry(BpredSBeemm,"MC SFSB","l");
3455 >      if(RestrictToMassPeak) {
3456 >        legBpredc->AddEntry(Bpredem,"MC OFZP","l");
3457 >        legBpredc->AddEntry(BpredSBem,"MC OFSB","l");
3458 >        legBpredc->AddEntry(BpredSBeemm,"MC SFSB","l");
3459 >      } else legBpredc->AddEntry(Bpredem,"MC OF","l");
3460 >        
3461        legBpredc->Draw();
3462        CompleteSave(globalcanvas,subdir+"Bpred_MC_comparison");
3463      }
3464      if(use_data==2) {
3465        legBpredc->AddEntry(RcorrJZBeemm,"MC true","p");
3466 <      legBpredc->AddEntry(Bpredem,"MC OFZP","l");
3467 <      legBpredc->AddEntry(BpredSBem,"MC OFSB","l");
3468 <      legBpredc->AddEntry(BpredSBeemm,"MC SFSB","l");
3466 >      if(RestrictToMassPeak) {
3467 >        legBpredc->AddEntry(Bpredem,"MC OFZP","l");
3468 >        legBpredc->AddEntry(BpredSBem,"MC OFSB","l");
3469 >        legBpredc->AddEntry(BpredSBeemm,"MC SFSB","l");
3470 >      } else {
3471 >        legBpredc->AddEntry(Bpredem,"MC OF","l");
3472 >      }
3473   //       if ( overlay_signal ) legBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
3474        legBpredc->Draw();
3475        CompleteSave(globalcanvas,subdir+"Bpred_MCwithS_comparison");
3476      }
3477    }
3478    
2834  TFile *f = new TFile("tester.root","RECREATE");
2835  RcorrJZBeemm->Write();
2836  Bpred->Write();
2837  f->Close();
2838  
3479    delete RcorrJZBeemm;
3480    delete LcorrJZBeemm;
3481    delete RcorrJZBem;
# Line 2865 | Line 3505 | void do_prediction_plot(string jzb, TCan
3505  
3506   void do_prediction_plots(string mcjzb, string datajzb, float DataSigma, float MCSigma, bool overlay_signal ) {
3507    switch_overunderflow(true);
3508 +  
3509 +  TCut cuts[3] = {TCut("mll>0"),Restrmasscut,TCut("mll>20&&mll<70")};
3510 +  string cutnames[3] = {"NoMassCut","ZWindow","LowMassRegion2070"};
3511 +  
3512    TCanvas *globalcanvas = new TCanvas("globalcanvas","Prediction Canvas");
3513 <  do_prediction_plot(datajzb,globalcanvas,jzbHigh ,data,overlay_signal);
3514 <  if ( !PlottingSetup::Approved ) {
3515 <    do_prediction_plot(mcjzb,globalcanvas,jzbHigh ,mc,overlay_signal);
3516 <    do_prediction_plot(mcjzb,globalcanvas,jzbHigh ,mcwithsignal,overlay_signal);
3517 <  } else {
3518 <    write_info(__FUNCTION__,"You set approved to true, therefore not producing prediction/observation plots for MC with and without signal.");
3513 >  for(int i=0;i<3;i++) {
3514 >    do_prediction_plot(cuts[i],cutnames[i],datajzb,globalcanvas,jzbHigh ,data,overlay_signal);
3515 >    if ( !PlottingSetup::Approved ) {
3516 >      do_prediction_plot(cuts[i],cutnames[i],mcjzb,globalcanvas,jzbHigh ,mc,overlay_signal);
3517 >      do_prediction_plot(cuts[i],cutnames[i],mcjzb,globalcanvas,jzbHigh ,mcwithsignal,overlay_signal);
3518 >    } else {
3519 >      write_info(__FUNCTION__,"You set approved to true, therefore not producing prediction/observation plots for MC with and without signal.");
3520 >    }
3521    }
3522 +  
3523    delete globalcanvas;
3524    switch_overunderflow(false);
3525   }
# Line 2897 | Line 3544 | void lepton_comparison_plots() {
3544    Float_t ymin = 1.e-5, ymax = 0.25;
3545    TCanvas *can = new TCanvas("can","Lepton Comparison Canvas");
3546    can->SetLogy(1);
3547 <  TH1F *eemc = allsamples.Draw("eemc","mll",50,50,150, "mll [GeV]", "events", cutOSSF&&cutnJets&&"(id1==0)",mc, luminosity,allsamples.FindSample("/DY"));
3548 <  TH1F *mmmc = allsamples.Draw("mmmc","mll",50,50,150, "mll [GeV]", "events", cutOSSF&&cutnJets&&"(id1==1)",mc, luminosity,allsamples.FindSample("/DY"));
3547 >  TH1F *eemc = allsamples.Draw("eemc","mll",50,50,150, "mll [GeV]", "events", cutOSSF&&cutnJets&&"(id1==0)",mc, luminosity,allsamples.FindSample("DYJetsToLL"));
3548 >  TH1F *mmmc = allsamples.Draw("mmmc","mll",50,50,150, "mll [GeV]", "events", cutOSSF&&cutnJets&&"(id1==1)",mc, luminosity,allsamples.FindSample("DYJetsToLL"));
3549    eemc->SetLineColor(kBlue);
3550    mmmc->SetLineColor(kRed);
3551    eemc->SetMinimum(0.1);
# Line 2963 | Line 3610 | void lepton_comparison_plots() {
3610    DrawPrelim();
3611    Save_With_Ratio(jeed,jmmd,eemmpad->cd(),"lepton_comparison/jzb_Comparing_ee_mm_data");
3612    
3613 <  TH1F *zjeed = allsamples.Draw("zjeed",jzbvariablemc,    int((jzbHigh+150)/5),-150,jzbHigh , "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&"(id1==0)",mc,  luminosity,allsamples.FindSample("/DY"));
3614 <  TH1F *zjmmd = allsamples.Draw("zjmmd",jzbvariablemc,    int((jzbHigh+150)/5),-150,jzbHigh , "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&"(id1==1)",mc,  luminosity,allsamples.FindSample("/DY"));
3615 <  TH1F *zjeemmd = allsamples.Draw("zjeemmd",jzbvariablemc,int((jzbHigh+150)/5),-150,jzbHigh , "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,            mc,  luminosity,allsamples.FindSample("/DY"));
3613 >  TH1F *zjeed = allsamples.Draw("zjeed",jzbvariablemc,    int((jzbHigh+150)/5),-150,jzbHigh , "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&"(id1==0)",mc,  luminosity,allsamples.FindSample("DYJetsToLL"));
3614 >  TH1F *zjmmd = allsamples.Draw("zjmmd",jzbvariablemc,    int((jzbHigh+150)/5),-150,jzbHigh , "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&"(id1==1)",mc,  luminosity,allsamples.FindSample("DYJetsToLL"));
3615 >  TH1F *zjeemmd = allsamples.Draw("zjeemmd",jzbvariablemc,int((jzbHigh+150)/5),-150,jzbHigh , "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,            mc,  luminosity,allsamples.FindSample("DYJetsToLL"));
3616    dout << "Z+Jets ee : " << zjeed->GetMean() << "+/-" << zjeed->GetMeanError() << endl;
3617    dout << "Z+Jets ee : " << zjmmd->GetMean() << "+/-" << zjmmd->GetMeanError() << endl;
3618    dout << "Z+Jets eemd : " << zjeemmd->GetMean() << "+/-" << zjeemmd->GetMeanError() << endl;
# Line 3169 | Line 3816 | void diboson_plots(string mcjzb, string
3816    TCanvas *gloca = new TCanvas("gloca","gloca");
3817    
3818    dout << "Going to produce prediction plots" << endl;
3819 <  do_prediction_plot(mcjzb, gloca, PlottingSetup::jzbHigh, 0, false,"Dibosons/Bpred/" ); // do only MC plots, no signal
3820 <  do_prediction_plot(mcjzb, gloca, PlottingSetup::jzbHigh, 0, false,"Dibosons/Bpred/" ); // do MC plots with signal
3819 >  do_prediction_plot(TCut("mll>0"),"",mcjzb, gloca, PlottingSetup::jzbHigh, 0, false,"Dibosons/Bpred/" ); // do only MC plots, no signal
3820 >  do_prediction_plot(TCut("mll>0"),"",mcjzb, gloca, PlottingSetup::jzbHigh, 0, false,"Dibosons/Bpred/" ); // do MC plots with signal
3821    delete gloca;
3822  
3823    dout << "Going to reset the cross section for diboson samples ... " << endl;
# Line 3298 | Line 3945 | string jzb_tex_command(string region, st
3945   //  \SFZPJZBPOS
3946   //  Sample &  \OFZPJZBPOS  & \OFZPJZBNEG &  \SFZPJZBPOS & \SFZPJZBNEG & \OFSBJZBPOS  & \OFSBJZBNEG  & \SFSBJZBPOS  & \SFSBJZBNEG  \\\hline
3947    
3948 +  
3949 + void compute_Improved_MC_yields(string mcjzb,vector<float> jzb_cuts) {
3950 +  dout << "Calculating background yields in MC:" << endl;
3951 +  
3952 +  TCanvas *yica = new TCanvas("yica","yield canvas");
3953 +  
3954 +  int nRegions=2;
3955 +  if(!PlottingSetup::RestrictToMassPeak||!PlottingSetup::UseSidebandsForcJZB) nRegions=2;
3956 +  string tsRegions[] = {"SFZP","OFZP"};
3957 +  string posneg[] = {"pos","neg"};
3958 +  TCut tkRegions[] = {cutOSSF&&cutnJets&&cutmass,cutOSOF&&cutnJets&&cutmass};
3959 +
3960 +  
3961 +  
3962 +  for(int ijzb=0;ijzb<(int)jzb_cuts.size();ijzb++) {
3963 +    TCut posJZB = give_jzb_expression(mcjzb,jzb_cuts[ijzb],"pos");
3964 +    TCut negJZB = give_jzb_expression(mcjzb,jzb_cuts[ijzb],"neg");
3965 +    
3966 +    dout << "_________________________________________________________" << endl;
3967 +    dout << "Table for JZB> " << jzb_cuts[ijzb] << endl;
3968 +    
3969 +    
3970 +    THStack *spstack = new THStack(allsamples.DrawStack("spstack","mll<10e6||mll>1",1,0,500,"tester","events",cutOSSF&&cutnJets&&cutmass&&posJZB,mc,luminosity));
3971 +    THStack *snstack = new THStack(allsamples.DrawStack("snstack","mll<10e6||mll>1",1,0,500,"tester","events",cutOSSF&&cutnJets&&cutmass&&negJZB,mc,luminosity));
3972 +    THStack *opstack = new THStack(allsamples.DrawStack("opstack","mll<10e6||mll>1",1,0,500,"tester","events",cutOSOF&&cutnJets&&cutmass&&posJZB,mc,luminosity));
3973 +    THStack *onstack = new THStack(allsamples.DrawStack("onstack","mll<10e6||mll>1",1,0,500,"tester","events",cutOSOF&&cutnJets&&cutmass&&negJZB,mc,luminosity));
3974 +    
3975 +    
3976 +    vector<pair<string,Value> > obs_yields     = WriteYield(spstack, -10, 10, true);
3977 +    vector<pair<string,Value> > neg_sf_yields  = WriteYield(snstack, -10, 10, true);
3978 +    vector<pair<string,Value> > pos_of_yields  = WriteYield(opstack, -10, 10, true);
3979 +    vector<pair<string,Value> > neg_of_yields  = WriteYield(onstack, -10, 10, true);
3980 +    
3981 +    Value TotObs=Value(0,0);
3982 +    Value TotPred=Value(0,0);
3983 +    
3984 +    for(int ientry=0;ientry<obs_yields.size();ientry++) {
3985 +      if(Contains(obs_yields[ientry].first,"t_bar_t")) continue; // ttbar
3986 +      if(Contains(obs_yields[ientry].first,"W_Jets")) continue; // W+Jets
3987 +      if(Contains(obs_yields[ientry].first,"WW_")) continue; // WW (fully flavor symmetric)
3988 +      if(Contains(obs_yields[ientry].first,"Single_top")) continue; // Single Top
3989 +      if(Contains(obs_yields[ientry].first,"ee_mumu")) continue; // DY
3990 +      if(Contains(obs_yields[ientry].first,"tau_tau")) continue; // DY
3991 +      Value pred = neg_sf_yields[ientry].second + pos_of_yields[ientry].second - neg_of_yields[ientry].second;
3992 +      Value obs=obs_yields[ientry].second;
3993 +      Value diff=obs-pred;
3994 +      dout << obs_yields[ientry].first << "\t & \t " << obs << " \t & \t " << pred << "\t & \t " << diff << endl;
3995 +      TotObs=TotObs+obs_yields[ientry].second;
3996 +      TotPred=TotPred+pred;
3997 +    }
3998 +    
3999 +    float Systematic=sqrt(pow(TotPred.getValue(),2)*0.5*0.5 + pow(TotObs.getValue(),2)*0.5*0.5);
4000 +
4001 +        
4002 +  }
4003 +  
4004 +  delete yica;
4005 + }
4006 +      
4007   void compute_MC_yields(string mcjzb,vector<float> jzb_cuts) {
4008    dout << "Calculating background yields in MC:" << endl;
4009    
# Line 3393 | Line 4099 | void draw_ttbar_and_zjets_shape_for_one_
4099    TText *titlecenter;
4100    bool frommc=false;
4101    if(frommc) {
4102 <    osof = allsamples.Draw("osof",datajzb,40,-200,200, "JZB [GeV]", "events", massat40&&cutOSSF&&jetcut&&lepcut,mc,luminosity,allsamples.FindSample("TTJets"));
4102 >    osof = allsamples.Draw("osof",datajzb,40,-200,200, "JZB [GeV]", "events", massat40&&cutOSSF&&jetcut&&lepcut,mc,luminosity,allsamples.FindSample("TT_"));
4103      titlecenter = write_title("Extracting ttbar shape (from ossf MC)");
4104    }
4105    else {
# Line 3610 | Line 4316 | float find_one_correction_factor(string
4316      (allsamples.collection)[SampleIndices[iSample]].events->Draw("sumJetPt[1]/pt:pt>>+niceresponseplotd",(zptforresponsepresentation&&cutOSSF)*cutWeight);
4317      (allsamples.collection)[SampleIndices[iSample]].events->Draw("sumJetPt[1]/pt:pt>>+emuResponse",(zptforresponsepresentation&&cutOSOF)*cutWeight);
4318    }
4319 +  
4320    niceresponseplotd->Add(emuResponse,-1);
4321    
4322 +  //TF1 *resp_func = new TF1("resp_func","[0]+[1]/x + [2]/pow(x,2)",10,600);
4323 +  
4324    niceresponseplotd->SetStats(0);
4325    niceresponseplotd->GetXaxis()->SetTitle("Z p_{T} [GeV]");
4326    niceresponseplotd->GetYaxis()->SetTitle("Response");
# Line 3621 | Line 4330 | float find_one_correction_factor(string
4330    TProfile * profd = (TProfile*)niceresponseplotd->ProfileX();
4331    profd->Rebin(2);
4332    profd->SetMarkerSize(DataMarkerSize);
4333 +  //profd->Fit(resp_func,"","same,e1",10,400);
4334    profd->Fit("pol0","","same,e1",100,400);
4335 +  //resp_func->SetLineColor(kBlue);
4336    DrawPrelim();
4337    string stitle="Data";
4338    if(!Contains(FindKeyword,"Data")) stitle="MC";
4339    TText* title = write_text(0.5,0.7,stitle.c_str());
4340    title->SetTextAlign(12);
4341    title->Draw();
4342 + //  TF1 *datapol=(TF1*)profd->GetFunction("pol0");
4343    TF1 *datapol=(TF1*)profd->GetFunction("pol0");
4344    float correction=datapol->GetParameter(0);
4345 +  
4346 + //  float correction=resp_func->GetParameter(0);
4347    stringstream resstring;
4348    resstring<<"Response: "<<std::setprecision(2)<<100*correction<<" %";
4349    TText* restitle = write_text(0.5,0.65,resstring.str());
# Line 3650 | Line 4364 | void find_correction_factors(string &jzb
4364    float datacorrection=find_one_correction_factor("Data",true,"","Data");
4365    float mccorrection=find_one_correction_factor("DY",false,"","MC");
4366    
4367 <  float dataEEcorrection=find_one_correction_factor("Data",true,"id1==0","Data_ee");
4367 > /*  float dataEEcorrection=find_one_correction_factor("Data",true,"id1==0","Data_ee");
4368    float mcEEcorrection=find_one_correction_factor("DY",false,"id1==0","MC_ee");
4369    
4370    float dataMMcorrection=find_one_correction_factor("Data",true,"id1==1","Data_mm");
4371    float mcMMcorrection=find_one_correction_factor("DY",false,"id1==1","MC_mm");
4372 <  
4372 >  */
4373    cout << "Corrections : " << endl;
4374    cout << "   Data : " << datacorrection << endl;
4375 <  cout << "     ee (" << dataEEcorrection << ") , mm (" << dataMMcorrection << ")" << endl;
4375 > //   cout << "     ee (" << dataEEcorrection << ") , mm (" << dataMMcorrection << ")" << endl;
4376    cout << "   MC : " << mccorrection << endl;
4377 <  cout << "     ee (" << mcEEcorrection << ") , mm (" << mcMMcorrection << ")" << endl;
4377 > //   cout << "     ee (" << mcEEcorrection << ") , mm (" << mcMMcorrection << ")" << endl;
4378    
4379    //Step 2: Processing the result and making it into something useful :-)
4380    stringstream jzbvardatas;
4381 +  /*
4382    jzbvardatas << "(";
4383    
4384    if(dataEEcorrection>=1) jzbvardatas<<"((id1==0&&id1==id2)*(jzb[1]-" << dataEEcorrection-1 << "*pt))";
# Line 3679 | Line 4394 | void find_correction_factors(string &jzb
4394    
4395    jzbvardatas << ")";
4396    jzbvardata=jzbvardatas.str();
4397 <  
4397 >  */
4398    stringstream jzbvarmcs;
4399 +  /*
4400    jzbvarmcs << "(";
4401 <  
4401 >
4402    if(mcEEcorrection>=1) jzbvarmcs<<"((id1==0&&id1==id2)*(jzb[1]-" << mcEEcorrection-1 << "*pt))";
4403    if(mcEEcorrection<1)  jzbvarmcs<<"((id1==0&&id1==id2)*(jzb[1]+" << 1-mcEEcorrection << "*pt))";
4404    
# Line 3696 | Line 4412 | void find_correction_factors(string &jzb
4412    
4413    jzbvarmcs << ")";
4414    jzbvarmc=jzbvarmcs.str();
4415 <
4415 >  */
4416 >  
4417 >  if(datacorrection>=1) jzbvardatas<<"(jzb[1]-" << datacorrection-1 << "*pt)";
4418 >  if(datacorrection<1)  jzbvardatas<<"(jzb[1]+" << 1-datacorrection << "*pt)";
4419 >  
4420 >  if(mccorrection>=1) jzbvarmcs<<"(jzb[1]-" << mccorrection-1 << "*pt)";
4421 >  if(mccorrection<1)  jzbvarmcs<<"(jzb[1]+" << 1-mccorrection << "*pt)";
4422 >  
4423 >  jzbvardata = jzbvardatas.str();
4424 >  jzbvarmc = jzbvarmcs.str();
4425 >  
4426    dout << "JZB Z pt correction summary : " << endl;
4427    dout << "  Data: The response is " << datacorrection << "  --> jzb variable is now : " << jzbvardata << endl;
4428    dout << "  MC  : The response is " << mccorrection << "  --> jzb variable is now : " << jzbvarmc << endl;
4429    
4430   }
4431  
4432 < void pick_up_events(string cut, string filename) {
4433 <  allsamples.PickUpEvents(cut,filename);
4432 > void pick_up_events(string cut, string filename, bool QuietMode=false) {
4433 >  allsamples.PickUpEvents(cut,filename,QuietMode);
4434   }
4435  
4436   void save_template(string mcjzb, string datajzb,vector<float> jzb_cuts,float MCPeakError,float DataPeakError, vector<float> jzb_shape_limit_bins) {
# Line 3790 | Line 4516 | void draw_all_ttbar_histos(TCanvas *can,
4516    }
4517   }
4518  
4519 < void ttbar_sidebands_comparison(string mcjzb, vector<float> binning, string prestring) {
4519 > void ttbar_sidebands_comparison(string mcjzb, vector<float> binning, string prestring, TCut cut) {
4520    //in the case of the on peak analysis, we compare the 3 control regions to the real value
4521    //in the case of the OFF peak analysis, we compare our control region to the real value
4522    TCut weightbackup=cutWeight;
4523    switch_overunderflow(true);
4524    
4525 <  bool doPURW=false;
4525 >  bool doPURW=true;
4526    
4527    
4528    if(!doPURW) {
# Line 3816 | Line 4542 | void ttbar_sidebands_comparison(string m
4542        
4543    float simulatedlumi = luminosity; //in pb please - adjust to your likings
4544  
4545 <  TH1F *TZem  = allsamples.Draw("TZem",     mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSOF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("/TT"));
4546 <  TH1F *nTZem = allsamples.Draw("nTZem","-"+mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSOF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("/TT"));
4545 >  TH1F *TZem  = allsamples.Draw("TZem",     mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSOF&&cutnJets&&cut,mc,simulatedlumi,allsamples.FindSample("/TT"));
4546 >  TH1F *nTZem = allsamples.Draw("nTZem","-"+mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSOF&&cutnJets&&cut,mc,simulatedlumi,allsamples.FindSample("/TT"));
4547    TH1F *TSem;
4548    TH1F *nTSem;
4549 <  TH1F *TZeemm  = allsamples.Draw("TZeemm",     mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("/TT"));
4550 <  TH1F *nTZeemm = allsamples.Draw("nTZeemm","-"+mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("/TT"));
4549 >  TH1F *TZeemm  = allsamples.Draw("TZeemm",     mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSSF&&cutnJets&&cut,mc,simulatedlumi,allsamples.FindSample("/TT"));
4550 >  TH1F *nTZeemm = allsamples.Draw("nTZeemm","-"+mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSSF&&cutnJets&&cut,mc,simulatedlumi,allsamples.FindSample("/TT"));
4551    TH1F *TSeemm;
4552    TH1F *nTSeemm;
4553    
4554    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
4555 <    TSem    = allsamples.Draw("TSem",       mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSOF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("/TT"));
4556 <    nTSem   = allsamples.Draw("nTSem",  "-"+mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSOF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("/TT"));
4557 <    TSeemm  = allsamples.Draw("TSeemm",     mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSSF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("/TT"));
4558 <    nTSeemm = allsamples.Draw("nTSeemm","-"+mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSSF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("/TT"));
4555 >    TSem    = allsamples.Draw("TSem",       mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSOF&&cutnJets&&cut,mc,simulatedlumi,allsamples.FindSample("/TT"));
4556 >    nTSem   = allsamples.Draw("nTSem",  "-"+mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSOF&&cutnJets&&cut,mc,simulatedlumi,allsamples.FindSample("/TT"));
4557 >    TSeemm  = allsamples.Draw("TSeemm",     mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSSF&&cutnJets&&cut,mc,simulatedlumi,allsamples.FindSample("/TT"));
4558 >    nTSeemm = allsamples.Draw("nTSeemm","-"+mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSSF&&cutnJets&&cut,mc,simulatedlumi,allsamples.FindSample("/TT"));
4559    }
4560  
4561    TCanvas *tcan = new TCanvas("tcan","tcan");
# Line 4084 | Line 4810 | void ttbar_sidebands_comparison(string m
4810   //  nicer_binning.push_back(300);
4811   //  nicer_binning.push_back(400);
4812    
4813 <  ttbar_sidebands_comparison(mcjzb,nicer_binning, "ttbar/");
4813 >  ttbar_sidebands_comparison(mcjzb,nicer_binning, "ttbar/",TCut("mll>0"));
4814 >  ttbar_sidebands_comparison(mcjzb,nicer_binning, "ttbar/CutAt20",TCut("mll>20"));
4815 >  ttbar_sidebands_comparison(mcjzb,nicer_binning, "ttbar/LowMassRegion2070",TCut("mll>20&&mll<70"));
4816 >  ttbar_sidebands_comparison(mcjzb,nicer_binning, "ttbar/ZWindow",Restrmasscut);
4817 >  
4818   }
4819  
4820  
4821   void zjets_prediction_comparison(string mcjzbWithPUa, TCut massregioncut, string massregionname) {
4822    cout << "****************************************************************************************************************************************************************" << endl;
4823    TCanvas *zcan = new TCanvas("zcan","zcan");  
4094 //  zcan->SetLogy(1);
4824    TCut weightbackup=cutWeight;
4825    
4826    bool UsePURW=true;
# Line 4117 | Line 4846 | void zjets_prediction_comparison(string
4846    }
4847  
4848    
4849 +  
4850    vector<float> binning;
4851    binning.push_back(0);
4852    binning.push_back(10);
4853 <  binning.push_back(20);
4854 <  binning.push_back(40);
4855 <  binning.push_back(60);
4856 < //   binning.push_back(50);
4853 >  binning.push_back(30);
4854 > //  binning.push_back(40);
4855 > //  binning.push_back(60);
4856 >   binning.push_back(50);
4857   //   binning.push_back(60);
4858   //   binning.push_back(70);
4859   //   binning.push_back(80);
# Line 4134 | Line 4864 | void zjets_prediction_comparison(string
4864    
4865    TCut kPos((mcjzb+">0").c_str());
4866    TCut kNeg((mcjzb+"<0").c_str());
4867 +  TCut reducedNJets(cutnJets);
4868    string var( "abs("+mcjzb+")" );
4869    
4870 <  TCut notTau("abs(genMID1)!=15");
4870 >  
4871 >  TCut notTau("!EventZToTaus");
4872    TCut ee_mm_tautau("mll>0");
4873    
4874 <
4875 <  TH1F *hJZBpos = systsamples.Draw("hJZBpos",var,binning, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets&&notTau&&kPos&&massregioncut,mc,simulatedlumi,systsamples.FindSample("/DY"));
4144 <  TH1F *hJZBneg = systsamples.Draw("hJZBneg",var,binning, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets&&notTau&&kNeg&&massregioncut,mc,simulatedlumi,systsamples.FindSample("/DY"));
4874 >  TH1F *hJZBpos = allsamples.Draw("hJZBpos",var,binning, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets&&notTau&&kPos&&massregioncut,mc,simulatedlumi,allsamples.FindSample("DYJetsToLL"));
4875 >  TH1F *hJZBneg = allsamples.Draw("hJZBneg",var,binning, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets&&notTau&&kNeg&&massregioncut,mc,simulatedlumi,allsamples.FindSample("DYJetsToLL"));
4876    
4877    hJZBpos->SetLineColor(kBlack);
4878    hJZBneg->SetLineColor(kRed);
# Line 4162 | Line 4893 | void zjets_prediction_comparison(string
4893    hratio->Divide(hJZBneg);
4894    
4895    for(int i=1;i<=hJZBpos->GetNbinsX();i++) {
4896 <    cout << "Positive: " << hJZBpos->GetBinContent(i) << "   vs    Negative : " << hJZBneg->GetBinContent(i) << "   (ratio : " << hJZBpos->GetBinContent(i) / hJZBneg->GetBinContent(i) << endl;
4896 >    cout << "Positive: " << hJZBpos->GetBinContent(i) << " +/- " << hJZBpos->GetBinError(i) << "   vs    Negative : " << hJZBneg->GetBinContent(i) << " +/- " << hJZBneg->GetBinError(i) << "   (ratio : " << hJZBpos->GetBinContent(i) / hJZBneg->GetBinContent(i) << " +/- " << (hJZBpos->GetBinContent(i) / hJZBneg->GetBinContent(i)) * sqrt(pow(hJZBpos->GetBinError(i)/hJZBpos->GetBinContent(i),2) + pow(hJZBneg->GetBinError(i)/hJZBneg->GetBinContent(i),2)) << ")" << endl;
4897    }
4898    
4899   //  zcan->SetLogy(0);
# Line 4170 | Line 4901 | void zjets_prediction_comparison(string
4901    hratio->GetYaxis()->SetTitle("Observed/Predicted");
4902    hratio->Draw("e1");
4903    
4904 <  TLine *top = new TLine(binning[0],1.25,binning[binning.size()-1],1.25);
4904 >  TLine *top = new TLine(binning[0],1.2,binning[binning.size()-1],1.2);
4905    TLine *center = new TLine(binning[0],1.0,binning[binning.size()-1],1.0);
4906 <  TLine *bottom = new TLine(binning[0],0.75,binning[binning.size()-1],0.75);
4906 >  TLine *bottom = new TLine(binning[0],0.8,binning[binning.size()-1],0.8);
4907    
4908  
4909    top->SetLineColor(kBlue);top->SetLineStyle(2);
# Line 4190 | Line 4921 | void zjets_prediction_comparison(string
4921    DrawMCPrelim(simulatedlumi);
4922    CompleteSave(zcan,"Systematics/ZJets/zjets_eemm_prediction_ratio"+any2string(massregionname));
4923    
4924 <  TCut reducedNJets(cutnJets);
4925 <  
4926 <  TH1F *TAUhJZBpos       = systsamples.Draw("TAUhJZBpos",var,binning, "JZB [GeV]", "events",cutmass&&cutOSSF&&reducedNJets&&ee_mm_tautau&&kPos&&massregioncut,mc,simulatedlumi,systsamples.FindSample("/DY"));
4927 <  TH1F *LcorrJZBeemm     = systsamples.Draw("LcorrJZBeemm",var,binning, "JZB [GeV]", "events",cutmass&&cutOSSF&&reducedNJets&&ee_mm_tautau&&kNeg&&massregioncut,mc,simulatedlumi,systsamples.FindSample("/DY"));
4197 <  TH1F *RcorrJZBem       = systsamples.Draw("RcorrJZBem",var,binning, "JZB [GeV]", "events",cutmass&&cutOSOF&&reducedNJets&&ee_mm_tautau&&kPos&&massregioncut,mc,simulatedlumi,systsamples.FindSample("/DY"));
4198 <  TH1F *LcorrJZBem       = systsamples.Draw("LcorrJZBem",var,binning, "JZB [GeV]", "events",cutmass&&cutOSOF&&reducedNJets&&ee_mm_tautau&&kNeg&&massregioncut,mc,simulatedlumi,systsamples.FindSample("/DY"));
4924 >  TH1F *TAUhJZBpos       = allsamples.Draw("TAUhJZBpos",var,binning, "JZB [GeV]", "events",cutmass&&cutOSSF&&reducedNJets&&ee_mm_tautau&&kPos&&massregioncut,mc,simulatedlumi,allsamples.FindSample("DYJetsToLL"));
4925 >  TH1F *LcorrJZBeemm     = allsamples.Draw("LcorrJZBeemm",var,binning, "JZB [GeV]", "events",cutmass&&cutOSSF&&reducedNJets&&ee_mm_tautau&&kNeg&&massregioncut,mc,simulatedlumi,allsamples.FindSample("DYJetsToLL"));
4926 >  TH1F *RcorrJZBem       = allsamples.Draw("RcorrJZBem",var,binning, "JZB [GeV]", "events",cutmass&&cutOSOF&&reducedNJets&&ee_mm_tautau&&kPos&&massregioncut,mc,simulatedlumi,allsamples.FindSample("DYJetsToLL"));
4927 >  TH1F *LcorrJZBem       = allsamples.Draw("LcorrJZBem",var,binning, "JZB [GeV]", "events",cutmass&&cutOSOF&&reducedNJets&&ee_mm_tautau&&kNeg&&massregioncut,mc,simulatedlumi,allsamples.FindSample("DYJetsToLL"));
4928  
4929    TH1F *RcorrJZBSBem;
4930    TH1F *LcorrJZBSBem;
# Line 4203 | Line 4932 | void zjets_prediction_comparison(string
4932    TH1F *LcorrJZBSBeemm;
4933  
4934    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
4935 <    RcorrJZBSBem   = systsamples.Draw("RcorrJZBSBem",var,binning, "JZB [GeV]", "events",sidebandcut&&cutOSOF&&reducedNJets&&ee_mm_tautau&&kPos&&massregioncut,mc,simulatedlumi,systsamples.FindSample("/DY"));
4936 <    LcorrJZBSBem   = systsamples.Draw("LcorrJZBSBem",var,binning, "JZB [GeV]", "events",sidebandcut&&cutOSOF&&reducedNJets&&ee_mm_tautau&&kNeg&&massregioncut,mc,simulatedlumi,systsamples.FindSample("/DY"));
4937 <    RcorrJZBSBeemm = systsamples.Draw("RcorrJZBSBeemm",var,binning, "JZB [GeV]", "events",sidebandcut&&cutOSSF&&reducedNJets&&ee_mm_tautau&&kPos&&massregioncut,mc,simulatedlumi,systsamples.FindSample("/DY"));
4938 <    LcorrJZBSBeemm = systsamples.Draw("LcorrJZBSBeemm",var,binning, "JZB [GeV]", "events",sidebandcut&&cutOSSF&&reducedNJets&&ee_mm_tautau&&kNeg&&massregioncut,mc,simulatedlumi,systsamples.FindSample("/DY"));
4935 >    RcorrJZBSBem   = allsamples.Draw("RcorrJZBSBem",var,binning, "JZB [GeV]", "events",sidebandcut&&cutOSOF&&reducedNJets&&ee_mm_tautau&&kPos&&massregioncut,mc,simulatedlumi,allsamples.FindSample("DYJetsToLL"));
4936 >    LcorrJZBSBem   = allsamples.Draw("LcorrJZBSBem",var,binning, "JZB [GeV]", "events",sidebandcut&&cutOSOF&&reducedNJets&&ee_mm_tautau&&kNeg&&massregioncut,mc,simulatedlumi,allsamples.FindSample("DYJetsToLL"));
4937 >    RcorrJZBSBeemm = allsamples.Draw("RcorrJZBSBeemm",var,binning, "JZB [GeV]", "events",sidebandcut&&cutOSSF&&reducedNJets&&ee_mm_tautau&&kPos&&massregioncut,mc,simulatedlumi,allsamples.FindSample("DYJetsToLL"));
4938 >    LcorrJZBSBeemm = allsamples.Draw("LcorrJZBSBeemm",var,binning, "JZB [GeV]", "events",sidebandcut&&cutOSSF&&reducedNJets&&ee_mm_tautau&&kNeg&&massregioncut,mc,simulatedlumi,allsamples.FindSample("DYJetsToLL"));
4939    }
4940    
4941    TH1F *Bpred = (TH1F*)LcorrJZBeemm->Clone("Bpred");
# Line 4243 | Line 4972 | void zjets_prediction_comparison(string
4972    TAUhratio->Divide(Bpred);
4973    
4974    for(int i=1;i<=TAUhJZBpos->GetNbinsX();i++) {
4975 <    cout << "ee/mm/tautau observed: " << TAUhJZBpos->GetBinContent(i) << "   vs    predicted : " << Bpred->GetBinContent(i) << "   (ratio : " << TAUhJZBpos->GetBinContent(i) / Bpred->GetBinContent(i) << endl;
4975 >    cout << "ee/mm/tautau observed: " << TAUhJZBpos->GetBinContent(i) << " +/- " << TAUhJZBpos->GetBinError(i) << "   vs    Negative : " << Bpred->GetBinContent(i) << " +/- " << Bpred->GetBinError(i) << "   (ratio : " << TAUhJZBpos->GetBinContent(i) / Bpred->GetBinContent(i) << " +/- " << (TAUhJZBpos->GetBinContent(i) / Bpred->GetBinContent(i)) * sqrt(pow(TAUhJZBpos->GetBinError(i)/TAUhJZBpos->GetBinContent(i),2) + pow(Bpred->GetBinError(i)/Bpred->GetBinContent(i),2)) << ")" << endl;
4976 >    
4977 >    
4978    }
4979    
4980    zcan->SetLogy(0);
# Line 4277 | Line 5008 | void zjets_prediction_comparison(string
5008      delete LcorrJZBSBeemm;
5009    }
5010    
5011 +  //***************************************************************************************************
5012    
5013 +  string jzbvar=var;
5014 +  /*
5015 +  for(int i=0;i<60;i+=10) {
5016 +    stringstream sSpecialJZBCut;
5017 +    sSpecialJZBCut << jzbvar << ">" << i;
5018 +  TCut SpecialJZBCut(sSpecialJZBCut.str().c_str());
5019 +  
5020 +  var="mll";
5021 +  
5022 +  TH1F *FullJZBhJZBpos       = allsamples.Draw("FullJZBhJZBpos",var,10,0,200, "m_{ll} [GeV]", "events",cutmass&&cutOSSF&&reducedNJets&&notTau&&kPos&&massregioncut&&SpecialJZBCut,mc,simulatedlumi,allsamples.FindSample("DYJetsToLL"));
5023 +  TH1F *LcorrJZBPluseemm     = allsamples.Draw("LcorrJZBPluseemm",var,10,0,200, "m_{ll} [GeV]", "events",cutmass&&cutOSSF&&reducedNJets&&notTau&&kNeg&&massregioncut&&SpecialJZBCut,mc,simulatedlumi,allsamples.FindSample("DYJetsToLL"));
5024 +  TH1F *RcorrJZBPlusem       = allsamples.Draw("RcorrJZBPlusem",var,10,0,200, "m_{ll} [GeV]", "events",cutmass&&cutOSOF&&reducedNJets&&notTau&&kPos&&massregioncut&&SpecialJZBCut,mc,simulatedlumi,allsamples.FindSample("DYJetsToLL"));
5025 +  TH1F *LcorrJZBPlusem       = allsamples.Draw("LcorrJZBPlusem",var,10,0,200, "m_{ll} [GeV]", "events",cutmass&&cutOSOF&&reducedNJets&&notTau&&kNeg&&massregioncut&&SpecialJZBCut,mc,simulatedlumi,allsamples.FindSample("DYJetsToLL"));
5026 +
5027 +  TH1F *RcorrJZBPlusSBem;
5028 +  TH1F *LcorrJZBPlusSBem;
5029 +  TH1F *RcorrJZBPlusSBeemm;
5030 +  TH1F *LcorrJZBPlusSBeemm;
5031 +
5032 +  
5033 +  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
5034 +    RcorrJZBPlusSBem   = allsamples.Draw("RcorrJZBPlusSBem",var,10,0,200, "m_{ll} [GeV]", "events",sidebandcut&&cutOSOF&&reducedNJets&&notTau&&kPos&&massregioncut&&SpecialJZBCut,mc,simulatedlumi,allsamples.FindSample("DYJetsToLL"));
5035 +    LcorrJZBPlusSBem   = allsamples.Draw("LcorrJZBPlusSBem",var,10,0,200, "m_{ll} [GeV]", "events",sidebandcut&&cutOSOF&&reducedNJets&&notTau&&kNeg&&massregioncut&&SpecialJZBCut,mc,simulatedlumi,allsamples.FindSample("DYJetsToLL"));
5036 +    RcorrJZBPlusSBeemm = allsamples.Draw("RcorrJZBPlusSBeemm",var,10,0,200, "m_{ll} [GeV]", "events",sidebandcut&&cutOSSF&&reducedNJets&&notTau&&kPos&&massregioncut&&SpecialJZBCut,mc,simulatedlumi,allsamples.FindSample("DYJetsToLL"));
5037 +    LcorrJZBPlusSBeemm = allsamples.Draw("LcorrJZBPlusSBeemm",var,10,0,200, "m_{ll} [GeV]", "events",sidebandcut&&cutOSSF&&reducedNJets&&notTau&&kNeg&&massregioncut&&SpecialJZBCut,mc,simulatedlumi,allsamples.FindSample("DYJetsToLL"));
5038 +  }
5039 +  
5040 +  TH1F *BpredPrime = (TH1F*)LcorrJZBPluseemm->Clone("BpredPrime");
5041 +  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
5042 +    BpredPrime->Add(RcorrJZBPlusem,1.0/3.);
5043 +    BpredPrime->Add(LcorrJZBPlusem,-1.0/3.);
5044 +    BpredPrime->Add(RcorrJZBPlusSBem,1.0/3.);
5045 +    BpredPrime->Add(LcorrJZBPlusSBem,-1.0/3.);
5046 +    BpredPrime->Add(RcorrJZBPlusSBeemm,1.0/3.);
5047 +    BpredPrime->Add(LcorrJZBPlusSBeemm,-1.0/3.);
5048 +  } else {
5049 +    BpredPrime->Add(RcorrJZBPlusem,1.0);
5050 +    BpredPrime->Add(LcorrJZBPlusem,-1.0);
5051 +  }
5052 +  
5053 +  BpredPrime->SetLineColor(kRed);
5054 +
5055 +  FullJZBhJZBpos->SetLineColor(kBlack);
5056 +  BpredPrime->SetLineColor(kRed);
5057 +  
5058 +  FullJZBhJZBpos->SetMinimum(1.0);
5059 +  FullJZBhJZBpos->Draw("e1");
5060 +  BpredPrime->Draw("same,hist");
5061 +  FullJZBhJZBpos->Draw("same,e1");
5062 +  
5063 +  TLegend *FullJZBleg = make_legend("MC Z+jets #rightarrow ee,#mu#mu",0.55,0.75,false);
5064 +  FullJZBleg->AddEntry(FullJZBhJZBpos,"Observed","pe");
5065 +  FullJZBleg->AddEntry(BpredPrime,"Predicted","l");
5066 +  FullJZBleg->Draw("same");
5067 +  DrawMCPrelim(simulatedlumi);
5068 +  CompleteSave(zcan,"Systematics/ZJets/Mll_Distribution_JZB"+any2string(i)+"_zjets_eemumu_prediction__"+any2string(massregionname));
5069 +  
5070 +  TH1F* FullJZBhratio = (TH1F*)FullJZBhJZBpos->Clone("FullJZBhratio");
5071 +  FullJZBhratio->Divide(BpredPrime);
5072 +  
5073 +  zcan->SetLogy(0);
5074 +  FullJZBhratio->GetYaxis()->SetRangeUser(0,2.5);
5075 +  FullJZBhratio->GetYaxis()->SetTitle("Observed/Predicted");
5076 +  FullJZBhratio->Draw("e1");
5077 +  
5078 +  TLine *atop = new TLine(0,1.2,200,1.2);
5079 +  TLine *acenter = new TLine(0,1.0,200,1.0);
5080 +  TLine *abottom = new TLine(0,0.8,200,0.8);
5081 +  
5082 +  atop->SetLineColor(kBlue);
5083 +  atop->SetLineStyle(2);
5084 +  acenter->SetLineColor(kBlue);
5085 +  abottom->SetLineColor(kBlue);
5086 +  abottom->SetLineStyle(2);
5087 +  
5088 +  atop->Draw("same");
5089 +  acenter->Draw("same");
5090 +  abottom->Draw("same");
5091 +  
5092 +  TLegend *FullJZBleg2 = make_legend("MC Z+jets #rightarrow ee,#mu#mu",0.25,0.75,false);
5093 +  FullJZBleg2->AddEntry(FullJZBhratio,"obs / pred","pe");
5094 +  FullJZBleg2->AddEntry(abottom,"syst. envelope","l");
5095 +  FullJZBleg2->Draw("same");
5096 +  DrawMCPrelim(simulatedlumi);
5097 +  CompleteSave(zcan,"Systematics/ZJets/Mll_Distribution_JZB"+any2string(i)+"zjets_eemumu_prediction_ratio"+any2string(massregionname));
5098 +  
5099 +  
5100 +  delete BpredPrime;
5101 +  delete FullJZBhJZBpos;
5102 +  delete LcorrJZBPluseemm;
5103 +  delete RcorrJZBPlusem;
5104 +  delete LcorrJZBPlusem;
5105 + //  delete FullJZBhJZBpos;
5106 +  
5107 +  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
5108 +    delete RcorrJZBPlusSBem;
5109 +    delete LcorrJZBPlusSBem;
5110 +    delete RcorrJZBPlusSBeemm;
5111 +    delete LcorrJZBPlusSBeemm;
5112 +  }
5113 +  
5114 +  }
5115 +  //***************************************************************************************************
5116 +  */
5117    delete zcan;
5118    cutWeight=weightbackup;
5119   }
5120  
5121  
5122   void zjets_prediction_comparison(string mcjzbWithPUa) {
5123 <  zjets_prediction_comparison(mcjzbWithPUa, TCut(""), "nomasscut");
5124 <  zjets_prediction_comparison(mcjzbWithPUa, TCut("abs(mll-91)<20"), "Zwindow_20");
5123 >   zjets_prediction_comparison(mcjzbWithPUa, TCut("mll>20"), "nomasscut");
5124 >  zjets_prediction_comparison(mcjzbWithPUa, TCut("abs(mll-91)<10"), "Zwindow_10");
5125    zjets_prediction_comparison(mcjzbWithPUa, TCut("mll>20&&mll<70"), "LowMassRegion2070");
5126 <  zjets_prediction_comparison(mcjzbWithPUa, TCut("mll>110"), "HighMassRegion110");
5126 > //  zjets_prediction_comparison(mcjzbWithPUa, TCut("abs(mll-91)>10&&mll>20"), "Outside_Zwindow_10");
5127 > //  zjets_prediction_comparison(mcjzbWithPUa, TCut("mll>110"), "HighMassRegion110");
5128   }
5129    
5130   void sideband_assessment(string datajzb, float min=30.0, float max=50.0) {
# Line 4804 | Line 5641 | void met_vs_jzb_plots(string datajzb, st
5641    
5642    vector<string> findme;
5643    findme.push_back("DY");
5644 <  findme.push_back("TTJets");
5644 >  findme.push_back("TT_");
5645    findme.push_back("LM");
5646    /*
5647    for(int ifind=0;ifind<(int)findme.size();ifind++) {
# Line 4841 | Line 5678 | void met_vs_jzb_plots(string datajzb, st
5678    sRIGHT << "((" << mcjzb << ")>0)";
5679    TCut RIGHT(sRIGHT.str().c_str());
5680    
5681 <  TH1F *metleft   = allsamples.Draw("metleft","met[4]",nbins,low,high, "MET [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&LEFT,mc, luminosity, allsamples.FindSample("DYJets"));
5682 <  TH1F *metleftO  = allsamples.Draw("metleftO","met[4]",nbins,low,high, "MET [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&LEFT,mc, luminosity, allsamples.FindSample("DYJets"));
5683 <  TH1F *metright  = allsamples.Draw("metright","met[4]",nbins,low,high, "MET [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&RIGHT,mc, luminosity, allsamples.FindSample("DYJets"));
5684 <  TH1F *metrightO = allsamples.Draw("metrightO","met[4]",nbins,low,high, "MET [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&RIGHT,mc, luminosity, allsamples.FindSample("DYJets"));
5681 >  TH1F *metleft   = allsamples.Draw("metleft","met[4]",nbins,low,high, "#slash{E}_{T} [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&LEFT,mc, luminosity, allsamples.FindSample("DYJets"));
5682 >  TH1F *metleftO  = allsamples.Draw("metleftO","met[4]",nbins,low,high, "#slash{E}_{T} [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&LEFT,mc, luminosity, allsamples.FindSample("DYJets"));
5683 >  TH1F *metright  = allsamples.Draw("metright","met[4]",nbins,low,high, "#slash{E}_{T} [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&RIGHT,mc, luminosity, allsamples.FindSample("DYJets"));
5684 >  TH1F *metrightO = allsamples.Draw("metrightO","met[4]",nbins,low,high, "#slash{E}_{T} [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&RIGHT,mc, luminosity, allsamples.FindSample("DYJets"));
5685    
5686    
5687    TH1F *Bpred =  (TH1F*)metleft->Clone("Bpred");
# Line 4894 | Line 5731 | void met_vs_jzb_plots(string datajzb, st
5731    metpad2->cd();
5732    metpad2->SetLogy(1);
5733    
5734 <  TH1F *metlefta   = allsamples.Draw("metlefta","met[2]",nbins,low,high, "MET [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&LEFT,mc, luminosity, allsamples.FindSample("DYJets"));
5735 <  TH1F *metleftOa  = allsamples.Draw("metleftOa","met[2]",nbins,low,high, "MET [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&LEFT,mc, luminosity, allsamples.FindSample("DYJets"));
5736 <  TH1F *metrighta  = allsamples.Draw("metrighta","met[2]",nbins,low,high, "MET [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&RIGHT,mc, luminosity, allsamples.FindSample("DYJets"));
5737 <  TH1F *metrightOa = allsamples.Draw("metrightOa","met[2]",nbins,low,high, "MET [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&RIGHT,mc, luminosity, allsamples.FindSample("DYJets"));
5734 >  TH1F *metlefta   = allsamples.Draw("metlefta","met[2]",nbins,low,high, "#slash{E}_{T} [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&LEFT,mc, luminosity, allsamples.FindSample("DYJets"));
5735 >  TH1F *metleftOa  = allsamples.Draw("metleftOa","met[2]",nbins,low,high, "#slash{E}_{T} [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&LEFT,mc, luminosity, allsamples.FindSample("DYJets"));
5736 >  TH1F *metrighta  = allsamples.Draw("metrighta","met[2]",nbins,low,high, "#slash{E}_{T} [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&RIGHT,mc, luminosity, allsamples.FindSample("DYJets"));
5737 >  TH1F *metrightOa = allsamples.Draw("metrightOa","met[2]",nbins,low,high, "#slash{E}_{T} [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&RIGHT,mc, luminosity, allsamples.FindSample("DYJets"));
5738    
5739    metlefta->Add(metleftOa,-1);
5740    metrighta->Add(metrightOa,-1);
# Line 4916 | Line 5753 | void met_vs_jzb_plots(string datajzb, st
5753    int newNBins=30;
5754    
5755    TPad *metpad4 = new TPad("metpad4","metpad4",0,0,1,1);
5756 <  TH1F *Ametleft   = allsamples.Draw("Ametleft","met[4]",newNBins,low,newhigh, "MET [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&LEFT,mc, luminosity);
5757 <  TH1F *AmetleftO  = allsamples.Draw("AmetleftO","met[4]",newNBins,low,newhigh, "MET [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&LEFT,mc, luminosity);
5758 <  TH1F *Ametright  = allsamples.Draw("Ametright","met[4]",newNBins,low,newhigh, "MET [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&RIGHT,mc, luminosity);
5759 <  TH1F *AmetrightO = allsamples.Draw("AmetrightO","met[4]",newNBins,low,newhigh, "MET [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&RIGHT,mc, luminosity);
5756 >  TH1F *Ametleft   = allsamples.Draw("Ametleft","met[4]",newNBins,low,newhigh, "#slash{E}_{T} [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&LEFT,mc, luminosity);
5757 >  TH1F *AmetleftO  = allsamples.Draw("AmetleftO","met[4]",newNBins,low,newhigh, "#slash{E}_{T} [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&LEFT,mc, luminosity);
5758 >  TH1F *Ametright  = allsamples.Draw("Ametright","met[4]",newNBins,low,newhigh, "#slash{E}_{T} [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&RIGHT,mc, luminosity);
5759 >  TH1F *AmetrightO = allsamples.Draw("AmetrightO","met[4]",newNBins,low,newhigh, "#slash{E}_{T} [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&RIGHT,mc, luminosity);
5760    
5761    TH1F *aBpred = (TH1F*)Ametleft->Clone("aBpred");
5762    aBpred->Add(AmetleftO,-1);
# Line 4944 | Line 5781 | void met_vs_jzb_plots(string datajzb, st
5781    delete metright;
5782    delete metrightO;
5783   }
5784 +
5785 +
5786 + void do_one_ttbar_test(TH1F* &observed, TH1F* &predicted, TH1F* &ratio, TH1F* &ratio2, string mcjzb, string prestring) {
5787 +  
5788 +  if(PlottingSetup::RestrictToMassPeak) {
5789 +    write_error(__FUNCTION__,"This function (ttbar_tests) was not written for on-peak studies - sorry.");
5790 +    assert(!PlottingSetup::RestrictToMassPeak);
5791 +  }
5792 +  
5793 +  vector<float> binning;
5794 +  
5795 +  binning.push_back(-200);
5796 +  binning.push_back(-150);
5797 +  binning.push_back(-125);
5798 +  binning.push_back(-100);
5799 +  binning.push_back(-75);
5800 +  binning.push_back(-50);
5801 +  binning.push_back(-25);
5802 +  binning.push_back(0);
5803 +  binning.push_back(25);
5804 +  binning.push_back(50);
5805 +  binning.push_back(75);
5806 +  binning.push_back(100);
5807 +  binning.push_back(125);
5808 +  binning.push_back(150);
5809 +  binning.push_back(200);
5810 +  
5811 +  switch_overunderflow(true);
5812 +  
5813 +  TH1F *TZem  = allsamples.Draw("TZem",     mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSOF&&cutnJets,mc,luminosity,allsamples.FindSample("/TT"));
5814 +  TH1F *nTZem = allsamples.Draw("nTZem","-"+mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSOF&&cutnJets,mc,luminosity,allsamples.FindSample("/TT"));
5815 +  TH1F *TZeemm  = allsamples.Draw("TZeemm",     mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSSF&&cutnJets,mc,luminosity,allsamples.FindSample("/TT"));
5816 +  TH1F *nTZeemm = allsamples.Draw("nTZeemm","-"+mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSSF&&cutnJets,mc,luminosity,allsamples.FindSample("/TT"));
5817 +  
5818 +  TCanvas *tcan = new TCanvas("tcan","tcan");
5819 +  tcan->SetLogy(1);
5820 +  
5821 +  TZeemm->SetLineColor(kBlack);
5822 +  TZem->SetLineColor(kRed);
5823 +  TZeemm->SetMarkerColor(kBlack);
5824 +  TZem->SetMarkerColor(kRed);
5825 +  
5826 +  vector<TH1F*> histos;
5827 + //  TZem->GetXaxis()->SetRangeUser(-100,binning[binning.size()-1]);
5828 + //  TZeemm->GetXaxis()->SetRangeUser(-100,binning[binning.size()-1]);
5829 +  histos.push_back(TZem);
5830 +  histos.push_back(TZeemm);
5831 +  draw_all_ttbar_histos(tcan,histos,"histo",8);
5832 +  
5833 +  TLegend *leg = make_legend("MC t#bar{t}",0.6,0.65,false);
5834 +  leg->AddEntry(TZeemm,"SFZP","l");
5835 +  leg->AddEntry(TZem,"OFZP","l");
5836 +  leg->Draw("same");
5837 +  DrawMCPrelim();
5838 +  CompleteSave(tcan,"Systematics/TtbarTests/"+prestring+"/ttbar_shape_comparison");
5839 +  
5840 +  TH1F *TZemcopy = (TH1F*)TZem->Clone("TZemcopy");
5841 +  TH1F *TZeemmcopy = (TH1F*)TZeemm->Clone("TZeemmcopy");
5842 +  TH1F *TSeemmcopy;
5843 +  TH1F *TSemcopy;
5844 +  
5845 +  predicted=(TH1F*)TZem->Clone(((string)"predicted_"+prestring).c_str());
5846 +  observed=(TH1F*)TZeemm->Clone(((string)"observed_"+prestring).c_str());
5847 +  
5848 +  vector<float> posbinning;
5849 +  for(unsigned int i=0;i<binning.size();i++) {
5850 +    if(binning[i]<0) continue;
5851 +    posbinning.push_back(binning[i]);
5852 +  }
5853 +  
5854 +  TH1F *pred2 = new TH1F("pred2","pred2",posbinning.size()-1,&posbinning[0]);pred2->Sumw2();
5855 +  TH1F *obs2 = new TH1F("obs2","obs2",posbinning.size()-1,&posbinning[0]);obs2->Sumw2();
5856 +  
5857 +  for(unsigned int i=1;i<=predicted->GetNbinsX();i++) {
5858 +    int index=pred2->FindBin(abs(TZem->GetBinCenter(i)));
5859 +    if(TZem->GetBinCenter(i)<0) {
5860 +      //we're on the left: subtract em!
5861 +      pred2->SetBinContent(index,pred2->GetBinContent(index)-TZem->GetBinContent(i));
5862 +      pred2->SetBinError(index,sqrt(pow(pred2->GetBinError(index),2)+pow(TZem->GetBinError(i),2)));
5863 +      //we're on the left: add eemm!
5864 +      pred2->SetBinContent(index,pred2->GetBinContent(index)+TZeemm->GetBinContent(i));
5865 +      pred2->SetBinError(index,sqrt(pow(pred2->GetBinError(index),2)+pow(TZeemm->GetBinError(i),2)));
5866 +    } else {
5867 +      //we're on the right: add em!
5868 +      pred2->SetBinContent(index,pred2->GetBinContent(index)+TZem->GetBinContent(i));
5869 +      pred2->SetBinError(index,sqrt(pow(pred2->GetBinError(index),2)+pow(TZem->GetBinError(i),2)));
5870 +      //we're on the left: add eemm!
5871 +      obs2->SetBinContent(index,obs2->GetBinContent(index)+TZeemm->GetBinContent(i));
5872 +      obs2->SetBinError(index,sqrt(pow(pred2->GetBinError(index),2)+pow(TZeemm->GetBinError(i),2)));
5873 +    }
5874 +  }
5875 +  
5876 +  ratio2 = (TH1F*)pred2->Clone(((string)"ratio2_"+prestring).c_str());
5877 +  ratio2->Divide(obs2);
5878 +
5879 +  TZem->Divide(TZeemm);
5880 +  TZem->SetMarkerStyle(21);
5881 +
5882 +  TZem->SetTitle("OF / SF");
5883 +  ratio = (TH1F*)TZem->Clone(((string)"ratio_"+prestring).c_str());
5884 +  
5885 +  tcan->SetLogy(0);
5886 +  TZem->GetYaxis()->SetRangeUser(0,2.5);
5887 +  TZem->GetYaxis()->SetTitle("ratio");
5888 +  TZem->Draw();
5889 +  
5890 +  float linepos=emuncertOFFPEAK;
5891 +  
5892 +  TLine *top = new TLine(binning[0],1.0+linepos,binning[binning.size()-1],1.0+linepos);
5893 +  TLine *center = new TLine(binning[0],1.0,binning[binning.size()-1],1.0);
5894 +  TLine *bottom = new TLine(binning[0],1.0-linepos,binning[binning.size()-1],1.0-linepos);
5895 +  
5896 +  top->SetLineColor(kBlue);top->SetLineStyle(2);
5897 +  bottom->SetLineColor(kBlue);bottom->SetLineStyle(2);
5898 +  center->SetLineColor(kBlue);
5899 +  
5900 +  top->Draw("same");
5901 +  center->Draw("same");
5902 +  bottom->Draw("same");
5903 +  
5904 +  TLegend *leg2 = make_legend("MC t#bar{t}",0.55,0.75,false);
5905 +  leg2->AddEntry(TZem,"OFZP / SFZP","ple");
5906 +  leg2->AddEntry(bottom,"syst. envelope","l");
5907 +  leg2->SetX1(0.25);leg2->SetX2(0.6);
5908 +  leg2->SetY1(0.65);
5909 +  
5910 +  leg2->Draw("same");
5911 +  
5912 +  DrawMCPrelim();
5913 +  CompleteSave(tcan,"Systematics/TtbarTests/"+prestring+"/ttbar_shape_comparison_ratio");
5914 +  
5915 +  ratio2->SetLineColor(TZem->GetLineColor());
5916 +  ratio2->SetMarkerColor(TZem->GetMarkerColor());
5917 +  ratio2->GetYaxis()->SetRangeUser(0,2.5);
5918 +  ratio2->GetYaxis()->SetTitle("ratio");
5919 +  ratio2->Draw();
5920 +  
5921 +  TLine *top2 = new TLine(0,1.0+linepos,binning[binning.size()-1],1.0+linepos);
5922 +  TLine *center2 = new TLine(0,1.0,binning[binning.size()-1],1.0);
5923 +  TLine *bottom2 = new TLine(0,1.0-linepos,binning[binning.size()-1],1.0-linepos);
5924 +  
5925 +  top2->SetLineColor(kBlue);top->SetLineStyle(2);
5926 +  bottom2->SetLineColor(kBlue);bottom->SetLineStyle(2);
5927 +  center2->SetLineColor(kBlue);
5928 +  
5929 +  top2->Draw("same");
5930 +  center2->Draw("same");
5931 +  bottom2->Draw("same");
5932 +  
5933 +  leg2->Draw("same");
5934 +  
5935 +  DrawMCPrelim();
5936 +  CompleteSave(tcan,"Systematics/TtbarTests/"+prestring+"/ttbar_shape_comparison_FINALratio");
5937 +  
5938 +  delete TZem;
5939 +  delete nTZem;
5940 +  delete TZeemm;
5941 +  delete nTZeemm;
5942 +  delete obs2;
5943 +  delete pred2;
5944 +  delete tcan;
5945 +  switch_overunderflow(false);
5946 + }
5947 +
5948 + void IllustrateVariation(TH1F *vanilla_ratio, TH1F *response_only_up_ratio, TH1F *response_only_down_ratio, TH1F *reponse_plus_peak_up_ratio, TH1F *reponse_plus_peak_down_ratio, string PostString) {
5949 +    
5950 +  
5951 +  TCanvas *ttcan2 = new TCanvas("ttcan2","ttcan2");
5952 +  vanilla_ratio->GetYaxis()->SetRangeUser(0.5,1.5);
5953 +  vanilla_ratio->SetFillColor(kGreen);
5954 +  vanilla_ratio->SetLineColor(kGreen);
5955 +  vanilla_ratio->SetMarkerColor(kGreen);
5956 +  vanilla_ratio->SetFillStyle(3001);
5957 +  vanilla_ratio->Draw("e3");
5958 +  
5959 +  response_only_up_ratio->SetFillColor(kRed);
5960 +  response_only_up_ratio->SetMarkerColor(kRed);
5961 +  response_only_up_ratio->SetLineColor(kRed);
5962 +  response_only_up_ratio->SetFillStyle(3003);
5963 +  response_only_up_ratio->Draw("e3,same");
5964 +  
5965 +  response_only_down_ratio->SetFillColor(kOrange);
5966 +  response_only_down_ratio->SetMarkerColor(kOrange);
5967 +  response_only_down_ratio->SetLineColor(kOrange);
5968 +  response_only_down_ratio->SetFillStyle(3004);
5969 +  response_only_down_ratio->Draw("e3,same");
5970 +  
5971 +  reponse_plus_peak_up_ratio->SetFillColor(TColor::GetColor("#BDBDBD"));
5972 +  reponse_plus_peak_up_ratio->SetMarkerColor(TColor::GetColor("#BDBDBD"));
5973 +  reponse_plus_peak_up_ratio->SetLineColor(TColor::GetColor("#BDBDBD"));
5974 +  reponse_plus_peak_up_ratio->SetFillStyle(3005);
5975 +  reponse_plus_peak_up_ratio->Draw("e3,same");
5976 +  
5977 +  reponse_plus_peak_down_ratio->SetFillColor(kBlue);
5978 +  reponse_plus_peak_down_ratio->SetMarkerColor(kBlue);
5979 +  reponse_plus_peak_down_ratio->SetLineColor(kBlue);
5980 +  reponse_plus_peak_down_ratio->SetFillStyle(3006);
5981 +  reponse_plus_peak_down_ratio->Draw("e3,same");
5982 +  
5983 +  TLine *llow = new TLine(vanilla_ratio->GetBinLowEdge(1),1.0-emuncertOFFPEAK,vanilla_ratio->GetBinLowEdge(vanilla_ratio->GetNbinsX())+vanilla_ratio->GetBinWidth(vanilla_ratio->GetNbinsX()),1.0-emuncertOFFPEAK);
5984 +  TLine *lhi = new TLine(vanilla_ratio->GetBinLowEdge(1),1.0+emuncertOFFPEAK,vanilla_ratio->GetBinLowEdge(vanilla_ratio->GetNbinsX())+vanilla_ratio->GetBinWidth(vanilla_ratio->GetNbinsX()),1.0+emuncertOFFPEAK);
5985 +  TLine *lOne = new TLine(vanilla_ratio->GetBinLowEdge(1),1.0,vanilla_ratio->GetBinLowEdge(vanilla_ratio->GetNbinsX())+vanilla_ratio->GetBinWidth(vanilla_ratio->GetNbinsX()),1.0);
5986 +  
5987 +  TLine *llowA = new TLine(vanilla_ratio->GetBinLowEdge(1),1.0-0.07,vanilla_ratio->GetBinLowEdge(vanilla_ratio->GetNbinsX())+vanilla_ratio->GetBinWidth(vanilla_ratio->GetNbinsX()),1.0-0.07);
5988 +  TLine *lhiA = new TLine(vanilla_ratio->GetBinLowEdge(1),1.0+0.07,vanilla_ratio->GetBinLowEdge(vanilla_ratio->GetNbinsX())+vanilla_ratio->GetBinWidth(vanilla_ratio->GetNbinsX()),1.0+0.07);
5989 +  
5990 +  lhiA->SetLineColor(kRed);
5991 +  lhiA->SetLineStyle(2);
5992 +  llowA->SetLineColor(kRed);
5993 +  llowA->SetLineStyle(2);
5994 +  
5995 +  llow->SetLineColor(kBlue);
5996 +  llow->SetLineStyle(2);
5997 +  lhi->SetLineColor(kBlue);
5998 +  lhi->SetLineStyle(2);
5999 +  lOne->SetLineColor(kBlue);
6000 +  
6001 +  llow->Draw();
6002 +  lhi->Draw();
6003 +  lOne->Draw();
6004 +  
6005 +  llowA->Draw();
6006 +  lhiA->Draw();
6007 +  
6008 +  TLegend *leg = make_legend();
6009 +  leg->SetX1(0.15);
6010 +  leg->SetY1(0.7);
6011 +  leg->AddEntry(vanilla_ratio,"Raw JZB","pf");
6012 +  leg->AddEntry(response_only_up_ratio,"With response correction","pf");
6013 +  leg->AddEntry(response_only_down_ratio,"With inverted response correction","pf");
6014 +  leg->AddEntry(reponse_plus_peak_up_ratio,"With response and peak correction","pf");
6015 +  leg->AddEntry(reponse_plus_peak_down_ratio,"With response and inverted peak corr.","pf");
6016 +  leg->AddEntry(lhi,"Systematic envelope","l");
6017 + //  leg->SetNColumns(2);
6018 +  leg->Draw();
6019 +  
6020 +  CompleteSave(ttcan2,"Systematics/TtbarTests/Comparison"+PostString);
6021 +  
6022 +  vanilla_ratio->GetYaxis()->SetRangeUser(0.6,1.4);
6023 +  vanilla_ratio->Draw("e3");
6024 +  response_only_up_ratio->Draw("e3 same");
6025 +  response_only_down_ratio->Draw("e3 same");
6026 +  TLegend *leg2 = make_legend();
6027 +  leg2->SetX1(0.15);
6028 +  leg2->SetY1(0.7);
6029 +  leg2->AddEntry(vanilla_ratio,"Raw JZB","pf");
6030 +  leg2->AddEntry(response_only_up_ratio,"With response correction","pf");
6031 +  leg2->AddEntry(response_only_down_ratio,"With inverted response correction","pf");
6032 +  leg2->AddEntry(lhi,"Systematic envelope","l");
6033 +  leg2->Draw();
6034 +  llow->Draw();
6035 +  lOne->Draw();
6036 +  llowA->Draw();
6037 +  lhiA->Draw();
6038 +  
6039 +  CompleteSave(ttcan2,"Systematics/TtbarTests/Comparison_Response"+PostString);
6040 +  
6041 +  response_only_up_ratio->GetYaxis()->SetRangeUser(0.6,1.4);
6042 +  response_only_up_ratio->Draw("e3");
6043 +  reponse_plus_peak_up_ratio->Draw("e3 same");
6044 +  reponse_plus_peak_down_ratio->Draw("e3 same");
6045 +  TLegend *leg3 = make_legend();
6046 +  leg3->SetX1(0.15);
6047 +  leg3->SetY1(0.7);
6048 +  leg3->AddEntry(response_only_up_ratio,"With response correction","pf");
6049 +  leg3->AddEntry(reponse_plus_peak_up_ratio,"With response and peak correction","pf");
6050 +  leg3->AddEntry(reponse_plus_peak_down_ratio,"With response and inverted peak corr.","pf");
6051 +  leg3->AddEntry(lhi,"Systematic envelope","l");
6052 +  leg3->Draw();
6053 +  llow->Draw();
6054 +  lOne->Draw();
6055 +  llowA->Draw();
6056 +  lhiA->Draw();
6057 +  
6058 +  CompleteSave(ttcan2,"Systematics/TtbarTests/Comparison_Peak"+PostString);
6059 +  
6060 +  delete ttcan2;
6061 + }
6062 +
6063 + void ttbar_correction_tests() {
6064 +  TCanvas *ttcan = new TCanvas("ttcan","ttcan");
6065 +    
6066 +  TH1F *vanilla_observed, *response_only_up_observed, *response_only_down_observed, *reponse_plus_peak_up_observed, *reponse_plus_peak_down_observed;
6067 +  
6068 +  TH1F *vanilla_predicted, *response_only_up_predicted, *response_only_down_predicted, *reponse_plus_peak_up_predicted, *reponse_plus_peak_down_predicted;
6069 +  
6070 +  TH1F *vanilla_ratio, *response_only_up_ratio, *response_only_down_ratio, *reponse_plus_peak_up_ratio, *reponse_plus_peak_down_ratio;
6071 +  
6072 +  TH1F *vanilla_ratio2, *response_only_up_ratio2, *response_only_down_ratio2, *reponse_plus_peak_up_ratio2, *reponse_plus_peak_down_ratio2;
6073 +  
6074 +  string vanilla="jzb[1]";
6075 +  string response_only_up="((jzb[1]+0.034665*pt))";
6076 +  string response_only_down="((jzb[1]-0.034665*pt))";
6077 +  string reponse_plus_peak_up="((jzb[1]+0.034665*pt)- 3.58273 )";
6078 +  string reponse_plus_peak_down="((jzb[1]+0.034665*pt)+ 3.58273 )";
6079 +
6080 +  do_one_ttbar_test(vanilla_observed,vanilla_predicted,vanilla_ratio,vanilla_ratio2,vanilla,"vanilla");
6081 +  do_one_ttbar_test(response_only_up_observed,response_only_up_predicted,response_only_up_ratio,response_only_up_ratio2,response_only_up,"response_only_up");
6082 +  do_one_ttbar_test(response_only_down_observed,response_only_down_predicted,response_only_down_ratio,response_only_down_ratio2,response_only_down,"response_only_down");
6083 +  do_one_ttbar_test(reponse_plus_peak_up_observed,reponse_plus_peak_up_predicted,reponse_plus_peak_up_ratio,reponse_plus_peak_up_ratio2,reponse_plus_peak_up,"reponse_plus_peak_up");
6084 +  do_one_ttbar_test(reponse_plus_peak_down_observed,reponse_plus_peak_down_predicted,reponse_plus_peak_down_ratio,reponse_plus_peak_down_ratio2,reponse_plus_peak_down,"reponse_plus_peak_down");
6085 +  
6086 +  ttcan->cd();
6087 +  
6088 +  IllustrateVariation(vanilla_ratio,response_only_up_ratio,response_only_down_ratio,reponse_plus_peak_up_ratio,reponse_plus_peak_down_ratio,"PartialRatio");
6089 +  IllustrateVariation(vanilla_ratio2,response_only_up_ratio2,response_only_down_ratio2,reponse_plus_peak_up_ratio2,reponse_plus_peak_down_ratio2,"FullRatio");
6090 +  
6091 +  delete vanilla_observed;
6092 +  delete response_only_up_observed;
6093 +  delete response_only_down_observed;
6094 +  delete reponse_plus_peak_up_observed;
6095 +  delete reponse_plus_peak_down_observed;
6096 +  
6097 +  delete vanilla_predicted;
6098 +  delete response_only_up_predicted;
6099 +  delete response_only_down_predicted;
6100 +  delete reponse_plus_peak_up_predicted;
6101 +  delete reponse_plus_peak_down_predicted;
6102 +  
6103 +  delete vanilla_ratio;
6104 +  delete response_only_up_ratio;
6105 +  delete response_only_down_ratio;
6106 +  delete reponse_plus_peak_up_ratio;
6107 +  delete reponse_plus_peak_down_ratio;
6108 +  
6109 +  delete ttcan;
6110 + }
6111 +
6112 + void ttbar_region_search(string mcjzb) {
6113 +  cout << "Looking for a nice control region" << endl;
6114 +  TCanvas *can = new TCanvas("can","can",1200,1200);
6115 +  can->Divide(2,2);
6116 +  can->cd(1);
6117 +  can->cd(1)->SetLogy(1);
6118 +  
6119 +  THStack JZBdistSF = allsamples.DrawStack("JZBdistSF",mcjzb,100,-150,150, "JZB [GeV]", "events", cutmass&&cutOSSF&&TCut("pfJetGoodNum40==2"),mc, luminosity);
6120 +  THStack JZBdistOF = allsamples.DrawStack("JZBdistOF",mcjzb,100,-150,150, "JZB [GeV]", "events", cutmass&&cutOSOF&&TCut("pfJetGoodNum40==2"),mc, luminosity);
6121 +  
6122 +  JZBdistSF.Draw("histo");
6123 +  JZBdistSF.SetMaximum(1000);
6124 +  JZBdistSF.SetMinimum(0.1);
6125 +  JZBdistSF.Draw("histo");
6126 +  DrawMCPrelim();
6127 +  
6128 +  can->cd(2);
6129 +  can->cd(2)->SetLogy(1);
6130 +  JZBdistOF.Draw("histo");
6131 +  JZBdistOF.SetMaximum(1000);
6132 +  JZBdistOF.SetMinimum(0.1);
6133 +  JZBdistOF.Draw("histo");
6134 +  DrawMCPrelim();
6135 +  
6136 +  can->cd(3);
6137 +  
6138 +  
6139 +  write_warning(__FUNCTION__,"Missing negative JZB subtraction  ");
6140 +  
6141 +  DrawMCPrelim();
6142 +  
6143 +  /*
6144 +  THStack *Subtracted = new THStack();
6145 +  
6146 +  TIter nextSF(JZBdistSF.GetHists());
6147 +  TIter nextOF(JZBdistOF.GetHists());
6148 +  TObject* SFobj;
6149 +  TObject* OFobj;
6150 +  
6151 +  TH1* sfh = NULL;
6152 +  TH1* ofh = NULL;
6153 +  
6154 +  while ( (SFobj = nextSF()) && (OFobj = nextOF()) ) {
6155 +    TH1F *sfstart = (TH1*)SFobj->Clone();
6156 +    TH1F *ofstart = (TH1*)OFobj->Clone();
6157 +    TH1F *obs, *pred;
6158 +    MakeObservationPrediction(obs,pred,sfstart,ofstart);
6159      
6160 +    if ( !hratio ) {
6161 +      hratio = (TH1*)obj->Clone();
6162 +      hratio->SetName("hratio");
6163 +    } else hratio->Add( (TH1*)obj );
6164 +    
6165 +  }
6166 +  hratio->Divide(hdata);
6167 +  */
6168 +  
6169 +  
6170 +  can->cd(4);
6171 +  JZBdistOF.Draw("histo");
6172 +  DrawMCPrelim();
6173 +  
6174 +  
6175 +  
6176 +  CompleteSave(can,"Systematics/TtbarTests/ControlRegion");
6177 +  
6178 +  CleanLegends();
6179 +  delete can;
6180 + }
6181 +
6182 + void ttbar_tests(string mcjzb) {
6183 +  //ttbar_correction_tests();
6184 +  ttbar_region_search(mcjzb);
6185 + }
6186 +
6187 + Value GetYieldBetween(TH1F *h, float low, float high) {
6188 +  float Yield=0;
6189 +  float YieldErr=0;
6190 +  for(int i=1;i<=h->GetNbinsX()+1;i++) {
6191 +    if(h->GetBinLowEdge(i)+h->GetBinWidth(i)<=low) continue;// considered in the next bin
6192 +    if(h->GetBinLowEdge(i)>=high) continue;//above the threshold, out!
6193 +    Yield+=h->GetBinContent(i);
6194 +    YieldErr=sqrt(YieldErr*YieldErr+h->GetBinError(i)*h->GetBinError(i));
6195 +  }
6196 +  
6197 +  Value a(Yield,YieldErr);
6198 +  return a;
6199 + }
6200 +
6201 +
6202 + void make_SF_over_OF_plot(string datajzb, string mcjzb, TCut cut, string variable, int nbins, float xmin, float ymin, string varname, string filename) {
6203 +  TCanvas *SFoOF_can = new TCanvas("SFoOF_can","SFoOF_can");
6204 +  TH1F *data_sf = allsamples.Draw("data_sf","mll",20,0,200, "m_{ll} [GeV]", "events", cut&&cutOSSF,data,luminosity);
6205 +  TH1F *data_of = allsamples.Draw("data_of","mll",20,0,200, "m_{ll} [GeV]", "events", cut&&cutOSOF,data,luminosity);
6206 +  
6207 +  TH1F *mc_sf = allsamples.Draw("mc_sf","mll",20,0,200, "m_{ll} [GeV]", "events", cut&&cutOSSF,mc,luminosity);
6208 +  TH1F *mc_of = allsamples.Draw("mc_of","mll",20,0,200, "m_{ll} [GeV]", "events", cut&&cutOSOF,mc,luminosity);
6209 +  
6210 +  TH1F *mc_ratio = (TH1F*)mc_sf->Clone("mc_ratio");
6211 +  mc_ratio->Divide(mc_of);
6212 +  
6213 +  TH1F *data_ratio = (TH1F*)data_sf->Clone("data_ratio");
6214 +  data_ratio->Divide(data_of);
6215 +  
6216 +  mc_ratio->SetFillColor(TColor::GetColor("#00ADE1"));
6217 +  mc_ratio->SetMarkerColor(TColor::GetColor("#00ADE1"));
6218 +  mc_ratio->GetYaxis()->SetRangeUser(0.5,1.5);
6219 +  
6220 +  mc_ratio->GetYaxis()->SetTitle("R(SF / OF)");
6221 +  
6222 +  
6223 +  Value R_sf_of_low_mass = GetYieldBetween(data_sf,20,70)/GetYieldBetween(data_of,20,70);
6224 +  Value R_sf_of_high_mass = GetYieldBetween(data_sf,120,200)/GetYieldBetween(data_of,120,200);
6225 +  
6226 +  Value R_sf_of_low_mass_mc = GetYieldBetween(mc_sf,20,70)/GetYieldBetween(mc_of,20,70);
6227 +  Value R_sf_of_high_mass_mc = GetYieldBetween(mc_sf,120,200)/GetYieldBetween(mc_of,120,200);
6228 +  
6229 +  dout << "Ratio at low mass  : " << R_sf_of_low_mass  << " (mc : " << R_sf_of_low_mass_mc << " )" << endl;
6230 +  dout << "Ratio at high mass : " << R_sf_of_high_mass << " (mc : " << R_sf_of_high_mass_mc << " )" << endl;
6231 +  
6232 +  TGraphAsymmErrors *gra = produce_ratio_graph(mc_ratio);
6233 +  gra->Draw();
6234 +  mc_ratio->Draw();
6235 +  gra->Draw("e20");
6236 +  gra->SetFillColor(TColor::GetColor("#00ADE1"));
6237 +  gra->SetMarkerColor(TColor::GetColor("#00ADE1"));
6238 +  data_ratio->Draw("e1,same");
6239 +  
6240 +  TLegend *leg = new TLegend(0.17,0.16,0.53,0.31);
6241 + //   leg->SetHeader("R( SF / OF )");
6242 +  leg->SetFillColor(kWhite);
6243 +  leg->SetBorderSize(0);
6244 +  leg->AddEntry(data_ratio,"Data","p");
6245 +  leg->AddEntry(gra,"MC","fp");
6246 +  leg->Draw();
6247 +  
6248 +  TLine *g = new TLine(0,1.0,200,1.0);
6249 +  g->SetLineColor(kBlue);
6250 +  g->Draw();
6251 +  
6252 +  TLine *l = new TLine(70,0.5,70,1.5);
6253 +  l->SetLineStyle(2);
6254 +  l->SetLineColor(TColor::GetColor("#00ADE1"));
6255 +  TLine *m = new TLine(120,0.5,120,1.5);
6256 +  m->SetLineStyle(2);
6257 +  m->SetLineColor(TColor::GetColor("#00ADE1"));
6258 +  l->Draw();
6259 +  m->Draw();
6260 +  
6261 +  
6262 +  DrawPrelim();
6263 +  
6264 +  CompleteSave(SFoOF_can,"iTTbar/"+filename+"SF_vs_OF");
6265 +  
6266 +  delete leg;
6267 +  delete mc_sf;
6268 +  delete mc_of;
6269 +  delete mc_ratio;
6270 +  delete data_sf;
6271 +  delete data_of;
6272 +  delete data_ratio;
6273 +  delete SFoOF_can;
6274 + }  
6275 +
6276 + void make_iTTbar_JZB_plot(string datajzb, string mcjzb, TCut cut) {
6277 +  TCanvas *can = new TCanvas("can","can");
6278 +  vector<float> binning;
6279 +  binning.push_back(-100);
6280 +  binning.push_back(-50);
6281 +  binning.push_back(-20);
6282 +  binning.push_back(0);
6283 + //  binning.push_back(10);
6284 +  binning.push_back(20);
6285 + //  binning.push_back(30);
6286 +  binning.push_back(50);
6287 +  binning.push_back(100);
6288 +  binning.push_back(300);
6289 +  
6290 +  TH1F *hdata   = allsamples.Draw("hdata",  datajzb,    binning, "JZB [GeV]", "events", cut&&cutOSSF,data,luminosity);
6291 +  TH1F *hodata  = allsamples.Draw("hodata", datajzb,    binning, "JZB [GeV]", "events", cut&&cutOSOF,data,luminosity);
6292 +  TH1F *hndata  = allsamples.Draw("hndata", "-"+datajzb,binning, "JZB [GeV]", "events", cut&&cutOSSF,data,luminosity);
6293 +  TH1F *hnodata = allsamples.Draw("hnodata","-"+datajzb,binning, "JZB [GeV]", "events", cut&&cutOSOF,data,luminosity);
6294 +  
6295 +  TH1F *hmc   = allsamples.Draw("hmc",  datajzb,    binning, "JZB [GeV]", "events", cut&&cutOSSF,mc,luminosity);
6296 +  TH1F *homc  = allsamples.Draw("homc", datajzb,    binning, "JZB [GeV]", "events", cut&&cutOSOF,mc,luminosity);
6297 +  
6298 +  hodata->SetLineColor(kRed);
6299 +  hmc->SetLineColor(kRed);
6300 + //  hodata->Add(hndata);
6301 + //  hodata->Add(hnodata,-1);
6302 +  
6303 +  if(hdata->GetMaximum()>hodata->GetMaximum()) {
6304 +    hdata->SetMinimum(1.0);
6305 +    hdata->Draw();
6306 +    hodata->Draw("histo,same");
6307 +    hdata->Draw("same");
6308 +  } else {
6309 +    hodata->SetMinimum(1.0);
6310 +    hodata->Draw("histo");
6311 +    hdata->Draw("same");
6312 +  }
6313 +  
6314 +  CompleteSave(can,"iTTbar/JZB_plot");
6315 +  TH1F *ratio = (TH1F*)hdata->Clone("ratio");
6316 +  ratio->Divide(hodata);
6317 +  ratio->GetYaxis()->SetTitle("obs/pred");
6318 +  ratio->GetYaxis()->SetRangeUser(0,2);
6319 +  
6320 +  ratio->Draw();
6321 +  TLine *l = new TLine(-100,1.0,300,1.0);
6322 +  l->SetLineColor(kBlue);
6323 +  l->SetLineStyle(2);
6324 +  l->Draw();
6325 +  TLine *llow = new TLine(-100,1.0-0.07,300,1.0-0.07);
6326 +  TLine *lhi = new TLine(-100,1.0+0.07,300,1.0+0.07);
6327 +  llow->SetLineColor(kBlue);
6328 +  llow->SetLineStyle(2);
6329 +  llow->Draw();
6330 +  lhi->SetLineColor(kBlue);
6331 +  lhi->SetLineStyle(2);
6332 +  lhi->Draw();
6333 +  
6334 +  CompleteSave(can,"iTTbar/JZB_plot_ratio");
6335 +  
6336 +  delete hdata;
6337 +  delete hodata;
6338 +  delete ratio;
6339 +  delete can;
6340 + //  THStack *hmc = new THStack(allsamples.DrawStack("hmc","mll",40,0,200, "m_{ll} [GeV]", "events", cut&&cutOSSF,mc,luminosity));
6341 + //  THStack *homc = new THStack(allsamples.DrawStack("homc","mll",40,0,200, "m_{ll} [GeV]", "events", cut&&cutOSOF,mc,luminosity));
6342 + }
6343 +
6344 +  
6345 +  
6346 + void MakeSpecialiTTbarClosurePlot(TCut fullcut, string datajzb, string mcjzb, string MassRegion) {
6347 +  TCanvas *iTTbarClosureTestCanvas = new TCanvas("iTTbarClosureTestCanvas","iTTbarClosureTestCanvas");
6348 +  
6349 +  vector<float> binning;
6350 + /*
6351 +  binning.push_back(0);
6352 +  binning.push_back(20);
6353 +  binning.push_back(50);
6354 +  binning.push_back(100);
6355 + //  binning.push_back(200);
6356 + */
6357 +  binning.push_back(0);
6358 +  binning.push_back(10);
6359 +  binning.push_back(30);
6360 +  binning.push_back(50);
6361 +  binning.push_back(100);
6362 + //  binning.push_back(200);
6363 +  
6364 +  
6365 +  TH1F *hdata  = allsamples.Draw("hdata", datajzb,binning, "JZB [GeV]", "events", fullcut&&TCut("id1==id2"),data,luminosity);
6366 +  TH1F *hodata = allsamples.Draw("hodata",datajzb,binning, "JZB [GeV]", "events", fullcut&&TCut("id1!=id2"),data,luminosity);
6367 +  TH1F *hmc    = allsamples.Draw("hmc",   mcjzb,binning,   "JZB [GeV]", "events", fullcut&&TCut("id1==id2"),mc,luminosity);
6368 +  TH1F *homc   = allsamples.Draw("homc",  mcjzb,binning,   "JZB [GeV]", "events", fullcut&&TCut("id1!=id2"),mc,luminosity);
6369 +  
6370 +  hdata->SetLineColor(kBlack);
6371 +  hmc->SetLineColor(kBlack);
6372 +  hodata->SetLineColor(kRed);
6373 +  homc->SetLineColor(kRed);
6374 +  hodata->SetMarkerColor(kRed);
6375 +  
6376 +  hdata->GetYaxis()->SetTitle("events");
6377 +  
6378 +  float maximum=hdata->GetMaximum()+1.2*sqrt(hdata->GetMaximum());
6379 +  float minimum=hdata->GetMinimum()-1.2*sqrt(hdata->GetMinimum());
6380 +  if(hmc->GetMinimum()<minimum) minimum=hmc->GetMinimum()-1.2*sqrt(hmc->GetMinimum());
6381 +  if(hmc->GetMaximum()>maximum) maximum=hmc->GetMaximum()+1.2*sqrt(hmc->GetMaximum());
6382 +  if(homc->GetMinimum()<minimum) minimum=homc->GetMinimum()-1.2*sqrt(homc->GetMinimum());
6383 +  if(homc->GetMaximum()>maximum) maximum=homc->GetMaximum()+1.2*sqrt(homc->GetMaximum());
6384 +  if(hodata->GetMinimum()<minimum) minimum=hodata->GetMinimum()-1.2*sqrt(hodata->GetMinimum());
6385 +  if(hodata->GetMaximum()>maximum) maximum=hodata->GetMaximum()+1.2*sqrt(hodata->GetMaximum());
6386 +  
6387 +  hdata->SetMaximum(maximum);
6388 +  hdata->SetMinimum(minimum);
6389 +  
6390 +  
6391 +  hdata->Draw();
6392 +  hmc->Draw("same,histo");
6393 +  homc->Draw("same,histo");
6394 +  hdata->Draw("same");
6395 +  hodata->Draw("same");
6396 +  
6397 +  TLegend *leg = make_legend();
6398 +  leg->AddEntry(hdata,"SF data","pe");
6399 +  leg->AddEntry(hodata,"OF data","pe");
6400 +  leg->AddEntry(hmc,"SF MC","l");
6401 +  leg->AddEntry(homc,"OF MC","l");
6402 +  leg->Draw();
6403 +  
6404 +  DrawPrelim();
6405 +  
6406 +  CompleteSave(iTTbarClosureTestCanvas,"iTTbar/TTbar_CR_Closure_"+MassRegion);
6407 +  
6408 +  TH1F *ratio_data = (TH1F*)hdata->Clone("ratio_data");
6409 +  ratio_data->Divide(hodata);
6410 +  TH1F *ratio_mc = (TH1F*)hmc->Clone("ratio_mc");
6411 +  ratio_mc->Divide(homc);
6412 +  
6413 +  ratio_mc->SetFillColor(kBlue);
6414 +  ratio_mc->SetMarkerSize(0);
6415 +  
6416 +  TGraphAsymmErrors *eratio = produce_ratio_graph(ratio_mc);
6417 +  
6418 +  eratio->SetFillColor(TColor::GetColor("#00ADE1"));
6419 +  ratio_data->GetYaxis()->SetRangeUser(0.5,1.5);
6420 +  ratio_data->Draw("e1");
6421 +  eratio->Draw("20");
6422 +  ratio_data->Draw("e1,same");
6423 +  
6424 +  TLegend *leg2 = make_legend();
6425 +  leg2->AddEntry(ratio_data,"R(SF/OF) in #bar{t}t CR, data","pe");
6426 +  leg2->AddEntry(eratio    ,"R(SF/OF) in #bar{t}t CR, MC"  ,"f");
6427 +  leg2->SetY1(0.8);
6428 +  leg2->SetX1(0.45);
6429 +  leg2->Draw();
6430 +  
6431 +  DrawPrelim();
6432 +  CompleteSave(iTTbarClosureTestCanvas,"iTTbar/TTbar_CR_Closure_Ratio_"+MassRegion);
6433 +  
6434 +  TFile *f = new TFile("fout.root","RECREATE");
6435 +  eratio->Write();
6436 +  ratio_data->Write();
6437 +  leg2->Write();
6438 +  f->Close();
6439 +  
6440 +  
6441 +  delete leg;
6442 +  delete leg2;
6443 +  delete ratio_data;
6444 +  delete ratio_mc;
6445 +  delete hdata;
6446 +  delete hmc;
6447 +  delete hodata;
6448 +  delete iTTbarClosureTestCanvas;
6449 + }
6450 +  
6451 +  
6452 +  
6453 + void make_ijzb_ttbar_closure_test(string datajzb, string mcjzb) {
6454 +  TCut tt_nJets("pfJetGoodNum40==2");
6455 +  TCut tt_bJet("pfJetGoodNumBtag40==2 && met[4]>10");
6456 +  TCut tt_LowMass("mll>20&&mll<70");
6457 +  TCut tt_HighMass("mll>120&&mll<200");
6458 +  TCut tt_noZ(tt_LowMass || tt_HighMass);
6459 +  
6460 +  /*
6461 +  make_iTTbar_JZB_plot(datajzb, mcjzb,tt_nJets&&tt_bJet&&tt_noZ);
6462 + */
6463 +  TCanvas *can = new TCanvas("can","can");
6464 +
6465 +  TH1F *hdata  =                allsamples.Draw(        "hdata", "mll",40,0,200, "m_{ll} [GeV]", "events", tt_nJets&&tt_bJet&&tt_noZ&&cutOSSF,data,luminosity);
6466 +  THStack *hmc = new THStack(   allsamples.DrawStack(   "hmc",   "mll",40,0,200, "m_{ll} [GeV]", "events", tt_nJets&&tt_bJet&&tt_noZ&&cutOSSF,mc,  luminosity));
6467 +  TH1F *hodata =                allsamples.Draw(        "hodata","mll",40,0,200, "m_{ll} [GeV]", "events", tt_nJets&&tt_bJet&&tt_noZ&&cutOSOF,data,luminosity);
6468 +  THStack *homc = new THStack(  allsamples.DrawStack(   "homc",  "mll",40,0,200, "m_{ll} [GeV]", "events", tt_nJets&&tt_bJet&&tt_noZ&&cutOSOF,mc,  luminosity));
6469 +  
6470 +  TH1F *coll_hmc = CollapseStack(hmc);
6471 +  TH1F *coll_homc = CollapseStack(homc);
6472 +  
6473 +  bool dolog=true;
6474 +  bool nolog=false;
6475 +  
6476 +  dout << " SF: " << endl;
6477 +  dout << "   Data : " << hdata->Integral() << endl;
6478 +  WriteYield(hmc, 0, 10000);
6479 +  dout << " OF: " << endl;
6480 +  dout << "   Data : " << hodata->Integral() << endl;
6481 +  WriteYield(homc, 0, 10000);
6482 +  hodata->SetLineColor(kRed);
6483 +  hdata->Draw();
6484 +  hmc->Draw("histo,same");
6485 +  hodata->Draw("histo,same");
6486 +  hdata->Draw("e1,same");
6487 +  DrawPrelim();
6488 +  CompleteSave(can,"TestingPrediction");
6489 +  
6490 +  dout << "We get an expected ratio of " << coll_hmc->Integral()/coll_homc->Integral() << endl;
6491 +  dout << "In data we find  " << hdata->Integral()/hodata->Integral() << endl;
6492 +  
6493 +  Value R_sf_of_low_mass = GetYieldBetween(hdata,20,70)/GetYieldBetween(hodata,20,70);
6494 +  Value R_sf_of_high_mass = GetYieldBetween(hdata,120,200)/GetYieldBetween(hodata,120,200);
6495 +  
6496 +  Value R_sf_of_low_mass_mc = GetYieldBetween(coll_hmc,20,70)/GetYieldBetween(coll_homc,20,70);
6497 +  Value R_sf_of_high_mass_mc = GetYieldBetween(coll_hmc,120,200)/GetYieldBetween(coll_homc,120,200);
6498 +  
6499 +  dout << "Ratio at low mass  : " << R_sf_of_low_mass  << " (mc : " << R_sf_of_low_mass_mc << " )" << endl;
6500 +  dout << "Ratio at high mass : " << R_sf_of_high_mass << " (mc : " << R_sf_of_high_mass_mc << " )" << endl;
6501 +  
6502 +  dout << "Composition at low mass : " << endl;
6503 +  dout << "Same flavor: " << endl;
6504 +  ProduceYields(20, 70, hdata, hmc);
6505 +  dout << "Opposite flavor: " << endl;
6506 +  ProduceYields(20, 70, hodata, homc);
6507 +  
6508 +  dout << endl << endl;
6509 +  
6510 +  dout << "Composition at high mass : " << endl;
6511 +  dout << "Same flavor: " << endl;
6512 +  ProduceYields(120, 200, hdata, hmc);
6513 +  dout << "Opposite flavor: " << endl;
6514 +  ProduceYields(120, 200, hodata, homc);
6515 +  
6516 +  
6517 +
6518 +  
6519 +  make_plain_kin_plot(mcjzb,(const char*) (tt_nJets&&tt_bJet&&tt_noZ&&cutOSSF),20,-200,200,dolog,"JZB","iTTbar/JZB_SF",false,true);
6520 +  make_plain_kin_plot(mcjzb,(const char*) (tt_nJets&&tt_bJet&&tt_noZ&&cutOSOF),20,-200,200,dolog,"JZB","iTTbar/JZB_OF",false,true);
6521 +
6522 +  make_plain_kin_plot("mll",(const char*) (tt_nJets&&tt_bJet&&tt_noZ&&cutOSSF),40,0,200,nolog,"m_{ll} [GeV]","iTTbar/mll_SF",false,true);
6523 +  make_plain_kin_plot("mll",(const char*) (tt_nJets&&tt_bJet&&tt_noZ&&cutOSOF),40,0,200,nolog,"m_{ll} [GeV]","iTTbar/mll_OF",false,true);
6524 +  
6525 +  make_SF_over_OF_plot(datajzb, mcjzb,tt_nJets&&tt_bJet&&tt_noZ,"mll",20,0,200,"m_{ll} [GeV]","mll");
6526 +  
6527 +  MakeSpecialiTTbarClosurePlot((tt_nJets&&tt_bJet&&tt_LowMass),datajzb,mcjzb,"LowMassRegion2070");
6528 +  MakeSpecialiTTbarClosurePlot((tt_nJets&&tt_bJet&&tt_HighMass),datajzb,mcjzb,"HighMassRegion");
6529 +  MakeSpecialiTTbarClosurePlot((tt_nJets&&tt_bJet&&tt_noZ),datajzb,mcjzb,"NoZ");
6530 +  
6531 + //   make_plain_kin_plot("pfJetGoodNum40",(const char*) (tt_nJets&&tt_bJet&&tt_noZ&&cutOSSF),10,-0.5,9.5,dolog,"n_{jets}","iTTbar/nJets_SF",false,true);
6532 + //   make_plain_kin_plot("pfJetGoodNum40",(const char*) (tt_nJets&&tt_bJet&&tt_noZ&&cutOSOF),10,-0.5,9.5,dolog,"n_{jets}","iTTbar/nJets_OF",false,true);
6533 + //  
6534 + //   make_plain_kin_plot("pfJetGoodNumBtag40",(const char*) (tt_nJets&&tt_bJet&&tt_noZ&&cutOSSF),10,-0.5,9.5,dolog,"n_{btags}","iTTbar/nBtags_SF",false,true);
6535 + //   make_plain_kin_plot("pfJetGoodNumBtag40",(const char*) (tt_nJets&&tt_bJet&&tt_noZ&&cutOSOF),10,-0.5,9.5,dolog,"n_{btags}","iTTbar/nBtags_OF",false,true);
6536 +  
6537 +  
6538 +  delete coll_hmc;
6539 +  delete coll_homc;
6540 +  delete hmc;
6541 +  delete homc;
6542 +  delete hdata;
6543 +  delete hodata;
6544 +  delete can;
6545 + }
6546 +
6547 + void compute_global_significance(float local_significance) {
6548 +    float global_sigificance = ROOT::Math::normal_quantile_c(ROOT::Math::normal_cdf_c(local_significance,1)*4,1);
6549 +    dout << "local significance  : " << local_significance << endl;
6550 +    dout << "global significance : " << global_sigificance << endl;
6551 + }
6552 +  
6553  
6554   void test() {
6555    
6556 +  
6557 +  float MCPeak, MCPeakError, DataPeak, DataPeakError;
6558 +  stringstream result, datajzb, mcjzb;
6559 +  bool doPUreweighting=true;
6560 +  bool SwitchOffNJetsCut=false;
6561 +  
6562 +  
6563 +  TCanvas *can = new TCanvas("can","can");
6564 +  float mcSigma,mcSigmaError,dataSigma,dataSigmaError;
6565 +  
6566 +  float NumVtxBin[6] = {0,5,10,15,20,30};
6567 +  
6568 +  stringstream NowCut;
6569 +  
6570 +  TGraphErrors *gMCPeak = new TGraphErrors();
6571 +  gMCPeak->SetTitle("gMCPeak");
6572 +  gMCPeak->SetName("gMCPeak");
6573 +  TGraphErrors *gDataPeak = new TGraphErrors();
6574 +  gDataPeak->SetTitle("gDataPeak");
6575 +  gDataPeak->SetName("gDataPeak");
6576 +  TGraphErrors *gMCWidth = new TGraphErrors();
6577 +  gMCWidth->SetTitle("gMCWidth");
6578 +  gMCWidth->SetName("gMCWidth");
6579 +  TGraphErrors *gDataWidth = new TGraphErrors();
6580 +  gDataWidth->SetTitle("gDataWidth");
6581 +  gDataWidth->SetName("gDataWidth");
6582 +  
6583 +  float AllMCPeaks[200];
6584 +  float AllMCPeaksErrors[200];
6585 +  
6586 +  for(int i=10;i<180;i+=20) {
6587 +    NowCut.str("");
6588 +    NowCut << "mll>=" << i << "&&mll<" << i+20;
6589 +    find_one_peak_combination(TCut(NowCut.str().c_str()),SwitchOffNJetsCut,MCPeak,MCPeakError, DataPeak,DataPeakError,mcSigma,mcSigmaError, dataSigma,dataSigmaError,result,doPUreweighting,"");
6590 +    AllMCPeaks[i]=MCPeak;
6591 +    AllMCPeaksErrors[i]=MCPeakError;
6592 +  }
6593 +  
6594 +  dout << "Summary : " << endl;
6595 +  for(int i=10;i<180;i+=20) {
6596 +    dout << "For the slice at [" << i << " , " << i+20 << "] we get a peak at " << AllMCPeaks[i] << " +/- " << AllMCPeaksErrors[i] << endl;
6597 +  }
6598 +  /*
6599    TCanvas *testcanv = new TCanvas("testcanv","testcanv");
6600    testcanv->cd();
6601   //  switch_overunderflow(true);
6602 <  TH1F *ptdistr   = allsamples.Draw("ptdistr","pt1",100,30,200, "p_{T} [GeV]", "events", cutOSSF,data,luminosity);
6603 <  switch_overunderflow(false);
6604 <  ptdistr->Draw();
6605 <  testcanv->SaveAs("test.png");
6606 <  dout << "HELLO there!" << endl;
6602 >  TH1F *histo1 = new TH1F("histo","histo",100,0,1);
6603 >  histo1->Sumw2();
6604 >  TH1F *histo2 = new TH1F("histo2","histo2",100,0,1);
6605 >  histo2->Sumw2();
6606 >  
6607 >  for(int i=0;i<100;i++) {
6608 >    histo1->Fill(1.0/i,i);
6609 >    histo2->Fill(1.0/(i*i),i);
6610 >  }
6611 >
6612 >  histo1->Draw();
6613 >  histo2->Draw("e1,same");
6614    
6615 +  Save_With_Ratio( histo1, histo2, testcanv->cd(), "Bullshit", false, false, "AnyCrap" );
6616 +  
6617 +  
6618 +  dout << "HELLO there!" << endl;
6619 +  */
6620   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines