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.75 by buchmann, Tue Dec 4 12:31:52 2012 UTC vs.
Revision 1.86 by buchmann, Mon Feb 25 15:39:12 2013 UTC

# Line 87 | Line 87 | void find_one_peak_combination(TCut spec
87    delete tempcan;
88   }
89  
90 + void DoPeakVsPU() {
91 +  cout << "Trying to find peak position as a function of PU" << endl;
92 +  float MCPeak, MCPeakError, DataPeak, DataPeakError;
93 +  stringstream result, datajzb, mcjzb;
94 +  bool doPUreweighting=true;
95 +  bool SwitchOffNJetsCut=false;
96 +  
97 +  float mcSigma,mcSigmaError,dataSigma,dataSigmaError;
98 +  
99 +  float NumVtxBin[6] = {0,5,10,15,20,100};
100 +  
101 +  stringstream NowCut;
102 +  
103 +  TGraphErrors *gMCPeak = new TGraphErrors();
104 +  gMCPeak->SetTitle("gMCPeak");
105 +  TGraphErrors *gDataPeak = new TGraphErrors();
106 +  gDataPeak->SetTitle("gDataPeak");
107 +  TGraphErrors *gMCWidth = new TGraphErrors();
108 +  gMCWidth->SetTitle("gMCWidth");
109 +  TGraphErrors *gDataWidth = new TGraphErrors();
110 +  gDataWidth->SetTitle("gDataWidth");
111 +  
112 +  
113 +  for(int i=0;i<5;i++) {
114 +    NowCut.str("");
115 +    NowCut << "numVtx>=" << NumVtxBin[i] << "&&numVtx<" << NumVtxBin[i+1];
116 +    find_one_peak_combination(TCut(NowCut.str().c_str()),SwitchOffNJetsCut,MCPeak,MCPeakError, DataPeak,DataPeakError,mcSigma,mcSigmaError, dataSigma,dataSigmaError,result,doPUreweighting,"");
117 +    cout << "    " << MCPeak << " +/- " << MCPeakError << endl;
118 +    cout << "    " << DataPeak << " +/- " << DataPeakError << endl;
119 +    
120 +    gMCPeak->SetPoint(i,0.5*(NumVtxBin[i]+NumVtxBin[i+1]),MCPeak);
121 +    gMCPeak->SetPointError(i,0.5*(NumVtxBin[i+1]-NumVtxBin[i]),MCPeakError);
122 +    
123 +    gDataPeak->SetPoint(i,0.5*(NumVtxBin[i]+NumVtxBin[i+1]),DataPeak);
124 +    gDataPeak->SetPointError(i,0.5*(NumVtxBin[i+1]-NumVtxBin[i]),DataPeakError);
125 +    
126 +    gMCWidth->SetPoint(i,0.5*(NumVtxBin[i]+NumVtxBin[i+1]),mcSigma);
127 +    gMCWidth->SetPointError(i,0.5*(NumVtxBin[i+1]-NumVtxBin[i]),mcSigmaError);
128 +    
129 +    gDataWidth->SetPoint(i,0.5*(NumVtxBin[i]+NumVtxBin[i+1]),dataSigma);
130 +    gDataWidth->SetPointError(i,0.5*(NumVtxBin[i+1]-NumVtxBin[i]),dataSigmaError);
131 +  }
132 +  
133 +  TFile *fo = new TFile("fout.root","RECREATE");
134 +  gMCPeak->Write();
135 +  gDataPeak->Write();
136 +  gMCWidth->Write();
137 +  gDataWidth->Write();
138 +  fo->Close();
139 +  
140 + }
141 +
142   void find_peaks(float &MCPeak,float &MCPeakError, float &DataPeak, float &DataPeakError, stringstream &result, bool doPUreweighting, stringstream &datajzb, stringstream &mcjzb, string sSpecialCut="", bool SwitchOffNJetsCut=false)
143   {
144    bool overunderflowstatus=addoverunderflowbins;
# Line 228 | Line 280 | void make_special_obs_pred_mll_plot(stri
280    
281    RcorrJZBeemm->SetTitleOffset(1.3,"y");
282    RcorrJZBeemm->Draw();
283 <  mcRcorrJZBeemm.Draw("same");
283 >  mcRcorrJZBeemm.Draw("histo,same");
284    Bpred->Draw("histo,same");
285    RcorrJZBeemm->Draw("same");
286    
# Line 285 | Line 337 | void make_special_obs_pred_mll_plot(stri
337    }
338    delete Bpred;
339    delete ckin;
340 +  CleanLegends();
341   }
342  
343   void make_special_mll_plot(int nbins, float min, float max, bool logscale,string xlabel) {
# Line 331 | Line 384 | void make_special_mll_plot(int nbins, fl
384    delete datahistoOSOF;
385    delete datahistoOSSF;
386    delete ckin;
387 +  CleanLegends();
388   }
389    
390  
# Line 384 | Line 438 | float make_one_OFSF_plot(string variable
438  
439    cutOF = cutOSOF&&cutnJets&&ibasiccut;
440    cutSF = cutOSSF&&cutnJets&&ibasiccut;
441 +  
442 +  TCanvas *ofsf_can = new TCanvas("ofsf_can","ofsf_can");
443  
388  TCanvas *ckin = new TCanvas("ckin","Kinematic Plots (in the making)",600,600);
444    TPad* rcan = new TPad("rcan","rcan",0,0,1,1);
445    rcan->SetLogy(logscale);
446    rcan->cd();
# Line 410 | Line 465 | float make_one_OFSF_plot(string variable
465    }
466    if (ymax<0) {
467      if ( logscale ) datahistoSF->SetMaximum(5.3*datahistoSF->GetMaximum());
468 <    else datahistoSF->SetMaximum(1.8*datahistoSF->GetMaximum());
468 >    else datahistoSF->SetMaximum(0.8*datahistoSF->GetMaximum());
469    } else {
470      datahistoSF->SetMaximum(ymax);
471    }
# Line 437 | Line 492 | float make_one_OFSF_plot(string variable
492    mleg->Draw();
493    DrawPrelim();
494    if (datahistoOF->Integral()>0) {
495 <    save_with_ratio( datahistoSF, datahistoOF, rcan, "SFOF/" + filename, false, false, "SF/OF" );
495 >    Save_With_Ratio( datahistoSF, datahistoOF, rcan, "SFOF/" + filename, false, false, "SF/OF" );
496    } else {
497      CompleteSave(rcan, "SFOF/" + filename);
443    delete rcan;
498    }
499  
500    datahistoSF->Delete();
501    datahistoOF->Delete();
502    //signalhisto->Delete();
503    delete mleg;
504 <  delete ckin;
504 >  delete rcan;
505 >  delete ofsf_can;
506  
507    return ymaxSet;
508  
# Line 500 | Line 555 | float make_data_comparison_plot(string v
555    data2->Draw("HIST,SAMES");
556    mleg->Draw();
557    DrawPrelim();
558 <  save_with_ratio( data1, data2, rcan, "compareData/" + filename, false, false, "new/old" );
558 >  Save_With_Ratio( data1, data2, rcan, "compareData/" + filename, false, false, "new/old" );
559  
560    data1->Delete();
561    data2->Delete();
562    delete mleg;
563 +  delete rcan;
564    delete ckin;
565  
566   }
# Line 537 | Line 593 | void make_OFSF_plots(string variable, st
593  
594   }
595  
596 + TCut ReplaceInCut(TCut cut, string replacethis, string withthis) {
597 +  string scut=(string)(const char*)cut;
598 +  string acut=ReplaceAll(scut,replacethis,withthis);
599 +  return TCut(acut.c_str());
600 + }
601 +
602 + void DoMCSystPlot(string datavariable, string mcvariable, int nbins, float min, float max, TCut addcut, bool dolog, string xlabel, string filename) {
603 +  TCut cut=addcut&&basiccut;
604 +
605 +  TCanvas *ckin = new TCanvas("ckin","Kinematic Plots (in the making)",600,600);
606 +  ckin->SetLogy(dolog);
607 +  cout << "\r Creating " << filename << " : data   (1/6)" << std::flush;
608 +  TH1F *datahisto = allsamples.Draw("datahisto",datavariable,nbins,min,max, xlabel, "events",cut,data,luminosity);
609 +  datahisto->SetMarkerSize(DataMarkerSize);
610 +  if ( !dolog ) datahisto->SetMinimum(0); // Defaults
611 +  else datahisto->SetMinimum(0.5);
612 +  if (dolog) datahisto->SetMaximum(5.3*datahisto->GetMaximum());
613 +  else datahisto->SetMaximum(1.3*datahisto->GetMaximum());
614 +  cout << "\r Creating " << filename << " : MC central   (2/6)" << std::flush;
615 +  THStack mcstack   = allsamples.DrawStack("mcstack",  mcvariable,nbins,min,max,xlabel,"events",cut,mc,luminosity);
616 +  TH1F *MCcentral = CollapseStack(mcstack);
617 +
618 +  TCut bkpcut = cut;
619 +  cut = ReplaceInCut(cut,"pfJetGoodNum40","pfJetGoodNum40p1sigma");
620 +  cout << "\r Creating " << filename << " : MC JES up   (3/6)" << std::flush;
621 +  TH1F *MCJESup   = allsamples.Draw("MCJESup",  mcvariable,nbins,min,max,xlabel,"events",cut,mc,luminosity);
622 +
623 +  cut = ReplaceInCut(cut,"pfJetGoodNum40p1sigma","pfJetGoodNum40n1sigma");
624 +  cout << "\r Creating " << filename << " : MC JES down   (4/6)" << std::flush;
625 +  TH1F *MCJESdn   = allsamples.Draw("MCJESdn",  mcvariable,nbins,min,max,xlabel,"events",cut,mc,luminosity);
626 +  
627 +  cut=bkpcut;
628 +  TCut bkpweight = cutWeight;
629 +  cutWeight= ReplaceInCut(cutWeight,"weight","PUweightUP");
630 +  cout << "\r Creating " << filename << " : MC PU up   (5/6)" << std::flush;
631 +  TH1F *MCPUup    = allsamples.Draw("MCPUup",   mcvariable,nbins,min,max,xlabel,"events",cut,mc,luminosity);
632 +  
633 +  cutWeight= ReplaceInCut(cutWeight,"PUweightUP","PUweightDOWN");
634 +  cout << "\r Creating " << filename << " : MC PU down   (6/6)" << std::flush;
635 +  TH1F *MCPUdn    = allsamples.Draw("MCPUdn",   mcvariable,nbins,min,max,xlabel,"events",cut,mc,luminosity);
636 +  cutWeight=bkpweight;
637 +  cout << "\r Creating " << filename << " : Processing systematics ..." << std::flush;
638 +  TH1F *Systematic = (TH1F*)MCPUdn->Clone("Systematic");
639 +  for(int i=1;i<=Systematic->GetNbinsX();i++) {
640 +    float jesdn = abs(MCcentral->GetBinContent(i)-MCJESdn->GetBinContent(i));
641 +    float jesup = abs(MCcentral->GetBinContent(i)-MCJESup->GetBinContent(i));
642 +    float jes   = jesdn>jesup?jesdn:jesup;
643 +    
644 +    float PUup = abs(MCcentral->GetBinContent(i)-MCPUup->GetBinContent(i));
645 +    float PUdn = abs(MCcentral->GetBinContent(i)-MCPUdn->GetBinContent(i));
646 +    float pu   = PUdn>PUup?PUdn:PUup;
647 +    
648 +    float sys=sqrt(jes*jes+pu*pu);
649 +    sys/=MCcentral->GetBinContent(i);
650 +    if(MCcentral->GetBinContent(i)==0) sys=0;
651 +    Systematic->SetBinContent(i,sys);
652 +  }
653 +  
654 +  datahisto->Draw("e1");
655 +  ckin->Update();
656 +  mcstack.Draw("histo,same");
657 +  
658 +  datahisto->Draw("same,e1");
659 +  TLegend *kinleg = allsamples.allbglegend();
660 +  kinleg->Draw();
661 +
662 +  TPad *kinpad = new TPad("kinpad","kinpad",0,0,1,1);
663 +  kinpad->SetLogy(dolog);
664 +  kinpad->cd();
665 +  datahisto->Draw("e1");
666 +  mcstack.Draw("histo,same");
667 +  datahisto->Draw("same,e1");
668 +  datahisto->Draw("same,axis");
669 +  
670 +  kinleg->Draw("same");
671 +  DrawPrelim();
672 +  string saveas="kin/"+filename;
673 +  
674 +  cout << "Passing filename to be saved : " << filename << " as " << saveas << endl;
675 +  save_with_ratio_and_sys_band( datahisto, CollapseStack(mcstack), kinpad->cd(), saveas, false, false, "data/mc",Systematic );
676 +  
677 +  ckin->cd();
678 +  MCcentral->SetFillColor(kWhite);
679 +  MCcentral->SetLineColor(kBlack);
680 +  MCcentral->SetLineWidth(2);
681 +  MCPUdn->SetLineColor(kRed);
682 +  MCPUup->SetLineColor(kYellow);
683 +  MCJESdn->SetLineColor(kBlue);
684 +  MCJESup->SetLineColor(kGreen);
685 +  
686 +  TLegend *legsmall = new TLegend(0.0,0.85,1.0,1.00);
687 +  legsmall->SetNColumns(5);
688 +  legsmall->AddEntry(MCcentral,"central","L");
689 +  legsmall->AddEntry(MCPUdn,"PU down","L");
690 +  legsmall->AddEntry(MCPUup,"PU up","L");
691 +  legsmall->AddEntry(MCJESdn,"JES down","L");
692 +  legsmall->AddEntry(MCJESup,"JES up","L");
693 +  legsmall->SetFillColor(kWhite);
694 +  legsmall->SetBorderSize(0);
695 +  
696 +  datahisto->Draw("e1");
697 +  MCcentral->Draw("histo,same");
698 +  MCPUdn->Draw("histo,same");
699 +  MCPUup->Draw("histo,same");
700 +  MCJESdn->Draw("histo,same");
701 +  MCJESup->Draw("histo,same");
702 +  datahisto->Draw("e1,same");
703 +  legsmall->Draw();
704 +  CompleteSave(ckin,saveas+"___AllLines");
705 +  
706 +  delete datahisto;
707 +  delete MCcentral;
708 +  delete MCPUdn;
709 +  delete MCPUup;
710 +  delete MCJESdn;
711 +  delete MCJESup;
712 +  delete ckin;
713 + }
714  
715 + void DoMCSystPlot(string variable, int nbins, float min, float max, TCut addcut, bool dolog, string xlabel, string filename) {
716 +  DoMCSystPlot(variable, variable, nbins, min, max, addcut, dolog, xlabel, filename);
717 + }
718 +  
719   float lastrange_min=0;
720   float lastrange_max=0;
721  
# Line 688 | Line 866 | void make_kin_plot(string variable, stri
866          DrawPrelim();
867          string saveas="kin/"+filename;
868          if(isPF) saveas="kin/"+filename+"__PF";
869 <        save_with_ratio(datahisto,mcstack,kinpad->cd(),saveas);
869 >        Save_With_Ratio(datahisto,mcstack,kinpad->cd(),saveas);
870   //      if(isPF) CompleteSave(with_ratio,"kin/"+filename+"__PF_withratio");
871   //      else CompleteSave(with_ratio,"kin/"+filename+"_withratio");
872   //      delete with_ratio;
# Line 751 | Line 929 | void make_plain_kin_plot(string variable
929          DrawPrelim();
930          string saveas="kin/"+filename;
931          if(isPF) saveas="kin/"+filename+"__PF";
932 <        save_with_ratio(datahisto,mcstack,kinpad->cd(),saveas);
932 >        Save_With_Ratio(datahisto,mcstack,kinpad->cd(),saveas);
933    } else {
934          if(isPF) CompleteSave(ckin,"kin/"+filename+"__PF");
935          else CompleteSave(ckin,"kin/"+filename);
# Line 803 | Line 981 | void make_JES_plot(TCut cut, string name
981    CompleteSave(ckin,"Systematics/JES"+name);
982    datahisto->Delete();
983    delete ckin;
984 <
984 >  delete JESunc;
985 >  delete JESup;
986 >  delete JESdn;
987 >  CleanLegends();
988   }
989  
990   string Cut2Str(TCut cut) {
# Line 843 | Line 1024 | void MakeElegantTwoThreeComparisons() {
1024      leg_SFOF_Two->AddEntry(TwoOF,"OF, nJets==2","l");
1025      leg_SFOF_Two->AddEntry(TwoSF,"SF, nJets==2","lp");
1026      leg_SFOF_Two->Draw();
1027 <    save_with_ratio(TwoSF,TwoOF,kin3->cd(),"DoubleRatios/SFOF_Two");
1027 >    Save_With_Ratio(TwoSF,TwoOF,kin3->cd(),"DoubleRatios/SFOF_Two");
1028      
1029      TPad *kin4 = new TPad("kin4","kin4",0,0,1,1);
1030      kin4->cd();
# Line 854 | Line 1035 | void MakeElegantTwoThreeComparisons() {
1035      leg_SFOF_Three->AddEntry(TwoOF,"OF, nJet#geq3","l");
1036      leg_SFOF_Three->AddEntry(TwoSF,"SF, nJets#geq3","lp");
1037      leg_SFOF_Three->Draw();
1038 <    save_with_ratio(ThreeSF,ThreeOF,kin4->cd(),"DoubleRatios/SFOF_Three");
1038 >    Save_With_Ratio(ThreeSF,ThreeOF,kin4->cd(),"DoubleRatios/SFOF_Three");
1039      
1040      
1041      TwoSF->Scale(ThreeSF->Integral()/TwoSF->Integral());
# Line 867 | Line 1048 | void MakeElegantTwoThreeComparisons() {
1048      leg_SF_Two_Three->AddEntry(TwoSF,"#splitline{SF, nJets==2}{ (scaled)}","l");
1049      leg_SF_Two_Three->AddEntry(ThreeSF,"SF, nJets#geq3","lp");
1050      leg_SF_Two_Three->Draw();
1051 <    save_with_ratio(TwoSF,ThreeSF,kin->cd(),"DoubleRatios/SF_Two_Three");
1051 >    Save_With_Ratio(TwoSF,ThreeSF,kin->cd(),"DoubleRatios/SF_Two_Three");
1052      
1053      TwoOF->Scale(ThreeOF->Integral()/TwoOF->Integral());
1054      TPad *kin2 = new TPad("kin2","kin2",0,0,1,1);
# Line 879 | Line 1060 | void MakeElegantTwoThreeComparisons() {
1060      leg_OF_Two_Three->AddEntry(TwoSF,"#splitline{OF, nJets==2}{ (scaled)}","l");
1061      leg_OF_Two_Three->AddEntry(ThreeSF,"OF, nJets#geq3","lp");
1062      leg_OF_Two_Three->Draw();
1063 <    save_with_ratio(TwoOF,ThreeOF,kin2->cd(),"DoubleRatios/OF_Two_Three");
1063 >    Save_With_Ratio(TwoOF,ThreeOF,kin2->cd(),"DoubleRatios/OF_Two_Three");
1064 >    
1065 > }
1066 >
1067 > void PresentRange(TH1F *Down, TH1F *Up, TH1F *central, TVirtualPad *pad, string title) {
1068 >  pad->cd();
1069 >  TGraphErrors *gr = new TGraphErrors(Down->GetNbinsX());
1070 >  for(int i=1;i<=Down->GetNbinsX();i++) {
1071 >    float average=0.5*(Down->GetBinContent(i)+Up->GetBinContent(i));
1072 >    float error=abs(Down->GetBinContent(i)-average);
1073 >    gr->SetPoint(i-1,Down->GetBinCenter(i),average);
1074 >    gr->SetPointError(i-1,Down->GetBinWidth(i)/2.0,error);
1075 >  }
1076 >  gr->SetFillColor(TColor::GetColor("#F79F81"));
1077 >  gr->GetYaxis()->SetRangeUser(0,2);
1078 >  gr->GetXaxis()->SetTitle(central->GetXaxis()->GetTitle());
1079 >  gr->GetYaxis()->SetTitle(central->GetYaxis()->GetTitle());
1080 >  gr->GetXaxis()->CenterTitle();
1081 >  gr->GetYaxis()->CenterTitle();
1082 >  
1083 >  gr->Draw("A2");
1084 >  central->Draw("e1,same");
1085 >  DrawMCPrelim();
1086 >  TText *rtitle = write_text(0.8,0.8,title);
1087 >  TLine *line = new TLine(Down->GetBinLowEdge(1),1.0,Down->GetBinLowEdge(Down->GetNbinsX())+Down->GetBinWidth(Down->GetNbinsX()),1.0);
1088 >  line->SetLineColor(kBlue);
1089 >  line->SetLineStyle(2);
1090 >  line->Draw("same");
1091 >  rtitle->Draw("same");
1092 > }
1093 >
1094 > TH1F* ProduceTTbarRatio(TH1F *datahisto, TH1F *fullmc, TH1F *originalttbar, TH1F *httbar) {
1095 >  TH1F *basehisto = (TH1F*)fullmc->Clone("basehisto");
1096 >  basehisto->Add(originalttbar,-1);
1097 >  basehisto->Add(httbar);
1098 >  
1099 >  string sname=httbar->GetName();
1100 >  sname="R"+sname.substr(1,sname.length());
1101 >  TH1F *ratio = (TH1F*)datahisto->Clone(sname.c_str());
1102 >  ratio->Divide(basehisto);
1103 >  delete basehisto;
1104 >  return ratio;
1105 > }
1106 >  
1107 > void make_ttbar_comparison(string datavariable, string mcvariable, int nbins, float min, float max, TCut addcut, bool dolog, string xlabel, string filename) {
1108 >  
1109 >  TCut cut=addcut&&basiccut;
1110 >  
1111 >  TCanvas *ckin = new TCanvas("ckin","Kinematic Plots (in the making)",600,600);
1112 >  ckin->SetLogy(dolog);
1113 >  cout << "\r Creating " << filename << " : data   (1/7)" << std::flush;
1114 >  TH1F *datahisto = allsamples.Draw("datahisto",datavariable,nbins,min,max, xlabel, "events",cut,data,luminosity);
1115 >  datahisto->SetMarkerSize(DataMarkerSize);
1116 >  if ( !dolog ) datahisto->SetMinimum(0); // Defaults
1117 >  else datahisto->SetMinimum(0.5);
1118 >  if (dolog) datahisto->SetMaximum(5.3*datahisto->GetMaximum());
1119 >  else datahisto->SetMaximum(1.3*datahisto->GetMaximum());
1120 >  cout << "\r Creating " << filename << " : MC central  (stack) (2/7)" << std::flush;
1121 >  THStack mcstack   = allsamples.DrawStack("mcstack",  mcvariable,nbins,min,max,xlabel,"events",cut,mc,luminosity);
1122 >  TH1F *MCcentral = CollapseStack(mcstack);
1123 >
1124 >  cout << "\r Creating " << filename << " : MC central (histo)   (3/7)" << std::flush;
1125 >  TH1F *TCentral        = allsamples.Draw ("TCentral",     mcvariable,nbins,min,max,xlabel,"events",cut,mc,luminosity,allsamples.FindSample("TTJets_"));
1126 >  TH1F *RCentral        = ProduceTTbarRatio(datahisto,MCcentral,TCentral,TCentral);
1127 >  
1128 >  cout << "\r Creating " << filename << " : MC Matching up   (4/7)" << std::flush;
1129 >  TH1F *TMatchingUp     = systsamples.Draw("TMatchingUp",  mcvariable,nbins,min,max,xlabel,"events",cut,mc,luminosity,systsamples.FindSample("TTJets_matchingup"));
1130 >  TH1F *RMatchingUp     = ProduceTTbarRatio(datahisto,MCcentral,TCentral,TMatchingUp);
1131 >  
1132 >  cout << "\r Creating " << filename << " : MC Matching down   (5/7)" << std::flush;
1133 >  TH1F *TMatchingDown   = systsamples.Draw("TMatchingDown",mcvariable,nbins,min,max,xlabel,"events",cut,mc,luminosity,systsamples.FindSample("TTJets_matchingdown"));
1134 >  TH1F *RMatchingDown   = ProduceTTbarRatio(datahisto,MCcentral,TCentral,TMatchingDown);
1135 >  
1136 >  cout << "\r Creating " << filename << " : MC Scale up   (6/7)" << std::flush;
1137 >  TH1F *TScaleUp        = systsamples.Draw("TScaleUp",     mcvariable,nbins,min,max,xlabel,"events",cut,mc,luminosity,systsamples.FindSample("TTJets_scaleup"));
1138 >  TH1F *RScaleUp        = ProduceTTbarRatio(datahisto,MCcentral,TCentral,TScaleUp);
1139 >  
1140 >  cout << "\r Creating " << filename << " : MC Scale down   (7/7)" << std::flush;
1141 >  TH1F *TScaleDown      = systsamples.Draw("TScaleDown",   mcvariable,nbins,min,max,xlabel,"events",cut,mc,luminosity,systsamples.FindSample("TTJets_scaledown"));
1142 >  TH1F *RScaleDown      = ProduceTTbarRatio(datahisto,MCcentral,TCentral,TScaleDown);
1143 >  
1144 >  datahisto->Draw("e1");
1145 >  ckin->Update();
1146 >  mcstack.Draw("histo,same");
1147 >  
1148 >  datahisto->Draw("same,e1");
1149 >  TLegend *kinleg = allsamples.allbglegend();
1150 >  kinleg->Draw();
1151 >
1152 >  TPad *kinpad = new TPad("kinpad","kinpad",0,0,1,1);
1153 >  kinpad->SetLogy(dolog);
1154 >  kinpad->cd();
1155 >  datahisto->Draw("e1");
1156 >  mcstack.Draw("histo,same");
1157 >  datahisto->Draw("same,e1");
1158 >  datahisto->Draw("same,axis");
1159 >  
1160 >  kinleg->Draw("same");
1161 >  DrawPrelim();
1162 >  string saveas="kin/"+filename;
1163 >  
1164 >  cout << "Passing filename to be saved : " << filename << " as " << saveas << endl;
1165 >  Save_With_Ratio( datahisto, CollapseStack(mcstack), kinpad->cd(), saveas, false, false, "data/mc");
1166 >  delete kinpad;
1167 >  
1168 >  ckin->cd();
1169 >  TCentral->SetLineColor(kBlack);
1170 >  
1171 >  TMatchingUp->SetLineColor(TColor::GetColor("#2c17b1"));//blue
1172 >  TMatchingUp->SetLineStyle(2);//dashed
1173 >  TMatchingDown->SetLineColor(TColor::GetColor("#2c17b1"));
1174 >  TMatchingDown->SetLineStyle(3);//dotted
1175 >  
1176 >  TScaleUp->SetLineColor(TColor::GetColor("#FF8500"));//orange
1177 >  TScaleUp->SetLineStyle(2);//dashed
1178 >  TScaleDown->SetLineColor(TColor::GetColor("#FF8500"));
1179 >  TScaleDown->SetLineStyle(3);//dotted
1180 >  
1181 >  MCcentral->SetLineStyle(3);
1182 >  MCcentral->SetLineColor(kRed);
1183 >  
1184 >  TCentral->Draw("e1,same");
1185 >  TCentral->Draw("histo,same");
1186 >  TMatchingUp->Draw("histo,same");
1187 >  TMatchingDown->Draw("histo,same");
1188 >  TScaleUp->Draw("histo,same");
1189 >  TScaleDown->Draw("histo,same");
1190 >  
1191 >  TLegend *sleg = make_legend();
1192 >  sleg->AddEntry(TCentral,"Central","L");
1193 >  sleg->AddEntry(TMatchingUp,"matching up","L");
1194 >  sleg->AddEntry(TMatchingDown,"matching down","L");
1195 >  sleg->AddEntry(TScaleUp,"scale up","L");
1196 >  sleg->AddEntry(TScaleDown,"scale down","L");
1197 >  sleg->Draw();
1198 >  
1199 >  CompleteSave(ckin,saveas+"___AllLines");
1200 >  ckin->cd();
1201 >  ckin->SetLogy(0);
1202 >  
1203 >  RCentral->SetLineColor(kBlack);
1204 >  
1205 >  RMatchingUp->SetLineColor(TColor::GetColor("#2c17b1"));//blue
1206 >  RMatchingUp->SetLineStyle(2);//dashed
1207 >  RMatchingDown->SetLineColor(TColor::GetColor("#2c17b1"));
1208 >  RMatchingDown->SetLineStyle(3);//dotted
1209 >  
1210 >  RScaleUp->SetLineColor(TColor::GetColor("#FF8500"));//orange
1211 >  RScaleUp->SetLineStyle(2);//dashed
1212 >  RScaleDown->SetLineColor(TColor::GetColor("#FF8500"));
1213 >  RScaleDown->SetLineStyle(3);//dotted
1214 >  
1215 >  RCentral->GetYaxis()->SetRangeUser(0,2);
1216 >  RCentral->Draw("e1");
1217 >  RMatchingUp->Draw("histo,same");
1218 >  RMatchingDown->Draw("histo,same");
1219 >  RScaleUp->Draw("histo,same");
1220 >  RScaleDown->Draw("histo,same");
1221 >  
1222 >  CompleteSave(ckin,saveas+"___AllRatios");
1223 >
1224 >  TCanvas *multicanvas = new TCanvas("multicanvas","multicanvas",1400,700);
1225 >  multicanvas->Divide(2,1);
1226 >  PresentRange(RMatchingUp,RMatchingDown,RCentral,multicanvas->cd(1),"Matching");
1227 >  PresentRange(RScaleUp,RScaleDown,RCentral,multicanvas->cd(2),"Scale");
1228 >  CompleteSave(multicanvas,saveas+"___RangeIllustration");
1229 >  
1230 >  
1231 >  delete datahisto;
1232 >  delete   TCentral;
1233 >  delete   TMatchingUp;
1234 >  delete   TMatchingDown;
1235 >  delete   TScaleUp;
1236 >  delete   TScaleDown;
1237 > //   delete   Ttmass166;
1238 > //   delete   Ttmass169;
1239 > //   delete   Ttmass175;
1240 > //   delete   Ttmass178;
1241 >  
1242 >  delete ckin;
1243 >  
1244 > }
1245 >  
1246 > void make_ttbar_comparison(string variable, int nbins, float min, float max, TCut addcut, bool dolog, string xlabel, string filename) {
1247 >  make_ttbar_comparison(variable, variable, nbins, min, max, addcut, dolog, xlabel, filename);
1248 > }
1249 >
1250 > void ProduceJanPlots() {
1251 >  TCanvas *c1 = new TCanvas("c1","c1");
1252 >  TH1F *metSF = allsamples.Draw("metSF","met[4]",30,100,400, "E_{T}^{miss} [GeV]", "events", cutmass&&cutOSSF&&cutnJets,data, luminosity);
1253 >  TH1F *metOF = allsamples.Draw("metOF","met[4]",30,100,400, "E_{T}^{miss} [GeV]", "events", cutmass&&cutOSOF&&cutnJets,data, luminosity);
1254 >  
1255 >  TPad* rcan = new TPad("rcan","rcan",0,0,1,1);
1256 >  rcan->cd();
1257 >
1258 >  metOF->SetLineColor(kRed);
1259 >  metSF->Draw("e1");
1260 >  metOF->Draw("histo,same");
1261 >  metSF->Draw("e1,same");
1262 >  
1263 >  TLegend *leg = make_legend();
1264 >  
1265 >  leg->AddEntry(metSF,"Data SF","p");
1266 >  leg->AddEntry(metOF,"Data OF","l");
1267 >  leg->Draw();
1268 >  
1269 >  DrawPrelim();
1270 >  
1271 >  Save_With_Ratio(metSF,metOF,rcan,"JanPlots/ETHConfig",false,false,"SF/OF");
1272 >  
1273 >  delete rcan;
1274 >  delete metSF;
1275 >  delete metOF;
1276 >  delete c1;
1277 > }
1278 >
1279 > THStack MakeOneSystematicsPlot(TCut cut, string saveas, string variation, TH1F *hdata, string variable, int nbins, float bmin, float bmax, string label, TH1F* &thisto) {
1280 >  THStack SystPlot = allsamples.DrawStack(variation,variable,nbins,bmin,bmax,label,"events",cut,mc,PlottingSetup::luminosity);
1281 >  
1282 >  //now need to process the plot (calculate the variation and set the member of thstack accordingly!)
1283 >  if(variation!="Central") {
1284 >    TH1F *varttbar;
1285 >    if(variation=="MatchingUp") varttbar = systsamples.Draw("varttbar",variable,nbins,bmin,bmax,label,"events",cut,mc,PlottingSetup::luminosity,systsamples.FindSample("TTJets_matchingup_TuneZ2s"));
1286 >    if(variation=="MatchingDown") varttbar = systsamples.Draw("varttbar",variable,nbins,bmin,bmax,label,"events",cut,mc,PlottingSetup::luminosity,systsamples.FindSample("TTJets_matchingdown"));
1287 >    if(variation=="ScaleUp") varttbar = systsamples.Draw("varttbar",variable,nbins,bmin,bmax,label,"events",cut,mc,PlottingSetup::luminosity,systsamples.FindSample("TTJets_scaleup"));
1288 >    if(variation=="ScaleDown") varttbar = systsamples.Draw("varttbar",variable,nbins,bmin,bmax,label,"events",cut,mc,PlottingSetup::luminosity,systsamples.FindSample("TTJets_scaledown"));
1289 >    assert(varttbar);
1290 >    
1291 >    TIter nextHisto(SystPlot.GetHists());
1292 >    TH1F* h;
1293 >    while ( h = (TH1F*)nextHisto() ) {
1294 >      if(Contains(h->GetName(),"t_bar_t")) {
1295 >        varttbar->Scale(h->Integral()/varttbar->Integral());
1296 >        for(int i=0;i<=h->GetNbinsX()+1;i++) {//note that we deliberatly consider the under/overflow bin as well!
1297 >          h->SetBinContent(i,varttbar->GetBinContent(i));
1298 >          h->SetBinError(i,varttbar->GetBinError(i));
1299 >        }
1300 >        thisto=(TH1F*)varttbar->Clone(variation.c_str());
1301 >        SystPlot.Modified();
1302 >      }
1303 >    }
1304 >    delete varttbar;
1305 >  } else {
1306 >    TIter nextHisto(SystPlot.GetHists());
1307 >    TH1F* h;
1308 >    while ( h = (TH1F*)nextHisto() ) {
1309 >      if(Contains(h->GetName(),"t_bar_t")) thisto=(TH1F*)h->Clone(variation.c_str());
1310 >    }
1311 >  }
1312      
1313 +  TLegend *fullleg = allsamples.allbglegend();
1314 +  fullleg->SetHeader(variation.c_str());
1315 +  TPad *kinpad = new TPad("kinpad","kinpad",0,0,1,1);
1316 +  kinpad->SetLogy(1);
1317 +  kinpad->cd();
1318 +  
1319 +  hdata->Draw("e1");
1320 +  SystPlot.Draw("histo,same");
1321 +  hdata->Draw("e1,same");
1322 +  fullleg->Draw();
1323 +  DrawPrelim();
1324 +  
1325 +  Save_With_Ratio(hdata,SystPlot,kinpad,saveas+"_"+variation);
1326 +  CleanLegends();
1327 +  
1328 +  delete kinpad;
1329 +  return SystPlot;
1330   }
1331 +  
1332 +
1333  
1334 + void ProduceMCSystematicPlot(string variable, int nbins, float bmin, float bmax, string label, TCut thiscut, string saveas) {
1335 +  TCanvas *ca = new TCanvas("ca","ca");
1336 +  TH1F *hdata = allsamples.Draw("hdata",variable,nbins,bmin,bmax,label,"events",thiscut,data,luminosity);
1337 +  
1338 +  TH1F *tScaleUp,*tScaleDown,*tMatchingUp,*tMatchingDown,*tCentral;
1339 +  
1340 +  THStack ScaleUp      = MakeOneSystematicsPlot(thiscut,saveas,"ScaleUp",hdata,variable, nbins, bmin, bmax, label,tScaleUp);
1341 +  THStack ScaleDown    = MakeOneSystematicsPlot(thiscut,saveas,"ScaleDown",hdata,variable, nbins, bmin, bmax, label,tScaleDown);
1342 +  THStack MatchingUp   = MakeOneSystematicsPlot(thiscut,saveas,"MatchingUp",hdata,variable, nbins, bmin, bmax, label,tMatchingUp);
1343 +  THStack MatchingDown = MakeOneSystematicsPlot(thiscut,saveas,"MatchingDown",hdata,variable, nbins, bmin, bmax, label,tMatchingDown);
1344 +  
1345 +  TH1F *HScaleUp = CollapseStack(ScaleUp);
1346 +  TH1F *HScaleDown = CollapseStack(ScaleDown);
1347 +  TH1F *HMatchingUp = CollapseStack(MatchingUp);
1348 +  TH1F *HMatchingDown = CollapseStack(MatchingDown);
1349 +  
1350 +  THStack Central = MakeOneSystematicsPlot(thiscut,saveas,"Central",hdata,variable, nbins, bmin, bmax, label,tCentral);
1351 +  TH1F *HCentral = CollapseStack(Central);
1352 +  
1353 +  TH1F *Systematic = (TH1F*)hdata->Clone("Systematic");
1354 +  for(int i=1;i<=Systematic->GetNbinsX();i++) {
1355 +    float matchingup   = abs(HMatchingUp->GetBinContent(i)-HCentral->GetBinContent(i));
1356 +    float matchingdown = abs(HMatchingDown->GetBinContent(i)-HCentral->GetBinContent(i));
1357 +    float scaleup   = abs(HScaleUp->GetBinContent(i)-HCentral->GetBinContent(i));
1358 +    float scaledown = abs(HScaleDown->GetBinContent(i)-HCentral->GetBinContent(i));
1359 +    
1360 +    float matching = matchingup>matchingdown?matchingup:matchingdown;
1361 +    float scale    = scaleup>scaledown?scaleup:scaledown;
1362 +    
1363 +    float sys=sqrt(matching*matching+scale*scale);
1364 +    sys/=HCentral->GetBinContent(i);
1365 +    if(HCentral->GetBinContent(i)==0) sys=0;
1366 +    Systematic->SetBinContent(i,sys);
1367 +  }
1368 +  
1369 +  TPad *kinpad = new TPad("kinpad","kinpad",0,0,1,1);
1370 +  kinpad->SetLogy(1);
1371 +  kinpad->cd();
1372 +  if(variable=="genMET") {
1373 +    Central.Draw("histo");
1374 +  } else {
1375 +    hdata->Draw("e1");
1376 +    Central.Draw("histo,same");
1377 +    hdata->Draw("e1,same");
1378 +  }
1379 +  
1380 +  DrawPrelim();
1381 +  
1382 +  save_with_ratio_and_sys_band( hdata, HCentral, kinpad->cd(), saveas, false, false, "data/mc",Systematic );
1383 +  
1384 +  kinpad->cd();
1385 +  tCentral->SetFillColor(kWhite);
1386 +  tCentral->SetLineColor(kBlack);
1387 +  tScaleUp->SetLineColor(kRed);
1388 +  tScaleDown->SetLineColor(kRed);
1389 +  tMatchingUp->SetLineColor(kBlue);
1390 +  tMatchingDown->SetLineColor(kBlue);
1391 +  tScaleUp->SetLineStyle(2);
1392 +  tScaleDown->SetLineStyle(3);
1393 +  tMatchingUp->SetLineStyle(2);
1394 +  tMatchingDown->SetLineStyle(3);
1395 +  
1396 +  TLegend *leg2 = make_legend();
1397 +  leg2->AddEntry(hdata,"Data","p");
1398 +  leg2->AddEntry(tCentral,"Central (ttbar)","l");
1399 +  leg2->AddEntry(tScaleUp,"ScaleUp (ttbar)","l");
1400 +  leg2->AddEntry(tScaleDown,"ScaleDown (ttbar)","l");
1401 +  leg2->AddEntry(tMatchingUp,"MatchingUp (ttbar)","l");
1402 +  leg2->AddEntry(tMatchingDown,"MatchingDown (ttbar)","l");
1403 +  if(variable=="genMET") {
1404 +    Central.Draw("histo");
1405 +  }else {
1406 +    hdata->Draw("e1");
1407 +    Central.Draw("histo,same");
1408 +    hdata->Draw("e1,same");
1409 +  }
1410 +  tCentral->Draw("histo,same");
1411 +  tScaleUp->Draw("histo,same");
1412 +  tScaleDown->Draw("histo,same");
1413 +  tMatchingUp->Draw("histo,same");
1414 +  tMatchingDown->Draw("histo,same");
1415 +  leg2->Draw();
1416 +  
1417 +  CompleteSave(kinpad,saveas+"__TTbarComparison");
1418 +  
1419 +  gStyle->SetOptFit(0);
1420 +  
1421 +  kinpad->cd();
1422 +  kinpad->SetLogy(0);
1423 +  TH1F *MatchingRatio = (TH1F*)tMatchingUp->Clone("MatchingRatio");
1424 +  MatchingRatio->Divide(tMatchingDown);
1425 +  TLine *lone = new TLine(tScaleUp->GetBinLowEdge(1),1,tScaleUp->GetBinLowEdge(tScaleUp->GetNbinsX())+tScaleUp->GetBinWidth(tScaleUp->GetNbinsX()),1);
1426 +  lone->SetLineColor(TColor::GetColor("#01DF01"));
1427 +  lone->SetLineStyle(2);
1428 +  TH1F *ScaleRatio = (TH1F*)tScaleUp->Clone("ScaleRatio");
1429 +  ScaleRatio->Divide(tScaleDown);
1430 +  MatchingRatio->GetYaxis()->SetRangeUser(0,3);
1431 +  MatchingRatio->Draw("e1");
1432 +  TF1 *QP1 = new TF1("QP1","[0]+[1]*x",50,200);//simple linear function ranging from 50 to 200
1433 +  MatchingRatio->Fit("QP1","R");
1434 +  lone->Draw();
1435 +  stringstream summary;
1436 +  summary << " #splitline{Fit result for f(x) = a+bx :}{#splitline{a=" << DigitsAfterComma(QP1->GetParameter(0),4) << " +/- " << DigitsAfterComma(QP1->GetParError(0),4) << "}{b=" << DigitsAfterComma(QP1->GetParameter(1),4);
1437 +  summary << " +/- " << DigitsAfterComma(QP1->GetParError(1),4) << "}}";
1438 +  TText *infobox = write_title(summary.str());
1439 +  infobox->SetX(0.75);
1440 +  infobox->SetTextSize(0.03);
1441 +  infobox->SetY(0.75);
1442 +  infobox->Draw();
1443 +  CompleteSave(kinpad,saveas+"__TTbarComparison_MatchingUpDividedMatchingDown");
1444 +  kinpad->cd();
1445 +  ScaleRatio->GetYaxis()->SetRangeUser(0,3);
1446 +  ScaleRatio->Draw("e1");
1447 +  ScaleRatio->Fit("QP1","R");
1448 +  summary.str("");
1449 +  summary << " #splitline{Fit result for f(x) = a+bx :}{#splitline{a=" << DigitsAfterComma(QP1->GetParameter(0),4) << " +/- " << DigitsAfterComma(QP1->GetParError(0),4) << "}{b=" << DigitsAfterComma(QP1->GetParameter(1),4);
1450 +  summary << " +/- " << DigitsAfterComma(QP1->GetParError(1),4) << "}}";
1451 +  TText *infobox2 = write_title(summary.str());
1452 +  infobox2->SetX(0.75);
1453 +  infobox2->SetTextSize(0.03);
1454 +  infobox2->SetY(0.75);
1455 +  infobox2->Draw();
1456 +
1457 +  lone->Draw();
1458 +  CompleteSave(kinpad,saveas+"__TTbarComparison_ScaleUpDividedScaleDown");
1459 +  
1460 +  
1461 +  delete QP1;
1462 +  delete infobox;
1463 +  delete infobox2;
1464 +  delete MatchingRatio;
1465 +  delete ScaleRatio;
1466 +  DeleteStack(ScaleUp);
1467 +  DeleteStack(ScaleDown);
1468 +  DeleteStack(MatchingUp);
1469 +  DeleteStack(MatchingDown);
1470 +  delete leg2;
1471 +  CleanLegends();
1472 +  DeleteStack(Central);
1473 +  delete Systematic;
1474 +  delete HScaleUp;
1475 +  delete HScaleDown;
1476 +  delete HMatchingUp;
1477 +  delete HMatchingDown;
1478 +  delete hdata;
1479 +  delete HCentral;
1480 +  delete ca;
1481 + }
1482 +
1483 + TH1F* ImposeBinning(TH1F *binninghisto, TH1F* histo) {
1484 +  float val=0,err=0;
1485 +  vector<float> bins;
1486 +  vector<float> vals;
1487 +  vector<float> errs;
1488 +  
1489 +  bins.push_back(binninghisto->GetBinLowEdge(1));
1490 +  int iBin=1;
1491 +  
1492 +  for(unsigned int i=1;i<histo->GetNbinsX();i++) {//going to second last one on purpose!
1493 +    if((histo->GetBinLowEdge(i)+0.00001>=binninghisto->GetBinLowEdge(iBin)+binninghisto->GetBinWidth(iBin))) {
1494 +      bins.push_back(histo->GetBinLowEdge(i));
1495 +      vals.push_back(val);val=0;
1496 +      errs.push_back(err);err=0;
1497 +      iBin++;
1498 +    }
1499 +    val+=histo->GetBinContent(i);
1500 +    err=sqrt(err*err+histo->GetBinError(i)*histo->GetBinError(i));
1501 +  }
1502 +  bins.push_back(histo->GetBinLowEdge(histo->GetNbinsX())+histo->GetBinWidth(histo->GetNbinsX()));
1503 +  vals.push_back(val);val=0;
1504 +  errs.push_back(err);err=0;
1505 +  
1506 +  TH1F *h = new TH1F(("r"+(string)histo->GetName()).c_str(),("r"+(string)histo->GetName()).c_str(),bins.size()-1,&bins[0]);
1507 +  for(unsigned int i=0;i<vals.size();i++) {
1508 +    h->SetBinContent(i+1,vals[i]);
1509 +    h->SetBinError(i+1,errs[i]);
1510 +  }
1511 +  
1512 +  h->GetXaxis()->SetTitle(histo->GetXaxis()->GetTitle());
1513 +  h->GetYaxis()->SetTitle(histo->GetYaxis()->GetTitle());
1514 +  
1515 +  h->GetXaxis()->CenterTitle();
1516 +  h->GetYaxis()->CenterTitle();
1517 +
1518 +  return h;
1519 + }
1520 +
1521 +
1522 + TH1F* ReBinOptimizingStats(int nbins, TH1F *histo) {
1523 +  float statsperbin = (1/(float)nbins) * histo->Integral();
1524 +  float val=0,err=0;
1525 +  vector<float> bins;
1526 +  vector<float> vals;
1527 +  vector<float> errs;
1528 +  
1529 +  bins.push_back(histo->GetBinLowEdge(1));
1530 +  for(unsigned int i=1;i<=histo->GetNbinsX();i++) {
1531 +    val+=histo->GetBinContent(i);
1532 +    err=sqrt(err*err+histo->GetBinError(i)*histo->GetBinError(i));
1533 +    if( val/statsperbin > 0.85) {
1534 +      if(bins.size()<nbins) {
1535 +        bins.push_back(histo->GetBinLowEdge(i)+histo->GetBinWidth(i));
1536 +        vals.push_back(val);val=0;
1537 +        errs.push_back(err);err=0;
1538 +      }
1539 +    }
1540 +    if(i==histo->GetNbinsX()) {
1541 +      bins.push_back(histo->GetBinLowEdge(i)+histo->GetBinWidth(i));
1542 +      vals.push_back(val);val=0;
1543 +      errs.push_back(err);err=0;
1544 +    }
1545 +  }
1546 +  TH1F *h = new TH1F(("r"+(string)histo->GetName()).c_str(),("r"+(string)histo->GetName()).c_str(),bins.size()-1,&bins[0]);
1547 +  
1548 +  h->GetXaxis()->SetTitle(histo->GetXaxis()->GetTitle());
1549 +  h->GetYaxis()->SetTitle(histo->GetYaxis()->GetTitle());
1550 +  
1551 +  h->GetXaxis()->CenterTitle();
1552 +  h->GetYaxis()->CenterTitle();
1553 +  
1554 +  for(unsigned int i=0;i<vals.size();i++) {
1555 +    h->SetBinContent(i+1,vals[i]);
1556 +    h->SetBinError(i+1,errs[i]);
1557 +  }
1558 +  
1559 +  return h;
1560 + }
1561 +
1562 +
1563 +  
1564 + void ShowBinning(TH1F *histo) {
1565 +  cout << "Showing binning for " << histo->GetName() << " (\" " << histo->GetTitle() << "\")" << endl;
1566 +  for(unsigned int i=1;i<=histo->GetNbinsX();i++) cout << "   Bin " << i << " : " << histo->GetBinLowEdge(i) << " , " << histo->GetBinLowEdge(i) + histo->GetBinWidth(i) << "  : " << histo->GetBinContent(i) << endl;
1567 + }
1568 +  
1569 + void QuickProduceMCSystematicPlot(string variable, int nbins, float bmin, float bmax, string label, TCut thiscut, string saveas) {
1570 +  TCanvas *ca = new TCanvas("ca","ca");
1571 +  TH1F *tScaleUp = systsamples.Draw("tScaleUp",variable,nbins,bmin,bmax,label,"events",thiscut,mc,luminosity,systsamples.FindSample("scaleup"));
1572 +  TH1F *tScaleDown = systsamples.Draw("tScaleDown",variable,nbins,bmin,bmax,label,"events",thiscut,mc,luminosity,systsamples.FindSample("scaledown"));
1573 +  TH1F *tMatchingUp = systsamples.Draw("tMatchingUp",variable,nbins,bmin,bmax,label,"events",thiscut,mc,luminosity,systsamples.FindSample("matchingup"));
1574 +  TH1F *tMatchingDown = systsamples.Draw("tMatchingDown",variable,nbins,bmin,bmax,label,"events",thiscut,mc,luminosity,systsamples.FindSample("matchingdown"));
1575 +  TH1F *tCentral = systsamples.Draw("tCentral",variable,nbins,bmin,bmax,label,"events",thiscut,mc,luminosity,systsamples.FindSample("TTJets_MassiveBinDECAY_TuneZ2sta"));
1576 +  
1577 +  tScaleUp->Scale(1.0/tScaleUp->Integral());
1578 +  tScaleDown->Scale(1.0/tScaleDown->Integral());
1579 +  tMatchingDown->Scale(1.0/tMatchingDown->Integral());
1580 +  tMatchingUp->Scale(1.0/tMatchingUp->Integral());
1581 +  tCentral->Scale(1.0/tCentral->Integral());
1582 +  
1583 +  cout << "At this point we want to rebin the scale/matching histograms so we get decent stats!" << endl;
1584 +  
1585 +  
1586 +  TH1F *rtScaleUp = ReBinOptimizingStats(7,tScaleUp); // using the scale up sample to get the binning (shouldn't use the central one for obvious reasons)
1587 +  TH1F *rtScaleDown = ImposeBinning(rtScaleUp,tScaleDown);
1588 +  TH1F *rtMatchingDown = ImposeBinning(rtScaleUp,tMatchingDown);
1589 +  TH1F *rtMatchingUp = ImposeBinning(rtScaleUp,tMatchingUp);
1590 +  TH1F *rtCentral = ImposeBinning(rtScaleUp,tCentral);
1591 +  
1592 +  float min=rtScaleUp->GetMinimum();
1593 +  float max=rtScaleUp->GetMaximum();
1594 +  
1595 +  if(rtScaleDown->GetMinimum()<min) min=rtScaleDown->GetMinimum();
1596 +  if(rtMatchingDown->GetMinimum()<min) min=rtMatchingDown->GetMinimum();
1597 +  if(rtMatchingDown->GetMinimum()<min) min=rtMatchingDown->GetMinimum();
1598 +  if(rtMatchingUp->GetMinimum()<min) min=rtMatchingUp->GetMinimum();
1599 +  if(rtCentral->GetMinimum()<min) min=rtCentral->GetMinimum();
1600 +  
1601 +  if(rtScaleDown->GetMaximum()<min) max=rtScaleDown->GetMaximum();
1602 +  if(rtMatchingDown->GetMaximum()<min) max=rtMatchingDown->GetMaximum();
1603 +  if(rtMatchingDown->GetMaximum()<min) max=rtMatchingDown->GetMaximum();
1604 +  if(rtMatchingUp->GetMaximum()<min) max=rtMatchingUp->GetMaximum();
1605 +  if(rtCentral->GetMaximum()<min) max=rtCentral->GetMaximum();
1606 +  
1607 +  rtCentral->SetMaximum(1.2*max);
1608 +  rtCentral->SetMinimum(0.8*min);
1609 +  
1610 + /*  tScaleUp->Rebin(40);
1611 +  tScaleDown->Rebin(40);
1612 +  tMatchingDown->Rebin(40);
1613 +  tMatchingUp->Rebin(40);
1614 +  tCentral->Rebin(40);*/
1615 +  
1616 +  TPad *kinpad = new TPad("kinpad","kinpad",0,0,1,1);
1617 +  kinpad->SetLogy(1);
1618 +  kinpad->cd();
1619 +  tCentral->SetFillColor(kWhite);
1620 +  tCentral->SetLineColor(kBlack);
1621 +  tScaleUp->SetLineColor(kRed);
1622 +  tScaleDown->SetLineColor(kRed);
1623 +  tMatchingUp->SetLineColor(kBlue);
1624 +  tMatchingDown->SetLineColor(kBlue);
1625 +  tScaleUp->SetLineStyle(2);
1626 +  tScaleDown->SetLineStyle(3);
1627 +  tMatchingUp->SetLineStyle(2);
1628 +  tMatchingDown->SetLineStyle(3);
1629 +  
1630 +  rtScaleDown->SetLineColor(kRed);
1631 +  rtMatchingUp->SetLineColor(kBlue);
1632 +  rtMatchingDown->SetLineColor(kBlue);
1633 +  rtScaleUp->SetLineStyle(2);
1634 +  rtScaleDown->SetLineStyle(3);
1635 +  rtMatchingUp->SetLineStyle(2);
1636 +  rtMatchingDown->SetLineStyle(3);
1637 +  
1638 +  TLegend *leg2 = make_legend();
1639 +  leg2->AddEntry(tCentral,"Central (ttbar)","l");
1640 +  leg2->AddEntry(tScaleUp,"ScaleUp (ttbar)","l");
1641 +  leg2->AddEntry(tScaleDown,"ScaleDown (ttbar)","l");
1642 +  leg2->AddEntry(tMatchingUp,"MatchingUp (ttbar)","l");
1643 +  leg2->AddEntry(tMatchingDown,"MatchingDown (ttbar)","l");
1644 +  
1645 +  tCentral->Draw("histo");
1646 +  tScaleUp->Draw("histo,same");
1647 +  tScaleDown->Draw("histo,same");
1648 +  tMatchingUp->Draw("histo,same");
1649 +  tMatchingDown->Draw("histo,same");
1650 +  leg2->Draw();
1651 +  DrawMCPrelim();
1652 +  CompleteSave(kinpad,saveas+"__TTbarComparison");
1653 +  kinpad->cd();
1654 +  kinpad->SetLogy(0);
1655 +  rtCentral->Draw("histo");
1656 +  rtScaleUp->Draw("histo,same");
1657 +  rtScaleDown->Draw("histo,same");
1658 +  rtMatchingUp->Draw("histo,same");
1659 +  rtMatchingDown->Draw("histo,same");
1660 +  leg2->Draw();
1661 +  DrawMCPrelim();
1662 +  CompleteSave(kinpad,saveas+"__TTbarComparison__REBINNED");
1663 +  
1664 +  
1665 +  gStyle->SetOptFit(0);
1666 +
1667 +  kinpad->cd();
1668 +  kinpad->SetLogy(0);
1669 +  TH1F *MatchingRatio = (TH1F*)rtMatchingUp->Clone("MatchingRatio");
1670 +  MatchingRatio->Divide(rtMatchingDown);
1671 +  TLine *lone = new TLine(tScaleUp->GetBinLowEdge(1),1,tScaleUp->GetBinLowEdge(tScaleUp->GetNbinsX())+tScaleUp->GetBinWidth(tScaleUp->GetNbinsX()),1);
1672 +  lone->SetLineColor(TColor::GetColor("#01DF01"));
1673 +  lone->SetLineStyle(2);
1674 +  TH1F *ScaleRatio = (TH1F*)rtScaleUp->Clone("ScaleRatio");
1675 +  ScaleRatio->Divide(rtScaleDown);
1676 +  MatchingRatio->GetYaxis()->SetRangeUser(0,3);
1677 +  MatchingRatio->Draw("e1");
1678 +  TF1 *QP1 = new TF1("QP1","[0]+[1]*x",50,200);//simple linear function ranging from 50 to 200
1679 +  if(variable=="genMET" || variable=="met[4]" || variable=="met[1]") MatchingRatio->Fit("QP1","RQ");
1680 +  lone->Draw();
1681 +  stringstream summary;
1682 +  summary << " #splitline{Fit result for f(x) = a+bx :}{#splitline{a=" << DigitsAfterComma(QP1->GetParameter(0),4) << " +/- " << DigitsAfterComma(QP1->GetParError(0),4) << "}{b=" << DigitsAfterComma(QP1->GetParameter(1),4);
1683 +  summary << " +/- " << DigitsAfterComma(QP1->GetParError(1),4) << "}}";
1684 +  TText *infobox = write_title(summary.str());
1685 +  infobox->SetX(0.75);
1686 +  infobox->SetTextSize(0.03);
1687 +  infobox->SetY(0.75);
1688 +  if(variable=="genMET" || variable=="met[4]" || variable=="met[1]") infobox->Draw();
1689 +  DrawMCPrelim();
1690 +  CompleteSave(kinpad,saveas+"__TTbarComparison_MatchingUpDividedMatchingDown");
1691 +  kinpad->cd();
1692 +  ScaleRatio->GetYaxis()->SetRangeUser(0,3);
1693 +  ScaleRatio->Draw("e1");
1694 +  if(variable=="genMET" || variable=="met[4]" || variable=="met[1]") ScaleRatio->Fit("QP1","RQ");
1695 +  summary.str("");
1696 +  summary << " #splitline{Fit result for f(x) = a+bx :}{#splitline{a=" << DigitsAfterComma(QP1->GetParameter(0),4) << " +/- " << DigitsAfterComma(QP1->GetParError(0),4) << "}{b=" << DigitsAfterComma(QP1->GetParameter(1),4);
1697 +  summary << " +/- " << DigitsAfterComma(QP1->GetParError(1),4) << "}}";
1698 +  TText *infobox2 = write_title(summary.str());
1699 +  infobox2->SetX(0.75);
1700 +  infobox2->SetTextSize(0.03);
1701 +  infobox2->SetY(0.75);
1702 +  if(variable=="genMET" || variable=="met[4]" || variable=="met[1]") infobox2->Draw();
1703 +
1704 +  lone->Draw();
1705 +  DrawMCPrelim();
1706 +  CompleteSave(kinpad,saveas+"__TTbarComparison_ScaleUpDividedScaleDown");
1707 +  
1708 +  kinpad->cd();
1709 +  TH1F *SysMatching = (TH1F*)rtMatchingDown->Clone("SysMatching");
1710 +  TH1F *SysScale = (TH1F*)rtScaleDown->Clone("SysMatching");
1711 +  TH1F *SysHisto = (TH1F*)rtScaleDown->Clone("SysHisto");
1712 +  
1713 +  for(int i=1;i<=SysScale->GetNbinsX();i++) {
1714 +    float matching, scale;
1715 +    bool AssumeFactor=false;
1716 +    if(AssumeFactor) {
1717 +      // assume that an upward/downward variation means a change by a constant factor, i.e. f(up) = alpha * f(central)
1718 +      matching=0.;
1719 +      scale=0.;
1720 +    } else {
1721 +      // assume that the central value is exactly between up & down, i.e. central = (up-down)/2
1722 +      matching = fabs(    ( rtMatchingUp->GetBinContent(i) - rtMatchingDown->GetBinContent(i)) / (rtMatchingUp->GetBinContent(i) + rtMatchingDown->GetBinContent(i)) );
1723 +      scale    = fabs(    ( rtScaleUp->GetBinContent(i) - rtScaleDown->GetBinContent(i)) / (rtScaleUp->GetBinContent(i) + rtScaleDown->GetBinContent(i)) );
1724 +    }
1725 +    
1726 +    SysMatching->SetBinContent(i,1+matching);
1727 +    SysScale->SetBinContent(i,1+scale);
1728 +    SysHisto->SetBinContent(i,sqrt(matching*matching+scale*scale)+1);
1729 +  }
1730 +  
1731 +  SysHisto->SetLineColor(kGreen);
1732 +  
1733 +  SysMatching->SetMaximum(3.0);
1734 +  SysMatching->SetMinimum(0.0);
1735 +  SysMatching->Draw("histo");
1736 +  SysScale->Draw("histo,same");
1737 +  SysHisto->Draw("histo,same");
1738 +  CompleteSave(kinpad,saveas+"__TTbarComparison_DerivedSystematic");
1739 +  
1740 +  delete SysMatching;
1741 +  delete SysScale;
1742 +  
1743 +  if(!Contains(variable,"gen")) {
1744 +    TH1F *hdata  = allsamples.Draw("hdata",   variable,nbins,bmin,bmax,label,"events",thiscut,data,luminosity);
1745 +    THStack smc = allsamples.DrawStack("smc",variable,nbins,bmin,bmax,label,"events",thiscut,mc,luminosity);
1746 +    
1747 +    TH1F *Systematic = (TH1F*)hdata->Clone("Systematic");
1748 +    
1749 +    for(int i=1;i<=Systematic->GetNbinsX();i++) {
1750 +      int iBin=SysHisto->FindBin(Systematic->GetBinCenter(i));
1751 +      if(iBin>SysHisto->GetNbinsX()) --iBin; // if we're over the end of the histo, use the last bin
1752 +      float sys = SysHisto->GetBinContent(iBin)-1;
1753 +      Systematic->SetBinContent(i,sys);
1754 +    }
1755 +    
1756 +    kinpad->cd();
1757 +    TLegend *leg = allsamples.allbglegend();
1758 +    hdata->Draw();
1759 +    smc.Draw("histo,same");
1760 +    hdata->Draw("same");
1761 +    leg->Draw();
1762 +    DrawPrelim();
1763 +    save_with_ratio_and_sys_band( hdata, CollapseStack(smc), kinpad->cd(), saveas+"__DataVsMC", false, false, "data/mc",Systematic );
1764 +    
1765 +    delete Systematic;
1766 +    delete hdata;
1767 +  }
1768 +  
1769 +  
1770 +  delete SysHisto;
1771 +  delete tScaleUp;
1772 +  delete tScaleDown;
1773 +  delete tCentral;
1774 +  delete tMatchingUp;
1775 +  delete tMatchingDown;
1776 +  delete rtScaleUp;
1777 +  delete rtScaleDown;
1778 +  delete rtCentral;
1779 +  delete rtMatchingUp;
1780 +  delete rtMatchingDown;
1781 +  delete QP1;
1782 +  delete infobox;
1783 +  delete infobox2;
1784 +  delete MatchingRatio;
1785 +  delete ScaleRatio;
1786 +  delete leg2;
1787 +  CleanLegends();
1788 +  delete ca;
1789 + }
1790 +
1791 + void ProduceMCSystematicPlots() {
1792 +  cout << "Getting ready to produce systematic plots " << endl;
1793 +  TCut cutweightBKP = cutWeight;
1794 +  
1795 +  QuickProduceMCSystematicPlot("genMET",20,0,200,"genMET [GeV]",cutOSSF&&cutnJets&&TCut("mll>20&&mll<70"),"MCSystPlots/genMET/ETH_SameFlavor");
1796 +  QuickProduceMCSystematicPlot("genMET",20,0,200,"genMET [GeV]",cutOSOF&&cutnJets&&TCut("mll>20&&mll<70"),"MCSystPlots/genMET/ETH_OppositeFlavor");
1797 +  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PFMET [GeV]",cutOSSF&&cutnJets&&TCut("mll>20&&mll<70"),"MCSystPlots/MET/ETH_SameFlavor");
1798 +  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PFMET [GeV]",cutOSOF&&cutnJets&&TCut("mll>20&&mll<70"),"MCSystPlots/MET/ETH_OppositeFlavor");
1799 +  
1800 +  QuickProduceMCSystematicPlot("genMET",20,0,200,"genMET [GeV]",cutOSSF&&TCut("mll>20&&mll<70"),"MCSystPlots/genMET/ETH_SameFlavor_INCLUSIVE");
1801 +  QuickProduceMCSystematicPlot("genMET",20,0,200,"genMET [GeV]",cutOSOF&&TCut("mll>20&&mll<70"),"MCSystPlots/genMET/ETH_OppositeFlavor_INCLUSIVE");  
1802 +  QuickProduceMCSystematicPlot("genMET",20,0,200,"genMET [GeV]",cutOSSF&&TCut("mll>120"),"MCSystPlots/genMET/ETH_SameFlavor_INCLUSIVE_HighMass");
1803 +  QuickProduceMCSystematicPlot("genMET",20,0,200,"genMET [GeV]",cutOSOF&&TCut("mll>120"),"MCSystPlots/genMET/ETH_OppositeFlavor_INCLUSIVE_HighMass");  
1804 +  
1805 +  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PFMET [GeV]",cutOSSF&&TCut("mll>20&&mll<70"),"MCSystPlots/MET/ETH_SameFlavor_INCLUSIVE");
1806 +  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PFMET [GeV]",cutOSOF&&TCut("mll>20&&mll<70"),"MCSystPlots/MET/ETH_OppositeFlavor_INCLUSIVE");
1807 +  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PFMET [GeV]",cutOSSF&&TCut("mll>120"),"MCSystPlots/MET/ETH_SameFlavor_INCLUSIVE_HighMass");
1808 +  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PFMET [GeV]",cutOSOF&&TCut("mll>120"),"MCSystPlots/MET/ETH_OppositeFlavor_INCLUSIVE_HighMass");
1809 +  QuickProduceMCSystematicPlot("pfJetGoodNum40",8,-0.5,7.5,"NJets",cutOSSF&&cutnJets&&TCut("mll>20&&mll<70&&met[4]>100"),"MCSystPlots/NJets/ETH_SameFlavor");
1810 +  QuickProduceMCSystematicPlot("pfJetGoodNum40",8,-0.5,7.5,"NJets",cutOSOF&&cutnJets&&TCut("mll>20&&mll<70&&met[4]>100"),"MCSystPlots/NJets/ETH_OppositeFlavor");
1811 +  
1812 +  
1813 +  
1814 +  cout << "Kicking cutWeight  " << (const char*) cutWeight << endl;
1815 +  cout << "Keeping OSSF cut " << (const char*)cutOSSF << endl;
1816 +  cutWeight="1.0";
1817 +  
1818 +  QuickProduceMCSystematicPlot("genMET",20,0,200,"genMET [GeV]",cutOSSF&&TCut("mll>20&&mll<70"),"MCSystPlots/genMET/ETH_SameFlavor_INCLUSIVE__NOPURW");
1819 +  QuickProduceMCSystematicPlot("genMET",20,0,200,"genMET [GeV]",cutOSOF&&TCut("mll>20&&mll<70"),"MCSystPlots/genMET/ETH_OppositeFlavor_INCLUSIVE__NOPURW");  
1820 +  QuickProduceMCSystematicPlot("genMET",20,0,200,"genMET [GeV]",cutOSSF&&TCut("mll>120"),"MCSystPlots/genMET/ETH_SameFlavor_INCLUSIVE_HighMass__NOPURW");
1821 +  QuickProduceMCSystematicPlot("genMET",20,0,200,"genMET [GeV]",cutOSOF&&TCut("mll>120"),"MCSystPlots/genMET/ETH_OppositeFlavor_INCLUSIVE_HighMass__NOPURW");  
1822 +  
1823 +  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PFMET [GeV]",cutOSSF&&TCut("mll>20&&mll<70"),"MCSystPlots/MET/ETH_SameFlavor_INCLUSIVE__NOPURW");
1824 +  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PFMET [GeV]",cutOSOF&&TCut("mll>20&&mll<70"),"MCSystPlots/MET/ETH_OppositeFlavor_INCLUSIVE__NOPURW");
1825 +  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PFMET [GeV]",cutOSSF&&TCut("mll>120"),"MCSystPlots/MET/ETH_SameFlavor_INCLUSIVE_HighMass__NOPURW");
1826 +  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PFMET [GeV]",cutOSOF&&TCut("mll>120"),"MCSystPlots/MET/ETH_OppositeFlavor_INCLUSIVE_HighMass__NOPURW");
1827 +  
1828 +  
1829 +  // --------------------------------------    ***** AACHEN *****      --------------------------------------    
1830 +  
1831 +  /*
1832 +  cutWeight=cutweightBKP;
1833 +  TCut essentialcutBKP = essentialcut;
1834 +  cout << (const char*) essentialcut << endl;
1835 +  
1836 +  essentialcut = TCut((ReplaceAll((const char*)essentialcut,"pt2>20","pt2>10")).c_str());
1837 +  essentialcut = TCut((ReplaceAll((const char*)essentialcut,"abs(eta1)<1.4","abs(eta1)<2.4")).c_str());
1838 +  essentialcut = TCut((ReplaceAll((const char*)essentialcut,"abs(eta2)<1.4","abs(eta2)<2.4")).c_str());
1839 +  
1840 +  TCut cutnJetsBKP = cutnJets;
1841 +  cutnJets = TCut((ReplaceAll((const char*)cutnJets,"pt2>20","pt2>10")).c_str());
1842 +  cutnJets = TCut((ReplaceAll((const char*)cutnJets,"pfJetGoodNum40>=3","pfJetGoodNum40>=2")).c_str());
1843 +  cutnJets = TCut((ReplaceAll((const char*)cutnJets,"abs(eta2)<1.4","abs(eta2)<2.4")).c_str());
1844 +  cutnJets = TCut((ReplaceAll((const char*)cutnJets,"abs(eta1)<1.4","abs(eta1)<2.4")).c_str());
1845 +  
1846 +  QuickProduceMCSystematicPlot("genMET",20,0,200,"genMET [GeV]",cutOSSF&&cutnJets&&TCut("mll>20&&mll<70"),"MCSystPlots/genMET/Aachen_SameFlavor");
1847 +  QuickProduceMCSystematicPlot("genMET",20,0,200,"genMET [GeV]",cutOSOF&&cutnJets&&TCut("mll>20&&mll<70"),"MCSystPlots/genMET/Aachen_OppositeFlavor");  
1848 +  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PFMET [GeV]",cutOSSF&&cutnJets&&TCut("mll>20&&mll<70"),"MCSystPlots/MET/Aachen_SameFlavor");
1849 +  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PFMET [GeV]",cutOSOF&&cutnJets&&TCut("mll>20&&mll<70"),"MCSystPlots/MET/Aachen_OppositeFlavor");
1850 +  
1851 +  QuickProduceMCSystematicPlot("genMET",20,0,200,"genMET [GeV]",cutOSSF&&TCut("mll>20&&mll<70"),"MCSystPlots/genMET/Aachen_SameFlavor_INCLUSIVE");
1852 +  QuickProduceMCSystematicPlot("genMET",20,0,200,"genMET [GeV]",cutOSOF&&TCut("mll>20&&mll<70"),"MCSystPlots/genMET/Aachen_OppositeFlavor_INCLUSIVE");  
1853 +  QuickProduceMCSystematicPlot("genMET",20,0,200,"genMET [GeV]",cutOSSF&&TCut("mll>120"),"MCSystPlots/genMET/Aachen_SameFlavor_INCLUSIVE_HighMass");
1854 +  QuickProduceMCSystematicPlot("genMET",20,0,200,"genMET [GeV]",cutOSOF&&TCut("mll>120"),"MCSystPlots/genMET/Aachen_OppositeFlavor_INCLUSIVE_HighMass");  
1855 +  
1856 +  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PFMET [GeV]",cutOSSF&&TCut("mll>20&&mll<70"),"MCSystPlots/MET/Aachen_SameFlavor_INCLUSIVE");
1857 +  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PFMET [GeV]",cutOSOF&&TCut("mll>20&&mll<70"),"MCSystPlots/MET/Aachen_OppositeFlavor_INCLUSIVE");
1858 +  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PFMET [GeV]",cutOSSF&&TCut("mll>120"),"MCSystPlots/MET/Aachen_SameFlavor_INCLUSIVE_HighMass");
1859 +  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PFMET [GeV]",cutOSOF&&TCut("mll>120"),"MCSystPlots/MET/Aachen_OppositeFlavor_INCLUSIVE_HighMass");
1860 +  QuickProduceMCSystematicPlot("pfJetGoodNum40",8,-0.5,7.5,"NJets",cutOSSF&&cutnJets&&TCut("mll>20&&mll<70&&met[4]>100"),"MCSystPlots/NJets/Aachen_SameFlavor");
1861 +  QuickProduceMCSystematicPlot("pfJetGoodNum40",8,-0.5,7.5,"NJets",cutOSOF&&cutnJets&&TCut("mll>20&&mll<70&&met[4]>100"),"MCSystPlots/NJets/Aachen_OppositeFlavor");
1862 +  
1863 +  
1864 +  
1865 +  cout << "Kicking cutWeight  " << (const char*) cutWeight << endl;
1866 +  cout << "Keeping OSSF cut " << (const char*)cutOSSF << endl;
1867 +  cutWeight="1.0";
1868 +  
1869 +  QuickProduceMCSystematicPlot("genMET",20,0,200,"genMET [GeV]",cutOSSF&&TCut("mll>20&&mll<70"),"MCSystPlots/genMET/Aachen_SameFlavor_INCLUSIVE__NOPURW");
1870 +  QuickProduceMCSystematicPlot("genMET",20,0,200,"genMET [GeV]",cutOSOF&&TCut("mll>20&&mll<70"),"MCSystPlots/genMET/Aachen_OppositeFlavor_INCLUSIVE__NOPURW");  
1871 +  QuickProduceMCSystematicPlot("genMET",20,0,200,"genMET [GeV]",cutOSSF&&TCut("mll>120"),"MCSystPlots/genMET/Aachen_SameFlavor_INCLUSIVE_HighMass__NOPURW");
1872 +  QuickProduceMCSystematicPlot("genMET",20,0,200,"genMET [GeV]",cutOSOF&&TCut("mll>120"),"MCSystPlots/genMET/Aachen_OppositeFlavor_INCLUSIVE_HighMass__NOPURW");  
1873 +  
1874 +  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PFMET [GeV]",cutOSSF&&TCut("mll>20&&mll<70"),"MCSystPlots/MET/Aachen_SameFlavor_INCLUSIVE__NOPURW");
1875 +  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PFMET [GeV]",cutOSOF&&TCut("mll>20&&mll<70"),"MCSystPlots/MET/Aachen_OppositeFlavor_INCLUSIVE__NOPURW");
1876 +  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PFMET [GeV]",cutOSSF&&TCut("mll>120"),"MCSystPlots/MET/Aachen_SameFlavor_INCLUSIVE_HighMass__NOPURW");
1877 +  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PFMET [GeV]",cutOSOF&&TCut("mll>120"),"MCSystPlots/MET/Aachen_OppositeFlavor_INCLUSIVE_HighMass__NOPURW");
1878 +  
1879 +  cutnJets  = cutnJetsBKP;
1880 +  cutWeight = cutweightBKP;
1881 +  essentialcut = essentialcutBKP;
1882 +  */
1883 +  write_error(__FUNCTION__,"Still need to add systematic shape");assert(0);
1884 + }
1885 +
1886 + void MakeTauPlot(string label, TCut pcut, string filename, bool TauOnly) {
1887 +  TCut cut=pcut&&basiccut;
1888 +  string variable="mll";
1889 +  string xlabel="m_{ll} [GeV]";
1890 +  int nbins=40;
1891 +  float min=0;
1892 +  float max=200;
1893 +
1894 +  TCanvas *ckin = new TCanvas("ckin","Kinematic Plots (in the making)",600,600);
1895 +  TH1F *datahistoSF = allsamples.Draw("datahistoSF",variable,nbins,min,max, xlabel, "events",cut&&cutOSSF,data,luminosity);
1896 +  TH1F *datahistoOF = allsamples.Draw("datahistoOF",variable,nbins,min,max, xlabel, "events",cut&&cutOSOF,data,luminosity);
1897 +  TH1F *tauSF = allsamples.Draw("tauSF",variable,nbins,min,max, xlabel, "events",cut&&cutOSSF,data,luminosity,systsamples.FindSample("DYToTauTau"));
1898 +  TH1F *tauOF = allsamples.Draw("tauOF",variable,nbins,min,max, xlabel, "events",cut&&cutOSOF,data,luminosity,systsamples.FindSample("DYToTauTau"));
1899 +  datahistoSF->SetMarkerSize(DataMarkerSize);
1900 +  datahistoSF->SetMaximum(1.3*datahistoSF->GetMaximum());
1901 +  datahistoOF->SetMarkerSize(DataMarkerSize);
1902 +  datahistoOF->SetMaximum(1.3*datahistoOF->GetMaximum());
1903 +
1904 +  THStack mcstackSF   = allsamples.DrawStack("mcstackSF",  variable,nbins,min,max,xlabel,"events",cut&&cutOSSF,mc,luminosity);
1905 +  THStack mcstackOF   = allsamples.DrawStack("mcstackOF",  variable,nbins,min,max,xlabel,"events",cut&&cutOSOF,mc,luminosity);
1906 +  datahistoSF->Draw("e1");
1907 +  ckin->Update();
1908 +  mcstackSF.Draw("histo,same");
1909 +  
1910 +  datahistoSF->Draw("same,e1");
1911 +  TLegend *kinleg = allsamples.allbglegend();
1912 +  kinleg->Draw();
1913 +  
1914 +  TPad *kinpad = new TPad("kinpad","kinpad",0,0,1,1);
1915 +  kinpad->cd();
1916 +  datahistoSF->Draw("e1");
1917 +  mcstackSF.Draw("histo,same");
1918 +  datahistoSF->Draw("same,e1");
1919 +  datahistoSF->Draw("same,axis");
1920 +  kinleg->Draw();
1921 +  DrawPrelim();
1922 +  Save_With_Ratio(datahistoSF,mcstackSF,kinpad->cd(),filename+"__SF_mc");
1923 +  
1924 +  kinpad->cd();
1925 +  datahistoOF->Draw("e1");
1926 +  mcstackOF.Draw("histo,same");
1927 +  datahistoOF->Draw("same,e1");
1928 +  datahistoOF->Draw("same,axis");
1929 +  kinleg->Draw();
1930 +  DrawPrelim();
1931 +  Save_With_Ratio(datahistoOF,mcstackOF,kinpad->cd(),filename+"__OF_mc");
1932 +  
1933 +  kinpad->cd();
1934 +  tauSF->Draw("e1");
1935 +  tauOF->Draw("histo,same");
1936 +  tauSF->Draw("e1,same");
1937 +  TLegend *legtau = make_legend();
1938 +  legtau->AddEntry(tauSF,"DY->#tau#tau, SF","p");
1939 +  legtau->AddEntry(tauSF,"DY->#tau#tau, OF","l");
1940 +  legtau->Draw();
1941 +  DrawPrelim();
1942 +  Save_With_Ratio(tauSF,tauOF,kinpad->cd(),filename+"__Tau_SF_vs_OF");
1943 +  
1944 +  delete datahistoSF;
1945 +  delete datahistoOF;
1946 +  delete tauSF;
1947 +  delete tauOF;
1948 +  delete kinpad;
1949 +  delete ckin;
1950 +  CleanLegends();
1951 + }
1952 +  
1953 +
1954 + void TauQuestion() {
1955 + //   MakeTauPlot("MET>100 GeV, #geq 3 jets",cutnJets&&TCut("met[4]>100"),"TauQ/MET100_3Jets",true);
1956 + //   MakeTauPlot("MET>100 GeV",TCut("met[4]>100"),"TauQ/MET100",true);
1957 + //   MakeTauPlot("MET>0 GeV",TCut("met[4]>0"),"TauQ/MET0",true);
1958 +  MakeTauPlot("b-tag veto, 50<MET<100",TCut("pfJetGoodNumBtag30==0&&met[4]>50&&met[4]<100"),"TauQ/ControlPlots",false);
1959 + }
1960  
1961   void do_kinematic_plots(string mcjzb, string datajzb, bool doPF=false)
1962   {
# Line 905 | Line 1979 | void do_kinematic_plots(string mcjzb, st
1979    }
1980    
1981    if(MakeTwoThreeJetComparison) MakeElegantTwoThreeComparisons();
1982 +  
1983 +  //TauQuestion();
1984  
1985 +  //ProduceJanPlots();
1986 +  ProduceMCSystematicPlots();
1987 +  assert(0);
1988 + //  make_plain_kin_plot("pt",Cut2Str(cutOSSF&&TCut("mll>20&&pfJetGoodNumBtag30>=2")),40,0,200,nolog,"Z p_{T}","PlotForKostas",doPF,true);
1989 +  
1990    if ( doOFSF ) {
1991       make_OFSF_plots("mll", "met[4]>100", 60, 20., 320., false, "m_{ll}", "mll");
1992 +     make_OFSF_plots("met[4]", "met[4]>100", 30, 100., 400., false, "PFMET", "met");
1993 +     make_OFSF_plots("leptonNum", "met[4]>100", 3, 2, 5., false, "N(leptons)", "NLeptons");
1994  
1995 < //      make_OFSF_plots("pfJetGoodNum40", "met[4]>100",                        7, 3, 10, true, "#(jets)", "njets");
1996 < //      make_OFSF_plots("pfJetGoodNum40", "met[4]>100&&pfJetGoodNumBtag30==0", 7, 3, 10, true, "#(jets)", "njets_btagVeto");
1997 < //      make_OFSF_plots("pfJetGoodNum40", "met[4]>100&&pfJetGoodNumBtag30>0",  7, 3, 10, true, "#(jets)", "njets_AtLeastOneBJet30");
1998 <
1999 < //      make_OFSF_plots("pfJetGoodNumBtag30", "met[4]>100", 5, 0, 5, true, "#(b-jets)", "nbjets");
2000 < //      make_OFSF_plots("pfJetGoodPtBtag[0]", "met[4]>100&&pfJetGoodNumBtag30>0", 20, 0, 400, true, "p_{T}(leading b-jet)", "ptb1");
2001 <
2002 < //     make_OFSF_plots("iso1", "met[4]>100", 20, 0, 0.3, true, "lepton 1 isolation", "iso1");
2003 < //     make_OFSF_plots("iso2", "met[4]>100", 20, 0, 0.3, true, "lepton 2 isolation", "iso2");
2004 <    //  make_OFSF_plots("pt1",  "met[4]>100", 30, 0., 300., true, "p_{T,1}", "pt1");
2005 <    //  make_OFSF_plots("pt2",  "met[4]>100", 22, 0., 220., true, "p_{T,2}", "pt2");
2006 < //     make_OFSF_plots("eta1", "met[4]>100", 10, -2.5, 2.5, false, "#eta_{1}", "eta1", 0.15);
2007 < //     make_OFSF_plots("eta2", "met[4]>100", 10, -2.5, 2.5, false, "#eta_{2}", "eta2", 0.15);
2008 <    //  make_OFSF_plots("phi1", "met[4]>100", 10, -TMath::Pi(), TMath::Pi(), false, "#phi_{1}", "phi1", 0.2);
2009 <    //  make_OFSF_plots("phi2", "met[4]>100", 10, -TMath::Pi(), TMath::Pi(), false, "#phi_{2}", "phi2", 0.2);
2010 < //     make_OFSF_plots("pfJetGoodPt[0]/pfJetGoodPt[1]", "met[4]>100", 20, 1, 10, true, "pt_{j}^{1}/pt_{j}^{2}", "jpt1pt2", 0.2);
2011 <    make_OFSF_plots("TMath::Abs(pfJetDphiMet[0])", "met[4]>100", 16, 0, 3.2, false, "|#Delta#phi(jet1,MET)|", "dphij1met", 0.2);
2012 < //    make_OFSF_plots("TMath::Abs(dphi)", "met[4]>100", 16, 0, 3.2, false, "|#Delta#phi(l1,l2)|", "dphi", 0.2);
2013 < //    make_OFSF_plots("TMath::Abs(dphiMet1)", "met[4]>100", 16, 0, 3.2, false, "|#Delta#phi(l1,MET)|", "dphiMet1", 0.2);
2014 < //    make_OFSF_plots("TMath::Abs(dphiMet2)", "met[4]>100", 16, 0, 3.2, false, "|#Delta#phi(l2,MET)|", "dphiMet2", 0.2);
2015 < //    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");
2016 < //    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");
2017 < //    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");
2018 < //    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");
1995 >     make_OFSF_plots("pfJetGoodNum40", "met[4]>100",                        7, 3, 10, true, "#(jets)", "njets");
1996 >     make_OFSF_plots("pfJetGoodNum40", "met[4]>100&&pfJetGoodNumBtag30==0", 7, 3, 10, true, "#(jets)", "njets_btagVeto");
1997 >     make_OFSF_plots("pfJetGoodNum40", "met[4]>100&&pfJetGoodNumBtag30>0",  7, 3, 10, true, "#(jets)", "njets_AtLeastOneBJet30");
1998 >
1999 >     make_OFSF_plots("pfJetGoodNumBtag30", "met[4]>100", 5, 0, 5, true, "#(b-jets)", "nbjets");
2000 >     make_OFSF_plots("pfJetGoodPtBtag[0]", "met[4]>100&&pfJetGoodNumBtag30>0", 20, 0, 400, true, "p_{T}(leading b-jet)", "ptb1");
2001 >
2002 >     make_OFSF_plots("iso1", "met[4]>100", 20, 0, 0.3, true, "lepton 1 isolation", "iso1");
2003 >     make_OFSF_plots("iso2", "met[4]>100", 20, 0, 0.3, true, "lepton 2 isolation", "iso2");
2004 >     make_OFSF_plots("pt1",  "met[4]>100", 30, 0., 300., true, "p_{T,1}", "pt1");
2005 >     make_OFSF_plots("pt2",  "met[4]>100", 22, 0., 220., true, "p_{T,2}", "pt2");
2006 >     make_OFSF_plots("eta1", "met[4]>100", 10, -2.5, 2.5, false, "#eta_{1}", "eta1", 0.15);
2007 >     make_OFSF_plots("eta2", "met[4]>100", 10, -2.5, 2.5, false, "#eta_{2}", "eta2", 0.15);
2008 >     make_OFSF_plots("phi1", "met[4]>100", 10, -TMath::Pi(), TMath::Pi(), false, "#phi_{1}", "phi1", 0.2);
2009 >     make_OFSF_plots("phi2", "met[4]>100", 10, -TMath::Pi(), TMath::Pi(), false, "#phi_{2}", "phi2", 0.2);
2010 >     make_OFSF_plots("pfJetGoodPt[0]/pfJetGoodPt[1]", "met[4]>100", 20, 1, 10, true, "pt_{j}^{1}/pt_{j}^{2}", "jpt1pt2", 0.2);
2011 >     make_OFSF_plots("TMath::Abs(pfJetDphiMet[0])", "met[4]>100", 16, 0, 3.2, false, "|#Delta#phi(jet1,MET)|", "dphij1met", 0.2);
2012 >    make_OFSF_plots("TMath::Abs(dphi)", "met[4]>100", 16, 0, 3.2, false, "|#Delta#phi(l1,l2)|", "dphi", 0.2);
2013 >    make_OFSF_plots("TMath::Abs(dphiMet1)", "met[4]>100", 16, 0, 3.2, false, "|#Delta#phi(l1,MET)|", "dphiMet1", 0.2);
2014 >    make_OFSF_plots("TMath::Abs(dphiMet2)", "met[4]>100", 16, 0, 3.2, false, "|#Delta#phi(l2,MET)|", "dphiMet2", 0.2);
2015 >    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");
2016 >    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");
2017 >    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");
2018 >    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");
2019    }
2020  
2021    if ( doDataComp) {
# Line 949 | Line 2032 | void do_kinematic_plots(string mcjzb, st
2032  
2033      TCut cutSignal = cutmass&&cutnJets&&"met[4]>100";
2034      
2035 < /*    make_data_comparison_plot("numVtx", "",40, -0.5, 39.5,-1., true, "N(Vertices)", "numVtx");
2035 >    make_data_comparison_plot("numVtx", "",40, -0.5, 39.5,-1., true, "N(Vertices)", "numVtx");
2036      make_data_comparison_plot("pfJetGoodEta[0]", "",50, -3.0, 3.0,-1., true, "N(Jets)", "pfJetGoodEta0");
2037      
2038      
# Line 960 | Line 2043 | void do_kinematic_plots(string mcjzb, st
2043      make_data_comparison_plot("met[1]", cutOSOF,60, 0., 300.,-1., true, "type 1 corrected pfMET", "mett1_OF_inclusive");
2044      
2045      make_data_comparison_plot("met[4]", cutnJets&&cutOSSF,60, 0., 300.,-1., true, "pfMET", "met_SF_exclusive");
2046 < //    make_data_comparison_plot("met[1]", cutnJets&&cutOSSF,60, 0., 300.,-1., true, "type 1 corrected pfMET", "mett1_SF_exclusive");
2046 >    make_data_comparison_plot("met[1]", cutnJets&&cutOSSF,60, 0., 300.,-1., true, "type 1 corrected pfMET", "mett1_SF_exclusive");
2047      make_data_comparison_plot("met[4]", cutnJets&&cutOSOF,60, 0., 300.,-1., true, "pfMET", "met_OF_exclusive");
2048 < //    make_data_comparison_plot("met[1]", cutnJets&&cutOSOF,60, 0., 300.,-1., true, "type 1 corrected pfMET", "mett1_OF_exclusive");
2049 < */
2048 >    make_data_comparison_plot("met[1]", cutnJets&&cutOSOF,60, 0., 300.,-1., true, "type 1 corrected pfMET", "mett1_OF_exclusive");
2049 >
2050    
2051      string basiccutsaved = (const char*)basiccut;
2052      
# Line 975 | Line 2058 | void do_kinematic_plots(string mcjzb, st
2058        newbasiccut.replace( found, string( "pt2>20" ).length(), "pt2>10" );
2059        found = newbasiccut.find( "pt2>20" );
2060      }
2061 < //    basiccut=TCut(newbasiccut.c_str());
2062 < //    make_data_comparison_plot("mll", TCut("pfJetGoodNum40>=2&&met[4]>150")&&cutOSSF,60, 0., 300.,-1., false, "mll", "mll_SF_Aachen_pt2010_met");
2063 < //    make_data_comparison_plot("mll", TCut("pfJetGoodNum40>=2&&met[4]>150")&&cutOSOF,60, 0., 300.,-1., false, "mll", "mll_OF_Aachen_pt2010_met");
2064 < //    make_data_comparison_plot("mll", TCut("pfJetGoodNum40>=2&&met[1]>150")&&cutOSSF,60, 0., 300.,-1., true, "mll", "mll_SF_Aachen_pt2010_t1cpfmet");
2065 < //    make_data_comparison_plot("mll", TCut("pfJetGoodNum40>=2&&met[1]>150")&&cutOSOF,60, 0., 300.,-1., true, "mll", "mll_OF_Aachen_pt2010_t1cpfmet");
2066 < //    basiccut=TCut(basiccutsaved.c_str());
2067 <    
2068 < //     make_data_comparison_plot("pfJetGoodNum40", cutOSSF, 8, 0., 8.,-1., true, "#(jets)", "njets_SF");
2069 < //     make_data_comparison_plot("pfJetGoodNum40", cutOSOF, 8, 0., 8.,-1., true, "#(jets)", "njets_OF");
2070 <    
2071 < //     make_data_comparison_plot("mll", TCut("pfJetGoodNum40>=3&&met[4]>100")&&cutOSSF,60, 0., 300.,-1., true, "mll", "mll_SF_ETH_met");
2072 < //     make_data_comparison_plot("mll", TCut("pfJetGoodNum40>=3&&met[4]>100")&&cutOSOF,60, 0., 300.,-1., true, "mll", "mll_OF_ETH_met");
2073 < //     make_data_comparison_plot("mll", TCut("pfJetGoodNum40>=3&&met[1]>100")&&cutOSSF,60, 0., 300.,-1., true, "mll", "mll_SF_ETH_t1cpfmet");
2074 < //     make_data_comparison_plot("mll", TCut("pfJetGoodNum40>=3&&met[1]>100")&&cutOSOF,60, 0., 300.,-1., true, "mll", "mll_OF_ETH_t1cpfmet");
2075 <
2076 <    
2077 < /*     make_data_comparison_plot("mll", cutOSSF,60, 15., 315.,-1., true, "m_{ll}", "mll_SF_inclusive");
2078 <     make_data_comparison_plot("mll", cutOSSF&&TCut("id1==0"),60, 15., 315.,-1., true, "m_{ll}", "mll_SF_inclusive_ee");
2079 <     make_data_comparison_plot("mll", cutOSSF&&TCut("id1==1"),60, 15., 315.,-1., true, "m_{ll}", "mll_SF_inclusive_mm");
2080 <     make_data_comparison_plot("mll", cutOSOF,60, 15., 315.,-1., true, "m_{ll}", "mll_OF_inclusive");
2061 >    basiccut=TCut(newbasiccut.c_str());
2062 >    make_data_comparison_plot("mll", TCut("pfJetGoodNum40>=2&&met[4]>150")&&cutOSSF,60, 0., 300.,-1., false, "mll", "mll_SF_Aachen_pt2010_met");
2063 >    make_data_comparison_plot("mll", TCut("pfJetGoodNum40>=2&&met[4]>150")&&cutOSOF,60, 0., 300.,-1., false, "mll", "mll_OF_Aachen_pt2010_met");
2064 >    make_data_comparison_plot("mll", TCut("pfJetGoodNum40>=2&&met[1]>150")&&cutOSSF,60, 0., 300.,-1., true, "mll", "mll_SF_Aachen_pt2010_t1cpfmet");
2065 >    make_data_comparison_plot("mll", TCut("pfJetGoodNum40>=2&&met[1]>150")&&cutOSOF,60, 0., 300.,-1., true, "mll", "mll_OF_Aachen_pt2010_t1cpfmet");
2066 >    basiccut=TCut(basiccutsaved.c_str());
2067 >    
2068 >    make_data_comparison_plot("pfJetGoodNum40", cutOSSF, 8, 0., 8.,-1., true, "#(jets)", "njets_SF");
2069 >    make_data_comparison_plot("pfJetGoodNum40", cutOSOF, 8, 0., 8.,-1., true, "#(jets)", "njets_OF");
2070 >    
2071 >    make_data_comparison_plot("mll", TCut("pfJetGoodNum40>=3&&met[4]>100")&&cutOSSF,60, 0., 300.,-1., true, "mll", "mll_SF_ETH_met");
2072 >    make_data_comparison_plot("mll", TCut("pfJetGoodNum40>=3&&met[4]>100")&&cutOSOF,60, 0., 300.,-1., true, "mll", "mll_OF_ETH_met");
2073 >    make_data_comparison_plot("mll", TCut("pfJetGoodNum40>=3&&met[1]>100")&&cutOSSF,60, 0., 300.,-1., true, "mll", "mll_SF_ETH_t1cpfmet");
2074 >    make_data_comparison_plot("mll", TCut("pfJetGoodNum40>=3&&met[1]>100")&&cutOSOF,60, 0., 300.,-1., true, "mll", "mll_OF_ETH_t1cpfmet");
2075 >
2076 >    
2077 >    make_data_comparison_plot("mll", cutOSSF,60, 15., 315.,-1., true, "m_{ll}", "mll_SF_inclusive");
2078 >    make_data_comparison_plot("mll", cutOSSF&&TCut("id1==0"),60, 15., 315.,-1., true, "m_{ll}", "mll_SF_inclusive_ee");
2079 >    make_data_comparison_plot("mll", cutOSSF&&TCut("id1==1"),60, 15., 315.,-1., true, "m_{ll}", "mll_SF_inclusive_mm");
2080 >    make_data_comparison_plot("mll", cutOSOF,60, 15., 315.,-1., true, "m_{ll}", "mll_OF_inclusive");
2081      make_data_comparison_plot("mll", cutnJets&&cutOSSF&&TCut("id1==0"),60, 15., 315.,-1., true, "m_{ll}", "mll_SF_exclusive_ee");
2082      make_data_comparison_plot("mll", cutnJets&&cutOSSF&&TCut("id1==1"),60, 15., 315.,-1., true, "m_{ll}", "mll_SF_exclusive_mm");
2083      make_data_comparison_plot("mll", cutnJets&&cutOSSF,60, 15., 315.,-1., true, "m_{ll}", "mll_SF_exclusive");
2084      make_data_comparison_plot("mll", cutnJets&&cutOSOF,60, 15., 315.,-1., true, "m_{ll}", "mll_OF_exclusive");
2085 < */
2085 >
2086      make_data_comparison_plot("mll", cutOSSF&&cutSignal&&mllCut,           massnbins, 15., 315.,-1., false, "m_{ll}", "mll_SF_sig");
2087      make_data_comparison_plot("mll", cutOSOF&&cutSignal&&mllCut,           massnbins, 15., 315.,-1., false, "m_{ll}", "mll_OF_sig");
2088      
# Line 1012 | Line 2095 | void do_kinematic_plots(string mcjzb, st
2095      make_data_comparison_plot("mll", cutOSSF&&cutSignal&&mllCut&&"pfJetGoodNumBtag30>0",  massnbins, 15., 315.,-1., false, "m_{ll}", "mll_SF_sig_AtLeastOneBJet");
2096      make_data_comparison_plot("mll", cutOSOF&&cutSignal&&mllCut&&"pfJetGoodNumBtag30>0",  massnbins, 15., 315.,-1., false, "m_{ll}", "mll_OF_sig_AtLeastOneBJet");
2097  
2098 < /*
2098 >
2099      make_data_comparison_plot("mll", mllCut&&cutOSOF&&cutSignal, massnbins, 15., 315.,-1., false, "m_{ll}", "mll_OF_sig");
2100      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");
2101      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");
# Line 1021 | Line 2104 | void do_kinematic_plots(string mcjzb, st
2104      make_data_comparison_plot("pfJetGoodNum40", cutOSOF&&cutSignal&&mllCut, 8, 0., 8.,-1., false, "#(jets)", "njets_OF_sig");
2105      make_data_comparison_plot("pfJetGoodNumBtag30", cutOSSF&&cutSignal&&mllCut, 8, 0., 8.,-1., false, "#(b-jets)", "nbjets_SF_sig");
2106      make_data_comparison_plot("pfJetGoodNumBtag30", cutOSOF&&cutSignal&&mllCut, 8, 0., 8.,-1., false, "#(b-jets)", "nbjets_OF_sig");
2107 <  */
2107 >
2108    }
2109  
2110  
2111    if ( doKin ) {
2112      string mllCut("");
2113 < /*  
2113 >    
2114 >    
2115 >  
2116      make_plain_kin_plot("met[4]",Cut2Str(cutOSOF&&TCut("mll>30&&mll<70&&pfJetGoodNum40==0")),40,0,400,dolog,"PFMET","Debunking/MET_OF_30to70_0j",doPF,true);
2117      make_plain_kin_plot("met[4]",Cut2Str(cutOSOF&&TCut("mll>30&&mll<70&&pfJetGoodNum40==1")),40,0,400,dolog,"PFMET","Debunking/MET_OF_30to70_1j",doPF,true);
2118      make_plain_kin_plot("met[4]",Cut2Str(cutOSOF&&TCut("mll>30&&mll<70&&pfTightHT>100&&pfJetGoodNum40==2")),40,0,400,dolog,"PFMET","Debunking/MET_OF_30to70_2j",doPF,true);
# Line 1037 | Line 2122 | void do_kinematic_plots(string mcjzb, st
2122      make_plain_kin_plot("met[4]",Cut2Str(cutOSOF&&TCut("mll>80&&mll<100&&pfJetGoodNum40==1")),40,0,400,dolog,"PFMET","Debunking/MET_OF_Z_1j",doPF,true);
2123      make_plain_kin_plot("met[4]",Cut2Str(cutOSOF&&TCut("mll>80&&mll<100&&pfTightHT>100&&pfJetGoodNum40==2")),40,0,400,dolog,"PFMET","Debunking/MET_OF_Z_2j",doPF,true);
2124      make_plain_kin_plot("met[4]",Cut2Str(cutOSOF&&TCut("mll>80&&mll<100&&pfTightHT>100&&pfJetGoodNum40==3")),40,0,400,dolog,"PFMET","Debunking/MET_OF_Z_3j",doPF,true);
2125 < */
2125 >
2126  
2127      make_plain_kin_plot("pfTightHT",Cut2Str(cutOSOF&&cutnJets),120,0,1200,dolog,"H_{T}","HT_3jets_OF",doPF,true);
2128      make_plain_kin_plot("pfTightHT",Cut2Str(cutOSSF&&cutnJets) ,120,0,1200,dolog,"H_{T}","HT_3jets_SF",doPF,true);
# Line 1055 | Line 2140 | void do_kinematic_plots(string mcjzb, st
2140      make_plain_kin_plot("met[1]",Cut2Str(cutOSOF&&TCut("mll>80&&mll<100&&pfTightHT>100&&pfJetGoodNum40==2")),40,0,400,dolog,"PFMET","Debunking/T1MET_OF_Z_2j",doPF,true);
2141      make_plain_kin_plot("met[1]",Cut2Str(cutOSOF&&TCut("mll>80&&mll<100&&pfTightHT>100&&pfJetGoodNum40==3")),40,0,400,dolog,"PFMET","Debunking/T1MET_OF_Z_3j",doPF,true);
2142  
2143 <     /*make_plain_kin_plot("met[4]",Cut2Str(cutOSSF&&cutnJets&&TCut("mll>20&&mll<70")),50,0,300,dolog,"PFMET","MET_SF_20to70",doPF,true);
2144 <     make_plain_kin_plot("met[4]",Cut2Str(cutOSOF&&cutnJets&&TCut("mll>20&&mll<70")),50,0,300,dolog,"PFMET","MET_OF_20to70",doPF,true);
1060 <    
1061 <     make_plain_kin_plot("met[4]",Cut2Str(cutOSSF&&cutnJets&&TCut("mll>120")),50,0,300,dolog,"PFMET","MET_SF_above120",doPF,true);
1062 <     make_plain_kin_plot("met[4]",Cut2Str(cutOSOF&&cutnJets&&TCut("mll>120")),50,0,300,dolog,"PFMET","MET_OF_above120",doPF,true);*/
1063 <    
1064 < /*     make_plain_kin_plot("met[4]",Cut2Str(cutOSSF&&TCut("pfJetGoodNum40==2")&&TCut("mll>20&&mll<70")),50,0,300,dolog,"PFMET","MET_SF_20to70___2jetsonly",doPF,true);
1065 <     make_plain_kin_plot("met[4]",Cut2Str(cutOSOF&&TCut("pfJetGoodNum40==2")&&TCut("mll>20&&mll<70")),50,0,300,dolog,"PFMET","MET_OF_20to70___2jetsonly",doPF,true);
1066 <    
1067 <     make_plain_kin_plot("met[4]",Cut2Str(cutOSSF&&TCut("pfJetGoodNum40==2")&&TCut("mll>120")),50,0,300,dolog,"PFMET","MET_SF_above120___2jetsonly",doPF,true);
1068 <     make_plain_kin_plot("met[4]",Cut2Str(cutOSOF&&TCut("pfJetGoodNum40==2")&&TCut("mll>120")),50,0,300,dolog,"PFMET","MET_OF_above120___2jetsonly",doPF,true);
1069 < */
1070 <    write_info(__FUNCTION__,"Last plot");
1071 <    
2143 >    make_plain_kin_plot("met[4]",Cut2Str(cutOSSF&&cutnJets&&TCut("mll>20&&mll<70")),50,0,300,dolog,"PFMET","MET_SF_20to70",doPF,true);
2144 >    make_plain_kin_plot("met[4]",Cut2Str(cutOSOF&&cutnJets&&TCut("mll>20&&mll<70")),50,0,300,dolog,"PFMET","MET_OF_20to70",doPF,true);
2145      
2146 +    make_plain_kin_plot("met[4]",Cut2Str(cutOSSF&&cutnJets&&TCut("mll>120")),50,0,300,dolog,"PFMET","MET_SF_above120",doPF,true);
2147 +    make_plain_kin_plot("met[4]",Cut2Str(cutOSOF&&cutnJets&&TCut("mll>120")),50,0,300,dolog,"PFMET","MET_OF_above120",doPF,true);
2148      
2149 +    make_plain_kin_plot("met[4]",Cut2Str(cutOSSF&&TCut("pfJetGoodNum40==2")&&TCut("mll>20&&mll<70")),50,0,300,dolog,"PFMET","MET_SF_20to70___2jetsonly",doPF,true);
2150 +    make_plain_kin_plot("met[4]",Cut2Str(cutOSOF&&TCut("pfJetGoodNum40==2")&&TCut("mll>20&&mll<70")),50,0,300,dolog,"PFMET","MET_OF_20to70___2jetsonly",doPF,true);
2151      
2152 +    make_plain_kin_plot("met[4]",Cut2Str(cutOSSF&&TCut("pfJetGoodNum40==2")&&TCut("mll>120")),50,0,300,dolog,"PFMET","MET_SF_above120___2jetsonly",doPF,true);
2153 +    make_plain_kin_plot("met[4]",Cut2Str(cutOSOF&&TCut("pfJetGoodNum40==2")&&TCut("mll>120")),50,0,300,dolog,"PFMET","MET_OF_above120___2jetsonly",doPF,true);
2154 +
2155      
2156 +    make_kin_plot("pfJetGoodPt[0]/pfJetGoodPt[1]","",45,1,10,dolog,"pt_{j}^{1}/pt_{j}^{2}","j1j2ratio",doPF,true);
2157 +    make_kin_plot("TMath::Abs(pfJetDphiMet[0])","",32,0,3.2,nolog,"|#Delta#phi(jet1,MET)|","dphiJ1MET",doPF,true);
2158 +    // Plots in signal region
2159 +    make_kin_plot("met[4]","",70,0,350,dolog,"MET [GeV]","met",doPF,true);
2160 +
2161 +
2162 +    make_kin_plot("MetFactor","",20,0,2,nolog,"MetFactor","MetFactor",doPF,true);
2163      
2164 +    make_ttbar_comparison("met[4]",40,0,400,(cutOSOF&&TCut("mll>30&&mll<70&&pfTightHT>100&&pfJetGoodNum40==2")),dolog,"PFMET","Debunking/MET_OF_30to70_2j__ALLMCSAMPLES");
2165 +    /*
2166 +    DoMCSystPlot("met[4]",40,0,400,(cutOSOF&&TCut("mll>30&&mll<70&&pfJetGoodNum40==0")),dolog,"PFMET","Debunking/MET_OF_30to70_0j");
2167 +    DoMCSystPlot("met[4]",40,0,400,(cutOSOF&&TCut("mll>30&&mll<70&&pfJetGoodNum40==1")),dolog,"PFMET","Debunking/MET_OF_30to70_1j");
2168 +    DoMCSystPlot("met[4]",40,0,400,(cutOSOF&&TCut("mll>30&&mll<70&&pfTightHT>100&&pfJetGoodNum40==2")),dolog,"PFMET","Debunking/MET_OF_30to70_2j");
2169 +    DoMCSystPlot("met[4]",40,0,400,(cutOSOF&&TCut("mll>30&&mll<70&&pfTightHT>100&&pfJetGoodNum40==3")),dolog,"PFMET","Debunking/MET_OF_30to70_3j");
2170 +
2171 +    DoMCSystPlot("met[4]",40,0,400,(cutOSSF&&TCut("mll>30&&mll<70&&pfJetGoodNum40==0")),dolog,"PFMET","Debunking/MET_SF_30to70_0j");
2172 +    DoMCSystPlot("met[4]",40,0,400,(cutOSSF&&TCut("mll>30&&mll<70&&pfJetGoodNum40==1")),dolog,"PFMET","Debunking/MET_SF_30to70_1j");
2173 +    DoMCSystPlot("met[4]",40,0,400,(cutOSSF&&TCut("mll>30&&mll<70&&pfTightHT>100&&pfJetGoodNum40==2")),dolog,"PFMET","Debunking/MET_SF_30to70_2j");
2174 +    DoMCSystPlot("met[4]",40,0,400,(cutOSSF&&TCut("mll>30&&mll<70&&pfTightHT>100&&pfJetGoodNum40==3")),dolog,"PFMET","Debunking/MET_SF_30to70_3j");
2175 +
2176 +    DoMCSystPlot("met[4]",40,0,400,(cutOSOF&&TCut("mll>80&&mll<100&&pfJetGoodNum40==0")),dolog,"PFMET","Debunking/MET_OF_Z_0j");
2177 +    DoMCSystPlot("met[4]",40,0,400,(cutOSOF&&TCut("mll>80&&mll<100&&pfJetGoodNum40==1")),dolog,"PFMET","Debunking/MET_OF_Z_1j");
2178 +    DoMCSystPlot("met[4]",40,0,400,(cutOSOF&&TCut("mll>80&&mll<100&&pfTightHT>100&&pfJetGoodNum40==2")),dolog,"PFMET","Debunking/MET_OF_Z_2j");
2179 +    DoMCSystPlot("met[4]",40,0,400,(cutOSOF&&TCut("mll>80&&mll<100&&pfTightHT>100&&pfJetGoodNum40==3")),dolog,"PFMET","Debunking/MET_OF_Z_3j");
2180 +
2181 +    
2182 +    DoMCSystPlot("mll", (int)((mll_hi-mll_low)/5),mll_low,mll_hi,cutnJets&&cutOSSF,dolog,"m_{ll} [GeV]","kinSys/mll");
2183 +    DoMCSystPlot("mll", (int)((mll_hi-mll_low)/5),mll_low,mll_hi,cutnJets&&cutOSSF&&TCut("id1==0"),dolog,"m_{ll} [GeV]","kinSys/mll_ee");
2184 +    DoMCSystPlot("mll", (int)((mll_hi-mll_low)/5),mll_low,mll_hi,cutnJets&&cutOSSF&&TCut("id1==1"),dolog,"m_{ll} [GeV]","kinSys/mll_mm");
2185 +    DoMCSystPlot("mll", (int)((mll_hi-mll_low)/5),mll_low,mll_hi,cutnJets&&cutOSOF,dolog,"m_{ll} [GeV]","kinSys/mll_osof");
2186 +
2187 +    DoMCSystPlot("mll", (int)((mll_hi-mll_low)/5),mll_low,mll_hi,cutOSSF,dolog,"m_{ll} [GeV]","kinSys/mll_inclusive");
2188 +    DoMCSystPlot("mll", (int)((mll_hi-mll_low)/5),mll_low,mll_hi,cutOSOF,dolog,"m_{ll} [GeV]","kinSys/mll_inclusive_osof");
2189 +
2190 +    DoMCSystPlot("pfJetGoodNum40", 9,-0.5,8.5,cutOSSF,dolog,"nJets","kinSys/nJets_ossf");
2191 +    DoMCSystPlot("pfJetGoodNum40", 9,-0.5,8.5,cutOSOF,dolog,"nJets","kinSys/nJets_osof");
2192      
2193 <    
2194 <     return;
2195 <    
2196 <    
2197 <    
2198 <     make_kin_plot("pfJetGoodPt[0]/pfJetGoodPt[1]","",45,1,10,dolog,"pt_{j}^{1}/pt_{j}^{2}","j1j2ratio",doPF,true);
2199 <     make_kin_plot("TMath::Abs(pfJetDphiMet[0])","",32,0,3.2,nolog,"|#Delta#phi(jet1,MET)|","dphiJ1MET",doPF,true);
2200 <    // Plots in signal region
2201 < //     make_kin_plot("met[4]","",70,0,350,dolog,"MET [GeV]","met",doPF,true);
2202 <     make_kin_plot("mll","mll>20"+mllCut,(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll",doPF,true);
2203 <     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);
2204 <     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);
2205 <     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);
2206 <    
2207 <     make_kin_plot("pfJetGoodNum40",mllCut,9,-0.5,8.5,dolog,"nJets","nJets",doPF);
2208 <     make_kin_plot("pfJetGoodNum40","",9,-0.5,8.5,dolog,"nJets","nJets_osof",doPF);
2209 <    
1095 < //     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);
1096 < //     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);
1097 < //     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);
1098 < //     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);
2193 >    DoMCSystPlot("pfJetGoodPt[0]/pfJetGoodPt[1]",45,1,10,cutnJets&&cutOSSF,dolog,"p_{T}^{J1} / p_{T}^{J2}","kinSys/j1j2ratio");
2194 >    DoMCSystPlot("TMath::Abs(pfJetDphiMet[0])",32,0,3.2,cutnJets&&cutOSSF,dolog,"|#Delta#phi(jet1,MET)|","kinSys/dphiJ1MET");
2195 >    DoMCSystPlot(datajzb,mcjzb, (int)((PlottingSetup::jzbHigh+110)/10),-110,PlottingSetup::jzbHigh,cutnJets&&cutOSSF&&Restrmasscut,dolog,"m_{ll} [GeV]","kinSys/jzb_OS_SFZP");
2196 >    DoMCSystPlot(datajzb,mcjzb, (int)((PlottingSetup::jzbHigh+110)/10),-110,PlottingSetup::jzbHigh,cutnJets&&cutOSOF&&Restrmasscut,dolog,"m_{ll} [GeV]","kinSys/jzb_OS_OFZP");
2197 >
2198 >    make_kin_plot("mll","mll>20"+mllCut,(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll",doPF,true);
2199 >    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);
2200 >    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);
2201 >    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);
2202 >    
2203 >    make_kin_plot("pfJetGoodNum40",mllCut,9,-0.5,8.5,dolog,"nJets","nJets",doPF);
2204 >    make_kin_plot("pfJetGoodNum40","",9,-0.5,8.5,dolog,"nJets","nJets_osof",doPF);
2205 >    
2206 >    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);
2207 >    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);
2208 >    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);
2209 >    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);
2210      
2211      
2212 < //     make_kin_plot("pfJetGoodNum40","met[4]>100"+mllCut,9,-0.5,8.5,dolog,"nJets","nJets_met100",doPF);
2213 < //     make_kin_plot("pfJetGoodNum40","met[4]>100",9,-0.5,8.5,dolog,"nJets","nJets_osof_met100",doPF);
2212 >    make_kin_plot("pfJetGoodNum40","met[4]>100"+mllCut,9,-0.5,8.5,dolog,"nJets","nJets_met100",doPF);
2213 >    make_kin_plot("pfJetGoodNum40","met[4]>100",9,-0.5,8.5,dolog,"nJets","nJets_osof_met100",doPF);
2214  
2215      // Further inclusive invariant mass plots
2216      make_kin_plot("mll",mllCut,(int)((mll_hi-mll_low))/5,mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive",doPF,true);
2217 < //     make_kin_plot("mll","",(int)((mll_hi-mll_low))/5,mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_ee",doPF,true);
2218 < //     make_kin_plot("mll","",(int)((mll_hi-mll_low))/5,mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_mm",doPF,true);
2217 >    make_kin_plot("mll","",(int)((mll_hi-mll_low))/5,mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_ee",doPF,true);
2218 >    make_kin_plot("mll","",(int)((mll_hi-mll_low))/5,mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_mm",doPF,true);
2219      make_kin_plot("mll",mllCut,(int)((mll_hi-mll_low))/5,mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_osof",doPF,true);
2220      
2221 <    //make_kin_plot("mll","",(int)((350-mll_low))/5,mll_low,350,dolog,"m_{ll} [GeV]","mll_inclusive_highrange",doPF);
2221 >    make_kin_plot("mll","",(int)((350-mll_low))/5,mll_low,350,dolog,"m_{ll} [GeV]","mll_inclusive_highrange",doPF);
2222      //if(!doPF) make_special_mll_plot((int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]");
2223      
2224      
2225      // Number of jets
2226      make_kin_plot("pfJetGoodNum40","",9,-0.5,8.5,dolog,"nJets","nJets_inclusive",doPF);
2227      make_kin_plot("pfJetGoodNum40","",9,-0.5,8.5,dolog,"nJets","nJets_osof_inclusive",doPF);
2228 <    //make_kin_plot("pfJetGoodNum40","",9,-0.5,8.5,dolog,"nJets","nJets_nocuts_except_mll_ossf",doPF);
2228 >    make_kin_plot("pfJetGoodNum40","",9,-0.5,8.5,dolog,"nJets","nJets_nocuts_except_mll_ossf",doPF);
2229      
2230      // Others
2231      make_kin_plot("numVtx","",(int)(30.5-(-0.5)),-0.5,30.5,nolog,"N(Vtx)","numVtx",doPF);
# Line 1146 | Line 2257 | void do_kinematic_plots(string mcjzb, st
2257      
2258      //   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);
2259      //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);
2260 <    //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);
2260 >    //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);*/
2261    }
2262 <    
2263 < //   make_special_obs_pred_mll_plot(datajzb,mcjzb,0);
2264 < //   make_special_obs_pred_mll_plot(datajzb,mcjzb,50);
2265 < //   make_special_obs_pred_mll_plot(datajzb,mcjzb,80);
2262 >    /*
2263 >   make_special_obs_pred_mll_plot(datajzb,mcjzb,0);
2264 >   make_special_obs_pred_mll_plot(datajzb,mcjzb,50);
2265 >   make_special_obs_pred_mll_plot(datajzb,mcjzb,80);
2266     make_special_obs_pred_mll_plot(datajzb,mcjzb,100);
2267 < //   make_special_obs_pred_mll_plot(datajzb,mcjzb,150);
2268 < //   make_special_obs_pred_mll_plot(datajzb,mcjzb,200);
2269 < //   make_special_obs_pred_mll_plot(datajzb,mcjzb,250);
1159 <
1160 < //   make_JES_plot(cutmass&&cutOSSF&&basiccut,"_ossf");
1161 < //   make_JES_plot(cutmass&&cutOSOF&&basiccut,"_osof");
2267 >   make_special_obs_pred_mll_plot(datajzb,mcjzb,150);
2268 >   make_special_obs_pred_mll_plot(datajzb,mcjzb,200);
2269 >   make_special_obs_pred_mll_plot(datajzb,mcjzb,250);
2270  
2271 +   make_JES_plot(cutmass&&cutOSSF&&basiccut,"_ossf");
2272 +   make_JES_plot(cutmass&&cutOSOF&&basiccut,"_osof");
2273 + */
2274    switch_overunderflow(false);
2275   }
2276  
# Line 1776 | Line 2887 | void do_prediction_plot(string jzb, TCan
2887   //    speciallegBpred->AddEntry(lm4RcorrJZBeemmC,"LM4","l");
2888   //     speciallegBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
2889      speciallegBpred->Draw();
2890 <    save_with_ratio(JRcorrJZBeemm,JBpred,predcomppad,subdir+"Bpred_Data_____PredictionComposition",true,true,"data/pred",BpredSys);
2890 >    Save_With_Ratio(JRcorrJZBeemm,JBpred,predcomppad,subdir+"Bpred_Data_____PredictionComposition",true,true,"data/pred",BpredSys);
2891 >    delete predcomppad;
2892      
2893      TCanvas *specialcanv = new TCanvas("specialcanv","specialcanv");
2894      specialcanv->SetLogy(1);
# Line 1859 | Line 2971 | void do_prediction_plot(string jzb, TCan
2971    string ytitle("ratio");
2972    if ( use_data==1 ) ytitle = "data/pred";
2973    //save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,Bpredsaveas,true,use_data!=1,ytitle);
2974 <  save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,subdir+Bpredsaveas,true,false,ytitle,BpredSys);//not extending the y range anymore up to 4
2974 >  Save_With_Ratio(JRcorrJZBeemm,JBpred,kinpad,subdir+Bpredsaveas,true,false,ytitle,BpredSys);//not extending the y range anymore up to 4
2975 >  
2976 >  delete kinpad;
2977  
2978  
2979    
# Line 2056 | Line 3170 | void lepton_comparison_plots() {
3170    eemmlegend->AddEntry(jmmd,"#mu#mu","l");
3171    eemmlegend->Draw();
3172    DrawPrelim();
3173 <  save_with_ratio(jeed,jmmd,eemmpad->cd(),"lepton_comparison/jzb_Comparing_ee_mm_data");
3173 >  Save_With_Ratio(jeed,jmmd,eemmpad->cd(),"lepton_comparison/jzb_Comparing_ee_mm_data");
3174    
3175    TH1F *zjeed = allsamples.Draw("zjeed",jzbvariablemc,    int((jzbHigh+150)/5),-150,jzbHigh , "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&"(id1==0)",mc,  luminosity,allsamples.FindSample("/DY"));
3176    TH1F *zjmmd = allsamples.Draw("zjmmd",jzbvariablemc,    int((jzbHigh+150)/5),-150,jzbHigh , "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&"(id1==1)",mc,  luminosity,allsamples.FindSample("/DY"));
# Line 2179 | Line 3293 | void draw_pure_jzb_histo(TCut cut,string
3293    TText *writeline1 = write_cut_on_canvas(write_cut.c_str());
3294    writeline1->SetTextSize(0.035);
3295    writeline1->Draw();
3296 <  if(!Contains(savename,"Dibosons")) save_with_ratio(datahisto,mcstack,jzbpad->cd(),("jzb/"+savename));
3297 <  else save_with_ratio(datahisto,mcstack,jzbpad->cd(),savename);
3296 >  if(!Contains(savename,"Dibosons")) Save_With_Ratio(datahisto,mcstack,jzbpad->cd(),("jzb/"+savename));
3297 >  else Save_With_Ratio(datahisto,mcstack,jzbpad->cd(),savename);
3298    TPad *jzbpad2 = new TPad("jzbpad2","jzbpad2",0,0,1,1);
3299    jzbpad2->cd();
3300    jzbpad2->SetLogy(1);
# Line 2195 | Line 3309 | void draw_pure_jzb_histo(TCut cut,string
3309    writeline1->SetTextSize(0.035);
3310    writeline1->Draw();
3311    DrawPrelim();
3312 <  if(!Contains(savename,"Dibosons")) save_with_ratio(datahisto,mcstack,jzbpad2->cd(),("jzb/PositiveSideOnly/"+savename+""));
3313 <  else save_with_ratio(datahisto,mcstack,jzbpad2->cd(),(savename+"__PosOnly"));
3312 >  if(!Contains(savename,"Dibosons")) Save_With_Ratio(datahisto,mcstack,jzbpad2->cd(),("jzb/PositiveSideOnly/"+savename+""));
3313 >  else Save_With_Ratio(datahisto,mcstack,jzbpad2->cd(),(savename+"__PosOnly"));
3314    datahisto->Delete();
3315    mcstack.Delete();
3316   }
# Line 2304 | Line 3418 | void draw_normalized_data_vs_data_histo(
3418    leg->AddEntry(datahisto2,legentry2.c_str());
3419    leg->Draw();
3420    
3421 <  save_with_ratio(datahisto1,datahisto2,jzbpad->cd(),("jzb/"+savename));
3421 >  Save_With_Ratio(datahisto1,datahisto2,jzbpad->cd(),("jzb/"+savename));
3422    
3423    datahisto1->Delete();
3424    datahisto2->Delete();
# Line 2798 | Line 3912 | void find_correction_factors(string &jzb
3912    
3913   }
3914  
3915 < void pick_up_events(string cut) {
3916 <  dout << "Picking up events with cut " << cut << endl;
2803 <  allsamples.PickUpEvents(cut);
3915 > void pick_up_events(string cut, string filename) {
3916 >  allsamples.PickUpEvents(cut,filename);
3917   }
3918  
3919   void save_template(string mcjzb, string datajzb,vector<float> jzb_cuts,float MCPeakError,float DataPeakError, vector<float> jzb_shape_limit_bins) {
# Line 2912 | Line 4025 | void ttbar_sidebands_comparison(string m
4025        
4026    float simulatedlumi = luminosity; //in pb please - adjust to your likings
4027  
4028 <  TH1F *TZem  = systsamples.Draw("TZem",     mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSOF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTT"));
4029 <  TH1F *nTZem = systsamples.Draw("nTZem","-"+mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSOF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTT"));
4028 >  TH1F *TZem  = allsamples.Draw("TZem",     mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSOF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("/TT"));
4029 >  TH1F *nTZem = allsamples.Draw("nTZem","-"+mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSOF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("/TT"));
4030    TH1F *TSem;
4031    TH1F *nTSem;
4032 <  TH1F *TZeemm  = systsamples.Draw("TZeemm",     mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTT"));
4033 <  TH1F *nTZeemm = systsamples.Draw("nTZeemm","-"+mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTT"));
4032 >  TH1F *TZeemm  = allsamples.Draw("TZeemm",     mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("/TT"));
4033 >  TH1F *nTZeemm = allsamples.Draw("nTZeemm","-"+mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("/TT"));
4034    TH1F *TSeemm;
4035    TH1F *nTSeemm;
4036    
4037    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
4038 <    TSem    = systsamples.Draw("TSem",       mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSOF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTT"));
4039 <    nTSem   = systsamples.Draw("nTSem",  "-"+mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSOF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTT"));
4040 <    TSeemm  = systsamples.Draw("TSeemm",     mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSSF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTT"));
4041 <    nTSeemm = systsamples.Draw("nTSeemm","-"+mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSSF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTT"));
4038 >    TSem    = allsamples.Draw("TSem",       mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSOF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("/TT"));
4039 >    nTSem   = allsamples.Draw("nTSem",  "-"+mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSOF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("/TT"));
4040 >    TSeemm  = allsamples.Draw("TSeemm",     mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSSF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("/TT"));
4041 >    nTSeemm = allsamples.Draw("nTSeemm","-"+mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSSF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("/TT"));
4042    }
4043  
4044    TCanvas *tcan = new TCanvas("tcan","tcan");
# Line 3271 | Line 4384 | void zjets_prediction_comparison(string
4384    TLine *bottom = new TLine(binning[0],0.75,binning[binning.size()-1],0.75);
4385    
4386  
3274  cout << __LINE__ << endl;
4387    top->SetLineColor(kBlue);top->SetLineStyle(2);
4388    bottom->SetLineColor(kBlue);bottom->SetLineStyle(2);
4389    center->SetLineColor(kBlue);
# Line 3294 | Line 4406 | void zjets_prediction_comparison(string
4406    TH1F *RcorrJZBem       = systsamples.Draw("RcorrJZBem",var,binning, "JZB [GeV]", "events",cutmass&&cutOSOF&&reducedNJets&&ee_mm_tautau&&kPos&&massregioncut,mc,simulatedlumi,systsamples.FindSample("/DY"));
4407    TH1F *LcorrJZBem       = systsamples.Draw("LcorrJZBem",var,binning, "JZB [GeV]", "events",cutmass&&cutOSOF&&reducedNJets&&ee_mm_tautau&&kNeg&&massregioncut,mc,simulatedlumi,systsamples.FindSample("/DY"));
4408  
3297  cout << __LINE__ << endl;
4409    TH1F *RcorrJZBSBem;
4410    TH1F *LcorrJZBSBem;
4411    TH1F *RcorrJZBSBeemm;
4412    TH1F *LcorrJZBSBeemm;
4413  
3303  cout << __LINE__ << endl;
4414    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
4415      RcorrJZBSBem   = systsamples.Draw("RcorrJZBSBem",var,binning, "JZB [GeV]", "events",sidebandcut&&cutOSOF&&reducedNJets&&ee_mm_tautau&&kPos&&massregioncut,mc,simulatedlumi,systsamples.FindSample("/DY"));
4416      LcorrJZBSBem   = systsamples.Draw("LcorrJZBSBem",var,binning, "JZB [GeV]", "events",sidebandcut&&cutOSOF&&reducedNJets&&ee_mm_tautau&&kNeg&&massregioncut,mc,simulatedlumi,systsamples.FindSample("/DY"));
# Line 3323 | Line 4433 | void zjets_prediction_comparison(string
4433    
4434    Bpred->SetLineColor(kRed);
4435  
3326  cout << __LINE__ << endl;
4436    TAUhJZBpos->SetLineColor(kBlack);
4437    Bpred->SetLineColor(kRed);
4438    
# Line 3380 | Line 4489 | void zjets_prediction_comparison(string
4489    
4490    delete zcan;
4491    cutWeight=weightbackup;
3383
3384  cout << __LINE__ << endl;
4492   }
4493  
4494  
# Line 3499 | Line 4606 | void make_table(samplecollection &coll,
4606   }
4607  
4608   void met_jzb_cut(string datajzb, string mcjzb, vector<float> jzb_cut) {
4609 +  cout << "You probably don't want --met, you want --metplots ... " << endl;
4610 +  assert(0);
4611    /*we want a table like this:
4612      __________________     50   |   100  | ...
4613      | Data prediction |  a vs b | a vs b | ...
# Line 3732 | Line 4841 | void qcd_plots(string datajzb, string mc
4841    //3rd last argument: do special bpred ratio, 2nd last argument: extended range!, last: y-axis title
4842    string ytitle("ratio");
4843    if ( use_data==1 ) ytitle = "data/pred";
4844 <  save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,"QCD/Bpred",true,false,ytitle);
4844 >  Save_With_Ratio(JRcorrJZBeemm,JBpred,kinpad,"QCD/Bpred",true,false,ytitle);
4845 >  delete kinpad;
4846    
4847    TH1F *allevents = qcdsamples.Draw("allevents","pfJetGoodNum",1,0,100, "internal code", "events", "" ,mc, luminosity);
4848    TH1F *ossf = qcdsamples.Draw("ossf","pfJetGoodNum",1,0,100, "internal code", "events", cutOSSF ,mc, luminosity);
# Line 3969 | Line 5079 | void met_vs_jzb_plots(string datajzb, st
5079    lg->SetHeader("DY");
5080    
5081    lg->Draw();
5082 <  save_with_ratio(metright,metleft,metpad->cd(),"METvsJZBplots/ComparingLeftToRightinMETspectrum");
5082 >  Save_With_Ratio(metright,metleft,metpad->cd(),"METvsJZBplots/ComparingLeftToRightinMETspectrum");
5083    
5084    TPad *metpad3 = new TPad("metpad3","metpad3",0,0,1,1);
5085    metpad3->cd();
# Line 3987 | Line 5097 | void met_vs_jzb_plots(string datajzb, st
5097  
5098    lg2->Draw();
5099    
5100 <  save_with_ratio(obs,Bpred,metpad3->cd(),"METvsJZBplots/ComparingPredObsinMET");
5100 >  Save_With_Ratio(obs,Bpred,metpad3->cd(),"METvsJZBplots/ComparingPredObsinMET");
5101    
5102    TPad *metpad2 = new TPad("metpad2","metpad2",0,0,1,1);
5103    metpad2->cd();
# Line 4006 | Line 5116 | void met_vs_jzb_plots(string datajzb, st
5116    metlefta->Draw("histo");
5117    metrighta->Draw("same");
5118    lg->Draw();
5119 <  save_with_ratio(metrighta,metlefta,metpad2->cd(),"METvsJZBplots/ComparingLeftToRightinMET_type1_spectrum");
5119 >  Save_With_Ratio(metrighta,metlefta,metpad2->cd(),"METvsJZBplots/ComparingLeftToRightinMET_type1_spectrum");
5120    
5121    delete Bpred;
5122    delete obs;
# Line 4033 | Line 5143 | void met_vs_jzb_plots(string datajzb, st
5143    aobs->Draw("same");
5144    lg->SetHeader("All MC");
5145    lg->Draw();
5146 <  save_with_ratio(aobs,aBpred,metpad4->cd(),"METvsJZBplots/ComparingPredObsinMET_ALLSAMPLES");
5146 >  Save_With_Ratio(aobs,aBpred,metpad4->cd(),"METvsJZBplots/ComparingPredObsinMET_ALLSAMPLES");
5147    
5148    
5149    delete lg;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines