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.42 by fronga, Thu Jul 26 11:18:37 2012 UTC vs.
Revision 1.55 by fronga, Wed Sep 5 16:32:51 2012 UTC

# Line 86 | Line 86 | void find_one_peak_combination(TCut spec
86  
87   void find_peaks(float &MCPeak,float &MCPeakError, float &DataPeak, float &DataPeakError, stringstream &result, bool doPUreweighting, stringstream &datajzb, stringstream &mcjzb)
88   {
89 <  
89 >  switch_overunderflow(false);
90 >
91    bool DoInvidualeemmPeaks=false;
92    
93    float mcpeak, datapeak;
# Line 148 | Line 149 | void find_peaks(float &MCPeak,float &MCP
149      mcjzb << ")";
150    }
151    
152 +  switch_overunderflow(true);
153    
154   }
155  
# Line 188 | Line 190 | void make_special_obs_pred_mll_plot(stri
190    
191   //  TH1F *RcorrJZBeemmNoS;
192  
193 <  if(PlottingSetup::RestrictToMassPeak) {
193 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
194      RcorrJZBSBem   = allsamples.Draw("RcorrJZBSBem",  "mll",nbins,min,max, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets&&largerzeroD,data, luminosity);
195      LcorrJZBSBem   = allsamples.Draw("LcorrJZBSBem",  "mll",nbins,min,max, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets&&smallerzeroD,data, luminosity);
196      RcorrJZBSBeemm = allsamples.Draw("RcorrJZBSBeemm","mll",nbins,min,max, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets&&largerzeroD,data, luminosity);
# Line 196 | Line 198 | void make_special_obs_pred_mll_plot(stri
198    }
199    
200    // Separate predictions
201 <  TH1F* Zpred = (TH1F*)LcorrJZBeemm->Clone("Zpred");
202 <  TH1F* OSpred = (TH1F*)RcorrJZBem->Clone("OSpred");
203 <  if(PlottingSetup::RestrictToMassPeak) {
204 <    OSpred->Scale(1.0/3.0);
205 <    OSpred->Add(RcorrJZBSBem,1.0/3.);
206 <    OSpred->Add(RcorrJZBSBeemm,1.0/3.);
207 <    Zpred->Add(LcorrJZBem,-1.0/3.);
208 <    Zpred->Add(LcorrJZBSBem,-1.0/3.);
209 <    Zpred->Add(LcorrJZBSBeemm,-1.0/3.);
210 <  } else {
211 <    Zpred->Add(LcorrJZBem,-1.0);
212 <  }
213 <
214 <  TH1F* Bpred = (TH1F*)Zpred->Clone("Bpred");
215 <  Bpred->Add(OSpred);
201 >  TH1F* SFN = (TH1F*)LcorrJZBeemm->Clone("SFN");
202 >  TH1F* OFP = (TH1F*)RcorrJZBem->Clone("OFP");
203 >  TH1F* OFN = (TH1F*)LcorrJZBem->Clone("OFN");
204 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
205 >    OFP->Scale(1.0/3.0);
206 >    OFP->Add(RcorrJZBSBem,1.0/3.);
207 >    OFP->Add(RcorrJZBSBeemm,1.0/3.);
208 >    OFN->Scale(1.0/3.0);
209 >    OFN->Add(LcorrJZBSBem,1.0/3.);
210 >    OFN->Add(LcorrJZBSBeemm,1.0/3.);
211 >  }
212 >
213 >  TH1F* Bpred = (TH1F*)SFN->Clone("Bpred");
214 >  Bpred->Add(OFP);
215 >  Bpred->Add(OFN,-1);
216    Bpred->SetLineColor(kRed);
217    
216  // Problem with negative bins: add contents to OSpred
217  for ( unsigned int i=0; i<=Zpred->GetNbinsX(); ++i ) {
218    if ( Zpred->GetBinContent(i)<0 ) {
219      OSpred->SetBinContent(i,OSpred->GetBinContent(i)+Zpred->GetBinContent(i));
220      Zpred->SetBinContent(i,0);
221    }
222  }
223
218    RcorrJZBeemm->SetTitleOffset(1.3,"y");
219    RcorrJZBeemm->Draw();
220    mcRcorrJZBeemm.Draw("same");
# Line 238 | Line 232 | void make_special_obs_pred_mll_plot(stri
232    CompleteSave(ckin,saveas.str());
233    
234    // Draw all predictions overlayed
235 <  Zpred->SetLineColor(kGreen+1);
236 <  Zpred->SetLineStyle(2);
237 <  OSpred->SetLineColor(kBlue-2);
238 <  OSpred->SetLineStyle(3);
235 >  unsigned int w = gStyle->GetHistLineWidth()+1; // Make line a bit wider, since we dash it
236 >  SFN->SetLineColor(kGreen+2);
237 >  SFN->SetLineStyle(2);
238 >  SFN->SetLineWidth(w);
239 >  OFP->SetLineColor(kBlue+2);
240 >  OFP->SetLineStyle(2);
241 >  OFP->SetLineWidth(w);
242 >  OFN->SetLineColor(kMagenta+2);
243 >  OFN->SetLineStyle(3);
244 >  OFN->SetLineWidth(w);
245    
246    RcorrJZBeemm->Draw();
247 <  OSpred->Draw("histo,same");
248 <  Zpred->Draw("histo,same");
247 >  SFN->Draw("histo,same");
248 >  OFP->Draw("histo,same");
249 >  OFN->Draw("histo,same");
250    Bpred->Draw("histo,same");
251    RcorrJZBeemm->Draw("same");
252    
253    TLegend *leg2 = make_legend("",0.52,0.7);
254    leg2->AddEntry(RcorrJZBeemm,"observed (data)","lp");
255    leg2->AddEntry(Bpred,"predicted (data)","l");
256 <  leg2->AddEntry(Zpred, "  bkgd w/Z (data)","l");
257 <  leg2->AddEntry(OSpred,"  bkgd w/o Z (data)","l");
256 >  leg2->AddEntry(SFN,  "  SF JZB<0","l");
257 >  leg2->AddEntry(OFN,  "  OF JZB<0","l");
258 >  leg2->AddEntry(OFP,  "  OF JZB>0","l");
259    leg2->Draw("same");
260    
261    saveas.str("");
262    saveas << "kin/Mll_After_Cut/Cut_At" << jzbthreshold << "_nomc";
263    CompleteSave(ckin,saveas.str());
264    
263  
264
265    delete RcorrJZBeemm;
266    delete LcorrJZBeemm;
267    delete RcorrJZBem;
268    delete LcorrJZBem;
269 <  if(PlottingSetup::RestrictToMassPeak) {
269 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
270      delete RcorrJZBSBeemm;
271      delete LcorrJZBSBeemm;
272      delete RcorrJZBSBem;
# Line 360 | Line 360 | void draw_ratio_plot(TH1* hdata, THStack
360    oneline->Draw("same");
361   }
362  
363 + float make_one_OFSF_plot(string variable, string addcut, string legendTitle, int nbins, float min, float max, float ymax, bool logscale,
364 +                        string xlabel, string filename, bool plotratio=true, bool loadlastminmax=false, float legendPosition=0.55) {
365 +
366 +  TCut ibasiccut=basiccut;
367 +  bool draw_separation_lines=false;
368 +
369 +  if(addcut != "") ibasiccut = ibasiccut && addcut.c_str();
370 +
371 +  TCut cutSF;
372 +  TCut cutOF;
373 +
374 +  cutOF = cutOSOF&&cutnJets&&ibasiccut;
375 +  cutSF = cutOSSF&&cutnJets&&ibasiccut;
376 +
377 +  TCanvas *ckin = new TCanvas("ckin","Kinematic Plots (in the making)",600,600);
378 +  TPad* rcan = new TPad("rcan","rcan",0,0,1,1);
379 +  rcan->SetLogy(logscale);
380 +  rcan->cd();
381 +
382 +  TH1F *datahistoSF = allsamples.Draw("datahistoSF",variable,nbins,min,max, xlabel, "events",cutSF,data,luminosity);
383 +  TH1F *datahistoOF = allsamples.Draw("datahistoOF",variable,nbins,min,max, xlabel, "events",cutOF,data,luminosity);
384 +  string signal("LM3");
385 +  TH1F* signalhisto = new TH1F("signalhisto",signal.c_str(),nbins,min,max);
386 +  int idx = signalsamples.FindSample(signal)[0];
387 +  (signalsamples.collection)[idx].events->Project("signalhisto",variable.c_str(),cutSF);
388 +  signalhisto->Scale((signalsamples.collection)[idx].weight*luminosity);
389 +  signalhisto->SetLineColor((signalsamples.collection)[idx].samplecolor);
390 +  signalhisto->SetLineStyle(2);
391 +  datahistoSF->SetMarkerSize(DataMarkerSize);
392 +  datahistoOF->SetLineColor(kRed);
393 +
394 +  if ( !logscale ) {
395 +    datahistoSF->SetMinimum(0); // Defaults
396 +  } else {
397 +    datahistoSF->SetMinimum(0.5);
398 +  }
399 +  if (ymax<0) {
400 +    if ( logscale ) datahistoSF->SetMaximum(5.3*datahistoSF->GetMaximum());
401 +    else datahistoSF->SetMaximum(1.5*datahistoSF->GetMaximum());
402 +  } else {
403 +    datahistoSF->SetMaximum(ymax);
404 +  }
405 +
406 +  float ymaxSet = datahistoSF->GetMaximum();
407 +
408 +  datahistoSF->GetXaxis()->SetTitle(xlabel.c_str());
409 +  datahistoSF->GetYaxis()->SetTitle("Events");
410 +  datahistoSF->GetXaxis()->CenterTitle();
411 +  datahistoSF->GetYaxis()->CenterTitle();
412 +
413 +  TLegend *mleg = make_legend(legendTitle.c_str(),legendPosition,0.7,false,legendPosition+0.2);
414 +  mleg->AddEntry(datahistoSF, "Same-flavor", "PL");
415 +  if (datahistoOF->Integral()>0) {
416 +    mleg->AddEntry(datahistoOF, "Opposite-flavor", "L");
417 +  } else {
418 +    mleg->AddEntry((TObject*)0, "", "");
419 +  }
420 +  mleg->AddEntry(signalhisto, "LM3", "L");
421 +
422 +  datahistoSF->Draw("E1");
423 +  if (datahistoOF->Integral()>0) datahistoOF->Draw("HIST,SAMES");
424 +  signalhisto->Draw("HIST,SAMES");
425 +  mleg->Draw();
426 +  DrawPrelim();
427 +  if (datahistoOF->Integral()>0) save_with_ratio( datahistoSF, datahistoOF, rcan, "SFOF/" + filename, false, false, "SF/OF" );
428 +  else CompleteSave(ckin, "SFOF/" + filename);
429 +
430 +  datahistoSF->Delete();
431 +  datahistoOF->Delete();
432 +  signalhisto->Delete();
433 +  delete mleg;
434 +  delete ckin;
435 +
436 +  return ymaxSet;
437 +
438 + }
439 +
440 + // Compare data to data
441 + float make_data_comparison_plot(string variable, TCut cut, int nbins, float min, float max, float ymax, bool logscale,
442 +                                string xlabel, string filename, float legendPosition=0.55) {
443 +
444 +  TCut ibasiccut=basiccut&&cut;
445 +
446 +  TCanvas *ckin = new TCanvas("ckin","Kinematic Plots (in the making)",600,600);
447 +  TPad* rcan = new TPad("rcan","rcan",0,0,1,1);
448 +  rcan->SetLogy(logscale);
449 +  rcan->cd();
450 +
451 +  std::cout << "Data comparison: variable = " << variable << ", cut = " << ibasiccut.GetTitle() << std::endl;
452 +
453 +  TH1F *data1 = allsamples.Draw("data1",variable,nbins,min,max, xlabel, "events",ibasiccut,data,luminosity);
454 +  TH1F *data2 = comparesamples.Draw("data2",variable,nbins,min,max, xlabel, "events",ibasiccut,data,luminosity);
455 +
456 +  data1->SetMarkerSize(DataMarkerSize);
457 +  data2->SetLineColor(kRed);
458 +
459 +  if ( !logscale ) {
460 +    data1->SetMinimum(0); // Defaults
461 +  } else {
462 +    data1->SetMinimum(0.5);
463 +  }
464 +  if (ymax<0) {
465 +    if ( logscale ) data1->SetMaximum(5.3*data1->GetMaximum());
466 +    else data1->SetMaximum(1.5*data1->GetMaximum());
467 +  } else {
468 +    data1->SetMaximum(ymax);
469 +  }
470 +
471 +  float ymaxSet = data1->GetMaximum();
472 +
473 +  data1->GetXaxis()->SetTitle(xlabel.c_str());
474 +  data1->GetYaxis()->SetTitle("Events");
475 +  data1->GetXaxis()->CenterTitle();
476 +  data1->GetYaxis()->CenterTitle();
477 +
478 +  TLegend *mleg = make_legend("",legendPosition,0.7,false,legendPosition+0.2);
479 +  mleg->AddEntry(data1, "Old 5/fb", "PL");
480 +  mleg->AddEntry(data2, "New x/fb", "L");
481 +
482 +  data1->Draw("E1");
483 +  data2->Draw("HIST,SAMES");
484 +  mleg->Draw();
485 +  DrawPrelim();
486 +  save_with_ratio( data1, data2, rcan, "compareData/" + filename, false, false, "old/new" );
487 +
488 +  data1->Delete();
489 +  data2->Delete();
490 +  delete mleg;
491 +  delete ckin;
492 +
493 + }
494 +
495 + void make_OFSF_plots(string variable, string addcut, int nbins, float min, float max, bool logscale,
496 +                     string xlabel, string filename, float legendPosition=0.55) {
497 +
498 +  string mllcuts[] = { "mll>20","mll>20&&mll<70", "mll>75&&mll<105", "mll>120" };
499 +  string mllcutname[] = { "m_{ll} > 20 GeV", "20 < m_{ll} < 70 GeV", "75 < m_{ll} < 105 GeV", "m_{ll} > 120 GeV" };
500 +  string plotname[] = {"_all","_low","_peak","_high"};
501 +  float ymax;
502 +
503 +  int start = 0;
504 +  if ( !PlottingSetup::openBox ) start = 3;
505 +
506 +  for ( int i=start; i<4; ++i ) {
507 +    if ( addcut != "" ) mllcuts[i] += "&&"+addcut;
508 +    if ( i==start ) {
509 +      ymax = make_one_OFSF_plot(variable, mllcuts[i],            mllcutname[i], nbins, min, max, -1, logscale, xlabel,
510 +                         filename+plotname[i], legendPosition );
511 +    } else {
512 +      make_one_OFSF_plot(variable, mllcuts[i],            mllcutname[i], nbins, min, max, ymax, logscale, xlabel,
513 +                         filename+plotname[i], legendPosition );
514 +    }
515 +    make_one_OFSF_plot(variable, "id1==1&&id1==id2&&"+mllcuts[i], mllcutname[i], nbins, min, max, ymax, logscale, xlabel,
516 +                       filename+plotname[i]+"_mm", legendPosition );
517 +    make_one_OFSF_plot(variable, "id1==0&&id1==id2&&"+mllcuts[i], mllcutname[i], nbins, min, max, ymax, logscale, xlabel,
518 +                       filename+plotname[i]+"_ee", legendPosition );
519 +  }
520 +
521 + }
522 +
523 +
524   float lastrange_min=0;
525   float lastrange_max=0;
526  
# Line 389 | Line 550 | void make_kin_plot(string variable, stri
550    //Step 2: Refine the cut
551    TCut cut;
552    cut=cutmass&&cutOSSF&&cutnJets&&ibasiccut;
553 <  if(filename=="nJets") cut=cutmass&&cutOSSF&&ibasiccut;
554 <  if(filename=="nJets_osof") cut=cutmass&&cutOSOF&&ibasiccut;
553 >  if(filename=="nJets" || filename=="nJets_inclusive") cut=cutmass&&cutOSSF&&ibasiccut;
554 >  if(filename=="nJets_osof" || filename=="nJets_osof_inclusive") cut=cutmass&&cutOSOF&&ibasiccut;
555    if(filename=="nJets_nocuts_except_mll_ossf") cut=cutmass&&cutOSSF;
556    if(filename=="mll") {
557          cut=cutOSSF&&cutnJets&&ibasiccut;
558          draw_separation_lines=true;
559    }
560    if(filename=="mll_ee") cut=cutOSSF&&cutnJets&&ibasiccut&&"id1==0";
561 +  if(filename=="mll_mm") cut=cutOSSF&&cutnJets&&ibasiccut&&"id1==1";
562    if(filename=="mll_osof") {
563          cut=cutOSOF&&cutnJets&&ibasiccut;
564          draw_separation_lines=true;
565    }
404  if(filename=="mll_mm") cut=cutOSSF&&cutnJets&&ibasiccut&&"id1==1";
566    if(Contains(filename,"aboveJZB")) cut=cutOSSF&&cutnJets&&ibasiccut;
567    if(Contains(filename,"mll_ee_above")) cut=cut&&"id1==0";
568    if(Contains(filename,"mll_mm_above")) cut=cut&&"id1==1";
569    if(Contains(filename,"mll_osof_aboveJZB")) cut=cutOSOF&&cutnJets&&ibasiccut;
570 <  if(filename=="mll_inclusive"||filename=="mll_inclusive_highrange") cut=cutOSSF;
571 <  if(filename=="mll_inclusive_osof") cut=cutOSOF;
572 <  if(filename=="mll_inclusive_ee") cut=cutOSSF&&"id1==0";
573 <  if(filename=="mll_inclusive_mm") cut=cutOSSF&&"id1==1";
570 >  if(filename=="mll_inclusive"||filename=="mll_inclusive_highrange") cut=cutmass&&cutOSSF;
571 >  if(filename=="mll_inclusive_osof") cut=cutmass&&cutOSOF;
572 >  if(filename=="mll_inclusive_ee") cut=cutmass&&cutOSSF&&"id1==0";
573 >  if(filename=="mll_inclusive_mm") cut=cutmass&&cutOSSF&&"id1==1";
574    if(filename=="pfJetGoodEta_0") cut=cutOSSF&&cutmass&&ibasiccut&&cutnJets;
575    if(filename=="pfJetGoodPt_0") cut=cutOSSF&&cutmass&&ibasiccut&&cutnJets;
576 +  if(filename=="numVtx") cut=cutmass&&ibasiccut;
577  
578    TCanvas *ckin = new TCanvas("ckin","Kinematic Plots (in the making)",600,600);
579    ckin->SetLogy(logscale);
# Line 429 | Line 591 | void make_kin_plot(string variable, stri
591    if (logscale) datahisto->SetMaximum(5.3*datahisto->GetMaximum());
592    else datahisto->SetMaximum(1.3*datahisto->GetMaximum());
593  
594 +  cout << "******** Cut used : " << (const char*) cut << endl;
595    if(loadlastminmax) {
596          datahisto->SetMinimum(lastrange_min);
597          datahisto->SetMaximum(lastrange_max);
# Line 568 | Line 731 | void do_kinematic_plots(string mcjzb, st
731   {
732    bool dolog=true;
733    bool nolog=false;
734 +
735 +  bool doOFSF = false;
736 +  bool doKin  = false;
737 +  bool doDataComp = true;
738 +  
739 +
740    if(doPF) write_warning(__FUNCTION__,"Please use caution when trying to produce PF plots; not all versions of the JZB trees have these variables!");
741    float mll_low=50;
742    float mll_hi=160;
743    if(!PlottingSetup::RestrictToMassPeak) {
744          mll_low=20;
745 <        mll_hi=300;
745 >        mll_hi=320;
746    }
747  
748 <  make_kin_plot("met[4]","",70,0,350,dolog,"MET [GeV]","met",doPF,true);
748 >  if ( doOFSF ) {
749 >    make_OFSF_plots("mll", "met[4]>100", 60, 20., 320., false, "m_{ll}", "mll");
750  
751 <  make_kin_plot("mll","",(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll",doPF,true);
752 <  make_kin_plot("mll","",(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_osof",doPF,true,true);
753 <  make_kin_plot("mll","",(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_ee",doPF,true);
754 <  make_kin_plot("mll","",(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_mm",doPF,true);
755 <  make_kin_plot("mll","",(int)((mll_hi-mll_low))/5,mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive",doPF,true);
756 <  make_kin_plot("mll","",(int)((mll_hi-mll_low))/5,mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_ee",doPF,true);
757 <  make_kin_plot("mll","",(int)((mll_hi-mll_low))/5,mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_mm",doPF,true);
758 <  make_kin_plot("mll","",(int)((mll_hi-mll_low))/5,mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_osof",doPF,true);
759 <  make_kin_plot("mll","",(int)((350-mll_low))/5,mll_low,350,dolog,"m_{ll} [GeV]","mll_inclusive_highrange",doPF);
760 <  if(!doPF) make_special_mll_plot((int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]");
761 <
762 <  make_kin_plot("pfJetGoodPt[0]/pfJetGoodPt[1]","",45,1,10,dolog,"pt_{j}^{1}/pt_{j}^{2}","j1j2ratio",doPF,true);
763 <  make_kin_plot("TMath::Abs(pfJetDphiMet[0])","",32,0,3.2,nolog,"|#Delta#phi(jet1,MET)|","dphiJ1MET",doPF,true);
764 <
765 <  make_kin_plot("pfJetGoodNum40","",9,-0.5,8.5,dolog,"nJets","nJets",doPF);
766 <  make_kin_plot("pfJetGoodNum40","",9,-0.5,8.5,dolog,"nJets","nJets_osof",doPF);
767 <  make_kin_plot("pfJetGoodNum40","",9,-0.5,8.5,dolog,"nJets","nJets_nocuts_except_mll_ossf",doPF);
768 <
769 <  make_kin_plot("numVtx","",(int)(30.5-(-0.5)),-0.5,30.5,nolog,"N(Vtx)","numVtx",doPF);
770 < //  make_kin_plot("jetpt[0]","",40,0,200,dolog,"leading jet p_{T} [GeV]","pfJetGoodPt_0",doPF);
771 < //  make_kin_plot("jeteta[0]","",40,-5,5,nolog,"leading jet #eta","pfJetGoodEta_0",doPF);
772 <  make_kin_plot("pt","",50,0,500,dolog,"Z p_{T} [GeV]","Zpt",doPF);
773 <  make_kin_plot("pt1","",50,0,200,nolog,"p_{T} [GeV]","pt1",doPF);
774 <  make_kin_plot("pt2","",50,0,200,nolog,"p_{T} [GeV]","pt2",doPF);
775 <  make_kin_plot("eta1","",40,-3,3,nolog,"#eta_{l}","eta",doPF);
776 <  make_kin_plot("jzb[1]","",100,-150,200,dolog,"JZB [GeV]","jzb_ossf",doPF);
777 <  stringstream jzbcut;
778 <  jzbcut << "((is_data&&("<<datajzb<<")>100)||(!is_data&&("<<mcjzb<<")>100))";
779 <  make_kin_plot("mll",jzbcut.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV]","mll_aboveJZB100",doPF,true);
780 <  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);
781 <  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);
782 <  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);
783 <  stringstream jzbcut2;
784 <  jzbcut2 << "((is_data&&("<<datajzb<<")>150)||(!is_data&&("<<mcjzb<<")>150))";
785 <  make_kin_plot("mll",jzbcut2.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV]","mll_aboveJZB150",doPF,true);
786 <  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);
787 <  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);
788 <  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);
789 <  stringstream jzbcut3;
790 <  jzbcut3 << "((is_data&&("<<datajzb<<")>50)||(!is_data&&("<<mcjzb<<")>50))";
791 <  make_kin_plot("mll",jzbcut3.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV]","mll_aboveJZB50",doPF,true);  
792 <  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);
793 <  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);  
794 <  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);  
795 <
796 <  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);
797 <
798 <  make_special_obs_pred_mll_plot(datajzb,mcjzb,0);
799 <  make_special_obs_pred_mll_plot(datajzb,mcjzb,50);
800 <  make_special_obs_pred_mll_plot(datajzb,mcjzb,80);
801 <  make_special_obs_pred_mll_plot(datajzb,mcjzb,100);
751 >    make_OFSF_plots("pfJetGoodNum40",     "met[4]>100", 7, 3, 10, true, "#(jets)", "njets");
752 >    make_OFSF_plots("pfJetGoodNum40",     "met[4]>100&&pfJetGoodNumBtag30==0", 7, 3, 10, true, "#(jets)", "njets_btagVeto");
753 >    make_OFSF_plots("pfJetGoodNum40",     "met[4]>100&&pfJetGoodNumBtag30>0", 7, 3, 10, true, "#(jets)", "njets_AtLeastOneBJet30");
754 >
755 >    make_OFSF_plots("pfJetGoodNumBtag30", "met[4]>100", 5, 0, 5, true, "#(b-jets)", "nbjets");
756 >    make_OFSF_plots("iso1", "met[4]>100", 20, 0, 0.3, true, "lepton 1 isolation", "iso1");
757 >    make_OFSF_plots("iso2", "met[4]>100", 20, 0, 0.3, true, "lepton 2 isolation", "iso2");
758 >    //  make_OFSF_plots("pt1",  "met[4]>100", 30, 0., 300., true, "p_{T,1}", "pt1");
759 >    //  make_OFSF_plots("pt2",  "met[4]>100", 22, 0., 220., true, "p_{T,2}", "pt2");
760 >    make_OFSF_plots("eta1", "met[4]>100", 10, -2.5, 2.5, false, "#eta_{1}", "eta1", 0.15);
761 >    make_OFSF_plots("eta2", "met[4]>100", 10, -2.5, 2.5, false, "#eta_{2}", "eta2", 0.15);
762 >    //  make_OFSF_plots("phi1", "met[4]>100", 10, -TMath::Pi(), TMath::Pi(), false, "#phi_{1}", "phi1", 0.2);
763 >    //  make_OFSF_plots("phi2", "met[4]>100", 10, -TMath::Pi(), TMath::Pi(), false, "#phi_{2}", "phi2", 0.2);
764 >    //  make_OFSF_plots("pfJetGoodPt[0]/pfJetGoodPt[1]", "met[4]>100", 20, 1, 10, true, "pt_{j}^{1}/pt_{j}^{2}", "jpt1pt2", 0.2);
765 >    make_OFSF_plots("TMath::Abs(pfJetDphiMet[0])", "met[4]>100", 16, 0, 3.2, false, "|#Delta#phi(jet1,MET)|", "dphij1met", 0.2);
766 >    make_OFSF_plots("TMath::Abs(dphi)", "met[4]>100", 16, 0, 3.2, false, "|#Delta#phi(l1,l2)|", "dphi", 0.2);
767 >    //  make_OFSF_plots("TMath::Abs(dphiMet1)", "met[4]>100", 16, 0, 3.2, false, "|#Delta#phi(l1,MET)|", "dphiMet1", 0.2);
768 >    //  make_OFSF_plots("TMath::Abs(dphiMet2)", "met[4]>100", 16, 0, 3.2, false, "|#Delta#phi(l2,MET)|", "dphiMet2", 0.2);
769 >    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");
770 >    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");
771 >    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");
772 >    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");
773 >  }
774 >
775 >  if ( doDataComp && !PlottingSetup::openBox ) {
776 >    TCut mllCut("");
777 >    if ( !PlottingSetup::openBox ) mllCut = "mll>120";
778 >
779 >    TCut cutSignal = cutmass&&cutnJets&&"met[4]>100";
780 >    make_data_comparison_plot("mll", cutOSSF&&cutSignal&&mllCut,           60, 20., 320.,-1., false, "m_{ll}", "mll_SF_sig");
781 >    make_data_comparison_plot("mll", cutOSSF&&cutSignal&&mllCut&&"id1==0", 60, 20., 320.,-1., false, "m_{ll}", "mll_SF_sig_ee");
782 >    make_data_comparison_plot("mll", cutOSSF&&cutSignal&&mllCut&&"id1==1", 60, 20., 320.,-1., false, "m_{ll}", "mll_SF_sig_mm");
783 >
784 >    make_data_comparison_plot("mll", cutOSSF&&cutSignal&&mllCut&&"pfJetGoodNumBtag30==0",           60, 20., 320.,-1., false, "m_{ll}", "mll_SF_sig_btagVeto");
785 >    make_data_comparison_plot("mll", cutOSSF&&cutSignal&&mllCut&&"id1==0&&pfJetGoodNumBtag30==0", 60, 20., 320.,-1., false, "m_{ll}", "mll_SF_sig_ee_btagVeto");
786 >    make_data_comparison_plot("mll", cutOSSF&&cutSignal&&mllCut&&"id1==1&&pfJetGoodNumBtag30==0", 60, 20., 320.,-1., false, "m_{ll}", "mll_SF_sig_mm_btagVeto");
787 >
788 >    make_data_comparison_plot("mll", cutOSSF&&cutSignal&&mllCut&&"pfJetGoodNumBtag30>0",           60, 20., 320.,-1., false, "m_{ll}", "mll_SF_sig_AtLeastOneBJet");
789 >    make_data_comparison_plot("mll", cutOSSF&&cutSignal&&mllCut&&"id1==0&&pfJetGoodNumBtag30>0", 60, 20., 320.,-1., false, "m_{ll}", "mll_SF_sig_ee_AtLeastOneBJet");
790 >    make_data_comparison_plot("mll", cutOSSF&&cutSignal&&mllCut&&"id1==1&&pfJetGoodNumBtag30>0", 60, 20., 320.,-1., false, "m_{ll}", "mll_SF_sig_mm_AtLeastOneBJet");
791 >
792 >    make_data_comparison_plot("mll", cutOSOF&&cutSignal, 60, 20., 320.,-1., false, "m_{ll}", "mll_OF_sig");
793 >    make_data_comparison_plot("mll", cutmass&&"met[4]>100&&met[4]<150&&pfJetGoodNum40<3", 60, 20., 320.,-1., false, "m_{ll}", "mll_SF_CR");
794 >  }
795 >
796 >
797 >  if ( doKin ) {
798 >    string mllCut("");
799 >    if ( !PlottingSetup::openBox ) mllCut = "&&mll>120";
800 >
801 >    // Plots in signal region
802 >    make_kin_plot("met[4]","",70,0,350,dolog,"MET [GeV]","met",doPF,true);
803 >    make_kin_plot("mll","mll>20&&met[4]>100"+mllCut,(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll",doPF,true);
804 >    make_kin_plot("mll","mll>20&&met[4]>100",(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_osof",doPF,true,true);
805 >    make_kin_plot("mll","mll>20&&met[4]>100"+mllCut,(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_ee",doPF,true);
806 >    make_kin_plot("mll","mll>20&&met[4]>100"+mllCut,(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_mm",doPF,true);
807 >    
808 >    make_kin_plot("pfJetGoodNum40","met[4]>100"+mllCut,9,-0.5,8.5,dolog,"nJets","nJets",doPF);
809 >    make_kin_plot("pfJetGoodNum40","met[4]>100",9,-0.5,8.5,dolog,"nJets","nJets_osof",doPF);
810 >
811 >    // Further inclusive invariant mass plots
812 >    make_kin_plot("mll","",(int)((mll_hi-mll_low))/5,mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive",doPF,true);
813 >    make_kin_plot("mll","",(int)((mll_hi-mll_low))/5,mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_ee",doPF,true);
814 >    make_kin_plot("mll","",(int)((mll_hi-mll_low))/5,mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_mm",doPF,true);
815 >    make_kin_plot("mll","",(int)((mll_hi-mll_low))/5,mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_osof",doPF,true);
816 >    
817 >    //make_kin_plot("mll","",(int)((350-mll_low))/5,mll_low,350,dolog,"m_{ll} [GeV]","mll_inclusive_highrange",doPF);
818 >    //if(!doPF) make_special_mll_plot((int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]");
819 >    
820 >    //make_kin_plot("pfJetGoodPt[0]/pfJetGoodPt[1]","",45,1,10,dolog,"pt_{j}^{1}/pt_{j}^{2}","j1j2ratio",doPF,true);
821 >    //make_kin_plot("TMath::Abs(pfJetDphiMet[0])","",32,0,3.2,nolog,"|#Delta#phi(jet1,MET)|","dphiJ1MET",doPF,true);
822 >    
823 >    // Number of jets
824 >    make_kin_plot("pfJetGoodNum40","",9,-0.5,8.5,dolog,"nJets","nJets_inclusive",doPF);
825 >    make_kin_plot("pfJetGoodNum40","",9,-0.5,8.5,dolog,"nJets","nJets_osof_inclusive",doPF);
826 >    //make_kin_plot("pfJetGoodNum40","",9,-0.5,8.5,dolog,"nJets","nJets_nocuts_except_mll_ossf",doPF);
827 >    
828 >    // Others
829 >    make_kin_plot("numVtx","",(int)(30.5-(-0.5)),-0.5,30.5,nolog,"N(Vtx)","numVtx",doPF);
830 >    //  make_kin_plot("jetpt[0]","",40,0,200,dolog,"leading jet p_{T} [GeV]","pfJetGoodPt_0",doPF);
831 >    //  make_kin_plot("jeteta[0]","",40,-5,5,nolog,"leading jet #eta","pfJetGoodEta_0",doPF);
832 >    make_kin_plot("pt","",50,0,500,dolog,"Z p_{T} [GeV]","Zpt",doPF);
833 >    make_kin_plot("pt1","",50,0,200,nolog,"p_{T} [GeV]","pt1",doPF);
834 >    make_kin_plot("pt2","",50,0,200,nolog,"p_{T} [GeV]","pt2",doPF);
835 >    make_kin_plot("eta1","",40,-3,3,nolog,"#eta_{l}","eta",doPF);
836 >    make_kin_plot("jzb[1]","",100,-150,200,dolog,"JZB [GeV]","jzb_ossf",doPF);
837 >    //   stringstream jzbcut;
838 >    //   jzbcut << "((is_data&&("<<datajzb<<")>100)||(!is_data&&("<<mcjzb<<")>100))";
839 >    //   make_kin_plot("mll",jzbcut.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV]","mll_aboveJZB100",doPF,true);
840 >    //   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);
841 >    //   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);
842 >    //   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);
843 >    //   stringstream jzbcut2;
844 >    //   jzbcut2 << "((is_data&&("<<datajzb<<")>150)||(!is_data&&("<<mcjzb<<")>150))";
845 >    //   make_kin_plot("mll",jzbcut2.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV]","mll_aboveJZB150",doPF,true);
846 >    //   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);
847 >    //   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);
848 >    //   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);
849 >    //   stringstream jzbcut3;
850 >    //   jzbcut3 << "((is_data&&("<<datajzb<<")>50)||(!is_data&&("<<mcjzb<<")>50))";
851 >    //   make_kin_plot("mll",jzbcut3.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV]","mll_aboveJZB50",doPF,true);  
852 >    //   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);
853 >    //   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);  
854 >    //   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);  
855 >    
856 >    //   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);
857 >    //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);
858 >    //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);
859 >  }
860 >    
861 > //   make_special_obs_pred_mll_plot(datajzb,mcjzb,0);
862 > //   make_special_obs_pred_mll_plot(datajzb,mcjzb,50);
863 > //   make_special_obs_pred_mll_plot(datajzb,mcjzb,80);
864 > //   make_special_obs_pred_mll_plot(datajzb,mcjzb,100);
865   //   make_special_obs_pred_mll_plot(datajzb,mcjzb,150);
866   //   make_special_obs_pred_mll_plot(datajzb,mcjzb,200);
867   //   make_special_obs_pred_mll_plot(datajzb,mcjzb,250);
868  
869 <  make_JES_plot(cutmass&&cutOSSF&&basiccut,"_ossf");
870 <  make_JES_plot(cutmass&&cutOSOF&&basiccut,"_osof");
638 <
869 > //   make_JES_plot(cutmass&&cutOSSF&&basiccut,"_ossf");
870 > //   make_JES_plot(cutmass&&cutOSOF&&basiccut,"_osof");
871  
872   }
873  
# Line 652 | Line 884 | void make_comp_plot( string var, string
884  
885    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- below: the next ~20 lines changed!
886    int nRegions=4;
887 <  if(!PlottingSetup::RestrictToMassPeak) {
887 >  if(!PlottingSetup::RestrictToMassPeak||!PlottingSetup::UseSidebandsForcJZB) {
888      nRegions=2;
889    }
890    
# Line 926 | Line 1158 | vector<TF1*> do_extended_fit_to_plot(TH1
1158   //      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)
1159    TF1 *ttbarlogpar = do_logpar_fit_to_plot(Tprediction);
1160    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
1161 <  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);
1161 >  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);
1162  
1163  
1164    TF1 *ttbarlogparP = new TF1("ttbarlogparP",LogParabolaP,0,(prediction->GetXaxis()->GetBinLowEdge(prediction->GetNbinsX())+prediction->GetXaxis()->GetBinWidth(prediction->GetNbinsX())),8);
# Line 1067 | Line 1299 | void do_prediction_plot(string jzb, TCan
1299    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);
1300  
1301    
1302 <  if(PlottingSetup::RestrictToMassPeak) {
1302 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
1303      RcorrJZBSBem   = allsamples.Draw("RcorrJZBSBem",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1304      LcorrJZBSBem   = allsamples.Draw("LcorrJZBSBem",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1305      RcorrJZBSBeemm = allsamples.Draw("RcorrJZBSBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
# Line 1094 | Line 1326 | void do_prediction_plot(string jzb, TCan
1326    TH1F *BpredSys = new TH1F("Bpredsys","Bpredsys",PlottingSetup::global_ratio_binning.size()-1,&PlottingSetup::global_ratio_binning[0]);
1327    ClearHisto(BpredSys);
1328      
1329 <  if(PlottingSetup::RestrictToMassPeak) {
1329 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
1330      Bpred->Add(RcorrJZBem,1.0/3.);
1331      Bpred->Add(LcorrJZBem,-1.0/3.);
1332      Bpred->Add(RcorrJZBSBem,1.0/3.);
# Line 1149 | Line 1381 | void do_prediction_plot(string jzb, TCan
1381    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- prediction changed
1382    TH1F *Tpred = (TH1F*)RcorrJZBem->Clone("Bpred");
1383    Tpred->Add(LcorrJZBem,-1.0);
1384 <  if(PlottingSetup::RestrictToMassPeak) {
1384 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
1385      Tpred->Add(RcorrJZBSBem,1.0);
1386      Tpred->Add(LcorrJZBSBem,-1.0);
1387      Tpred->Add(RcorrJZBSBeemm,1.0);
# Line 1242 | Line 1474 | void do_prediction_plot(string jzb, TCan
1474      speciallegBpred->AddEntry(RcorrJZBeemm,"Data","pl");
1475      speciallegBpred->AddEntry(Bpred,"Total background","l");
1476      speciallegBpred->AddEntry(jzbnegative,"JZB<0 (data)","f");
1477 <    if(PlottingSetup::RestrictToMassPeak) speciallegBpred->AddEntry(sidebandsemu,"Sidebands/e#mu (data)","f");
1477 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) speciallegBpred->AddEntry(sidebandsemu,"Sidebands/e#mu (data)","f");
1478      else speciallegBpred->AddEntry(sidebandsemu,"e#mu (data)","f");
1479   //    speciallegBpred->AddEntry(lm4RcorrJZBeemmC,"LM4","l");
1480      speciallegBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
# Line 1335 | Line 1567 | void do_prediction_plot(string jzb, TCan
1567    
1568    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
1569    // The part below is meaningless for the offpeak analysis (it's a comparison of the different estimates but there is but one estimate!)
1570 <  if(PlottingSetup::RestrictToMassPeak) {
1570 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
1571      TH1F *Bpredem = (TH1F*)LcorrJZBeemm->Clone("Bpredem");
1572      Bpredem->Add(RcorrJZBem);
1573      Bpredem->Add(LcorrJZBem,-1);
# Line 1414 | Line 1646 | void do_prediction_plot(string jzb, TCan
1646    delete blankback;
1647    
1648    delete BpredSys;
1649 <  if(PlottingSetup::RestrictToMassPeak) {
1649 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
1650      delete RcorrJZBSBem;
1651      delete LcorrJZBSBem;
1652      delete RcorrJZBSBeemm;
# Line 1455 | Line 1687 | void do_ratio_plot(int is_data,vector<fl
1687    TH1F *RcorrJZBSBeemm;
1688    TH1F *LcorrJZBSbeemm;
1689    
1690 <  if(PlottingSetup::RestrictToMassPeak) {
1690 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
1691      RcorrJZBSBem   = allsamples.Draw("RcorrJZBSbem",jzb.c_str(),binning, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,do_data, luminosity,dosignal);
1692      LcorrJZBSBem   = allsamples.Draw("LcorrJZBSbem",("-"+jzb).c_str(),binning, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,do_data, luminosity,dosignal);
1693      RcorrJZBSBeemm = allsamples.Draw("RcorrJZBSbeemm",jzb.c_str(),binning, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,do_data, luminosity,dosignal);
# Line 1467 | Line 1699 | void do_ratio_plot(int is_data,vector<fl
1699  
1700    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
1701    TH1F *Bpred = (TH1F*)LcorrJZBeemm->Clone("Bpred");
1702 <  if(PlottingSetup::RestrictToMassPeak) {
1702 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
1703      Bpred->Add(RcorrJZBem,1.0/3);
1704      Bpred->Add(LcorrJZBem,-1.0/3);
1705      Bpred->Add(RcorrJZBSBem,1.0/3);
# Line 1774 | Line 2006 | void draw_pure_jzb_histo(TCut cut,string
2006    datahisto->Draw("same,e1");
2007    
2008    TLegend *leg;
2009 <  if (!PlottingSetup::RestrictToMassPeak) {
2009 >  if (!PlottingSetup::RestrictToMassPeak||!PlottingSetup::UseSidebandsForcJZB) {
2010      if(is_OF(cut)) leg = allsamples.allbglegend("Opposite flavor",datahisto);
2011      else leg = allsamples.allbglegend("Same flavor",datahisto);
2012    } else {
# Line 1837 | Line 2069 | void produce_stretched_jzb_plots(string
2069    draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass&&"id1==1",datajzb,mcjzb,"Dibosons/mm/jzb_OS_SFZP",dican,binning);
2070    draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass&&"id1==0",datajzb,mcjzb,"Dibosons/ee/jzb_OS_OFZP",dican,binning);
2071    draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass&&"id1==1",datajzb,mcjzb,"Dibosons/mm/jzb_OS_OFZP",dican,binning);
2072 <  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"Dibosons/jzb_OS_SFSB",dican,binning);
2073 <  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"Dibosons/jzb_OS_OFSB",dican,binning);
2072 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"Dibosons/jzb_OS_SFSB",dican,binning);
2073 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"Dibosons/jzb_OS_OFSB",dican,binning);
2074    
2075    draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass,datajzb,mcjzb,"Dibosons/jzb_OS_SFZP_coarse",dican,coarse_binning);
2076    draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass,datajzb,mcjzb,"Dibosons/jzb_OS_OFZP_coarse",dican,coarse_binning);
2077 <  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"Dibosons/jzb_OS_SFSB_coarse",dican,coarse_binning);
2078 <  if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"Dibosons/jzb_OS_OFSB_coarse",dican,coarse_binning);
2077 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"Dibosons/jzb_OS_SFSB_coarse",dican,coarse_binning);
2078 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"Dibosons/jzb_OS_OFSB_coarse",dican,coarse_binning);
2079    
2080    delete dican;
2081   }
# Line 1944 | Line 2176 | void jzb_plots(string mcjzb, string data
2176      draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass&&"id1==0",datajzb,mcjzb,"ee/jzb_OS_OFZP",can,binning);
2177      draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass&&"id1==1",datajzb,mcjzb,"mm/jzb_OS_OFZP",can,binning);
2178      flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
2179 <    if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_SFSB",can,binning);
2180 <    if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_OFSB",can,binning);
2179 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_SFSB",can,binning);
2180 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_OFSB",can,binning);
2181      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);
2182      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);
2183      draw_normalized_data_vs_data_histo(cutOSOF&&cutnJets&&cutmass&&"id1==0",cutOSOF&&cutnJets&&cutmass&&"id1==1",datajzb,"ee","mm","jzb_ee_vs_mm_coarsest",can,coarsest_binning);
# Line 1956 | Line 2188 | void jzb_plots(string mcjzb, string data
2188    if ( !PlottingSetup::Approved ) {
2189      draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_OFZP_coarse",can,coarse_binning);
2190      flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
2191 <    if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_SFSB_coarse",can,coarse_binning);
2192 <    if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_OFSB_coarse",can,coarse_binning);
2191 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_SFSB_coarse",can,coarse_binning);
2192 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_OFSB_coarse",can,coarse_binning);
2193    }
2194    delete can;
2195   }
# Line 2009 | Line 2241 | void compute_MC_yields(string mcjzb,vect
2241    TCanvas *yica = new TCanvas("yica","yield canvas");
2242    
2243    int nRegions=4;
2244 <  if(!PlottingSetup::RestrictToMassPeak) nRegions=2;
2244 >  if(!PlottingSetup::RestrictToMassPeak||!PlottingSetup::UseSidebandsForcJZB) nRegions=2;
2245    string tsRegions[] = {"SFZP","OFZP","SFSB","OFSB"};
2246    string posneg[] = {"pos","neg"};
2247    TCut tkRegions[] = {cutOSSF&&cutnJets&&cutmass,cutOSOF&&cutnJets&&cutmass,cutOSSF&&cutnJets&&sidebandcut,cutOSOF&&cutnJets&&sidebandcut};
# Line 2457 | Line 2689 | void save_template(string mcjzb, string
2689    configfile<<"\n\n";
2690    configfile<<"luminosity="<<luminosity<<";\n";
2691    configfile<<"RestrictToMassPeak="<<RestrictToMassPeak<<";//defines the type of analysis we're running\n";
2692 +  configfile<<"UseSidebandsForcJZB="<<UseSidebandsForcJZB<<";//tells us whether to use the sidebands or not\n";
2693    
2694    configfile<<"\n\ncout << \"Configuration successfully loaded!\" << endl; \n \n } \n \n";
2695    
# Line 2529 | Line 2762 | void ttbar_sidebands_comparison(string m
2762    TH1F *TSeemm;
2763    TH1F *nTSeemm;
2764    
2765 <  if(PlottingSetup::RestrictToMassPeak) {
2765 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2766      TSem    = systsamples.Draw("TSem",       mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSOF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2767      nTSem   = systsamples.Draw("nTSem",  "-"+mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSOF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2768      TSeemm  = systsamples.Draw("TSeemm",     mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSSF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
# Line 2545 | Line 2778 | void ttbar_sidebands_comparison(string m
2778    TZem->SetMarkerColor(kRed);
2779  
2780  
2781 <  if(PlottingSetup::RestrictToMassPeak) {
2781 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2782          TSem->SetLineColor(TColor::GetColor("#00A616"));
2783          TSeemm->SetLineColor(kMagenta+2);
2784          TSem->SetMarkerColor(TColor::GetColor("#00A616"));
# Line 2559 | Line 2792 | void ttbar_sidebands_comparison(string m
2792    TZeemm->GetXaxis()->SetRangeUser(-100,binning[binning.size()-1]);
2793    histos.push_back(TZem);
2794    histos.push_back(TZeemm);
2795 <  if(PlottingSetup::RestrictToMassPeak) {
2795 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2796      TSeemm->GetXaxis()->SetRangeUser(-100,binning[binning.size()-1]);
2797      TSem->GetXaxis()->SetRangeUser(-100,binning[binning.size()-1]);
2798      histos.push_back(TSem);
# Line 2570 | Line 2803 | void ttbar_sidebands_comparison(string m
2803    TLegend *leg = make_legend("MC t#bar{t}",0.6,0.65,false);
2804    leg->AddEntry(TZeemm,"SFZP","l");
2805    leg->AddEntry(TZem,"OFZP","l");
2806 <  if(PlottingSetup::RestrictToMassPeak) {
2806 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2807      leg->AddEntry(TSeemm,"SFSB","l");
2808      leg->AddEntry(TSem,"OFSB","l");
2809    }
# Line 2581 | Line 2814 | void ttbar_sidebands_comparison(string m
2814    TH1F *TZeemmcopy = (TH1F*)TZeemm->Clone("TZeemmcopy");
2815    TH1F *TSeemmcopy;
2816    TH1F *TSemcopy;
2817 <  if(PlottingSetup::RestrictToMassPeak) {
2817 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2818      TSeemmcopy = (TH1F*)TSeemm->Clone("TSeemmcopy");
2819      TSemcopy = (TH1F*)TSem->Clone("TSemcopy");
2820    }
2821  
2822    TZem->Divide(TZeemm);
2823    TZem->SetMarkerStyle(21);
2824 <  if(PlottingSetup::RestrictToMassPeak) {
2824 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2825      TSem->Divide(TZeemm);
2826      TSeemm->Divide(TZeemm);
2827      TSem->SetMarkerStyle(24);
# Line 2599 | Line 2832 | void ttbar_sidebands_comparison(string m
2832    TZem->GetYaxis()->SetRangeUser(0,2.5);
2833    TZem->GetYaxis()->SetTitle("ratio");
2834    TZem->Draw();
2835 <  if(PlottingSetup::RestrictToMassPeak) {
2835 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2836      TSem->Draw("same");
2837      TSeemm->Draw("same");
2838    }
# Line 2629 | Line 2862 | void ttbar_sidebands_comparison(string m
2862    
2863    TLegend *leg2 = make_legend("MC t#bar{t}",0.55,0.75,false);
2864    leg2->AddEntry(TZem,"OFZP / SFZP","ple");
2865 <  if(PlottingSetup::RestrictToMassPeak) {
2865 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2866      leg2->AddEntry(TSeemm,"SFSB / SFZP","ple");
2867      leg2->AddEntry(TSem,"OFSB / SFZP","ple");
2868    }
# Line 2655 | Line 2888 | void ttbar_sidebands_comparison(string m
2888      TH1F *rightofsb;
2889      TH1F *leftsfsb;
2890      TH1F *rightsfsb;
2891 <    if(PlottingSetup::RestrictToMassPeak) {
2891 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2892        leftofsb  = (TH1F*)nTSem->Clone("leftofsb");
2893        rightofsb = (TH1F*)TSemcopy->Clone("rightofsb");
2894        rightofsb->Add(leftofsb,-1);
# Line 2669 | Line 2902 | void ttbar_sidebands_comparison(string m
2902      rightsfzp->GetYaxis()->SetTitle("#deltaJZB / 25 GeV");
2903      rightsfzp->Draw("histo");
2904      rightofzp->Draw("histo,same");
2905 <    if(PlottingSetup::RestrictToMassPeak) {
2905 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2906        rightofsb->Draw("histo,same");
2907        rightsfsb->Draw("histo,same");
2908      }
# Line 2678 | Line 2911 | void ttbar_sidebands_comparison(string m
2911      TLegend *legA = make_legend("MC t#bar{t}",0.6,0.65,false);
2912      legA->AddEntry(rightsfzp,"SFZP","l");
2913      legA->AddEntry(rightofzp,"OFZP","l");
2914 <    if(PlottingSetup::RestrictToMassPeak) {
2914 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2915        legA->AddEntry(rightofsb,"SFSB","l");
2916        legA->AddEntry(rightsfsb,"OFSB","l");
2917      }
# Line 2692 | Line 2925 | void ttbar_sidebands_comparison(string m
2925      rightofzp->GetYaxis()->SetRangeUser(0.0,2.5);
2926      rightofzp->GetYaxis()->SetTitle("#deltaJZB ratio");
2927      rightofzp->Draw();
2928 <    if(PlottingSetup::RestrictToMassPeak) {
2928 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2929        rightofsb->Divide(rightsfzp);
2930        rightsfsb->Divide(rightsfzp);
2931        rightofsb->Draw("same");
# Line 2712 | Line 2945 | void ttbar_sidebands_comparison(string m
2945      bottom2->Draw("same");
2946  
2947      rightofzp->SetMarkerStyle(21);
2948 <    if(PlottingSetup::RestrictToMassPeak) {
2948 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2949        rightofsb->SetMarkerStyle(24);
2950        rightsfsb->SetMarkerStyle(32);
2951      }
2952  
2953      TLegend *leg3 = make_legend("MC t#bar{t}",0.55,0.75,false);
2954      leg3->AddEntry(rightofzp,"OFZP / SFZP","ple");
2955 <    if(PlottingSetup::RestrictToMassPeak) {
2955 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2956        leg3->AddEntry(rightsfsb,"SFSB / SFZP","ple");
2957        leg3->AddEntry(rightofsb,"OFSB / SFZP","ple");
2958      }
# Line 2738 | Line 2971 | void ttbar_sidebands_comparison(string m
2971    delete nTZem;
2972    delete TZeemm;
2973    delete nTZeemm;
2974 <  if(PlottingSetup::RestrictToMassPeak) {
2974 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2975          delete TSem;
2976          delete nTSem;
2977          delete TSeemm;
# Line 2901 | Line 3134 | void zjets_prediction_comparison(string
3134    TH1F *RcorrJZBSBeemm;
3135    TH1F *LcorrJZBSBeemm;
3136  
3137 <  if(PlottingSetup::RestrictToMassPeak) {
3137 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
3138      RcorrJZBSBem   = systsamples.Draw("RcorrJZBSBem",var,binning, "JZB [GeV]", "events",sidebandcut&&cutOSOF&&reducedNJets&&ONLYTau&&kPos,mc,simulatedlumi,systsamples.FindSample("/DY"));
3139      LcorrJZBSBem   = systsamples.Draw("LcorrJZBSBem",var,binning, "JZB [GeV]", "events",sidebandcut&&cutOSOF&&reducedNJets&&ONLYTau&&kNeg,mc,simulatedlumi,systsamples.FindSample("/DY"));
3140      RcorrJZBSBeemm = systsamples.Draw("RcorrJZBSBeemm",var,binning, "JZB [GeV]", "events",sidebandcut&&cutOSSF&&reducedNJets&&ONLYTau&&kPos,mc,simulatedlumi,systsamples.FindSample("/DY"));
# Line 2909 | Line 3142 | void zjets_prediction_comparison(string
3142    }
3143    
3144    TH1F *Bpred = (TH1F*)LcorrJZBeemm->Clone("Bpred");
3145 <  if(PlottingSetup::RestrictToMassPeak) {
3145 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
3146      Bpred->Add(RcorrJZBem,1.0/3.);
3147      Bpred->Add(LcorrJZBem,-1.0/3.);
3148      Bpred->Add(RcorrJZBSBem,1.0/3.);
# Line 2967 | Line 3200 | void zjets_prediction_comparison(string
3200    delete RcorrJZBem;
3201    delete LcorrJZBem;
3202    
3203 <  if(PlottingSetup::RestrictToMassPeak) {
3203 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
3204      delete RcorrJZBSBem;
3205      delete LcorrJZBSBem;
3206      delete RcorrJZBSBeemm;
# Line 3032 | Line 3265 | void make_table(samplecollection &coll,
3265      TH1F *RcorrJZBSBeemm;
3266      TH1F *LcorrJZBSBeemm;
3267      
3268 <    if(PlottingSetup::RestrictToMassPeak) {
3268 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
3269        RcorrJZBSBem   = coll.Draw("RcorrJZBSBem",jzbexpr.c_str(),nbins,low,14000, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity, mysample);
3270        LcorrJZBSBem   = coll.Draw("LcorrJZBSBem",("-("+jzbexpr+")").c_str(),nbins,low,14000, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity, mysample);
3271        RcorrJZBSBeemm = coll.Draw("RcorrJZBSBeemm",jzbexpr.c_str(),nbins,low,14000, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity, mysample);
# Line 3040 | Line 3273 | void make_table(samplecollection &coll,
3273      }
3274      
3275      TH1F *Bpred = (TH1F*)LcorrJZBeemm->Clone("Bpred");
3276 <    if(PlottingSetup::RestrictToMassPeak) {
3276 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
3277        Bpred->Add(RcorrJZBem,1.0/3.);
3278        Bpred->Add(LcorrJZBem,-1.0/3.);
3279        Bpred->Add(RcorrJZBSBem,1.0/3.);
# Line 3251 | Line 3484 | void qcd_plots(string datajzb, string mc
3484    TH1F *JRcorrJZBSBeemm;
3485    TH1F *JLcorrJZBSBeemm;
3486    
3487 <  if(PlottingSetup::RestrictToMassPeak) {
3487 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
3488      RcorrJZBSBem   = qcdsamples.Draw("RcorrJZBSBem",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
3489      LcorrJZBSBem   = qcdsamples.Draw("LcorrJZBSBem",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
3490      RcorrJZBSBeemm = qcdsamples.Draw("RcorrJZBSBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
# Line 3272 | Line 3505 | void qcd_plots(string datajzb, string mc
3505      
3506    TH1F *Bpred = (TH1F*)LcorrJZBeemm->Clone("Bpred");
3507    TH1F *JBpred = (TH1F*)JLcorrJZBeemm->Clone("Bpred");
3508 <  if(PlottingSetup::RestrictToMassPeak) {
3508 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
3509      Bpred->Add(RcorrJZBem,1.0/3.);
3510      Bpred->Add(LcorrJZBem,-1.0/3.);
3511      Bpred->Add(RcorrJZBSBem,1.0/3.);
# Line 3342 | Line 3575 | void qcd_plots(string datajzb, string mc
3575    dout << "______________________________________________" << endl;
3576    dout << "How QCD shows up in the different regions: " << endl;
3577    dout << "OSSF: " << endl;
3578 <  if(PlottingSetup::RestrictToMassPeak) {
3578 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
3579      dout << "     Z window: \t" << RcorrJZBeemm->Integral() << " (JZB>0) , " << LcorrJZBeemm->Integral() << " (JZB<0) --> total: " << RcorrJZBeemm->Integral() + LcorrJZBeemm->Integral() << endl;
3580      dout << "     sideband: \t" << RcorrJZBSBeemm->Integral() << " (JZB>0) , " << LcorrJZBSBeemm->Integral() << " (JZB<0) --> total: " << RcorrJZBSBeemm->Integral() + LcorrJZBSBeemm->Integral() << endl;
3581    } else {
3582      dout << "     " << RcorrJZBeemm->Integral() << " (JZB>0) , " << LcorrJZBeemm->Integral() << " (JZB<0) --> total: " << RcorrJZBeemm->Integral() + LcorrJZBeemm->Integral() << endl;
3583    }
3584    dout << "OSOF: " << endl;
3585 <  if(PlottingSetup::RestrictToMassPeak) {
3585 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
3586      dout << "     Z window: \t" << RcorrJZBem->Integral() << " (JZB>0) , " << LcorrJZBem->Integral() << " (JZB<0) --> total: " << RcorrJZBem->Integral() + LcorrJZBem->Integral() << endl;
3587      dout << "     sideband: \t" << RcorrJZBSBem->Integral() << " (JZB>0) , " << LcorrJZBSBem->Integral() << " (JZB<0) --> total: " << RcorrJZBSBem->Integral() + LcorrJZBSBem->Integral() << endl;
3588    } else {
3589      dout << "     Z window: \t" << RcorrJZBem->Integral() << " (JZB>0) , " << LcorrJZBem->Integral() << " (JZB<0) --> total: " << RcorrJZBem->Integral() + LcorrJZBem->Integral() << endl;
3590    }
3591    dout << "Therefore: " << endl;
3592 <  if(PlottingSetup::RestrictToMassPeak) {
3592 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
3593      dout << "    Prediction increases by : " << LcorrJZBeemm->Integral() << " + (1.0/3)*(" << RcorrJZBSBeemm->Integral() <<"-"<< LcorrJZBSBeemm->Integral() << ") (SFSB) ";
3594      dout << " + (1.0/3)*(" << RcorrJZBem->Integral() <<"-"<< LcorrJZBem->Integral() << ") (OFZP) ";
3595      dout << " + (1.0/3)*(" << RcorrJZBSBem->Integral() <<"-"<< LcorrJZBSBem->Integral() << ") (OFSB) ";
# Line 3372 | Line 3605 | void qcd_plots(string datajzb, string mc
3605    for(int i=0;i<(int)bins.size();i++) {
3606      dout << " JZB > " << bins[i] << " : " << endl;
3607      dout << "    Observation increases by : " << RcorrJZBeemm->Integral(RcorrJZBeemm->FindBin(bins[i]),RcorrJZBeemm->GetNbinsX()) << endl;
3608 <    if(PlottingSetup::RestrictToMassPeak) {
3608 >    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
3609          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;
3610      } else {
3611          dout << "    Prediction increases by : " << LcorrJZBeemm->Integral(RcorrJZBeemm->FindBin(bins[i]),RcorrJZBeemm->GetNbinsX()) + RcorrJZBem->Integral(RcorrJZBeemm->FindBin(bins[i]),RcorrJZBeemm->GetNbinsX()) - LcorrJZBem->Integral(RcorrJZBeemm->FindBin(bins[i]),RcorrJZBeemm->GetNbinsX()) << endl;
# Line 3386 | Line 3619 | void qcd_plots(string datajzb, string mc
3619    if(LcorrJZBem) delete LcorrJZBem;
3620    if(RcorrJZBeemm) delete RcorrJZBeemm;
3621    if(LcorrJZBeemm) delete LcorrJZBeemm;
3622 <  if(PlottingSetup::RestrictToMassPeak&&RcorrJZBSBem) delete RcorrJZBSBem;
3623 <  if(PlottingSetup::RestrictToMassPeak&&LcorrJZBSBem) delete LcorrJZBSBem;
3624 <  if(PlottingSetup::RestrictToMassPeak&&RcorrJZBSBeemm) delete RcorrJZBSBeemm;
3625 <  if(PlottingSetup::RestrictToMassPeak&&LcorrJZBSBeemm) delete LcorrJZBSBeemm;
3622 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB&&RcorrJZBSBem) delete RcorrJZBSBem;
3623 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB&&LcorrJZBSBem) delete LcorrJZBSBem;
3624 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB&&RcorrJZBSBeemm) delete RcorrJZBSBeemm;
3625 >  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB&&LcorrJZBSBeemm) delete LcorrJZBSBeemm;
3626   }
3627  
3628   void check_ptsanity() {
# Line 3486 | Line 3719 | void do_mlls_plot(string mcjzb) {
3719    }
3720   }
3721  
3722 < void met_vs_jzb_plots() {
3722 > void met_vs_jzb_plots(string datajzb, string mcjzb) {
3723    
3724    TCanvas *canmetjzb = new TCanvas("canmet","MET vs JZB canvas");
3725    canmetjzb->SetRightMargin(0.16);
# Line 3495 | Line 3728 | void met_vs_jzb_plots() {
3728    findme.push_back("DY");
3729    findme.push_back("TTJets");
3730    findme.push_back("LM");
3731 <  
3731 >  /*
3732    for(int ifind=0;ifind<(int)findme.size();ifind++) {
3733      vector<int> selsamples = allsamples.FindSample(findme[ifind]);
3734      TH2F *metvsjzb = new TH2F("metvsjzb","metvsjzb",200,0,100,400,-100,100);
3735      for(int isel=0;isel<(int)selsamples.size();isel++) {
3736 <      cout << "Producing MET:JZB plot ... working on sample: " << allsamples.collection[selsamples[isel]].filename << endl;
3737 <      allsamples.collection[selsamples[isel]].events->Draw("jzb[1]:met[4]>>+metvsjzb",cutmass&&cutOSSF);
3736 >      dout << "Producing MET:JZB plot ... working on sample: " << allsamples.collection[selsamples[isel]].filename << endl;
3737 >      allsamples.collection[selsamples[isel]].events->Draw("jzb[1]:met[4]>>+metvsjzb",cutmass&&cutOSSF&&cutnJets);
3738      }
3739      metvsjzb->Scale(allsamples.collection[selsamples[0]].weight);
3740      metvsjzb->SetStats(0);
# Line 3515 | Line 3748 | void met_vs_jzb_plots() {
3748      title->Draw();
3749      CompleteSave(canmetjzb,(string)"METvsJZBplots/"+findme[ifind]);
3750    }
3751 +  */
3752 +  
3753 +  dout << "About to produce MET plot for DY split up by JZB" << endl;
3754 +  
3755 +  int nbins=14;
3756 +  float low=0;
3757 +  float high=140;
3758 +  
3759 +  stringstream sLEFT;
3760 +  sLEFT << "((" << mcjzb << ")<0)";
3761 +  TCut LEFT(sLEFT.str().c_str());
3762 +  stringstream sRIGHT;
3763 +  sRIGHT << "((" << mcjzb << ")>0)";
3764 +  TCut RIGHT(sRIGHT.str().c_str());
3765 +  
3766 +  TH1F *metleft   = allsamples.Draw("metleft","met[4]",nbins,low,high, "MET [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&LEFT,mc, luminosity, allsamples.FindSample("DYJets"));
3767 +  TH1F *metleftO  = allsamples.Draw("metleftO","met[4]",nbins,low,high, "MET [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&LEFT,mc, luminosity, allsamples.FindSample("DYJets"));
3768 +  TH1F *metright  = allsamples.Draw("metright","met[4]",nbins,low,high, "MET [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&RIGHT,mc, luminosity, allsamples.FindSample("DYJets"));
3769 +  TH1F *metrightO = allsamples.Draw("metrightO","met[4]",nbins,low,high, "MET [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&RIGHT,mc, luminosity, allsamples.FindSample("DYJets"));
3770 +  
3771 +  
3772 +  TH1F *Bpred =  (TH1F*)metleft->Clone("Bpred");
3773 +  Bpred->Add(metleftO,-1);
3774 +  Bpred->Add(metrightO);
3775 +  TH1F *obs = (TH1F*)metright->Clone("obs");
3776 +  
3777 +  metleft->Add(metleftO,-1);
3778 +  metright->Add(metrightO,-1);
3779 +  
3780 +  metleft->SetLineColor(kRed);
3781 +  metright->SetLineColor(kBlack);
3782 +  TPad *metpad = new TPad("metpad","metpad",0,0,1,1);
3783 +  metpad->cd();
3784 +  metpad->SetLogy(1);
3785 +  metleft->Draw("histo");
3786 +  metright->Draw("same");
3787 +  TLegend *lg = make_legend();
3788 +  lg->SetX1(0.5);
3789 +  lg->SetY1(0.7);
3790 +  lg->AddEntry(metright,"JZB>0 (OSOF corrected)","P");
3791 +  lg->AddEntry(metleft,"JZB<0 (OSOF corrected)","L");
3792 +  lg->SetHeader("DY");
3793 +  
3794 +  lg->Draw();
3795 +  save_with_ratio(metright,metleft,metpad->cd(),"METvsJZBplots/ComparingLeftToRightinMETspectrum");
3796 +  
3797 +  TPad *metpad3 = new TPad("metpad3","metpad3",0,0,1,1);
3798 +  metpad3->cd();
3799 +  metpad3->SetLogy(1);
3800 +  Bpred->SetLineColor(kRed);
3801 +  Bpred->Draw("histo");
3802 +  obs->SetLineColor(kBlack);
3803 +  obs->Draw("same");
3804 +  TLegend *lg2 = make_legend();
3805 +  lg2->SetX1(0.5);
3806 +  lg2->SetY1(0.7);
3807 +  lg2->AddEntry(obs,"observed","P");
3808 +  lg2->AddEntry(Bpred,"predicted","L");
3809 +  lg2->SetHeader("DY");
3810 +
3811 +  lg2->Draw();
3812 +  
3813 +  save_with_ratio(obs,Bpred,metpad3->cd(),"METvsJZBplots/ComparingPredObsinMET");
3814 +  
3815 +  TPad *metpad2 = new TPad("metpad2","metpad2",0,0,1,1);
3816 +  metpad2->cd();
3817 +  metpad2->SetLogy(1);
3818 +  
3819 +  TH1F *metlefta   = allsamples.Draw("metlefta","met[2]",nbins,low,high, "MET [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&LEFT,mc, luminosity, allsamples.FindSample("DYJets"));
3820 +  TH1F *metleftOa  = allsamples.Draw("metleftOa","met[2]",nbins,low,high, "MET [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&LEFT,mc, luminosity, allsamples.FindSample("DYJets"));
3821 +  TH1F *metrighta  = allsamples.Draw("metrighta","met[2]",nbins,low,high, "MET [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&RIGHT,mc, luminosity, allsamples.FindSample("DYJets"));
3822 +  TH1F *metrightOa = allsamples.Draw("metrightOa","met[2]",nbins,low,high, "MET [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&RIGHT,mc, luminosity, allsamples.FindSample("DYJets"));
3823 +  
3824 +  metlefta->Add(metleftOa,-1);
3825 +  metrighta->Add(metrightOa,-1);
3826 +  
3827 +  metlefta->SetLineColor(kRed);
3828 +  metpad2->cd();
3829 +  metlefta->Draw("histo");
3830 +  metrighta->Draw("same");
3831 +  lg->Draw();
3832 +  save_with_ratio(metrighta,metlefta,metpad2->cd(),"METvsJZBplots/ComparingLeftToRightinMET_type1_spectrum");
3833 +  
3834 +  delete Bpred;
3835 +  delete obs;
3836 +  
3837 +  float newhigh=300;
3838 +  int newNBins=30;
3839 +  
3840 +  TPad *metpad4 = new TPad("metpad4","metpad4",0,0,1,1);
3841 +  TH1F *Ametleft   = allsamples.Draw("Ametleft","met[4]",newNBins,low,newhigh, "MET [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&LEFT,mc, luminosity);
3842 +  TH1F *AmetleftO  = allsamples.Draw("AmetleftO","met[4]",newNBins,low,newhigh, "MET [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&LEFT,mc, luminosity);
3843 +  TH1F *Ametright  = allsamples.Draw("Ametright","met[4]",newNBins,low,newhigh, "MET [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&RIGHT,mc, luminosity);
3844 +  TH1F *AmetrightO = allsamples.Draw("AmetrightO","met[4]",newNBins,low,newhigh, "MET [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&RIGHT,mc, luminosity);
3845 +  
3846 +  TH1F *aBpred = (TH1F*)Ametleft->Clone("aBpred");
3847 +  aBpred->Add(AmetleftO,-1);
3848 +  aBpred->Add(AmetrightO);
3849 +  aBpred->SetLineColor(kRed);
3850 +  
3851 +  TH1F *aobs = (TH1F*)Ametright->Clone("aobs");
3852 +  metpad4->cd();
3853 +  metpad4->SetLogy(1);
3854 +  aobs->Draw();
3855 +  aBpred->Draw("histo,same");
3856 +  aobs->Draw("same");
3857 +  lg->SetHeader("All MC");
3858 +  lg->Draw();
3859 +  save_with_ratio(aobs,aBpred,metpad4->cd(),"METvsJZBplots/ComparingPredObsinMET_ALLSAMPLES");
3860 +  
3861 +  
3862 +  delete lg;
3863 +  delete canmetjzb;
3864 +  delete metleft;
3865 +  delete metleftO;
3866 +  delete metright;
3867 +  delete metrightO;
3868   }
3869      
3870  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines