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.47 by buchmann, Tue Aug 14 09:32:53 2012 UTC vs.
Revision 1.69 by buchmann, Wed Sep 19 15:33:46 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 +  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 101 | Line 109 | void find_peaks(float &MCPeak,float &MCP
109    float mcSigma,mcSigmaError, dataSigma, dataSigmaError;
110    
111    dout << "Finding global peak : " << endl;
112 <  find_one_peak_combination(TCut(""),mcpeak,mcpeakerr, datapeak,datapeakerr,mcSigma,mcSigmaError, dataSigma,dataSigmaError,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,mcSigmaError,dataSigma,dataSigmaError,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,mcSigmaError,dataSigma,dataSigmaError,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 148 | Line 157 | void find_peaks(float &MCPeak,float &MCP
157      mcjzb << ")";
158    }
159    
160 <  
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, float binWidth = 5.0) {
# 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);
# Line 199 | Line 212 | void make_special_obs_pred_mll_plot(stri
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) {
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.);
# Line 264 | Line 277 | void make_special_obs_pred_mll_plot(stri
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 358 | Line 371 | void draw_ratio_plot(TH1* hdata, THStack
371    oneline->Draw("same");
372   }
373  
374 < void make_OFSF_plot(string variable, string addcut, string legendTitle, int nbins, float min, float max, bool logscale,
375 <                   string xlabel, string filename, bool isPF=true, bool plotratio=true, bool loadlastminmax=false, float legendPosition=0.3) {
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  
367  if(isPF) ibasiccut=basiccut&&"pfjzb[0]>-998";
368
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;
376 <
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 <  ckin->SetLogy(logscale);
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);
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
393    datahistoOF->SetMinimum(0); // Defaults
408    } else {
409      datahistoSF->SetMinimum(0.5);
396    datahistoOF->SetMinimum(0.5);
410    }
411 <  if (logscale) {
412 <    datahistoSF->SetMaximum(5.3*datahistoSF->GetMaximum());
413 <    datahistoOF->SetMaximum(5.3*datahistoSF->GetMaximum());
411 >  if (ymax<0) {
412 >    if ( logscale ) datahistoSF->SetMaximum(5.3*datahistoSF->GetMaximum());
413 >    else datahistoSF->SetMaximum(1.8*datahistoSF->GetMaximum());
414    } else {
415 <    datahistoSF->SetMaximum(2.0*datahistoSF->GetMaximum());
403 <    datahistoOF->SetMaximum(2.0*datahistoOF->GetMaximum());
415 >    datahistoSF->SetMaximum(ymax);
416    }
417  
418 +  float ymaxSet = datahistoSF->GetMaximum();
419 +
420    datahistoSF->GetXaxis()->SetTitle(xlabel.c_str());
421 <  datahistoOF->GetXaxis()->SetTitle(xlabel.c_str());
408 <  signalhisto->GetXaxis()->SetTitle(xlabel.c_str());
409 <  datahistoSF->GetYaxis()->SetTitle("N. Events");
410 <  datahistoOF->GetYaxis()->SetTitle("N. Events");
411 <  signalhisto->GetYaxis()->SetTitle("N. Events");
421 >  datahistoSF->GetYaxis()->SetTitle("Events");
422    datahistoSF->GetXaxis()->CenterTitle();
413  datahistoOF->GetXaxis()->CenterTitle();
414  signalhisto->GetXaxis()->CenterTitle();
423    datahistoSF->GetYaxis()->CenterTitle();
416  datahistoOF->GetYaxis()->CenterTitle();
417  signalhisto->GetYaxis()->CenterTitle();
424  
425 <  TLegend *mleg = new TLegend(0.2+legendPosition, 0.72, 0.55+legendPosition, 0.87, legendTitle.c_str());
426 <  mleg->SetFillColor(kWhite);
427 <  mleg->SetTextFont(42);
428 <  mleg->SetTextSize(0.048);
429 <  mleg->SetLineWidth(0);
430 <  mleg->SetBorderSize(0);
431 <  mleg->AddEntry(datahistoSF, "S. Flavor", "PL");
432 <  mleg->AddEntry(datahistoOF, "O. Flavor", "L");
427 <  mleg->AddEntry(signalhisto, "LM3", "L");
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 <  datahistoOF->Draw("HIST,SAMES");
436 <  signalhisto->Draw("HIST,SAMES");
435 >  if (datahistoOF->Integral()>0) datahistoOF->Draw("HIST,SAMES");
436 >  //signalhisto->Draw("HIST,SAMES");
437    mleg->Draw();
438    DrawPrelim();
439 <  CompleteSave(ckin, "./SFOF/" + filename);
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();
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>20","mll>15&&mll<70", "mll>75&&mll<105", "mll>120" };
515 +  string mllcutname[] = { "m_{ll} > 20 GeV", "20 < 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;
# Line 451 | 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 472 | 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    }
487  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 495 | 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);
# Line 512 | Line 608 | void make_kin_plot(string variable, stri
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 525 | Line 622 | void make_kin_plot(string variable, stri
622    string signal("LM3");
623    TH1F* signalhisto = new TH1F("signalhisto",signal.c_str(),nbins,min,max);
624    int idx = signalsamples.FindSample(signal)[0];
625 <  (signalsamples.collection)[idx].events->Project("signalhisto",variable.c_str(),cut);
626 <  signalhisto->Scale((signalsamples.collection)[idx].weight*luminosity);
627 <  signalhisto->SetLineColor(kOrange);
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");
# Line 576 | Line 673 | void make_kin_plot(string variable, stri
673          kinpad->SetLogy(logscale);
674          datahisto->Draw("e1");
675          mcstack.Draw("same");
676 <        signalhisto->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 584 | Line 681 | void make_kin_plot(string variable, stri
681            upperboundary->Draw("same");
682          }
683            
684 <        kinleg->AddEntry("signalhisto",signal.c_str(),"l");
684 >        if(drawsignal) kinleg->AddEntry("signalhisto",signal.c_str(),"l");
685          kinleg->Draw();
686          write_cut->Draw();
687          DrawPrelim();
# Line 599 | 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  
# Line 649 | Line 747 | void make_JES_plot(TCut cut, string name
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=300;
764 >        mll_hi=320;
765    }
766  
767 <  make_OFSF_plot("pfJetGoodNum40", "mll>20&&mll<40&&met[4]>100", "20 GeV < mll < 40 GeV", 5, 3, 8, true, "N. jets", "njetsLow", false, false, false, 0.2);
768 <  make_OFSF_plot("pfJetGoodNum40", "mll>40&&mll<70&&met[4]>100", "40 GeV < mll < 70 GeV", 5, 3, 8, true, "N. jets", "njetsMed", false, false, false, 0.2);
769 <  make_OFSF_plot("pfJetGoodPt[0]/pfJetGoodPt[1]", "mll>20&&mll<40&&met[4]>100", "20 GeV < mll < 40 GeV", 20, 1, 10, true, "pt_{j}^{1}/pt_{j}^{2}", "jpt1pt2Low", false, false, false, 0.2);
770 <  make_OFSF_plot("pfJetGoodPt[0]/pfJetGoodPt[1]", "mll>40&&mll<70&&met[4]>100", "40 GeV < mll < 70 GeV", 20, 1, 10, true, "pt_{j}^{1}/pt_{j}^{2}", "jpt1pt2Med", false, false, false, 0.2);
771 <  make_OFSF_plot("TMath::Abs(pfJetDphiMet[0])", "mll>20&&mll<40&&met[4]>100", "20 GeV < mll < 40 GeV", 16, 0, 3.2, false, "|#Delta#phi(jet1,MET)|", "dphijetmetLow", false, false, false, 0.0);
772 <  make_OFSF_plot("TMath::Abs(pfJetDphiMet[0])", "mll>40&&mll<70&&met[4]>100", "40 GeV < mll < 70 GeV", 16, 0, 3.2, false, "|#Delta#phi(jet1,MET)|", "dphijetmetMed", false, false, false, 0.0);
773 <  make_OFSF_plot("TMath::Abs(dphi)", "mll>20&&mll<40&&met[4]>100", "20 GeV < mll < 40 GeV", 16, 0, 3.2, false, "|#Delta#phi(l1,l2)|", "dphiLow", false, false, false, 0.2);
774 <  make_OFSF_plot("TMath::Abs(dphi)", "mll>40&&mll<70&&met[4]>100", "40 GeV < mll < 70 GeV", 16, 0, 3.2, false, "|#Delta#phi(l1,l2)|", "dphiMed", false, false, false, 0.2);
775 <  make_OFSF_plot("TMath::Abs(dphiMet1)", "mll>20&&mll<40&&met[4]>100", "20 GeV < mll < 40 GeV", 16, 0, 3.2, false, "|#Delta#phi(l1,MET)|", "dphiMet1Low", false, false, false, 0.2);
776 <  make_OFSF_plot("TMath::Abs(dphiMet1)", "mll>40&&mll<70&&met[4]>100", "40 GeV < mll < 70 GeV", 16, 0, 3.2, false, "|#Delta#phi(l1,MET)|", "dphiMet1Med", false, false, false, 0.2);
777 <  make_OFSF_plot("TMath::Abs(dphiMet2)", "mll>20&&mll<40&&met[4]>100", "20 GeV < mll < 40 GeV", 16, 0, 3.2, false, "|#Delta#phi(l2,MET)|", "dphiMet2Low", false, false, false, 0.2);
778 <  make_OFSF_plot("TMath::Abs(dphiMet2)", "mll>40&&mll<70&&met[4]>100", "40 GeV < mll < 70 GeV", 16, 0, 3.2, false, "|#Delta#phi(l2,MET)|", "dphiMet2Med", false, false, false, 0.2);
779 <  make_OFSF_plot("TMath::Min(TMath::Abs(dphiMet1), TMath::Abs(dphiMet2))", "mll>20&&mll<40&&met[4]>100", "20 GeV < mll < 40 GeV", 16, 0, 3.2, false, "Min(|#Delta#phi(l,MET)|)", "dphilcLow", false, false, false, 0.2);
780 <  make_OFSF_plot("TMath::Min(TMath::Abs(dphiMet1), TMath::Abs(dphiMet2))", "mll>40&&mll<70&&met[4]>100", "40 GeV < mll < 70 GeV", 16, 0, 3.2, false, "Min(|#Delta#phi(l,MET)|)", "dphilcMed", false, false, false, 0.2);
781 <  make_OFSF_plot("TMath::Min(TMath::Abs(pfJetDphiMet[0]), TMath::Min(TMath::Abs(pfJetDphiMet[1]), TMath::Abs(pfJetDphiMet[2])))", "mll>20&&mll<40&&met[4]>100", "20 GeV < mll < 40 GeV", 16, 0, 3.2, false, "Min(|#Delta#phi(jet,MET)|)", "dphijcLow", false, false, false, 0.2);
782 <  make_OFSF_plot("TMath::Min(TMath::Abs(pfJetDphiMet[0]), TMath::Min(TMath::Abs(pfJetDphiMet[1]), TMath::Abs(pfJetDphiMet[2])))", "mll>20&&mll<40&&met[4]>100", "40 GeV < mll < 70 GeV", 16, 0, 3.2, false, "Min(|#Delta#phi(jet,MET)|)", "dphijcMed", false, false, false, 0.2);
783 <  make_OFSF_plot("TMath::Min((TMath::Pi()-TMath::Abs(dphiMet1)), (TMath::Pi() - TMath::Abs(dphiMet2)))", "mll>20&&mll<40&&met[4]>100", "20 GeV < mll < 40 GeV", 16, 0, 3.2, false, "Min(#Pi - |#Delta#phi(l,MET)|)", "dphilcoLow", false, false, false, 0.2);
784 <  make_OFSF_plot("TMath::Min((TMath::Pi()-TMath::Abs(dphiMet1)), (TMath::Pi() - TMath::Abs(dphiMet2)))", "mll>20&&mll<40&&met[4]>100", "40 GeV < mll < 70 GeV", 16, 0, 3.2, false, "Min(#Pi - |#Delta#phi(l,MET)|)", "dphilcoMed", false, false, false, 0.2);
785 <  make_OFSF_plot("TMath::Min((TMath::Pi()-TMath::Abs(pfJetDphiMet[0])), TMath::Min( (TMath::Pi()-TMath::Abs(pfJetDphiMet[1])), (TMath::Pi() - TMath::Abs(pfJetDphiMet[2]))))", "mll>20&&mll<40&&met[4]>100", "20 GeV < mll < 40 GeV", 16, 0, 3.2, false, "Min(#Pi - |#Delta#phi(jet,MET)|)", "dphijcoLow", false, false, false, 0.2);
786 <  make_OFSF_plot("TMath::Min((TMath::Pi()-TMath::Abs(pfJetDphiMet[0])), TMath::Min( (TMath::Pi()-TMath::Abs(pfJetDphiMet[1])), (TMath::Pi() - TMath::Abs(pfJetDphiMet[2]))))", "mll>20&&mll<40&&met[4]>100", "40 GeV < mll < 70 GeV", 16, 0, 3.2, false, "Min(#Pi - |#Delta#phi(jet,MET)|)", "dphijcoMed", false, false, false, 0.2);
787 <
788 <
789 <
790 <  make_kin_plot("met[4]","",70,0,350,dolog,"MET [GeV]","met",doPF,true);
791 <
792 <  make_kin_plot("mll","",(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll",doPF,true);
793 <  make_kin_plot("mll","",(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_osof",doPF,true,true);
794 <  make_kin_plot("mll","",(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_ee",doPF,true);
795 <  make_kin_plot("mll","",(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_mm",doPF,true);
796 <  make_kin_plot("mll","",(int)((mll_hi-mll_low))/5,mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive",doPF,true);
797 <  make_kin_plot("mll","",(int)((mll_hi-mll_low))/5,mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_ee",doPF,true);
798 <  make_kin_plot("mll","",(int)((mll_hi-mll_low))/5,mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_mm",doPF,true);
799 <  make_kin_plot("mll","",(int)((mll_hi-mll_low))/5,mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_osof",doPF,true);
800 <  make_kin_plot("mll","",(int)((350-mll_low))/5,mll_low,350,dolog,"m_{ll} [GeV]","mll_inclusive_highrange",doPF);
801 <  if(!doPF) make_special_mll_plot((int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]");
802 <
803 <  make_kin_plot("pfJetGoodPt[0]/pfJetGoodPt[1]","",45,1,10,dolog,"pt_{j}^{1}/pt_{j}^{2}","j1j2ratio",doPF,true);
804 <  make_kin_plot("TMath::Abs(pfJetDphiMet[0])","",32,0,3.2,nolog,"|#Delta#phi(jet1,MET)|","dphiJ1MET",doPF,true);
805 <
806 <  make_kin_plot("pfJetGoodNum40","",9,-0.5,8.5,dolog,"nJets","nJets",doPF);
807 <  make_kin_plot("pfJetGoodNum40","",9,-0.5,8.5,dolog,"nJets","nJets_osof",doPF);
808 <  make_kin_plot("pfJetGoodNum40","",9,-0.5,8.5,dolog,"nJets","nJets_nocuts_except_mll_ossf",doPF);
809 <
810 <  make_kin_plot("numVtx","",(int)(30.5-(-0.5)),-0.5,30.5,nolog,"N(Vtx)","numVtx",doPF);
811 < //  make_kin_plot("jetpt[0]","",40,0,200,dolog,"leading jet p_{T} [GeV]","pfJetGoodPt_0",doPF);
812 < //  make_kin_plot("jeteta[0]","",40,-5,5,nolog,"leading jet #eta","pfJetGoodEta_0",doPF);
813 <  make_kin_plot("pt","",50,0,500,dolog,"Z p_{T} [GeV]","Zpt",doPF);
814 <  make_kin_plot("pt1","",50,0,200,nolog,"p_{T} [GeV]","pt1",doPF);
815 <  make_kin_plot("pt2","",50,0,200,nolog,"p_{T} [GeV]","pt2",doPF);
816 <  make_kin_plot("eta1","",40,-3,3,nolog,"#eta_{l}","eta",doPF);
817 <  make_kin_plot("jzb[1]","",100,-150,200,dolog,"JZB [GeV]","jzb_ossf",doPF);
818 <  stringstream jzbcut;
819 <  jzbcut << "((is_data&&("<<datajzb<<")>100)||(!is_data&&("<<mcjzb<<")>100))";
820 <  make_kin_plot("mll",jzbcut.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV]","mll_aboveJZB100",doPF,true);
821 <  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);
822 <  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);
823 <  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);
824 <  stringstream jzbcut2;
825 <  jzbcut2 << "((is_data&&("<<datajzb<<")>150)||(!is_data&&("<<mcjzb<<")>150))";
826 <  make_kin_plot("mll",jzbcut2.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV]","mll_aboveJZB150",doPF,true);
827 <  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);
828 <  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);
829 <  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);
830 <  stringstream jzbcut3;
831 <  jzbcut3 << "((is_data&&("<<datajzb<<")>50)||(!is_data&&("<<mcjzb<<")>50))";
832 <  make_kin_plot("mll",jzbcut3.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV]","mll_aboveJZB50",doPF,true);  
833 <  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);
834 <  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);  
835 <  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);  
836 <
837 <  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);
838 <
839 <  make_special_obs_pred_mll_plot(datajzb,mcjzb,0);
840 <  make_special_obs_pred_mll_plot(datajzb,mcjzb,50);
841 <  make_special_obs_pred_mll_plot(datajzb,mcjzb,80);
842 <  make_special_obs_pred_mll_plot(datajzb,mcjzb,100);
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>70";
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>70";
830 >
831 >    make_kin_plot("pfJetGoodPt[0]/pfJetGoodPt[1]","",45,1,10,dolog,"pt_{j}^{1}/pt_{j}^{2}","j1j2ratio",doPF,true);
832 >    make_kin_plot("TMath::Abs(pfJetDphiMet[0])","",32,0,3.2,nolog,"|#Delta#phi(jet1,MET)|","dphiJ1MET",doPF,true);
833 >    // Plots in signal region
834 > //     make_kin_plot("met[4]","",70,0,350,dolog,"MET [GeV]","met",doPF,true);
835 >    make_kin_plot("mll","mll>20"+mllCut,(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll",doPF,true);
836 >    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);
837 >    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);
838 >    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);
839 >    
840 >    make_kin_plot("pfJetGoodNum40",mllCut,9,-0.5,8.5,dolog,"nJets","nJets",doPF);
841 >    make_kin_plot("pfJetGoodNum40","",9,-0.5,8.5,dolog,"nJets","nJets_osof",doPF);
842 >    
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_met100",doPF,true);
844 >    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);
845 >    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);
846 >    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);
847 >    
848 >    
849 >    make_kin_plot("pfJetGoodNum40","met[4]>100"+mllCut,9,-0.5,8.5,dolog,"nJets","nJets_met100",doPF);
850 >    make_kin_plot("pfJetGoodNum40","met[4]>100",9,-0.5,8.5,dolog,"nJets","nJets_osof_met100",doPF);
851 >
852 >    // Further inclusive invariant mass plots
853 >    make_kin_plot("mll","",(int)((mll_hi-mll_low))/5,mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive",doPF,true);
854 >    make_kin_plot("mll","",(int)((mll_hi-mll_low))/5,mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_ee",doPF,true);
855 >    make_kin_plot("mll","",(int)((mll_hi-mll_low))/5,mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_mm",doPF,true);
856 >    make_kin_plot("mll","",(int)((mll_hi-mll_low))/5,mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_osof",doPF,true);
857 >    
858 >    //make_kin_plot("mll","",(int)((350-mll_low))/5,mll_low,350,dolog,"m_{ll} [GeV]","mll_inclusive_highrange",doPF);
859 >    //if(!doPF) make_special_mll_plot((int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]");
860 >    
861 >    
862 >    // Number of jets
863 >    make_kin_plot("pfJetGoodNum40","",9,-0.5,8.5,dolog,"nJets","nJets_inclusive",doPF);
864 >    make_kin_plot("pfJetGoodNum40","",9,-0.5,8.5,dolog,"nJets","nJets_osof_inclusive",doPF);
865 >    //make_kin_plot("pfJetGoodNum40","",9,-0.5,8.5,dolog,"nJets","nJets_nocuts_except_mll_ossf",doPF);
866 >    
867 >    // Others
868 >    make_kin_plot("numVtx","",(int)(30.5-(-0.5)),-0.5,30.5,nolog,"N(Vtx)","numVtx",doPF);
869 >    //  make_kin_plot("jetpt[0]","",40,0,200,dolog,"leading jet p_{T} [GeV]","pfJetGoodPt_0",doPF);
870 >    //  make_kin_plot("jeteta[0]","",40,-5,5,nolog,"leading jet #eta","pfJetGoodEta_0",doPF);
871 >    make_kin_plot("pt","",50,0,500,dolog,"Z p_{T} [GeV]","Zpt",doPF);
872 >    make_kin_plot("pt1","",50,0,200,nolog,"p_{T} [GeV]","pt1",doPF);
873 >    make_kin_plot("pt2","",50,0,200,nolog,"p_{T} [GeV]","pt2",doPF);
874 >    make_kin_plot("eta1","",40,-3,3,nolog,"#eta_{l}","eta",doPF);
875 >    make_kin_plot("jzb[1]","",100,-150,200,dolog,"JZB [GeV]","jzb_ossf",doPF);
876 >    //   stringstream jzbcut;
877 >    //   jzbcut << "((is_data&&("<<datajzb<<")>100)||(!is_data&&("<<mcjzb<<")>100))";
878 >    //   make_kin_plot("mll",jzbcut.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV]","mll_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_osof_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_ee_aboveJZB100",doPF,true);
881 >    //   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);
882 >    //   stringstream jzbcut2;
883 >    //   jzbcut2 << "((is_data&&("<<datajzb<<")>150)||(!is_data&&("<<mcjzb<<")>150))";
884 >    //   make_kin_plot("mll",jzbcut2.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV]","mll_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_osof_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_ee_aboveJZB150",doPF,true);
887 >    //   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);
888 >    //   stringstream jzbcut3;
889 >    //   jzbcut3 << "((is_data&&("<<datajzb<<")>50)||(!is_data&&("<<mcjzb<<")>50))";
890 >    //   make_kin_plot("mll",jzbcut3.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV]","mll_aboveJZB50",doPF,true);  
891 >    //   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);
892 >    //   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);  
893 >    //   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);  
894 >    
895 >    //   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);
896 >    //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);
897 >    //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);
898 >  }
899 >    
900 > //   make_special_obs_pred_mll_plot(datajzb,mcjzb,0);
901 > //   make_special_obs_pred_mll_plot(datajzb,mcjzb,50);
902 > //   make_special_obs_pred_mll_plot(datajzb,mcjzb,80);
903 >   make_special_obs_pred_mll_plot(datajzb,mcjzb,100);
904   //   make_special_obs_pred_mll_plot(datajzb,mcjzb,150);
905   //   make_special_obs_pred_mll_plot(datajzb,mcjzb,200);
906   //   make_special_obs_pred_mll_plot(datajzb,mcjzb,250);
907  
908 <  make_JES_plot(cutmass&&cutOSSF&&basiccut,"_ossf");
909 <  make_JES_plot(cutmass&&cutOSOF&&basiccut,"_osof");
744 <
908 > //   make_JES_plot(cutmass&&cutOSSF&&basiccut,"_ossf");
909 > //   make_JES_plot(cutmass&&cutOSOF&&basiccut,"_osof");
910  
911 +  switch_overunderflow(false);
912   }
913  
914   void make_comp_plot( string var, string xlabel, string filename, float jzbcut, string mcjzb, string datajzb,
# Line 758 | Line 924 | void make_comp_plot( string var, string
924  
925    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- below: the next ~20 lines changed!
926    int nRegions=4;
927 <  if(!PlottingSetup::RestrictToMassPeak) {
927 >  if(!PlottingSetup::RestrictToMassPeak||!PlottingSetup::UseSidebandsForcJZB) {
928      nRegions=2;
929    }
930    
# Line 812 | Line 978 | void region_comparison_plots(string mcjz
978  
979   //  switch_overunderflow(true);  // switching overflow/underflow bins on
980      
981 <  
981 >  switch_overunderflow(true);
982      flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- the arguments changed
983    for(int ijzb=0;ijzb<(int)jzb_cuts.size();ijzb++) {
984      float jzbcut=jzb_cuts[ijzb]; // Comparison plots are done for this JZB cut
# Line 1032 | Line 1198 | vector<TF1*> do_extended_fit_to_plot(TH1
1198   //      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)
1199    TF1 *ttbarlogpar = do_logpar_fit_to_plot(Tprediction);
1200    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
1201 <  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);
1201 >  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);
1202  
1203  
1204    TF1 *ttbarlogparP = new TF1("ttbarlogparP",LogParabolaP,0,(prediction->GetXaxis()->GetBinLowEdge(prediction->GetNbinsX())+prediction->GetXaxis()->GetBinWidth(prediction->GetNbinsX())),8);
# Line 1129 | Line 1295 | if you want to start from scratch (witho
1295  
1296   void do_prediction_plot(string jzb, TCanvas *globalcanvas, float high, int use_data, bool overlay_signal = false,string subdir="" )
1297   {
1298 < //  switch_overunderflow(true);
1298 >  
1299    bool is_data=false;
1300    bool use_signal=false;
1301    if(use_data==1) is_data=true;
1302    if(use_data==2) use_signal=true;
1303 <  int nbins=50;//100;
1304 <  if(is_data) nbins=50;
1303 >  int nbins=int(high/10);//100;
1304 >  if(is_data) nbins=int(high/10);
1305    float low=0;
1306 <  float hi=500;
1306 >  float hi=high;
1307 >  
1308 >  stringstream cutpositiveS;
1309 >  cutpositiveS << "(" << jzb << ">0)";
1310 >  TCut cutpositive(cutpositiveS.str().c_str());
1311 >  stringstream cutnegativeS;
1312 >  cutnegativeS << "(" << jzb << "<0)";
1313 >  TCut cutnegative(cutnegativeS.str().c_str());
1314 >  
1315    
1316    TH1F *blankback = new TH1F("blankback","blankback",int(high/10),0,high);
1317 <  TH1F *RcorrJZBeemm   = allsamples.Draw("RcorrJZBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1318 <  TH1F *LcorrJZBeemm   = allsamples.Draw("LcorrJZBeemm",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1319 <  TH1F *RcorrJZBem     = allsamples.Draw("RcorrJZBem",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1320 <  TH1F *LcorrJZBem     = allsamples.Draw("LcorrJZBem",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1317 >  TH1F *RcorrJZBeemm   = allsamples.Draw("RcorrJZBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutpositive&&cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1318 >  TH1F *LcorrJZBeemm   = allsamples.Draw("LcorrJZBeemm",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutnegative&&cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1319 >  TH1F *RcorrJZBem     = allsamples.Draw("RcorrJZBem",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutpositive&&cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1320 >  TH1F *LcorrJZBem     = allsamples.Draw("LcorrJZBem",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutnegative&&cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1321  
1322    blankback->GetXaxis()->SetTitle(RcorrJZBeemm->GetXaxis()->GetTitle());
1323    blankback->GetYaxis()->SetTitle(RcorrJZBeemm->GetYaxis()->GetTitle());
# Line 1158 | Line 1332 | void do_prediction_plot(string jzb, TCan
1332    
1333    TH1F *RcorrJZBeemmNoS;
1334  
1335 <    //these are for the ratio
1336 <  
1337 <  TH1F *JRcorrJZBeemm   = allsamples.Draw("JRcorrJZBeemm",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1338 <  TH1F *JLcorrJZBeemm   = allsamples.Draw("JLcorrJZBeemm",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1339 <  TH1F *JRcorrJZBem     = allsamples.Draw("JRcorrJZBem",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1166 <  TH1F *JLcorrJZBem     = allsamples.Draw("JLcorrJZBem",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1335 >  //these are for the ratio
1336 >  TH1F *JRcorrJZBeemm   = allsamples.Draw("JRcorrJZBeemm",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutpositive&&cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1337 >  TH1F *JLcorrJZBeemm   = allsamples.Draw("JLcorrJZBeemm",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutnegative&&cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1338 >  TH1F *JRcorrJZBem     = allsamples.Draw("JRcorrJZBem",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutpositive&&cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1339 >  TH1F *JLcorrJZBem     = allsamples.Draw("JLcorrJZBem",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutnegative&&cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1340    
1341    TH1F *JRcorrJZBSBem;
1342    TH1F *JLcorrJZBSBem;
1343    TH1F *JRcorrJZBSBeemm;
1344    TH1F *JLcorrJZBSBeemm;
1345    
1346 <  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);
1346 >  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);
1347  
1348    
1349 <  if(PlottingSetup::RestrictToMassPeak) {
1350 <    RcorrJZBSBem   = allsamples.Draw("RcorrJZBSBem",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1351 <    LcorrJZBSBem   = allsamples.Draw("LcorrJZBSBem",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1352 <    RcorrJZBSBeemm = allsamples.Draw("RcorrJZBSBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1353 <    LcorrJZBSBeemm = allsamples.Draw("LcorrJZBSBeemm",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1349 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
1350 >    RcorrJZBSBem   = allsamples.Draw("RcorrJZBSBem",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutpositive&&sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1351 >    LcorrJZBSBem   = allsamples.Draw("LcorrJZBSBem",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutnegative&&sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1352 >    RcorrJZBSBeemm = allsamples.Draw("RcorrJZBSBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutpositive&&sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1353 >    LcorrJZBSBeemm = allsamples.Draw("LcorrJZBSBeemm",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutnegative&&sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1354      
1355      //these are for the ratio
1356 <    JRcorrJZBSBem   = allsamples.Draw("JRcorrJZBSBem",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1357 <    JLcorrJZBSBem   = allsamples.Draw("JLcorrJZBSBem",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1358 <    JRcorrJZBSBeemm = allsamples.Draw("JRcorrJZBSBeemm",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1359 <    JLcorrJZBSBeemm = allsamples.Draw("JLcorrJZBSBeemm",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1356 >    JRcorrJZBSBem   = allsamples.Draw("JRcorrJZBSBem",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutpositive&&sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1357 >    JLcorrJZBSBem   = allsamples.Draw("JLcorrJZBSBem",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutnegative&&sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1358 >    JRcorrJZBSBeemm = allsamples.Draw("JRcorrJZBSBeemm",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutpositive&&sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1359 >    JLcorrJZBSBeemm = allsamples.Draw("JLcorrJZBSBeemm",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutnegative&&sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1360    }
1361    
1362    TH1F *lm4RcorrJZBeemm;
1363 <  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"));
1363 >  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"));
1364    
1365    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- prediction changed.
1366    
# Line 1200 | Line 1373 | void do_prediction_plot(string jzb, TCan
1373    TH1F *BpredSys = new TH1F("Bpredsys","Bpredsys",PlottingSetup::global_ratio_binning.size()-1,&PlottingSetup::global_ratio_binning[0]);
1374    ClearHisto(BpredSys);
1375      
1376 <  if(PlottingSetup::RestrictToMassPeak) {
1376 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
1377      Bpred->Add(RcorrJZBem,1.0/3.);
1378      Bpred->Add(LcorrJZBem,-1.0/3.);
1379      Bpred->Add(RcorrJZBSBem,1.0/3.);
# Line 1251 | Line 1424 | void do_prediction_plot(string jzb, TCan
1424    SQRT(BpredSys);
1425    BpredSys->Divide(JBpred);
1426  
1254  
1427    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- prediction changed
1428    TH1F *Tpred = (TH1F*)RcorrJZBem->Clone("Bpred");
1429    Tpred->Add(LcorrJZBem,-1.0);
1430 <  if(PlottingSetup::RestrictToMassPeak) {
1430 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
1431      Tpred->Add(RcorrJZBSBem,1.0);
1432      Tpred->Add(LcorrJZBSBem,-1.0);
1433      Tpred->Add(RcorrJZBSBeemm,1.0);
# Line 1304 | Line 1476 | void do_prediction_plot(string jzb, TCan
1476      Bpred->Draw("hist,same");
1477      //analytical_function[0]->Draw("same"); analytical_function[1]->Draw("same");analytical_function[2]->Draw("same");
1478      RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
1479 <    lm4RcorrJZBeemm->Draw("hist,same");
1479 >    //lm4RcorrJZBeemm->Draw("hist,same");
1480      legBpred->AddEntry(RcorrJZBeemm,"observed","p");
1481      legBpred->AddEntry(Bpred,"predicted","l");
1482   //    legBpred->AddEntry(analytical_function[1],"predicted fit","l");
1483   //    legBpred->AddEntry(analytical_function[2],"stat. uncert.","l");
1484 <    legBpred->AddEntry(lm4RcorrJZBeemm,(allsamples.collection[allsamples.FindSample("LM")[0]].samplename).c_str(),"l");
1484 > //     legBpred->AddEntry(lm4RcorrJZBeemm,(allsamples.collection[allsamples.FindSample("LM")[0]].samplename).c_str(),"l");
1485      legBpred->Draw();
1486      DrawPrelim();
1487  
# Line 1319 | Line 1491 | void do_prediction_plot(string jzb, TCan
1491      Bpred->SetLineWidth(2);
1492      predcomppad->cd();
1493      predcomppad->SetLogy(1);
1322    
1494      TH1F *jzbnegative = (TH1F*)LcorrJZBeemm->Clone("jzbnegative");
1495      TH1F *sidebandsemu = (TH1F*)Bpred->Clone("sidebandsemu");
1496      sidebandsemu->Add(jzbnegative,-1);
# Line 1341 | Line 1512 | void do_prediction_plot(string jzb, TCan
1512   //    lm4RcorrJZBeemm->SetLineColor(kOrange+1);
1513      lm4RcorrJZBeemm->SetLineWidth(2);
1514      //lm4RcorrJZBeemm->SetLineWidth(2); // paper style. overruled.
1515 <    lm4RcorrJZBeemm->Draw("histo,same");
1515 > //     lm4RcorrJZBeemm->Draw("histo,same");
1516      DrawPrelim();
1517      TLegend *speciallegBpred = make_legend("",0.45,0.55);
1518      //TLegend *speciallegBpred = make_legend("",0.35,0.55); // paper style. overruled.
1519      speciallegBpred->AddEntry(RcorrJZBeemm,"Data","pl");
1520      speciallegBpred->AddEntry(Bpred,"Total background","l");
1521      speciallegBpred->AddEntry(jzbnegative,"JZB<0 (data)","f");
1522 <    if(PlottingSetup::RestrictToMassPeak) speciallegBpred->AddEntry(sidebandsemu,"Sidebands/e#mu (data)","f");
1522 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) speciallegBpred->AddEntry(sidebandsemu,"Sidebands/e#mu (data)","f");
1523      else speciallegBpred->AddEntry(sidebandsemu,"e#mu (data)","f");
1524   //    speciallegBpred->AddEntry(lm4RcorrJZBeemmC,"LM4","l");
1525 <    speciallegBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
1525 > //     speciallegBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
1526      speciallegBpred->Draw();
1527      save_with_ratio(JRcorrJZBeemm,JBpred,predcomppad,subdir+"Bpred_Data_____PredictionComposition",true,true,"data/pred",BpredSys);
1528      
# Line 1387 | Line 1558 | void do_prediction_plot(string jzb, TCan
1558      legBpred->AddEntry(Bpred,"MC predicted","l");    
1559      if(versok) legBpred->AddEntry((TObject*)0,"",""); // Just for alignment // causes seg fault on root v5.18
1560      if(versok) legBpred->AddEntry((TObject*)0,"",""); // causes seg fault on root v5.18
1561 <    if ( overlay_signal ) legBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
1561 > //     if ( overlay_signal ) legBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
1562      legBpred->Draw();
1563      DrawMCPrelim();
1564      Bpredsaveas="Bpred_MC";
# Line 1419 | Line 1590 | void do_prediction_plot(string jzb, TCan
1590        
1591        RcorrJZBeemmNoS->SetLineStyle(2);
1592        legBpred2->AddEntry(RcorrJZBeemmNoS,"MC B","l");
1593 <      legBpred2->AddEntry(lm4RcorrJZBeemm,"MC S","l");
1593 > //       legBpred2->AddEntry(lm4RcorrJZBeemm,"MC S","l");
1594        legBpred2->Draw();
1595        RcorrJZBeemmNoS->SetLineColor(TColor::GetColor("#61210B"));
1596        RcorrJZBeemmNoS->Draw("histo,same");
# Line 1438 | Line 1609 | void do_prediction_plot(string jzb, TCan
1609    //save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,Bpredsaveas,true,use_data!=1,ytitle);
1610    save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,subdir+Bpredsaveas,true,false,ytitle,BpredSys);//not extending the y range anymore up to 4
1611  
1612 +
1613    
1614    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
1615    // The part below is meaningless for the offpeak analysis (it's a comparison of the different estimates but there is but one estimate!)
1616 <  if(PlottingSetup::RestrictToMassPeak) {
1616 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
1617      TH1F *Bpredem = (TH1F*)LcorrJZBeemm->Clone("Bpredem");
1618      Bpredem->Add(RcorrJZBem);
1619      Bpredem->Add(LcorrJZBem,-1);
# Line 1496 | Line 1668 | void do_prediction_plot(string jzb, TCan
1668        legBpredc->AddEntry(Bpredem,"MC OFZP","l");
1669        legBpredc->AddEntry(BpredSBem,"MC OFSB","l");
1670        legBpredc->AddEntry(BpredSBeemm,"MC SFSB","l");
1671 <      if ( overlay_signal ) legBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
1671 > //       if ( overlay_signal ) legBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
1672        legBpredc->Draw();
1673        CompleteSave(globalcanvas,subdir+"Bpred_MCwithS_comparison");
1674      }
# Line 1520 | Line 1692 | void do_prediction_plot(string jzb, TCan
1692    delete blankback;
1693    
1694    delete BpredSys;
1695 <  if(PlottingSetup::RestrictToMassPeak) {
1695 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
1696      delete RcorrJZBSBem;
1697      delete LcorrJZBSBem;
1698      delete RcorrJZBSBeemm;
# Line 1532 | Line 1704 | void do_prediction_plot(string jzb, TCan
1704      delete JLcorrJZBSBeemm;
1705    }
1706    if(overlay_signal || use_data==2) delete lm4RcorrJZBeemm;
1535  switch_overunderflow(false);
1707   }
1708  
1709   void do_prediction_plots(string mcjzb, string datajzb, float DataSigma, float MCSigma, bool overlay_signal ) {
1710 +  switch_overunderflow(true);
1711    TCanvas *globalcanvas = new TCanvas("globalcanvas","Prediction Canvas");
1712    do_prediction_plot(datajzb,globalcanvas,jzbHigh ,data,overlay_signal);
1713    if ( !PlottingSetup::Approved ) {
# Line 1544 | Line 1716 | void do_prediction_plots(string mcjzb, s
1716    } else {
1717      write_info(__FUNCTION__,"You set approved to true, therefore not producing prediction/observation plots for MC with and without signal.");
1718    }
1719 < }
1720 <
1549 < void do_ratio_plot(int is_data,vector<float> binning, string jzb, TCanvas *can, float high=-9999) {
1550 <  bool do_data=0;
1551 <  bool dosignal=0;
1552 <  if(is_data==1) do_data=1;
1553 <  if(is_data==2) dosignal=1;
1554 <  TH1F *RcorrJZBeemm   = allsamples.Draw("RcorrJZBeemm",jzb.c_str(),binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,do_data, luminosity,dosignal);
1555 <  TH1F *LcorrJZBeemm   = allsamples.Draw("LcorrJZBeemm",("-"+jzb).c_str(),binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,do_data, luminosity,dosignal);
1556 <  TH1F *RcorrJZBem     = allsamples.Draw("RcorrJZBem",jzb.c_str(),binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,do_data, luminosity,dosignal);
1557 <  TH1F *LcorrJZBem     = allsamples.Draw("LcorrJZBem",("-"+jzb).c_str(),binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,do_data, luminosity,dosignal);
1558 <  
1559 <  TH1F *RcorrJZBSBem;
1560 <  TH1F *LcorrJZBSBem;
1561 <  TH1F *RcorrJZBSBeemm;
1562 <  TH1F *LcorrJZBSbeemm;
1563 <  
1564 <  if(PlottingSetup::RestrictToMassPeak) {
1565 <    RcorrJZBSBem   = allsamples.Draw("RcorrJZBSbem",jzb.c_str(),binning, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,do_data, luminosity,dosignal);
1566 <    LcorrJZBSBem   = allsamples.Draw("LcorrJZBSbem",("-"+jzb).c_str(),binning, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,do_data, luminosity,dosignal);
1567 <    RcorrJZBSBeemm = allsamples.Draw("RcorrJZBSbeemm",jzb.c_str(),binning, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,do_data, luminosity,dosignal);
1568 <    LcorrJZBSbeemm = allsamples.Draw("LcorrJZBSbeemm",("-"+jzb).c_str(),binning, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,do_data, luminosity,dosignal);
1569 <  }
1570 <  
1571 <
1572 <
1573 <
1574 <  flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
1575 <  TH1F *Bpred = (TH1F*)LcorrJZBeemm->Clone("Bpred");
1576 <  if(PlottingSetup::RestrictToMassPeak) {
1577 <    Bpred->Add(RcorrJZBem,1.0/3);
1578 <    Bpred->Add(LcorrJZBem,-1.0/3);
1579 <    Bpred->Add(RcorrJZBSBem,1.0/3);
1580 <    Bpred->Add(LcorrJZBSBem,-1.0/3);
1581 <    Bpred->Add(RcorrJZBSBeemm,1.0/3);
1582 <    Bpred->Add(LcorrJZBSbeemm,-1.0/3);
1583 <  } else {
1584 <    Bpred->Add(RcorrJZBem,1.0);
1585 <    Bpred->Add(LcorrJZBem,-1.0);
1586 <  }
1587 <
1588 <  can->cd();
1589 <  can->SetLogy(0);
1590 <  Bpred->SetLineColor(kRed);
1591 <  Bpred->SetStats(0);
1592 <  if(high>0) Bpred->GetXaxis()->SetRangeUser(0,high);
1593 <  TH1F *JZBratioforfitting=(TH1F*)RcorrJZBeemm->Clone("JZBratioforfitting");
1594 <  JZBratioforfitting->Divide(Bpred);
1595 <  TGraphAsymmErrors *JZBratio = histRatio(RcorrJZBeemm,Bpred,is_data,binning,false);
1596 <  
1597 <  
1598 <  JZBratio->SetTitle("");
1599 <  JZBratio->GetYaxis()->SetRangeUser(0.0,9.0);
1600 < //  if(is_data==1) JZBratio->GetXaxis()->SetRangeUser(0,jzbHigh );
1601 <  
1602 <  TF1 *pol0 = new TF1("pol0","[0]",0,1000);
1603 <  TF1 *pol0d = new TF1("pol0","[0]",0,1000);
1604 < //  straightline_fit->SetParameter(0,1);
1605 <  JZBratioforfitting->Fit(pol0,"Q0R","",0,30);
1606 <  pol0d->SetParameter(0,pol0->GetParameter(0));
1607 <  
1608 <  JZBratio->GetYaxis()->SetTitle("Observed/Predicted");
1609 <  JZBratio->GetXaxis()->SetTitle("JZB [GeV]");
1610 <  if ( high>0 ) JZBratio->GetXaxis()->SetRangeUser(0.0,high);
1611 <  JZBratio->GetYaxis()->SetNdivisions(519);
1612 <  JZBratio->GetYaxis()->SetRangeUser(0.0,4.0);
1613 <  JZBratio->GetYaxis()->CenterTitle();
1614 <  JZBratio->GetXaxis()->CenterTitle();
1615 <  JZBratio->SetMarkerSize(DataMarkerSize);
1616 <  JZBratio->Draw("AP");
1617 <  /////----------------------------
1618 <  TPaveText *writeresult = new TPaveText(0.15,0.78,0.49,0.91,"blNDC");
1619 <  writeresult->SetFillStyle(4000);
1620 <  writeresult->SetFillColor(kWhite);
1621 <  writeresult->SetTextFont(42);
1622 <  writeresult->SetTextSize(0.03);
1623 <  writeresult->SetTextAlign(12);
1624 <  ostringstream jzb_agreement_data_text;
1625 <  jzb_agreement_data_text<< setprecision(2) << "mean =" << pol0->GetParameter(0) << " #pm " << setprecision(1) <<  pol0->GetParError(0);
1626 <  if(is_data==1) fitresultconstdata=pol0->GetParameter(0);// data
1627 <  if(is_data==0) fitresultconstmc=pol0->GetParameter(0); // monte carlo, no signal
1628 < /*  if(is_data) writeresult->AddText("Data closure test");
1629 <  else writeresult->AddText("MC closure test");
1630 <  */
1631 <  writeresult->AddText(jzb_agreement_data_text.str().c_str());
1632 < //  writeresult->Draw("same");
1633 < //  pol0d->Draw("same");
1634 <  TF1 *topline =  new TF1("","1.5",0,1000);
1635 <  TF1 *bottomline =  new TF1("","0.5",0,1000);
1636 <  topline->SetLineColor(kBlue);
1637 <  topline->SetLineStyle(2);
1638 <  bottomline->SetLineColor(kBlue);
1639 <  bottomline->SetLineStyle(2);
1640 < //  topline->Draw("same");
1641 < //  bottomline->Draw("same");
1642 <  TF1 *oneline = new TF1("","1.0",0,1000);
1643 <  oneline->SetLineColor(kBlue);
1644 <  oneline->SetLineStyle(1);
1645 <  oneline->Draw("same");
1646 <  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.
1647 <  if(is_data==1) DrawPrelim();
1648 <  else DrawMCPrelim();
1649 <  TLegend *leg = new TLegend(0.55,0.75,0.89,0.89);
1650 <  leg->SetTextFont(42);
1651 <  leg->SetTextSize(0.04);
1652 < //   if(is_data==1) leg->SetHeader("Ratio (data)");
1653 < //   else leg->SetHeader("Ratio (MC)");
1654 <
1655 <  TString MCtitle("MC ");
1656 <  if (is_data==1) MCtitle = "";
1657 <
1658 <  leg->SetFillStyle(4000);
1659 <  leg->SetFillColor(kWhite);
1660 <  leg->SetTextFont(42);
1661 < //  leg->AddEntry(topline,"+20\% sys envelope","l");
1662 <  leg->AddEntry(JZBratio,MCtitle+"obs / "+MCtitle+"pred","p");
1663 <  leg->AddEntry(oneline,"ratio = 1","l");
1664 < //  leg->AddEntry(pol0d,"fit in [0,30] GeV","l");
1665 < //  leg->AddEntry(bottomline,"#pm50% envelope","l");
1666 <
1667 <
1668 <  //leg->Draw("same"); // no longer drawing legend
1669 <
1670 <  if(is_data==1) CompleteSave(can, "jzb_ratio_data");
1671 <  if(is_data==0) CompleteSave(can, "jzb_ratio_mc");
1672 <  if(is_data==2) CompleteSave(can, "jzb_ratio_mc_BandS");//special case, MC with signal!
1673 <  
1674 <  delete RcorrJZBeemm;
1675 <  delete LcorrJZBeemm;
1676 <  delete RcorrJZBem;
1677 <  delete LcorrJZBem;
1678 <  
1679 <  delete RcorrJZBSBem;
1680 <  delete LcorrJZBSBem;
1681 <  delete RcorrJZBSBeemm;
1682 <  delete LcorrJZBSbeemm;
1683 < }
1684 <
1685 < void do_ratio_plots(string mcjzb,string datajzb,vector<float> ratio_binning) {
1686 <  TCanvas *globalc = new TCanvas("globalc","Ratio Plot Canvas");
1687 <  globalc->SetLogy(0);
1688 <  
1689 <  do_ratio_plot(mc,ratio_binning,mcjzb,globalc, jzbHigh  );
1690 <  do_ratio_plot(data,ratio_binning,datajzb,globalc, jzbHigh  );
1691 <  do_ratio_plot(mcwithsignal,ratio_binning,mcjzb,globalc, jzbHigh  );
1719 >  delete globalcanvas;
1720 >  switch_overunderflow(false);
1721   }
1722  
1723   string give_jzb_expression(float peak, int type) {
# Line 1880 | Line 1909 | void draw_pure_jzb_histo(TCut cut,string
1909    datahisto->Draw("same,e1");
1910    
1911    TLegend *leg;
1912 <  if (!PlottingSetup::RestrictToMassPeak) {
1912 >  if (!PlottingSetup::RestrictToMassPeak||!PlottingSetup::UseSidebandsForcJZB) {
1913      if(is_OF(cut)) leg = allsamples.allbglegend("Opposite flavor",datahisto);
1914      else leg = allsamples.allbglegend("Same flavor",datahisto);
1915    } else {
# Line 1943 | Line 1972 | void produce_stretched_jzb_plots(string
1972    draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass&&"id1==1",datajzb,mcjzb,"Dibosons/mm/jzb_OS_SFZP",dican,binning);
1973    draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass&&"id1==0",datajzb,mcjzb,"Dibosons/ee/jzb_OS_OFZP",dican,binning);
1974    draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass&&"id1==1",datajzb,mcjzb,"Dibosons/mm/jzb_OS_OFZP",dican,binning);
1975 <  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"Dibosons/jzb_OS_SFSB",dican,binning);
1976 <  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"Dibosons/jzb_OS_OFSB",dican,binning);
1975 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"Dibosons/jzb_OS_SFSB",dican,binning);
1976 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"Dibosons/jzb_OS_OFSB",dican,binning);
1977    
1978    draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass,datajzb,mcjzb,"Dibosons/jzb_OS_SFZP_coarse",dican,coarse_binning);
1979    draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass,datajzb,mcjzb,"Dibosons/jzb_OS_OFZP_coarse",dican,coarse_binning);
1980 <  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"Dibosons/jzb_OS_SFSB_coarse",dican,coarse_binning);
1981 <  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"Dibosons/jzb_OS_OFSB_coarse",dican,coarse_binning);
1980 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"Dibosons/jzb_OS_SFSB_coarse",dican,coarse_binning);
1981 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"Dibosons/jzb_OS_OFSB_coarse",dican,coarse_binning);
1982    
1983    delete dican;
1984   }
1985    
1986  
1987   void diboson_plots(string mcjzb, string datajzb,vector<float> ratio_binning) {
1988 +  switch_overunderflow(true);
1989    vector<int> SamplesToBeModified = allsamples.FindSampleBySampleName("WW/WZ/ZZ");
1990    
1991    if(SamplesToBeModified.size()==0 || SamplesToBeModified[0]==-1) {
# Line 1995 | Line 2025 | void diboson_plots(string mcjzb, string
2025      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;
2026      
2027    }
2028 <  
2028 > //   switch_overunderflow(false);
2029   }
2030  
2031  
# Line 2030 | Line 2060 | void draw_normalized_data_vs_data_histo(
2060  
2061  
2062   void jzb_plots(string mcjzb, string datajzb,vector<float> ratio_binning) {
2063 +  switch_overunderflow(true);
2064    TCanvas *can = new TCanvas("can","JZB Plots Canvas");
2065    float max=jzbHigh ;
2066    float min=-120;
# Line 2050 | Line 2081 | void jzb_plots(string mcjzb, string data
2081      draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass&&"id1==0",datajzb,mcjzb,"ee/jzb_OS_OFZP",can,binning);
2082      draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass&&"id1==1",datajzb,mcjzb,"mm/jzb_OS_OFZP",can,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",can,binning);
2085 <    if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_OFSB",can,binning);
2084 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_SFSB",can,binning);
2085 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_OFSB",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",can,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_coarse",can,coarse_binning);
2088      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 2062 | Line 2093 | void jzb_plots(string mcjzb, string data
2093    if ( !PlottingSetup::Approved ) {
2094      draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_OFZP_coarse",can,coarse_binning);
2095      flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
2096 <    if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_SFSB_coarse",can,coarse_binning);
2097 <    if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_OFSB_coarse",can,coarse_binning);
2096 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_SFSB_coarse",can,coarse_binning);
2097 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_OFSB_coarse",can,coarse_binning);
2098    }
2099    delete can;
2100 +  switch_overunderflow(false);
2101   }
2102  
2103  
# Line 2115 | Line 2147 | void compute_MC_yields(string mcjzb,vect
2147    TCanvas *yica = new TCanvas("yica","yield canvas");
2148    
2149    int nRegions=4;
2150 <  if(!PlottingSetup::RestrictToMassPeak) nRegions=2;
2150 >  if(!PlottingSetup::RestrictToMassPeak||!PlottingSetup::UseSidebandsForcJZB) nRegions=2;
2151    string tsRegions[] = {"SFZP","OFZP","SFSB","OFSB"};
2152    string posneg[] = {"pos","neg"};
2153    TCut tkRegions[] = {cutOSSF&&cutnJets&&cutmass,cutOSOF&&cutnJets&&cutmass,cutOSSF&&cutnJets&&sidebandcut,cutOSOF&&cutnJets&&sidebandcut};
# Line 2563 | Line 2595 | void save_template(string mcjzb, string
2595    configfile<<"\n\n";
2596    configfile<<"luminosity="<<luminosity<<";\n";
2597    configfile<<"RestrictToMassPeak="<<RestrictToMassPeak<<";//defines the type of analysis we're running\n";
2598 +  configfile<<"UseSidebandsForcJZB="<<UseSidebandsForcJZB<<";//tells us whether to use the sidebands or not\n";
2599    
2600    configfile<<"\n\ncout << \"Configuration successfully loaded!\" << endl; \n \n } \n \n";
2601    
# Line 2605 | Line 2638 | void ttbar_sidebands_comparison(string m
2638    //in the case of the on peak analysis, we compare the 3 control regions to the real value
2639    //in the case of the OFF peak analysis, we compare our control region to the real value
2640    TCut weightbackup=cutWeight;
2641 +  switch_overunderflow(true);
2642    
2643    bool doPURW=false;
2644    
# Line 2635 | Line 2669 | void ttbar_sidebands_comparison(string m
2669    TH1F *TSeemm;
2670    TH1F *nTSeemm;
2671    
2672 <  if(PlottingSetup::RestrictToMassPeak) {
2672 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2673      TSem    = systsamples.Draw("TSem",       mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSOF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2674      nTSem   = systsamples.Draw("nTSem",  "-"+mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSOF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2675      TSeemm  = systsamples.Draw("TSeemm",     mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSSF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
# Line 2651 | Line 2685 | void ttbar_sidebands_comparison(string m
2685    TZem->SetMarkerColor(kRed);
2686  
2687  
2688 <  if(PlottingSetup::RestrictToMassPeak) {
2688 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2689          TSem->SetLineColor(TColor::GetColor("#00A616"));
2690          TSeemm->SetLineColor(kMagenta+2);
2691          TSem->SetMarkerColor(TColor::GetColor("#00A616"));
# Line 2665 | Line 2699 | void ttbar_sidebands_comparison(string m
2699    TZeemm->GetXaxis()->SetRangeUser(-100,binning[binning.size()-1]);
2700    histos.push_back(TZem);
2701    histos.push_back(TZeemm);
2702 <  if(PlottingSetup::RestrictToMassPeak) {
2702 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2703      TSeemm->GetXaxis()->SetRangeUser(-100,binning[binning.size()-1]);
2704      TSem->GetXaxis()->SetRangeUser(-100,binning[binning.size()-1]);
2705      histos.push_back(TSem);
2706      histos.push_back(TSeemm);
2707    }
2708 <  draw_all_ttbar_histos(tcan,histos,"histo",1);
2708 >  draw_all_ttbar_histos(tcan,histos,"histo",8);
2709    
2710    TLegend *leg = make_legend("MC t#bar{t}",0.6,0.65,false);
2711    leg->AddEntry(TZeemm,"SFZP","l");
2712    leg->AddEntry(TZem,"OFZP","l");
2713 <  if(PlottingSetup::RestrictToMassPeak) {
2713 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2714      leg->AddEntry(TSeemm,"SFSB","l");
2715      leg->AddEntry(TSem,"OFSB","l");
2716    }
2717    leg->Draw("same");
2718    DrawMCPrelim(simulatedlumi);
2719    CompleteSave(tcan,"Systematics/"+prestring+"/ttbar_shape_comparison");
2720 +  
2721    TH1F *TZemcopy = (TH1F*)TZem->Clone("TZemcopy");
2722    TH1F *TZeemmcopy = (TH1F*)TZeemm->Clone("TZeemmcopy");
2723    TH1F *TSeemmcopy;
2724    TH1F *TSemcopy;
2725 <  if(PlottingSetup::RestrictToMassPeak) {
2725 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2726      TSeemmcopy = (TH1F*)TSeemm->Clone("TSeemmcopy");
2727      TSemcopy = (TH1F*)TSem->Clone("TSemcopy");
2728    }
2729  
2730    TZem->Divide(TZeemm);
2731    TZem->SetMarkerStyle(21);
2732 <  if(PlottingSetup::RestrictToMassPeak) {
2732 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2733      TSem->Divide(TZeemm);
2734      TSeemm->Divide(TZeemm);
2735      TSem->SetMarkerStyle(24);
# Line 2705 | Line 2740 | void ttbar_sidebands_comparison(string m
2740    TZem->GetYaxis()->SetRangeUser(0,2.5);
2741    TZem->GetYaxis()->SetTitle("ratio");
2742    TZem->Draw();
2743 <  if(PlottingSetup::RestrictToMassPeak) {
2743 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2744      TSem->Draw("same");
2745      TSeemm->Draw("same");
2746    }
# Line 2735 | Line 2770 | void ttbar_sidebands_comparison(string m
2770    
2771    TLegend *leg2 = make_legend("MC t#bar{t}",0.55,0.75,false);
2772    leg2->AddEntry(TZem,"OFZP / SFZP","ple");
2773 <  if(PlottingSetup::RestrictToMassPeak) {
2773 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2774      leg2->AddEntry(TSeemm,"SFSB / SFZP","ple");
2775      leg2->AddEntry(TSem,"OFSB / SFZP","ple");
2776    }
# Line 2748 | Line 2783 | void ttbar_sidebands_comparison(string m
2783    DrawMCPrelim(simulatedlumi);
2784    CompleteSave(tcan,"Systematics/"+prestring+"/ttbar_shape_comparison_ratio");
2785    
2786 +  
2787    if (0) { // Turn this off: we don't need this
2788  
2789      ///-------------- second part: only look at the quantity we actually care about!
# Line 2761 | Line 2797 | void ttbar_sidebands_comparison(string m
2797      TH1F *rightofsb;
2798      TH1F *leftsfsb;
2799      TH1F *rightsfsb;
2800 <    if(PlottingSetup::RestrictToMassPeak) {
2800 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2801        leftofsb  = (TH1F*)nTSem->Clone("leftofsb");
2802        rightofsb = (TH1F*)TSemcopy->Clone("rightofsb");
2803        rightofsb->Add(leftofsb,-1);
# Line 2775 | Line 2811 | void ttbar_sidebands_comparison(string m
2811      rightsfzp->GetYaxis()->SetTitle("#deltaJZB / 25 GeV");
2812      rightsfzp->Draw("histo");
2813      rightofzp->Draw("histo,same");
2814 <    if(PlottingSetup::RestrictToMassPeak) {
2814 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2815        rightofsb->Draw("histo,same");
2816        rightsfsb->Draw("histo,same");
2817      }
# Line 2784 | Line 2820 | void ttbar_sidebands_comparison(string m
2820      TLegend *legA = make_legend("MC t#bar{t}",0.6,0.65,false);
2821      legA->AddEntry(rightsfzp,"SFZP","l");
2822      legA->AddEntry(rightofzp,"OFZP","l");
2823 <    if(PlottingSetup::RestrictToMassPeak) {
2823 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2824        legA->AddEntry(rightofsb,"SFSB","l");
2825        legA->AddEntry(rightsfsb,"OFSB","l");
2826      }
# Line 2798 | Line 2834 | void ttbar_sidebands_comparison(string m
2834      rightofzp->GetYaxis()->SetRangeUser(0.0,2.5);
2835      rightofzp->GetYaxis()->SetTitle("#deltaJZB ratio");
2836      rightofzp->Draw();
2837 <    if(PlottingSetup::RestrictToMassPeak) {
2837 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2838        rightofsb->Divide(rightsfzp);
2839        rightsfsb->Divide(rightsfzp);
2840        rightofsb->Draw("same");
# Line 2818 | Line 2854 | void ttbar_sidebands_comparison(string m
2854      bottom2->Draw("same");
2855  
2856      rightofzp->SetMarkerStyle(21);
2857 <    if(PlottingSetup::RestrictToMassPeak) {
2857 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2858        rightofsb->SetMarkerStyle(24);
2859        rightsfsb->SetMarkerStyle(32);
2860      }
2861  
2862      TLegend *leg3 = make_legend("MC t#bar{t}",0.55,0.75,false);
2863      leg3->AddEntry(rightofzp,"OFZP / SFZP","ple");
2864 <    if(PlottingSetup::RestrictToMassPeak) {
2864 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2865        leg3->AddEntry(rightsfsb,"SFSB / SFZP","ple");
2866        leg3->AddEntry(rightofsb,"OFSB / SFZP","ple");
2867      }
# Line 2844 | Line 2880 | void ttbar_sidebands_comparison(string m
2880    delete nTZem;
2881    delete TZeemm;
2882    delete nTZeemm;
2883 <  if(PlottingSetup::RestrictToMassPeak) {
2883 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2884          delete TSem;
2885          delete nTSem;
2886          delete TSeemm;
# Line 2853 | Line 2889 | void ttbar_sidebands_comparison(string m
2889  
2890    delete tcan;
2891    cutWeight=weightbackup;
2892 +  switch_overunderflow(false);
2893   }
2894  
2895   void ttbar_sidebands_comparison(string mcjzb, vector<float> jzb_binning) {
# Line 2887 | Line 2924 | void ttbar_sidebands_comparison(string m
2924    nicer_binning.push_back(150);
2925    //nicer_binning.push_back(175);
2926    nicer_binning.push_back(200);
2927 <  nicer_binning.push_back(250);
2928 <  nicer_binning.push_back(300);
2929 <  nicer_binning.push_back(400);
2927 > //  nicer_binning.push_back(250);
2928 > //  nicer_binning.push_back(300);
2929 > //  nicer_binning.push_back(400);
2930    
2931    ttbar_sidebands_comparison(mcjzb,nicer_binning, "ttbar/");
2932   }
2933  
2934  
2935   void zjets_prediction_comparison(string mcjzbWithPUa) {
2936 +  cout << "****************************************************************************************************************************************************************" << endl;
2937    TCanvas *zcan = new TCanvas("zcan","zcan");  
2938   //  zcan->SetLogy(1);
2939    TCut weightbackup=cutWeight;
2940    
2941 <  bool UsePURW=false;
2941 >  bool UsePURW=true;
2942    
2943    
2944    string mcjzb;
2945    if(UsePURW) {
2946      mcjzb=mcjzbWithPUa;
2947 +    cout << "Using PURW peak positions" << endl;
2948    } else {
2949      // Do it without PU re-weighting
2950 +    cutWeight="1.0";
2951      float MCPeakNoPU=0,MCPeakErrorNoPU=0,DataPeakNoPU=0,DataPeakErrorNoPU=0,MCSigma=0,DataSigma=0;
2952      stringstream resultsNoPU;
2953      stringstream noPUdatajzb;
# Line 2918 | Line 2958 | void zjets_prediction_comparison(string
2958      
2959      mcjzb = noPUmcjzb.str();
2960      
2921    cutWeight="1.0";
2961    }
2962  
2963    
# Line 2942 | Line 2981 | void zjets_prediction_comparison(string
2981    string var( "abs("+mcjzb+")" );
2982    
2983    TCut notTau("abs(genMID1)!=15");
2984 <  TCut ONLYTau("mll>20");
2984 >  TCut ee_mm_tautau("mll>0");
2985    
2986  
2987    TH1F *hJZBpos = systsamples.Draw("hJZBpos",var,binning, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets&&notTau&&kPos,mc,simulatedlumi,systsamples.FindSample("/DY"));
# Line 2971 | Line 3010 | void zjets_prediction_comparison(string
3010    }
3011    
3012    zcan->SetLogy(0);
3013 <  hratio->GetYaxis()->SetRangeUser(0,2.0);
3013 >  hratio->GetYaxis()->SetRangeUser(0,2.5);
3014    hratio->GetYaxis()->SetTitle("Observed/Predicted");
3015    hratio->Draw("e1");
3016    
# Line 2997 | Line 3036 | void zjets_prediction_comparison(string
3036    
3037    TCut reducedNJets(cutnJets);
3038    
3039 <  TH1F *TAUhJZBpos = systsamples.Draw("TAUhJZBpos",var,binning, "JZB [GeV]", "events",cutmass&&cutOSSF&&reducedNJets&&ONLYTau&&kPos,mc,simulatedlumi,systsamples.FindSample("/DY"));
3040 <  TH1F *LcorrJZBeemm     = systsamples.Draw("LcorrJZBeemm",var,binning, "JZB [GeV]", "events",cutmass&&cutOSSF&&reducedNJets&&ONLYTau&&kNeg,mc,simulatedlumi,systsamples.FindSample("/DY"));
3041 <  TH1F *RcorrJZBem       = systsamples.Draw("RcorrJZBem",var,binning, "JZB [GeV]", "events",cutmass&&cutOSOF&&reducedNJets&&ONLYTau&&kPos,mc,simulatedlumi,systsamples.FindSample("/DY"));
3042 <  TH1F *LcorrJZBem       = systsamples.Draw("LcorrJZBem",var,binning, "JZB [GeV]", "events",cutmass&&cutOSOF&&reducedNJets&&ONLYTau&&kNeg,mc,simulatedlumi,systsamples.FindSample("/DY"));
3039 >  TH1F *TAUhJZBpos = systsamples.Draw("TAUhJZBpos",var,binning, "JZB [GeV]", "events",cutmass&&cutOSSF&&reducedNJets&&ee_mm_tautau&&kPos,mc,simulatedlumi,systsamples.FindSample("/DY"));
3040 >  TH1F *LcorrJZBeemm     = systsamples.Draw("LcorrJZBeemm",var,binning, "JZB [GeV]", "events",cutmass&&cutOSSF&&reducedNJets&&ee_mm_tautau&&kNeg,mc,simulatedlumi,systsamples.FindSample("/DY"));
3041 >  TH1F *RcorrJZBem       = systsamples.Draw("RcorrJZBem",var,binning, "JZB [GeV]", "events",cutmass&&cutOSOF&&reducedNJets&&ee_mm_tautau&&kPos,mc,simulatedlumi,systsamples.FindSample("/DY"));
3042 >  TH1F *LcorrJZBem       = systsamples.Draw("LcorrJZBem",var,binning, "JZB [GeV]", "events",cutmass&&cutOSOF&&reducedNJets&&ee_mm_tautau&&kNeg,mc,simulatedlumi,systsamples.FindSample("/DY"));
3043  
3044    TH1F *RcorrJZBSBem;
3045    TH1F *LcorrJZBSBem;
3046    TH1F *RcorrJZBSBeemm;
3047    TH1F *LcorrJZBSBeemm;
3048  
3049 <  if(PlottingSetup::RestrictToMassPeak) {
3050 <    RcorrJZBSBem   = systsamples.Draw("RcorrJZBSBem",var,binning, "JZB [GeV]", "events",sidebandcut&&cutOSOF&&reducedNJets&&ONLYTau&&kPos,mc,simulatedlumi,systsamples.FindSample("/DY"));
3051 <    LcorrJZBSBem   = systsamples.Draw("LcorrJZBSBem",var,binning, "JZB [GeV]", "events",sidebandcut&&cutOSOF&&reducedNJets&&ONLYTau&&kNeg,mc,simulatedlumi,systsamples.FindSample("/DY"));
3052 <    RcorrJZBSBeemm = systsamples.Draw("RcorrJZBSBeemm",var,binning, "JZB [GeV]", "events",sidebandcut&&cutOSSF&&reducedNJets&&ONLYTau&&kPos,mc,simulatedlumi,systsamples.FindSample("/DY"));
3053 <    LcorrJZBSBeemm = systsamples.Draw("LcorrJZBSBeemm",var,binning, "JZB [GeV]", "events",sidebandcut&&cutOSSF&&reducedNJets&&ONLYTau&&kNeg,mc,simulatedlumi,systsamples.FindSample("/DY"));
3049 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
3050 >    RcorrJZBSBem   = systsamples.Draw("RcorrJZBSBem",var,binning, "JZB [GeV]", "events",sidebandcut&&cutOSOF&&reducedNJets&&ee_mm_tautau&&kPos,mc,simulatedlumi,systsamples.FindSample("/DY"));
3051 >    LcorrJZBSBem   = systsamples.Draw("LcorrJZBSBem",var,binning, "JZB [GeV]", "events",sidebandcut&&cutOSOF&&reducedNJets&&ee_mm_tautau&&kNeg,mc,simulatedlumi,systsamples.FindSample("/DY"));
3052 >    RcorrJZBSBeemm = systsamples.Draw("RcorrJZBSBeemm",var,binning, "JZB [GeV]", "events",sidebandcut&&cutOSSF&&reducedNJets&&ee_mm_tautau&&kPos,mc,simulatedlumi,systsamples.FindSample("/DY"));
3053 >    LcorrJZBSBeemm = systsamples.Draw("LcorrJZBSBeemm",var,binning, "JZB [GeV]", "events",sidebandcut&&cutOSSF&&reducedNJets&&ee_mm_tautau&&kNeg,mc,simulatedlumi,systsamples.FindSample("/DY"));
3054    }
3055    
3056    TH1F *Bpred = (TH1F*)LcorrJZBeemm->Clone("Bpred");
3057 <  if(PlottingSetup::RestrictToMassPeak) {
3057 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
3058      Bpred->Add(RcorrJZBem,1.0/3.);
3059      Bpred->Add(LcorrJZBem,-1.0/3.);
3060      Bpred->Add(RcorrJZBSBem,1.0/3.);
# Line 3060 | Line 3099 | void zjets_prediction_comparison(string
3099    center->Draw("same");
3100    bottom->Draw("same");
3101    
3102 <  TLegend *TAUleg2 = make_legend("MC Z+jets #rightarrow #tau#tau",0.25,0.75,false);
3102 >  TLegend *TAUleg2 = make_legend("MC Z+jets #rightarrow ee,#mu#mu",0.25,0.75,false);
3103    TAUleg2->AddEntry(TAUhratio,"obs / pred","pe");
3104    TAUleg2->AddEntry(bottom,"syst. envelope","l");
3105    TAUleg2->Draw("same");
# Line 3073 | Line 3112 | void zjets_prediction_comparison(string
3112    delete RcorrJZBem;
3113    delete LcorrJZBem;
3114    
3115 <  if(PlottingSetup::RestrictToMassPeak) {
3115 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
3116      delete RcorrJZBSBem;
3117      delete LcorrJZBSBem;
3118      delete RcorrJZBSBeemm;
# Line 3138 | Line 3177 | void make_table(samplecollection &coll,
3177      TH1F *RcorrJZBSBeemm;
3178      TH1F *LcorrJZBSBeemm;
3179      
3180 <    if(PlottingSetup::RestrictToMassPeak) {
3180 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
3181        RcorrJZBSBem   = coll.Draw("RcorrJZBSBem",jzbexpr.c_str(),nbins,low,14000, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity, mysample);
3182        LcorrJZBSBem   = coll.Draw("LcorrJZBSBem",("-("+jzbexpr+")").c_str(),nbins,low,14000, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity, mysample);
3183        RcorrJZBSBeemm = coll.Draw("RcorrJZBSBeemm",jzbexpr.c_str(),nbins,low,14000, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity, mysample);
# Line 3146 | Line 3185 | void make_table(samplecollection &coll,
3185      }
3186      
3187      TH1F *Bpred = (TH1F*)LcorrJZBeemm->Clone("Bpred");
3188 <    if(PlottingSetup::RestrictToMassPeak) {
3188 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
3189        Bpred->Add(RcorrJZBem,1.0/3.);
3190        Bpred->Add(LcorrJZBem,-1.0/3.);
3191        Bpred->Add(RcorrJZBSBem,1.0/3.);
# Line 3357 | Line 3396 | void qcd_plots(string datajzb, string mc
3396    TH1F *JRcorrJZBSBeemm;
3397    TH1F *JLcorrJZBSBeemm;
3398    
3399 <  if(PlottingSetup::RestrictToMassPeak) {
3399 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
3400      RcorrJZBSBem   = qcdsamples.Draw("RcorrJZBSBem",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
3401      LcorrJZBSBem   = qcdsamples.Draw("LcorrJZBSBem",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
3402      RcorrJZBSBeemm = qcdsamples.Draw("RcorrJZBSBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
# Line 3378 | Line 3417 | void qcd_plots(string datajzb, string mc
3417      
3418    TH1F *Bpred = (TH1F*)LcorrJZBeemm->Clone("Bpred");
3419    TH1F *JBpred = (TH1F*)JLcorrJZBeemm->Clone("Bpred");
3420 <  if(PlottingSetup::RestrictToMassPeak) {
3420 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
3421      Bpred->Add(RcorrJZBem,1.0/3.);
3422      Bpred->Add(LcorrJZBem,-1.0/3.);
3423      Bpred->Add(RcorrJZBSBem,1.0/3.);
# Line 3448 | Line 3487 | void qcd_plots(string datajzb, string mc
3487    dout << "______________________________________________" << endl;
3488    dout << "How QCD shows up in the different regions: " << endl;
3489    dout << "OSSF: " << endl;
3490 <  if(PlottingSetup::RestrictToMassPeak) {
3490 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
3491      dout << "     Z window: \t" << RcorrJZBeemm->Integral() << " (JZB>0) , " << LcorrJZBeemm->Integral() << " (JZB<0) --> total: " << RcorrJZBeemm->Integral() + LcorrJZBeemm->Integral() << endl;
3492      dout << "     sideband: \t" << RcorrJZBSBeemm->Integral() << " (JZB>0) , " << LcorrJZBSBeemm->Integral() << " (JZB<0) --> total: " << RcorrJZBSBeemm->Integral() + LcorrJZBSBeemm->Integral() << endl;
3493    } else {
3494      dout << "     " << RcorrJZBeemm->Integral() << " (JZB>0) , " << LcorrJZBeemm->Integral() << " (JZB<0) --> total: " << RcorrJZBeemm->Integral() + LcorrJZBeemm->Integral() << endl;
3495    }
3496    dout << "OSOF: " << endl;
3497 <  if(PlottingSetup::RestrictToMassPeak) {
3497 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
3498      dout << "     Z window: \t" << RcorrJZBem->Integral() << " (JZB>0) , " << LcorrJZBem->Integral() << " (JZB<0) --> total: " << RcorrJZBem->Integral() + LcorrJZBem->Integral() << endl;
3499      dout << "     sideband: \t" << RcorrJZBSBem->Integral() << " (JZB>0) , " << LcorrJZBSBem->Integral() << " (JZB<0) --> total: " << RcorrJZBSBem->Integral() + LcorrJZBSBem->Integral() << endl;
3500    } else {
3501      dout << "     Z window: \t" << RcorrJZBem->Integral() << " (JZB>0) , " << LcorrJZBem->Integral() << " (JZB<0) --> total: " << RcorrJZBem->Integral() + LcorrJZBem->Integral() << endl;
3502    }
3503    dout << "Therefore: " << endl;
3504 <  if(PlottingSetup::RestrictToMassPeak) {
3504 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
3505      dout << "    Prediction increases by : " << LcorrJZBeemm->Integral() << " + (1.0/3)*(" << RcorrJZBSBeemm->Integral() <<"-"<< LcorrJZBSBeemm->Integral() << ") (SFSB) ";
3506      dout << " + (1.0/3)*(" << RcorrJZBem->Integral() <<"-"<< LcorrJZBem->Integral() << ") (OFZP) ";
3507      dout << " + (1.0/3)*(" << RcorrJZBSBem->Integral() <<"-"<< LcorrJZBSBem->Integral() << ") (OFSB) ";
# Line 3478 | Line 3517 | void qcd_plots(string datajzb, string mc
3517    for(int i=0;i<(int)bins.size();i++) {
3518      dout << " JZB > " << bins[i] << " : " << endl;
3519      dout << "    Observation increases by : " << RcorrJZBeemm->Integral(RcorrJZBeemm->FindBin(bins[i]),RcorrJZBeemm->GetNbinsX()) << endl;
3520 <    if(PlottingSetup::RestrictToMassPeak) {
3520 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
3521          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;
3522      } else {
3523          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 3492 | Line 3531 | void qcd_plots(string datajzb, string mc
3531    if(LcorrJZBem) delete LcorrJZBem;
3532    if(RcorrJZBeemm) delete RcorrJZBeemm;
3533    if(LcorrJZBeemm) delete LcorrJZBeemm;
3534 <  if(PlottingSetup::RestrictToMassPeak&&RcorrJZBSBem) delete RcorrJZBSBem;
3535 <  if(PlottingSetup::RestrictToMassPeak&&LcorrJZBSBem) delete LcorrJZBSBem;
3536 <  if(PlottingSetup::RestrictToMassPeak&&RcorrJZBSBeemm) delete RcorrJZBSBeemm;
3537 <  if(PlottingSetup::RestrictToMassPeak&&LcorrJZBSBeemm) delete LcorrJZBSBeemm;
3534 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB&&RcorrJZBSBem) delete RcorrJZBSBem;
3535 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB&&LcorrJZBSBem) delete LcorrJZBSBem;
3536 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB&&RcorrJZBSBeemm) delete RcorrJZBSBeemm;
3537 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB&&LcorrJZBSBeemm) delete LcorrJZBSBeemm;
3538   }
3539  
3540   void check_ptsanity() {
# Line 3601 | Line 3640 | void met_vs_jzb_plots(string datajzb, st
3640    findme.push_back("DY");
3641    findme.push_back("TTJets");
3642    findme.push_back("LM");
3643 <  
3643 >  /*
3644    for(int ifind=0;ifind<(int)findme.size();ifind++) {
3645      vector<int> selsamples = allsamples.FindSample(findme[ifind]);
3646      TH2F *metvsjzb = new TH2F("metvsjzb","metvsjzb",200,0,100,400,-100,100);
# Line 3621 | Line 3660 | void met_vs_jzb_plots(string datajzb, st
3660      title->Draw();
3661      CompleteSave(canmetjzb,(string)"METvsJZBplots/"+findme[ifind]);
3662    }
3663 <  
3663 >  */
3664    
3665    dout << "About to produce MET plot for DY split up by JZB" << endl;
3666    
# Line 3641 | Line 3680 | void met_vs_jzb_plots(string datajzb, st
3680    TH1F *metright  = allsamples.Draw("metright","met[4]",nbins,low,high, "MET [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&RIGHT,mc, luminosity, allsamples.FindSample("DYJets"));
3681    TH1F *metrightO = allsamples.Draw("metrightO","met[4]",nbins,low,high, "MET [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&RIGHT,mc, luminosity, allsamples.FindSample("DYJets"));
3682    
3683 +  
3684 +  TH1F *Bpred =  (TH1F*)metleft->Clone("Bpred");
3685 +  Bpred->Add(metleftO,-1);
3686 +  Bpred->Add(metrightO);
3687 +  TH1F *obs = (TH1F*)metright->Clone("obs");
3688 +  
3689    metleft->Add(metleftO,-1);
3690    metright->Add(metrightO,-1);
3691    
# Line 3653 | Line 3698 | void met_vs_jzb_plots(string datajzb, st
3698    metright->Draw("same");
3699    TLegend *lg = make_legend();
3700    lg->SetX1(0.5);
3701 +  lg->SetY1(0.7);
3702    lg->AddEntry(metright,"JZB>0 (OSOF corrected)","P");
3703    lg->AddEntry(metleft,"JZB<0 (OSOF corrected)","L");
3704 +  lg->SetHeader("DY");
3705 +  
3706    lg->Draw();
3707    save_with_ratio(metright,metleft,metpad->cd(),"METvsJZBplots/ComparingLeftToRightinMETspectrum");
3708 +  
3709 +  TPad *metpad3 = new TPad("metpad3","metpad3",0,0,1,1);
3710 +  metpad3->cd();
3711 +  metpad3->SetLogy(1);
3712 +  Bpred->SetLineColor(kRed);
3713 +  Bpred->Draw("histo");
3714 +  obs->SetLineColor(kBlack);
3715 +  obs->Draw("same");
3716 +  TLegend *lg2 = make_legend();
3717 +  lg2->SetX1(0.5);
3718 +  lg2->SetY1(0.7);
3719 +  lg2->AddEntry(obs,"observed","P");
3720 +  lg2->AddEntry(Bpred,"predicted","L");
3721 +  lg2->SetHeader("DY");
3722 +
3723 +  lg2->Draw();
3724 +  
3725 +  save_with_ratio(obs,Bpred,metpad3->cd(),"METvsJZBplots/ComparingPredObsinMET");
3726 +  
3727    TPad *metpad2 = new TPad("metpad2","metpad2",0,0,1,1);
3728 +  metpad2->cd();
3729 +  metpad2->SetLogy(1);
3730    
3731    TH1F *metlefta   = allsamples.Draw("metlefta","met[2]",nbins,low,high, "MET [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&LEFT,mc, luminosity, allsamples.FindSample("DYJets"));
3732    TH1F *metleftOa  = allsamples.Draw("metleftOa","met[2]",nbins,low,high, "MET [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&LEFT,mc, luminosity, allsamples.FindSample("DYJets"));
3733    TH1F *metrighta  = allsamples.Draw("metrighta","met[2]",nbins,low,high, "MET [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&RIGHT,mc, luminosity, allsamples.FindSample("DYJets"));
3734    TH1F *metrightOa = allsamples.Draw("metrightOa","met[2]",nbins,low,high, "MET [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&RIGHT,mc, luminosity, allsamples.FindSample("DYJets"));
3735    
3667  TH1F *Bpred =  (TH1F*)metlefta->Clone("Bpred");
3668  Bpred->Add(metleftOa,-1);
3669  Bpred->Add(metrightOa);
3670  TH1F *obs = (TH1F*)metrighta->Clone("obs");
3671  
3736    metlefta->Add(metleftOa,-1);
3737    metrighta->Add(metrightOa,-1);
3738    
# Line 3679 | Line 3743 | void met_vs_jzb_plots(string datajzb, st
3743    lg->Draw();
3744    save_with_ratio(metrighta,metlefta,metpad2->cd(),"METvsJZBplots/ComparingLeftToRightinMET_type1_spectrum");
3745    
3746 <  TPad *metpad3 = new TPad("metpad3","metpad3",0,0,1,1);
3747 <  metpad3->cd();
3748 <  Bpred->SetLineColor(kRed);
3749 <  Bpred->Draw("histo");
3750 <  obs->SetLineColor(kBlack);
3751 <  obs->Draw("same");
3752 <  TLegend *lg2 = make_legend();
3753 <  lg2->SetX1(0.5);
3754 <  lg2->AddEntry(obs,"observed","P");
3755 <  lg2->AddEntry(Bpred,"predicted","L");
3756 <  lg2->Draw();
3746 >  delete Bpred;
3747 >  delete obs;
3748 >  
3749 >  float newhigh=300;
3750 >  int newNBins=30;
3751 >  
3752 >  TPad *metpad4 = new TPad("metpad4","metpad4",0,0,1,1);
3753 >  TH1F *Ametleft   = allsamples.Draw("Ametleft","met[4]",newNBins,low,newhigh, "MET [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&LEFT,mc, luminosity);
3754 >  TH1F *AmetleftO  = allsamples.Draw("AmetleftO","met[4]",newNBins,low,newhigh, "MET [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&LEFT,mc, luminosity);
3755 >  TH1F *Ametright  = allsamples.Draw("Ametright","met[4]",newNBins,low,newhigh, "MET [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&RIGHT,mc, luminosity);
3756 >  TH1F *AmetrightO = allsamples.Draw("AmetrightO","met[4]",newNBins,low,newhigh, "MET [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&RIGHT,mc, luminosity);
3757 >  
3758 >  TH1F *aBpred = (TH1F*)Ametleft->Clone("aBpred");
3759 >  aBpred->Add(AmetleftO,-1);
3760 >  aBpred->Add(AmetrightO);
3761 >  aBpred->SetLineColor(kRed);
3762 >  
3763 >  TH1F *aobs = (TH1F*)Ametright->Clone("aobs");
3764 >  metpad4->cd();
3765 >  metpad4->SetLogy(1);
3766 >  aobs->Draw();
3767 >  aBpred->Draw("histo,same");
3768 >  aobs->Draw("same");
3769 >  lg->SetHeader("All MC");
3770 >  lg->Draw();
3771 >  save_with_ratio(aobs,aBpred,metpad4->cd(),"METvsJZBplots/ComparingPredObsinMET_ALLSAMPLES");
3772 >  
3773    
3694  save_with_ratio(obs,Bpred,metpad3->cd(),"METvsJZBplots/ComparingPredObsinMET_type1_spectrum");
3774    delete lg;
3775    delete canmetjzb;
3776    delete metleft;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines