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.35 by buchmann, Mon Jul 9 16:26:00 2012 UTC vs.
Revision 1.67 by buchmann, Fri Sep 14 10:18:31 2012 UTC

# Line 33 | Line 33 | void todo() {
33  
34  
35  
36 < void find_one_peak_combination(TCut specialcut, float &MCPeak,float &MCPeakError, float &DataPeak, float &DataPeakError, float &MCSigma, float &DataSigma, stringstream &result, bool doPUreweighting = true, string saveas="")
36 > 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="")
37   {
38    // Temporarily switch off PU reweighting, if asked
39    TCut weightbackup=cutWeight;
# Line 42 | Line 42 | void find_one_peak_combination(TCut spec
42    int nbins=100;
43    if(PlottingSetup::DoBTag) nbins=25;
44    
45 +  TCut nJetsCut(cutnJets);
46 +  if(SwitchOffNJetsCut) nJetsCut=specialcut;
47 +  
48    TCanvas *tempcan = new TCanvas("tempcan","Temporary canvas for peak finding preparations");
49 <  TH1F *rawJZBeemmMC      = allsamples.Draw("rawJZBeemmMC",jzbvariablemc,nbins,-50,50, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&specialcut,mc, luminosity);
50 <  TH1F *rawJZBeemmData    = allsamples.Draw("rawJZBeemmData",jzbvariabledata,nbins, -50,50, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&specialcut,data, luminosity);
51 <  TH1F *rawJZBemMC      = allsamples.Draw("rawJZBemMC",jzbvariablemc,nbins,-50,50, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&specialcut,mc, luminosity);
52 <  TH1F *rawJZBemData    = allsamples.Draw("rawJZBemData",jzbvariabledata,nbins, -50,50, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&specialcut,data, luminosity);
49 >  TH1F *rawJZBeemmMC      = allsamples.Draw("rawJZBeemmMC",jzbvariablemc,nbins,-50,50, "JZB [GeV]", "events", cutmass&&cutOSSF&&nJetsCut&&specialcut,mc, luminosity);
50 >  TH1F *rawJZBeemmData    = allsamples.Draw("rawJZBeemmData",jzbvariabledata,nbins, -50,50, "JZB [GeV]", "events", cutmass&&cutOSSF&&nJetsCut&&specialcut,data, luminosity);
51 >  TH1F *rawJZBemMC      = allsamples.Draw("rawJZBemMC",jzbvariablemc,nbins,-50,50, "JZB [GeV]", "events", cutmass&&cutOSOF&&nJetsCut&&specialcut,mc, luminosity);
52 >  TH1F *rawJZBemData    = allsamples.Draw("rawJZBemData",jzbvariabledata,nbins, -50,50, "JZB [GeV]", "events", cutmass&&cutOSOF&&nJetsCut&&specialcut,data, luminosity);
53    TH1F *rawttbarjzbeemmMC;
54  
55    if(method==doKM) {
56      //we only need this histo for the KM fitting...
57 <    rawttbarjzbeemmMC = allsamples.Draw("rawttbarjzbeemmMC",jzbvariablemc,nbins, -50,50, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets&&specialcut,mc,luminosity,allsamples.FindSample("TTJet"));
58 <    MCPeak=find_peak(rawJZBeemmMC, rawttbarjzbeemmMC, -40, 40, mc, MCPeakError,MCSigma,method,saveas);
59 <    DataPeak=find_peak(rawJZBeemmData, rawJZBeemmData, -40, 40, data, DataPeakError,DataSigma,method,saveas);
57 >    rawttbarjzbeemmMC = allsamples.Draw("rawttbarjzbeemmMC",jzbvariablemc,nbins, -50,50, "JZB [GeV]", "events",cutmass&&cutOSSF&&nJetsCut&&specialcut,mc,luminosity,allsamples.FindSample("TTJet"));
58 >    MCPeak=find_peak(rawJZBeemmMC, rawttbarjzbeemmMC, -40, 40, mc, MCPeakError,MCSigma,MCSigmaError,method,saveas);
59 >    DataPeak=find_peak(rawJZBeemmData, rawJZBeemmData, -40, 40, data, DataPeakError,DataSigma,DataSigmaError,method,saveas);
60      delete rawttbarjzbeemmMC;
61    }
62    else {
# Line 62 | Line 65 | void find_one_peak_combination(TCut spec
65      reducedMC->Add(rawJZBemMC,-1);
66      reducedData->Add(rawJZBemData,-1);
67      //this is Kostas' way of doing it - we subtract em to get rid of some of the ttbar contribution (in reality, of flavor-symmetric contribution)
68 <    MCPeak=find_peak(reducedMC, rawttbarjzbeemmMC, -40, 40, mc, MCPeakError,MCSigma,method,saveas);
69 <    DataPeak=find_peak(reducedData, rawJZBeemmData, -40, 40, data, DataPeakError,DataSigma,method,saveas);
68 >    MCPeak=find_peak(reducedMC, rawttbarjzbeemmMC, -40, 40, mc, MCPeakError,MCSigma,MCSigmaError,method,saveas);
69 >    DataPeak=find_peak(reducedData, rawJZBeemmData, -40, 40, data, DataPeakError,DataSigma,DataSigmaError,method,saveas);
70      delete reducedMC;
71      delete reducedData;
72    }
# Line 73 | Line 76 | void find_one_peak_combination(TCut spec
76      
77   //  MCPeak=find_peak(rawJZBeemmMC, rawttbarjzbeemmMC, -40, 40, mc, MCPeakError,MCSigma,method);
78   //  DataPeak=find_peak(rawJZBeemmData, rawJZBeemmData, -40, 40, data, DataPeakError,DataSigma,method);
79 <  dout   << "   We have found the peak in Data at " << DataPeak << " +/- " << DataPeakError << " with sigma=" << DataSigma << " +/- ?? (not impl.)" << endl;
80 <  result << "   We have found the peak in Data at " << DataPeak << " +/- " << DataPeakError << " with sigma=" << DataSigma << " +/- ?? (not impl.)" << endl;
81 <  dout   << "   We have found the peak in MC at " << MCPeak << " +/- " << MCPeakError << " with sigma=" << MCSigma << " +/- ?? (not impl.)" << endl;
82 <  result << "   We have found the peak in MC at " << MCPeak << " +/- " << MCPeakError << " with sigma=" << MCSigma << " +/- ?? (not impl.)" << endl;
79 >  dout   << "   We have found the peak in Data at " << DataPeak << " +/- " << DataPeakError << " with sigma=" << DataSigma << " +/- " << DataSigmaError << endl;
80 >  result << "   We have found the peak in Data at " << DataPeak << " +/- " << DataPeakError << " with sigma=" << DataSigma << " +/- " << DataSigmaError << endl;
81 >  dout   << "   We have found the peak in MC at " << MCPeak << " +/- " << MCPeakError << " with sigma=" << MCSigma << " +/- " << MCSigmaError << endl;
82 >  result << "   We have found the peak in MC at " << MCPeak << " +/- " << MCPeakError << " with sigma=" << MCSigma << " +/- " << MCSigmaError << endl;
83    delete rawJZBeemmData;
84    delete rawJZBeemmMC;
85    delete rawJZBemData;
# Line 84 | Line 87 | void find_one_peak_combination(TCut spec
87    delete tempcan;
88   }
89  
90 < void find_peaks(float &MCPeak,float &MCPeakError, float &DataPeak, float &DataPeakError, stringstream &result, bool doPUreweighting, stringstream &datajzb, stringstream &mcjzb)
90 > void find_peaks(float &MCPeak,float &MCPeakError, float &DataPeak, float &DataPeakError, stringstream &result, bool doPUreweighting, stringstream &datajzb, stringstream &mcjzb, string sSpecialCut="", bool SwitchOffNJetsCut=false)
91   {
92 +  bool overunderflowstatus=addoverunderflowbins;
93 +  switch_overunderflow(false);
94 +  
95 +  TCut SpecialCut("mll>=0");
96 +  if(sSpecialCut!="") SpecialCut=TCut(sSpecialCut.c_str());
97    
98    bool DoInvidualeemmPeaks=false;
99    
# Line 98 | Line 106 | void find_peaks(float &MCPeak,float &MCP
106    float datammpeak,dataeepeak;
107    float datammpeakerr,dataeepeakerr;
108    
109 <  float mcSigma, dataSigma;
109 >  float mcSigma,mcSigmaError, dataSigma, dataSigmaError;
110    
111    dout << "Finding global peak : " << endl;
112 <  find_one_peak_combination(TCut(""),mcpeak,mcpeakerr, datapeak,datapeakerr,mcSigma, dataSigma,result,doPUreweighting,"");
112 >  find_one_peak_combination(SpecialCut,SwitchOffNJetsCut,mcpeak,mcpeakerr, datapeak,datapeakerr,mcSigma,mcSigmaError, dataSigma,dataSigmaError,result,doPUreweighting,"");
113    
114    if(DoInvidualeemmPeaks) {
115      dout << "Finding peak for electrons : " << endl;
116 <    find_one_peak_combination(TCut("id1==0"),mceepeak,mceepeakerr, dataeepeak,dataeepeakerr,mcSigma, dataSigma,result,doPUreweighting,"_ele");
116 >    find_one_peak_combination(SpecialCut&&TCut("id1==0"),SwitchOffNJetsCut,mceepeak,mceepeakerr,dataeepeak,dataeepeakerr,mcSigma,mcSigmaError,dataSigma,dataSigmaError,result,doPUreweighting,"_ele");
117      dout << "Finding peak for muons : " << endl;
118 <    find_one_peak_combination(TCut("id1==1"),mcmmpeak,mcmmpeakerr, datammpeak,datammpeakerr,mcSigma, dataSigma,result,doPUreweighting,"_mu");
118 >    find_one_peak_combination(SpecialCut&&TCut("id1==1"),SwitchOffNJetsCut,mcmmpeak,mcmmpeakerr,datammpeak,datammpeakerr,mcSigma,mcSigmaError,dataSigma,dataSigmaError,result,doPUreweighting,"_mu");
119      
120      datajzb << "(" << jzbvariabledata;
121      mcjzb << "(" << jzbvariablemc;
# Line 133 | Line 141 | void find_peaks(float &MCPeak,float &MCP
141      else mcjzb << "+ (id1!=id2)*" << TMath::Abs(mcpeak) << " ";
142      
143      mcjzb << ")";
144 +    
145    } else {
146      datajzb << "(" << jzbvariabledata;
147        mcjzb << "(" << jzbvariablemc;
# Line 147 | Line 156 | void find_peaks(float &MCPeak,float &MCP
156      
157      mcjzb << ")";
158    }
150    
159    
160 +    MCPeak=mcpeak;
161 +    MCPeakError=mcpeakerr;
162 +    DataPeak=datapeak;
163 +    DataPeakError=datapeakerr;
164 +    switch_overunderflow(overunderflowstatus);
165   }
166  
167 < void make_special_obs_pred_mll_plot(string datajzb, string mcjzb, float jzbthreshold) {
167 > void make_special_obs_pred_mll_plot(string datajzb, string mcjzb, float jzbthreshold, float binWidth = 5.0) {
168    float min=70.0;
169    float max=115.0;
170    if(!PlottingSetup::RestrictToMassPeak) {
171      min=20;
172 <    max=200;
172 >    max=300;
173    }
174 <  int nbins=int((max-min)/5);
174 >  int nbins=int((max-min)/binWidth);
175    
176    TCanvas *ckin = new TCanvas("ckin","Kinematic Plots (in the making)",600,600);
177    
# Line 188 | Line 201 | void make_special_obs_pred_mll_plot(stri
201    
202   //  TH1F *RcorrJZBeemmNoS;
203  
204 <  if(PlottingSetup::RestrictToMassPeak) {
204 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
205      RcorrJZBSBem   = allsamples.Draw("RcorrJZBSBem",  "mll",nbins,min,max, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets&&largerzeroD,data, luminosity);
206      LcorrJZBSBem   = allsamples.Draw("LcorrJZBSBem",  "mll",nbins,min,max, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets&&smallerzeroD,data, luminosity);
207      RcorrJZBSBeemm = allsamples.Draw("RcorrJZBSBeemm","mll",nbins,min,max, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets&&largerzeroD,data, luminosity);
208      LcorrJZBSBeemm = allsamples.Draw("LcorrJZBSBeemm","mll",nbins,min,max, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets&&smallerzeroD,data, luminosity);
209    }
210    
211 <  TH1F *Bpred = (TH1F*)LcorrJZBeemm->Clone("Bpred");
212 <  if(PlottingSetup::RestrictToMassPeak) {
213 <    Bpred->Add(RcorrJZBem,1.0/3.);
214 <    Bpred->Add(LcorrJZBem,-1.0/3.);
215 <    Bpred->Add(RcorrJZBSBem,1.0/3.);
216 <    Bpred->Add(LcorrJZBSBem,-1.0/3.);
217 <    Bpred->Add(RcorrJZBSBeemm,1.0/3.);
218 <    Bpred->Add(LcorrJZBSBeemm,-1.0/3.);
219 <  } else {
220 <    Bpred->Add(RcorrJZBem,1.0);
221 <    Bpred->Add(LcorrJZBem,-1.0);
222 <  }
223 <  
211 >  // Separate predictions
212 >  TH1F* SFN = (TH1F*)LcorrJZBeemm->Clone("SFN");
213 >  TH1F* OFP = (TH1F*)RcorrJZBem->Clone("OFP");
214 >  TH1F* OFN = (TH1F*)LcorrJZBem->Clone("OFN");
215 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
216 >    OFP->Scale(1.0/3.0);
217 >    OFP->Add(RcorrJZBSBem,1.0/3.);
218 >    OFP->Add(RcorrJZBSBeemm,1.0/3.);
219 >    OFN->Scale(1.0/3.0);
220 >    OFN->Add(LcorrJZBSBem,1.0/3.);
221 >    OFN->Add(LcorrJZBSBeemm,1.0/3.);
222 >  }
223 >
224 >  TH1F* Bpred = (TH1F*)SFN->Clone("Bpred");
225 >  Bpred->Add(OFP);
226 >  Bpred->Add(OFN,-1);
227    Bpred->SetLineColor(kRed);
228    
229 +  RcorrJZBeemm->SetTitleOffset(1.3,"y");
230    RcorrJZBeemm->Draw();
231    mcRcorrJZBeemm.Draw("same");
232    Bpred->Draw("histo,same");
# Line 225 | Line 242 | void make_special_obs_pred_mll_plot(stri
242    saveas << "kin/Mll_After_Cut/Cut_At" << jzbthreshold;
243    CompleteSave(ckin,saveas.str());
244    
245 <  
245 >  // Draw all predictions overlayed
246 >  unsigned int w = gStyle->GetHistLineWidth()+1; // Make line a bit wider, since we dash it
247 >  SFN->SetLineColor(kGreen+2);
248 >  SFN->SetLineStyle(2);
249 >  SFN->SetLineWidth(w);
250 >  OFP->SetLineColor(kBlue+2);
251 >  OFP->SetLineStyle(2);
252 >  OFP->SetLineWidth(w);
253 >  OFN->SetLineColor(kMagenta+2);
254 >  OFN->SetLineStyle(3);
255 >  OFN->SetLineWidth(w);
256    
257    RcorrJZBeemm->Draw();
258 +  SFN->Draw("histo,same");
259 +  OFP->Draw("histo,same");
260 +  OFN->Draw("histo,same");
261    Bpred->Draw("histo,same");
262    RcorrJZBeemm->Draw("same");
263    
264 <  TLegend *leg2 = make_legend();
265 <  leg2->SetX1(0.58);
236 <  leg2->AddEntry(RcorrJZBeemm,"observed (data)","l");
264 >  TLegend *leg2 = make_legend("",0.52,0.7);
265 >  leg2->AddEntry(RcorrJZBeemm,"observed (data)","lp");
266    leg2->AddEntry(Bpred,"predicted (data)","l");
267 +  leg2->AddEntry(SFN,  "  SF JZB<0","l");
268 +  leg2->AddEntry(OFN,  "  OF JZB<0","l");
269 +  leg2->AddEntry(OFP,  "  OF JZB>0","l");
270    leg2->Draw("same");
271    
272    saveas.str("");
273    saveas << "kin/Mll_After_Cut/Cut_At" << jzbthreshold << "_nomc";
274    CompleteSave(ckin,saveas.str());
275    
244  
245
276    delete RcorrJZBeemm;
277    delete LcorrJZBeemm;
278    delete RcorrJZBem;
279    delete LcorrJZBem;
280 <  if(PlottingSetup::RestrictToMassPeak) {
280 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
281      delete RcorrJZBSBeemm;
282      delete LcorrJZBSBeemm;
283      delete RcorrJZBSBem;
# Line 341 | Line 371 | void draw_ratio_plot(TH1* hdata, THStack
371    oneline->Draw("same");
372   }
373  
374 + float make_one_OFSF_plot(string variable, string addcut, string legendTitle, int nbins, float min, float max, float ymax, bool logscale,
375 +                        string xlabel, string filename, float legendPosition=0.55) {
376 +
377 +  TCut ibasiccut=basiccut;
378 +  bool draw_separation_lines=false;
379 +
380 +  if(addcut != "") ibasiccut = ibasiccut && addcut.c_str();
381 +
382 +  TCut cutSF;
383 +  TCut cutOF;
384 +
385 +  cutOF = cutOSOF&&cutnJets&&ibasiccut;
386 +  cutSF = cutOSSF&&cutnJets&&ibasiccut;
387 +
388 +  TCanvas *ckin = new TCanvas("ckin","Kinematic Plots (in the making)",600,600);
389 +  TPad* rcan = new TPad("rcan","rcan",0,0,1,1);
390 +  rcan->SetLogy(logscale);
391 +  rcan->cd();
392 +
393 +  std::cout << "OF/SF comparison: variable = " << variable << ", cut = " << cutSF.GetTitle() << std::endl;
394 +  TH1F *datahistoSF = allsamples.Draw("datahistoSF",variable,nbins,min,max, xlabel, "events",cutSF,data,luminosity);
395 +  TH1F *datahistoOF = allsamples.Draw("datahistoOF",variable,nbins,min,max, xlabel, "events",cutOF,data,luminosity);
396 + //   string signal("LM3");
397 + //   TH1F* signalhisto = new TH1F("signalhisto",signal.c_str(),nbins,min,max);
398 + //   int idx = signalsamples.FindSample(signal)[0];
399 + //   (signalsamples.collection)[idx].events->Project("signalhisto",variable.c_str(),cutSF);
400 + //   signalhisto->Scale((signalsamples.collection)[idx].weight*luminosity);
401 + //   signalhisto->SetLineColor((signalsamples.collection)[idx].samplecolor);
402 + //   signalhisto->SetLineStyle(2);
403 +  datahistoSF->SetMarkerSize(DataMarkerSize);
404 +  datahistoOF->SetLineColor(kRed);
405 +
406 +  if ( !logscale ) {
407 +    datahistoSF->SetMinimum(0); // Defaults
408 +  } else {
409 +    datahistoSF->SetMinimum(0.5);
410 +  }
411 +  if (ymax<0) {
412 +    if ( logscale ) datahistoSF->SetMaximum(5.3*datahistoSF->GetMaximum());
413 +    else datahistoSF->SetMaximum(1.5*datahistoSF->GetMaximum());
414 +  } else {
415 +    datahistoSF->SetMaximum(ymax);
416 +  }
417 +
418 +  float ymaxSet = datahistoSF->GetMaximum();
419 +
420 +  datahistoSF->GetXaxis()->SetTitle(xlabel.c_str());
421 +  datahistoSF->GetYaxis()->SetTitle("Events");
422 +  datahistoSF->GetXaxis()->CenterTitle();
423 +  datahistoSF->GetYaxis()->CenterTitle();
424 +
425 +  TLegend *mleg = make_legend(legendTitle.c_str(),legendPosition,0.7,false,legendPosition+0.2);
426 +  mleg->AddEntry(datahistoSF, "Same-flavor", "PL");
427 +  if (datahistoOF->Integral()>0) {
428 +    mleg->AddEntry(datahistoOF, "Opposite-flavor", "L");
429 +  } else {
430 +    mleg->AddEntry((TObject*)0, "", "");
431 +  }
432 +  //mleg->AddEntry(signalhisto, "LM3", "L");
433 +
434 +  datahistoSF->Draw("E1");
435 +  if (datahistoOF->Integral()>0) datahistoOF->Draw("HIST,SAMES");
436 +  //signalhisto->Draw("HIST,SAMES");
437 +  mleg->Draw();
438 +  DrawPrelim();
439 +  if (datahistoOF->Integral()>0) {
440 +    save_with_ratio( datahistoSF, datahistoOF, rcan, "SFOF/" + filename, false, false, "SF/OF" );
441 +  } else {
442 +    CompleteSave(rcan, "SFOF/" + filename);
443 +    delete rcan;
444 +  }
445 +
446 +  datahistoSF->Delete();
447 +  datahistoOF->Delete();
448 +  //signalhisto->Delete();
449 +  delete mleg;
450 +  delete ckin;
451 +
452 +  return ymaxSet;
453 +
454 + }
455 +
456 + // Compare data to data
457 + float make_data_comparison_plot(string variable, TCut cut, int nbins, float min, float max, float ymax, bool logscale,
458 +                                string xlabel, string filename, float legendPosition=0.55) {
459 +
460 +  TCut ibasiccut=basiccut&&cut;
461 +
462 +  TCanvas *ckin = new TCanvas("ckin","Kinematic Plots (in the making)",600,600);
463 +  TPad* rcan = new TPad("rcan","rcan",0,0,1,1);
464 +  rcan->SetLogy(logscale);
465 +  rcan->cd();
466 +
467 +  std::cout << "Data comparison: variable = " << variable << ", cut = " << ibasiccut.GetTitle() << std::endl;
468 +
469 +  TH1F *data1 = allsamples.Draw("data1",variable,nbins,min,max, xlabel, "events",ibasiccut,data,luminosity);
470 +  TH1F *data2 = comparesamples.Draw("data2",variable,nbins,min,max, xlabel, "events",ibasiccut,data,luminosity);
471 +
472 +  data1->SetMarkerSize(DataMarkerSize);
473 +  data2->SetLineColor(kRed);
474 +
475 +  if ( !logscale ) {
476 +    data1->SetMinimum(0); // Defaults
477 +  } else {
478 +    data1->SetMinimum(0.5);
479 +  }
480 +  if (ymax<0) {
481 +    if ( logscale ) data1->SetMaximum(5.3*data1->GetMaximum());
482 +    else data1->SetMaximum(1.5*data1->GetMaximum());
483 +  } else {
484 +    data1->SetMaximum(ymax);
485 +  }
486 +
487 +  float ymaxSet = data1->GetMaximum();
488 +
489 +  data1->GetXaxis()->SetTitle(xlabel.c_str());
490 +  data1->GetYaxis()->SetTitle("Events");
491 +  data1->GetXaxis()->CenterTitle();
492 +  data1->GetYaxis()->CenterTitle();
493 +
494 +  TLegend *mleg = make_legend("",legendPosition,0.7,false,legendPosition+0.2);
495 +  mleg->AddEntry(data1, "New 3.8/fb", "PL");
496 +  mleg->AddEntry(data2, "Old 5.1/fb", "L");
497 +
498 +  data1->Draw("E1");
499 +  data2->Draw("HIST,SAMES");
500 +  mleg->Draw();
501 +  DrawPrelim();
502 +  save_with_ratio( data1, data2, rcan, "compareData/" + filename, false, false, "old/new" );
503 +
504 +  data1->Delete();
505 +  data2->Delete();
506 +  delete mleg;
507 +  delete ckin;
508 +
509 + }
510 +
511 + void make_OFSF_plots(string variable, string addcut, int nbins, float min, float max, bool logscale,
512 +                     string xlabel, string filename, float legendPosition=0.55) {
513 +
514 +  string mllcuts[] = { "mll>15","mll>15&&mll<70", "mll>75&&mll<105", "mll>120" };
515 +  string mllcutname[] = { "m_{ll} > 15 GeV", "15 < m_{ll} < 70 GeV", "70 < m_{ll} < 110 GeV", "m_{ll} > 120 GeV" };
516 +  string plotname[] = {"_all","_low","_peak","_high"};
517 +  float ymax;
518 +
519 +  int start = 0;
520 +  if ( !PlottingSetup::openBox ) start = 3;
521 +
522 +  for ( int i=start; i<4; ++i ) {
523 +    if ( addcut != "" ) mllcuts[i] += "&&"+addcut;
524 +    if ( i==start ) {
525 +      ymax = make_one_OFSF_plot(variable, mllcuts[i], mllcutname[i], nbins, min, max, -1, logscale, xlabel,
526 +                         filename+plotname[i], legendPosition );
527 +    } else {
528 +      make_one_OFSF_plot(variable, mllcuts[i],        mllcutname[i], nbins, min, max, ymax, logscale, xlabel,
529 +                         filename+plotname[i], legendPosition );
530 +    }
531 +    make_one_OFSF_plot(variable, "id1==1&&id1==id2&&"+mllcuts[i], mllcutname[i], nbins, min, max, ymax, logscale, xlabel,
532 +                       filename+plotname[i]+"_mm", legendPosition );
533 +    make_one_OFSF_plot(variable, "id1==0&&id1==id2&&"+mllcuts[i], mllcutname[i], nbins, min, max, ymax, logscale, xlabel,
534 +                       filename+plotname[i]+"_ee", legendPosition );
535 +  }
536 +
537 + }
538 +
539 +
540   float lastrange_min=0;
541   float lastrange_max=0;
542  
# Line 349 | Line 545 | void make_kin_plot(string variable, stri
545   //  TCut basiccut("(pfJetGoodNum>=2&&pfJetGoodID[0])&&(pfJetGoodNum>=2&&pfJetGoodID[1])&&(passed_triggers||!is_data)");
546    TCut ibasiccut=basiccut;
547    bool draw_separation_lines=false;
548 +  bool drawsignal = false;
549    
550    if(isPF) ibasiccut=basiccut&&"pfjzb[0]>-998";
551  
# Line 370 | Line 567 | void make_kin_plot(string variable, stri
567    //Step 2: Refine the cut
568    TCut cut;
569    cut=cutmass&&cutOSSF&&cutnJets&&ibasiccut;
570 <  if(filename=="nJets") cut=cutmass&&cutOSSF&&ibasiccut;
571 <  if(filename=="nJets_osof") cut=cutmass&&cutOSOF&&ibasiccut;
570 >  if(filename=="nJets" || filename=="nJets_inclusive" || filename=="nJets_met100" || filename=="nJets_inclusive_met100") cut=cutmass&&cutOSSF&&ibasiccut;
571 >  if(filename=="nJets_osof" || filename=="nJets_osof_inclusive" || filename=="nJets_osof_met100" || filename=="nJets_osof_inclusive_met100") cut=cutmass&&cutOSOF&&ibasiccut;
572    if(filename=="nJets_nocuts_except_mll_ossf") cut=cutmass&&cutOSSF;
573 <  if(filename=="mll") {
573 >  if(filename=="mll"||filename=="mll_met100") {
574          cut=cutOSSF&&cutnJets&&ibasiccut;
575          draw_separation_lines=true;
576    }
577 <  if(filename=="mll_ee") cut=cutOSSF&&cutnJets&&ibasiccut&&"id1==0";
578 <  if(filename=="mll_osof") {
577 >  if(filename=="mll_ee"||filename=="mll_ee_met100") cut=cutOSSF&&cutnJets&&ibasiccut&&"id1==0";
578 >  if(filename=="mll_mm"||filename=="mll_mm_met100") cut=cutOSSF&&cutnJets&&ibasiccut&&"id1==1";
579 >  if(filename=="mll_osof"||filename=="mll_osof_met100") {
580          cut=cutOSOF&&cutnJets&&ibasiccut;
581          draw_separation_lines=true;
582    }
385  if(filename=="mll_mm") cut=cutOSSF&&cutnJets&&ibasiccut&&"id1==1";
583    if(Contains(filename,"aboveJZB")) cut=cutOSSF&&cutnJets&&ibasiccut;
584    if(Contains(filename,"mll_ee_above")) cut=cut&&"id1==0";
585    if(Contains(filename,"mll_mm_above")) cut=cut&&"id1==1";
# Line 393 | Line 590 | void make_kin_plot(string variable, stri
590    if(filename=="mll_inclusive_mm") cut=cutOSSF&&"id1==1";
591    if(filename=="pfJetGoodEta_0") cut=cutOSSF&&cutmass&&ibasiccut&&cutnJets;
592    if(filename=="pfJetGoodPt_0") cut=cutOSSF&&cutmass&&ibasiccut&&cutnJets;
593 +  if(filename=="numVtx") cut=cutmass&&ibasiccut;
594  
595    TCanvas *ckin = new TCanvas("ckin","Kinematic Plots (in the making)",600,600);
596    ckin->SetLogy(logscale);
597    TH1F *datahisto = allsamples.Draw("datahisto",variable,nbins,min,max, xlabel, "events",cut,data,luminosity);
598    datahisto->SetMarkerSize(DataMarkerSize);
599 <  THStack mcstack = allsamples.DrawStack("mcstack",variable,nbins,min,max, xlabel, "events",cut,mc,luminosity);
599 >  if ( !logscale ) datahisto->SetMinimum(0); // Defaults
600 >  else datahisto->SetMinimum(0.5);
601 >  // Custom max.
602 >  if(variable=="TMath::Abs(pfJetDphiMet[0])") datahisto->SetMaximum(1.5*datahisto->GetMaximum());
603    if(variable=="pfJetGoodPt[0]") datahisto->SetMaximum(10*datahisto->GetMaximum());
604    if(variable=="pt") datahisto->SetMaximum(10*datahisto->GetMaximum());
605    if(filename=="mll_inclusive"||filename=="mll_inclusive_mm"||filename=="mll_inclusive_ee") datahisto->SetMinimum(1);
606    if(filename=="mll_osof") datahisto->SetMaximum(10*datahisto->GetMaximum());
607    if(filename=="mll_osof") datahisto->SetMinimum(9);
608 <  datahisto->SetMaximum(5.3*datahisto->GetMaximum());
609 <  datahisto->Draw("e1");
610 <  ckin->Update();
608 >  if (logscale) datahisto->SetMaximum(5.3*datahisto->GetMaximum());
609 >  else datahisto->SetMaximum(1.3*datahisto->GetMaximum());
610 >
611 >  cout << "******** Cut used : " << (const char*) cut << " for plot " << filename << endl;
612    if(loadlastminmax) {
613          datahisto->SetMinimum(lastrange_min);
614          datahisto->SetMaximum(lastrange_max);
# Line 416 | Line 618 | void make_kin_plot(string variable, stri
618          }              
619    }
620  
621 +  // Draw signal by hand (for some reason I don't manage to use the sample class: it adds it to the stack!)
622 +  string signal("LM3");
623 +  TH1F* signalhisto = new TH1F("signalhisto",signal.c_str(),nbins,min,max);
624 +  int idx = signalsamples.FindSample(signal)[0];
625 +  if(drawsignal) (signalsamples.collection)[idx].events->Project("signalhisto",variable.c_str(),cut);
626 +  if(drawsignal) signalhisto->Scale((signalsamples.collection)[idx].weight*luminosity);
627 +  if(drawsignal) signalhisto->SetLineColor(kOrange);
628 +
629 +  THStack mcstack   = allsamples.DrawStack("mcstack",  variable,nbins,min,max,xlabel,"events",cut,mc,luminosity);
630 +  datahisto->Draw("e1");
631 +  ckin->Update();
632    mcstack.Draw("same");
633 +  
634    datahisto->Draw("same,e1");
635    TLegend *kinleg = allsamples.allbglegend();
636    kinleg->Draw();
# Line 459 | Line 673 | void make_kin_plot(string variable, stri
673          kinpad->SetLogy(logscale);
674          datahisto->Draw("e1");
675          mcstack.Draw("same");
676 +        if(drawsignal) signalhisto->Draw("same");
677          datahisto->Draw("same,e1");
678          datahisto->Draw("same,axis");
679          if(RestrictToMassPeak&&draw_separation_lines) {
# Line 466 | Line 681 | void make_kin_plot(string variable, stri
681            upperboundary->Draw("same");
682          }
683            
684 +        if(drawsignal) kinleg->AddEntry("signalhisto",signal.c_str(),"l");
685          kinleg->Draw();
686          write_cut->Draw();
687          DrawPrelim();
# Line 480 | Line 696 | void make_kin_plot(string variable, stri
696          else CompleteSave(ckin,"kin/"+filename);
697    }
698    datahisto->Delete();
699 +  delete signalhisto;
700    delete ckin;
701   }
702  
703 < void make_JES_plot() {
703 > void make_JES_plot(TCut cut, string name) {
704  
705    int nbins=10;
706    float min=-0.5;
707    float max = 9.5;
708    bool logscale=true;
709    string xlabel="nJets";
493  TCut cut=cutmass&&cutOSSF&&basiccut;
710  
711    TCanvas *ckin = new TCanvas("ckin","Kinematic Plots (in the making)",600,600);
712    ckin->SetLogy(logscale);
713 <  TH1F *datahisto = allsamples.Draw("datahisto","pfJetGoodNum",nbins,min,max, xlabel, "events",cut,data,luminosity);
713 >  TH1F *datahisto = allsamples.Draw("datahisto","pfJetGoodNum40",nbins,min,max, xlabel, "events",cut,data,luminosity);
714    datahisto->SetMarkerSize(DataMarkerSize);
715 <  THStack mcstack = allsamples.DrawStack("mcstack","pfJetGoodNum",nbins,min,max, xlabel, "events",cut,mc,luminosity);
716 <  TH1F *JESup = allsamples.Draw("JESup","pfJetGoodNump1sigma",nbins,min,max, xlabel, "events",cut,mc,luminosity);
717 <  TH1F *JESdn = allsamples.Draw("JESdn","pfJetGoodNumn1sigma",nbins,min,max, xlabel, "events",cut,mc,luminosity);
715 >  THStack mcstack = allsamples.DrawStack("mcstack","pfJetGoodNum40",nbins,min,max, xlabel, "events",cut,mc,luminosity);
716 >  TH1F *JESup = allsamples.Draw("JESup","pfJetGoodNum40p1sigma",nbins,min,max, xlabel, "events",cut,mc,luminosity);
717 >  TH1F *JESdn = allsamples.Draw("JESdn","pfJetGoodNum40n1sigma",nbins,min,max, xlabel, "events",cut,mc,luminosity);
718  
719    datahisto->SetMinimum(1);
720    datahisto->SetMaximum(5.3*datahisto->GetMaximum()); // in line with kinematic plots style
# Line 523 | Line 739 | void make_JES_plot() {
739    TLegend *kinleg = allsamples.allbglegend();
740    kinleg->AddEntry(JESunc,"JES uncertainty","f");
741    kinleg->Draw();
742 <  CompleteSave(ckin,"Systematics/JES");
742 >  CompleteSave(ckin,"Systematics/JES"+name);
743    datahisto->Delete();
744    delete ckin;
745  
# Line 531 | Line 747 | void make_JES_plot() {
747  
748   void do_kinematic_plots(string mcjzb, string datajzb, bool doPF=false)
749   {
750 + //  switch_overunderflow(true);
751    bool dolog=true;
752    bool nolog=false;
753 +
754 +  bool doOFSF = false;
755 +  bool doKin  = true;
756 +  bool doDataComp = false;
757 +  
758 +
759    if(doPF) write_warning(__FUNCTION__,"Please use caution when trying to produce PF plots; not all versions of the JZB trees have these variables!");
760    float mll_low=50;
761    float mll_hi=160;
762    if(!PlottingSetup::RestrictToMassPeak) {
763          mll_low=20;
764 <        mll_hi=210;
764 >        mll_hi=320;
765    }
766 <  
767 <  make_kin_plot("met[4]","",40,0,200,dolog,"MET [GeV]","met",doPF,true);
768 <  make_kin_plot("mll","",(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll",doPF,true);
769 <  make_kin_plot("mll","",(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_osof",doPF,true,true);
770 <  make_kin_plot("mll","",(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_ee",doPF,true);
771 <  make_kin_plot("mll","",(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_mm",doPF,true);
772 <  make_kin_plot("mll","",(int)((mll_hi-mll_low)),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive",doPF,true);
773 <  make_kin_plot("mll","",(int)((mll_hi-mll_low)),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_ee",doPF,true);
774 <  make_kin_plot("mll","",(int)((mll_hi-mll_low)),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_mm",doPF,true);
775 <  make_kin_plot("mll","",(int)((mll_hi-mll_low))/2,mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_osof",doPF,true);
776 <  make_kin_plot("mll","",(int)((350-mll_low)),mll_low,350,dolog,"m_{ll} [GeV]","mll_inclusive_highrange",doPF);
777 <  make_kin_plot("numVtx","",(int)(30.5-(-0.5)),-0.5,30.5,nolog,"N(Vtx)","numVtx",doPF);
778 < //  make_kin_plot("jetpt[0]","",40,0,200,dolog,"leading jet p_{T} [GeV]","pfJetGoodPt_0",doPF);
779 < //  make_kin_plot("jeteta[0]","",40,-5,5,nolog,"leading jet #eta","pfJetGoodEta_0",doPF);
780 <  make_kin_plot("pt","",50,0,400,dolog,"Z p_{T} [GeV]","Zpt",doPF);
781 <  make_kin_plot("pt1","",50,0,100,nolog,"p_{T} [GeV]","pt1",doPF);
782 <  make_kin_plot("pt2","",50,0,100,nolog,"p_{T} [GeV]","pt2",doPF);
783 <  make_kin_plot("eta1","",40,-5,5,nolog,"#eta_{l}","eta",doPF);
784 <  make_kin_plot("jzb[1]","",100,-150,150,dolog,"JZB [GeV]","jzb_ossf",doPF);
785 <  make_kin_plot("pfJetGoodNum40","",9,-0.5,8.5,dolog,"nJets","nJets",doPF);
786 <  make_kin_plot("pfJetGoodNum40","",9,-0.5,8.5,dolog,"nJets","nJets_osof",doPF);
787 <  make_kin_plot("pfJetGoodNum40","",9,-0.5,8.5,dolog,"nJets","nJets_nocuts_except_mll_ossf",doPF);
788 <  if(!doPF) make_special_mll_plot((int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]");
789 <  stringstream jzbcut;
790 <  jzbcut << "((is_data&&("<<datajzb<<")>100)||(!is_data&&("<<mcjzb<<")>100))";
791 <  make_kin_plot("mll",jzbcut.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV]","mll_aboveJZB100",doPF,true);
792 <  make_kin_plot("mll",jzbcut.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV]","mll_osof_aboveJZB100",doPF,true);
793 <  make_kin_plot("mll",jzbcut.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV]","mll_ee_aboveJZB100",doPF,true);
794 <  make_kin_plot("mll",jzbcut.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV]","mll_mm_aboveJZB100",doPF,true);
795 <  stringstream jzbcut2;
796 <  jzbcut2 << "((is_data&&("<<datajzb<<")>150)||(!is_data&&("<<mcjzb<<")>150))";
797 <  make_kin_plot("mll",jzbcut2.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV]","mll_aboveJZB150",doPF,true);
798 <  make_kin_plot("mll",jzbcut2.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV]","mll_osof_aboveJZB150",doPF,true);
799 <  make_kin_plot("mll",jzbcut2.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV]","mll_ee_aboveJZB150",doPF,true);
800 <  make_kin_plot("mll",jzbcut2.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV]","mll_mm_aboveJZB150",doPF,true);
801 <  stringstream jzbcut3;
802 <  jzbcut3 << "((is_data&&("<<datajzb<<")>50)||(!is_data&&("<<mcjzb<<")>50))";
803 <  make_kin_plot("mll",jzbcut3.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV]","mll_aboveJZB50",doPF,true);  
804 <  make_kin_plot("mll",jzbcut3.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV]","mll_osof_aboveJZB50",doPF,true,true);
805 <  make_kin_plot("mll",jzbcut3.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV]","mll_ee_aboveJZB50",doPF,true);  
806 <  make_kin_plot("mll",jzbcut3.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV]","mll_mm_aboveJZB50",doPF,true);  
807 <  
808 <  
809 <  make_special_obs_pred_mll_plot(datajzb,mcjzb,0);
810 <  make_special_obs_pred_mll_plot(datajzb,mcjzb,50);
811 <  make_special_obs_pred_mll_plot(datajzb,mcjzb,100);
812 <  make_special_obs_pred_mll_plot(datajzb,mcjzb,150);
813 <  make_special_obs_pred_mll_plot(datajzb,mcjzb,200);
814 <  make_special_obs_pred_mll_plot(datajzb,mcjzb,250);
815 <  
816 <  make_JES_plot();
766 >
767 >  if ( doOFSF ) {
768 >    make_OFSF_plots("mll", "met[4]>100", 60, 20., 320., false, "m_{ll}", "mll");
769 >
770 >    make_OFSF_plots("pfJetGoodNum40", "met[4]>100",                        7, 3, 10, true, "#(jets)", "njets");
771 >    make_OFSF_plots("pfJetGoodNum40", "met[4]>100&&pfJetGoodNumBtag30==0", 7, 3, 10, true, "#(jets)", "njets_btagVeto");
772 >    make_OFSF_plots("pfJetGoodNum40", "met[4]>100&&pfJetGoodNumBtag30>0",  7, 3, 10, true, "#(jets)", "njets_AtLeastOneBJet30");
773 >
774 >    make_OFSF_plots("pfJetGoodNumBtag30", "met[4]>100", 5, 0, 5, true, "#(b-jets)", "nbjets");
775 >    make_OFSF_plots("pfJetGoodPtBtag[0]", "met[4]>100&&pfJetGoodNumBtag30>0", 20, 0, 400, true, "p_{T}(leading b-jet)", "ptb1");
776 >
777 >    make_OFSF_plots("iso1", "met[4]>100", 20, 0, 0.3, true, "lepton 1 isolation", "iso1");
778 >    make_OFSF_plots("iso2", "met[4]>100", 20, 0, 0.3, true, "lepton 2 isolation", "iso2");
779 >    //  make_OFSF_plots("pt1",  "met[4]>100", 30, 0., 300., true, "p_{T,1}", "pt1");
780 >    //  make_OFSF_plots("pt2",  "met[4]>100", 22, 0., 220., true, "p_{T,2}", "pt2");
781 >    make_OFSF_plots("eta1", "met[4]>100", 10, -2.5, 2.5, false, "#eta_{1}", "eta1", 0.15);
782 >    make_OFSF_plots("eta2", "met[4]>100", 10, -2.5, 2.5, false, "#eta_{2}", "eta2", 0.15);
783 >    //  make_OFSF_plots("phi1", "met[4]>100", 10, -TMath::Pi(), TMath::Pi(), false, "#phi_{1}", "phi1", 0.2);
784 >    //  make_OFSF_plots("phi2", "met[4]>100", 10, -TMath::Pi(), TMath::Pi(), false, "#phi_{2}", "phi2", 0.2);
785 >    //  make_OFSF_plots("pfJetGoodPt[0]/pfJetGoodPt[1]", "met[4]>100", 20, 1, 10, true, "pt_{j}^{1}/pt_{j}^{2}", "jpt1pt2", 0.2);
786 >    make_OFSF_plots("TMath::Abs(pfJetDphiMet[0])", "met[4]>100", 16, 0, 3.2, false, "|#Delta#phi(jet1,MET)|", "dphij1met", 0.2);
787 >    make_OFSF_plots("TMath::Abs(dphi)", "met[4]>100", 16, 0, 3.2, false, "|#Delta#phi(l1,l2)|", "dphi", 0.2);
788 >    //  make_OFSF_plots("TMath::Abs(dphiMet1)", "met[4]>100", 16, 0, 3.2, false, "|#Delta#phi(l1,MET)|", "dphiMet1", 0.2);
789 >    //  make_OFSF_plots("TMath::Abs(dphiMet2)", "met[4]>100", 16, 0, 3.2, false, "|#Delta#phi(l2,MET)|", "dphiMet2", 0.2);
790 >    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");
791 >    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");
792 >    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");
793 >    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");
794 >  }
795 >
796 >  if ( doDataComp && !PlottingSetup::openBox ) {
797 >    TCut mllCut("");
798 >    float massmin = 15.;
799 >    float massmax = 315;
800 >    int massnbins = 60;
801 >    if ( !PlottingSetup::openBox ) {
802 >      mllCut = "mll>120";
803 >      massmin = 120;
804 >      massmax = 360;
805 >      massnbins = 14;
806 >    }
807 >
808 >    TCut cutSignal = cutmass&&cutnJets&&"met[4]>100";
809 >    make_data_comparison_plot("mll", cutOSSF,60, 15., 315.,-1., true, "m_{ll}", "mll_SF_inclusive");
810 >    make_data_comparison_plot("mll", cutOSOF,60, 15., 315.,-1., true, "m_{ll}", "mll_OF_inclusive");
811 >
812 >    make_data_comparison_plot("mll", cutOSSF&&cutSignal&&mllCut,           massnbins, 15., 315.,-1., false, "m_{ll}", "mll_SF_sig");
813 >    make_data_comparison_plot("mll", cutOSSF&&cutSignal&&mllCut&&"pfJetGoodNumBtag30==0", massnbins, 15., 315.,-1., false, "m_{ll}", "mll_SF_sig_btagVeto");
814 >    make_data_comparison_plot("mll", cutOSSF&&cutSignal&&mllCut&&"pfJetGoodNumBtag30>0",  massnbins, 15., 315.,-1., false, "m_{ll}", "mll_SF_sig_AtLeastOneBJet");
815 >
816 >    make_data_comparison_plot("mll", mllCut&&cutOSOF&&cutSignal, massnbins, 15., 315.,-1., false, "m_{ll}", "mll_OF_sig");
817 >    make_data_comparison_plot("mll", cutmass&&cutOSSF&&"met[4]>100&&met[4]<150&&pfJetGoodNum40==2", massnbins, 15., 315.,-1., false, "m_{ll}", "mll_SF_CR");
818 >    make_data_comparison_plot("mll", cutmass&&cutOSOF&&"met[4]>100&&met[4]<150&&pfJetGoodNum40==2", massnbins, 15., 315.,-1., false, "m_{ll}", "mll_OF_CR");
819 >
820 >    make_data_comparison_plot("pfJetGoodNum40", cutOSSF&&cutSignal&&mllCut, 8, 0., 8.,-1., false, "#(jets)", "njets_SF_sig");
821 >    make_data_comparison_plot("pfJetGoodNum40", cutOSOF&&cutSignal&&mllCut, 8, 0., 8.,-1., false, "#(jets)", "njets_OF_sig");
822 >    make_data_comparison_plot("pfJetGoodNumBtag30", cutOSSF&&cutSignal&&mllCut, 8, 0., 8.,-1., false, "#(b-jets)", "nbjets_SF_sig");
823 >    make_data_comparison_plot("pfJetGoodNumBtag30", cutOSOF&&cutSignal&&mllCut, 8, 0., 8.,-1., false, "#(b-jets)", "nbjets_OF_sig");
824 >  }
825 >
826 >
827 >  if ( doKin ) {
828 >    string mllCut("");
829 >    if ( !PlottingSetup::openBox ) mllCut = "&&mll>120";
830 >
831 >    // Plots in signal region
832 > //     make_kin_plot("met[4]","",70,0,350,dolog,"MET [GeV]","met",doPF,true);
833 >    make_kin_plot("mll","mll>20"+mllCut,(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll",doPF,true);
834 >    make_kin_plot("mll","mll>20",(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_osof",doPF,true,true);
835 >    make_kin_plot("mll","mll>20"+mllCut,(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_ee",doPF,true);
836 >    make_kin_plot("mll","mll>20"+mllCut,(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_mm",doPF,true);
837 >    
838 >    make_kin_plot("pfJetGoodNum40",mllCut,9,-0.5,8.5,dolog,"nJets","nJets",doPF);
839 >    make_kin_plot("pfJetGoodNum40","",9,-0.5,8.5,dolog,"nJets","nJets_osof",doPF);
840 >    
841 >    make_kin_plot("mll","mll>20&&met[4]>100"+mllCut,(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_met100",doPF,true);
842 >    make_kin_plot("mll","mll>20&&met[4]>100",(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_osof_met100",doPF,true,true);
843 >    make_kin_plot("mll","mll>20&&met[4]>100"+mllCut,(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_ee_met100",doPF,true);
844 >    make_kin_plot("mll","mll>20&&met[4]>100"+mllCut,(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_mm_met100",doPF,true);
845 >    
846 >    make_kin_plot("pfJetGoodNum40","met[4]>100"+mllCut,9,-0.5,8.5,dolog,"nJets","nJets_met100",doPF);
847 >    make_kin_plot("pfJetGoodNum40","met[4]>100",9,-0.5,8.5,dolog,"nJets","nJets_osof_met100",doPF);
848 >
849 >    // Further inclusive invariant mass plots
850 >    make_kin_plot("mll","",(int)((mll_hi-mll_low))/5,mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive",doPF,true);
851 >    make_kin_plot("mll","",(int)((mll_hi-mll_low))/5,mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_ee",doPF,true);
852 >    make_kin_plot("mll","",(int)((mll_hi-mll_low))/5,mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_mm",doPF,true);
853 >    make_kin_plot("mll","",(int)((mll_hi-mll_low))/5,mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_osof",doPF,true);
854 >    
855 >    //make_kin_plot("mll","",(int)((350-mll_low))/5,mll_low,350,dolog,"m_{ll} [GeV]","mll_inclusive_highrange",doPF);
856 >    //if(!doPF) make_special_mll_plot((int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]");
857 >    
858 >    //make_kin_plot("pfJetGoodPt[0]/pfJetGoodPt[1]","",45,1,10,dolog,"pt_{j}^{1}/pt_{j}^{2}","j1j2ratio",doPF,true);
859 >    //make_kin_plot("TMath::Abs(pfJetDphiMet[0])","",32,0,3.2,nolog,"|#Delta#phi(jet1,MET)|","dphiJ1MET",doPF,true);
860 >    
861 >    // Number of jets
862 >    make_kin_plot("pfJetGoodNum40","",9,-0.5,8.5,dolog,"nJets","nJets_inclusive",doPF);
863 >    make_kin_plot("pfJetGoodNum40","",9,-0.5,8.5,dolog,"nJets","nJets_osof_inclusive",doPF);
864 >    //make_kin_plot("pfJetGoodNum40","",9,-0.5,8.5,dolog,"nJets","nJets_nocuts_except_mll_ossf",doPF);
865 >    
866 >    // Others
867 >    make_kin_plot("numVtx","",(int)(30.5-(-0.5)),-0.5,30.5,nolog,"N(Vtx)","numVtx",doPF);
868 >    //  make_kin_plot("jetpt[0]","",40,0,200,dolog,"leading jet p_{T} [GeV]","pfJetGoodPt_0",doPF);
869 >    //  make_kin_plot("jeteta[0]","",40,-5,5,nolog,"leading jet #eta","pfJetGoodEta_0",doPF);
870 >    make_kin_plot("pt","",50,0,500,dolog,"Z p_{T} [GeV]","Zpt",doPF);
871 >    make_kin_plot("pt1","",50,0,200,nolog,"p_{T} [GeV]","pt1",doPF);
872 >    make_kin_plot("pt2","",50,0,200,nolog,"p_{T} [GeV]","pt2",doPF);
873 >    make_kin_plot("eta1","",40,-3,3,nolog,"#eta_{l}","eta",doPF);
874 >    make_kin_plot("jzb[1]","",100,-150,200,dolog,"JZB [GeV]","jzb_ossf",doPF);
875 >    //   stringstream jzbcut;
876 >    //   jzbcut << "((is_data&&("<<datajzb<<")>100)||(!is_data&&("<<mcjzb<<")>100))";
877 >    //   make_kin_plot("mll",jzbcut.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV]","mll_aboveJZB100",doPF,true);
878 >    //   make_kin_plot("mll",jzbcut.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV]","mll_osof_aboveJZB100",doPF,true);
879 >    //   make_kin_plot("mll",jzbcut.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV]","mll_ee_aboveJZB100",doPF,true);
880 >    //   make_kin_plot("mll",jzbcut.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV]","mll_mm_aboveJZB100",doPF,true);
881 >    //   stringstream jzbcut2;
882 >    //   jzbcut2 << "((is_data&&("<<datajzb<<")>150)||(!is_data&&("<<mcjzb<<")>150))";
883 >    //   make_kin_plot("mll",jzbcut2.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV]","mll_aboveJZB150",doPF,true);
884 >    //   make_kin_plot("mll",jzbcut2.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV]","mll_osof_aboveJZB150",doPF,true);
885 >    //   make_kin_plot("mll",jzbcut2.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV]","mll_ee_aboveJZB150",doPF,true);
886 >    //   make_kin_plot("mll",jzbcut2.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV]","mll_mm_aboveJZB150",doPF,true);
887 >    //   stringstream jzbcut3;
888 >    //   jzbcut3 << "((is_data&&("<<datajzb<<")>50)||(!is_data&&("<<mcjzb<<")>50))";
889 >    //   make_kin_plot("mll",jzbcut3.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV]","mll_aboveJZB50",doPF,true);  
890 >    //   make_kin_plot("mll",jzbcut3.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV]","mll_osof_aboveJZB50",doPF,true,true);
891 >    //   make_kin_plot("mll",jzbcut3.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV]","mll_ee_aboveJZB50",doPF,true);  
892 >    //   make_kin_plot("mll",jzbcut3.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV]","mll_mm_aboveJZB50",doPF,true);  
893 >    
894 >    //   make_kin_plot("mll","met[4]>100",(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV] (MET>100GeV)","mll_met100_ll",doPF,true);
895 >    //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);
896 >    //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);
897 >  }
898 >    
899 > //   make_special_obs_pred_mll_plot(datajzb,mcjzb,0);
900 > //   make_special_obs_pred_mll_plot(datajzb,mcjzb,50);
901 > //   make_special_obs_pred_mll_plot(datajzb,mcjzb,80);
902 >   make_special_obs_pred_mll_plot(datajzb,mcjzb,100);
903 > //   make_special_obs_pred_mll_plot(datajzb,mcjzb,150);
904 > //   make_special_obs_pred_mll_plot(datajzb,mcjzb,200);
905 > //   make_special_obs_pred_mll_plot(datajzb,mcjzb,250);
906 >
907 > //   make_JES_plot(cutmass&&cutOSSF&&basiccut,"_ossf");
908 > //   make_JES_plot(cutmass&&cutOSOF&&basiccut,"_osof");
909 >
910 >  switch_overunderflow(false);
911   }
912  
913   void make_comp_plot( string var, string xlabel, string filename, float jzbcut, string mcjzb, string datajzb,
914                       int nbins, float xmin, float xmax, bool log,
915                       float ymin=0, float ymax=0, bool leftJustified=false ) {
916 <      flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- WATCH OUT: the argument in the function changed!
916 >  flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- WATCH OUT: the argument in the function changed!
917  
918    TCut weightbackup=cutWeight;//backing up the correct weight (restoring below!)
919    if(weightbackup==TCut("1.0")||weightbackup==TCut("1")) write_warning(__FUNCTION__,"WATCH OUT THE WEIGHT HAS POSSIBLY NOT BEEN RESET!!!! PLEASE CHANGE LINE "+any2string(__LINE__));
920 <  if(var=="numVtx") cutWeight=TCut("1.0");
920 >  //if(var=="numVtx") cutWeight=TCut("1.0");
921    TCut jzbData[]= { TCut(TString(datajzb+">"+any2string(jzbcut))),TCut(TString(datajzb+"<-"+any2string(jzbcut))) };
922    TCut jzbMC[]  = { TCut(TString(mcjzb+">"+any2string(jzbcut))),TCut(TString(mcjzb+"<-"+any2string(jzbcut))) };
923  
924    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- below: the next ~20 lines changed!
925    int nRegions=4;
926 <  if(!PlottingSetup::RestrictToMassPeak) {
926 >  if(!PlottingSetup::RestrictToMassPeak||!PlottingSetup::UseSidebandsForcJZB) {
927      nRegions=2;
928    }
929    
# Line 624 | Line 941 | void make_comp_plot( string var, string
941        TCanvas *ccomp = new TCanvas("ccomp","Comparison plot",600,400);
942        ccomp->SetLogy(log);
943        TH1F *datahisto = allsamples.Draw("datahisto",   var,nbins,xmin,xmax,xlabel,"events",kRegions[iregion]&&jzbData[ijzb],data,luminosity);
944 <      TH1F *lm4histo = signalsamples.Draw("lm4histo",   var,nbins,xmin,xmax,xlabel,"events",kRegions[iregion]&&jzbData[ijzb],data,luminosity,signalsamples.FindSample("LM"));
944 >      TH1F *lm3histo  = signalsamples.Draw("lm3histo",   var,nbins,xmin,xmax,xlabel,"events",kRegions[iregion]&&jzbMC[ijzb],data,luminosity,signalsamples.FindSample("LM3"));
945        THStack mcstack = allsamples.DrawStack("mcstack",var,nbins,xmin,xmax,xlabel,"events",kRegions[iregion]&&jzbMC[ijzb],  mc,  luminosity);
946        datahisto->SetMarkerSize(DataMarkerSize);
947        if (ymax>ymin) datahisto->SetMaximum(ymax);
948 <      lm4histo->SetLineStyle(2);
948 >      lm3histo->SetLineStyle(2);
949        datahisto->Draw("e1");
950        mcstack.Draw("same");
951        datahisto->Draw("same,e1");
952 < //      lm4histo->Draw("hist,same");
952 >      lm3histo->Draw("hist,same");
953        TLegend *kinleg = allsamples.allbglegend((sRegions[iregion]+(ijzb?"neg":"pos")).c_str());
954        if ( leftJustified ) {
955          Float_t w = kinleg->GetX2()-kinleg->GetX1();
956          kinleg->SetX1(0.2);
957          kinleg->SetX2(0.2+w);
958        }
959 < //      kinleg->AddEntry(lm4histo,"LM4","l");
959 >      kinleg->AddEntry(lm3histo,"LM3","l");
960        kinleg->Draw();
961        TText* write_variable = write_text(0.99,0.01,var);
962        write_variable->SetTextAlign(31);
# Line 648 | Line 965 | void make_comp_plot( string var, string
965        CompleteSave(ccomp,"compare/JZBcut_at_"+any2string(jzbcut)+"/"+filename+"/"+filename+sRegions[iregion]+(ijzb?"neg":"pos"));
966        delete datahisto;
967        delete ccomp;
968 <      delete lm4histo;
968 >      delete lm3histo;
969      }
970    cutWeight=weightbackup;
971   }
# Line 660 | Line 977 | void region_comparison_plots(string mcjz
977  
978   //  switch_overunderflow(true);  // switching overflow/underflow bins on
979      
980 <  
980 >  switch_overunderflow(true);
981      flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- the arguments changed
982    for(int ijzb=0;ijzb<(int)jzb_cuts.size();ijzb++) {
983      float jzbcut=jzb_cuts[ijzb]; // Comparison plots are done for this JZB cut
984      float mll_low=50;float mll_high=170;
985      if(!PlottingSetup::RestrictToMassPeak) {
986 <        mll_high=200;
987 <        mll_low=50;
986 >        mll_high=300;
987 >        mll_low=20;
988      }
989 <    make_comp_plot("mll","m_{ll} [GeV]","mll",jzbcut,mcjzb,datajzb,30,mll_low,mll_high,false,0,16.);
989 >    make_comp_plot("pfJetGoodPt[0]/pfJetGoodPt[1]","pt_{j}^{1}/pt_{j}^{2}","j1j2ratio",jzbcut,mcjzb,datajzb,100,0,10,true);
990 >    make_comp_plot("TMath::Abs(pfJetDphiMet[0])","|#Delta#phi(jet1,MET)|","dphiJ1MET",jzbcut,mcjzb,datajzb,32,0,3.2,false,0,0,true);
991 >
992 >    make_comp_plot("mll","m_{ll} [GeV]","mll",jzbcut,mcjzb,datajzb,56,mll_low,mll_high,false,0,16.);
993      make_comp_plot("met[4]","pfMET [GeV]","pfmet",jzbcut,mcjzb,datajzb,18,0,360,false,0,16.);
994 <    make_comp_plot("pfJetGoodNum","#(jets)","njets",jzbcut,mcjzb,datajzb,10,0,10, false,0,35.);
994 >    make_comp_plot("pfJetGoodNum40","#(jets)","njets",jzbcut,mcjzb,datajzb,10,0,10, false,0,35.);
995 >    make_comp_plot("pfJetGoodNumBtag","#(b-jets)","nBjets",jzbcut,mcjzb,datajzb,10,0,10, false,0,35.);
996      make_comp_plot("pt","Z p_{T} [GeV]","Zpt",jzbcut,mcjzb,datajzb,26,0,525,false,0.,21.);
997 <    make_comp_plot("numVtx","#(prim. vertices)","nvtx",jzbcut,mcjzb,datajzb,20,0.,20.,false,0,16.);
997 >    make_comp_plot("numVtx","#(prim. vertices)","nvtx",jzbcut,mcjzb,datajzb,40,0.,40.,false,0,16.);
998      make_comp_plot("TMath::Abs(dphi)","#Delta#phi(leptons)","dphilep",jzbcut,mcjzb,datajzb,10,0.,3.1415,false,0,16.,true);
999      make_comp_plot("TMath::Abs(dphi_sumJetVSZ[1])","#Delta#phi(Z,jets)","dphiZjets",jzbcut,mcjzb,datajzb,10,0.,3.1415,false,0,16.,true);
1000 +    make_comp_plot("eta1","#eta_1","eta1",jzbcut,mcjzb,datajzb,10,0.,2.5,false,0,16.);
1001 +    make_comp_plot("eta2","#eta_2","eta2",jzbcut,mcjzb,datajzb,10,0.,2.5,false,0,16.);
1002    }
1003  
1004    switch_overunderflow(false); // switching overflow/underflow bins off
# Line 874 | Line 1197 | vector<TF1*> do_extended_fit_to_plot(TH1
1197   //      the line above is not necessary anymore as we're now looking at a prediction without Z+Jets, and not multiplied with (1.0/3)
1198    TF1 *ttbarlogpar = do_logpar_fit_to_plot(Tprediction);
1199    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
1200 <  if(PlottingSetup::RestrictToMassPeak) ttbarlogpar->SetParameter(0,1.0/3*ttbarlogpar->GetParameter(0));//correcting for the fact that we didn't multiply with (1.0/3);
1200 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) ttbarlogpar->SetParameter(0,1.0/3*ttbarlogpar->GetParameter(0));//correcting for the fact that we didn't multiply with (1.0/3);
1201  
1202  
1203    TF1 *ttbarlogparP = new TF1("ttbarlogparP",LogParabolaP,0,(prediction->GetXaxis()->GetBinLowEdge(prediction->GetNbinsX())+prediction->GetXaxis()->GetBinWidth(prediction->GetNbinsX())),8);
# Line 971 | Line 1294 | if you want to start from scratch (witho
1294  
1295   void do_prediction_plot(string jzb, TCanvas *globalcanvas, float high, int use_data, bool overlay_signal = false,string subdir="" )
1296   {
1297 < //  switch_overunderflow(true);
1297 >  
1298    bool is_data=false;
1299    bool use_signal=false;
1300    if(use_data==1) is_data=true;
1301    if(use_data==2) use_signal=true;
1302 <  int nbins=50;//100;
1303 <  if(is_data) nbins=50;
1302 >  int nbins=int(high/10);//100;
1303 >  if(is_data) nbins=int(high/10);
1304    float low=0;
1305 <  float hi=500;
1305 >  float hi=high;
1306 >  
1307 >  stringstream cutpositiveS;
1308 >  cutpositiveS << "(" << jzb << ">0)";
1309 >  TCut cutpositive(cutpositiveS.str().c_str());
1310 >  stringstream cutnegativeS;
1311 >  cutnegativeS << "(" << jzb << "<0)";
1312 >  TCut cutnegative(cutnegativeS.str().c_str());
1313 >  
1314    
1315    TH1F *blankback = new TH1F("blankback","blankback",int(high/10),0,high);
1316 <  TH1F *RcorrJZBeemm   = allsamples.Draw("RcorrJZBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1317 <  TH1F *LcorrJZBeemm   = allsamples.Draw("LcorrJZBeemm",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1318 <  TH1F *RcorrJZBem     = allsamples.Draw("RcorrJZBem",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1319 <  TH1F *LcorrJZBem     = allsamples.Draw("LcorrJZBem",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1316 >  TH1F *RcorrJZBeemm   = allsamples.Draw("RcorrJZBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutpositive&&cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1317 >  TH1F *LcorrJZBeemm   = allsamples.Draw("LcorrJZBeemm",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutnegative&&cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1318 >  TH1F *RcorrJZBem     = allsamples.Draw("RcorrJZBem",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutpositive&&cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1319 >  TH1F *LcorrJZBem     = allsamples.Draw("LcorrJZBem",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutnegative&&cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1320  
1321    blankback->GetXaxis()->SetTitle(RcorrJZBeemm->GetXaxis()->GetTitle());
1322    blankback->GetYaxis()->SetTitle(RcorrJZBeemm->GetYaxis()->GetTitle());
# Line 1000 | Line 1331 | void do_prediction_plot(string jzb, TCan
1331    
1332    TH1F *RcorrJZBeemmNoS;
1333  
1334 <    //these are for the ratio
1335 <  
1336 <  TH1F *JRcorrJZBeemm   = allsamples.Draw("JRcorrJZBeemm",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1337 <  TH1F *JLcorrJZBeemm   = allsamples.Draw("JLcorrJZBeemm",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1338 <  TH1F *JRcorrJZBem     = allsamples.Draw("JRcorrJZBem",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1008 <  TH1F *JLcorrJZBem     = allsamples.Draw("JLcorrJZBem",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1334 >  //these are for the ratio
1335 >  TH1F *JRcorrJZBeemm   = allsamples.Draw("JRcorrJZBeemm",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutpositive&&cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1336 >  TH1F *JLcorrJZBeemm   = allsamples.Draw("JLcorrJZBeemm",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutnegative&&cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1337 >  TH1F *JRcorrJZBem     = allsamples.Draw("JRcorrJZBem",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutpositive&&cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1338 >  TH1F *JLcorrJZBem     = allsamples.Draw("JLcorrJZBem",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutnegative&&cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1339    
1340    TH1F *JRcorrJZBSBem;
1341    TH1F *JLcorrJZBSBem;
1342    TH1F *JRcorrJZBSBeemm;
1343    TH1F *JLcorrJZBSBeemm;
1344    
1345 <  if(use_data==2 || overlay_signal) RcorrJZBeemmNoS = allsamples.Draw("RcorrJZBeemmNoS",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,false);
1345 >  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);
1346  
1347    
1348 <  if(PlottingSetup::RestrictToMassPeak) {
1349 <    RcorrJZBSBem   = allsamples.Draw("RcorrJZBSBem",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1350 <    LcorrJZBSBem   = allsamples.Draw("LcorrJZBSBem",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1351 <    RcorrJZBSBeemm = allsamples.Draw("RcorrJZBSBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1352 <    LcorrJZBSBeemm = allsamples.Draw("LcorrJZBSBeemm",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1348 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
1349 >    RcorrJZBSBem   = allsamples.Draw("RcorrJZBSBem",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutpositive&&sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1350 >    LcorrJZBSBem   = allsamples.Draw("LcorrJZBSBem",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutnegative&&sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1351 >    RcorrJZBSBeemm = allsamples.Draw("RcorrJZBSBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutpositive&&sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1352 >    LcorrJZBSBeemm = allsamples.Draw("LcorrJZBSBeemm",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutnegative&&sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1353      
1354      //these are for the ratio
1355 <    JRcorrJZBSBem   = allsamples.Draw("JRcorrJZBSBem",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1356 <    JLcorrJZBSBem   = allsamples.Draw("JLcorrJZBSBem",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1357 <    JRcorrJZBSBeemm = allsamples.Draw("JRcorrJZBSBeemm",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1358 <    JLcorrJZBSBeemm = allsamples.Draw("JLcorrJZBSBeemm",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1355 >    JRcorrJZBSBem   = allsamples.Draw("JRcorrJZBSBem",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutpositive&&sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1356 >    JLcorrJZBSBem   = allsamples.Draw("JLcorrJZBSBem",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutnegative&&sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1357 >    JRcorrJZBSBeemm = allsamples.Draw("JRcorrJZBSBeemm",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutpositive&&sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1358 >    JLcorrJZBSBeemm = allsamples.Draw("JLcorrJZBSBeemm",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutnegative&&sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1359    }
1360    
1361    TH1F *lm4RcorrJZBeemm;
1362 <  if(overlay_signal || use_data == 2 || use_data == 1) lm4RcorrJZBeemm = allsamples.Draw("lm4RcorrJZBSBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,allsamples.FindSample("LM"));
1362 >  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"));
1363    
1364    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- prediction changed.
1365    
# Line 1042 | Line 1372 | void do_prediction_plot(string jzb, TCan
1372    TH1F *BpredSys = new TH1F("Bpredsys","Bpredsys",PlottingSetup::global_ratio_binning.size()-1,&PlottingSetup::global_ratio_binning[0]);
1373    ClearHisto(BpredSys);
1374      
1375 <  if(PlottingSetup::RestrictToMassPeak) {
1375 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
1376      Bpred->Add(RcorrJZBem,1.0/3.);
1377      Bpred->Add(LcorrJZBem,-1.0/3.);
1378      Bpred->Add(RcorrJZBSBem,1.0/3.);
# Line 1093 | Line 1423 | void do_prediction_plot(string jzb, TCan
1423    SQRT(BpredSys);
1424    BpredSys->Divide(JBpred);
1425  
1096  
1426    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- prediction changed
1427    TH1F *Tpred = (TH1F*)RcorrJZBem->Clone("Bpred");
1428    Tpred->Add(LcorrJZBem,-1.0);
1429 <  if(PlottingSetup::RestrictToMassPeak) {
1429 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
1430      Tpred->Add(RcorrJZBSBem,1.0);
1431      Tpred->Add(LcorrJZBSBem,-1.0);
1432      Tpred->Add(RcorrJZBSBeemm,1.0);
# Line 1146 | Line 1475 | void do_prediction_plot(string jzb, TCan
1475      Bpred->Draw("hist,same");
1476      //analytical_function[0]->Draw("same"); analytical_function[1]->Draw("same");analytical_function[2]->Draw("same");
1477      RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
1478 <    lm4RcorrJZBeemm->Draw("hist,same");
1478 >    //lm4RcorrJZBeemm->Draw("hist,same");
1479      legBpred->AddEntry(RcorrJZBeemm,"observed","p");
1480      legBpred->AddEntry(Bpred,"predicted","l");
1481   //    legBpred->AddEntry(analytical_function[1],"predicted fit","l");
1482   //    legBpred->AddEntry(analytical_function[2],"stat. uncert.","l");
1483 <    legBpred->AddEntry(lm4RcorrJZBeemm,(allsamples.collection[allsamples.FindSample("LM")[0]].samplename).c_str(),"l");
1483 > //     legBpred->AddEntry(lm4RcorrJZBeemm,(allsamples.collection[allsamples.FindSample("LM")[0]].samplename).c_str(),"l");
1484      legBpred->Draw();
1485      DrawPrelim();
1486  
# Line 1161 | Line 1490 | void do_prediction_plot(string jzb, TCan
1490      Bpred->SetLineWidth(2);
1491      predcomppad->cd();
1492      predcomppad->SetLogy(1);
1164    
1493      TH1F *jzbnegative = (TH1F*)LcorrJZBeemm->Clone("jzbnegative");
1494      TH1F *sidebandsemu = (TH1F*)Bpred->Clone("sidebandsemu");
1495      sidebandsemu->Add(jzbnegative,-1);
# Line 1183 | Line 1511 | void do_prediction_plot(string jzb, TCan
1511   //    lm4RcorrJZBeemm->SetLineColor(kOrange+1);
1512      lm4RcorrJZBeemm->SetLineWidth(2);
1513      //lm4RcorrJZBeemm->SetLineWidth(2); // paper style. overruled.
1514 <    lm4RcorrJZBeemm->Draw("histo,same");
1514 > //     lm4RcorrJZBeemm->Draw("histo,same");
1515      DrawPrelim();
1516      TLegend *speciallegBpred = make_legend("",0.45,0.55);
1517      //TLegend *speciallegBpred = make_legend("",0.35,0.55); // paper style. overruled.
1518      speciallegBpred->AddEntry(RcorrJZBeemm,"Data","pl");
1519      speciallegBpred->AddEntry(Bpred,"Total background","l");
1520      speciallegBpred->AddEntry(jzbnegative,"JZB<0 (data)","f");
1521 <    if(PlottingSetup::RestrictToMassPeak) speciallegBpred->AddEntry(sidebandsemu,"Sidebands/e#mu (data)","f");
1521 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) speciallegBpred->AddEntry(sidebandsemu,"Sidebands/e#mu (data)","f");
1522      else speciallegBpred->AddEntry(sidebandsemu,"e#mu (data)","f");
1523   //    speciallegBpred->AddEntry(lm4RcorrJZBeemmC,"LM4","l");
1524 <    speciallegBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
1524 > //     speciallegBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
1525      speciallegBpred->Draw();
1526      save_with_ratio(JRcorrJZBeemm,JBpred,predcomppad,subdir+"Bpred_Data_____PredictionComposition",true,true,"data/pred",BpredSys);
1527      
# Line 1229 | Line 1557 | void do_prediction_plot(string jzb, TCan
1557      legBpred->AddEntry(Bpred,"MC predicted","l");    
1558      if(versok) legBpred->AddEntry((TObject*)0,"",""); // Just for alignment // causes seg fault on root v5.18
1559      if(versok) legBpred->AddEntry((TObject*)0,"",""); // causes seg fault on root v5.18
1560 <    if ( overlay_signal ) legBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
1560 > //     if ( overlay_signal ) legBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
1561      legBpred->Draw();
1562      DrawMCPrelim();
1563      Bpredsaveas="Bpred_MC";
# Line 1261 | Line 1589 | void do_prediction_plot(string jzb, TCan
1589        
1590        RcorrJZBeemmNoS->SetLineStyle(2);
1591        legBpred2->AddEntry(RcorrJZBeemmNoS,"MC B","l");
1592 <      legBpred2->AddEntry(lm4RcorrJZBeemm,"MC S","l");
1592 > //       legBpred2->AddEntry(lm4RcorrJZBeemm,"MC S","l");
1593        legBpred2->Draw();
1594        RcorrJZBeemmNoS->SetLineColor(TColor::GetColor("#61210B"));
1595        RcorrJZBeemmNoS->Draw("histo,same");
# Line 1278 | Line 1606 | void do_prediction_plot(string jzb, TCan
1606    string ytitle("ratio");
1607    if ( use_data==1 ) ytitle = "data/pred";
1608    //save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,Bpredsaveas,true,use_data!=1,ytitle);
1609 <  save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,subdir+Bpredsaveas,true,true,ytitle,BpredSys);//not extending the y range anymore up to 4
1609 >  save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,subdir+Bpredsaveas,true,false,ytitle,BpredSys);//not extending the y range anymore up to 4
1610 >
1611  
1612    
1613    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
1614    // The part below is meaningless for the offpeak analysis (it's a comparison of the different estimates but there is but one estimate!)
1615 <  if(PlottingSetup::RestrictToMassPeak) {
1615 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
1616      TH1F *Bpredem = (TH1F*)LcorrJZBeemm->Clone("Bpredem");
1617      Bpredem->Add(RcorrJZBem);
1618      Bpredem->Add(LcorrJZBem,-1);
# Line 1338 | Line 1667 | void do_prediction_plot(string jzb, TCan
1667        legBpredc->AddEntry(Bpredem,"MC OFZP","l");
1668        legBpredc->AddEntry(BpredSBem,"MC OFSB","l");
1669        legBpredc->AddEntry(BpredSBeemm,"MC SFSB","l");
1670 <      if ( overlay_signal ) legBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
1670 > //       if ( overlay_signal ) legBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
1671        legBpredc->Draw();
1672        CompleteSave(globalcanvas,subdir+"Bpred_MCwithS_comparison");
1673      }
# Line 1362 | Line 1691 | void do_prediction_plot(string jzb, TCan
1691    delete blankback;
1692    
1693    delete BpredSys;
1694 <  if(PlottingSetup::RestrictToMassPeak) {
1694 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
1695      delete RcorrJZBSBem;
1696      delete LcorrJZBSBem;
1697      delete RcorrJZBSBeemm;
# Line 1374 | Line 1703 | void do_prediction_plot(string jzb, TCan
1703      delete JLcorrJZBSBeemm;
1704    }
1705    if(overlay_signal || use_data==2) delete lm4RcorrJZBeemm;
1377  switch_overunderflow(false);
1706   }
1707  
1708   void do_prediction_plots(string mcjzb, string datajzb, float DataSigma, float MCSigma, bool overlay_signal ) {
1709 +  switch_overunderflow(true);
1710    TCanvas *globalcanvas = new TCanvas("globalcanvas","Prediction Canvas");
1711    do_prediction_plot(datajzb,globalcanvas,jzbHigh ,data,overlay_signal);
1712    if ( !PlottingSetup::Approved ) {
# Line 1386 | Line 1715 | void do_prediction_plots(string mcjzb, s
1715    } else {
1716      write_info(__FUNCTION__,"You set approved to true, therefore not producing prediction/observation plots for MC with and without signal.");
1717    }
1718 < }
1719 <
1391 < void do_ratio_plot(int is_data,vector<float> binning, string jzb, TCanvas *can, float high=-9999) {
1392 <  bool do_data=0;
1393 <  bool dosignal=0;
1394 <  if(is_data==1) do_data=1;
1395 <  if(is_data==2) dosignal=1;
1396 <  TH1F *RcorrJZBeemm   = allsamples.Draw("RcorrJZBeemm",jzb.c_str(),binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,do_data, luminosity,dosignal);
1397 <  TH1F *LcorrJZBeemm   = allsamples.Draw("LcorrJZBeemm",("-"+jzb).c_str(),binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,do_data, luminosity,dosignal);
1398 <  TH1F *RcorrJZBem     = allsamples.Draw("RcorrJZBem",jzb.c_str(),binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,do_data, luminosity,dosignal);
1399 <  TH1F *LcorrJZBem     = allsamples.Draw("LcorrJZBem",("-"+jzb).c_str(),binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,do_data, luminosity,dosignal);
1400 <  
1401 <  TH1F *RcorrJZBSBem;
1402 <  TH1F *LcorrJZBSBem;
1403 <  TH1F *RcorrJZBSBeemm;
1404 <  TH1F *LcorrJZBSbeemm;
1405 <  
1406 <  if(PlottingSetup::RestrictToMassPeak) {
1407 <    RcorrJZBSBem   = allsamples.Draw("RcorrJZBSbem",jzb.c_str(),binning, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,do_data, luminosity,dosignal);
1408 <    LcorrJZBSBem   = allsamples.Draw("LcorrJZBSbem",("-"+jzb).c_str(),binning, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,do_data, luminosity,dosignal);
1409 <    RcorrJZBSBeemm = allsamples.Draw("RcorrJZBSbeemm",jzb.c_str(),binning, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,do_data, luminosity,dosignal);
1410 <    LcorrJZBSbeemm = allsamples.Draw("LcorrJZBSbeemm",("-"+jzb).c_str(),binning, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,do_data, luminosity,dosignal);
1411 <  }
1412 <  
1413 <
1414 <
1415 <
1416 <  flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
1417 <  TH1F *Bpred = (TH1F*)LcorrJZBeemm->Clone("Bpred");
1418 <  if(PlottingSetup::RestrictToMassPeak) {
1419 <    Bpred->Add(RcorrJZBem,1.0/3);
1420 <    Bpred->Add(LcorrJZBem,-1.0/3);
1421 <    Bpred->Add(RcorrJZBSBem,1.0/3);
1422 <    Bpred->Add(LcorrJZBSBem,-1.0/3);
1423 <    Bpred->Add(RcorrJZBSBeemm,1.0/3);
1424 <    Bpred->Add(LcorrJZBSbeemm,-1.0/3);
1425 <  } else {
1426 <    Bpred->Add(RcorrJZBem,1.0);
1427 <    Bpred->Add(LcorrJZBem,-1.0);
1428 <  }
1429 <
1430 <  can->cd();
1431 <  can->SetLogy(0);
1432 <  Bpred->SetLineColor(kRed);
1433 <  Bpred->SetStats(0);
1434 <  if(high>0) Bpred->GetXaxis()->SetRangeUser(0,high);
1435 <  TH1F *JZBratioforfitting=(TH1F*)RcorrJZBeemm->Clone("JZBratioforfitting");
1436 <  JZBratioforfitting->Divide(Bpred);
1437 <  TGraphAsymmErrors *JZBratio = histRatio(RcorrJZBeemm,Bpred,is_data,binning,false);
1438 <  
1439 <  
1440 <  JZBratio->SetTitle("");
1441 <  JZBratio->GetYaxis()->SetRangeUser(0.0,9.0);
1442 < //  if(is_data==1) JZBratio->GetXaxis()->SetRangeUser(0,jzbHigh );
1443 <  
1444 <  TF1 *pol0 = new TF1("pol0","[0]",0,1000);
1445 <  TF1 *pol0d = new TF1("pol0","[0]",0,1000);
1446 < //  straightline_fit->SetParameter(0,1);
1447 <  JZBratioforfitting->Fit(pol0,"Q0R","",0,30);
1448 <  pol0d->SetParameter(0,pol0->GetParameter(0));
1449 <  
1450 <  JZBratio->GetYaxis()->SetTitle("Observed/Predicted");
1451 <  JZBratio->GetXaxis()->SetTitle("JZB [GeV]");
1452 <  if ( high>0 ) JZBratio->GetXaxis()->SetRangeUser(0.0,high);
1453 <  JZBratio->GetYaxis()->SetNdivisions(519);
1454 <  JZBratio->GetYaxis()->SetRangeUser(0.0,4.0);
1455 <  JZBratio->GetYaxis()->CenterTitle();
1456 <  JZBratio->GetXaxis()->CenterTitle();
1457 <  JZBratio->SetMarkerSize(DataMarkerSize);
1458 <  JZBratio->Draw("AP");
1459 <  /////----------------------------
1460 <  TPaveText *writeresult = new TPaveText(0.15,0.78,0.49,0.91,"blNDC");
1461 <  writeresult->SetFillStyle(4000);
1462 <  writeresult->SetFillColor(kWhite);
1463 <  writeresult->SetTextFont(42);
1464 <  writeresult->SetTextSize(0.03);
1465 <  writeresult->SetTextAlign(12);
1466 <  ostringstream jzb_agreement_data_text;
1467 <  jzb_agreement_data_text<< setprecision(2) << "mean =" << pol0->GetParameter(0) << " #pm " << setprecision(1) <<  pol0->GetParError(0);
1468 <  if(is_data==1) fitresultconstdata=pol0->GetParameter(0);// data
1469 <  if(is_data==0) fitresultconstmc=pol0->GetParameter(0); // monte carlo, no signal
1470 < /*  if(is_data) writeresult->AddText("Data closure test");
1471 <  else writeresult->AddText("MC closure test");
1472 <  */
1473 <  writeresult->AddText(jzb_agreement_data_text.str().c_str());
1474 < //  writeresult->Draw("same");
1475 < //  pol0d->Draw("same");
1476 <  TF1 *topline =  new TF1("","1.5",0,1000);
1477 <  TF1 *bottomline =  new TF1("","0.5",0,1000);
1478 <  topline->SetLineColor(kBlue);
1479 <  topline->SetLineStyle(2);
1480 <  bottomline->SetLineColor(kBlue);
1481 <  bottomline->SetLineStyle(2);
1482 < //  topline->Draw("same");
1483 < //  bottomline->Draw("same");
1484 <  TF1 *oneline = new TF1("","1.0",0,1000);
1485 <  oneline->SetLineColor(kBlue);
1486 <  oneline->SetLineStyle(1);
1487 <  oneline->Draw("same");
1488 <  TLegend *phony_leg = make_legend("ratio",0.6,0.55,false);//this line is just to have the default CMS Preliminary (...) on the canvas as well.
1489 <  if(is_data==1) DrawPrelim();
1490 <  else DrawMCPrelim();
1491 <  TLegend *leg = new TLegend(0.55,0.75,0.89,0.89);
1492 <  leg->SetTextFont(42);
1493 <  leg->SetTextSize(0.04);
1494 < //   if(is_data==1) leg->SetHeader("Ratio (data)");
1495 < //   else leg->SetHeader("Ratio (MC)");
1496 <
1497 <  TString MCtitle("MC ");
1498 <  if (is_data==1) MCtitle = "";
1499 <
1500 <  leg->SetFillStyle(4000);
1501 <  leg->SetFillColor(kWhite);
1502 <  leg->SetTextFont(42);
1503 < //  leg->AddEntry(topline,"+20\% sys envelope","l");
1504 <  leg->AddEntry(JZBratio,MCtitle+"obs / "+MCtitle+"pred","p");
1505 <  leg->AddEntry(oneline,"ratio = 1","l");
1506 < //  leg->AddEntry(pol0d,"fit in [0,30] GeV","l");
1507 < //  leg->AddEntry(bottomline,"#pm50% envelope","l");
1508 <
1509 <
1510 <  //leg->Draw("same"); // no longer drawing legend
1511 <
1512 <  if(is_data==1) CompleteSave(can, "jzb_ratio_data");
1513 <  if(is_data==0) CompleteSave(can, "jzb_ratio_mc");
1514 <  if(is_data==2) CompleteSave(can, "jzb_ratio_mc_BandS");//special case, MC with signal!
1515 <  
1516 <  delete RcorrJZBeemm;
1517 <  delete LcorrJZBeemm;
1518 <  delete RcorrJZBem;
1519 <  delete LcorrJZBem;
1520 <  
1521 <  delete RcorrJZBSBem;
1522 <  delete LcorrJZBSBem;
1523 <  delete RcorrJZBSBeemm;
1524 <  delete LcorrJZBSbeemm;
1525 < }
1526 <
1527 < void do_ratio_plots(string mcjzb,string datajzb,vector<float> ratio_binning) {
1528 <  TCanvas *globalc = new TCanvas("globalc","Ratio Plot Canvas");
1529 <  globalc->SetLogy(0);
1530 <  
1531 <  do_ratio_plot(mc,ratio_binning,mcjzb,globalc, jzbHigh  );
1532 <  do_ratio_plot(data,ratio_binning,datajzb,globalc, jzbHigh  );
1533 <  do_ratio_plot(mcwithsignal,ratio_binning,mcjzb,globalc, jzbHigh  );
1718 >  delete globalcanvas;
1719 >  switch_overunderflow(false);
1720   }
1721  
1722   string give_jzb_expression(float peak, int type) {
# Line 1722 | Line 1908 | void draw_pure_jzb_histo(TCut cut,string
1908    datahisto->Draw("same,e1");
1909    
1910    TLegend *leg;
1911 <  if(is_OF(cut) && is_ZP(cut)) leg = allsamples.allbglegend("OFZP",datahisto);
1912 <  else if(!is_OF(cut) &&  is_ZP(cut)) leg = allsamples.allbglegend("SFZP",datahisto);
1913 <  else if( is_OF(cut) && !is_ZP(cut)) leg = allsamples.allbglegend("OFSB",datahisto);
1914 <  else if(!is_OF(cut) && !is_ZP(cut)) leg = allsamples.allbglegend("SFSB",datahisto);
1915 <  else {
1916 <    std::cerr << "Unable to decode cut: " << cut.GetTitle() << std::endl;
1917 <    exit(-1);
1918 <      }
1911 >  if (!PlottingSetup::RestrictToMassPeak||!PlottingSetup::UseSidebandsForcJZB) {
1912 >    if(is_OF(cut)) leg = allsamples.allbglegend("Opposite flavor",datahisto);
1913 >    else leg = allsamples.allbglegend("Same flavor",datahisto);
1914 >  } else {
1915 >    if(is_OF(cut) && is_ZP(cut)) leg = allsamples.allbglegend("OFZP",datahisto);
1916 >    else if(!is_OF(cut) &&  is_ZP(cut)) leg = allsamples.allbglegend("SFZP",datahisto);
1917 >    else if( is_OF(cut) && !is_ZP(cut)) leg = allsamples.allbglegend("OFSB",datahisto);
1918 >    else if(!is_OF(cut) && !is_ZP(cut)) leg = allsamples.allbglegend("SFSB",datahisto);
1919 >    else {
1920 >      std::cerr << "Unable to decode cut: " << cut.GetTitle() << std::endl;
1921 >      exit(-1);
1922 >    }
1923 >  }
1924    leg->Draw();
1925    string write_cut = decipher_cut(cut,"");
1926    TText *writeline1 = write_cut_on_canvas(write_cut.c_str());
# Line 1780 | Line 1971 | void produce_stretched_jzb_plots(string
1971    draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass&&"id1==1",datajzb,mcjzb,"Dibosons/mm/jzb_OS_SFZP",dican,binning);
1972    draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass&&"id1==0",datajzb,mcjzb,"Dibosons/ee/jzb_OS_OFZP",dican,binning);
1973    draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass&&"id1==1",datajzb,mcjzb,"Dibosons/mm/jzb_OS_OFZP",dican,binning);
1974 <  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"Dibosons/jzb_OS_SFSB",dican,binning);
1975 <  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"Dibosons/jzb_OS_OFSB",dican,binning);
1974 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"Dibosons/jzb_OS_SFSB",dican,binning);
1975 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"Dibosons/jzb_OS_OFSB",dican,binning);
1976    
1977    draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass,datajzb,mcjzb,"Dibosons/jzb_OS_SFZP_coarse",dican,coarse_binning);
1978    draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass,datajzb,mcjzb,"Dibosons/jzb_OS_OFZP_coarse",dican,coarse_binning);
1979 <  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"Dibosons/jzb_OS_SFSB_coarse",dican,coarse_binning);
1980 <  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"Dibosons/jzb_OS_OFSB_coarse",dican,coarse_binning);
1979 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"Dibosons/jzb_OS_SFSB_coarse",dican,coarse_binning);
1980 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"Dibosons/jzb_OS_OFSB_coarse",dican,coarse_binning);
1981    
1982    delete dican;
1983   }
1984    
1985  
1986   void diboson_plots(string mcjzb, string datajzb,vector<float> ratio_binning) {
1987 +  switch_overunderflow(true);
1988    vector<int> SamplesToBeModified = allsamples.FindSampleBySampleName("WW/WZ/ZZ");
1989    
1990    if(SamplesToBeModified.size()==0 || SamplesToBeModified[0]==-1) {
# Line 1832 | Line 2024 | void diboson_plots(string mcjzb, string
2024      dout << "     Reset xs for sample " << (allsamples.collection)[SamplesToBeModified[i]].samplename << " from " << Upxs << " to " << (allsamples.collection)[SamplesToBeModified[i]].xs << " (by a factor of " << stretchfactor << ") and reset the correct name (from " << Upname << ")" << endl;
2025      
2026    }
2027 <  
2027 > //   switch_overunderflow(false);
2028   }
2029  
2030  
# Line 1867 | Line 2059 | void draw_normalized_data_vs_data_histo(
2059  
2060  
2061   void jzb_plots(string mcjzb, string datajzb,vector<float> ratio_binning) {
2062 +  switch_overunderflow(true);
2063    TCanvas *can = new TCanvas("can","JZB Plots Canvas");
2064    float max=jzbHigh ;
2065    float min=-120;
# Line 1887 | Line 2080 | void jzb_plots(string mcjzb, string data
2080      draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass&&"id1==0",datajzb,mcjzb,"ee/jzb_OS_OFZP",can,binning);
2081      draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass&&"id1==1",datajzb,mcjzb,"mm/jzb_OS_OFZP",can,binning);
2082      flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
2083 <    if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_SFSB",can,binning);
2084 <    if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_OFSB",can,binning);
1892 <
2083 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_SFSB",can,binning);
2084 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_OFSB",can,binning);
2085      draw_normalized_data_vs_data_histo(cutOSOF&&cutnJets&&cutmass&&"id1==0",cutOSOF&&cutnJets&&cutmass&&"id1==1",datajzb,"ee","mm","jzb_ee_vs_mm",can,binning);
2086      draw_normalized_data_vs_data_histo(cutOSOF&&cutnJets&&cutmass&&"id1==0",cutOSOF&&cutnJets&&cutmass&&"id1==1",datajzb,"ee","mm","jzb_ee_vs_mm_coarse",can,coarse_binning);
2087 +    draw_normalized_data_vs_data_histo(cutOSOF&&cutnJets&&cutmass&&"id1==0",cutOSOF&&cutnJets&&cutmass&&"id1==1",datajzb,"ee","mm","jzb_ee_vs_mm_coarsest",can,coarsest_binning);
2088  
2089    }
2090    
# Line 1899 | Line 2092 | void jzb_plots(string mcjzb, string data
2092    if ( !PlottingSetup::Approved ) {
2093      draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_OFZP_coarse",can,coarse_binning);
2094      flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
2095 <    if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_SFSB_coarse",can,coarse_binning);
2096 <    if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_OFSB_coarse",can,coarse_binning);
2095 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_SFSB_coarse",can,coarse_binning);
2096 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_OFSB_coarse",can,coarse_binning);
2097    }
2098    delete can;
2099 +  switch_overunderflow(false);
2100   }
2101  
2102  
# Line 1952 | Line 2146 | void compute_MC_yields(string mcjzb,vect
2146    TCanvas *yica = new TCanvas("yica","yield canvas");
2147    
2148    int nRegions=4;
2149 <  if(!PlottingSetup::RestrictToMassPeak) nRegions=2;
2149 >  if(!PlottingSetup::RestrictToMassPeak||!PlottingSetup::UseSidebandsForcJZB) nRegions=2;
2150    string tsRegions[] = {"SFZP","OFZP","SFSB","OFSB"};
2151    string posneg[] = {"pos","neg"};
2152    TCut tkRegions[] = {cutOSSF&&cutnJets&&cutmass,cutOSOF&&cutnJets&&cutmass,cutOSSF&&cutnJets&&sidebandcut,cutOSOF&&cutnJets&&sidebandcut};
# Line 2243 | Line 2437 | float find_one_correction_factor(string
2437    TCanvas *cancorr = new TCanvas("cancorr","Canvas for Response Correction");
2438    cancorr->SetLogz();
2439    cancorr->SetRightMargin(0.13);
2440 <  TCut zptforresponsepresentation("pt<600"&&cutmass&&cutOSSF&&"((sumJetPt[1]/pt)<5.0)"&&SpecialCut&&passtrig);
2440 >  TCut zptforresponsepresentation(Restrmasscut&&SpecialCut&&passtrig);
2441 >
2442    if(PlottingSetup::DoBTag) zptforresponsepresentation=zptforresponsepresentation&&PlottingSetup::bTagRequirement;
2443    TH2F *niceresponseplotd = new TH2F("niceresponseplotd","",100,0,600,100,0,5);
2444 +  niceresponseplotd->Sumw2();
2445 +  TH2F* emuResponse = (TH2F*)niceresponseplotd->Clone("emuResponse");
2446    vector<int> SampleIndices=allsamples.FindSample(FindKeyword);
2447    for(int iSample=0;iSample<(int)SampleIndices.size();iSample++) {
2448      if((allsamples.collection)[SampleIndices[iSample]].is_data && !dodata) continue;
2449      if((allsamples.collection)[SampleIndices[iSample]].is_data ==false && dodata) continue;
2450      
2451      dout << "   Response correction : Using sample " << (allsamples.collection)[SampleIndices[iSample]].filename << " for " << FindKeyword << endl;
2452 <    (allsamples.collection)[SampleIndices[iSample]].events->Draw("sumJetPt[1]/pt:pt>>+niceresponseplotd",zptforresponsepresentation*cutWeight);
2452 >    (allsamples.collection)[SampleIndices[iSample]].events->Draw("sumJetPt[1]/pt:pt>>+niceresponseplotd",(zptforresponsepresentation&&cutOSSF)*cutWeight);
2453 >    (allsamples.collection)[SampleIndices[iSample]].events->Draw("sumJetPt[1]/pt:pt>>+emuResponse",(zptforresponsepresentation&&cutOSOF)*cutWeight);
2454    }
2455 <    
2455 >  niceresponseplotd->Add(emuResponse,-1);
2456 >  
2457    niceresponseplotd->SetStats(0);
2458    niceresponseplotd->GetXaxis()->SetTitle("Z p_{T} [GeV]");
2459    niceresponseplotd->GetYaxis()->SetTitle("Response");
# Line 2262 | Line 2461 | float find_one_correction_factor(string
2461    niceresponseplotd->GetYaxis()->CenterTitle();
2462    niceresponseplotd->Draw("COLZ");
2463    TProfile * profd = (TProfile*)niceresponseplotd->ProfileX();
2464 +  profd->Rebin(2);
2465    profd->SetMarkerSize(DataMarkerSize);
2466    profd->Fit("pol0","","same,e1",100,400);
2467    DrawPrelim();
# Line 2281 | Line 2481 | float find_one_correction_factor(string
2481    CompleteSave(cancorr,"ResponseCorrection/Response_Correction_Illustration_New_"+SaveAs);
2482    delete cancorr;
2483    delete niceresponseplotd;
2484 +  delete profd;
2485    return correction;
2486   }
2487  
# Line 2393 | Line 2594 | void save_template(string mcjzb, string
2594    configfile<<"\n\n";
2595    configfile<<"luminosity="<<luminosity<<";\n";
2596    configfile<<"RestrictToMassPeak="<<RestrictToMassPeak<<";//defines the type of analysis we're running\n";
2597 +  configfile<<"UseSidebandsForcJZB="<<UseSidebandsForcJZB<<";//tells us whether to use the sidebands or not\n";
2598    
2599    configfile<<"\n\ncout << \"Configuration successfully loaded!\" << endl; \n \n } \n \n";
2600    
# Line 2435 | Line 2637 | void ttbar_sidebands_comparison(string m
2637    //in the case of the on peak analysis, we compare the 3 control regions to the real value
2638    //in the case of the OFF peak analysis, we compare our control region to the real value
2639    TCut weightbackup=cutWeight;
2640 +  switch_overunderflow(true);
2641    
2642    bool doPURW=false;
2643    
2644    
2645    if(!doPURW) {
2646 +    dout << "Not doing PU reweighting for ttbar closure test" << endl;
2647      cutWeight="1.0";
2648      // Do it without PU re-weighting
2649      float MCPeakNoPU=0,MCPeakErrorNoPU=0,DataPeakNoPU=0,DataPeakErrorNoPU=0,MCSigma=0,DataSigma=0;
# Line 2449 | Line 2653 | void ttbar_sidebands_comparison(string m
2653      
2654      stringstream mcjzbnoPU;
2655      find_peaks(MCPeakNoPU,MCPeakErrorNoPU, DataPeakNoPU, DataPeakErrorNoPU,resultsNoPU,true,noPUdatajzb,noPUmcjzb);
2656 <    if(MCPeakNoPU>0) mcjzbnoPU<<"("<<jzbvariablemc<<"-"<<TMath::Abs(MCPeakNoPU)<<")";
2453 <    else mcjzbnoPU<<"("<<jzbvariablemc<<"+"<<TMath::Abs(MCPeakNoPU)<<")";
2454 <    dout << "The peak corrected JZB expression for MC without pileup is : " <<  mcjzbnoPU.str() << endl;
2455 <    
2456 <    mcjzb = mcjzbnoPU.str();
2457 <    
2656 >    mcjzb = noPUmcjzb.str();
2657    }
2658  
2659 <    
2461 <    
2462 <    
2463 <    
2464 <    
2659 >      
2660    float simulatedlumi = luminosity; //in pb please - adjust to your likings
2661  
2662 <  TH1F *TZem = systsamples.Draw("TZem",mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSOF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2662 >  TH1F *TZem  = systsamples.Draw("TZem",     mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSOF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2663    TH1F *nTZem = systsamples.Draw("nTZem","-"+mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSOF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2664    TH1F *TSem;
2665    TH1F *nTSem;
2666 <  TH1F *TZeemm = systsamples.Draw("TZeemm",mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2666 >  TH1F *TZeemm  = systsamples.Draw("TZeemm",     mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2667    TH1F *nTZeemm = systsamples.Draw("nTZeemm","-"+mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2668    TH1F *TSeemm;
2669    TH1F *nTSeemm;
2670    
2671 <  if(PlottingSetup::RestrictToMassPeak) {
2672 <    TSem = systsamples.Draw("TSem",mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSOF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2673 <    nTSem = systsamples.Draw("nTSem","-"+mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSOF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2674 <    TSeemm = systsamples.Draw("TSeemm",mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSSF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2671 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2672 >    TSem    = systsamples.Draw("TSem",       mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSOF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2673 >    nTSem   = systsamples.Draw("nTSem",  "-"+mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSOF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2674 >    TSeemm  = systsamples.Draw("TSeemm",     mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSSF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2675      nTSeemm = systsamples.Draw("nTSeemm","-"+mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSSF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2676    }
2677  
2678    TCanvas *tcan = new TCanvas("tcan","tcan");
2484  
2679    tcan->SetLogy(1);
2680    
2681    TZeemm->SetLineColor(kBlack);
# Line 2490 | Line 2684 | void ttbar_sidebands_comparison(string m
2684    TZem->SetMarkerColor(kRed);
2685  
2686  
2687 <  if(PlottingSetup::RestrictToMassPeak) {
2687 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2688          TSem->SetLineColor(TColor::GetColor("#00A616"));
2689          TSeemm->SetLineColor(kMagenta+2);
2690          TSem->SetMarkerColor(TColor::GetColor("#00A616"));
# Line 2504 | Line 2698 | void ttbar_sidebands_comparison(string m
2698    TZeemm->GetXaxis()->SetRangeUser(-100,binning[binning.size()-1]);
2699    histos.push_back(TZem);
2700    histos.push_back(TZeemm);
2701 <  if(PlottingSetup::RestrictToMassPeak) {
2701 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2702      TSeemm->GetXaxis()->SetRangeUser(-100,binning[binning.size()-1]);
2703      TSem->GetXaxis()->SetRangeUser(-100,binning[binning.size()-1]);
2704      histos.push_back(TSem);
2705      histos.push_back(TSeemm);
2706    }
2707 <  draw_all_ttbar_histos(tcan,histos,"histo",0.04);
2707 >  draw_all_ttbar_histos(tcan,histos,"histo",8);
2708    
2709    TLegend *leg = make_legend("MC t#bar{t}",0.6,0.65,false);
2710    leg->AddEntry(TZeemm,"SFZP","l");
2711    leg->AddEntry(TZem,"OFZP","l");
2712 <  if(PlottingSetup::RestrictToMassPeak) {
2712 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2713      leg->AddEntry(TSeemm,"SFSB","l");
2714      leg->AddEntry(TSem,"OFSB","l");
2715    }
2716    leg->Draw("same");
2717    DrawMCPrelim(simulatedlumi);
2718    CompleteSave(tcan,"Systematics/"+prestring+"/ttbar_shape_comparison");
2719 +  
2720    TH1F *TZemcopy = (TH1F*)TZem->Clone("TZemcopy");
2721    TH1F *TZeemmcopy = (TH1F*)TZeemm->Clone("TZeemmcopy");
2722    TH1F *TSeemmcopy;
2723    TH1F *TSemcopy;
2724 <  if(PlottingSetup::RestrictToMassPeak) {
2724 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2725      TSeemmcopy = (TH1F*)TSeemm->Clone("TSeemmcopy");
2726      TSemcopy = (TH1F*)TSem->Clone("TSemcopy");
2727    }
2728  
2729    TZem->Divide(TZeemm);
2730    TZem->SetMarkerStyle(21);
2731 <  if(PlottingSetup::RestrictToMassPeak) {
2731 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2732      TSem->Divide(TZeemm);
2733      TSeemm->Divide(TZeemm);
2734      TSem->SetMarkerStyle(24);
2735      TSeemm->SetMarkerStyle(32);
2736 < }
2736 >  }
2737  
2738    tcan->SetLogy(0);
2739    TZem->GetYaxis()->SetRangeUser(0,2.5);
2740    TZem->GetYaxis()->SetTitle("ratio");
2741    TZem->Draw();
2742 <  if(PlottingSetup::RestrictToMassPeak) {
2742 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2743      TSem->Draw("same");
2744      TSeemm->Draw("same");
2745    }
# Line 2574 | Line 2769 | void ttbar_sidebands_comparison(string m
2769    
2770    TLegend *leg2 = make_legend("MC t#bar{t}",0.55,0.75,false);
2771    leg2->AddEntry(TZem,"OFZP / SFZP","ple");
2772 <  if(PlottingSetup::RestrictToMassPeak) {
2772 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2773      leg2->AddEntry(TSeemm,"SFSB / SFZP","ple");
2774      leg2->AddEntry(TSem,"OFSB / SFZP","ple");
2775    }
# Line 2587 | Line 2782 | void ttbar_sidebands_comparison(string m
2782    DrawMCPrelim(simulatedlumi);
2783    CompleteSave(tcan,"Systematics/"+prestring+"/ttbar_shape_comparison_ratio");
2784    
2785 +  
2786 +  if (0) { // Turn this off: we don't need this
2787  
2788 < ///-------------- second part: only look at the quantity we actually care about!
2789 <  TH1F *leftsfzp  = (TH1F*)nTZeemm->Clone("leftsfzp");
2790 <  TH1F *rightsfzp = (TH1F*)TZeemmcopy->Clone("rightsfzp");
2791 <  rightsfzp->Add(leftsfzp,-1);
2792 <  TH1F *leftofzp  = (TH1F*)nTZem->Clone("leftofzp");
2793 <  TH1F *rightofzp = (TH1F*)TZemcopy->Clone("rightofzp");
2794 <  rightofzp->Add(leftofzp,-1);
2795 <  TH1F *leftofsb;
2796 <  TH1F *rightofsb;
2797 <  TH1F *leftsfsb;
2798 <  TH1F *rightsfsb;
2799 <  if(PlottingSetup::RestrictToMassPeak) {
2800 <        leftofsb  = (TH1F*)nTSem->Clone("leftofsb");
2801 <        rightofsb = (TH1F*)TSemcopy->Clone("rightofsb");
2802 <        rightofsb->Add(leftofsb,-1);
2803 <        leftsfsb  = (TH1F*)nTSeemm->Clone("leftsfsb");
2804 <        rightsfsb = (TH1F*)TSeemmcopy->Clone("rightsfsb");
2805 <        rightsfsb->Add(leftsfsb,-1);
2806 <  }
2788 >    ///-------------- second part: only look at the quantity we actually care about!
2789 >    TH1F *leftsfzp  = (TH1F*)nTZeemm->Clone("leftsfzp");
2790 >    TH1F *rightsfzp = (TH1F*)TZeemmcopy->Clone("rightsfzp");
2791 >    rightsfzp->Add(leftsfzp,-1);
2792 >    TH1F *leftofzp  = (TH1F*)nTZem->Clone("leftofzp");
2793 >    TH1F *rightofzp = (TH1F*)TZemcopy->Clone("rightofzp");
2794 >    rightofzp->Add(leftofzp,-1);
2795 >    TH1F *leftofsb;
2796 >    TH1F *rightofsb;
2797 >    TH1F *leftsfsb;
2798 >    TH1F *rightsfsb;
2799 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2800 >      leftofsb  = (TH1F*)nTSem->Clone("leftofsb");
2801 >      rightofsb = (TH1F*)TSemcopy->Clone("rightofsb");
2802 >      rightofsb->Add(leftofsb,-1);
2803 >      leftsfsb  = (TH1F*)nTSeemm->Clone("leftsfsb");
2804 >      rightsfsb = (TH1F*)TSeemmcopy->Clone("rightsfsb");
2805 >      rightsfsb->Add(leftsfsb,-1);
2806 >    }
2807  
2808 <  tcan->SetLogy(1);
2809 <  rightsfzp->GetXaxis()->SetRangeUser(0,binning[binning.size()-1]);
2810 <  rightsfzp->GetYaxis()->SetTitle("#deltaJZB / 25 GeV");
2811 <  rightsfzp->Draw("histo");
2812 <  rightofzp->Draw("histo,same");
2813 <  if(PlottingSetup::RestrictToMassPeak) {
2814 <    rightofsb->Draw("histo,same");
2815 <    rightsfsb->Draw("histo,same");
2816 <  }
2817 <  DrawMCPrelim(simulatedlumi);
2808 >    tcan->SetLogy(1);
2809 >    rightsfzp->GetXaxis()->SetRangeUser(0,binning[binning.size()-1]);
2810 >    rightsfzp->GetYaxis()->SetTitle("#deltaJZB / 25 GeV");
2811 >    rightsfzp->Draw("histo");
2812 >    rightofzp->Draw("histo,same");
2813 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2814 >      rightofsb->Draw("histo,same");
2815 >      rightsfsb->Draw("histo,same");
2816 >    }
2817 >    DrawMCPrelim(simulatedlumi);
2818  
2819 <  TLegend *legA = make_legend("MC t#bar{t}",0.6,0.65,false);
2820 <  legA->AddEntry(rightsfzp,"SFZP","l");
2821 <  legA->AddEntry(rightofzp,"OFZP","l");
2822 <  if(PlottingSetup::RestrictToMassPeak) {
2823 <    legA->AddEntry(rightofsb,"SFSB","l");
2824 <    legA->AddEntry(rightsfsb,"OFSB","l");
2825 <  }
2826 <  legA->Draw();
2819 >    TLegend *legA = make_legend("MC t#bar{t}",0.6,0.65,false);
2820 >    legA->AddEntry(rightsfzp,"SFZP","l");
2821 >    legA->AddEntry(rightofzp,"OFZP","l");
2822 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2823 >      legA->AddEntry(rightofsb,"SFSB","l");
2824 >      legA->AddEntry(rightsfsb,"OFSB","l");
2825 >    }
2826 >    legA->Draw();
2827  
2828 <  CompleteSave(tcan,"Systematics/"+prestring+"/ttbar_deltajzb_comparison");
2828 >    CompleteSave(tcan,"Systematics/"+prestring+"/ttbar_deltajzb_comparison");
2829  
2830 <  tcan->SetLogy(0);
2831 <  rightofzp->Divide(rightsfzp);
2832 <  rightofzp->GetXaxis()->SetRangeUser(0.0,binning[binning.size()-1]);
2833 <  rightofzp->GetYaxis()->SetRangeUser(0.0,2.5);
2834 <  rightofzp->GetYaxis()->SetTitle("#deltaJZB ratio");
2835 <  rightofzp->Draw();
2836 <  if(PlottingSetup::RestrictToMassPeak) {
2837 <    rightofsb->Divide(rightsfzp);
2838 <    rightsfsb->Divide(rightsfzp);
2839 <    rightofsb->Draw("same");
2840 <    rightsfsb->Draw("same");
2841 <  }
2842 <
2843 <  TLine *top2 = new TLine(0.0,1.0+linepos,binning[binning.size()-1],1.0+linepos);
2844 <  TLine *center2 = new TLine(0.0,1.0,binning[binning.size()-1],1.0);
2845 <  TLine *bottom2 = new TLine(0.0,1.0-linepos,binning[binning.size()-1],1.0-linepos);
2846 <  
2847 <  top2->SetLineColor(kBlue);top2->SetLineStyle(2);
2848 <  bottom2->SetLineColor(kBlue);bottom2->SetLineStyle(2);
2849 <  center2->SetLineColor(kBlue);
2850 <  
2851 <  top2->Draw("same");
2852 <  center2->Draw("same");
2853 <  bottom2->Draw("same");
2854 <
2855 <  rightofzp->SetMarkerStyle(21);
2856 <  if(PlottingSetup::RestrictToMassPeak) {
2857 <    rightofsb->SetMarkerStyle(24);
2858 <    rightsfsb->SetMarkerStyle(32);
2859 <  }
2860 <
2861 <  TLegend *leg3 = make_legend("MC t#bar{t}",0.55,0.75,false);
2862 <  leg3->AddEntry(rightofzp,"OFZP / SFZP","ple");
2863 <  if(PlottingSetup::RestrictToMassPeak) {
2864 <        leg3->AddEntry(rightsfsb,"SFSB / SFZP","ple");
2865 <        leg3->AddEntry(rightofsb,"OFSB / SFZP","ple");
2866 <  }
2867 <  leg3->AddEntry(bottom,"syst. envelope","l");
2868 <  leg3->SetX1(0.25);leg3->SetX2(0.6);
2869 <  leg3->SetY1(0.65);
2830 >    tcan->SetLogy(0);
2831 >    rightofzp->Divide(rightsfzp);
2832 >    rightofzp->GetXaxis()->SetRangeUser(0.0,binning[binning.size()-1]);
2833 >    rightofzp->GetYaxis()->SetRangeUser(0.0,2.5);
2834 >    rightofzp->GetYaxis()->SetTitle("#deltaJZB ratio");
2835 >    rightofzp->Draw();
2836 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2837 >      rightofsb->Divide(rightsfzp);
2838 >      rightsfsb->Divide(rightsfzp);
2839 >      rightofsb->Draw("same");
2840 >      rightsfsb->Draw("same");
2841 >    }
2842 >
2843 >    TLine *top2 = new TLine(0.0,1.0+linepos,binning[binning.size()-1],1.0+linepos);
2844 >    TLine *center2 = new TLine(0.0,1.0,binning[binning.size()-1],1.0);
2845 >    TLine *bottom2 = new TLine(0.0,1.0-linepos,binning[binning.size()-1],1.0-linepos);
2846 >  
2847 >    top2->SetLineColor(kBlue);top2->SetLineStyle(2);
2848 >    bottom2->SetLineColor(kBlue);bottom2->SetLineStyle(2);
2849 >    center2->SetLineColor(kBlue);
2850 >  
2851 >    top2->Draw("same");
2852 >    center2->Draw("same");
2853 >    bottom2->Draw("same");
2854 >
2855 >    rightofzp->SetMarkerStyle(21);
2856 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2857 >      rightofsb->SetMarkerStyle(24);
2858 >      rightsfsb->SetMarkerStyle(32);
2859 >    }
2860 >
2861 >    TLegend *leg3 = make_legend("MC t#bar{t}",0.55,0.75,false);
2862 >    leg3->AddEntry(rightofzp,"OFZP / SFZP","ple");
2863 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2864 >      leg3->AddEntry(rightsfsb,"SFSB / SFZP","ple");
2865 >      leg3->AddEntry(rightofsb,"OFSB / SFZP","ple");
2866 >    }
2867 >    leg3->AddEntry(bottom,"syst. envelope","l");
2868 >    leg3->SetX1(0.25);leg3->SetX2(0.6);
2869 >    leg3->SetY1(0.65);
2870    
2871 <  leg3->Draw("same");
2871 >    leg3->Draw("same");
2872    
2873 <  DrawMCPrelim(simulatedlumi);
2874 <  CompleteSave(tcan,"Systematics/"+prestring+"/ttbar_deltajzb_comparison_ratio");
2873 >    DrawMCPrelim(simulatedlumi);
2874 >    CompleteSave(tcan,"Systematics/"+prestring+"/ttbar_deltajzb_comparison_ratio");
2875 >
2876 >  }
2877  
2878    delete TZem;
2879    delete nTZem;
2880    delete TZeemm;
2881    delete nTZeemm;
2882 <  if(PlottingSetup::RestrictToMassPeak) {
2882 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2883          delete TSem;
2884          delete nTSem;
2885          delete TSeemm;
# Line 2689 | Line 2888 | void ttbar_sidebands_comparison(string m
2888  
2889    delete tcan;
2890    cutWeight=weightbackup;
2891 +  switch_overunderflow(false);
2892   }
2893  
2894   void ttbar_sidebands_comparison(string mcjzb, vector<float> jzb_binning) {
# Line 2721 | Line 2921 | void ttbar_sidebands_comparison(string m
2921    nicer_binning.push_back(100);
2922    nicer_binning.push_back(125);
2923    nicer_binning.push_back(150);
2924 <  nicer_binning.push_back(175);
2924 >  //nicer_binning.push_back(175);
2925    nicer_binning.push_back(200);
2926 <  nicer_binning.push_back(230);
2927 <  nicer_binning.push_back(280);
2928 <  nicer_binning.push_back(400);
2926 > //  nicer_binning.push_back(250);
2927 > //  nicer_binning.push_back(300);
2928 > //  nicer_binning.push_back(400);
2929    
2930    ttbar_sidebands_comparison(mcjzb,nicer_binning, "ttbar/");
2931   }
2932  
2933  
2934   void zjets_prediction_comparison(string mcjzbWithPUa) {
2935 +  cout << "****************************************************************************************************************************************************************" << endl;
2936    TCanvas *zcan = new TCanvas("zcan","zcan");  
2937 <  zcan->SetLogy(1);
2937 > //  zcan->SetLogy(1);
2938    TCut weightbackup=cutWeight;
2939 <
2940 <
2941 <  // Do it without PU re-weighting
2942 <  float MCPeakNoPU=0,MCPeakErrorNoPU=0,DataPeakNoPU=0,DataPeakErrorNoPU=0,MCSigma=0,DataSigma=0;
2943 <  stringstream resultsNoPU;
2944 <  stringstream noPUdatajzb;
2945 <  stringstream noPUmcjzb;
2946 <
2947 <  stringstream mcjzbnoPU;
2948 < //  void find_peaks(float &MCPeak,float &MCPeakError, float &DataPeak, float &DataPeakError, stringstream &result, bool doPUreweighting, stringstream &datajzb, stringstream &mcjzb)
2949 <  find_peaks(MCPeakNoPU,MCPeakErrorNoPU, DataPeakNoPU, DataPeakErrorNoPU,resultsNoPU,true,noPUdatajzb,noPUmcjzb);
2950 <  if(MCPeakNoPU>0) mcjzbnoPU<<"("<<jzbvariablemc<<"-"<<TMath::Abs(MCPeakNoPU)<<")";
2951 <  else mcjzbnoPU<<"("<<jzbvariablemc<<"+"<<TMath::Abs(MCPeakNoPU)<<")";
2952 <  dout << "The peak corrected JZB expression for MC without pileup is : " <<  mcjzbnoPU.str() << endl;
2953 <
2954 <  string mcjzb = mcjzbnoPU.str();
2955 <
2956 <  cutWeight="1.0";
2939 >  
2940 >  bool UsePURW=true;
2941 >  
2942 >  
2943 >  string mcjzb;
2944 >  if(UsePURW) {
2945 >    mcjzb=mcjzbWithPUa;
2946 >    cout << "Using PURW peak positions" << endl;
2947 >  } else {
2948 >    // Do it without PU re-weighting
2949 >    cutWeight="1.0";
2950 >    float MCPeakNoPU=0,MCPeakErrorNoPU=0,DataPeakNoPU=0,DataPeakErrorNoPU=0,MCSigma=0,DataSigma=0;
2951 >    stringstream resultsNoPU;
2952 >    stringstream noPUdatajzb;
2953 >    stringstream noPUmcjzb;
2954 >    
2955 >    find_peaks(MCPeakNoPU,MCPeakErrorNoPU, DataPeakNoPU, DataPeakErrorNoPU,resultsNoPU,false,noPUdatajzb,noPUmcjzb);
2956 >    dout << "The peak corrected JZB expression for MC without pileup is : " <<  noPUmcjzb.str() << endl;
2957 >    
2958 >    mcjzb = noPUmcjzb.str();
2959 >    
2960 >  }
2961  
2962    
2963    vector<float> binning;
# Line 2760 | Line 2965 | void zjets_prediction_comparison(string
2965    binning.push_back(10);
2966    binning.push_back(20);
2967    binning.push_back(40);
2968 < //  binning.push_back(80);
2968 >  binning.push_back(60);
2969 > //   binning.push_back(50);
2970 > //   binning.push_back(60);
2971 > //   binning.push_back(70);
2972 > //   binning.push_back(80);
2973 > //   binning.push_back(90);
2974    binning.push_back(100);
2975 < //  float sbg_min=0.;
2766 < //  float sbg_max=100.;
2767 < //  int sbg_nbins=5;
2975 >
2976    float simulatedlumi = luminosity;//in pb please - adjust to your likings
2977    
2978    TCut kPos((mcjzb+">0").c_str());
2979    TCut kNeg((mcjzb+"<0").c_str());
2980    string var( "abs("+mcjzb+")" );
2981 +  
2982 +  TCut notTau("abs(genMID1)!=15");
2983 +  TCut ee_mm_tautau("mll>0");
2984 +  
2985  
2986 <  TCut kcut(cutmass&&cutOSSF&&cutnJets);
2987 <  TH1F *hJZBpos = systsamples.Draw("hJZBpos",var,binning, "JZB [GeV]", "events",kcut&&kPos,mc,simulatedlumi,systsamples.FindSample("/DY"));
2988 <  TH1F *hJZBneg = systsamples.Draw("hJZBneg",var,binning, "JZB [GeV]", "events",kcut&&kNeg,mc,simulatedlumi,systsamples.FindSample("/DY"));
2986 >  TH1F *hJZBpos = systsamples.Draw("hJZBpos",var,binning, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets&&notTau&&kPos,mc,simulatedlumi,systsamples.FindSample("/DY"));
2987 >  TH1F *hJZBneg = systsamples.Draw("hJZBneg",var,binning, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets&&notTau&&kNeg,mc,simulatedlumi,systsamples.FindSample("/DY"));
2988 >  
2989    hJZBpos->SetLineColor(kBlack);
2990    hJZBneg->SetLineColor(kRed);
2991    
# Line 2782 | Line 2994 | void zjets_prediction_comparison(string
2994    hJZBneg->Draw("same,hist");
2995    hJZBpos->Draw("same,e1"); // So it's on top...
2996    
2997 <  TLegend *leg = make_legend("MC Z+jets",0.55,0.75,false);
2997 >  TLegend *leg = make_legend("MC Z+jets #rightarrow ee,#mu#mu",0.55,0.75,false);
2998    leg->AddEntry(hJZBpos,"Observed","pe");
2999    leg->AddEntry(hJZBneg,"Predicted","l");
3000    leg->Draw("same");
3001    DrawMCPrelim(simulatedlumi);
3002 <  CompleteSave(zcan,"Systematics/zjets_prediction");
3002 >  CompleteSave(zcan,"Systematics/ZJets/zjets_eemm_prediction");
3003    
3004    TH1F* hratio = (TH1F*)hJZBpos->Clone("hratio");
3005    hratio->Divide(hJZBneg);
3006    
3007    for(int i=1;i<=hJZBpos->GetNbinsX();i++) {
3008 <    cout << "Positive: " << hJZBpos->GetBinContent(i) << "   vs    Negative : " << hJZBneg->GetBinContent(i) << endl;
3008 >    cout << "Positive: " << hJZBpos->GetBinContent(i) << "   vs    Negative : " << hJZBneg->GetBinContent(i) << "   (ratio : " << hJZBpos->GetBinContent(i) / hJZBneg->GetBinContent(i) << endl;
3009    }
3010    
3011    zcan->SetLogy(0);
# Line 2814 | Line 3026 | void zjets_prediction_comparison(string
3026    center->Draw("same");
3027    bottom->Draw("same");
3028    
3029 <  TLegend *leg2 = make_legend("MC Z+jets",0.25,0.75,false);
3029 >  TLegend *leg2 = make_legend("MC Z+jets #rightarrow ee,#mu#mu",0.25,0.75,false);
3030    leg2->AddEntry(hratio,"obs / pred","pe");
3031    leg2->AddEntry(bottom,"syst. envelope","l");
3032    leg2->Draw("same");
3033    DrawMCPrelim(simulatedlumi);
3034 <  CompleteSave(zcan,"Systematics/zjets_prediction_ratio");
3034 >  CompleteSave(zcan,"Systematics/ZJets/zjets_eemm_prediction_ratio");
3035 >  
3036 >  TCut reducedNJets(cutnJets);
3037 >  
3038 >  TH1F *TAUhJZBpos = systsamples.Draw("TAUhJZBpos",var,binning, "JZB [GeV]", "events",cutmass&&cutOSSF&&reducedNJets&&ee_mm_tautau&&kPos,mc,simulatedlumi,systsamples.FindSample("/DY"));
3039 >  TH1F *LcorrJZBeemm     = systsamples.Draw("LcorrJZBeemm",var,binning, "JZB [GeV]", "events",cutmass&&cutOSSF&&reducedNJets&&ee_mm_tautau&&kNeg,mc,simulatedlumi,systsamples.FindSample("/DY"));
3040 >  TH1F *RcorrJZBem       = systsamples.Draw("RcorrJZBem",var,binning, "JZB [GeV]", "events",cutmass&&cutOSOF&&reducedNJets&&ee_mm_tautau&&kPos,mc,simulatedlumi,systsamples.FindSample("/DY"));
3041 >  TH1F *LcorrJZBem       = systsamples.Draw("LcorrJZBem",var,binning, "JZB [GeV]", "events",cutmass&&cutOSOF&&reducedNJets&&ee_mm_tautau&&kNeg,mc,simulatedlumi,systsamples.FindSample("/DY"));
3042 >
3043 >  TH1F *RcorrJZBSBem;
3044 >  TH1F *LcorrJZBSBem;
3045 >  TH1F *RcorrJZBSBeemm;
3046 >  TH1F *LcorrJZBSBeemm;
3047 >
3048 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
3049 >    RcorrJZBSBem   = systsamples.Draw("RcorrJZBSBem",var,binning, "JZB [GeV]", "events",sidebandcut&&cutOSOF&&reducedNJets&&ee_mm_tautau&&kPos,mc,simulatedlumi,systsamples.FindSample("/DY"));
3050 >    LcorrJZBSBem   = systsamples.Draw("LcorrJZBSBem",var,binning, "JZB [GeV]", "events",sidebandcut&&cutOSOF&&reducedNJets&&ee_mm_tautau&&kNeg,mc,simulatedlumi,systsamples.FindSample("/DY"));
3051 >    RcorrJZBSBeemm = systsamples.Draw("RcorrJZBSBeemm",var,binning, "JZB [GeV]", "events",sidebandcut&&cutOSSF&&reducedNJets&&ee_mm_tautau&&kPos,mc,simulatedlumi,systsamples.FindSample("/DY"));
3052 >    LcorrJZBSBeemm = systsamples.Draw("LcorrJZBSBeemm",var,binning, "JZB [GeV]", "events",sidebandcut&&cutOSSF&&reducedNJets&&ee_mm_tautau&&kNeg,mc,simulatedlumi,systsamples.FindSample("/DY"));
3053 >  }
3054 >  
3055 >  TH1F *Bpred = (TH1F*)LcorrJZBeemm->Clone("Bpred");
3056 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
3057 >    Bpred->Add(RcorrJZBem,1.0/3.);
3058 >    Bpred->Add(LcorrJZBem,-1.0/3.);
3059 >    Bpred->Add(RcorrJZBSBem,1.0/3.);
3060 >    Bpred->Add(LcorrJZBSBem,-1.0/3.);
3061 >    Bpred->Add(RcorrJZBSBeemm,1.0/3.);
3062 >    Bpred->Add(LcorrJZBSBeemm,-1.0/3.);
3063 >  } else {
3064 >    Bpred->Add(RcorrJZBem,1.0);
3065 >    Bpred->Add(LcorrJZBem,-1.0);
3066 >  }
3067 >  
3068 >  Bpred->SetLineColor(kRed);
3069 >
3070 >  TAUhJZBpos->SetLineColor(kBlack);
3071 >  Bpred->SetLineColor(kRed);
3072 >  
3073 >  TAUhJZBpos->SetMinimum(1.0);
3074 >  TAUhJZBpos->Draw("e1");
3075 >  Bpred->Draw("same,hist");
3076 >  TAUhJZBpos->Draw("same,e1");
3077 >  
3078 >  TLegend *TAUleg = make_legend("MC Z+jets #rightarrow ee,#mu#mu,#tau#tau",0.55,0.75,false);
3079 >  TAUleg->AddEntry(TAUhJZBpos,"Observed","pe");
3080 >  TAUleg->AddEntry(Bpred,"Predicted","l");
3081 >  TAUleg->Draw("same");
3082 >  DrawMCPrelim(simulatedlumi);
3083 >  CompleteSave(zcan,"Systematics/ZJets/zjets_eemumutautau_prediction");
3084 >  
3085 >  TH1F* TAUhratio = (TH1F*)TAUhJZBpos->Clone("TAUhratio");
3086 >  TAUhratio->Divide(Bpred);
3087 >  
3088 >  for(int i=1;i<=TAUhJZBpos->GetNbinsX();i++) {
3089 >    cout << "ee/mm/tautau observed: " << TAUhJZBpos->GetBinContent(i) << "   vs    predicted : " << Bpred->GetBinContent(i) << "   (ratio : " << TAUhJZBpos->GetBinContent(i) / Bpred->GetBinContent(i) << endl;
3090 >  }
3091 >  
3092 >  zcan->SetLogy(0);
3093 >  TAUhratio->GetYaxis()->SetRangeUser(0,2.5);
3094 >  TAUhratio->GetYaxis()->SetTitle("Observed/Predicted");
3095 >  TAUhratio->Draw("e1");
3096 >  
3097 >  top->Draw("same");
3098 >  center->Draw("same");
3099 >  bottom->Draw("same");
3100 >  
3101 >  TLegend *TAUleg2 = make_legend("MC Z+jets #rightarrow ee,#mu#mu",0.25,0.75,false);
3102 >  TAUleg2->AddEntry(TAUhratio,"obs / pred","pe");
3103 >  TAUleg2->AddEntry(bottom,"syst. envelope","l");
3104 >  TAUleg2->Draw("same");
3105 >  DrawMCPrelim(simulatedlumi);
3106 >  CompleteSave(zcan,"Systematics/ZJets/zjets_eemumutautau_prediction_ratio");
3107 >  
3108 >  delete Bpred;
3109 >  delete TAUhJZBpos;
3110 >  delete LcorrJZBeemm;
3111 >  delete RcorrJZBem;
3112 >  delete LcorrJZBem;
3113 >  
3114 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
3115 >    delete RcorrJZBSBem;
3116 >    delete LcorrJZBSBem;
3117 >    delete RcorrJZBSBeemm;
3118 >    delete LcorrJZBSBeemm;
3119 >  }
3120 >  
3121    
3122    delete zcan;
3123    cutWeight=weightbackup;
# Line 2878 | Line 3176 | void make_table(samplecollection &coll,
3176      TH1F *RcorrJZBSBeemm;
3177      TH1F *LcorrJZBSBeemm;
3178      
3179 <    if(PlottingSetup::RestrictToMassPeak) {
3179 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
3180        RcorrJZBSBem   = coll.Draw("RcorrJZBSBem",jzbexpr.c_str(),nbins,low,14000, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity, mysample);
3181        LcorrJZBSBem   = coll.Draw("LcorrJZBSBem",("-("+jzbexpr+")").c_str(),nbins,low,14000, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity, mysample);
3182        RcorrJZBSBeemm = coll.Draw("RcorrJZBSBeemm",jzbexpr.c_str(),nbins,low,14000, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity, mysample);
# Line 2886 | Line 3184 | void make_table(samplecollection &coll,
3184      }
3185      
3186      TH1F *Bpred = (TH1F*)LcorrJZBeemm->Clone("Bpred");
3187 <    if(PlottingSetup::RestrictToMassPeak) {
3187 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
3188        Bpred->Add(RcorrJZBem,1.0/3.);
3189        Bpred->Add(LcorrJZBem,-1.0/3.);
3190        Bpred->Add(RcorrJZBSBem,1.0/3.);
# Line 3097 | Line 3395 | void qcd_plots(string datajzb, string mc
3395    TH1F *JRcorrJZBSBeemm;
3396    TH1F *JLcorrJZBSBeemm;
3397    
3398 <  if(PlottingSetup::RestrictToMassPeak) {
3398 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
3399      RcorrJZBSBem   = qcdsamples.Draw("RcorrJZBSBem",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
3400      LcorrJZBSBem   = qcdsamples.Draw("LcorrJZBSBem",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
3401      RcorrJZBSBeemm = qcdsamples.Draw("RcorrJZBSBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
# Line 3118 | Line 3416 | void qcd_plots(string datajzb, string mc
3416      
3417    TH1F *Bpred = (TH1F*)LcorrJZBeemm->Clone("Bpred");
3418    TH1F *JBpred = (TH1F*)JLcorrJZBeemm->Clone("Bpred");
3419 <  if(PlottingSetup::RestrictToMassPeak) {
3419 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
3420      Bpred->Add(RcorrJZBem,1.0/3.);
3421      Bpred->Add(LcorrJZBem,-1.0/3.);
3422      Bpred->Add(RcorrJZBSBem,1.0/3.);
# Line 3188 | Line 3486 | void qcd_plots(string datajzb, string mc
3486    dout << "______________________________________________" << endl;
3487    dout << "How QCD shows up in the different regions: " << endl;
3488    dout << "OSSF: " << endl;
3489 <  if(PlottingSetup::RestrictToMassPeak) {
3489 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
3490      dout << "     Z window: \t" << RcorrJZBeemm->Integral() << " (JZB>0) , " << LcorrJZBeemm->Integral() << " (JZB<0) --> total: " << RcorrJZBeemm->Integral() + LcorrJZBeemm->Integral() << endl;
3491      dout << "     sideband: \t" << RcorrJZBSBeemm->Integral() << " (JZB>0) , " << LcorrJZBSBeemm->Integral() << " (JZB<0) --> total: " << RcorrJZBSBeemm->Integral() + LcorrJZBSBeemm->Integral() << endl;
3492    } else {
3493      dout << "     " << RcorrJZBeemm->Integral() << " (JZB>0) , " << LcorrJZBeemm->Integral() << " (JZB<0) --> total: " << RcorrJZBeemm->Integral() + LcorrJZBeemm->Integral() << endl;
3494    }
3495    dout << "OSOF: " << endl;
3496 <  if(PlottingSetup::RestrictToMassPeak) {
3496 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
3497      dout << "     Z window: \t" << RcorrJZBem->Integral() << " (JZB>0) , " << LcorrJZBem->Integral() << " (JZB<0) --> total: " << RcorrJZBem->Integral() + LcorrJZBem->Integral() << endl;
3498      dout << "     sideband: \t" << RcorrJZBSBem->Integral() << " (JZB>0) , " << LcorrJZBSBem->Integral() << " (JZB<0) --> total: " << RcorrJZBSBem->Integral() + LcorrJZBSBem->Integral() << endl;
3499    } else {
3500      dout << "     Z window: \t" << RcorrJZBem->Integral() << " (JZB>0) , " << LcorrJZBem->Integral() << " (JZB<0) --> total: " << RcorrJZBem->Integral() + LcorrJZBem->Integral() << endl;
3501    }
3502    dout << "Therefore: " << endl;
3503 <  if(PlottingSetup::RestrictToMassPeak) {
3503 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
3504      dout << "    Prediction increases by : " << LcorrJZBeemm->Integral() << " + (1.0/3)*(" << RcorrJZBSBeemm->Integral() <<"-"<< LcorrJZBSBeemm->Integral() << ") (SFSB) ";
3505      dout << " + (1.0/3)*(" << RcorrJZBem->Integral() <<"-"<< LcorrJZBem->Integral() << ") (OFZP) ";
3506      dout << " + (1.0/3)*(" << RcorrJZBSBem->Integral() <<"-"<< LcorrJZBSBem->Integral() << ") (OFSB) ";
# Line 3218 | Line 3516 | void qcd_plots(string datajzb, string mc
3516    for(int i=0;i<(int)bins.size();i++) {
3517      dout << " JZB > " << bins[i] << " : " << endl;
3518      dout << "    Observation increases by : " << RcorrJZBeemm->Integral(RcorrJZBeemm->FindBin(bins[i]),RcorrJZBeemm->GetNbinsX()) << endl;
3519 <    if(PlottingSetup::RestrictToMassPeak) {
3519 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
3520          dout << "    Prediction increases by : " << LcorrJZBeemm->Integral(RcorrJZBeemm->FindBin(bins[i]),RcorrJZBeemm->GetNbinsX()) + (1.0/3)*(RcorrJZBSBeemm->Integral(RcorrJZBeemm->FindBin(bins[i]),RcorrJZBeemm->GetNbinsX()) - LcorrJZBSBeemm->Integral(RcorrJZBeemm->FindBin(bins[i]),RcorrJZBeemm->GetNbinsX()) + RcorrJZBem->Integral(RcorrJZBeemm->FindBin(bins[i]),RcorrJZBeemm->GetNbinsX()) - LcorrJZBem->Integral(RcorrJZBeemm->FindBin(bins[i]),RcorrJZBeemm->GetNbinsX()) + RcorrJZBSBem->Integral(RcorrJZBeemm->FindBin(bins[i]),RcorrJZBeemm->GetNbinsX()) - LcorrJZBSBem->Integral(RcorrJZBeemm->FindBin(bins[i]),RcorrJZBeemm->GetNbinsX())) << endl;
3521      } else {
3522          dout << "    Prediction increases by : " << LcorrJZBeemm->Integral(RcorrJZBeemm->FindBin(bins[i]),RcorrJZBeemm->GetNbinsX()) + RcorrJZBem->Integral(RcorrJZBeemm->FindBin(bins[i]),RcorrJZBeemm->GetNbinsX()) - LcorrJZBem->Integral(RcorrJZBeemm->FindBin(bins[i]),RcorrJZBeemm->GetNbinsX()) << endl;
# Line 3232 | Line 3530 | void qcd_plots(string datajzb, string mc
3530    if(LcorrJZBem) delete LcorrJZBem;
3531    if(RcorrJZBeemm) delete RcorrJZBeemm;
3532    if(LcorrJZBeemm) delete LcorrJZBeemm;
3533 <  if(PlottingSetup::RestrictToMassPeak&&RcorrJZBSBem) delete RcorrJZBSBem;
3534 <  if(PlottingSetup::RestrictToMassPeak&&LcorrJZBSBem) delete LcorrJZBSBem;
3535 <  if(PlottingSetup::RestrictToMassPeak&&RcorrJZBSBeemm) delete RcorrJZBSBeemm;
3536 <  if(PlottingSetup::RestrictToMassPeak&&LcorrJZBSBeemm) delete LcorrJZBSBeemm;
3533 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB&&RcorrJZBSBem) delete RcorrJZBSBem;
3534 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB&&LcorrJZBSBem) delete LcorrJZBSBem;
3535 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB&&RcorrJZBSBeemm) delete RcorrJZBSBeemm;
3536 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB&&LcorrJZBSBeemm) delete LcorrJZBSBeemm;
3537   }
3538  
3539   void check_ptsanity() {
# Line 3332 | Line 3630 | void do_mlls_plot(string mcjzb) {
3630    }
3631   }
3632  
3633 < void met_vs_jzb_plots() {
3633 > void met_vs_jzb_plots(string datajzb, string mcjzb) {
3634    
3635    TCanvas *canmetjzb = new TCanvas("canmet","MET vs JZB canvas");
3636    canmetjzb->SetRightMargin(0.16);
# Line 3341 | Line 3639 | void met_vs_jzb_plots() {
3639    findme.push_back("DY");
3640    findme.push_back("TTJets");
3641    findme.push_back("LM");
3642 <  
3642 >  /*
3643    for(int ifind=0;ifind<(int)findme.size();ifind++) {
3644      vector<int> selsamples = allsamples.FindSample(findme[ifind]);
3645      TH2F *metvsjzb = new TH2F("metvsjzb","metvsjzb",200,0,100,400,-100,100);
3646      for(int isel=0;isel<(int)selsamples.size();isel++) {
3647 <      cout << "Producing MET:JZB plot ... working on sample: " << allsamples.collection[selsamples[isel]].filename << endl;
3648 <      allsamples.collection[selsamples[isel]].events->Draw("jzb[1]:met[4]>>+metvsjzb",cutmass&&cutOSSF);
3647 >      dout << "Producing MET:JZB plot ... working on sample: " << allsamples.collection[selsamples[isel]].filename << endl;
3648 >      allsamples.collection[selsamples[isel]].events->Draw("jzb[1]:met[4]>>+metvsjzb",cutmass&&cutOSSF&&cutnJets);
3649      }
3650      metvsjzb->Scale(allsamples.collection[selsamples[0]].weight);
3651      metvsjzb->SetStats(0);
# Line 3361 | Line 3659 | void met_vs_jzb_plots() {
3659      title->Draw();
3660      CompleteSave(canmetjzb,(string)"METvsJZBplots/"+findme[ifind]);
3661    }
3662 +  */
3663 +  
3664 +  dout << "About to produce MET plot for DY split up by JZB" << endl;
3665 +  
3666 +  int nbins=14;
3667 +  float low=0;
3668 +  float high=140;
3669 +  
3670 +  stringstream sLEFT;
3671 +  sLEFT << "((" << mcjzb << ")<0)";
3672 +  TCut LEFT(sLEFT.str().c_str());
3673 +  stringstream sRIGHT;
3674 +  sRIGHT << "((" << mcjzb << ")>0)";
3675 +  TCut RIGHT(sRIGHT.str().c_str());
3676 +  
3677 +  TH1F *metleft   = allsamples.Draw("metleft","met[4]",nbins,low,high, "MET [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&LEFT,mc, luminosity, allsamples.FindSample("DYJets"));
3678 +  TH1F *metleftO  = allsamples.Draw("metleftO","met[4]",nbins,low,high, "MET [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&LEFT,mc, luminosity, allsamples.FindSample("DYJets"));
3679 +  TH1F *metright  = allsamples.Draw("metright","met[4]",nbins,low,high, "MET [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&RIGHT,mc, luminosity, allsamples.FindSample("DYJets"));
3680 +  TH1F *metrightO = allsamples.Draw("metrightO","met[4]",nbins,low,high, "MET [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&RIGHT,mc, luminosity, allsamples.FindSample("DYJets"));
3681 +  
3682 +  
3683 +  TH1F *Bpred =  (TH1F*)metleft->Clone("Bpred");
3684 +  Bpred->Add(metleftO,-1);
3685 +  Bpred->Add(metrightO);
3686 +  TH1F *obs = (TH1F*)metright->Clone("obs");
3687 +  
3688 +  metleft->Add(metleftO,-1);
3689 +  metright->Add(metrightO,-1);
3690 +  
3691 +  metleft->SetLineColor(kRed);
3692 +  metright->SetLineColor(kBlack);
3693 +  TPad *metpad = new TPad("metpad","metpad",0,0,1,1);
3694 +  metpad->cd();
3695 +  metpad->SetLogy(1);
3696 +  metleft->Draw("histo");
3697 +  metright->Draw("same");
3698 +  TLegend *lg = make_legend();
3699 +  lg->SetX1(0.5);
3700 +  lg->SetY1(0.7);
3701 +  lg->AddEntry(metright,"JZB>0 (OSOF corrected)","P");
3702 +  lg->AddEntry(metleft,"JZB<0 (OSOF corrected)","L");
3703 +  lg->SetHeader("DY");
3704 +  
3705 +  lg->Draw();
3706 +  save_with_ratio(metright,metleft,metpad->cd(),"METvsJZBplots/ComparingLeftToRightinMETspectrum");
3707 +  
3708 +  TPad *metpad3 = new TPad("metpad3","metpad3",0,0,1,1);
3709 +  metpad3->cd();
3710 +  metpad3->SetLogy(1);
3711 +  Bpred->SetLineColor(kRed);
3712 +  Bpred->Draw("histo");
3713 +  obs->SetLineColor(kBlack);
3714 +  obs->Draw("same");
3715 +  TLegend *lg2 = make_legend();
3716 +  lg2->SetX1(0.5);
3717 +  lg2->SetY1(0.7);
3718 +  lg2->AddEntry(obs,"observed","P");
3719 +  lg2->AddEntry(Bpred,"predicted","L");
3720 +  lg2->SetHeader("DY");
3721 +
3722 +  lg2->Draw();
3723 +  
3724 +  save_with_ratio(obs,Bpred,metpad3->cd(),"METvsJZBplots/ComparingPredObsinMET");
3725 +  
3726 +  TPad *metpad2 = new TPad("metpad2","metpad2",0,0,1,1);
3727 +  metpad2->cd();
3728 +  metpad2->SetLogy(1);
3729 +  
3730 +  TH1F *metlefta   = allsamples.Draw("metlefta","met[2]",nbins,low,high, "MET [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&LEFT,mc, luminosity, allsamples.FindSample("DYJets"));
3731 +  TH1F *metleftOa  = allsamples.Draw("metleftOa","met[2]",nbins,low,high, "MET [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&LEFT,mc, luminosity, allsamples.FindSample("DYJets"));
3732 +  TH1F *metrighta  = allsamples.Draw("metrighta","met[2]",nbins,low,high, "MET [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&RIGHT,mc, luminosity, allsamples.FindSample("DYJets"));
3733 +  TH1F *metrightOa = allsamples.Draw("metrightOa","met[2]",nbins,low,high, "MET [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&RIGHT,mc, luminosity, allsamples.FindSample("DYJets"));
3734 +  
3735 +  metlefta->Add(metleftOa,-1);
3736 +  metrighta->Add(metrightOa,-1);
3737 +  
3738 +  metlefta->SetLineColor(kRed);
3739 +  metpad2->cd();
3740 +  metlefta->Draw("histo");
3741 +  metrighta->Draw("same");
3742 +  lg->Draw();
3743 +  save_with_ratio(metrighta,metlefta,metpad2->cd(),"METvsJZBplots/ComparingLeftToRightinMET_type1_spectrum");
3744 +  
3745 +  delete Bpred;
3746 +  delete obs;
3747 +  
3748 +  float newhigh=300;
3749 +  int newNBins=30;
3750 +  
3751 +  TPad *metpad4 = new TPad("metpad4","metpad4",0,0,1,1);
3752 +  TH1F *Ametleft   = allsamples.Draw("Ametleft","met[4]",newNBins,low,newhigh, "MET [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&LEFT,mc, luminosity);
3753 +  TH1F *AmetleftO  = allsamples.Draw("AmetleftO","met[4]",newNBins,low,newhigh, "MET [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&LEFT,mc, luminosity);
3754 +  TH1F *Ametright  = allsamples.Draw("Ametright","met[4]",newNBins,low,newhigh, "MET [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&RIGHT,mc, luminosity);
3755 +  TH1F *AmetrightO = allsamples.Draw("AmetrightO","met[4]",newNBins,low,newhigh, "MET [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&RIGHT,mc, luminosity);
3756 +  
3757 +  TH1F *aBpred = (TH1F*)Ametleft->Clone("aBpred");
3758 +  aBpred->Add(AmetleftO,-1);
3759 +  aBpred->Add(AmetrightO);
3760 +  aBpred->SetLineColor(kRed);
3761 +  
3762 +  TH1F *aobs = (TH1F*)Ametright->Clone("aobs");
3763 +  metpad4->cd();
3764 +  metpad4->SetLogy(1);
3765 +  aobs->Draw();
3766 +  aBpred->Draw("histo,same");
3767 +  aobs->Draw("same");
3768 +  lg->SetHeader("All MC");
3769 +  lg->Draw();
3770 +  save_with_ratio(aobs,aBpred,metpad4->cd(),"METvsJZBplots/ComparingPredObsinMET_ALLSAMPLES");
3771 +  
3772 +  
3773 +  delete lg;
3774 +  delete canmetjzb;
3775 +  delete metleft;
3776 +  delete metleftO;
3777 +  delete metright;
3778 +  delete metrightO;
3779   }
3780      
3781  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines