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.50 by buchmann, Wed Aug 15 13:52:12 2012 UTC vs.
Revision 1.71 by buchmann, Wed Nov 7 10:54:34 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 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 +  data1->Scale(5.0/9.2);
472 +
473 +  data1->SetMarkerSize(DataMarkerSize);
474 +  data2->SetLineColor(kRed);
475 +
476 +  if ( !logscale ) {
477 +    data1->SetMinimum(0); // Defaults
478 +  } else {
479 +    data1->SetMinimum(0.5);
480 +  }
481 +  if (ymax<0) {
482 +    if ( logscale ) data1->SetMaximum(5.3*data1->GetMaximum());
483 +    else data1->SetMaximum(1.5*data1->GetMaximum());
484 +  } else {
485 +    data1->SetMaximum(ymax);
486 +  }
487 +
488 +  float ymaxSet = data1->GetMaximum();
489 +
490 +  data1->GetXaxis()->SetTitle(xlabel.c_str());
491 +  data1->GetYaxis()->SetTitle("Events");
492 +  data1->GetXaxis()->CenterTitle();
493 +  data1->GetYaxis()->CenterTitle();
494 +
495 +  TLegend *mleg = make_legend("",legendPosition,0.7,false,legendPosition+0.2);
496 +  mleg->AddEntry(data1, "2012 data (scaled)", "PL");
497 +  mleg->AddEntry(data2, "2011 data", "L");
498 +
499 +  data1->Draw("E1");
500 +  data2->Draw("HIST,SAMES");
501 +  mleg->Draw();
502 +  DrawPrelim();
503 +  save_with_ratio( data1, data2, rcan, "compareData/" + filename, false, false, "new/old" );
504 +
505 +  data1->Delete();
506 +  data2->Delete();
507 +  delete mleg;
508 +  delete ckin;
509 +
510 + }
511 +
512 + void make_OFSF_plots(string variable, string addcut, int nbins, float min, float max, bool logscale,
513 +                     string xlabel, string filename, float legendPosition=0.55) {
514 +
515 +  string mllcuts[] = { "mll>20","mll>15&&mll<70", "mll>75&&mll<105", "mll>120" };
516 +  string mllcutname[] = { "m_{ll} > 20 GeV", "20 < m_{ll} < 70 GeV", "70 < m_{ll} < 110 GeV", "m_{ll} > 120 GeV" };
517 +  string plotname[] = {"_all","_low","_peak","_high"};
518 +  float ymax;
519 +
520 +  int start = 0;
521 +  if ( !PlottingSetup::openBox ) start = 3;
522 +
523 +  for ( int i=start; i<4; ++i ) {
524 +    if ( addcut != "" ) mllcuts[i] += "&&"+addcut;
525 +    if ( i==start ) {
526 +      ymax = make_one_OFSF_plot(variable, mllcuts[i], mllcutname[i], nbins, min, max, -1, logscale, xlabel,
527 +                         filename+plotname[i], legendPosition );
528 +    } else {
529 +      make_one_OFSF_plot(variable, mllcuts[i],        mllcutname[i], nbins, min, max, ymax, logscale, xlabel,
530 +                         filename+plotname[i], legendPosition );
531 +    }
532 +    make_one_OFSF_plot(variable, "id1==1&&id1==id2&&"+mllcuts[i], mllcutname[i], nbins, min, max, ymax, logscale, xlabel,
533 +                       filename+plotname[i]+"_mm", legendPosition );
534 +    make_one_OFSF_plot(variable, "id1==0&&id1==id2&&"+mllcuts[i], mllcutname[i], nbins, min, max, ymax, logscale, xlabel,
535 +                       filename+plotname[i]+"_ee", legendPosition );
536 +  }
537 +
538 + }
539  
540  
541   float lastrange_min=0;
# Line 451 | Line 546 | void make_kin_plot(string variable, stri
546   //  TCut basiccut("(pfJetGoodNum>=2&&pfJetGoodID[0])&&(pfJetGoodNum>=2&&pfJetGoodID[1])&&(passed_triggers||!is_data)");
547    TCut ibasiccut=basiccut;
548    bool draw_separation_lines=false;
549 +  bool drawsignal = false;
550    
551    if(isPF) ibasiccut=basiccut&&"pfjzb[0]>-998";
552  
# Line 472 | Line 568 | void make_kin_plot(string variable, stri
568    //Step 2: Refine the cut
569    TCut cut;
570    cut=cutmass&&cutOSSF&&cutnJets&&ibasiccut;
571 <  if(filename=="nJets") cut=cutmass&&cutOSSF&&ibasiccut;
572 <  if(filename=="nJets_osof") cut=cutmass&&cutOSOF&&ibasiccut;
571 >  if(filename=="nJets" || filename=="nJets_inclusive" || filename=="nJets_met100" || filename=="nJets_inclusive_met100") cut=cutmass&&cutOSSF&&ibasiccut;
572 >  if(filename=="nJets_osof" || filename=="nJets_osof_inclusive" || filename=="nJets_osof_met100" || filename=="nJets_osof_inclusive_met100") cut=cutmass&&cutOSOF&&ibasiccut;
573    if(filename=="nJets_nocuts_except_mll_ossf") cut=cutmass&&cutOSSF;
574 <  if(filename=="mll") {
574 >  if(filename=="mll"||filename=="mll_met100") {
575          cut=cutOSSF&&cutnJets&&ibasiccut;
576          draw_separation_lines=true;
577    }
578 <  if(filename=="mll_ee") cut=cutOSSF&&cutnJets&&ibasiccut&&"id1==0";
579 <  if(filename=="mll_osof") {
578 >  if(filename=="mll_ee"||filename=="mll_ee_met100") cut=cutOSSF&&cutnJets&&ibasiccut&&"id1==0";
579 >  if(filename=="mll_mm"||filename=="mll_mm_met100") cut=cutOSSF&&cutnJets&&ibasiccut&&"id1==1";
580 >  if(filename=="mll_osof"||filename=="mll_osof_met100") {
581          cut=cutOSOF&&cutnJets&&ibasiccut;
582          draw_separation_lines=true;
583    }
487  if(filename=="mll_mm") cut=cutOSSF&&cutnJets&&ibasiccut&&"id1==1";
584    if(Contains(filename,"aboveJZB")) cut=cutOSSF&&cutnJets&&ibasiccut;
585    if(Contains(filename,"mll_ee_above")) cut=cut&&"id1==0";
586    if(Contains(filename,"mll_mm_above")) cut=cut&&"id1==1";
# Line 495 | Line 591 | void make_kin_plot(string variable, stri
591    if(filename=="mll_inclusive_mm") cut=cutOSSF&&"id1==1";
592    if(filename=="pfJetGoodEta_0") cut=cutOSSF&&cutmass&&ibasiccut&&cutnJets;
593    if(filename=="pfJetGoodPt_0") cut=cutOSSF&&cutmass&&ibasiccut&&cutnJets;
594 +  if(filename=="numVtx") cut=cutmass&&ibasiccut;
595  
596    TCanvas *ckin = new TCanvas("ckin","Kinematic Plots (in the making)",600,600);
597    ckin->SetLogy(logscale);
# Line 512 | Line 609 | void make_kin_plot(string variable, stri
609    if (logscale) datahisto->SetMaximum(5.3*datahisto->GetMaximum());
610    else datahisto->SetMaximum(1.3*datahisto->GetMaximum());
611  
612 <  cout << "******** Cut used : " << (const char*) cut << endl;
612 >  cout << "******** Cut used : " << (const char*) cut << " for plot " << filename << endl;
613    if(loadlastminmax) {
614          datahisto->SetMinimum(lastrange_min);
615          datahisto->SetMaximum(lastrange_max);
# Line 526 | Line 623 | void make_kin_plot(string variable, stri
623    string signal("LM3");
624    TH1F* signalhisto = new TH1F("signalhisto",signal.c_str(),nbins,min,max);
625    int idx = signalsamples.FindSample(signal)[0];
626 <  (signalsamples.collection)[idx].events->Project("signalhisto",variable.c_str(),cut);
627 <  signalhisto->Scale((signalsamples.collection)[idx].weight*luminosity);
628 <  signalhisto->SetLineColor(kOrange);
626 >  if(drawsignal) (signalsamples.collection)[idx].events->Project("signalhisto",variable.c_str(),cut);
627 >  if(drawsignal) signalhisto->Scale((signalsamples.collection)[idx].weight*luminosity);
628 >  if(drawsignal) signalhisto->SetLineColor(kOrange);
629  
630    THStack mcstack   = allsamples.DrawStack("mcstack",  variable,nbins,min,max,xlabel,"events",cut,mc,luminosity);
631    datahisto->Draw("e1");
# Line 577 | Line 674 | void make_kin_plot(string variable, stri
674          kinpad->SetLogy(logscale);
675          datahisto->Draw("e1");
676          mcstack.Draw("same");
677 <        signalhisto->Draw("same");
677 >        if(drawsignal) signalhisto->Draw("same");
678          datahisto->Draw("same,e1");
679          datahisto->Draw("same,axis");
680          if(RestrictToMassPeak&&draw_separation_lines) {
# Line 585 | Line 682 | void make_kin_plot(string variable, stri
682            upperboundary->Draw("same");
683          }
684            
685 <        kinleg->AddEntry("signalhisto",signal.c_str(),"l");
685 >        if(drawsignal) kinleg->AddEntry("signalhisto",signal.c_str(),"l");
686          kinleg->Draw();
687          write_cut->Draw();
688          DrawPrelim();
# Line 600 | Line 697 | void make_kin_plot(string variable, stri
697          else CompleteSave(ckin,"kin/"+filename);
698    }
699    datahisto->Delete();
700 +  delete signalhisto;
701    delete ckin;
702   }
703  
# Line 650 | Line 748 | void make_JES_plot(TCut cut, string name
748  
749   void do_kinematic_plots(string mcjzb, string datajzb, bool doPF=false)
750   {
751 + //  switch_overunderflow(true);
752    bool dolog=true;
753    bool nolog=false;
754 +
755 +  bool doOFSF = false;
756 +  bool doKin  = true;
757 +  bool doDataComp = false;
758 +  
759 +
760    if(doPF) write_warning(__FUNCTION__,"Please use caution when trying to produce PF plots; not all versions of the JZB trees have these variables!");
761    float mll_low=50;
762    float mll_hi=160;
763    if(!PlottingSetup::RestrictToMassPeak) {
764          mll_low=20;
765 <        mll_hi=300;
765 >        mll_hi=320;
766    }
767  
768 <  /*
769 <  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);
665 <  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);
666 <  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);
667 <  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);
668 <  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);
669 <  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);
670 <  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);
671 <  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);
672 <  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);
673 <  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);
674 <  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);
675 <  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);
676 <  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);
677 <  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);
678 <  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);
679 <  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);
680 <  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);
681 <  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);
682 <  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);
683 <  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);
684 <
685 <
686 <  make_kin_plot("met[4]","",70,0,350,dolog,"MET [GeV]","met",doPF,true);
687 <
688 <  make_kin_plot("mll","",(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll",doPF,true);
689 <  make_kin_plot("mll","",(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_osof",doPF,true,true);
690 <  make_kin_plot("mll","",(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_ee",doPF,true);
691 <  make_kin_plot("mll","",(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_mm",doPF,true);
692 <  make_kin_plot("mll","",(int)((mll_hi-mll_low))/5,mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive",doPF,true);
693 <  make_kin_plot("mll","",(int)((mll_hi-mll_low))/5,mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_ee",doPF,true);
694 <  make_kin_plot("mll","",(int)((mll_hi-mll_low))/5,mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_mm",doPF,true);
695 <  make_kin_plot("mll","",(int)((mll_hi-mll_low))/5,mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_osof",doPF,true);
696 <  make_kin_plot("mll","",(int)((350-mll_low))/5,mll_low,350,dolog,"m_{ll} [GeV]","mll_inclusive_highrange",doPF);
697 <  if(!doPF) make_special_mll_plot((int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]");
698 <
699 <  make_kin_plot("pfJetGoodPt[0]/pfJetGoodPt[1]","",45,1,10,dolog,"pt_{j}^{1}/pt_{j}^{2}","j1j2ratio",doPF,true);
700 <  make_kin_plot("TMath::Abs(pfJetDphiMet[0])","",32,0,3.2,nolog,"|#Delta#phi(jet1,MET)|","dphiJ1MET",doPF,true);
701 <
702 <  make_kin_plot("pfJetGoodNum40","",9,-0.5,8.5,dolog,"nJets","nJets",doPF);
703 <  make_kin_plot("pfJetGoodNum40","",9,-0.5,8.5,dolog,"nJets","nJets_osof",doPF);
704 <  make_kin_plot("pfJetGoodNum40","",9,-0.5,8.5,dolog,"nJets","nJets_nocuts_except_mll_ossf",doPF);
705 <
706 <  make_kin_plot("numVtx","",(int)(30.5-(-0.5)),-0.5,30.5,nolog,"N(Vtx)","numVtx",doPF);
707 < //  make_kin_plot("jetpt[0]","",40,0,200,dolog,"leading jet p_{T} [GeV]","pfJetGoodPt_0",doPF);
708 < //  make_kin_plot("jeteta[0]","",40,-5,5,nolog,"leading jet #eta","pfJetGoodEta_0",doPF);
709 <  make_kin_plot("pt","",50,0,500,dolog,"Z p_{T} [GeV]","Zpt",doPF);
710 <  make_kin_plot("pt1","",50,0,200,nolog,"p_{T} [GeV]","pt1",doPF);
711 <  make_kin_plot("pt2","",50,0,200,nolog,"p_{T} [GeV]","pt2",doPF);
712 <  make_kin_plot("eta1","",40,-3,3,nolog,"#eta_{l}","eta",doPF);
713 <  make_kin_plot("jzb[1]","",100,-150,200,dolog,"JZB [GeV]","jzb_ossf",doPF);
714 <  stringstream jzbcut;
715 <  jzbcut << "((is_data&&("<<datajzb<<")>100)||(!is_data&&("<<mcjzb<<")>100))";
716 <  make_kin_plot("mll",jzbcut.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV]","mll_aboveJZB100",doPF,true);
717 <  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);
718 <  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);
719 <  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);
720 <  stringstream jzbcut2;
721 <  jzbcut2 << "((is_data&&("<<datajzb<<")>150)||(!is_data&&("<<mcjzb<<")>150))";
722 <  make_kin_plot("mll",jzbcut2.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV]","mll_aboveJZB150",doPF,true);
723 <  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);
724 <  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);
725 <  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);
726 <  stringstream jzbcut3;
727 <  jzbcut3 << "((is_data&&("<<datajzb<<")>50)||(!is_data&&("<<mcjzb<<")>50))";
728 <  make_kin_plot("mll",jzbcut3.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV]","mll_aboveJZB50",doPF,true);  
729 <  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);
730 <  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);  
731 <  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);  
732 <
733 <  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);
734 <
735 <  make_special_obs_pred_mll_plot(datajzb,mcjzb,0);
736 <  make_special_obs_pred_mll_plot(datajzb,mcjzb,50);
737 <  make_special_obs_pred_mll_plot(datajzb,mcjzb,80);
738 <  make_special_obs_pred_mll_plot(datajzb,mcjzb,100);
739 < //   make_special_obs_pred_mll_plot(datajzb,mcjzb,150);
740 < //   make_special_obs_pred_mll_plot(datajzb,mcjzb,200);
741 < //   make_special_obs_pred_mll_plot(datajzb,mcjzb,250);
768 >  if ( doOFSF ) {
769 >     make_OFSF_plots("mll", "met[4]>100", 60, 20., 320., false, "m_{ll}", "mll");
770  
771 <  make_JES_plot(cutmass&&cutOSSF&&basiccut,"_ossf");
772 <  make_JES_plot(cutmass&&cutOSOF&&basiccut,"_osof");
773 <  */
774 <  
775 <  string regioncut[4] =    {"mll>0&&","mll>20&&mll<70&&","mll>70&&mll<110&&","mll>110&&"};
776 <  string regionname[4] = {"global","lowmass","Zregion","highmass"};
777 <  bool StoreRatioPlots=false;
778 <  for(int iregion=0;iregion<4;iregion++) {
779 <    cout << regionname[iregion] << " : " << regioncut[iregion] << endl;
780 <
781 <    //Z properties
782 <    make_kin_plot("pt","met[4]>100&&id1==0&&"+regioncut[iregion]+(const char*)TCut(cutmass&&cutOSSF&&cutnJets),40,0,200,dolog,"p_{T}^{ee} [GeV] (MET>100GeV)","Z/ZPT_ee_met100_"+regionname[iregion],doPF,StoreRatioPlots);
783 <    make_kin_plot("pt","met[4]>100&&id1==1&&"+regioncut[iregion]+(const char*)TCut(cutmass&&cutOSSF&&cutnJets),40,0,200,dolog,"p_{T}^{#mu#mu} [GeV] (MET>100GeV)","Z/ZPT_mm_met100_"+regionname[iregion],doPF,StoreRatioPlots);
784 <    
785 <    make_kin_plot("phi","met[4]>100&&id1==0&&"+regioncut[iregion]+(const char*)TCut(cutmass&&cutOSSF&&cutnJets),32,-3.2,3.2,nolog,"#phi^{ee} (MET>100GeV)","Z/ZPhi_ee_met100_"+regionname[iregion],doPF,StoreRatioPlots);
786 <    make_kin_plot("phi","met[4]>100&&id1==1&&"+regioncut[iregion]+(const char*)TCut(cutmass&&cutOSSF&&cutnJets),32,-3.2,3.2,nolog,"#phi^{#mu#mu} (MET>100GeV)","Z/ZPhi_mm_met100_"+regionname[iregion],doPF,StoreRatioPlots);
787 <    
788 <    make_kin_plot("eta","met[4]>100&&id1==0&&"+regioncut[iregion]+(const char*)TCut(cutmass&&cutOSSF&&cutnJets),30,-3.0,3.0,nolog,"#eta^{ee} (MET>100GeV)","Z/ZEta_ee_met100_"+regionname[iregion],doPF,StoreRatioPlots);
789 <    make_kin_plot("eta","met[4]>100&&id1==1&&"+regioncut[iregion]+(const char*)TCut(cutmass&&cutOSSF&&cutnJets),30,-3.0,3.0,nolog,"#eta^{#mu#mu} (MET>100GeV)","Z/ZEta_mm_met100_"+regionname[iregion],doPF,StoreRatioPlots);
790 <    
791 <    // lepton properties
792 <    make_kin_plot("pt1","met[4]>100&&id1==0&&"+regioncut[iregion]+(const char*)TCut(cutmass&&cutnJets),40,0,200,dolog,"p_{T}^{e1} [GeV] (MET>100GeV)","Lepton/LeadingElectronPt_met100_"+regionname[iregion],doPF,StoreRatioPlots);
793 <    make_kin_plot("pt1","met[4]>100&&id1==1&&"+regioncut[iregion]+(const char*)TCut(cutmass&&cutnJets),40,0,200,dolog,"p_{T}^{#mu1} [GeV] (MET>100GeV)","Lepton/LeadingMuonPt_met100_"+regionname[iregion],doPF,StoreRatioPlots);
794 <    make_kin_plot("pt2","met[4]>100&&id2==0&&"+regioncut[iregion]+(const char*)TCut(cutmass&&cutnJets),40,0,200,dolog,"p_{T}^{e2} [GeV] (MET>100GeV)","Lepton/SubLeadingElectronPt_met100_"+regionname[iregion],doPF,StoreRatioPlots);
795 <    make_kin_plot("pt2","met[4]>100&&id2==1&&"+regioncut[iregion]+(const char*)TCut(cutmass&&cutnJets),40,0,200,dolog,"p_{T}^{#mu2} [GeV] (MET>100GeV)","Lepton/SubLeadingMuonPt_met100_"+regionname[iregion],doPF,StoreRatioPlots);
796 <    
797 <    make_kin_plot("phi1","met[4]>100&&id1==0&&"+regioncut[iregion]+(const char*)TCut(cutmass&&cutnJets),32,-3.2,3.2,nolog,"#phi^{e1} (MET>100GeV)","Lepton/LeadingElectronPhi_met100_"+regionname[iregion],doPF,StoreRatioPlots);
798 <    make_kin_plot("phi1","met[4]>100&&id1==1&&"+regioncut[iregion]+(const char*)TCut(cutmass&&cutnJets),32,-3.2,3.2,nolog,"#phi^{#mu1} (MET>100GeV)","Lepton/LeadingMuonPhi_met100_"+regionname[iregion],doPF,StoreRatioPlots);
799 <    make_kin_plot("phi2","met[4]>100&&id2==0&&"+regioncut[iregion]+(const char*)TCut(cutmass&&cutnJets),32,-3.2,3.2,nolog,"#phi^{e2} (MET>100GeV)","Lepton/SubLeadingElectronPhi_met100_"+regionname[iregion],doPF,StoreRatioPlots);
800 <    make_kin_plot("phi2","met[4]>100&&id2==1&&"+regioncut[iregion]+(const char*)TCut(cutmass&&cutnJets),32,-3.2,3.2,nolog,"#phi^{#mu2} (MET>100GeV)","Lepton/SubLeadingMuonPhi_met100_"+regionname[iregion],doPF,StoreRatioPlots);
801 <    
802 <    make_kin_plot("eta1","met[4]>100&&id1==0&&"+regioncut[iregion]+(const char*)TCut(cutmass&&cutnJets),30,-3.0,3.0,nolog,"#eta^{e1} (MET>100GeV)","Lepton/LeadingElectronEta_met100_"+regionname[iregion],doPF,StoreRatioPlots);
803 <    make_kin_plot("eta1","met[4]>100&&id1==1&&"+regioncut[iregion]+(const char*)TCut(cutmass&&cutnJets),30,-3.0,3.0,nolog,"#eta^{#mu1} (MET>100GeV)","Lepton/LeadingMuonEta_met100_"+regionname[iregion],doPF,StoreRatioPlots);
804 <    make_kin_plot("eta2","met[4]>100&&id2==0&&"+regioncut[iregion]+(const char*)TCut(cutmass&&cutnJets),30,-3.0,3.0,nolog,"#eta^{e2} (MET>100GeV)","Lepton/SubLeadingElectronEta_met100_"+regionname[iregion],doPF,StoreRatioPlots);
805 <    make_kin_plot("eta2","met[4]>100&&id2==1&&"+regioncut[iregion]+(const char*)TCut(cutmass&&cutnJets),30,-3.0,3.0,nolog,"#eta^{#mu2} (MET>100GeV)","Lepton/SubLeadingMuonEta_met100_"+regionname[iregion],doPF,StoreRatioPlots);
771 > //      make_OFSF_plots("pfJetGoodNum40", "met[4]>100",                        7, 3, 10, true, "#(jets)", "njets");
772 > //      make_OFSF_plots("pfJetGoodNum40", "met[4]>100&&pfJetGoodNumBtag30==0", 7, 3, 10, true, "#(jets)", "njets_btagVeto");
773 > //      make_OFSF_plots("pfJetGoodNum40", "met[4]>100&&pfJetGoodNumBtag30>0",  7, 3, 10, true, "#(jets)", "njets_AtLeastOneBJet30");
774 >
775 > //      make_OFSF_plots("pfJetGoodNumBtag30", "met[4]>100", 5, 0, 5, true, "#(b-jets)", "nbjets");
776 > //      make_OFSF_plots("pfJetGoodPtBtag[0]", "met[4]>100&&pfJetGoodNumBtag30>0", 20, 0, 400, true, "p_{T}(leading b-jet)", "ptb1");
777 >
778 > //     make_OFSF_plots("iso1", "met[4]>100", 20, 0, 0.3, true, "lepton 1 isolation", "iso1");
779 > //     make_OFSF_plots("iso2", "met[4]>100", 20, 0, 0.3, true, "lepton 2 isolation", "iso2");
780 >    //  make_OFSF_plots("pt1",  "met[4]>100", 30, 0., 300., true, "p_{T,1}", "pt1");
781 >    //  make_OFSF_plots("pt2",  "met[4]>100", 22, 0., 220., true, "p_{T,2}", "pt2");
782 > //     make_OFSF_plots("eta1", "met[4]>100", 10, -2.5, 2.5, false, "#eta_{1}", "eta1", 0.15);
783 > //     make_OFSF_plots("eta2", "met[4]>100", 10, -2.5, 2.5, false, "#eta_{2}", "eta2", 0.15);
784 >    //  make_OFSF_plots("phi1", "met[4]>100", 10, -TMath::Pi(), TMath::Pi(), false, "#phi_{1}", "phi1", 0.2);
785 >    //  make_OFSF_plots("phi2", "met[4]>100", 10, -TMath::Pi(), TMath::Pi(), false, "#phi_{2}", "phi2", 0.2);
786 > //     make_OFSF_plots("pfJetGoodPt[0]/pfJetGoodPt[1]", "met[4]>100", 20, 1, 10, true, "pt_{j}^{1}/pt_{j}^{2}", "jpt1pt2", 0.2);
787 >    make_OFSF_plots("TMath::Abs(pfJetDphiMet[0])", "met[4]>100", 16, 0, 3.2, false, "|#Delta#phi(jet1,MET)|", "dphij1met", 0.2);
788 > //    make_OFSF_plots("TMath::Abs(dphi)", "met[4]>100", 16, 0, 3.2, false, "|#Delta#phi(l1,l2)|", "dphi", 0.2);
789 > //    make_OFSF_plots("TMath::Abs(dphiMet1)", "met[4]>100", 16, 0, 3.2, false, "|#Delta#phi(l1,MET)|", "dphiMet1", 0.2);
790 > //    make_OFSF_plots("TMath::Abs(dphiMet2)", "met[4]>100", 16, 0, 3.2, false, "|#Delta#phi(l2,MET)|", "dphiMet2", 0.2);
791 > //    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");
792 > //    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");
793 > //    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");
794 > //    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");
795 >  }
796 >
797 >  if ( doDataComp) {
798 >    TCut mllCut("");
799 >    float massmin = 15.;
800 >    float massmax = 315;
801 >    int massnbins = 60;
802 > /*    if ( !PlottingSetup::openBox ) {
803 >      mllCut = "mll>70";
804 >      massmin = 120;
805 >      massmax = 360;
806 >      massnbins = 14;
807 >    }*/
808 >
809 >    TCut cutSignal = cutmass&&cutnJets&&"met[4]>100";
810 >    
811 > /*    make_data_comparison_plot("numVtx", "",40, -0.5, 39.5,-1., true, "N(Vertices)", "numVtx");
812 >    make_data_comparison_plot("pfJetGoodEta[0]", "",50, -3.0, 3.0,-1., true, "N(Jets)", "pfJetGoodEta0");
813 >    
814 >    
815 >    make_data_comparison_plot("pfJetGoodNum40", cutOSOF,10, -0.5, 9.5,-1., true, "N(Jets)", "njets_OF");
816 >    make_data_comparison_plot("met[4]", cutOSSF,60, 0., 300.,-1., true, "pfMET", "met_SF_inclusive");
817 >    make_data_comparison_plot("met[1]", cutOSSF,60, 0., 300.,-1., true, "type 1 corrected pfMET", "mett1_SF_inclusive");
818 >    make_data_comparison_plot("met[4]", cutOSOF,60, 0., 300.,-1., true, "pfMET", "met_OF_inclusive");
819 >    make_data_comparison_plot("met[1]", cutOSOF,60, 0., 300.,-1., true, "type 1 corrected pfMET", "mett1_OF_inclusive");
820 >    
821 >    make_data_comparison_plot("met[4]", cutnJets&&cutOSSF,60, 0., 300.,-1., true, "pfMET", "met_SF_exclusive");
822 > //    make_data_comparison_plot("met[1]", cutnJets&&cutOSSF,60, 0., 300.,-1., true, "type 1 corrected pfMET", "mett1_SF_exclusive");
823 >    make_data_comparison_plot("met[4]", cutnJets&&cutOSOF,60, 0., 300.,-1., true, "pfMET", "met_OF_exclusive");
824 > //    make_data_comparison_plot("met[1]", cutnJets&&cutOSOF,60, 0., 300.,-1., true, "type 1 corrected pfMET", "mett1_OF_exclusive");
825 > */
826 >  
827 >    string basiccutsaved = (const char*)basiccut;
828 >    
829 >    string newbasiccut=basiccutsaved;
830 >    
831 >    size_t found;
832 >    found = newbasiccut.find( "pt2>20" );
833 >    while (found!=string::npos){
834 >      newbasiccut.replace( found, string( "pt2>20" ).length(), "pt2>10" );
835 >      found = newbasiccut.find( "pt2>20" );
836 >    }
837 > //    basiccut=TCut(newbasiccut.c_str());
838 > //    make_data_comparison_plot("mll", TCut("pfJetGoodNum40>=2&&met[4]>150")&&cutOSSF,60, 0., 300.,-1., false, "mll", "mll_SF_Aachen_pt2010_met");
839 > //    make_data_comparison_plot("mll", TCut("pfJetGoodNum40>=2&&met[4]>150")&&cutOSOF,60, 0., 300.,-1., false, "mll", "mll_OF_Aachen_pt2010_met");
840 > //    make_data_comparison_plot("mll", TCut("pfJetGoodNum40>=2&&met[1]>150")&&cutOSSF,60, 0., 300.,-1., true, "mll", "mll_SF_Aachen_pt2010_t1cpfmet");
841 > //    make_data_comparison_plot("mll", TCut("pfJetGoodNum40>=2&&met[1]>150")&&cutOSOF,60, 0., 300.,-1., true, "mll", "mll_OF_Aachen_pt2010_t1cpfmet");
842 > //    basiccut=TCut(basiccutsaved.c_str());
843 >    
844 > //     make_data_comparison_plot("pfJetGoodNum40", cutOSSF, 8, 0., 8.,-1., true, "#(jets)", "njets_SF");
845 > //     make_data_comparison_plot("pfJetGoodNum40", cutOSOF, 8, 0., 8.,-1., true, "#(jets)", "njets_OF");
846 >    
847 > //     make_data_comparison_plot("mll", TCut("pfJetGoodNum40>=3&&met[4]>100")&&cutOSSF,60, 0., 300.,-1., true, "mll", "mll_SF_ETH_met");
848 > //     make_data_comparison_plot("mll", TCut("pfJetGoodNum40>=3&&met[4]>100")&&cutOSOF,60, 0., 300.,-1., true, "mll", "mll_OF_ETH_met");
849 > //     make_data_comparison_plot("mll", TCut("pfJetGoodNum40>=3&&met[1]>100")&&cutOSSF,60, 0., 300.,-1., true, "mll", "mll_SF_ETH_t1cpfmet");
850 > //     make_data_comparison_plot("mll", TCut("pfJetGoodNum40>=3&&met[1]>100")&&cutOSOF,60, 0., 300.,-1., true, "mll", "mll_OF_ETH_t1cpfmet");
851 >
852 >    
853 > /*     make_data_comparison_plot("mll", cutOSSF,60, 15., 315.,-1., true, "m_{ll}", "mll_SF_inclusive");
854 >     make_data_comparison_plot("mll", cutOSSF&&TCut("id1==0"),60, 15., 315.,-1., true, "m_{ll}", "mll_SF_inclusive_ee");
855 >     make_data_comparison_plot("mll", cutOSSF&&TCut("id1==1"),60, 15., 315.,-1., true, "m_{ll}", "mll_SF_inclusive_mm");
856 >     make_data_comparison_plot("mll", cutOSOF,60, 15., 315.,-1., true, "m_{ll}", "mll_OF_inclusive");
857 >    make_data_comparison_plot("mll", cutnJets&&cutOSSF&&TCut("id1==0"),60, 15., 315.,-1., true, "m_{ll}", "mll_SF_exclusive_ee");
858 >    make_data_comparison_plot("mll", cutnJets&&cutOSSF&&TCut("id1==1"),60, 15., 315.,-1., true, "m_{ll}", "mll_SF_exclusive_mm");
859 >    make_data_comparison_plot("mll", cutnJets&&cutOSSF,60, 15., 315.,-1., true, "m_{ll}", "mll_SF_exclusive");
860 >    make_data_comparison_plot("mll", cutnJets&&cutOSOF,60, 15., 315.,-1., true, "m_{ll}", "mll_OF_exclusive");
861 > */
862 >    make_data_comparison_plot("mll", cutOSSF&&cutSignal&&mllCut,           massnbins, 15., 315.,-1., false, "m_{ll}", "mll_SF_sig");
863 >    make_data_comparison_plot("mll", cutOSOF&&cutSignal&&mllCut,           massnbins, 15., 315.,-1., false, "m_{ll}", "mll_OF_sig");
864      
865 +    make_data_comparison_plot("mll", TCut("abs(eta1)<1.4&&abs(eta2)<1.4") && cutOSSF&&cutSignal&&mllCut,           massnbins, 15., 315.,-1., false, "m_{ll}", "mll_SF_sig_central");
866 +    make_data_comparison_plot("mll", TCut("abs(eta1)<1.4&&abs(eta2)<1.4") && cutOSOF&&cutSignal&&mllCut,           massnbins, 15., 315.,-1., false, "m_{ll}", "mll_OF_sig_central");
867      
868 +    make_data_comparison_plot("mll", cutOSSF&&cutSignal&&mllCut&&"pfJetGoodNumBtag30==0", massnbins, 15., 315.,-1., false, "m_{ll}", "mll_SF_sig_btagVeto");
869 +    make_data_comparison_plot("mll", cutOSOF&&cutSignal&&mllCut&&"pfJetGoodNumBtag30==0", massnbins, 15., 315.,-1., false, "m_{ll}", "mll_OF_sig_btagVeto");
870 +    
871 +    make_data_comparison_plot("mll", cutOSSF&&cutSignal&&mllCut&&"pfJetGoodNumBtag30>0",  massnbins, 15., 315.,-1., false, "m_{ll}", "mll_SF_sig_AtLeastOneBJet");
872 +    make_data_comparison_plot("mll", cutOSOF&&cutSignal&&mllCut&&"pfJetGoodNumBtag30>0",  massnbins, 15., 315.,-1., false, "m_{ll}", "mll_OF_sig_AtLeastOneBJet");
873 +
874 + /*
875 +    make_data_comparison_plot("mll", mllCut&&cutOSOF&&cutSignal, massnbins, 15., 315.,-1., false, "m_{ll}", "mll_OF_sig");
876 +    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");
877 +    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");
878 +
879 +    make_data_comparison_plot("pfJetGoodNum40", cutOSSF&&cutSignal&&mllCut, 8, 0., 8.,-1., false, "#(jets)", "njets_SF_sig");
880 +    make_data_comparison_plot("pfJetGoodNum40", cutOSOF&&cutSignal&&mllCut, 8, 0., 8.,-1., false, "#(jets)", "njets_OF_sig");
881 +    make_data_comparison_plot("pfJetGoodNumBtag30", cutOSSF&&cutSignal&&mllCut, 8, 0., 8.,-1., false, "#(b-jets)", "nbjets_SF_sig");
882 +    make_data_comparison_plot("pfJetGoodNumBtag30", cutOSOF&&cutSignal&&mllCut, 8, 0., 8.,-1., false, "#(b-jets)", "nbjets_OF_sig");
883 +  */
884    }
885  
886 +
887 +  if ( doKin ) {
888 +    string mllCut("");
889 +
890 +     make_kin_plot("pfJetGoodPt[0]/pfJetGoodPt[1]","",45,1,10,dolog,"pt_{j}^{1}/pt_{j}^{2}","j1j2ratio",doPF,true);
891 +     make_kin_plot("TMath::Abs(pfJetDphiMet[0])","",32,0,3.2,nolog,"|#Delta#phi(jet1,MET)|","dphiJ1MET",doPF,true);
892 +    // Plots in signal region
893 + //     make_kin_plot("met[4]","",70,0,350,dolog,"MET [GeV]","met",doPF,true);
894 +     make_kin_plot("mll","mll>20"+mllCut,(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll",doPF,true);
895 +     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);
896 +     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);
897 +     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);
898 +    
899 +     make_kin_plot("pfJetGoodNum40",mllCut,9,-0.5,8.5,dolog,"nJets","nJets",doPF);
900 +     make_kin_plot("pfJetGoodNum40","",9,-0.5,8.5,dolog,"nJets","nJets_osof",doPF);
901 +    
902 + //     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);
903 + //     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);
904 + //     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);
905 + //     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);
906 +    
907 +    
908 + //     make_kin_plot("pfJetGoodNum40","met[4]>100"+mllCut,9,-0.5,8.5,dolog,"nJets","nJets_met100",doPF);
909 + //     make_kin_plot("pfJetGoodNum40","met[4]>100",9,-0.5,8.5,dolog,"nJets","nJets_osof_met100",doPF);
910 +
911 +    // Further inclusive invariant mass plots
912 +    make_kin_plot("mll",mllCut,(int)((mll_hi-mll_low))/5,mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive",doPF,true);
913 + //     make_kin_plot("mll","",(int)((mll_hi-mll_low))/5,mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_ee",doPF,true);
914 + //     make_kin_plot("mll","",(int)((mll_hi-mll_low))/5,mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_mm",doPF,true);
915 +    make_kin_plot("mll",mllCut,(int)((mll_hi-mll_low))/5,mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_osof",doPF,true);
916 +    
917 +    //make_kin_plot("mll","",(int)((350-mll_low))/5,mll_low,350,dolog,"m_{ll} [GeV]","mll_inclusive_highrange",doPF);
918 +    //if(!doPF) make_special_mll_plot((int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]");
919 +    
920 +    
921 +    // Number of jets
922 +    make_kin_plot("pfJetGoodNum40","",9,-0.5,8.5,dolog,"nJets","nJets_inclusive",doPF);
923 +    make_kin_plot("pfJetGoodNum40","",9,-0.5,8.5,dolog,"nJets","nJets_osof_inclusive",doPF);
924 +    //make_kin_plot("pfJetGoodNum40","",9,-0.5,8.5,dolog,"nJets","nJets_nocuts_except_mll_ossf",doPF);
925 +    
926 +    // Others
927 +    make_kin_plot("numVtx","",(int)(30.5-(-0.5)),-0.5,30.5,nolog,"N(Vtx)","numVtx",doPF);
928 +    //  make_kin_plot("jetpt[0]","",40,0,200,dolog,"leading jet p_{T} [GeV]","pfJetGoodPt_0",doPF);
929 +    //  make_kin_plot("jeteta[0]","",40,-5,5,nolog,"leading jet #eta","pfJetGoodEta_0",doPF);
930 +    make_kin_plot("pt","",50,0,500,dolog,"Z p_{T} [GeV]","Zpt",doPF);
931 +    make_kin_plot("pt1","",50,0,200,nolog,"p_{T} [GeV]","pt1",doPF);
932 +    make_kin_plot("pt2","",50,0,200,nolog,"p_{T} [GeV]","pt2",doPF);
933 +    make_kin_plot("eta1","",40,-3,3,nolog,"#eta_{l}","eta",doPF);
934 +    make_kin_plot("jzb[1]","",100,-150,200,dolog,"JZB [GeV]","jzb_ossf",doPF);
935 +    //   stringstream jzbcut;
936 +    //   jzbcut << "((is_data&&("<<datajzb<<")>100)||(!is_data&&("<<mcjzb<<")>100))";
937 +    //   make_kin_plot("mll",jzbcut.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV]","mll_aboveJZB100",doPF,true);
938 +    //   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);
939 +    //   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);
940 +    //   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);
941 +    //   stringstream jzbcut2;
942 +    //   jzbcut2 << "((is_data&&("<<datajzb<<")>150)||(!is_data&&("<<mcjzb<<")>150))";
943 +    //   make_kin_plot("mll",jzbcut2.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV]","mll_aboveJZB150",doPF,true);
944 +    //   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);
945 +    //   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);
946 +    //   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);
947 +    //   stringstream jzbcut3;
948 +    //   jzbcut3 << "((is_data&&("<<datajzb<<")>50)||(!is_data&&("<<mcjzb<<")>50))";
949 +    //   make_kin_plot("mll",jzbcut3.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV]","mll_aboveJZB50",doPF,true);  
950 +    //   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);
951 +    //   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);  
952 +    //   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);  
953 +    
954 +    //   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);
955 +    //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);
956 +    //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);
957 +  }
958 +    
959 + //   make_special_obs_pred_mll_plot(datajzb,mcjzb,0);
960 + //   make_special_obs_pred_mll_plot(datajzb,mcjzb,50);
961 + //   make_special_obs_pred_mll_plot(datajzb,mcjzb,80);
962 +   make_special_obs_pred_mll_plot(datajzb,mcjzb,100);
963 + //   make_special_obs_pred_mll_plot(datajzb,mcjzb,150);
964 + //   make_special_obs_pred_mll_plot(datajzb,mcjzb,200);
965 + //   make_special_obs_pred_mll_plot(datajzb,mcjzb,250);
966 +
967 + //   make_JES_plot(cutmass&&cutOSSF&&basiccut,"_ossf");
968 + //   make_JES_plot(cutmass&&cutOSOF&&basiccut,"_osof");
969 +
970 +  switch_overunderflow(false);
971   }
972  
973   void make_comp_plot( string var, string xlabel, string filename, float jzbcut, string mcjzb, string datajzb,
# Line 848 | Line 1037 | void region_comparison_plots(string mcjz
1037  
1038   //  switch_overunderflow(true);  // switching overflow/underflow bins on
1039      
1040 <  
1040 >  switch_overunderflow(true);
1041      flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- the arguments changed
1042    for(int ijzb=0;ijzb<(int)jzb_cuts.size();ijzb++) {
1043      float jzbcut=jzb_cuts[ijzb]; // Comparison plots are done for this JZB cut
# Line 1165 | Line 1354 | if you want to start from scratch (witho
1354  
1355   void do_prediction_plot(string jzb, TCanvas *globalcanvas, float high, int use_data, bool overlay_signal = false,string subdir="" )
1356   {
1357 < //  switch_overunderflow(true);
1357 >  
1358    bool is_data=false;
1359    bool use_signal=false;
1360    if(use_data==1) is_data=true;
1361    if(use_data==2) use_signal=true;
1362 <  int nbins=50;//100;
1363 <  if(is_data) nbins=50;
1362 >  int nbins=int(high/10);//100;
1363 >  if(is_data) nbins=int(high/10);
1364    float low=0;
1365 <  float hi=500;
1365 >  float hi=high;
1366 >  
1367 >  stringstream cutpositiveS;
1368 >  cutpositiveS << "(" << jzb << ">0)";
1369 >  TCut cutpositive(cutpositiveS.str().c_str());
1370 >  stringstream cutnegativeS;
1371 >  cutnegativeS << "(" << jzb << "<0)";
1372 >  TCut cutnegative(cutnegativeS.str().c_str());
1373 >  
1374    
1375    TH1F *blankback = new TH1F("blankback","blankback",int(high/10),0,high);
1376 <  TH1F *RcorrJZBeemm   = allsamples.Draw("RcorrJZBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1377 <  TH1F *LcorrJZBeemm   = allsamples.Draw("LcorrJZBeemm",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1378 <  TH1F *RcorrJZBem     = allsamples.Draw("RcorrJZBem",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1379 <  TH1F *LcorrJZBem     = allsamples.Draw("LcorrJZBem",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1376 >  TH1F *RcorrJZBeemm   = allsamples.Draw("RcorrJZBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutpositive&&cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1377 >  TH1F *LcorrJZBeemm   = allsamples.Draw("LcorrJZBeemm",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutnegative&&cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1378 >  TH1F *RcorrJZBem     = allsamples.Draw("RcorrJZBem",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutpositive&&cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1379 >  TH1F *LcorrJZBem     = allsamples.Draw("LcorrJZBem",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutnegative&&cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1380  
1381    blankback->GetXaxis()->SetTitle(RcorrJZBeemm->GetXaxis()->GetTitle());
1382    blankback->GetYaxis()->SetTitle(RcorrJZBeemm->GetYaxis()->GetTitle());
# Line 1194 | Line 1391 | void do_prediction_plot(string jzb, TCan
1391    
1392    TH1F *RcorrJZBeemmNoS;
1393  
1394 <    //these are for the ratio
1395 <  
1396 <  TH1F *JRcorrJZBeemm   = allsamples.Draw("JRcorrJZBeemm",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1397 <  TH1F *JLcorrJZBeemm   = allsamples.Draw("JLcorrJZBeemm",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1398 <  TH1F *JRcorrJZBem     = allsamples.Draw("JRcorrJZBem",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1202 <  TH1F *JLcorrJZBem     = allsamples.Draw("JLcorrJZBem",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1394 >  //these are for the ratio
1395 >  TH1F *JRcorrJZBeemm   = allsamples.Draw("JRcorrJZBeemm",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutpositive&&cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1396 >  TH1F *JLcorrJZBeemm   = allsamples.Draw("JLcorrJZBeemm",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutnegative&&cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1397 >  TH1F *JRcorrJZBem     = allsamples.Draw("JRcorrJZBem",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutpositive&&cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1398 >  TH1F *JLcorrJZBem     = allsamples.Draw("JLcorrJZBem",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutnegative&&cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1399    
1400    TH1F *JRcorrJZBSBem;
1401    TH1F *JLcorrJZBSBem;
1402    TH1F *JRcorrJZBSBeemm;
1403    TH1F *JLcorrJZBSBeemm;
1404    
1405 <  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);
1405 >  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);
1406  
1407    
1408    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
1409 <    RcorrJZBSBem   = allsamples.Draw("RcorrJZBSBem",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1410 <    LcorrJZBSBem   = allsamples.Draw("LcorrJZBSBem",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1411 <    RcorrJZBSBeemm = allsamples.Draw("RcorrJZBSBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1412 <    LcorrJZBSBeemm = allsamples.Draw("LcorrJZBSBeemm",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1409 >    RcorrJZBSBem   = allsamples.Draw("RcorrJZBSBem",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutpositive&&sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1410 >    LcorrJZBSBem   = allsamples.Draw("LcorrJZBSBem",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutnegative&&sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1411 >    RcorrJZBSBeemm = allsamples.Draw("RcorrJZBSBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutpositive&&sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1412 >    LcorrJZBSBeemm = allsamples.Draw("LcorrJZBSBeemm",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutnegative&&sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1413      
1414      //these are for the ratio
1415 <    JRcorrJZBSBem   = allsamples.Draw("JRcorrJZBSBem",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1416 <    JLcorrJZBSBem   = allsamples.Draw("JLcorrJZBSBem",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1417 <    JRcorrJZBSBeemm = allsamples.Draw("JRcorrJZBSBeemm",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1418 <    JLcorrJZBSBeemm = allsamples.Draw("JLcorrJZBSBeemm",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1415 >    JRcorrJZBSBem   = allsamples.Draw("JRcorrJZBSBem",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutpositive&&sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1416 >    JLcorrJZBSBem   = allsamples.Draw("JLcorrJZBSBem",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutnegative&&sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1417 >    JRcorrJZBSBeemm = allsamples.Draw("JRcorrJZBSBeemm",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutpositive&&sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1418 >    JLcorrJZBSBeemm = allsamples.Draw("JLcorrJZBSBeemm",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutnegative&&sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1419    }
1420    
1421    TH1F *lm4RcorrJZBeemm;
1422 <  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"));
1422 >  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"));
1423    
1424    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- prediction changed.
1425    
# Line 1287 | Line 1483 | void do_prediction_plot(string jzb, TCan
1483    SQRT(BpredSys);
1484    BpredSys->Divide(JBpred);
1485  
1290  
1486    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- prediction changed
1487    TH1F *Tpred = (TH1F*)RcorrJZBem->Clone("Bpred");
1488    Tpred->Add(LcorrJZBem,-1.0);
# Line 1340 | Line 1535 | void do_prediction_plot(string jzb, TCan
1535      Bpred->Draw("hist,same");
1536      //analytical_function[0]->Draw("same"); analytical_function[1]->Draw("same");analytical_function[2]->Draw("same");
1537      RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
1538 <    lm4RcorrJZBeemm->Draw("hist,same");
1538 >    //lm4RcorrJZBeemm->Draw("hist,same");
1539      legBpred->AddEntry(RcorrJZBeemm,"observed","p");
1540      legBpred->AddEntry(Bpred,"predicted","l");
1541   //    legBpred->AddEntry(analytical_function[1],"predicted fit","l");
1542   //    legBpred->AddEntry(analytical_function[2],"stat. uncert.","l");
1543 <    legBpred->AddEntry(lm4RcorrJZBeemm,(allsamples.collection[allsamples.FindSample("LM")[0]].samplename).c_str(),"l");
1543 > //     legBpred->AddEntry(lm4RcorrJZBeemm,(allsamples.collection[allsamples.FindSample("LM")[0]].samplename).c_str(),"l");
1544      legBpred->Draw();
1545      DrawPrelim();
1546  
# Line 1355 | Line 1550 | void do_prediction_plot(string jzb, TCan
1550      Bpred->SetLineWidth(2);
1551      predcomppad->cd();
1552      predcomppad->SetLogy(1);
1358    
1553      TH1F *jzbnegative = (TH1F*)LcorrJZBeemm->Clone("jzbnegative");
1554      TH1F *sidebandsemu = (TH1F*)Bpred->Clone("sidebandsemu");
1555      sidebandsemu->Add(jzbnegative,-1);
# Line 1377 | Line 1571 | void do_prediction_plot(string jzb, TCan
1571   //    lm4RcorrJZBeemm->SetLineColor(kOrange+1);
1572      lm4RcorrJZBeemm->SetLineWidth(2);
1573      //lm4RcorrJZBeemm->SetLineWidth(2); // paper style. overruled.
1574 <    lm4RcorrJZBeemm->Draw("histo,same");
1574 > //     lm4RcorrJZBeemm->Draw("histo,same");
1575      DrawPrelim();
1576      TLegend *speciallegBpred = make_legend("",0.45,0.55);
1577      //TLegend *speciallegBpred = make_legend("",0.35,0.55); // paper style. overruled.
# Line 1387 | Line 1581 | void do_prediction_plot(string jzb, TCan
1581      if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) speciallegBpred->AddEntry(sidebandsemu,"Sidebands/e#mu (data)","f");
1582      else speciallegBpred->AddEntry(sidebandsemu,"e#mu (data)","f");
1583   //    speciallegBpred->AddEntry(lm4RcorrJZBeemmC,"LM4","l");
1584 <    speciallegBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
1584 > //     speciallegBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
1585      speciallegBpred->Draw();
1586      save_with_ratio(JRcorrJZBeemm,JBpred,predcomppad,subdir+"Bpred_Data_____PredictionComposition",true,true,"data/pred",BpredSys);
1587      
# Line 1423 | Line 1617 | void do_prediction_plot(string jzb, TCan
1617      legBpred->AddEntry(Bpred,"MC predicted","l");    
1618      if(versok) legBpred->AddEntry((TObject*)0,"",""); // Just for alignment // causes seg fault on root v5.18
1619      if(versok) legBpred->AddEntry((TObject*)0,"",""); // causes seg fault on root v5.18
1620 <    if ( overlay_signal ) legBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
1620 > //     if ( overlay_signal ) legBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
1621      legBpred->Draw();
1622      DrawMCPrelim();
1623      Bpredsaveas="Bpred_MC";
# Line 1455 | Line 1649 | void do_prediction_plot(string jzb, TCan
1649        
1650        RcorrJZBeemmNoS->SetLineStyle(2);
1651        legBpred2->AddEntry(RcorrJZBeemmNoS,"MC B","l");
1652 <      legBpred2->AddEntry(lm4RcorrJZBeemm,"MC S","l");
1652 > //       legBpred2->AddEntry(lm4RcorrJZBeemm,"MC S","l");
1653        legBpred2->Draw();
1654        RcorrJZBeemmNoS->SetLineColor(TColor::GetColor("#61210B"));
1655        RcorrJZBeemmNoS->Draw("histo,same");
# Line 1474 | Line 1668 | void do_prediction_plot(string jzb, TCan
1668    //save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,Bpredsaveas,true,use_data!=1,ytitle);
1669    save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,subdir+Bpredsaveas,true,false,ytitle,BpredSys);//not extending the y range anymore up to 4
1670  
1671 +
1672    
1673    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
1674    // The part below is meaningless for the offpeak analysis (it's a comparison of the different estimates but there is but one estimate!)
# Line 1532 | Line 1727 | void do_prediction_plot(string jzb, TCan
1727        legBpredc->AddEntry(Bpredem,"MC OFZP","l");
1728        legBpredc->AddEntry(BpredSBem,"MC OFSB","l");
1729        legBpredc->AddEntry(BpredSBeemm,"MC SFSB","l");
1730 <      if ( overlay_signal ) legBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
1730 > //       if ( overlay_signal ) legBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
1731        legBpredc->Draw();
1732        CompleteSave(globalcanvas,subdir+"Bpred_MCwithS_comparison");
1733      }
# Line 1568 | Line 1763 | void do_prediction_plot(string jzb, TCan
1763      delete JLcorrJZBSBeemm;
1764    }
1765    if(overlay_signal || use_data==2) delete lm4RcorrJZBeemm;
1571  switch_overunderflow(false);
1766   }
1767  
1768   void do_prediction_plots(string mcjzb, string datajzb, float DataSigma, float MCSigma, bool overlay_signal ) {
1769 +  switch_overunderflow(true);
1770    TCanvas *globalcanvas = new TCanvas("globalcanvas","Prediction Canvas");
1771    do_prediction_plot(datajzb,globalcanvas,jzbHigh ,data,overlay_signal);
1772    if ( !PlottingSetup::Approved ) {
# Line 1580 | Line 1775 | void do_prediction_plots(string mcjzb, s
1775    } else {
1776      write_info(__FUNCTION__,"You set approved to true, therefore not producing prediction/observation plots for MC with and without signal.");
1777    }
1778 < }
1779 <
1585 < void do_ratio_plot(int is_data,vector<float> binning, string jzb, TCanvas *can, float high=-9999) {
1586 <  bool do_data=0;
1587 <  bool dosignal=0;
1588 <  if(is_data==1) do_data=1;
1589 <  if(is_data==2) dosignal=1;
1590 <  TH1F *RcorrJZBeemm   = allsamples.Draw("RcorrJZBeemm",jzb.c_str(),binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,do_data, luminosity,dosignal);
1591 <  TH1F *LcorrJZBeemm   = allsamples.Draw("LcorrJZBeemm",("-"+jzb).c_str(),binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,do_data, luminosity,dosignal);
1592 <  TH1F *RcorrJZBem     = allsamples.Draw("RcorrJZBem",jzb.c_str(),binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,do_data, luminosity,dosignal);
1593 <  TH1F *LcorrJZBem     = allsamples.Draw("LcorrJZBem",("-"+jzb).c_str(),binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,do_data, luminosity,dosignal);
1594 <  
1595 <  TH1F *RcorrJZBSBem;
1596 <  TH1F *LcorrJZBSBem;
1597 <  TH1F *RcorrJZBSBeemm;
1598 <  TH1F *LcorrJZBSbeemm;
1599 <  
1600 <  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
1601 <    RcorrJZBSBem   = allsamples.Draw("RcorrJZBSbem",jzb.c_str(),binning, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,do_data, luminosity,dosignal);
1602 <    LcorrJZBSBem   = allsamples.Draw("LcorrJZBSbem",("-"+jzb).c_str(),binning, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,do_data, luminosity,dosignal);
1603 <    RcorrJZBSBeemm = allsamples.Draw("RcorrJZBSbeemm",jzb.c_str(),binning, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,do_data, luminosity,dosignal);
1604 <    LcorrJZBSbeemm = allsamples.Draw("LcorrJZBSbeemm",("-"+jzb).c_str(),binning, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,do_data, luminosity,dosignal);
1605 <  }
1606 <  
1607 <
1608 <
1609 <
1610 <  flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
1611 <  TH1F *Bpred = (TH1F*)LcorrJZBeemm->Clone("Bpred");
1612 <  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
1613 <    Bpred->Add(RcorrJZBem,1.0/3);
1614 <    Bpred->Add(LcorrJZBem,-1.0/3);
1615 <    Bpred->Add(RcorrJZBSBem,1.0/3);
1616 <    Bpred->Add(LcorrJZBSBem,-1.0/3);
1617 <    Bpred->Add(RcorrJZBSBeemm,1.0/3);
1618 <    Bpred->Add(LcorrJZBSbeemm,-1.0/3);
1619 <  } else {
1620 <    Bpred->Add(RcorrJZBem,1.0);
1621 <    Bpred->Add(LcorrJZBem,-1.0);
1622 <  }
1623 <
1624 <  can->cd();
1625 <  can->SetLogy(0);
1626 <  Bpred->SetLineColor(kRed);
1627 <  Bpred->SetStats(0);
1628 <  if(high>0) Bpred->GetXaxis()->SetRangeUser(0,high);
1629 <  TH1F *JZBratioforfitting=(TH1F*)RcorrJZBeemm->Clone("JZBratioforfitting");
1630 <  JZBratioforfitting->Divide(Bpred);
1631 <  TGraphAsymmErrors *JZBratio = histRatio(RcorrJZBeemm,Bpred,is_data,binning,false);
1632 <  
1633 <  
1634 <  JZBratio->SetTitle("");
1635 <  JZBratio->GetYaxis()->SetRangeUser(0.0,9.0);
1636 < //  if(is_data==1) JZBratio->GetXaxis()->SetRangeUser(0,jzbHigh );
1637 <  
1638 <  TF1 *pol0 = new TF1("pol0","[0]",0,1000);
1639 <  TF1 *pol0d = new TF1("pol0","[0]",0,1000);
1640 < //  straightline_fit->SetParameter(0,1);
1641 <  JZBratioforfitting->Fit(pol0,"Q0R","",0,30);
1642 <  pol0d->SetParameter(0,pol0->GetParameter(0));
1643 <  
1644 <  JZBratio->GetYaxis()->SetTitle("Observed/Predicted");
1645 <  JZBratio->GetXaxis()->SetTitle("JZB [GeV]");
1646 <  if ( high>0 ) JZBratio->GetXaxis()->SetRangeUser(0.0,high);
1647 <  JZBratio->GetYaxis()->SetNdivisions(519);
1648 <  JZBratio->GetYaxis()->SetRangeUser(0.0,4.0);
1649 <  JZBratio->GetYaxis()->CenterTitle();
1650 <  JZBratio->GetXaxis()->CenterTitle();
1651 <  JZBratio->SetMarkerSize(DataMarkerSize);
1652 <  JZBratio->Draw("AP");
1653 <  /////----------------------------
1654 <  TPaveText *writeresult = new TPaveText(0.15,0.78,0.49,0.91,"blNDC");
1655 <  writeresult->SetFillStyle(4000);
1656 <  writeresult->SetFillColor(kWhite);
1657 <  writeresult->SetTextFont(42);
1658 <  writeresult->SetTextSize(0.03);
1659 <  writeresult->SetTextAlign(12);
1660 <  ostringstream jzb_agreement_data_text;
1661 <  jzb_agreement_data_text<< setprecision(2) << "mean =" << pol0->GetParameter(0) << " #pm " << setprecision(1) <<  pol0->GetParError(0);
1662 <  if(is_data==1) fitresultconstdata=pol0->GetParameter(0);// data
1663 <  if(is_data==0) fitresultconstmc=pol0->GetParameter(0); // monte carlo, no signal
1664 < /*  if(is_data) writeresult->AddText("Data closure test");
1665 <  else writeresult->AddText("MC closure test");
1666 <  */
1667 <  writeresult->AddText(jzb_agreement_data_text.str().c_str());
1668 < //  writeresult->Draw("same");
1669 < //  pol0d->Draw("same");
1670 <  TF1 *topline =  new TF1("","1.5",0,1000);
1671 <  TF1 *bottomline =  new TF1("","0.5",0,1000);
1672 <  topline->SetLineColor(kBlue);
1673 <  topline->SetLineStyle(2);
1674 <  bottomline->SetLineColor(kBlue);
1675 <  bottomline->SetLineStyle(2);
1676 < //  topline->Draw("same");
1677 < //  bottomline->Draw("same");
1678 <  TF1 *oneline = new TF1("","1.0",0,1000);
1679 <  oneline->SetLineColor(kBlue);
1680 <  oneline->SetLineStyle(1);
1681 <  oneline->Draw("same");
1682 <  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.
1683 <  if(is_data==1) DrawPrelim();
1684 <  else DrawMCPrelim();
1685 <  TLegend *leg = new TLegend(0.55,0.75,0.89,0.89);
1686 <  leg->SetTextFont(42);
1687 <  leg->SetTextSize(0.04);
1688 < //   if(is_data==1) leg->SetHeader("Ratio (data)");
1689 < //   else leg->SetHeader("Ratio (MC)");
1690 <
1691 <  TString MCtitle("MC ");
1692 <  if (is_data==1) MCtitle = "";
1693 <
1694 <  leg->SetFillStyle(4000);
1695 <  leg->SetFillColor(kWhite);
1696 <  leg->SetTextFont(42);
1697 < //  leg->AddEntry(topline,"+20\% sys envelope","l");
1698 <  leg->AddEntry(JZBratio,MCtitle+"obs / "+MCtitle+"pred","p");
1699 <  leg->AddEntry(oneline,"ratio = 1","l");
1700 < //  leg->AddEntry(pol0d,"fit in [0,30] GeV","l");
1701 < //  leg->AddEntry(bottomline,"#pm50% envelope","l");
1702 <
1703 <
1704 <  //leg->Draw("same"); // no longer drawing legend
1705 <
1706 <  if(is_data==1) CompleteSave(can, "jzb_ratio_data");
1707 <  if(is_data==0) CompleteSave(can, "jzb_ratio_mc");
1708 <  if(is_data==2) CompleteSave(can, "jzb_ratio_mc_BandS");//special case, MC with signal!
1709 <  
1710 <  delete RcorrJZBeemm;
1711 <  delete LcorrJZBeemm;
1712 <  delete RcorrJZBem;
1713 <  delete LcorrJZBem;
1714 <  
1715 <  delete RcorrJZBSBem;
1716 <  delete LcorrJZBSBem;
1717 <  delete RcorrJZBSBeemm;
1718 <  delete LcorrJZBSbeemm;
1719 < }
1720 <
1721 < void do_ratio_plots(string mcjzb,string datajzb,vector<float> ratio_binning) {
1722 <  TCanvas *globalc = new TCanvas("globalc","Ratio Plot Canvas");
1723 <  globalc->SetLogy(0);
1724 <  
1725 <  do_ratio_plot(mc,ratio_binning,mcjzb,globalc, jzbHigh  );
1726 <  do_ratio_plot(data,ratio_binning,datajzb,globalc, jzbHigh  );
1727 <  do_ratio_plot(mcwithsignal,ratio_binning,mcjzb,globalc, jzbHigh  );
1778 >  delete globalcanvas;
1779 >  switch_overunderflow(false);
1780   }
1781  
1782   string give_jzb_expression(float peak, int type) {
# Line 1992 | Line 2044 | void produce_stretched_jzb_plots(string
2044    
2045  
2046   void diboson_plots(string mcjzb, string datajzb,vector<float> ratio_binning) {
2047 +  switch_overunderflow(true);
2048    vector<int> SamplesToBeModified = allsamples.FindSampleBySampleName("WW/WZ/ZZ");
2049    
2050    if(SamplesToBeModified.size()==0 || SamplesToBeModified[0]==-1) {
# Line 2031 | Line 2084 | void diboson_plots(string mcjzb, string
2084      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;
2085      
2086    }
2087 <  
2087 > //   switch_overunderflow(false);
2088   }
2089  
2090  
# Line 2066 | Line 2119 | void draw_normalized_data_vs_data_histo(
2119  
2120  
2121   void jzb_plots(string mcjzb, string datajzb,vector<float> ratio_binning) {
2122 +  switch_overunderflow(true);
2123    TCanvas *can = new TCanvas("can","JZB Plots Canvas");
2124    float max=jzbHigh ;
2125    float min=-120;
# Line 2102 | Line 2156 | void jzb_plots(string mcjzb, string data
2156      if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_OFSB_coarse",can,coarse_binning);
2157    }
2158    delete can;
2159 +  switch_overunderflow(false);
2160   }
2161  
2162  
# Line 2599 | Line 2654 | void save_template(string mcjzb, string
2654    configfile<<"\n\n";
2655    configfile<<"luminosity="<<luminosity<<";\n";
2656    configfile<<"RestrictToMassPeak="<<RestrictToMassPeak<<";//defines the type of analysis we're running\n";
2657 +  configfile<<"UseSidebandsForcJZB="<<UseSidebandsForcJZB<<";//tells us whether to use the sidebands or not\n";
2658    
2659    configfile<<"\n\ncout << \"Configuration successfully loaded!\" << endl; \n \n } \n \n";
2660    
# Line 2641 | Line 2697 | void ttbar_sidebands_comparison(string m
2697    //in the case of the on peak analysis, we compare the 3 control regions to the real value
2698    //in the case of the OFF peak analysis, we compare our control region to the real value
2699    TCut weightbackup=cutWeight;
2700 +  switch_overunderflow(true);
2701    
2702    bool doPURW=false;
2703    
# Line 2662 | Line 2719 | void ttbar_sidebands_comparison(string m
2719        
2720    float simulatedlumi = luminosity; //in pb please - adjust to your likings
2721  
2722 <  TH1F *TZem  = systsamples.Draw("TZem",     mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSOF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2723 <  TH1F *nTZem = systsamples.Draw("nTZem","-"+mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSOF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2722 >  TH1F *TZem  = systsamples.Draw("TZem",     mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSOF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTT"));
2723 >  TH1F *nTZem = systsamples.Draw("nTZem","-"+mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSOF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTT"));
2724    TH1F *TSem;
2725    TH1F *nTSem;
2726 <  TH1F *TZeemm  = systsamples.Draw("TZeemm",     mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2727 <  TH1F *nTZeemm = systsamples.Draw("nTZeemm","-"+mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2726 >  TH1F *TZeemm  = systsamples.Draw("TZeemm",     mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTT"));
2727 >  TH1F *nTZeemm = systsamples.Draw("nTZeemm","-"+mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTT"));
2728    TH1F *TSeemm;
2729    TH1F *nTSeemm;
2730    
2731    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
2732 <    TSem    = systsamples.Draw("TSem",       mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSOF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2733 <    nTSem   = systsamples.Draw("nTSem",  "-"+mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSOF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2734 <    TSeemm  = systsamples.Draw("TSeemm",     mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSSF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2735 <    nTSeemm = systsamples.Draw("nTSeemm","-"+mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSSF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
2732 >    TSem    = systsamples.Draw("TSem",       mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSOF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTT"));
2733 >    nTSem   = systsamples.Draw("nTSem",  "-"+mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSOF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTT"));
2734 >    TSeemm  = systsamples.Draw("TSeemm",     mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSSF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTT"));
2735 >    nTSeemm = systsamples.Draw("nTSeemm","-"+mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSSF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTT"));
2736    }
2737  
2738    TCanvas *tcan = new TCanvas("tcan","tcan");
# Line 2707 | Line 2764 | void ttbar_sidebands_comparison(string m
2764      histos.push_back(TSem);
2765      histos.push_back(TSeemm);
2766    }
2767 <  draw_all_ttbar_histos(tcan,histos,"histo",1);
2767 >  draw_all_ttbar_histos(tcan,histos,"histo",8);
2768    
2769    TLegend *leg = make_legend("MC t#bar{t}",0.6,0.65,false);
2770    leg->AddEntry(TZeemm,"SFZP","l");
# Line 2719 | Line 2776 | void ttbar_sidebands_comparison(string m
2776    leg->Draw("same");
2777    DrawMCPrelim(simulatedlumi);
2778    CompleteSave(tcan,"Systematics/"+prestring+"/ttbar_shape_comparison");
2779 +  
2780    TH1F *TZemcopy = (TH1F*)TZem->Clone("TZemcopy");
2781    TH1F *TZeemmcopy = (TH1F*)TZeemm->Clone("TZeemmcopy");
2782    TH1F *TSeemmcopy;
# Line 2747 | Line 2805 | void ttbar_sidebands_comparison(string m
2805    }
2806    
2807    float linepos=emuncertONPEAK;
2808 <  if(!PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) linepos=emuncertOFFPEAK;
2808 >  if(!PlottingSetup::RestrictToMassPeak) linepos=emuncertOFFPEAK;
2809    
2810    TLine *top = new TLine(binning[0],1.0+linepos,binning[binning.size()-1],1.0+linepos);
2811    TLine *center = new TLine(binning[0],1.0,binning[binning.size()-1],1.0);
# Line 2784 | Line 2842 | void ttbar_sidebands_comparison(string m
2842    DrawMCPrelim(simulatedlumi);
2843    CompleteSave(tcan,"Systematics/"+prestring+"/ttbar_shape_comparison_ratio");
2844    
2845 +  
2846    if (0) { // Turn this off: we don't need this
2847  
2848      ///-------------- second part: only look at the quantity we actually care about!
# Line 2889 | Line 2948 | void ttbar_sidebands_comparison(string m
2948  
2949    delete tcan;
2950    cutWeight=weightbackup;
2951 +  switch_overunderflow(false);
2952   }
2953  
2954   void ttbar_sidebands_comparison(string mcjzb, vector<float> jzb_binning) {
# Line 2923 | Line 2983 | void ttbar_sidebands_comparison(string m
2983    nicer_binning.push_back(150);
2984    //nicer_binning.push_back(175);
2985    nicer_binning.push_back(200);
2986 <  nicer_binning.push_back(250);
2987 <  nicer_binning.push_back(300);
2988 <  nicer_binning.push_back(400);
2986 > //  nicer_binning.push_back(250);
2987 > //  nicer_binning.push_back(300);
2988 > //  nicer_binning.push_back(400);
2989    
2990    ttbar_sidebands_comparison(mcjzb,nicer_binning, "ttbar/");
2991   }
2992  
2993  
2994 < void zjets_prediction_comparison(string mcjzbWithPUa) {
2994 > void zjets_prediction_comparison(string mcjzbWithPUa, TCut massregioncut, string massregionname) {
2995 >  cout << "****************************************************************************************************************************************************************" << endl;
2996    TCanvas *zcan = new TCanvas("zcan","zcan");  
2997   //  zcan->SetLogy(1);
2998    TCut weightbackup=cutWeight;
2999    
3000 <  bool UsePURW=false;
3000 >  bool UsePURW=true;
3001    
3002    
3003    string mcjzb;
3004    if(UsePURW) {
3005      mcjzb=mcjzbWithPUa;
3006 +    cout << "Using PURW peak positions" << endl;
3007    } else {
3008      // Do it without PU re-weighting
3009 +    cutWeight="1.0";
3010      float MCPeakNoPU=0,MCPeakErrorNoPU=0,DataPeakNoPU=0,DataPeakErrorNoPU=0,MCSigma=0,DataSigma=0;
3011      stringstream resultsNoPU;
3012      stringstream noPUdatajzb;
# Line 2954 | Line 3017 | void zjets_prediction_comparison(string
3017      
3018      mcjzb = noPUmcjzb.str();
3019      
2957    cutWeight="1.0";
3020    }
3021  
3022    
# Line 2978 | Line 3040 | void zjets_prediction_comparison(string
3040    string var( "abs("+mcjzb+")" );
3041    
3042    TCut notTau("abs(genMID1)!=15");
3043 <  TCut ONLYTau("mll>20");
3043 >  TCut ee_mm_tautau("mll>0");
3044    
3045  
3046 <  TH1F *hJZBpos = systsamples.Draw("hJZBpos",var,binning, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets&&notTau&&kPos,mc,simulatedlumi,systsamples.FindSample("/DY"));
3047 <  TH1F *hJZBneg = systsamples.Draw("hJZBneg",var,binning, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets&&notTau&&kNeg,mc,simulatedlumi,systsamples.FindSample("/DY"));
3046 >  TH1F *hJZBpos = systsamples.Draw("hJZBpos",var,binning, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets&&notTau&&kPos&&massregioncut,mc,simulatedlumi,systsamples.FindSample("/DY"));
3047 >  TH1F *hJZBneg = systsamples.Draw("hJZBneg",var,binning, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets&&notTau&&kNeg&&massregioncut,mc,simulatedlumi,systsamples.FindSample("/DY"));
3048    
3049    hJZBpos->SetLineColor(kBlack);
3050    hJZBneg->SetLineColor(kRed);
# Line 2997 | Line 3059 | void zjets_prediction_comparison(string
3059    leg->AddEntry(hJZBneg,"Predicted","l");
3060    leg->Draw("same");
3061    DrawMCPrelim(simulatedlumi);
3062 <  CompleteSave(zcan,"Systematics/ZJets/zjets_eemm_prediction");
3062 >  CompleteSave(zcan,"Systematics/ZJets/zjets_eemm_prediction"+any2string(massregionname));
3063    
3064    TH1F* hratio = (TH1F*)hJZBpos->Clone("hratio");
3065    hratio->Divide(hJZBneg);
# Line 3006 | Line 3068 | void zjets_prediction_comparison(string
3068      cout << "Positive: " << hJZBpos->GetBinContent(i) << "   vs    Negative : " << hJZBneg->GetBinContent(i) << "   (ratio : " << hJZBpos->GetBinContent(i) / hJZBneg->GetBinContent(i) << endl;
3069    }
3070    
3071 <  zcan->SetLogy(0);
3072 <  hratio->GetYaxis()->SetRangeUser(0,2.0);
3071 > //  zcan->SetLogy(0);
3072 >  hratio->GetYaxis()->SetRangeUser(0,2.5);
3073    hratio->GetYaxis()->SetTitle("Observed/Predicted");
3074    hratio->Draw("e1");
3075    
# Line 3016 | Line 3078 | void zjets_prediction_comparison(string
3078    TLine *bottom = new TLine(binning[0],0.75,binning[binning.size()-1],0.75);
3079    
3080  
3081 +  cout << __LINE__ << endl;
3082    top->SetLineColor(kBlue);top->SetLineStyle(2);
3083    bottom->SetLineColor(kBlue);bottom->SetLineStyle(2);
3084    center->SetLineColor(kBlue);
# Line 3029 | Line 3092 | void zjets_prediction_comparison(string
3092    leg2->AddEntry(bottom,"syst. envelope","l");
3093    leg2->Draw("same");
3094    DrawMCPrelim(simulatedlumi);
3095 <  CompleteSave(zcan,"Systematics/ZJets/zjets_eemm_prediction_ratio");
3095 >  CompleteSave(zcan,"Systematics/ZJets/zjets_eemm_prediction_ratio"+any2string(massregionname));
3096    
3097    TCut reducedNJets(cutnJets);
3098    
3099 <  TH1F *TAUhJZBpos = systsamples.Draw("TAUhJZBpos",var,binning, "JZB [GeV]", "events",cutmass&&cutOSSF&&reducedNJets&&ONLYTau&&kPos,mc,simulatedlumi,systsamples.FindSample("/DY"));
3100 <  TH1F *LcorrJZBeemm     = systsamples.Draw("LcorrJZBeemm",var,binning, "JZB [GeV]", "events",cutmass&&cutOSSF&&reducedNJets&&ONLYTau&&kNeg,mc,simulatedlumi,systsamples.FindSample("/DY"));
3101 <  TH1F *RcorrJZBem       = systsamples.Draw("RcorrJZBem",var,binning, "JZB [GeV]", "events",cutmass&&cutOSOF&&reducedNJets&&ONLYTau&&kPos,mc,simulatedlumi,systsamples.FindSample("/DY"));
3102 <  TH1F *LcorrJZBem       = systsamples.Draw("LcorrJZBem",var,binning, "JZB [GeV]", "events",cutmass&&cutOSOF&&reducedNJets&&ONLYTau&&kNeg,mc,simulatedlumi,systsamples.FindSample("/DY"));
3099 >  TH1F *TAUhJZBpos       = systsamples.Draw("TAUhJZBpos",var,binning, "JZB [GeV]", "events",cutmass&&cutOSSF&&reducedNJets&&ee_mm_tautau&&kPos&&massregioncut,mc,simulatedlumi,systsamples.FindSample("/DY"));
3100 >  TH1F *LcorrJZBeemm     = systsamples.Draw("LcorrJZBeemm",var,binning, "JZB [GeV]", "events",cutmass&&cutOSSF&&reducedNJets&&ee_mm_tautau&&kNeg&&massregioncut,mc,simulatedlumi,systsamples.FindSample("/DY"));
3101 >  TH1F *RcorrJZBem       = systsamples.Draw("RcorrJZBem",var,binning, "JZB [GeV]", "events",cutmass&&cutOSOF&&reducedNJets&&ee_mm_tautau&&kPos&&massregioncut,mc,simulatedlumi,systsamples.FindSample("/DY"));
3102 >  TH1F *LcorrJZBem       = systsamples.Draw("LcorrJZBem",var,binning, "JZB [GeV]", "events",cutmass&&cutOSOF&&reducedNJets&&ee_mm_tautau&&kNeg&&massregioncut,mc,simulatedlumi,systsamples.FindSample("/DY"));
3103  
3104 +  cout << __LINE__ << endl;
3105    TH1F *RcorrJZBSBem;
3106    TH1F *LcorrJZBSBem;
3107    TH1F *RcorrJZBSBeemm;
3108    TH1F *LcorrJZBSBeemm;
3109  
3110 +  cout << __LINE__ << endl;
3111    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
3112 <    RcorrJZBSBem   = systsamples.Draw("RcorrJZBSBem",var,binning, "JZB [GeV]", "events",sidebandcut&&cutOSOF&&reducedNJets&&ONLYTau&&kPos,mc,simulatedlumi,systsamples.FindSample("/DY"));
3113 <    LcorrJZBSBem   = systsamples.Draw("LcorrJZBSBem",var,binning, "JZB [GeV]", "events",sidebandcut&&cutOSOF&&reducedNJets&&ONLYTau&&kNeg,mc,simulatedlumi,systsamples.FindSample("/DY"));
3114 <    RcorrJZBSBeemm = systsamples.Draw("RcorrJZBSBeemm",var,binning, "JZB [GeV]", "events",sidebandcut&&cutOSSF&&reducedNJets&&ONLYTau&&kPos,mc,simulatedlumi,systsamples.FindSample("/DY"));
3115 <    LcorrJZBSBeemm = systsamples.Draw("LcorrJZBSBeemm",var,binning, "JZB [GeV]", "events",sidebandcut&&cutOSSF&&reducedNJets&&ONLYTau&&kNeg,mc,simulatedlumi,systsamples.FindSample("/DY"));
3112 >    RcorrJZBSBem   = systsamples.Draw("RcorrJZBSBem",var,binning, "JZB [GeV]", "events",sidebandcut&&cutOSOF&&reducedNJets&&ee_mm_tautau&&kPos&&massregioncut,mc,simulatedlumi,systsamples.FindSample("/DY"));
3113 >    LcorrJZBSBem   = systsamples.Draw("LcorrJZBSBem",var,binning, "JZB [GeV]", "events",sidebandcut&&cutOSOF&&reducedNJets&&ee_mm_tautau&&kNeg&&massregioncut,mc,simulatedlumi,systsamples.FindSample("/DY"));
3114 >    RcorrJZBSBeemm = systsamples.Draw("RcorrJZBSBeemm",var,binning, "JZB [GeV]", "events",sidebandcut&&cutOSSF&&reducedNJets&&ee_mm_tautau&&kPos&&massregioncut,mc,simulatedlumi,systsamples.FindSample("/DY"));
3115 >    LcorrJZBSBeemm = systsamples.Draw("LcorrJZBSBeemm",var,binning, "JZB [GeV]", "events",sidebandcut&&cutOSSF&&reducedNJets&&ee_mm_tautau&&kNeg&&massregioncut,mc,simulatedlumi,systsamples.FindSample("/DY"));
3116    }
3117    
3118    TH1F *Bpred = (TH1F*)LcorrJZBeemm->Clone("Bpred");
# Line 3065 | Line 3130 | void zjets_prediction_comparison(string
3130    
3131    Bpred->SetLineColor(kRed);
3132  
3133 +  cout << __LINE__ << endl;
3134    TAUhJZBpos->SetLineColor(kBlack);
3135    Bpred->SetLineColor(kRed);
3136    
# Line 3078 | Line 3144 | void zjets_prediction_comparison(string
3144    TAUleg->AddEntry(Bpred,"Predicted","l");
3145    TAUleg->Draw("same");
3146    DrawMCPrelim(simulatedlumi);
3147 <  CompleteSave(zcan,"Systematics/ZJets/zjets_eemumutautau_prediction");
3147 >  CompleteSave(zcan,"Systematics/ZJets/zjets_eemumutautau_prediction__"+any2string(massregionname));
3148    
3149    TH1F* TAUhratio = (TH1F*)TAUhJZBpos->Clone("TAUhratio");
3150    TAUhratio->Divide(Bpred);
# Line 3096 | Line 3162 | void zjets_prediction_comparison(string
3162    center->Draw("same");
3163    bottom->Draw("same");
3164    
3165 <  TLegend *TAUleg2 = make_legend("MC Z+jets #rightarrow #tau#tau",0.25,0.75,false);
3165 >  TLegend *TAUleg2 = make_legend("MC Z+jets #rightarrow ee,#mu#mu",0.25,0.75,false);
3166    TAUleg2->AddEntry(TAUhratio,"obs / pred","pe");
3167    TAUleg2->AddEntry(bottom,"syst. envelope","l");
3168    TAUleg2->Draw("same");
3169    DrawMCPrelim(simulatedlumi);
3170 <  CompleteSave(zcan,"Systematics/ZJets/zjets_eemumutautau_prediction_ratio");
3170 >  CompleteSave(zcan,"Systematics/ZJets/zjets_eemumutautau_prediction_ratio"+any2string(massregionname));
3171    
3172    delete Bpred;
3173    delete TAUhJZBpos;
3174    delete LcorrJZBeemm;
3175    delete RcorrJZBem;
3176    delete LcorrJZBem;
3177 +  delete hJZBpos;
3178 +  delete hJZBneg;
3179    
3180    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
3181      delete RcorrJZBSBem;
# Line 3120 | Line 3188 | void zjets_prediction_comparison(string
3188    delete zcan;
3189    cutWeight=weightbackup;
3190  
3191 +  cout << __LINE__ << endl;
3192   }
3193  
3194  
3195 <
3195 > void zjets_prediction_comparison(string mcjzbWithPUa) {
3196 >  zjets_prediction_comparison(mcjzbWithPUa, TCut(""), "nomasscut");
3197 >  zjets_prediction_comparison(mcjzbWithPUa, TCut("abs(mll-91)<20"), "Zwindow_20");
3198 >  zjets_prediction_comparison(mcjzbWithPUa, TCut("mll>20&&mll<70"), "LowMassRegion2070");
3199 >  zjets_prediction_comparison(mcjzbWithPUa, TCut("mll>110"), "HighMassRegion110");
3200 > }
3201 >  
3202   void sideband_assessment(string datajzb, float min=30.0, float max=50.0) {
3203    tout << endl << endl;
3204    stringstream bordercut;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines