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.41 by fronga, Wed Jul 25 14:38:04 2012 UTC vs.
Revision 1.65 by buchmann, Thu Sep 13 09:44:16 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 &MCSigmaError, float &DataSigma, float& DataSigmaError, 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"));
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;
# 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 +  switch_overunderflow(false);
93 +  
94 +  TCut SpecialCut("mll>=0");
95 +  if(sSpecialCut!="") SpecialCut=TCut(sSpecialCut.c_str());
96    
97    bool DoInvidualeemmPeaks=false;
98    
# Line 101 | Line 108 | void find_peaks(float &MCPeak,float &MCP
108    float mcSigma,mcSigmaError, dataSigma, dataSigmaError;
109    
110    dout << "Finding global peak : " << endl;
111 <  find_one_peak_combination(TCut(""),mcpeak,mcpeakerr, datapeak,datapeakerr,mcSigma,mcSigmaError, dataSigma,dataSigmaError,result,doPUreweighting,"");
111 >  find_one_peak_combination(SpecialCut,SwitchOffNJetsCut,mcpeak,mcpeakerr, datapeak,datapeakerr,mcSigma,mcSigmaError, dataSigma,dataSigmaError,result,doPUreweighting,"");
112    
113    if(DoInvidualeemmPeaks) {
114      dout << "Finding peak for electrons : " << endl;
115 <    find_one_peak_combination(TCut("id1==0"),mceepeak,mceepeakerr,dataeepeak,dataeepeakerr,mcSigma,mcSigmaError,dataSigma,dataSigmaError,result,doPUreweighting,"_ele");
115 >    find_one_peak_combination(SpecialCut&&TCut("id1==0"),SwitchOffNJetsCut,mceepeak,mceepeakerr,dataeepeak,dataeepeakerr,mcSigma,mcSigmaError,dataSigma,dataSigmaError,result,doPUreweighting,"_ele");
116      dout << "Finding peak for muons : " << endl;
117 <    find_one_peak_combination(TCut("id1==1"),mcmmpeak,mcmmpeakerr,datammpeak,datammpeakerr,mcSigma,mcSigmaError,dataSigma,dataSigmaError,result,doPUreweighting,"_mu");
117 >    find_one_peak_combination(SpecialCut&&TCut("id1==1"),SwitchOffNJetsCut,mcmmpeak,mcmmpeakerr,datammpeak,datammpeakerr,mcSigma,mcSigmaError,dataSigma,dataSigmaError,result,doPUreweighting,"_mu");
118      
119      datajzb << "(" << jzbvariabledata;
120      mcjzb << "(" << jzbvariablemc;
# Line 133 | Line 140 | void find_peaks(float &MCPeak,float &MCP
140      else mcjzb << "+ (id1!=id2)*" << TMath::Abs(mcpeak) << " ";
141      
142      mcjzb << ")";
143 +    
144    } else {
145      datajzb << "(" << jzbvariabledata;
146        mcjzb << "(" << jzbvariablemc;
# Line 148 | Line 156 | void find_peaks(float &MCPeak,float &MCP
156      mcjzb << ")";
157    }
158    
159 <  
159 >    MCPeak=mcpeak;
160 >    MCPeakError=mcpeakerr;
161 >    DataPeak=datapeak;
162 >    DataPeakError=datapeakerr;
163 >    
164   }
165  
166   void make_special_obs_pred_mll_plot(string datajzb, string mcjzb, float jzbthreshold, float binWidth = 5.0) {
# Line 188 | Line 200 | void make_special_obs_pred_mll_plot(stri
200    
201   //  TH1F *RcorrJZBeemmNoS;
202  
203 <  if(PlottingSetup::RestrictToMassPeak) {
203 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
204      RcorrJZBSBem   = allsamples.Draw("RcorrJZBSBem",  "mll",nbins,min,max, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets&&largerzeroD,data, luminosity);
205      LcorrJZBSBem   = allsamples.Draw("LcorrJZBSBem",  "mll",nbins,min,max, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets&&smallerzeroD,data, luminosity);
206      RcorrJZBSBeemm = allsamples.Draw("RcorrJZBSBeemm","mll",nbins,min,max, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets&&largerzeroD,data, luminosity);
# Line 196 | Line 208 | void make_special_obs_pred_mll_plot(stri
208    }
209    
210    // Separate predictions
211 <  TH1F* Zpred = (TH1F*)LcorrJZBeemm->Clone("Zpred");
212 <  TH1F* OSpred = (TH1F*)RcorrJZBem->Clone("OSpred");
213 <  if(PlottingSetup::RestrictToMassPeak) {
214 <    OSpred->Scale(1.0/3.0);
215 <    OSpred->Add(RcorrJZBSBem,1.0/3.);
216 <    OSpred->Add(RcorrJZBSBeemm,1.0/3.);
217 <    Zpred->Add(LcorrJZBem,-1.0/3.);
218 <    Zpred->Add(LcorrJZBSBem,-1.0/3.);
219 <    Zpred->Add(LcorrJZBSBeemm,-1.0/3.);
220 <  } else {
221 <    Zpred->Add(LcorrJZBem,-1.0);
222 <  }
223 <
224 <  TH1F* Bpred = (TH1F*)Zpred->Clone("Bpred");
225 <  Bpred->Add(OSpred);
211 >  TH1F* SFN = (TH1F*)LcorrJZBeemm->Clone("SFN");
212 >  TH1F* OFP = (TH1F*)RcorrJZBem->Clone("OFP");
213 >  TH1F* OFN = (TH1F*)LcorrJZBem->Clone("OFN");
214 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
215 >    OFP->Scale(1.0/3.0);
216 >    OFP->Add(RcorrJZBSBem,1.0/3.);
217 >    OFP->Add(RcorrJZBSBeemm,1.0/3.);
218 >    OFN->Scale(1.0/3.0);
219 >    OFN->Add(LcorrJZBSBem,1.0/3.);
220 >    OFN->Add(LcorrJZBSBeemm,1.0/3.);
221 >  }
222 >
223 >  TH1F* Bpred = (TH1F*)SFN->Clone("Bpred");
224 >  Bpred->Add(OFP);
225 >  Bpred->Add(OFN,-1);
226    Bpred->SetLineColor(kRed);
227    
216  // Problem with negative bins: add contents to OSpred
217  for ( unsigned int i=0; i<=Zpred->GetNbinsX(); ++i ) {
218    if ( Zpred->GetBinContent(i)<0 ) {
219      OSpred->SetBinContent(i,OSpred->GetBinContent(i)+Zpred->GetBinContent(i));
220      Zpred->SetBinContent(i,0);
221    }
222  }
223
228    RcorrJZBeemm->SetTitleOffset(1.3,"y");
229    RcorrJZBeemm->Draw();
230    mcRcorrJZBeemm.Draw("same");
# Line 238 | Line 242 | void make_special_obs_pred_mll_plot(stri
242    CompleteSave(ckin,saveas.str());
243    
244    // Draw all predictions overlayed
245 <  Zpred->SetLineColor(kGreen+1);
246 <  Zpred->SetLineStyle(2);
247 <  OSpred->SetLineColor(kBlue-2);
248 <  OSpred->SetLineStyle(3);
245 >  unsigned int w = gStyle->GetHistLineWidth()+1; // Make line a bit wider, since we dash it
246 >  SFN->SetLineColor(kGreen+2);
247 >  SFN->SetLineStyle(2);
248 >  SFN->SetLineWidth(w);
249 >  OFP->SetLineColor(kBlue+2);
250 >  OFP->SetLineStyle(2);
251 >  OFP->SetLineWidth(w);
252 >  OFN->SetLineColor(kMagenta+2);
253 >  OFN->SetLineStyle(3);
254 >  OFN->SetLineWidth(w);
255    
256    RcorrJZBeemm->Draw();
257 <  OSpred->Draw("histo,same");
258 <  Zpred->Draw("histo,same");
257 >  SFN->Draw("histo,same");
258 >  OFP->Draw("histo,same");
259 >  OFN->Draw("histo,same");
260    Bpred->Draw("histo,same");
261    RcorrJZBeemm->Draw("same");
262    
263    TLegend *leg2 = make_legend("",0.52,0.7);
264    leg2->AddEntry(RcorrJZBeemm,"observed (data)","lp");
265    leg2->AddEntry(Bpred,"predicted (data)","l");
266 <  leg2->AddEntry(Zpred, "  bkgd w/Z (data)","l");
267 <  leg2->AddEntry(OSpred,"  bkgd w/o Z (data)","l");
266 >  leg2->AddEntry(SFN,  "  SF JZB<0","l");
267 >  leg2->AddEntry(OFN,  "  OF JZB<0","l");
268 >  leg2->AddEntry(OFP,  "  OF JZB>0","l");
269    leg2->Draw("same");
270    
271    saveas.str("");
272    saveas << "kin/Mll_After_Cut/Cut_At" << jzbthreshold << "_nomc";
273    CompleteSave(ckin,saveas.str());
274    
263  
264
275    delete RcorrJZBeemm;
276    delete LcorrJZBeemm;
277    delete RcorrJZBem;
278    delete LcorrJZBem;
279 <  if(PlottingSetup::RestrictToMassPeak) {
279 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
280      delete RcorrJZBSBeemm;
281      delete LcorrJZBSBeemm;
282      delete RcorrJZBSBem;
# Line 360 | Line 370 | void draw_ratio_plot(TH1* hdata, THStack
370    oneline->Draw("same");
371   }
372  
373 + float make_one_OFSF_plot(string variable, string addcut, string legendTitle, int nbins, float min, float max, float ymax, bool logscale,
374 +                        string xlabel, string filename, float legendPosition=0.55) {
375 +
376 +  TCut ibasiccut=basiccut;
377 +  bool draw_separation_lines=false;
378 +
379 +  if(addcut != "") ibasiccut = ibasiccut && addcut.c_str();
380 +
381 +  TCut cutSF;
382 +  TCut cutOF;
383 +
384 +  cutOF = cutOSOF&&cutnJets&&ibasiccut;
385 +  cutSF = cutOSSF&&cutnJets&&ibasiccut;
386 +
387 +  TCanvas *ckin = new TCanvas("ckin","Kinematic Plots (in the making)",600,600);
388 +  TPad* rcan = new TPad("rcan","rcan",0,0,1,1);
389 +  rcan->SetLogy(logscale);
390 +  rcan->cd();
391 +
392 +  std::cout << "OF/SF comparison: variable = " << variable << ", cut = " << cutSF.GetTitle() << std::endl;
393 +  TH1F *datahistoSF = allsamples.Draw("datahistoSF",variable,nbins,min,max, xlabel, "events",cutSF,data,luminosity);
394 +  TH1F *datahistoOF = allsamples.Draw("datahistoOF",variable,nbins,min,max, xlabel, "events",cutOF,data,luminosity);
395 + //   string signal("LM3");
396 + //   TH1F* signalhisto = new TH1F("signalhisto",signal.c_str(),nbins,min,max);
397 + //   int idx = signalsamples.FindSample(signal)[0];
398 + //   (signalsamples.collection)[idx].events->Project("signalhisto",variable.c_str(),cutSF);
399 + //   signalhisto->Scale((signalsamples.collection)[idx].weight*luminosity);
400 + //   signalhisto->SetLineColor((signalsamples.collection)[idx].samplecolor);
401 + //   signalhisto->SetLineStyle(2);
402 +  datahistoSF->SetMarkerSize(DataMarkerSize);
403 +  datahistoOF->SetLineColor(kRed);
404 +
405 +  if ( !logscale ) {
406 +    datahistoSF->SetMinimum(0); // Defaults
407 +  } else {
408 +    datahistoSF->SetMinimum(0.5);
409 +  }
410 +  if (ymax<0) {
411 +    if ( logscale ) datahistoSF->SetMaximum(5.3*datahistoSF->GetMaximum());
412 +    else datahistoSF->SetMaximum(1.5*datahistoSF->GetMaximum());
413 +  } else {
414 +    datahistoSF->SetMaximum(ymax);
415 +  }
416 +
417 +  float ymaxSet = datahistoSF->GetMaximum();
418 +
419 +  datahistoSF->GetXaxis()->SetTitle(xlabel.c_str());
420 +  datahistoSF->GetYaxis()->SetTitle("Events");
421 +  datahistoSF->GetXaxis()->CenterTitle();
422 +  datahistoSF->GetYaxis()->CenterTitle();
423 +
424 +  TLegend *mleg = make_legend(legendTitle.c_str(),legendPosition,0.7,false,legendPosition+0.2);
425 +  mleg->AddEntry(datahistoSF, "Same-flavor", "PL");
426 +  if (datahistoOF->Integral()>0) {
427 +    mleg->AddEntry(datahistoOF, "Opposite-flavor", "L");
428 +  } else {
429 +    mleg->AddEntry((TObject*)0, "", "");
430 +  }
431 +  //mleg->AddEntry(signalhisto, "LM3", "L");
432 +
433 +  datahistoSF->Draw("E1");
434 +  if (datahistoOF->Integral()>0) datahistoOF->Draw("HIST,SAMES");
435 +  //signalhisto->Draw("HIST,SAMES");
436 +  mleg->Draw();
437 +  DrawPrelim();
438 +  if (datahistoOF->Integral()>0) {
439 +    save_with_ratio( datahistoSF, datahistoOF, rcan, "SFOF/" + filename, false, false, "SF/OF" );
440 +  } else {
441 +    CompleteSave(rcan, "SFOF/" + filename);
442 +    delete rcan;
443 +  }
444 +
445 +  datahistoSF->Delete();
446 +  datahistoOF->Delete();
447 +  //signalhisto->Delete();
448 +  delete mleg;
449 +  delete ckin;
450 +
451 +  return ymaxSet;
452 +
453 + }
454 +
455 + // Compare data to data
456 + float make_data_comparison_plot(string variable, TCut cut, int nbins, float min, float max, float ymax, bool logscale,
457 +                                string xlabel, string filename, float legendPosition=0.55) {
458 +
459 +  TCut ibasiccut=basiccut&&cut;
460 +
461 +  TCanvas *ckin = new TCanvas("ckin","Kinematic Plots (in the making)",600,600);
462 +  TPad* rcan = new TPad("rcan","rcan",0,0,1,1);
463 +  rcan->SetLogy(logscale);
464 +  rcan->cd();
465 +
466 +  std::cout << "Data comparison: variable = " << variable << ", cut = " << ibasiccut.GetTitle() << std::endl;
467 +
468 +  TH1F *data1 = allsamples.Draw("data1",variable,nbins,min,max, xlabel, "events",ibasiccut,data,luminosity);
469 +  TH1F *data2 = comparesamples.Draw("data2",variable,nbins,min,max, xlabel, "events",ibasiccut,data,luminosity);
470 +
471 +  data1->SetMarkerSize(DataMarkerSize);
472 +  data2->SetLineColor(kRed);
473 +
474 +  if ( !logscale ) {
475 +    data1->SetMinimum(0); // Defaults
476 +  } else {
477 +    data1->SetMinimum(0.5);
478 +  }
479 +  if (ymax<0) {
480 +    if ( logscale ) data1->SetMaximum(5.3*data1->GetMaximum());
481 +    else data1->SetMaximum(1.5*data1->GetMaximum());
482 +  } else {
483 +    data1->SetMaximum(ymax);
484 +  }
485 +
486 +  float ymaxSet = data1->GetMaximum();
487 +
488 +  data1->GetXaxis()->SetTitle(xlabel.c_str());
489 +  data1->GetYaxis()->SetTitle("Events");
490 +  data1->GetXaxis()->CenterTitle();
491 +  data1->GetYaxis()->CenterTitle();
492 +
493 +  TLegend *mleg = make_legend("",legendPosition,0.7,false,legendPosition+0.2);
494 +  mleg->AddEntry(data1, "New 3.8/fb", "PL");
495 +  mleg->AddEntry(data2, "Old 5.1/fb", "L");
496 +
497 +  data1->Draw("E1");
498 +  data2->Draw("HIST,SAMES");
499 +  mleg->Draw();
500 +  DrawPrelim();
501 +  save_with_ratio( data1, data2, rcan, "compareData/" + filename, false, false, "old/new" );
502 +
503 +  data1->Delete();
504 +  data2->Delete();
505 +  delete mleg;
506 +  delete ckin;
507 +
508 + }
509 +
510 + void make_OFSF_plots(string variable, string addcut, int nbins, float min, float max, bool logscale,
511 +                     string xlabel, string filename, float legendPosition=0.55) {
512 +
513 +  string mllcuts[] = { "mll>15","mll>15&&mll<70", "mll>75&&mll<105", "mll>120" };
514 +  string mllcutname[] = { "m_{ll} > 15 GeV", "15 < m_{ll} < 70 GeV", "70 < m_{ll} < 110 GeV", "m_{ll} > 120 GeV" };
515 +  string plotname[] = {"_all","_low","_peak","_high"};
516 +  float ymax;
517 +
518 +  int start = 0;
519 +  if ( !PlottingSetup::openBox ) start = 3;
520 +
521 +  for ( int i=start; i<4; ++i ) {
522 +    if ( addcut != "" ) mllcuts[i] += "&&"+addcut;
523 +    if ( i==start ) {
524 +      ymax = make_one_OFSF_plot(variable, mllcuts[i], mllcutname[i], nbins, min, max, -1, logscale, xlabel,
525 +                         filename+plotname[i], legendPosition );
526 +    } else {
527 +      make_one_OFSF_plot(variable, mllcuts[i],        mllcutname[i], nbins, min, max, ymax, logscale, xlabel,
528 +                         filename+plotname[i], legendPosition );
529 +    }
530 +    make_one_OFSF_plot(variable, "id1==1&&id1==id2&&"+mllcuts[i], mllcutname[i], nbins, min, max, ymax, logscale, xlabel,
531 +                       filename+plotname[i]+"_mm", legendPosition );
532 +    make_one_OFSF_plot(variable, "id1==0&&id1==id2&&"+mllcuts[i], mllcutname[i], nbins, min, max, ymax, logscale, xlabel,
533 +                       filename+plotname[i]+"_ee", legendPosition );
534 +  }
535 +
536 + }
537 +
538 +
539   float lastrange_min=0;
540   float lastrange_max=0;
541  
# Line 389 | Line 565 | void make_kin_plot(string variable, stri
565    //Step 2: Refine the cut
566    TCut cut;
567    cut=cutmass&&cutOSSF&&cutnJets&&ibasiccut;
568 <  if(filename=="nJets") cut=cutmass&&cutOSSF&&ibasiccut;
569 <  if(filename=="nJets_osof") cut=cutmass&&cutOSOF&&ibasiccut;
568 >  if(filename=="nJets" || filename=="nJets_inclusive") cut=cutmass&&cutOSSF&&ibasiccut;
569 >  if(filename=="nJets_osof" || filename=="nJets_osof_inclusive") cut=cutmass&&cutOSOF&&ibasiccut;
570    if(filename=="nJets_nocuts_except_mll_ossf") cut=cutmass&&cutOSSF;
571    if(filename=="mll") {
572          cut=cutOSSF&&cutnJets&&ibasiccut;
573          draw_separation_lines=true;
574    }
575    if(filename=="mll_ee") cut=cutOSSF&&cutnJets&&ibasiccut&&"id1==0";
576 +  if(filename=="mll_mm") cut=cutOSSF&&cutnJets&&ibasiccut&&"id1==1";
577    if(filename=="mll_osof") {
578          cut=cutOSOF&&cutnJets&&ibasiccut;
579          draw_separation_lines=true;
580    }
404  if(filename=="mll_mm") cut=cutOSSF&&cutnJets&&ibasiccut&&"id1==1";
581    if(Contains(filename,"aboveJZB")) cut=cutOSSF&&cutnJets&&ibasiccut;
582    if(Contains(filename,"mll_ee_above")) cut=cut&&"id1==0";
583    if(Contains(filename,"mll_mm_above")) cut=cut&&"id1==1";
584    if(Contains(filename,"mll_osof_aboveJZB")) cut=cutOSOF&&cutnJets&&ibasiccut;
585 <  if(filename=="mll_inclusive"||filename=="mll_inclusive_highrange") cut=cutOSSF;
586 <  if(filename=="mll_inclusive_osof") cut=cutOSOF;
587 <  if(filename=="mll_inclusive_ee") cut=cutOSSF&&"id1==0";
588 <  if(filename=="mll_inclusive_mm") cut=cutOSSF&&"id1==1";
585 >  if(filename=="mll_inclusive"||filename=="mll_inclusive_highrange") cut=cutmass&&cutOSSF;
586 >  if(filename=="mll_inclusive_osof") cut=cutmass&&cutOSOF;
587 >  if(filename=="mll_inclusive_ee") cut=cutmass&&cutOSSF&&"id1==0";
588 >  if(filename=="mll_inclusive_mm") cut=cutmass&&cutOSSF&&"id1==1";
589    if(filename=="pfJetGoodEta_0") cut=cutOSSF&&cutmass&&ibasiccut&&cutnJets;
590    if(filename=="pfJetGoodPt_0") cut=cutOSSF&&cutmass&&ibasiccut&&cutnJets;
591 +  if(filename=="numVtx") cut=cutmass&&ibasiccut;
592  
593    TCanvas *ckin = new TCanvas("ckin","Kinematic Plots (in the making)",600,600);
594    ckin->SetLogy(logscale);
# Line 429 | Line 606 | void make_kin_plot(string variable, stri
606    if (logscale) datahisto->SetMaximum(5.3*datahisto->GetMaximum());
607    else datahisto->SetMaximum(1.3*datahisto->GetMaximum());
608  
609 +  cout << "******** Cut used : " << (const char*) cut << endl;
610    if(loadlastminmax) {
611          datahisto->SetMinimum(lastrange_min);
612          datahisto->SetMaximum(lastrange_max);
# Line 444 | Line 622 | void make_kin_plot(string variable, stri
622    int idx = signalsamples.FindSample(signal)[0];
623    (signalsamples.collection)[idx].events->Project("signalhisto",variable.c_str(),cut);
624    signalhisto->Scale((signalsamples.collection)[idx].weight*luminosity);
625 <  signalhisto->SetLineColor((signalsamples.collection)[idx].samplecolor);
625 >  signalhisto->SetLineColor(kOrange);
626  
627    THStack mcstack   = allsamples.DrawStack("mcstack",  variable,nbins,min,max,xlabel,"events",cut,mc,luminosity);
628    datahisto->Draw("e1");
# Line 501 | Line 679 | void make_kin_plot(string variable, stri
679            upperboundary->Draw("same");
680          }
681            
682 <        kinleg->AddEntry("signalihisto",signal.c_str(),"l");
682 >        kinleg->AddEntry("signalhisto",signal.c_str(),"l");
683          kinleg->Draw();
684          write_cut->Draw();
685          DrawPrelim();
# Line 566 | Line 744 | void make_JES_plot(TCut cut, string name
744  
745   void do_kinematic_plots(string mcjzb, string datajzb, bool doPF=false)
746   {
747 +  switch_overunderflow(true);
748    bool dolog=true;
749    bool nolog=false;
750 +
751 +  bool doOFSF = true;
752 +  bool doKin  = true;
753 +  bool doDataComp = true;
754 +  
755 +
756    if(doPF) write_warning(__FUNCTION__,"Please use caution when trying to produce PF plots; not all versions of the JZB trees have these variables!");
757    float mll_low=50;
758    float mll_hi=160;
759    if(!PlottingSetup::RestrictToMassPeak) {
760          mll_low=20;
761 <        mll_hi=300;
761 >        mll_hi=320;
762    }
763  
764 <  make_kin_plot("met[4]","",70,0,350,dolog,"MET [GeV]","met",doPF,true);
764 >  if ( doOFSF ) {
765 >    make_OFSF_plots("mll", "met[4]>100", 60, 20., 320., false, "m_{ll}", "mll");
766  
767 <  make_kin_plot("mll","",(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll",doPF,true);
768 <  make_kin_plot("mll","",(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_osof",doPF,true,true);
769 <  make_kin_plot("mll","",(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_ee",doPF,true);
770 <  make_kin_plot("mll","",(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_mm",doPF,true);
771 <  make_kin_plot("mll","",(int)((mll_hi-mll_low))/5,mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive",doPF,true);
772 <  make_kin_plot("mll","",(int)((mll_hi-mll_low))/5,mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_ee",doPF,true);
773 <  make_kin_plot("mll","",(int)((mll_hi-mll_low))/5,mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_mm",doPF,true);
774 <  make_kin_plot("mll","",(int)((mll_hi-mll_low))/5,mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_osof",doPF,true);
775 <  make_kin_plot("mll","",(int)((350-mll_low))/5,mll_low,350,dolog,"m_{ll} [GeV]","mll_inclusive_highrange",doPF);
776 <  if(!doPF) make_special_mll_plot((int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]");
777 <
778 <  make_kin_plot("pfJetGoodPt[0]/pfJetGoodPt[1]","",45,1,10,dolog,"pt_{j}^{1}/pt_{j}^{2}","j1j2ratio",doPF,true);
779 <  make_kin_plot("TMath::Abs(pfJetDphiMet[0])","",32,0,3.2,nolog,"|#Delta#phi(jet1,MET)|","dphiJ1MET",doPF,true);
780 <
781 <  make_kin_plot("pfJetGoodNum40","",9,-0.5,8.5,dolog,"nJets","nJets",doPF);
782 <  make_kin_plot("pfJetGoodNum40","",9,-0.5,8.5,dolog,"nJets","nJets_osof",doPF);
783 <  make_kin_plot("pfJetGoodNum40","",9,-0.5,8.5,dolog,"nJets","nJets_nocuts_except_mll_ossf",doPF);
784 <
785 <  make_kin_plot("numVtx","",(int)(30.5-(-0.5)),-0.5,30.5,nolog,"N(Vtx)","numVtx",doPF);
786 < //  make_kin_plot("jetpt[0]","",40,0,200,dolog,"leading jet p_{T} [GeV]","pfJetGoodPt_0",doPF);
787 < //  make_kin_plot("jeteta[0]","",40,-5,5,nolog,"leading jet #eta","pfJetGoodEta_0",doPF);
788 <  make_kin_plot("pt","",50,0,500,dolog,"Z p_{T} [GeV]","Zpt",doPF);
789 <  make_kin_plot("pt1","",50,0,200,nolog,"p_{T} [GeV]","pt1",doPF);
790 <  make_kin_plot("pt2","",50,0,200,nolog,"p_{T} [GeV]","pt2",doPF);
791 <  make_kin_plot("eta1","",40,-3,3,nolog,"#eta_{l}","eta",doPF);
792 <  make_kin_plot("jzb[1]","",100,-150,200,dolog,"JZB [GeV]","jzb_ossf",doPF);
793 <  stringstream jzbcut;
794 <  jzbcut << "((is_data&&("<<datajzb<<")>100)||(!is_data&&("<<mcjzb<<")>100))";
795 <  make_kin_plot("mll",jzbcut.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV]","mll_aboveJZB100",doPF,true);
796 <  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);
797 <  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);
798 <  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);
799 <  stringstream jzbcut2;
800 <  jzbcut2 << "((is_data&&("<<datajzb<<")>150)||(!is_data&&("<<mcjzb<<")>150))";
801 <  make_kin_plot("mll",jzbcut2.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV]","mll_aboveJZB150",doPF,true);
802 <  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);
803 <  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);
804 <  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);
805 <  stringstream jzbcut3;
806 <  jzbcut3 << "((is_data&&("<<datajzb<<")>50)||(!is_data&&("<<mcjzb<<")>50))";
807 <  make_kin_plot("mll",jzbcut3.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV]","mll_aboveJZB50",doPF,true);  
808 <  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);
809 <  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);  
810 <  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);  
811 <
812 <  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",doPF,true);
813 <
814 <  make_special_obs_pred_mll_plot(datajzb,mcjzb,0);
815 <  make_special_obs_pred_mll_plot(datajzb,mcjzb,50);
816 <  make_special_obs_pred_mll_plot(datajzb,mcjzb,80);
817 <  make_special_obs_pred_mll_plot(datajzb,mcjzb,100);
767 >    make_OFSF_plots("pfJetGoodNum40", "met[4]>100",                        7, 3, 10, true, "#(jets)", "njets");
768 >    make_OFSF_plots("pfJetGoodNum40", "met[4]>100&&pfJetGoodNumBtag30==0", 7, 3, 10, true, "#(jets)", "njets_btagVeto");
769 >    make_OFSF_plots("pfJetGoodNum40", "met[4]>100&&pfJetGoodNumBtag30>0",  7, 3, 10, true, "#(jets)", "njets_AtLeastOneBJet30");
770 >
771 >    make_OFSF_plots("pfJetGoodNumBtag30", "met[4]>100", 5, 0, 5, true, "#(b-jets)", "nbjets");
772 >    make_OFSF_plots("pfJetGoodPtBtag[0]", "met[4]>100&&pfJetGoodNumBtag30>0", 20, 0, 400, true, "p_{T}(leading b-jet)", "ptb1");
773 >
774 >    make_OFSF_plots("iso1", "met[4]>100", 20, 0, 0.3, true, "lepton 1 isolation", "iso1");
775 >    make_OFSF_plots("iso2", "met[4]>100", 20, 0, 0.3, true, "lepton 2 isolation", "iso2");
776 >    //  make_OFSF_plots("pt1",  "met[4]>100", 30, 0., 300., true, "p_{T,1}", "pt1");
777 >    //  make_OFSF_plots("pt2",  "met[4]>100", 22, 0., 220., true, "p_{T,2}", "pt2");
778 >    make_OFSF_plots("eta1", "met[4]>100", 10, -2.5, 2.5, false, "#eta_{1}", "eta1", 0.15);
779 >    make_OFSF_plots("eta2", "met[4]>100", 10, -2.5, 2.5, false, "#eta_{2}", "eta2", 0.15);
780 >    //  make_OFSF_plots("phi1", "met[4]>100", 10, -TMath::Pi(), TMath::Pi(), false, "#phi_{1}", "phi1", 0.2);
781 >    //  make_OFSF_plots("phi2", "met[4]>100", 10, -TMath::Pi(), TMath::Pi(), false, "#phi_{2}", "phi2", 0.2);
782 >    //  make_OFSF_plots("pfJetGoodPt[0]/pfJetGoodPt[1]", "met[4]>100", 20, 1, 10, true, "pt_{j}^{1}/pt_{j}^{2}", "jpt1pt2", 0.2);
783 >    make_OFSF_plots("TMath::Abs(pfJetDphiMet[0])", "met[4]>100", 16, 0, 3.2, false, "|#Delta#phi(jet1,MET)|", "dphij1met", 0.2);
784 >    make_OFSF_plots("TMath::Abs(dphi)", "met[4]>100", 16, 0, 3.2, false, "|#Delta#phi(l1,l2)|", "dphi", 0.2);
785 >    //  make_OFSF_plots("TMath::Abs(dphiMet1)", "met[4]>100", 16, 0, 3.2, false, "|#Delta#phi(l1,MET)|", "dphiMet1", 0.2);
786 >    //  make_OFSF_plots("TMath::Abs(dphiMet2)", "met[4]>100", 16, 0, 3.2, false, "|#Delta#phi(l2,MET)|", "dphiMet2", 0.2);
787 >    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");
788 >    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");
789 >    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");
790 >    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");
791 >  }
792 >
793 >  if ( doDataComp && !PlottingSetup::openBox ) {
794 >    TCut mllCut("");
795 >    float massmin = 15.;
796 >    float massmax = 315;
797 >    int massnbins = 60;
798 >    if ( !PlottingSetup::openBox ) {
799 >      mllCut = "mll>120";
800 >      massmin = 120;
801 >      massmax = 360;
802 >      massnbins = 14;
803 >    }
804 >
805 >    TCut cutSignal = cutmass&&cutnJets&&"met[4]>100";
806 >    make_data_comparison_plot("mll", cutOSSF,60, 15., 315.,-1., true, "m_{ll}", "mll_SF_inclusive");
807 >    make_data_comparison_plot("mll", cutOSOF,60, 15., 315.,-1., true, "m_{ll}", "mll_OF_inclusive");
808 >
809 >    make_data_comparison_plot("mll", cutOSSF&&cutSignal&&mllCut,           massnbins, 15., 315.,-1., false, "m_{ll}", "mll_SF_sig");
810 >    make_data_comparison_plot("mll", cutOSSF&&cutSignal&&mllCut&&"pfJetGoodNumBtag30==0", massnbins, 15., 315.,-1., false, "m_{ll}", "mll_SF_sig_btagVeto");
811 >    make_data_comparison_plot("mll", cutOSSF&&cutSignal&&mllCut&&"pfJetGoodNumBtag30>0",  massnbins, 15., 315.,-1., false, "m_{ll}", "mll_SF_sig_AtLeastOneBJet");
812 >
813 >    make_data_comparison_plot("mll", mllCut&&cutOSOF&&cutSignal, massnbins, 15., 315.,-1., false, "m_{ll}", "mll_OF_sig");
814 >    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");
815 >    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");
816 >
817 >    make_data_comparison_plot("pfJetGoodNum40", cutOSSF&&cutSignal&&mllCut, 8, 0., 8.,-1., false, "#(jets)", "njets_SF_sig");
818 >    make_data_comparison_plot("pfJetGoodNum40", cutOSOF&&cutSignal&&mllCut, 8, 0., 8.,-1., false, "#(jets)", "njets_OF_sig");
819 >    make_data_comparison_plot("pfJetGoodNumBtag30", cutOSSF&&cutSignal&&mllCut, 8, 0., 8.,-1., false, "#(b-jets)", "nbjets_SF_sig");
820 >    make_data_comparison_plot("pfJetGoodNumBtag30", cutOSOF&&cutSignal&&mllCut, 8, 0., 8.,-1., false, "#(b-jets)", "nbjets_OF_sig");
821 >  }
822 >
823 >
824 >  if ( doKin ) {
825 >    string mllCut("");
826 >    if ( !PlottingSetup::openBox ) mllCut = "&&mll>120";
827 >
828 >    // Plots in signal region
829 >    make_kin_plot("met[4]","",70,0,350,dolog,"MET [GeV]","met",doPF,true);
830 >    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",doPF,true);
831 >    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",doPF,true,true);
832 >    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",doPF,true);
833 >    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",doPF,true);
834 >    
835 >    make_kin_plot("pfJetGoodNum40","met[4]>100"+mllCut,9,-0.5,8.5,dolog,"nJets","nJets",doPF);
836 >    make_kin_plot("pfJetGoodNum40","met[4]>100",9,-0.5,8.5,dolog,"nJets","nJets_osof",doPF);
837 >
838 >    // Further inclusive invariant mass plots
839 >    make_kin_plot("mll","",(int)((mll_hi-mll_low))/5,mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive",doPF,true);
840 >    make_kin_plot("mll","",(int)((mll_hi-mll_low))/5,mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_ee",doPF,true);
841 >    make_kin_plot("mll","",(int)((mll_hi-mll_low))/5,mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_mm",doPF,true);
842 >    make_kin_plot("mll","",(int)((mll_hi-mll_low))/5,mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_osof",doPF,true);
843 >    
844 >    //make_kin_plot("mll","",(int)((350-mll_low))/5,mll_low,350,dolog,"m_{ll} [GeV]","mll_inclusive_highrange",doPF);
845 >    //if(!doPF) make_special_mll_plot((int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]");
846 >    
847 >    //make_kin_plot("pfJetGoodPt[0]/pfJetGoodPt[1]","",45,1,10,dolog,"pt_{j}^{1}/pt_{j}^{2}","j1j2ratio",doPF,true);
848 >    //make_kin_plot("TMath::Abs(pfJetDphiMet[0])","",32,0,3.2,nolog,"|#Delta#phi(jet1,MET)|","dphiJ1MET",doPF,true);
849 >    
850 >    // Number of jets
851 >    make_kin_plot("pfJetGoodNum40","",9,-0.5,8.5,dolog,"nJets","nJets_inclusive",doPF);
852 >    make_kin_plot("pfJetGoodNum40","",9,-0.5,8.5,dolog,"nJets","nJets_osof_inclusive",doPF);
853 >    //make_kin_plot("pfJetGoodNum40","",9,-0.5,8.5,dolog,"nJets","nJets_nocuts_except_mll_ossf",doPF);
854 >    
855 >    // Others
856 >    make_kin_plot("numVtx","",(int)(30.5-(-0.5)),-0.5,30.5,nolog,"N(Vtx)","numVtx",doPF);
857 >    //  make_kin_plot("jetpt[0]","",40,0,200,dolog,"leading jet p_{T} [GeV]","pfJetGoodPt_0",doPF);
858 >    //  make_kin_plot("jeteta[0]","",40,-5,5,nolog,"leading jet #eta","pfJetGoodEta_0",doPF);
859 >    make_kin_plot("pt","",50,0,500,dolog,"Z p_{T} [GeV]","Zpt",doPF);
860 >    make_kin_plot("pt1","",50,0,200,nolog,"p_{T} [GeV]","pt1",doPF);
861 >    make_kin_plot("pt2","",50,0,200,nolog,"p_{T} [GeV]","pt2",doPF);
862 >    make_kin_plot("eta1","",40,-3,3,nolog,"#eta_{l}","eta",doPF);
863 >    make_kin_plot("jzb[1]","",100,-150,200,dolog,"JZB [GeV]","jzb_ossf",doPF);
864 >    //   stringstream jzbcut;
865 >    //   jzbcut << "((is_data&&("<<datajzb<<")>100)||(!is_data&&("<<mcjzb<<")>100))";
866 >    //   make_kin_plot("mll",jzbcut.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV]","mll_aboveJZB100",doPF,true);
867 >    //   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);
868 >    //   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);
869 >    //   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);
870 >    //   stringstream jzbcut2;
871 >    //   jzbcut2 << "((is_data&&("<<datajzb<<")>150)||(!is_data&&("<<mcjzb<<")>150))";
872 >    //   make_kin_plot("mll",jzbcut2.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV]","mll_aboveJZB150",doPF,true);
873 >    //   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);
874 >    //   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);
875 >    //   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);
876 >    //   stringstream jzbcut3;
877 >    //   jzbcut3 << "((is_data&&("<<datajzb<<")>50)||(!is_data&&("<<mcjzb<<")>50))";
878 >    //   make_kin_plot("mll",jzbcut3.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV]","mll_aboveJZB50",doPF,true);  
879 >    //   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);
880 >    //   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);  
881 >    //   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);  
882 >    
883 >    //   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);
884 >    //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);
885 >    //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);
886 >  }
887 >    
888 > //   make_special_obs_pred_mll_plot(datajzb,mcjzb,0);
889 > //   make_special_obs_pred_mll_plot(datajzb,mcjzb,50);
890 > //   make_special_obs_pred_mll_plot(datajzb,mcjzb,80);
891 > //   make_special_obs_pred_mll_plot(datajzb,mcjzb,100);
892   //   make_special_obs_pred_mll_plot(datajzb,mcjzb,150);
893   //   make_special_obs_pred_mll_plot(datajzb,mcjzb,200);
894   //   make_special_obs_pred_mll_plot(datajzb,mcjzb,250);
895  
896 <  make_JES_plot(cutmass&&cutOSSF&&basiccut,"_ossf");
897 <  make_JES_plot(cutmass&&cutOSOF&&basiccut,"_osof");
638 <
896 > //   make_JES_plot(cutmass&&cutOSSF&&basiccut,"_ossf");
897 > //   make_JES_plot(cutmass&&cutOSOF&&basiccut,"_osof");
898  
899 +  switch_overunderflow(false);
900   }
901  
902   void make_comp_plot( string var, string xlabel, string filename, float jzbcut, string mcjzb, string datajzb,
# Line 652 | Line 912 | void make_comp_plot( string var, string
912  
913    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- below: the next ~20 lines changed!
914    int nRegions=4;
915 <  if(!PlottingSetup::RestrictToMassPeak) {
915 >  if(!PlottingSetup::RestrictToMassPeak||!PlottingSetup::UseSidebandsForcJZB) {
916      nRegions=2;
917    }
918    
# Line 706 | Line 966 | void region_comparison_plots(string mcjz
966  
967   //  switch_overunderflow(true);  // switching overflow/underflow bins on
968      
969 <  
969 >  switch_overunderflow(true);
970      flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- the arguments changed
971    for(int ijzb=0;ijzb<(int)jzb_cuts.size();ijzb++) {
972      float jzbcut=jzb_cuts[ijzb]; // Comparison plots are done for this JZB cut
# Line 926 | Line 1186 | vector<TF1*> do_extended_fit_to_plot(TH1
1186   //      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)
1187    TF1 *ttbarlogpar = do_logpar_fit_to_plot(Tprediction);
1188    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
1189 <  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);
1189 >  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);
1190  
1191  
1192    TF1 *ttbarlogparP = new TF1("ttbarlogparP",LogParabolaP,0,(prediction->GetXaxis()->GetBinLowEdge(prediction->GetNbinsX())+prediction->GetXaxis()->GetBinWidth(prediction->GetNbinsX())),8);
# Line 1023 | Line 1283 | if you want to start from scratch (witho
1283  
1284   void do_prediction_plot(string jzb, TCanvas *globalcanvas, float high, int use_data, bool overlay_signal = false,string subdir="" )
1285   {
1286 < //  switch_overunderflow(true);
1286 >  
1287    bool is_data=false;
1288    bool use_signal=false;
1289    if(use_data==1) is_data=true;
1290    if(use_data==2) use_signal=true;
1291 <  int nbins=50;//100;
1292 <  if(is_data) nbins=50;
1291 >  int nbins=int(high/10);//100;
1292 >  if(is_data) nbins=int(high/10);
1293    float low=0;
1294 <  float hi=500;
1294 >  float hi=high;
1295 >  
1296 >  stringstream cutpositiveS;
1297 >  cutpositiveS << "(" << jzb << ">0)";
1298 >  TCut cutpositive(cutpositiveS.str().c_str());
1299 >  stringstream cutnegativeS;
1300 >  cutnegativeS << "(" << jzb << "<0)";
1301 >  TCut cutnegative(cutnegativeS.str().c_str());
1302 >  
1303    
1304    TH1F *blankback = new TH1F("blankback","blankback",int(high/10),0,high);
1305 <  TH1F *RcorrJZBeemm   = allsamples.Draw("RcorrJZBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1306 <  TH1F *LcorrJZBeemm   = allsamples.Draw("LcorrJZBeemm",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1307 <  TH1F *RcorrJZBem     = allsamples.Draw("RcorrJZBem",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1308 <  TH1F *LcorrJZBem     = allsamples.Draw("LcorrJZBem",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1305 >  TH1F *RcorrJZBeemm   = allsamples.Draw("RcorrJZBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutpositive&&cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1306 >  TH1F *LcorrJZBeemm   = allsamples.Draw("LcorrJZBeemm",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutnegative&&cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1307 >  TH1F *RcorrJZBem     = allsamples.Draw("RcorrJZBem",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutpositive&&cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1308 >  TH1F *LcorrJZBem     = allsamples.Draw("LcorrJZBem",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutnegative&&cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1309  
1310    blankback->GetXaxis()->SetTitle(RcorrJZBeemm->GetXaxis()->GetTitle());
1311    blankback->GetYaxis()->SetTitle(RcorrJZBeemm->GetYaxis()->GetTitle());
# Line 1052 | Line 1320 | void do_prediction_plot(string jzb, TCan
1320    
1321    TH1F *RcorrJZBeemmNoS;
1322  
1323 <    //these are for the ratio
1324 <  
1325 <  TH1F *JRcorrJZBeemm   = allsamples.Draw("JRcorrJZBeemm",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1326 <  TH1F *JLcorrJZBeemm   = allsamples.Draw("JLcorrJZBeemm",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1327 <  TH1F *JRcorrJZBem     = allsamples.Draw("JRcorrJZBem",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1060 <  TH1F *JLcorrJZBem     = allsamples.Draw("JLcorrJZBem",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1323 >  //these are for the ratio
1324 >  TH1F *JRcorrJZBeemm   = allsamples.Draw("JRcorrJZBeemm",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutpositive&&cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1325 >  TH1F *JLcorrJZBeemm   = allsamples.Draw("JLcorrJZBeemm",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutnegative&&cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1326 >  TH1F *JRcorrJZBem     = allsamples.Draw("JRcorrJZBem",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutpositive&&cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1327 >  TH1F *JLcorrJZBem     = allsamples.Draw("JLcorrJZBem",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutnegative&&cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1328    
1329    TH1F *JRcorrJZBSBem;
1330    TH1F *JLcorrJZBSBem;
1331    TH1F *JRcorrJZBSBeemm;
1332    TH1F *JLcorrJZBSBeemm;
1333    
1334 <  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);
1334 >  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);
1335  
1336    
1337 <  if(PlottingSetup::RestrictToMassPeak) {
1338 <    RcorrJZBSBem   = allsamples.Draw("RcorrJZBSBem",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1339 <    LcorrJZBSBem   = allsamples.Draw("LcorrJZBSBem",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1340 <    RcorrJZBSBeemm = allsamples.Draw("RcorrJZBSBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1341 <    LcorrJZBSBeemm = allsamples.Draw("LcorrJZBSBeemm",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1337 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
1338 >    RcorrJZBSBem   = allsamples.Draw("RcorrJZBSBem",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutpositive&&sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1339 >    LcorrJZBSBem   = allsamples.Draw("LcorrJZBSBem",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutnegative&&sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1340 >    RcorrJZBSBeemm = allsamples.Draw("RcorrJZBSBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutpositive&&sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1341 >    LcorrJZBSBeemm = allsamples.Draw("LcorrJZBSBeemm",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutnegative&&sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1342      
1343      //these are for the ratio
1344 <    JRcorrJZBSBem   = allsamples.Draw("JRcorrJZBSBem",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1345 <    JLcorrJZBSBem   = allsamples.Draw("JLcorrJZBSBem",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1346 <    JRcorrJZBSBeemm = allsamples.Draw("JRcorrJZBSBeemm",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1347 <    JLcorrJZBSBeemm = allsamples.Draw("JLcorrJZBSBeemm",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1344 >    JRcorrJZBSBem   = allsamples.Draw("JRcorrJZBSBem",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutpositive&&sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1345 >    JLcorrJZBSBem   = allsamples.Draw("JLcorrJZBSBem",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutnegative&&sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1346 >    JRcorrJZBSBeemm = allsamples.Draw("JRcorrJZBSBeemm",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutpositive&&sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1347 >    JLcorrJZBSBeemm = allsamples.Draw("JLcorrJZBSBeemm",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutnegative&&sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1348    }
1349    
1350    TH1F *lm4RcorrJZBeemm;
1351 <  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"));
1351 >  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"));
1352    
1353    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- prediction changed.
1354    
# Line 1094 | Line 1361 | void do_prediction_plot(string jzb, TCan
1361    TH1F *BpredSys = new TH1F("Bpredsys","Bpredsys",PlottingSetup::global_ratio_binning.size()-1,&PlottingSetup::global_ratio_binning[0]);
1362    ClearHisto(BpredSys);
1363      
1364 <  if(PlottingSetup::RestrictToMassPeak) {
1364 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
1365      Bpred->Add(RcorrJZBem,1.0/3.);
1366      Bpred->Add(LcorrJZBem,-1.0/3.);
1367      Bpred->Add(RcorrJZBSBem,1.0/3.);
# Line 1145 | Line 1412 | void do_prediction_plot(string jzb, TCan
1412    SQRT(BpredSys);
1413    BpredSys->Divide(JBpred);
1414  
1148  
1415    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- prediction changed
1416    TH1F *Tpred = (TH1F*)RcorrJZBem->Clone("Bpred");
1417    Tpred->Add(LcorrJZBem,-1.0);
1418 <  if(PlottingSetup::RestrictToMassPeak) {
1418 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
1419      Tpred->Add(RcorrJZBSBem,1.0);
1420      Tpred->Add(LcorrJZBSBem,-1.0);
1421      Tpred->Add(RcorrJZBSBeemm,1.0);
# Line 1213 | Line 1479 | void do_prediction_plot(string jzb, TCan
1479      Bpred->SetLineWidth(2);
1480      predcomppad->cd();
1481      predcomppad->SetLogy(1);
1216    
1482      TH1F *jzbnegative = (TH1F*)LcorrJZBeemm->Clone("jzbnegative");
1483      TH1F *sidebandsemu = (TH1F*)Bpred->Clone("sidebandsemu");
1484      sidebandsemu->Add(jzbnegative,-1);
# Line 1242 | Line 1507 | void do_prediction_plot(string jzb, TCan
1507      speciallegBpred->AddEntry(RcorrJZBeemm,"Data","pl");
1508      speciallegBpred->AddEntry(Bpred,"Total background","l");
1509      speciallegBpred->AddEntry(jzbnegative,"JZB<0 (data)","f");
1510 <    if(PlottingSetup::RestrictToMassPeak) speciallegBpred->AddEntry(sidebandsemu,"Sidebands/e#mu (data)","f");
1510 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) speciallegBpred->AddEntry(sidebandsemu,"Sidebands/e#mu (data)","f");
1511      else speciallegBpred->AddEntry(sidebandsemu,"e#mu (data)","f");
1512   //    speciallegBpred->AddEntry(lm4RcorrJZBeemmC,"LM4","l");
1513      speciallegBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
# Line 1332 | Line 1597 | void do_prediction_plot(string jzb, TCan
1597    //save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,Bpredsaveas,true,use_data!=1,ytitle);
1598    save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,subdir+Bpredsaveas,true,false,ytitle,BpredSys);//not extending the y range anymore up to 4
1599  
1600 +
1601    
1602    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
1603    // The part below is meaningless for the offpeak analysis (it's a comparison of the different estimates but there is but one estimate!)
1604 <  if(PlottingSetup::RestrictToMassPeak) {
1604 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
1605      TH1F *Bpredem = (TH1F*)LcorrJZBeemm->Clone("Bpredem");
1606      Bpredem->Add(RcorrJZBem);
1607      Bpredem->Add(LcorrJZBem,-1);
# Line 1414 | Line 1680 | void do_prediction_plot(string jzb, TCan
1680    delete blankback;
1681    
1682    delete BpredSys;
1683 <  if(PlottingSetup::RestrictToMassPeak) {
1683 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
1684      delete RcorrJZBSBem;
1685      delete LcorrJZBSBem;
1686      delete RcorrJZBSBeemm;
# Line 1426 | Line 1692 | void do_prediction_plot(string jzb, TCan
1692      delete JLcorrJZBSBeemm;
1693    }
1694    if(overlay_signal || use_data==2) delete lm4RcorrJZBeemm;
1429  switch_overunderflow(false);
1695   }
1696  
1697   void do_prediction_plots(string mcjzb, string datajzb, float DataSigma, float MCSigma, bool overlay_signal ) {
1698 +  switch_overunderflow(true);
1699    TCanvas *globalcanvas = new TCanvas("globalcanvas","Prediction Canvas");
1700    do_prediction_plot(datajzb,globalcanvas,jzbHigh ,data,overlay_signal);
1701    if ( !PlottingSetup::Approved ) {
# Line 1438 | Line 1704 | void do_prediction_plots(string mcjzb, s
1704    } else {
1705      write_info(__FUNCTION__,"You set approved to true, therefore not producing prediction/observation plots for MC with and without signal.");
1706    }
1707 < }
1708 <
1443 < void do_ratio_plot(int is_data,vector<float> binning, string jzb, TCanvas *can, float high=-9999) {
1444 <  bool do_data=0;
1445 <  bool dosignal=0;
1446 <  if(is_data==1) do_data=1;
1447 <  if(is_data==2) dosignal=1;
1448 <  TH1F *RcorrJZBeemm   = allsamples.Draw("RcorrJZBeemm",jzb.c_str(),binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,do_data, luminosity,dosignal);
1449 <  TH1F *LcorrJZBeemm   = allsamples.Draw("LcorrJZBeemm",("-"+jzb).c_str(),binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,do_data, luminosity,dosignal);
1450 <  TH1F *RcorrJZBem     = allsamples.Draw("RcorrJZBem",jzb.c_str(),binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,do_data, luminosity,dosignal);
1451 <  TH1F *LcorrJZBem     = allsamples.Draw("LcorrJZBem",("-"+jzb).c_str(),binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,do_data, luminosity,dosignal);
1452 <  
1453 <  TH1F *RcorrJZBSBem;
1454 <  TH1F *LcorrJZBSBem;
1455 <  TH1F *RcorrJZBSBeemm;
1456 <  TH1F *LcorrJZBSbeemm;
1457 <  
1458 <  if(PlottingSetup::RestrictToMassPeak) {
1459 <    RcorrJZBSBem   = allsamples.Draw("RcorrJZBSbem",jzb.c_str(),binning, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,do_data, luminosity,dosignal);
1460 <    LcorrJZBSBem   = allsamples.Draw("LcorrJZBSbem",("-"+jzb).c_str(),binning, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,do_data, luminosity,dosignal);
1461 <    RcorrJZBSBeemm = allsamples.Draw("RcorrJZBSbeemm",jzb.c_str(),binning, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,do_data, luminosity,dosignal);
1462 <    LcorrJZBSbeemm = allsamples.Draw("LcorrJZBSbeemm",("-"+jzb).c_str(),binning, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,do_data, luminosity,dosignal);
1463 <  }
1464 <  
1465 <
1466 <
1467 <
1468 <  flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
1469 <  TH1F *Bpred = (TH1F*)LcorrJZBeemm->Clone("Bpred");
1470 <  if(PlottingSetup::RestrictToMassPeak) {
1471 <    Bpred->Add(RcorrJZBem,1.0/3);
1472 <    Bpred->Add(LcorrJZBem,-1.0/3);
1473 <    Bpred->Add(RcorrJZBSBem,1.0/3);
1474 <    Bpred->Add(LcorrJZBSBem,-1.0/3);
1475 <    Bpred->Add(RcorrJZBSBeemm,1.0/3);
1476 <    Bpred->Add(LcorrJZBSbeemm,-1.0/3);
1477 <  } else {
1478 <    Bpred->Add(RcorrJZBem,1.0);
1479 <    Bpred->Add(LcorrJZBem,-1.0);
1480 <  }
1481 <
1482 <  can->cd();
1483 <  can->SetLogy(0);
1484 <  Bpred->SetLineColor(kRed);
1485 <  Bpred->SetStats(0);
1486 <  if(high>0) Bpred->GetXaxis()->SetRangeUser(0,high);
1487 <  TH1F *JZBratioforfitting=(TH1F*)RcorrJZBeemm->Clone("JZBratioforfitting");
1488 <  JZBratioforfitting->Divide(Bpred);
1489 <  TGraphAsymmErrors *JZBratio = histRatio(RcorrJZBeemm,Bpred,is_data,binning,false);
1490 <  
1491 <  
1492 <  JZBratio->SetTitle("");
1493 <  JZBratio->GetYaxis()->SetRangeUser(0.0,9.0);
1494 < //  if(is_data==1) JZBratio->GetXaxis()->SetRangeUser(0,jzbHigh );
1495 <  
1496 <  TF1 *pol0 = new TF1("pol0","[0]",0,1000);
1497 <  TF1 *pol0d = new TF1("pol0","[0]",0,1000);
1498 < //  straightline_fit->SetParameter(0,1);
1499 <  JZBratioforfitting->Fit(pol0,"Q0R","",0,30);
1500 <  pol0d->SetParameter(0,pol0->GetParameter(0));
1501 <  
1502 <  JZBratio->GetYaxis()->SetTitle("Observed/Predicted");
1503 <  JZBratio->GetXaxis()->SetTitle("JZB [GeV]");
1504 <  if ( high>0 ) JZBratio->GetXaxis()->SetRangeUser(0.0,high);
1505 <  JZBratio->GetYaxis()->SetNdivisions(519);
1506 <  JZBratio->GetYaxis()->SetRangeUser(0.0,4.0);
1507 <  JZBratio->GetYaxis()->CenterTitle();
1508 <  JZBratio->GetXaxis()->CenterTitle();
1509 <  JZBratio->SetMarkerSize(DataMarkerSize);
1510 <  JZBratio->Draw("AP");
1511 <  /////----------------------------
1512 <  TPaveText *writeresult = new TPaveText(0.15,0.78,0.49,0.91,"blNDC");
1513 <  writeresult->SetFillStyle(4000);
1514 <  writeresult->SetFillColor(kWhite);
1515 <  writeresult->SetTextFont(42);
1516 <  writeresult->SetTextSize(0.03);
1517 <  writeresult->SetTextAlign(12);
1518 <  ostringstream jzb_agreement_data_text;
1519 <  jzb_agreement_data_text<< setprecision(2) << "mean =" << pol0->GetParameter(0) << " #pm " << setprecision(1) <<  pol0->GetParError(0);
1520 <  if(is_data==1) fitresultconstdata=pol0->GetParameter(0);// data
1521 <  if(is_data==0) fitresultconstmc=pol0->GetParameter(0); // monte carlo, no signal
1522 < /*  if(is_data) writeresult->AddText("Data closure test");
1523 <  else writeresult->AddText("MC closure test");
1524 <  */
1525 <  writeresult->AddText(jzb_agreement_data_text.str().c_str());
1526 < //  writeresult->Draw("same");
1527 < //  pol0d->Draw("same");
1528 <  TF1 *topline =  new TF1("","1.5",0,1000);
1529 <  TF1 *bottomline =  new TF1("","0.5",0,1000);
1530 <  topline->SetLineColor(kBlue);
1531 <  topline->SetLineStyle(2);
1532 <  bottomline->SetLineColor(kBlue);
1533 <  bottomline->SetLineStyle(2);
1534 < //  topline->Draw("same");
1535 < //  bottomline->Draw("same");
1536 <  TF1 *oneline = new TF1("","1.0",0,1000);
1537 <  oneline->SetLineColor(kBlue);
1538 <  oneline->SetLineStyle(1);
1539 <  oneline->Draw("same");
1540 <  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.
1541 <  if(is_data==1) DrawPrelim();
1542 <  else DrawMCPrelim();
1543 <  TLegend *leg = new TLegend(0.55,0.75,0.89,0.89);
1544 <  leg->SetTextFont(42);
1545 <  leg->SetTextSize(0.04);
1546 < //   if(is_data==1) leg->SetHeader("Ratio (data)");
1547 < //   else leg->SetHeader("Ratio (MC)");
1548 <
1549 <  TString MCtitle("MC ");
1550 <  if (is_data==1) MCtitle = "";
1551 <
1552 <  leg->SetFillStyle(4000);
1553 <  leg->SetFillColor(kWhite);
1554 <  leg->SetTextFont(42);
1555 < //  leg->AddEntry(topline,"+20\% sys envelope","l");
1556 <  leg->AddEntry(JZBratio,MCtitle+"obs / "+MCtitle+"pred","p");
1557 <  leg->AddEntry(oneline,"ratio = 1","l");
1558 < //  leg->AddEntry(pol0d,"fit in [0,30] GeV","l");
1559 < //  leg->AddEntry(bottomline,"#pm50% envelope","l");
1560 <
1561 <
1562 <  //leg->Draw("same"); // no longer drawing legend
1563 <
1564 <  if(is_data==1) CompleteSave(can, "jzb_ratio_data");
1565 <  if(is_data==0) CompleteSave(can, "jzb_ratio_mc");
1566 <  if(is_data==2) CompleteSave(can, "jzb_ratio_mc_BandS");//special case, MC with signal!
1567 <  
1568 <  delete RcorrJZBeemm;
1569 <  delete LcorrJZBeemm;
1570 <  delete RcorrJZBem;
1571 <  delete LcorrJZBem;
1572 <  
1573 <  delete RcorrJZBSBem;
1574 <  delete LcorrJZBSBem;
1575 <  delete RcorrJZBSBeemm;
1576 <  delete LcorrJZBSbeemm;
1577 < }
1578 <
1579 < void do_ratio_plots(string mcjzb,string datajzb,vector<float> ratio_binning) {
1580 <  TCanvas *globalc = new TCanvas("globalc","Ratio Plot Canvas");
1581 <  globalc->SetLogy(0);
1582 <  
1583 <  do_ratio_plot(mc,ratio_binning,mcjzb,globalc, jzbHigh  );
1584 <  do_ratio_plot(data,ratio_binning,datajzb,globalc, jzbHigh  );
1585 <  do_ratio_plot(mcwithsignal,ratio_binning,mcjzb,globalc, jzbHigh  );
1707 >  delete globalcanvas;
1708 >  switch_overunderflow(false);
1709   }
1710  
1711   string give_jzb_expression(float peak, int type) {
# Line 1774 | Line 1897 | void draw_pure_jzb_histo(TCut cut,string
1897    datahisto->Draw("same,e1");
1898    
1899    TLegend *leg;
1900 <  if (!PlottingSetup::RestrictToMassPeak) {
1900 >  if (!PlottingSetup::RestrictToMassPeak||!PlottingSetup::UseSidebandsForcJZB) {
1901      if(is_OF(cut)) leg = allsamples.allbglegend("Opposite flavor",datahisto);
1902      else leg = allsamples.allbglegend("Same flavor",datahisto);
1903    } else {
# Line 1837 | Line 1960 | void produce_stretched_jzb_plots(string
1960    draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass&&"id1==1",datajzb,mcjzb,"Dibosons/mm/jzb_OS_SFZP",dican,binning);
1961    draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass&&"id1==0",datajzb,mcjzb,"Dibosons/ee/jzb_OS_OFZP",dican,binning);
1962    draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass&&"id1==1",datajzb,mcjzb,"Dibosons/mm/jzb_OS_OFZP",dican,binning);
1963 <  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"Dibosons/jzb_OS_SFSB",dican,binning);
1964 <  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"Dibosons/jzb_OS_OFSB",dican,binning);
1963 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"Dibosons/jzb_OS_SFSB",dican,binning);
1964 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"Dibosons/jzb_OS_OFSB",dican,binning);
1965    
1966    draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass,datajzb,mcjzb,"Dibosons/jzb_OS_SFZP_coarse",dican,coarse_binning);
1967    draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass,datajzb,mcjzb,"Dibosons/jzb_OS_OFZP_coarse",dican,coarse_binning);
1968 <  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"Dibosons/jzb_OS_SFSB_coarse",dican,coarse_binning);
1969 <  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"Dibosons/jzb_OS_OFSB_coarse",dican,coarse_binning);
1968 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"Dibosons/jzb_OS_SFSB_coarse",dican,coarse_binning);
1969 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"Dibosons/jzb_OS_OFSB_coarse",dican,coarse_binning);
1970    
1971    delete dican;
1972   }
1973    
1974  
1975   void diboson_plots(string mcjzb, string datajzb,vector<float> ratio_binning) {
1976 +  switch_overunderflow(true);
1977    vector<int> SamplesToBeModified = allsamples.FindSampleBySampleName("WW/WZ/ZZ");
1978    
1979    if(SamplesToBeModified.size()==0 || SamplesToBeModified[0]==-1) {
# Line 1889 | Line 2013 | void diboson_plots(string mcjzb, string
2013      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;
2014      
2015    }
2016 <  
2016 > //   switch_overunderflow(false);
2017   }
2018  
2019  
# Line 1924 | Line 2048 | void draw_normalized_data_vs_data_histo(
2048  
2049  
2050   void jzb_plots(string mcjzb, string datajzb,vector<float> ratio_binning) {
2051 +  switch_overunderflow(true);
2052    TCanvas *can = new TCanvas("can","JZB Plots Canvas");
2053    float max=jzbHigh ;
2054    float min=-120;
# Line 1944 | Line 2069 | void jzb_plots(string mcjzb, string data
2069      draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass&&"id1==0",datajzb,mcjzb,"ee/jzb_OS_OFZP",can,binning);
2070      draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass&&"id1==1",datajzb,mcjzb,"mm/jzb_OS_OFZP",can,binning);
2071      flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
2072 <    if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_SFSB",can,binning);
2073 <    if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_OFSB",can,binning);
2072 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_SFSB",can,binning);
2073 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_OFSB",can,binning);
2074      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);
2075      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);
2076      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);
# Line 1956 | Line 2081 | void jzb_plots(string mcjzb, string data
2081    if ( !PlottingSetup::Approved ) {
2082      draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_OFZP_coarse",can,coarse_binning);
2083      flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
2084 <    if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_SFSB_coarse",can,coarse_binning);
2085 <    if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_OFSB_coarse",can,coarse_binning);
2084 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_SFSB_coarse",can,coarse_binning);
2085 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_OFSB_coarse",can,coarse_binning);
2086    }
2087    delete can;
2088 +  switch_overunderflow(false);
2089   }
2090  
2091  
# Line 2009 | Line 2135 | void compute_MC_yields(string mcjzb,vect
2135    TCanvas *yica = new TCanvas("yica","yield canvas");
2136    
2137    int nRegions=4;
2138 <  if(!PlottingSetup::RestrictToMassPeak) nRegions=2;
2138 >  if(!PlottingSetup::RestrictToMassPeak||!PlottingSetup::UseSidebandsForcJZB) nRegions=2;
2139    string tsRegions[] = {"SFZP","OFZP","SFSB","OFSB"};
2140    string posneg[] = {"pos","neg"};
2141    TCut tkRegions[] = {cutOSSF&&cutnJets&&cutmass,cutOSOF&&cutnJets&&cutmass,cutOSSF&&cutnJets&&sidebandcut,cutOSOF&&cutnJets&&sidebandcut};
# Line 2457 | Line 2583 | void save_template(string mcjzb, string
2583    configfile<<"\n\n";
2584    configfile<<"luminosity="<<luminosity<<";\n";
2585    configfile<<"RestrictToMassPeak="<<RestrictToMassPeak<<";//defines the type of analysis we're running\n";
2586 +  configfile<<"UseSidebandsForcJZB="<<UseSidebandsForcJZB<<";//tells us whether to use the sidebands or not\n";
2587    
2588    configfile<<"\n\ncout << \"Configuration successfully loaded!\" << endl; \n \n } \n \n";
2589    
# Line 2499 | Line 2626 | void ttbar_sidebands_comparison(string m
2626    //in the case of the on peak analysis, we compare the 3 control regions to the real value
2627    //in the case of the OFF peak analysis, we compare our control region to the real value
2628    TCut weightbackup=cutWeight;
2629 +  switch_overunderflow(true);
2630    
2631    bool doPURW=false;
2632    
# Line 2529 | Line 2657 | void ttbar_sidebands_comparison(string m
2657    TH1F *TSeemm;
2658    TH1F *nTSeemm;
2659    
2660 <  if(PlottingSetup::RestrictToMassPeak) {
2660 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2661      TSem    = systsamples.Draw("TSem",       mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSOF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2662      nTSem   = systsamples.Draw("nTSem",  "-"+mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSOF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2663      TSeemm  = systsamples.Draw("TSeemm",     mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSSF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
# Line 2545 | Line 2673 | void ttbar_sidebands_comparison(string m
2673    TZem->SetMarkerColor(kRed);
2674  
2675  
2676 <  if(PlottingSetup::RestrictToMassPeak) {
2676 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2677          TSem->SetLineColor(TColor::GetColor("#00A616"));
2678          TSeemm->SetLineColor(kMagenta+2);
2679          TSem->SetMarkerColor(TColor::GetColor("#00A616"));
# Line 2559 | Line 2687 | void ttbar_sidebands_comparison(string m
2687    TZeemm->GetXaxis()->SetRangeUser(-100,binning[binning.size()-1]);
2688    histos.push_back(TZem);
2689    histos.push_back(TZeemm);
2690 <  if(PlottingSetup::RestrictToMassPeak) {
2690 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2691      TSeemm->GetXaxis()->SetRangeUser(-100,binning[binning.size()-1]);
2692      TSem->GetXaxis()->SetRangeUser(-100,binning[binning.size()-1]);
2693      histos.push_back(TSem);
# Line 2570 | Line 2698 | void ttbar_sidebands_comparison(string m
2698    TLegend *leg = make_legend("MC t#bar{t}",0.6,0.65,false);
2699    leg->AddEntry(TZeemm,"SFZP","l");
2700    leg->AddEntry(TZem,"OFZP","l");
2701 <  if(PlottingSetup::RestrictToMassPeak) {
2701 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2702      leg->AddEntry(TSeemm,"SFSB","l");
2703      leg->AddEntry(TSem,"OFSB","l");
2704    }
# Line 2581 | Line 2709 | void ttbar_sidebands_comparison(string m
2709    TH1F *TZeemmcopy = (TH1F*)TZeemm->Clone("TZeemmcopy");
2710    TH1F *TSeemmcopy;
2711    TH1F *TSemcopy;
2712 <  if(PlottingSetup::RestrictToMassPeak) {
2712 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2713      TSeemmcopy = (TH1F*)TSeemm->Clone("TSeemmcopy");
2714      TSemcopy = (TH1F*)TSem->Clone("TSemcopy");
2715    }
2716  
2717    TZem->Divide(TZeemm);
2718    TZem->SetMarkerStyle(21);
2719 <  if(PlottingSetup::RestrictToMassPeak) {
2719 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2720      TSem->Divide(TZeemm);
2721      TSeemm->Divide(TZeemm);
2722      TSem->SetMarkerStyle(24);
# Line 2599 | Line 2727 | void ttbar_sidebands_comparison(string m
2727    TZem->GetYaxis()->SetRangeUser(0,2.5);
2728    TZem->GetYaxis()->SetTitle("ratio");
2729    TZem->Draw();
2730 <  if(PlottingSetup::RestrictToMassPeak) {
2730 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2731      TSem->Draw("same");
2732      TSeemm->Draw("same");
2733    }
# Line 2629 | Line 2757 | void ttbar_sidebands_comparison(string m
2757    
2758    TLegend *leg2 = make_legend("MC t#bar{t}",0.55,0.75,false);
2759    leg2->AddEntry(TZem,"OFZP / SFZP","ple");
2760 <  if(PlottingSetup::RestrictToMassPeak) {
2760 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2761      leg2->AddEntry(TSeemm,"SFSB / SFZP","ple");
2762      leg2->AddEntry(TSem,"OFSB / SFZP","ple");
2763    }
# Line 2655 | Line 2783 | void ttbar_sidebands_comparison(string m
2783      TH1F *rightofsb;
2784      TH1F *leftsfsb;
2785      TH1F *rightsfsb;
2786 <    if(PlottingSetup::RestrictToMassPeak) {
2786 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2787        leftofsb  = (TH1F*)nTSem->Clone("leftofsb");
2788        rightofsb = (TH1F*)TSemcopy->Clone("rightofsb");
2789        rightofsb->Add(leftofsb,-1);
# Line 2669 | Line 2797 | void ttbar_sidebands_comparison(string m
2797      rightsfzp->GetYaxis()->SetTitle("#deltaJZB / 25 GeV");
2798      rightsfzp->Draw("histo");
2799      rightofzp->Draw("histo,same");
2800 <    if(PlottingSetup::RestrictToMassPeak) {
2800 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2801        rightofsb->Draw("histo,same");
2802        rightsfsb->Draw("histo,same");
2803      }
# Line 2678 | Line 2806 | void ttbar_sidebands_comparison(string m
2806      TLegend *legA = make_legend("MC t#bar{t}",0.6,0.65,false);
2807      legA->AddEntry(rightsfzp,"SFZP","l");
2808      legA->AddEntry(rightofzp,"OFZP","l");
2809 <    if(PlottingSetup::RestrictToMassPeak) {
2809 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2810        legA->AddEntry(rightofsb,"SFSB","l");
2811        legA->AddEntry(rightsfsb,"OFSB","l");
2812      }
# Line 2692 | Line 2820 | void ttbar_sidebands_comparison(string m
2820      rightofzp->GetYaxis()->SetRangeUser(0.0,2.5);
2821      rightofzp->GetYaxis()->SetTitle("#deltaJZB ratio");
2822      rightofzp->Draw();
2823 <    if(PlottingSetup::RestrictToMassPeak) {
2823 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2824        rightofsb->Divide(rightsfzp);
2825        rightsfsb->Divide(rightsfzp);
2826        rightofsb->Draw("same");
# Line 2712 | Line 2840 | void ttbar_sidebands_comparison(string m
2840      bottom2->Draw("same");
2841  
2842      rightofzp->SetMarkerStyle(21);
2843 <    if(PlottingSetup::RestrictToMassPeak) {
2843 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2844        rightofsb->SetMarkerStyle(24);
2845        rightsfsb->SetMarkerStyle(32);
2846      }
2847  
2848      TLegend *leg3 = make_legend("MC t#bar{t}",0.55,0.75,false);
2849      leg3->AddEntry(rightofzp,"OFZP / SFZP","ple");
2850 <    if(PlottingSetup::RestrictToMassPeak) {
2850 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2851        leg3->AddEntry(rightsfsb,"SFSB / SFZP","ple");
2852        leg3->AddEntry(rightofsb,"OFSB / SFZP","ple");
2853      }
# Line 2738 | Line 2866 | void ttbar_sidebands_comparison(string m
2866    delete nTZem;
2867    delete TZeemm;
2868    delete nTZeemm;
2869 <  if(PlottingSetup::RestrictToMassPeak) {
2869 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2870          delete TSem;
2871          delete nTSem;
2872          delete TSeemm;
# Line 2747 | Line 2875 | void ttbar_sidebands_comparison(string m
2875  
2876    delete tcan;
2877    cutWeight=weightbackup;
2878 +  switch_overunderflow(false);
2879   }
2880  
2881   void ttbar_sidebands_comparison(string mcjzb, vector<float> jzb_binning) {
# Line 2901 | Line 3030 | void zjets_prediction_comparison(string
3030    TH1F *RcorrJZBSBeemm;
3031    TH1F *LcorrJZBSBeemm;
3032  
3033 <  if(PlottingSetup::RestrictToMassPeak) {
3033 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
3034      RcorrJZBSBem   = systsamples.Draw("RcorrJZBSBem",var,binning, "JZB [GeV]", "events",sidebandcut&&cutOSOF&&reducedNJets&&ONLYTau&&kPos,mc,simulatedlumi,systsamples.FindSample("/DY"));
3035      LcorrJZBSBem   = systsamples.Draw("LcorrJZBSBem",var,binning, "JZB [GeV]", "events",sidebandcut&&cutOSOF&&reducedNJets&&ONLYTau&&kNeg,mc,simulatedlumi,systsamples.FindSample("/DY"));
3036      RcorrJZBSBeemm = systsamples.Draw("RcorrJZBSBeemm",var,binning, "JZB [GeV]", "events",sidebandcut&&cutOSSF&&reducedNJets&&ONLYTau&&kPos,mc,simulatedlumi,systsamples.FindSample("/DY"));
# Line 2909 | Line 3038 | void zjets_prediction_comparison(string
3038    }
3039    
3040    TH1F *Bpred = (TH1F*)LcorrJZBeemm->Clone("Bpred");
3041 <  if(PlottingSetup::RestrictToMassPeak) {
3041 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
3042      Bpred->Add(RcorrJZBem,1.0/3.);
3043      Bpred->Add(LcorrJZBem,-1.0/3.);
3044      Bpred->Add(RcorrJZBSBem,1.0/3.);
# Line 2967 | Line 3096 | void zjets_prediction_comparison(string
3096    delete RcorrJZBem;
3097    delete LcorrJZBem;
3098    
3099 <  if(PlottingSetup::RestrictToMassPeak) {
3099 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
3100      delete RcorrJZBSBem;
3101      delete LcorrJZBSBem;
3102      delete RcorrJZBSBeemm;
# Line 3032 | Line 3161 | void make_table(samplecollection &coll,
3161      TH1F *RcorrJZBSBeemm;
3162      TH1F *LcorrJZBSBeemm;
3163      
3164 <    if(PlottingSetup::RestrictToMassPeak) {
3164 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
3165        RcorrJZBSBem   = coll.Draw("RcorrJZBSBem",jzbexpr.c_str(),nbins,low,14000, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity, mysample);
3166        LcorrJZBSBem   = coll.Draw("LcorrJZBSBem",("-("+jzbexpr+")").c_str(),nbins,low,14000, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity, mysample);
3167        RcorrJZBSBeemm = coll.Draw("RcorrJZBSBeemm",jzbexpr.c_str(),nbins,low,14000, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity, mysample);
# Line 3040 | Line 3169 | void make_table(samplecollection &coll,
3169      }
3170      
3171      TH1F *Bpred = (TH1F*)LcorrJZBeemm->Clone("Bpred");
3172 <    if(PlottingSetup::RestrictToMassPeak) {
3172 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
3173        Bpred->Add(RcorrJZBem,1.0/3.);
3174        Bpred->Add(LcorrJZBem,-1.0/3.);
3175        Bpred->Add(RcorrJZBSBem,1.0/3.);
# Line 3251 | Line 3380 | void qcd_plots(string datajzb, string mc
3380    TH1F *JRcorrJZBSBeemm;
3381    TH1F *JLcorrJZBSBeemm;
3382    
3383 <  if(PlottingSetup::RestrictToMassPeak) {
3383 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
3384      RcorrJZBSBem   = qcdsamples.Draw("RcorrJZBSBem",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
3385      LcorrJZBSBem   = qcdsamples.Draw("LcorrJZBSBem",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
3386      RcorrJZBSBeemm = qcdsamples.Draw("RcorrJZBSBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
# Line 3272 | Line 3401 | void qcd_plots(string datajzb, string mc
3401      
3402    TH1F *Bpred = (TH1F*)LcorrJZBeemm->Clone("Bpred");
3403    TH1F *JBpred = (TH1F*)JLcorrJZBeemm->Clone("Bpred");
3404 <  if(PlottingSetup::RestrictToMassPeak) {
3404 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
3405      Bpred->Add(RcorrJZBem,1.0/3.);
3406      Bpred->Add(LcorrJZBem,-1.0/3.);
3407      Bpred->Add(RcorrJZBSBem,1.0/3.);
# Line 3342 | Line 3471 | void qcd_plots(string datajzb, string mc
3471    dout << "______________________________________________" << endl;
3472    dout << "How QCD shows up in the different regions: " << endl;
3473    dout << "OSSF: " << endl;
3474 <  if(PlottingSetup::RestrictToMassPeak) {
3474 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
3475      dout << "     Z window: \t" << RcorrJZBeemm->Integral() << " (JZB>0) , " << LcorrJZBeemm->Integral() << " (JZB<0) --> total: " << RcorrJZBeemm->Integral() + LcorrJZBeemm->Integral() << endl;
3476      dout << "     sideband: \t" << RcorrJZBSBeemm->Integral() << " (JZB>0) , " << LcorrJZBSBeemm->Integral() << " (JZB<0) --> total: " << RcorrJZBSBeemm->Integral() + LcorrJZBSBeemm->Integral() << endl;
3477    } else {
3478      dout << "     " << RcorrJZBeemm->Integral() << " (JZB>0) , " << LcorrJZBeemm->Integral() << " (JZB<0) --> total: " << RcorrJZBeemm->Integral() + LcorrJZBeemm->Integral() << endl;
3479    }
3480    dout << "OSOF: " << endl;
3481 <  if(PlottingSetup::RestrictToMassPeak) {
3481 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
3482      dout << "     Z window: \t" << RcorrJZBem->Integral() << " (JZB>0) , " << LcorrJZBem->Integral() << " (JZB<0) --> total: " << RcorrJZBem->Integral() + LcorrJZBem->Integral() << endl;
3483      dout << "     sideband: \t" << RcorrJZBSBem->Integral() << " (JZB>0) , " << LcorrJZBSBem->Integral() << " (JZB<0) --> total: " << RcorrJZBSBem->Integral() + LcorrJZBSBem->Integral() << endl;
3484    } else {
3485      dout << "     Z window: \t" << RcorrJZBem->Integral() << " (JZB>0) , " << LcorrJZBem->Integral() << " (JZB<0) --> total: " << RcorrJZBem->Integral() + LcorrJZBem->Integral() << endl;
3486    }
3487    dout << "Therefore: " << endl;
3488 <  if(PlottingSetup::RestrictToMassPeak) {
3488 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
3489      dout << "    Prediction increases by : " << LcorrJZBeemm->Integral() << " + (1.0/3)*(" << RcorrJZBSBeemm->Integral() <<"-"<< LcorrJZBSBeemm->Integral() << ") (SFSB) ";
3490      dout << " + (1.0/3)*(" << RcorrJZBem->Integral() <<"-"<< LcorrJZBem->Integral() << ") (OFZP) ";
3491      dout << " + (1.0/3)*(" << RcorrJZBSBem->Integral() <<"-"<< LcorrJZBSBem->Integral() << ") (OFSB) ";
# Line 3372 | Line 3501 | void qcd_plots(string datajzb, string mc
3501    for(int i=0;i<(int)bins.size();i++) {
3502      dout << " JZB > " << bins[i] << " : " << endl;
3503      dout << "    Observation increases by : " << RcorrJZBeemm->Integral(RcorrJZBeemm->FindBin(bins[i]),RcorrJZBeemm->GetNbinsX()) << endl;
3504 <    if(PlottingSetup::RestrictToMassPeak) {
3504 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
3505          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;
3506      } else {
3507          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 3386 | Line 3515 | void qcd_plots(string datajzb, string mc
3515    if(LcorrJZBem) delete LcorrJZBem;
3516    if(RcorrJZBeemm) delete RcorrJZBeemm;
3517    if(LcorrJZBeemm) delete LcorrJZBeemm;
3518 <  if(PlottingSetup::RestrictToMassPeak&&RcorrJZBSBem) delete RcorrJZBSBem;
3519 <  if(PlottingSetup::RestrictToMassPeak&&LcorrJZBSBem) delete LcorrJZBSBem;
3520 <  if(PlottingSetup::RestrictToMassPeak&&RcorrJZBSBeemm) delete RcorrJZBSBeemm;
3521 <  if(PlottingSetup::RestrictToMassPeak&&LcorrJZBSBeemm) delete LcorrJZBSBeemm;
3518 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB&&RcorrJZBSBem) delete RcorrJZBSBem;
3519 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB&&LcorrJZBSBem) delete LcorrJZBSBem;
3520 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB&&RcorrJZBSBeemm) delete RcorrJZBSBeemm;
3521 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB&&LcorrJZBSBeemm) delete LcorrJZBSBeemm;
3522   }
3523  
3524   void check_ptsanity() {
# Line 3486 | Line 3615 | void do_mlls_plot(string mcjzb) {
3615    }
3616   }
3617  
3618 < void met_vs_jzb_plots() {
3618 > void met_vs_jzb_plots(string datajzb, string mcjzb) {
3619    
3620    TCanvas *canmetjzb = new TCanvas("canmet","MET vs JZB canvas");
3621    canmetjzb->SetRightMargin(0.16);
# Line 3495 | Line 3624 | void met_vs_jzb_plots() {
3624    findme.push_back("DY");
3625    findme.push_back("TTJets");
3626    findme.push_back("LM");
3627 <  
3627 >  /*
3628    for(int ifind=0;ifind<(int)findme.size();ifind++) {
3629      vector<int> selsamples = allsamples.FindSample(findme[ifind]);
3630      TH2F *metvsjzb = new TH2F("metvsjzb","metvsjzb",200,0,100,400,-100,100);
3631      for(int isel=0;isel<(int)selsamples.size();isel++) {
3632 <      cout << "Producing MET:JZB plot ... working on sample: " << allsamples.collection[selsamples[isel]].filename << endl;
3633 <      allsamples.collection[selsamples[isel]].events->Draw("jzb[1]:met[4]>>+metvsjzb",cutmass&&cutOSSF);
3632 >      dout << "Producing MET:JZB plot ... working on sample: " << allsamples.collection[selsamples[isel]].filename << endl;
3633 >      allsamples.collection[selsamples[isel]].events->Draw("jzb[1]:met[4]>>+metvsjzb",cutmass&&cutOSSF&&cutnJets);
3634      }
3635      metvsjzb->Scale(allsamples.collection[selsamples[0]].weight);
3636      metvsjzb->SetStats(0);
# Line 3515 | Line 3644 | void met_vs_jzb_plots() {
3644      title->Draw();
3645      CompleteSave(canmetjzb,(string)"METvsJZBplots/"+findme[ifind]);
3646    }
3647 +  */
3648 +  
3649 +  dout << "About to produce MET plot for DY split up by JZB" << endl;
3650 +  
3651 +  int nbins=14;
3652 +  float low=0;
3653 +  float high=140;
3654 +  
3655 +  stringstream sLEFT;
3656 +  sLEFT << "((" << mcjzb << ")<0)";
3657 +  TCut LEFT(sLEFT.str().c_str());
3658 +  stringstream sRIGHT;
3659 +  sRIGHT << "((" << mcjzb << ")>0)";
3660 +  TCut RIGHT(sRIGHT.str().c_str());
3661 +  
3662 +  TH1F *metleft   = allsamples.Draw("metleft","met[4]",nbins,low,high, "MET [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&LEFT,mc, luminosity, allsamples.FindSample("DYJets"));
3663 +  TH1F *metleftO  = allsamples.Draw("metleftO","met[4]",nbins,low,high, "MET [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&LEFT,mc, luminosity, allsamples.FindSample("DYJets"));
3664 +  TH1F *metright  = allsamples.Draw("metright","met[4]",nbins,low,high, "MET [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&RIGHT,mc, luminosity, allsamples.FindSample("DYJets"));
3665 +  TH1F *metrightO = allsamples.Draw("metrightO","met[4]",nbins,low,high, "MET [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&RIGHT,mc, luminosity, allsamples.FindSample("DYJets"));
3666 +  
3667 +  
3668 +  TH1F *Bpred =  (TH1F*)metleft->Clone("Bpred");
3669 +  Bpred->Add(metleftO,-1);
3670 +  Bpred->Add(metrightO);
3671 +  TH1F *obs = (TH1F*)metright->Clone("obs");
3672 +  
3673 +  metleft->Add(metleftO,-1);
3674 +  metright->Add(metrightO,-1);
3675 +  
3676 +  metleft->SetLineColor(kRed);
3677 +  metright->SetLineColor(kBlack);
3678 +  TPad *metpad = new TPad("metpad","metpad",0,0,1,1);
3679 +  metpad->cd();
3680 +  metpad->SetLogy(1);
3681 +  metleft->Draw("histo");
3682 +  metright->Draw("same");
3683 +  TLegend *lg = make_legend();
3684 +  lg->SetX1(0.5);
3685 +  lg->SetY1(0.7);
3686 +  lg->AddEntry(metright,"JZB>0 (OSOF corrected)","P");
3687 +  lg->AddEntry(metleft,"JZB<0 (OSOF corrected)","L");
3688 +  lg->SetHeader("DY");
3689 +  
3690 +  lg->Draw();
3691 +  save_with_ratio(metright,metleft,metpad->cd(),"METvsJZBplots/ComparingLeftToRightinMETspectrum");
3692 +  
3693 +  TPad *metpad3 = new TPad("metpad3","metpad3",0,0,1,1);
3694 +  metpad3->cd();
3695 +  metpad3->SetLogy(1);
3696 +  Bpred->SetLineColor(kRed);
3697 +  Bpred->Draw("histo");
3698 +  obs->SetLineColor(kBlack);
3699 +  obs->Draw("same");
3700 +  TLegend *lg2 = make_legend();
3701 +  lg2->SetX1(0.5);
3702 +  lg2->SetY1(0.7);
3703 +  lg2->AddEntry(obs,"observed","P");
3704 +  lg2->AddEntry(Bpred,"predicted","L");
3705 +  lg2->SetHeader("DY");
3706 +
3707 +  lg2->Draw();
3708 +  
3709 +  save_with_ratio(obs,Bpred,metpad3->cd(),"METvsJZBplots/ComparingPredObsinMET");
3710 +  
3711 +  TPad *metpad2 = new TPad("metpad2","metpad2",0,0,1,1);
3712 +  metpad2->cd();
3713 +  metpad2->SetLogy(1);
3714 +  
3715 +  TH1F *metlefta   = allsamples.Draw("metlefta","met[2]",nbins,low,high, "MET [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&LEFT,mc, luminosity, allsamples.FindSample("DYJets"));
3716 +  TH1F *metleftOa  = allsamples.Draw("metleftOa","met[2]",nbins,low,high, "MET [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&LEFT,mc, luminosity, allsamples.FindSample("DYJets"));
3717 +  TH1F *metrighta  = allsamples.Draw("metrighta","met[2]",nbins,low,high, "MET [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&RIGHT,mc, luminosity, allsamples.FindSample("DYJets"));
3718 +  TH1F *metrightOa = allsamples.Draw("metrightOa","met[2]",nbins,low,high, "MET [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&RIGHT,mc, luminosity, allsamples.FindSample("DYJets"));
3719 +  
3720 +  metlefta->Add(metleftOa,-1);
3721 +  metrighta->Add(metrightOa,-1);
3722 +  
3723 +  metlefta->SetLineColor(kRed);
3724 +  metpad2->cd();
3725 +  metlefta->Draw("histo");
3726 +  metrighta->Draw("same");
3727 +  lg->Draw();
3728 +  save_with_ratio(metrighta,metlefta,metpad2->cd(),"METvsJZBplots/ComparingLeftToRightinMET_type1_spectrum");
3729 +  
3730 +  delete Bpred;
3731 +  delete obs;
3732 +  
3733 +  float newhigh=300;
3734 +  int newNBins=30;
3735 +  
3736 +  TPad *metpad4 = new TPad("metpad4","metpad4",0,0,1,1);
3737 +  TH1F *Ametleft   = allsamples.Draw("Ametleft","met[4]",newNBins,low,newhigh, "MET [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&LEFT,mc, luminosity);
3738 +  TH1F *AmetleftO  = allsamples.Draw("AmetleftO","met[4]",newNBins,low,newhigh, "MET [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&LEFT,mc, luminosity);
3739 +  TH1F *Ametright  = allsamples.Draw("Ametright","met[4]",newNBins,low,newhigh, "MET [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&RIGHT,mc, luminosity);
3740 +  TH1F *AmetrightO = allsamples.Draw("AmetrightO","met[4]",newNBins,low,newhigh, "MET [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&RIGHT,mc, luminosity);
3741 +  
3742 +  TH1F *aBpred = (TH1F*)Ametleft->Clone("aBpred");
3743 +  aBpred->Add(AmetleftO,-1);
3744 +  aBpred->Add(AmetrightO);
3745 +  aBpred->SetLineColor(kRed);
3746 +  
3747 +  TH1F *aobs = (TH1F*)Ametright->Clone("aobs");
3748 +  metpad4->cd();
3749 +  metpad4->SetLogy(1);
3750 +  aobs->Draw();
3751 +  aBpred->Draw("histo,same");
3752 +  aobs->Draw("same");
3753 +  lg->SetHeader("All MC");
3754 +  lg->Draw();
3755 +  save_with_ratio(aobs,aBpred,metpad4->cd(),"METvsJZBplots/ComparingPredObsinMET_ALLSAMPLES");
3756 +  
3757 +  
3758 +  delete lg;
3759 +  delete canmetjzb;
3760 +  delete metleft;
3761 +  delete metleftO;
3762 +  delete metright;
3763 +  delete metrightO;
3764   }
3765      
3766  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines