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.77 by buchmann, Fri Dec 14 13:24:29 2012 UTC vs.
Revision 1.87 by buchmann, Mon Feb 25 18:00:09 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 +  
98 +  TCanvas *can = new TCanvas("can","can");
99 +  float mcSigma,mcSigmaError,dataSigma,dataSigmaError;
100 +  
101 +  float NumVtxBin[6] = {0,5,10,15,20,30};
102 +  
103 +  stringstream NowCut;
104 +  
105 +  TGraphErrors *gMCPeak = new TGraphErrors();
106 +  gMCPeak->SetTitle("gMCPeak");
107 +  gMCPeak->SetName("gMCPeak");
108 +  TGraphErrors *gDataPeak = new TGraphErrors();
109 +  gDataPeak->SetTitle("gDataPeak");
110 +  gDataPeak->SetName("gDataPeak");
111 +  TGraphErrors *gMCWidth = new TGraphErrors();
112 +  gMCWidth->SetTitle("gMCWidth");
113 +  gMCWidth->SetName("gMCWidth");
114 +  TGraphErrors *gDataWidth = new TGraphErrors();
115 +  gDataWidth->SetTitle("gDataWidth");
116 +  gDataWidth->SetName("gDataWidth");
117 +  
118 +  for(int i=0;i<5;i++) {
119 +    NowCut.str("");
120 +    NowCut << "numVtx>=" << NumVtxBin[i] << "&&numVtx<" << NumVtxBin[i+1];
121 +    find_one_peak_combination(TCut(NowCut.str().c_str()),SwitchOffNJetsCut,MCPeak,MCPeakError, DataPeak,DataPeakError,mcSigma,mcSigmaError, dataSigma,dataSigmaError,result,doPUreweighting,"");
122 +    cout << "    " << MCPeak << " +/- " << MCPeakError << endl;
123 +    cout << "    " << DataPeak << " +/- " << DataPeakError << endl;
124 +    
125 +    gMCPeak->SetPoint(i,0.5*(NumVtxBin[i]+NumVtxBin[i+1]),MCPeak);
126 +    gMCPeak->SetPointError(i,0.5*(NumVtxBin[i+1]-NumVtxBin[i]),MCPeakError);
127 +    
128 +    gDataPeak->SetPoint(i,0.5*(NumVtxBin[i]+NumVtxBin[i+1]),DataPeak);
129 +    gDataPeak->SetPointError(i,0.5*(NumVtxBin[i+1]-NumVtxBin[i]),DataPeakError);
130 +    
131 +    gMCWidth->SetPoint(i,0.5*(NumVtxBin[i]+NumVtxBin[i+1]),mcSigma);
132 +    gMCWidth->SetPointError(i,0.5*(NumVtxBin[i+1]-NumVtxBin[i]),mcSigmaError);
133 +    
134 +    gDataWidth->SetPoint(i,0.5*(NumVtxBin[i]+NumVtxBin[i+1]),dataSigma);
135 +    gDataWidth->SetPointError(i,0.5*(NumVtxBin[i+1]-NumVtxBin[i]),dataSigmaError);
136 +  }
137 +  
138 +  can->cd();
139 +  gMCPeak->GetXaxis()->SetTitle("N(Vertices)");
140 +  gMCPeak->GetYaxis()->SetTitle("Peak position");
141 +  gMCPeak->GetXaxis()->CenterTitle();
142 +  gMCPeak->GetYaxis()->CenterTitle();
143 +  gDataPeak->GetXaxis()->SetTitle("N(Vertices)");
144 +  gDataPeak->GetYaxis()->SetTitle("Peak position");
145 +  gDataPeak->GetXaxis()->CenterTitle();
146 +  gDataPeak->GetYaxis()->CenterTitle();
147 +  
148 +  gDataWidth->GetXaxis()->SetTitle("N(Vertices)");
149 +  gDataWidth->GetYaxis()->SetTitle("#sigma_{JZB}");
150 +  gDataWidth->GetXaxis()->CenterTitle();
151 +  gDataWidth->GetYaxis()->CenterTitle();
152 +  gMCWidth->GetXaxis()->SetTitle("N(Vertices)");
153 +  gMCWidth->GetYaxis()->SetTitle("#sigma_{JZB}");
154 +  gMCWidth->GetXaxis()->CenterTitle();
155 +  gMCWidth->GetYaxis()->CenterTitle();
156 +  
157 +  gMCPeak->SetFillColor(TColor::GetColor("#2E9AFE"));
158 +  gDataPeak->SetFillColor(TColor::GetColor("#2E9AFE"));
159 +  gDataWidth->SetFillColor(TColor::GetColor("#2E9AFE"));
160 +  gMCWidth->SetFillColor(TColor::GetColor("#2E9AFE"));
161 +  
162 +  gMCPeak->Draw("A2");
163 +  DrawMCPrelim();
164 +  CompleteSave(can,"PUStudy/MCPeak");
165 +  can->cd();
166 +  gMCWidth->Draw("A2");
167 +  DrawMCPrelim();
168 +  CompleteSave(can,"PUStudy/MCWidth");
169 +  can->cd();
170 +  
171 +  gDataPeak->Draw("A2");
172 +  DrawPrelim();
173 +  CompleteSave(can,"PUStudy/DataPeak");
174 +  can->cd();
175 +  gDataWidth->Draw("A2");
176 +  DrawPrelim();
177 +  CompleteSave(can,"PUStudy/DataWidth");
178 +  
179 +  
180 +  
181 +  delete can;
182 +  
183 + }
184 +
185   void find_peaks(float &MCPeak,float &MCPeakError, float &DataPeak, float &DataPeakError, stringstream &result, bool doPUreweighting, stringstream &datajzb, stringstream &mcjzb, string sSpecialCut="", bool SwitchOffNJetsCut=false)
186   {
187    bool overunderflowstatus=addoverunderflowbins;
# Line 285 | Line 380 | void make_special_obs_pred_mll_plot(stri
380    }
381    delete Bpred;
382    delete ckin;
383 +  CleanLegends();
384   }
385  
386   void make_special_mll_plot(int nbins, float min, float max, bool logscale,string xlabel) {
# Line 331 | Line 427 | void make_special_mll_plot(int nbins, fl
427    delete datahistoOSOF;
428    delete datahistoOSSF;
429    delete ckin;
430 +  CleanLegends();
431   }
432    
433  
# Line 384 | Line 481 | float make_one_OFSF_plot(string variable
481  
482    cutOF = cutOSOF&&cutnJets&&ibasiccut;
483    cutSF = cutOSSF&&cutnJets&&ibasiccut;
484 +  
485 +  TCanvas *ofsf_can = new TCanvas("ofsf_can","ofsf_can");
486  
388  TCanvas *ckin = new TCanvas("ckin","Kinematic Plots (in the making)",600,600);
487    TPad* rcan = new TPad("rcan","rcan",0,0,1,1);
488    rcan->SetLogy(logscale);
489    rcan->cd();
# Line 410 | Line 508 | float make_one_OFSF_plot(string variable
508    }
509    if (ymax<0) {
510      if ( logscale ) datahistoSF->SetMaximum(5.3*datahistoSF->GetMaximum());
511 <    else datahistoSF->SetMaximum(1.8*datahistoSF->GetMaximum());
511 >    else datahistoSF->SetMaximum(0.8*datahistoSF->GetMaximum());
512    } else {
513      datahistoSF->SetMaximum(ymax);
514    }
# Line 437 | Line 535 | float make_one_OFSF_plot(string variable
535    mleg->Draw();
536    DrawPrelim();
537    if (datahistoOF->Integral()>0) {
538 <    save_with_ratio( datahistoSF, datahistoOF, rcan, "SFOF/" + filename, false, false, "SF/OF" );
538 >    Save_With_Ratio( datahistoSF, datahistoOF, rcan, "SFOF/" + filename, false, false, "SF/OF" );
539    } else {
540      CompleteSave(rcan, "SFOF/" + filename);
443    delete rcan;
541    }
542  
543    datahistoSF->Delete();
544    datahistoOF->Delete();
545    //signalhisto->Delete();
546    delete mleg;
547 <  delete ckin;
547 >  delete rcan;
548 >  delete ofsf_can;
549  
550    return ymaxSet;
551  
# Line 500 | Line 598 | float make_data_comparison_plot(string v
598    data2->Draw("HIST,SAMES");
599    mleg->Draw();
600    DrawPrelim();
601 <  save_with_ratio( data1, data2, rcan, "compareData/" + filename, false, false, "new/old" );
601 >  Save_With_Ratio( data1, data2, rcan, "compareData/" + filename, false, false, "new/old" );
602  
603    data1->Delete();
604    data2->Delete();
605    delete mleg;
606 +  delete rcan;
607    delete ckin;
608  
609   }
# Line 810 | Line 909 | void make_kin_plot(string variable, stri
909          DrawPrelim();
910          string saveas="kin/"+filename;
911          if(isPF) saveas="kin/"+filename+"__PF";
912 <        save_with_ratio(datahisto,mcstack,kinpad->cd(),saveas);
912 >        Save_With_Ratio(datahisto,mcstack,kinpad->cd(),saveas);
913   //      if(isPF) CompleteSave(with_ratio,"kin/"+filename+"__PF_withratio");
914   //      else CompleteSave(with_ratio,"kin/"+filename+"_withratio");
915   //      delete with_ratio;
# Line 873 | Line 972 | void make_plain_kin_plot(string variable
972          DrawPrelim();
973          string saveas="kin/"+filename;
974          if(isPF) saveas="kin/"+filename+"__PF";
975 <        save_with_ratio(datahisto,mcstack,kinpad->cd(),saveas);
975 >        Save_With_Ratio(datahisto,mcstack,kinpad->cd(),saveas);
976    } else {
977          if(isPF) CompleteSave(ckin,"kin/"+filename+"__PF");
978          else CompleteSave(ckin,"kin/"+filename);
# Line 925 | Line 1024 | void make_JES_plot(TCut cut, string name
1024    CompleteSave(ckin,"Systematics/JES"+name);
1025    datahisto->Delete();
1026    delete ckin;
1027 <
1027 >  delete JESunc;
1028 >  delete JESup;
1029 >  delete JESdn;
1030 >  CleanLegends();
1031   }
1032  
1033   string Cut2Str(TCut cut) {
# Line 965 | Line 1067 | void MakeElegantTwoThreeComparisons() {
1067      leg_SFOF_Two->AddEntry(TwoOF,"OF, nJets==2","l");
1068      leg_SFOF_Two->AddEntry(TwoSF,"SF, nJets==2","lp");
1069      leg_SFOF_Two->Draw();
1070 <    save_with_ratio(TwoSF,TwoOF,kin3->cd(),"DoubleRatios/SFOF_Two");
1070 >    Save_With_Ratio(TwoSF,TwoOF,kin3->cd(),"DoubleRatios/SFOF_Two");
1071      
1072      TPad *kin4 = new TPad("kin4","kin4",0,0,1,1);
1073      kin4->cd();
# Line 976 | Line 1078 | void MakeElegantTwoThreeComparisons() {
1078      leg_SFOF_Three->AddEntry(TwoOF,"OF, nJet#geq3","l");
1079      leg_SFOF_Three->AddEntry(TwoSF,"SF, nJets#geq3","lp");
1080      leg_SFOF_Three->Draw();
1081 <    save_with_ratio(ThreeSF,ThreeOF,kin4->cd(),"DoubleRatios/SFOF_Three");
1081 >    Save_With_Ratio(ThreeSF,ThreeOF,kin4->cd(),"DoubleRatios/SFOF_Three");
1082      
1083      
1084      TwoSF->Scale(ThreeSF->Integral()/TwoSF->Integral());
# Line 989 | Line 1091 | void MakeElegantTwoThreeComparisons() {
1091      leg_SF_Two_Three->AddEntry(TwoSF,"#splitline{SF, nJets==2}{ (scaled)}","l");
1092      leg_SF_Two_Three->AddEntry(ThreeSF,"SF, nJets#geq3","lp");
1093      leg_SF_Two_Three->Draw();
1094 <    save_with_ratio(TwoSF,ThreeSF,kin->cd(),"DoubleRatios/SF_Two_Three");
1094 >    Save_With_Ratio(TwoSF,ThreeSF,kin->cd(),"DoubleRatios/SF_Two_Three");
1095      
1096      TwoOF->Scale(ThreeOF->Integral()/TwoOF->Integral());
1097      TPad *kin2 = new TPad("kin2","kin2",0,0,1,1);
# Line 1001 | Line 1103 | void MakeElegantTwoThreeComparisons() {
1103      leg_OF_Two_Three->AddEntry(TwoSF,"#splitline{OF, nJets==2}{ (scaled)}","l");
1104      leg_OF_Two_Three->AddEntry(ThreeSF,"OF, nJets#geq3","lp");
1105      leg_OF_Two_Three->Draw();
1106 <    save_with_ratio(TwoOF,ThreeOF,kin2->cd(),"DoubleRatios/OF_Two_Three");
1106 >    Save_With_Ratio(TwoOF,ThreeOF,kin2->cd(),"DoubleRatios/OF_Two_Three");
1107 >    
1108 > }
1109 >
1110 > void PresentRange(TH1F *Down, TH1F *Up, TH1F *central, TVirtualPad *pad, string title) {
1111 >  pad->cd();
1112 >  TGraphErrors *gr = new TGraphErrors(Down->GetNbinsX());
1113 >  for(int i=1;i<=Down->GetNbinsX();i++) {
1114 >    float average=0.5*(Down->GetBinContent(i)+Up->GetBinContent(i));
1115 >    float error=abs(Down->GetBinContent(i)-average);
1116 >    gr->SetPoint(i-1,Down->GetBinCenter(i),average);
1117 >    gr->SetPointError(i-1,Down->GetBinWidth(i)/2.0,error);
1118 >  }
1119 >  gr->SetFillColor(TColor::GetColor("#F79F81"));
1120 >  gr->GetYaxis()->SetRangeUser(0,2);
1121 >  gr->GetXaxis()->SetTitle(central->GetXaxis()->GetTitle());
1122 >  gr->GetYaxis()->SetTitle(central->GetYaxis()->GetTitle());
1123 >  gr->GetXaxis()->CenterTitle();
1124 >  gr->GetYaxis()->CenterTitle();
1125 >  
1126 >  gr->Draw("A2");
1127 >  central->Draw("e1,same");
1128 >  DrawMCPrelim();
1129 >  TText *rtitle = write_text(0.8,0.8,title);
1130 >  TLine *line = new TLine(Down->GetBinLowEdge(1),1.0,Down->GetBinLowEdge(Down->GetNbinsX())+Down->GetBinWidth(Down->GetNbinsX()),1.0);
1131 >  line->SetLineColor(kBlue);
1132 >  line->SetLineStyle(2);
1133 >  line->Draw("same");
1134 >  rtitle->Draw("same");
1135 > }
1136 >
1137 > TH1F* ProduceTTbarRatio(TH1F *datahisto, TH1F *fullmc, TH1F *originalttbar, TH1F *httbar) {
1138 >  TH1F *basehisto = (TH1F*)fullmc->Clone("basehisto");
1139 >  basehisto->Add(originalttbar,-1);
1140 >  basehisto->Add(httbar);
1141 >  
1142 >  string sname=httbar->GetName();
1143 >  sname="R"+sname.substr(1,sname.length());
1144 >  TH1F *ratio = (TH1F*)datahisto->Clone(sname.c_str());
1145 >  ratio->Divide(basehisto);
1146 >  delete basehisto;
1147 >  return ratio;
1148 > }
1149 >  
1150 > void make_ttbar_comparison(string datavariable, string mcvariable, int nbins, float min, float max, TCut addcut, bool dolog, string xlabel, string filename) {
1151 >  
1152 >  TCut cut=addcut&&basiccut;
1153 >  
1154 >  TCanvas *ckin = new TCanvas("ckin","Kinematic Plots (in the making)",600,600);
1155 >  ckin->SetLogy(dolog);
1156 >  cout << "\r Creating " << filename << " : data   (1/7)" << std::flush;
1157 >  TH1F *datahisto = allsamples.Draw("datahisto",datavariable,nbins,min,max, xlabel, "events",cut,data,luminosity);
1158 >  datahisto->SetMarkerSize(DataMarkerSize);
1159 >  if ( !dolog ) datahisto->SetMinimum(0); // Defaults
1160 >  else datahisto->SetMinimum(0.5);
1161 >  if (dolog) datahisto->SetMaximum(5.3*datahisto->GetMaximum());
1162 >  else datahisto->SetMaximum(1.3*datahisto->GetMaximum());
1163 >  cout << "\r Creating " << filename << " : MC central  (stack) (2/7)" << std::flush;
1164 >  THStack mcstack   = allsamples.DrawStack("mcstack",  mcvariable,nbins,min,max,xlabel,"events",cut,mc,luminosity);
1165 >  TH1F *MCcentral = CollapseStack(mcstack);
1166 >
1167 >  cout << "\r Creating " << filename << " : MC central (histo)   (3/7)" << std::flush;
1168 >  TH1F *TCentral        = allsamples.Draw ("TCentral",     mcvariable,nbins,min,max,xlabel,"events",cut,mc,luminosity,allsamples.FindSample("TTJets_"));
1169 >  TH1F *RCentral        = ProduceTTbarRatio(datahisto,MCcentral,TCentral,TCentral);
1170 >  
1171 >  cout << "\r Creating " << filename << " : MC Matching up   (4/7)" << std::flush;
1172 >  TH1F *TMatchingUp     = systsamples.Draw("TMatchingUp",  mcvariable,nbins,min,max,xlabel,"events",cut,mc,luminosity,systsamples.FindSample("TTJets_matchingup"));
1173 >  TH1F *RMatchingUp     = ProduceTTbarRatio(datahisto,MCcentral,TCentral,TMatchingUp);
1174 >  
1175 >  cout << "\r Creating " << filename << " : MC Matching down   (5/7)" << std::flush;
1176 >  TH1F *TMatchingDown   = systsamples.Draw("TMatchingDown",mcvariable,nbins,min,max,xlabel,"events",cut,mc,luminosity,systsamples.FindSample("TTJets_matchingdown"));
1177 >  TH1F *RMatchingDown   = ProduceTTbarRatio(datahisto,MCcentral,TCentral,TMatchingDown);
1178 >  
1179 >  cout << "\r Creating " << filename << " : MC Scale up   (6/7)" << std::flush;
1180 >  TH1F *TScaleUp        = systsamples.Draw("TScaleUp",     mcvariable,nbins,min,max,xlabel,"events",cut,mc,luminosity,systsamples.FindSample("TTJets_scaleup"));
1181 >  TH1F *RScaleUp        = ProduceTTbarRatio(datahisto,MCcentral,TCentral,TScaleUp);
1182 >  
1183 >  cout << "\r Creating " << filename << " : MC Scale down   (7/7)" << std::flush;
1184 >  TH1F *TScaleDown      = systsamples.Draw("TScaleDown",   mcvariable,nbins,min,max,xlabel,"events",cut,mc,luminosity,systsamples.FindSample("TTJets_scaledown"));
1185 >  TH1F *RScaleDown      = ProduceTTbarRatio(datahisto,MCcentral,TCentral,TScaleDown);
1186 >  
1187 >  datahisto->Draw("e1");
1188 >  ckin->Update();
1189 >  mcstack.Draw("histo,same");
1190 >  
1191 >  datahisto->Draw("same,e1");
1192 >  TLegend *kinleg = allsamples.allbglegend();
1193 >  kinleg->Draw();
1194 >
1195 >  TPad *kinpad = new TPad("kinpad","kinpad",0,0,1,1);
1196 >  kinpad->SetLogy(dolog);
1197 >  kinpad->cd();
1198 >  datahisto->Draw("e1");
1199 >  mcstack.Draw("histo,same");
1200 >  datahisto->Draw("same,e1");
1201 >  datahisto->Draw("same,axis");
1202 >  
1203 >  kinleg->Draw("same");
1204 >  DrawPrelim();
1205 >  string saveas="kin/"+filename;
1206 >  
1207 >  cout << "Passing filename to be saved : " << filename << " as " << saveas << endl;
1208 >  Save_With_Ratio( datahisto, CollapseStack(mcstack), kinpad->cd(), saveas, false, false, "data/mc");
1209 >  delete kinpad;
1210 >  
1211 >  ckin->cd();
1212 >  TCentral->SetLineColor(kBlack);
1213 >  
1214 >  TMatchingUp->SetLineColor(TColor::GetColor("#2c17b1"));//blue
1215 >  TMatchingUp->SetLineStyle(2);//dashed
1216 >  TMatchingDown->SetLineColor(TColor::GetColor("#2c17b1"));
1217 >  TMatchingDown->SetLineStyle(3);//dotted
1218 >  
1219 >  TScaleUp->SetLineColor(TColor::GetColor("#FF8500"));//orange
1220 >  TScaleUp->SetLineStyle(2);//dashed
1221 >  TScaleDown->SetLineColor(TColor::GetColor("#FF8500"));
1222 >  TScaleDown->SetLineStyle(3);//dotted
1223 >  
1224 >  MCcentral->SetLineStyle(3);
1225 >  MCcentral->SetLineColor(kRed);
1226 >  
1227 >  TCentral->Draw("e1,same");
1228 >  TCentral->Draw("histo,same");
1229 >  TMatchingUp->Draw("histo,same");
1230 >  TMatchingDown->Draw("histo,same");
1231 >  TScaleUp->Draw("histo,same");
1232 >  TScaleDown->Draw("histo,same");
1233 >  
1234 >  TLegend *sleg = make_legend();
1235 >  sleg->AddEntry(TCentral,"Central","L");
1236 >  sleg->AddEntry(TMatchingUp,"matching up","L");
1237 >  sleg->AddEntry(TMatchingDown,"matching down","L");
1238 >  sleg->AddEntry(TScaleUp,"scale up","L");
1239 >  sleg->AddEntry(TScaleDown,"scale down","L");
1240 >  sleg->Draw();
1241 >  
1242 >  CompleteSave(ckin,saveas+"___AllLines");
1243 >  ckin->cd();
1244 >  ckin->SetLogy(0);
1245 >  
1246 >  RCentral->SetLineColor(kBlack);
1247 >  
1248 >  RMatchingUp->SetLineColor(TColor::GetColor("#2c17b1"));//blue
1249 >  RMatchingUp->SetLineStyle(2);//dashed
1250 >  RMatchingDown->SetLineColor(TColor::GetColor("#2c17b1"));
1251 >  RMatchingDown->SetLineStyle(3);//dotted
1252 >  
1253 >  RScaleUp->SetLineColor(TColor::GetColor("#FF8500"));//orange
1254 >  RScaleUp->SetLineStyle(2);//dashed
1255 >  RScaleDown->SetLineColor(TColor::GetColor("#FF8500"));
1256 >  RScaleDown->SetLineStyle(3);//dotted
1257 >  
1258 >  RCentral->GetYaxis()->SetRangeUser(0,2);
1259 >  RCentral->Draw("e1");
1260 >  RMatchingUp->Draw("histo,same");
1261 >  RMatchingDown->Draw("histo,same");
1262 >  RScaleUp->Draw("histo,same");
1263 >  RScaleDown->Draw("histo,same");
1264 >  
1265 >  CompleteSave(ckin,saveas+"___AllRatios");
1266 >
1267 >  TCanvas *multicanvas = new TCanvas("multicanvas","multicanvas",1400,700);
1268 >  multicanvas->Divide(2,1);
1269 >  PresentRange(RMatchingUp,RMatchingDown,RCentral,multicanvas->cd(1),"Matching");
1270 >  PresentRange(RScaleUp,RScaleDown,RCentral,multicanvas->cd(2),"Scale");
1271 >  CompleteSave(multicanvas,saveas+"___RangeIllustration");
1272 >  
1273 >  
1274 >  delete datahisto;
1275 >  delete   TCentral;
1276 >  delete   TMatchingUp;
1277 >  delete   TMatchingDown;
1278 >  delete   TScaleUp;
1279 >  delete   TScaleDown;
1280 > //   delete   Ttmass166;
1281 > //   delete   Ttmass169;
1282 > //   delete   Ttmass175;
1283 > //   delete   Ttmass178;
1284 >  
1285 >  delete ckin;
1286 >  
1287 > }
1288 >  
1289 > void make_ttbar_comparison(string variable, int nbins, float min, float max, TCut addcut, bool dolog, string xlabel, string filename) {
1290 >  make_ttbar_comparison(variable, variable, nbins, min, max, addcut, dolog, xlabel, filename);
1291 > }
1292 >
1293 > void ProduceJanPlots() {
1294 >  TCanvas *c1 = new TCanvas("c1","c1");
1295 >  TH1F *metSF = allsamples.Draw("metSF","met[4]",30,100,400, "E_{T}^{miss} [GeV]", "events", cutmass&&cutOSSF&&cutnJets,data, luminosity);
1296 >  TH1F *metOF = allsamples.Draw("metOF","met[4]",30,100,400, "E_{T}^{miss} [GeV]", "events", cutmass&&cutOSOF&&cutnJets,data, luminosity);
1297 >  
1298 >  TPad* rcan = new TPad("rcan","rcan",0,0,1,1);
1299 >  rcan->cd();
1300 >
1301 >  metOF->SetLineColor(kRed);
1302 >  metSF->Draw("e1");
1303 >  metOF->Draw("histo,same");
1304 >  metSF->Draw("e1,same");
1305 >  
1306 >  TLegend *leg = make_legend();
1307 >  
1308 >  leg->AddEntry(metSF,"Data SF","p");
1309 >  leg->AddEntry(metOF,"Data OF","l");
1310 >  leg->Draw();
1311 >  
1312 >  DrawPrelim();
1313 >  
1314 >  Save_With_Ratio(metSF,metOF,rcan,"JanPlots/ETHConfig",false,false,"SF/OF");
1315 >  
1316 >  delete rcan;
1317 >  delete metSF;
1318 >  delete metOF;
1319 >  delete c1;
1320 > }
1321 >
1322 > THStack MakeOneSystematicsPlot(TCut cut, string saveas, string variation, TH1F *hdata, string variable, int nbins, float bmin, float bmax, string label, TH1F* &thisto) {
1323 >  THStack SystPlot = allsamples.DrawStack(variation,variable,nbins,bmin,bmax,label,"events",cut,mc,PlottingSetup::luminosity);
1324 >  
1325 >  //now need to process the plot (calculate the variation and set the member of thstack accordingly!)
1326 >  if(variation!="Central") {
1327 >    TH1F *varttbar;
1328 >    if(variation=="MatchingUp") varttbar = systsamples.Draw("varttbar",variable,nbins,bmin,bmax,label,"events",cut,mc,PlottingSetup::luminosity,systsamples.FindSample("TTJets_matchingup_TuneZ2s"));
1329 >    if(variation=="MatchingDown") varttbar = systsamples.Draw("varttbar",variable,nbins,bmin,bmax,label,"events",cut,mc,PlottingSetup::luminosity,systsamples.FindSample("TTJets_matchingdown"));
1330 >    if(variation=="ScaleUp") varttbar = systsamples.Draw("varttbar",variable,nbins,bmin,bmax,label,"events",cut,mc,PlottingSetup::luminosity,systsamples.FindSample("TTJets_scaleup"));
1331 >    if(variation=="ScaleDown") varttbar = systsamples.Draw("varttbar",variable,nbins,bmin,bmax,label,"events",cut,mc,PlottingSetup::luminosity,systsamples.FindSample("TTJets_scaledown"));
1332 >    assert(varttbar);
1333 >    
1334 >    TIter nextHisto(SystPlot.GetHists());
1335 >    TH1F* h;
1336 >    while ( h = (TH1F*)nextHisto() ) {
1337 >      if(Contains(h->GetName(),"t_bar_t")) {
1338 >        varttbar->Scale(h->Integral()/varttbar->Integral());
1339 >        for(int i=0;i<=h->GetNbinsX()+1;i++) {//note that we deliberatly consider the under/overflow bin as well!
1340 >          h->SetBinContent(i,varttbar->GetBinContent(i));
1341 >          h->SetBinError(i,varttbar->GetBinError(i));
1342 >        }
1343 >        thisto=(TH1F*)varttbar->Clone(variation.c_str());
1344 >        SystPlot.Modified();
1345 >      }
1346 >    }
1347 >    delete varttbar;
1348 >  } else {
1349 >    TIter nextHisto(SystPlot.GetHists());
1350 >    TH1F* h;
1351 >    while ( h = (TH1F*)nextHisto() ) {
1352 >      if(Contains(h->GetName(),"t_bar_t")) thisto=(TH1F*)h->Clone(variation.c_str());
1353 >    }
1354 >  }
1355 >    
1356 >  TLegend *fullleg = allsamples.allbglegend();
1357 >  fullleg->SetHeader(variation.c_str());
1358 >  TPad *kinpad = new TPad("kinpad","kinpad",0,0,1,1);
1359 >  kinpad->SetLogy(1);
1360 >  kinpad->cd();
1361 >  
1362 >  hdata->Draw("e1");
1363 >  SystPlot.Draw("histo,same");
1364 >  hdata->Draw("e1,same");
1365 >  fullleg->Draw();
1366 >  DrawPrelim();
1367 >  
1368 >  Save_With_Ratio(hdata,SystPlot,kinpad,saveas+"_"+variation);
1369 >  CleanLegends();
1370 >  
1371 >  delete kinpad;
1372 >  return SystPlot;
1373 > }
1374 >  
1375 >
1376 >
1377 > void ProduceMCSystematicPlot(string variable, int nbins, float bmin, float bmax, string label, TCut thiscut, string saveas) {
1378 >  TCanvas *ca = new TCanvas("ca","ca");
1379 >  TH1F *hdata = allsamples.Draw("hdata",variable,nbins,bmin,bmax,label,"events",thiscut,data,luminosity);
1380 >  
1381 >  TH1F *tScaleUp,*tScaleDown,*tMatchingUp,*tMatchingDown,*tCentral;
1382 >  
1383 >  THStack ScaleUp      = MakeOneSystematicsPlot(thiscut,saveas,"ScaleUp",hdata,variable, nbins, bmin, bmax, label,tScaleUp);
1384 >  THStack ScaleDown    = MakeOneSystematicsPlot(thiscut,saveas,"ScaleDown",hdata,variable, nbins, bmin, bmax, label,tScaleDown);
1385 >  THStack MatchingUp   = MakeOneSystematicsPlot(thiscut,saveas,"MatchingUp",hdata,variable, nbins, bmin, bmax, label,tMatchingUp);
1386 >  THStack MatchingDown = MakeOneSystematicsPlot(thiscut,saveas,"MatchingDown",hdata,variable, nbins, bmin, bmax, label,tMatchingDown);
1387 >  
1388 >  TH1F *HScaleUp = CollapseStack(ScaleUp);
1389 >  TH1F *HScaleDown = CollapseStack(ScaleDown);
1390 >  TH1F *HMatchingUp = CollapseStack(MatchingUp);
1391 >  TH1F *HMatchingDown = CollapseStack(MatchingDown);
1392 >  
1393 >  THStack Central = MakeOneSystematicsPlot(thiscut,saveas,"Central",hdata,variable, nbins, bmin, bmax, label,tCentral);
1394 >  TH1F *HCentral = CollapseStack(Central);
1395 >  
1396 >  TH1F *Systematic = (TH1F*)hdata->Clone("Systematic");
1397 >  for(int i=1;i<=Systematic->GetNbinsX();i++) {
1398 >    float matchingup   = abs(HMatchingUp->GetBinContent(i)-HCentral->GetBinContent(i));
1399 >    float matchingdown = abs(HMatchingDown->GetBinContent(i)-HCentral->GetBinContent(i));
1400 >    float scaleup   = abs(HScaleUp->GetBinContent(i)-HCentral->GetBinContent(i));
1401 >    float scaledown = abs(HScaleDown->GetBinContent(i)-HCentral->GetBinContent(i));
1402 >    
1403 >    float matching = matchingup>matchingdown?matchingup:matchingdown;
1404 >    float scale    = scaleup>scaledown?scaleup:scaledown;
1405 >    
1406 >    float sys=sqrt(matching*matching+scale*scale);
1407 >    sys/=HCentral->GetBinContent(i);
1408 >    if(HCentral->GetBinContent(i)==0) sys=0;
1409 >    Systematic->SetBinContent(i,sys);
1410 >  }
1411 >  
1412 >  TPad *kinpad = new TPad("kinpad","kinpad",0,0,1,1);
1413 >  kinpad->SetLogy(1);
1414 >  kinpad->cd();
1415 >  if(variable=="genMET") {
1416 >    Central.Draw("histo");
1417 >  } else {
1418 >    hdata->Draw("e1");
1419 >    Central.Draw("histo,same");
1420 >    hdata->Draw("e1,same");
1421 >  }
1422 >  
1423 >  DrawPrelim();
1424 >  
1425 >  save_with_ratio_and_sys_band( hdata, HCentral, kinpad->cd(), saveas, false, false, "data/mc",Systematic );
1426 >  
1427 >  kinpad->cd();
1428 >  tCentral->SetFillColor(kWhite);
1429 >  tCentral->SetLineColor(kBlack);
1430 >  tScaleUp->SetLineColor(kRed);
1431 >  tScaleDown->SetLineColor(kRed);
1432 >  tMatchingUp->SetLineColor(kBlue);
1433 >  tMatchingDown->SetLineColor(kBlue);
1434 >  tScaleUp->SetLineStyle(2);
1435 >  tScaleDown->SetLineStyle(3);
1436 >  tMatchingUp->SetLineStyle(2);
1437 >  tMatchingDown->SetLineStyle(3);
1438 >  
1439 >  TLegend *leg2 = make_legend();
1440 >  leg2->AddEntry(hdata,"Data","p");
1441 >  leg2->AddEntry(tCentral,"Central (ttbar)","l");
1442 >  leg2->AddEntry(tScaleUp,"ScaleUp (ttbar)","l");
1443 >  leg2->AddEntry(tScaleDown,"ScaleDown (ttbar)","l");
1444 >  leg2->AddEntry(tMatchingUp,"MatchingUp (ttbar)","l");
1445 >  leg2->AddEntry(tMatchingDown,"MatchingDown (ttbar)","l");
1446 >  if(variable=="genMET") {
1447 >    Central.Draw("histo");
1448 >  }else {
1449 >    hdata->Draw("e1");
1450 >    Central.Draw("histo,same");
1451 >    hdata->Draw("e1,same");
1452 >  }
1453 >  tCentral->Draw("histo,same");
1454 >  tScaleUp->Draw("histo,same");
1455 >  tScaleDown->Draw("histo,same");
1456 >  tMatchingUp->Draw("histo,same");
1457 >  tMatchingDown->Draw("histo,same");
1458 >  leg2->Draw();
1459 >  
1460 >  CompleteSave(kinpad,saveas+"__TTbarComparison");
1461 >  
1462 >  gStyle->SetOptFit(0);
1463 >  
1464 >  kinpad->cd();
1465 >  kinpad->SetLogy(0);
1466 >  TH1F *MatchingRatio = (TH1F*)tMatchingUp->Clone("MatchingRatio");
1467 >  MatchingRatio->Divide(tMatchingDown);
1468 >  TLine *lone = new TLine(tScaleUp->GetBinLowEdge(1),1,tScaleUp->GetBinLowEdge(tScaleUp->GetNbinsX())+tScaleUp->GetBinWidth(tScaleUp->GetNbinsX()),1);
1469 >  lone->SetLineColor(TColor::GetColor("#01DF01"));
1470 >  lone->SetLineStyle(2);
1471 >  TH1F *ScaleRatio = (TH1F*)tScaleUp->Clone("ScaleRatio");
1472 >  ScaleRatio->Divide(tScaleDown);
1473 >  MatchingRatio->GetYaxis()->SetRangeUser(0,3);
1474 >  MatchingRatio->Draw("e1");
1475 >  TF1 *QP1 = new TF1("QP1","[0]+[1]*x",50,200);//simple linear function ranging from 50 to 200
1476 >  MatchingRatio->Fit("QP1","R");
1477 >  lone->Draw();
1478 >  stringstream summary;
1479 >  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);
1480 >  summary << " +/- " << DigitsAfterComma(QP1->GetParError(1),4) << "}}";
1481 >  TText *infobox = write_title(summary.str());
1482 >  infobox->SetX(0.75);
1483 >  infobox->SetTextSize(0.03);
1484 >  infobox->SetY(0.75);
1485 >  infobox->Draw();
1486 >  CompleteSave(kinpad,saveas+"__TTbarComparison_MatchingUpDividedMatchingDown");
1487 >  kinpad->cd();
1488 >  ScaleRatio->GetYaxis()->SetRangeUser(0,3);
1489 >  ScaleRatio->Draw("e1");
1490 >  ScaleRatio->Fit("QP1","R");
1491 >  summary.str("");
1492 >  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);
1493 >  summary << " +/- " << DigitsAfterComma(QP1->GetParError(1),4) << "}}";
1494 >  TText *infobox2 = write_title(summary.str());
1495 >  infobox2->SetX(0.75);
1496 >  infobox2->SetTextSize(0.03);
1497 >  infobox2->SetY(0.75);
1498 >  infobox2->Draw();
1499 >
1500 >  lone->Draw();
1501 >  CompleteSave(kinpad,saveas+"__TTbarComparison_ScaleUpDividedScaleDown");
1502 >  
1503 >  
1504 >  delete QP1;
1505 >  delete infobox;
1506 >  delete infobox2;
1507 >  delete MatchingRatio;
1508 >  delete ScaleRatio;
1509 >  DeleteStack(ScaleUp);
1510 >  DeleteStack(ScaleDown);
1511 >  DeleteStack(MatchingUp);
1512 >  DeleteStack(MatchingDown);
1513 >  delete leg2;
1514 >  CleanLegends();
1515 >  DeleteStack(Central);
1516 >  delete Systematic;
1517 >  delete HScaleUp;
1518 >  delete HScaleDown;
1519 >  delete HMatchingUp;
1520 >  delete HMatchingDown;
1521 >  delete hdata;
1522 >  delete HCentral;
1523 >  delete ca;
1524 > }
1525 >
1526 > TH1F* ImposeBinning(TH1F *binninghisto, TH1F* histo) {
1527 >  float val=0,err=0;
1528 >  vector<float> bins;
1529 >  vector<float> vals;
1530 >  vector<float> errs;
1531 >  
1532 >  bins.push_back(binninghisto->GetBinLowEdge(1));
1533 >  int iBin=1;
1534 >  
1535 >  for(unsigned int i=1;i<histo->GetNbinsX();i++) {//going to second last one on purpose!
1536 >    if((histo->GetBinLowEdge(i)+0.00001>=binninghisto->GetBinLowEdge(iBin)+binninghisto->GetBinWidth(iBin))) {
1537 >      bins.push_back(histo->GetBinLowEdge(i));
1538 >      vals.push_back(val);val=0;
1539 >      errs.push_back(err);err=0;
1540 >      iBin++;
1541 >    }
1542 >    val+=histo->GetBinContent(i);
1543 >    err=sqrt(err*err+histo->GetBinError(i)*histo->GetBinError(i));
1544 >  }
1545 >  bins.push_back(histo->GetBinLowEdge(histo->GetNbinsX())+histo->GetBinWidth(histo->GetNbinsX()));
1546 >  vals.push_back(val);val=0;
1547 >  errs.push_back(err);err=0;
1548 >  
1549 >  TH1F *h = new TH1F(("r"+(string)histo->GetName()).c_str(),("r"+(string)histo->GetName()).c_str(),bins.size()-1,&bins[0]);
1550 >  for(unsigned int i=0;i<vals.size();i++) {
1551 >    h->SetBinContent(i+1,vals[i]);
1552 >    h->SetBinError(i+1,errs[i]);
1553 >  }
1554 >  
1555 >  h->GetXaxis()->SetTitle(histo->GetXaxis()->GetTitle());
1556 >  h->GetYaxis()->SetTitle(histo->GetYaxis()->GetTitle());
1557 >  
1558 >  h->GetXaxis()->CenterTitle();
1559 >  h->GetYaxis()->CenterTitle();
1560 >
1561 >  return h;
1562 > }
1563 >
1564 >
1565 > TH1F* ReBinOptimizingStats(int nbins, TH1F *histo) {
1566 >  float statsperbin = (1/(float)nbins) * histo->Integral();
1567 >  float val=0,err=0;
1568 >  vector<float> bins;
1569 >  vector<float> vals;
1570 >  vector<float> errs;
1571 >  
1572 >  bins.push_back(histo->GetBinLowEdge(1));
1573 >  for(unsigned int i=1;i<=histo->GetNbinsX();i++) {
1574 >    val+=histo->GetBinContent(i);
1575 >    err=sqrt(err*err+histo->GetBinError(i)*histo->GetBinError(i));
1576 >    if( val/statsperbin > 0.85) {
1577 >      if(bins.size()<nbins) {
1578 >        bins.push_back(histo->GetBinLowEdge(i)+histo->GetBinWidth(i));
1579 >        vals.push_back(val);val=0;
1580 >        errs.push_back(err);err=0;
1581 >      }
1582 >    }
1583 >    if(i==histo->GetNbinsX()) {
1584 >      bins.push_back(histo->GetBinLowEdge(i)+histo->GetBinWidth(i));
1585 >      vals.push_back(val);val=0;
1586 >      errs.push_back(err);err=0;
1587 >    }
1588 >  }
1589 >  TH1F *h = new TH1F(("r"+(string)histo->GetName()).c_str(),("r"+(string)histo->GetName()).c_str(),bins.size()-1,&bins[0]);
1590 >  
1591 >  h->GetXaxis()->SetTitle(histo->GetXaxis()->GetTitle());
1592 >  h->GetYaxis()->SetTitle(histo->GetYaxis()->GetTitle());
1593 >  
1594 >  h->GetXaxis()->CenterTitle();
1595 >  h->GetYaxis()->CenterTitle();
1596 >  
1597 >  for(unsigned int i=0;i<vals.size();i++) {
1598 >    h->SetBinContent(i+1,vals[i]);
1599 >    h->SetBinError(i+1,errs[i]);
1600 >  }
1601 >  
1602 >  return h;
1603 > }
1604 >
1605 >
1606 >  
1607 > void ShowBinning(TH1F *histo) {
1608 >  cout << "Showing binning for " << histo->GetName() << " (\" " << histo->GetTitle() << "\")" << endl;
1609 >  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;
1610 > }
1611 >  
1612 > void QuickProduceMCSystematicPlot(string variable, int nbins, float bmin, float bmax, string label, TCut thiscut, string saveas) {
1613 >  TCanvas *ca = new TCanvas("ca","ca");
1614 >  TH1F *tScaleUp = systsamples.Draw("tScaleUp",variable,nbins,bmin,bmax,label,"events",thiscut,mc,luminosity,systsamples.FindSample("scaleup"));
1615 >  TH1F *tScaleDown = systsamples.Draw("tScaleDown",variable,nbins,bmin,bmax,label,"events",thiscut,mc,luminosity,systsamples.FindSample("scaledown"));
1616 >  TH1F *tMatchingUp = systsamples.Draw("tMatchingUp",variable,nbins,bmin,bmax,label,"events",thiscut,mc,luminosity,systsamples.FindSample("matchingup"));
1617 >  TH1F *tMatchingDown = systsamples.Draw("tMatchingDown",variable,nbins,bmin,bmax,label,"events",thiscut,mc,luminosity,systsamples.FindSample("matchingdown"));
1618 >  TH1F *tCentral = systsamples.Draw("tCentral",variable,nbins,bmin,bmax,label,"events",thiscut,mc,luminosity,systsamples.FindSample("TTJets_MassiveBinDECAY_TuneZ2sta"));
1619 >  
1620 >  tScaleUp->Scale(1.0/tScaleUp->Integral());
1621 >  tScaleDown->Scale(1.0/tScaleDown->Integral());
1622 >  tMatchingDown->Scale(1.0/tMatchingDown->Integral());
1623 >  tMatchingUp->Scale(1.0/tMatchingUp->Integral());
1624 >  tCentral->Scale(1.0/tCentral->Integral());
1625 >  
1626 >  cout << "At this point we want to rebin the scale/matching histograms so we get decent stats!" << endl;
1627 >  
1628 >  
1629 >  TH1F *rtScaleUp = ReBinOptimizingStats(7,tScaleUp); // using the scale up sample to get the binning (shouldn't use the central one for obvious reasons)
1630 >  TH1F *rtScaleDown = ImposeBinning(rtScaleUp,tScaleDown);
1631 >  TH1F *rtMatchingDown = ImposeBinning(rtScaleUp,tMatchingDown);
1632 >  TH1F *rtMatchingUp = ImposeBinning(rtScaleUp,tMatchingUp);
1633 >  TH1F *rtCentral = ImposeBinning(rtScaleUp,tCentral);
1634 >  
1635 >  float min=rtScaleUp->GetMinimum();
1636 >  float max=rtScaleUp->GetMaximum();
1637 >  
1638 >  if(rtScaleDown->GetMinimum()<min) min=rtScaleDown->GetMinimum();
1639 >  if(rtMatchingDown->GetMinimum()<min) min=rtMatchingDown->GetMinimum();
1640 >  if(rtMatchingDown->GetMinimum()<min) min=rtMatchingDown->GetMinimum();
1641 >  if(rtMatchingUp->GetMinimum()<min) min=rtMatchingUp->GetMinimum();
1642 >  if(rtCentral->GetMinimum()<min) min=rtCentral->GetMinimum();
1643 >  
1644 >  if(rtScaleDown->GetMaximum()<min) max=rtScaleDown->GetMaximum();
1645 >  if(rtMatchingDown->GetMaximum()<min) max=rtMatchingDown->GetMaximum();
1646 >  if(rtMatchingDown->GetMaximum()<min) max=rtMatchingDown->GetMaximum();
1647 >  if(rtMatchingUp->GetMaximum()<min) max=rtMatchingUp->GetMaximum();
1648 >  if(rtCentral->GetMaximum()<min) max=rtCentral->GetMaximum();
1649 >  
1650 >  rtCentral->SetMaximum(1.2*max);
1651 >  rtCentral->SetMinimum(0.8*min);
1652 >  
1653 > /*  tScaleUp->Rebin(40);
1654 >  tScaleDown->Rebin(40);
1655 >  tMatchingDown->Rebin(40);
1656 >  tMatchingUp->Rebin(40);
1657 >  tCentral->Rebin(40);*/
1658 >  
1659 >  TPad *kinpad = new TPad("kinpad","kinpad",0,0,1,1);
1660 >  kinpad->SetLogy(1);
1661 >  kinpad->cd();
1662 >  tCentral->SetFillColor(kWhite);
1663 >  tCentral->SetLineColor(kBlack);
1664 >  tScaleUp->SetLineColor(kRed);
1665 >  tScaleDown->SetLineColor(kRed);
1666 >  tMatchingUp->SetLineColor(kBlue);
1667 >  tMatchingDown->SetLineColor(kBlue);
1668 >  tScaleUp->SetLineStyle(2);
1669 >  tScaleDown->SetLineStyle(3);
1670 >  tMatchingUp->SetLineStyle(2);
1671 >  tMatchingDown->SetLineStyle(3);
1672 >  
1673 >  rtScaleDown->SetLineColor(kRed);
1674 >  rtMatchingUp->SetLineColor(kBlue);
1675 >  rtMatchingDown->SetLineColor(kBlue);
1676 >  rtScaleUp->SetLineStyle(2);
1677 >  rtScaleDown->SetLineStyle(3);
1678 >  rtMatchingUp->SetLineStyle(2);
1679 >  rtMatchingDown->SetLineStyle(3);
1680 >  
1681 >  TLegend *leg2 = make_legend();
1682 >  leg2->AddEntry(tCentral,"Central (ttbar)","l");
1683 >  leg2->AddEntry(tScaleUp,"ScaleUp (ttbar)","l");
1684 >  leg2->AddEntry(tScaleDown,"ScaleDown (ttbar)","l");
1685 >  leg2->AddEntry(tMatchingUp,"MatchingUp (ttbar)","l");
1686 >  leg2->AddEntry(tMatchingDown,"MatchingDown (ttbar)","l");
1687 >  
1688 >  tCentral->Draw("histo");
1689 >  tScaleUp->Draw("histo,same");
1690 >  tScaleDown->Draw("histo,same");
1691 >  tMatchingUp->Draw("histo,same");
1692 >  tMatchingDown->Draw("histo,same");
1693 >  leg2->Draw();
1694 >  DrawMCPrelim();
1695 >  CompleteSave(kinpad,saveas+"__TTbarComparison");
1696 >  kinpad->cd();
1697 >  kinpad->SetLogy(0);
1698 >  rtCentral->Draw("histo");
1699 >  rtScaleUp->Draw("histo,same");
1700 >  rtScaleDown->Draw("histo,same");
1701 >  rtMatchingUp->Draw("histo,same");
1702 >  rtMatchingDown->Draw("histo,same");
1703 >  leg2->Draw();
1704 >  DrawMCPrelim();
1705 >  CompleteSave(kinpad,saveas+"__TTbarComparison__REBINNED");
1706 >  
1707 >  
1708 >  gStyle->SetOptFit(0);
1709 >
1710 >  kinpad->cd();
1711 >  kinpad->SetLogy(0);
1712 >  TH1F *MatchingRatio = (TH1F*)rtMatchingUp->Clone("MatchingRatio");
1713 >  MatchingRatio->Divide(rtMatchingDown);
1714 >  TLine *lone = new TLine(tScaleUp->GetBinLowEdge(1),1,tScaleUp->GetBinLowEdge(tScaleUp->GetNbinsX())+tScaleUp->GetBinWidth(tScaleUp->GetNbinsX()),1);
1715 >  lone->SetLineColor(TColor::GetColor("#01DF01"));
1716 >  lone->SetLineStyle(2);
1717 >  TH1F *ScaleRatio = (TH1F*)rtScaleUp->Clone("ScaleRatio");
1718 >  ScaleRatio->Divide(rtScaleDown);
1719 >  MatchingRatio->GetYaxis()->SetRangeUser(0,3);
1720 >  MatchingRatio->Draw("e1");
1721 >  TF1 *QP1 = new TF1("QP1","[0]+[1]*x",50,200);//simple linear function ranging from 50 to 200
1722 >  if(variable=="genMET" || variable=="met[4]" || variable=="met[1]") MatchingRatio->Fit("QP1","RQ");
1723 >  lone->Draw();
1724 >  stringstream summary;
1725 >  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);
1726 >  summary << " +/- " << DigitsAfterComma(QP1->GetParError(1),4) << "}}";
1727 >  TText *infobox = write_title(summary.str());
1728 >  infobox->SetX(0.75);
1729 >  infobox->SetTextSize(0.03);
1730 >  infobox->SetY(0.75);
1731 >  if(variable=="genMET" || variable=="met[4]" || variable=="met[1]") infobox->Draw();
1732 >  DrawMCPrelim();
1733 >  CompleteSave(kinpad,saveas+"__TTbarComparison_MatchingUpDividedMatchingDown");
1734 >  kinpad->cd();
1735 >  ScaleRatio->GetYaxis()->SetRangeUser(0,3);
1736 >  ScaleRatio->Draw("e1");
1737 >  if(variable=="genMET" || variable=="met[4]" || variable=="met[1]") ScaleRatio->Fit("QP1","RQ");
1738 >  summary.str("");
1739 >  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);
1740 >  summary << " +/- " << DigitsAfterComma(QP1->GetParError(1),4) << "}}";
1741 >  TText *infobox2 = write_title(summary.str());
1742 >  infobox2->SetX(0.75);
1743 >  infobox2->SetTextSize(0.03);
1744 >  infobox2->SetY(0.75);
1745 >  if(variable=="genMET" || variable=="met[4]" || variable=="met[1]") infobox2->Draw();
1746 >
1747 >  lone->Draw();
1748 >  DrawMCPrelim();
1749 >  CompleteSave(kinpad,saveas+"__TTbarComparison_ScaleUpDividedScaleDown");
1750 >  
1751 >  kinpad->cd();
1752 >  TH1F *SysMatching = (TH1F*)rtMatchingDown->Clone("SysMatching");
1753 >  TH1F *SysScale = (TH1F*)rtScaleDown->Clone("SysMatching");
1754 >  TH1F *SysHisto = (TH1F*)rtScaleDown->Clone("SysHisto");
1755 >  
1756 >  for(int i=1;i<=SysScale->GetNbinsX();i++) {
1757 >    float matching, scale;
1758 >    bool AssumeFactor=false;
1759 >    if(AssumeFactor) {
1760 >      // assume that an upward/downward variation means a change by a constant factor, i.e. f(up) = alpha * f(central)
1761 >      matching=0.;
1762 >      scale=0.;
1763 >    } else {
1764 >      // assume that the central value is exactly between up & down, i.e. central = (up-down)/2
1765 >      matching = fabs(    ( rtMatchingUp->GetBinContent(i) - rtMatchingDown->GetBinContent(i)) / (rtMatchingUp->GetBinContent(i) + rtMatchingDown->GetBinContent(i)) );
1766 >      scale    = fabs(    ( rtScaleUp->GetBinContent(i) - rtScaleDown->GetBinContent(i)) / (rtScaleUp->GetBinContent(i) + rtScaleDown->GetBinContent(i)) );
1767 >    }
1768 >    
1769 >    SysMatching->SetBinContent(i,1+matching);
1770 >    SysScale->SetBinContent(i,1+scale);
1771 >    SysHisto->SetBinContent(i,sqrt(matching*matching+scale*scale)+1);
1772 >  }
1773 >  
1774 >  SysHisto->SetLineColor(kGreen);
1775 >  
1776 >  SysMatching->SetMaximum(3.0);
1777 >  SysMatching->SetMinimum(0.0);
1778 >  SysMatching->Draw("histo");
1779 >  SysScale->Draw("histo,same");
1780 >  SysHisto->Draw("histo,same");
1781 >  CompleteSave(kinpad,saveas+"__TTbarComparison_DerivedSystematic");
1782 >  
1783 >  delete SysMatching;
1784 >  delete SysScale;
1785 >  
1786 >  if(!Contains(variable,"gen")) {
1787 >    TH1F *hdata  = allsamples.Draw("hdata",   variable,nbins,bmin,bmax,label,"events",thiscut,data,luminosity);
1788 >    THStack smc = allsamples.DrawStack("smc",variable,nbins,bmin,bmax,label,"events",thiscut,mc,luminosity);
1789 >    
1790 >    TH1F *Systematic = (TH1F*)hdata->Clone("Systematic");
1791 >    
1792 >    for(int i=1;i<=Systematic->GetNbinsX();i++) {
1793 >      int iBin=SysHisto->FindBin(Systematic->GetBinCenter(i));
1794 >      if(iBin>SysHisto->GetNbinsX()) --iBin; // if we're over the end of the histo, use the last bin
1795 >      float sys = SysHisto->GetBinContent(iBin)-1;
1796 >      Systematic->SetBinContent(i,sys);
1797 >    }
1798      
1799 +    kinpad->cd();
1800 +    TLegend *leg = allsamples.allbglegend();
1801 +    hdata->Draw();
1802 +    smc.Draw("histo,same");
1803 +    hdata->Draw("same");
1804 +    leg->Draw();
1805 +    DrawPrelim();
1806 +    save_with_ratio_and_sys_band( hdata, CollapseStack(smc), kinpad->cd(), saveas+"__DataVsMC", false, false, "data/mc",Systematic );
1807 +    
1808 +    delete Systematic;
1809 +    delete hdata;
1810 +  }
1811 +  
1812 +  
1813 +  delete SysHisto;
1814 +  delete tScaleUp;
1815 +  delete tScaleDown;
1816 +  delete tCentral;
1817 +  delete tMatchingUp;
1818 +  delete tMatchingDown;
1819 +  delete rtScaleUp;
1820 +  delete rtScaleDown;
1821 +  delete rtCentral;
1822 +  delete rtMatchingUp;
1823 +  delete rtMatchingDown;
1824 +  delete QP1;
1825 +  delete infobox;
1826 +  delete infobox2;
1827 +  delete MatchingRatio;
1828 +  delete ScaleRatio;
1829 +  delete leg2;
1830 +  CleanLegends();
1831 +  delete ca;
1832 + }
1833 +
1834 + void ProduceMCSystematicPlots() {
1835 +  cout << "Getting ready to produce systematic plots " << endl;
1836 +  TCut cutweightBKP = cutWeight;
1837 +  
1838 +  QuickProduceMCSystematicPlot("genMET",20,0,200,"genMET [GeV]",cutOSSF&&cutnJets&&TCut("mll>20&&mll<70"),"MCSystPlots/genMET/ETH_SameFlavor");
1839 +  QuickProduceMCSystematicPlot("genMET",20,0,200,"genMET [GeV]",cutOSOF&&cutnJets&&TCut("mll>20&&mll<70"),"MCSystPlots/genMET/ETH_OppositeFlavor");
1840 +  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PFMET [GeV]",cutOSSF&&cutnJets&&TCut("mll>20&&mll<70"),"MCSystPlots/MET/ETH_SameFlavor");
1841 +  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PFMET [GeV]",cutOSOF&&cutnJets&&TCut("mll>20&&mll<70"),"MCSystPlots/MET/ETH_OppositeFlavor");
1842 +  
1843 +  QuickProduceMCSystematicPlot("genMET",20,0,200,"genMET [GeV]",cutOSSF&&TCut("mll>20&&mll<70"),"MCSystPlots/genMET/ETH_SameFlavor_INCLUSIVE");
1844 +  QuickProduceMCSystematicPlot("genMET",20,0,200,"genMET [GeV]",cutOSOF&&TCut("mll>20&&mll<70"),"MCSystPlots/genMET/ETH_OppositeFlavor_INCLUSIVE");  
1845 +  QuickProduceMCSystematicPlot("genMET",20,0,200,"genMET [GeV]",cutOSSF&&TCut("mll>120"),"MCSystPlots/genMET/ETH_SameFlavor_INCLUSIVE_HighMass");
1846 +  QuickProduceMCSystematicPlot("genMET",20,0,200,"genMET [GeV]",cutOSOF&&TCut("mll>120"),"MCSystPlots/genMET/ETH_OppositeFlavor_INCLUSIVE_HighMass");  
1847 +  
1848 +  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PFMET [GeV]",cutOSSF&&TCut("mll>20&&mll<70"),"MCSystPlots/MET/ETH_SameFlavor_INCLUSIVE");
1849 +  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PFMET [GeV]",cutOSOF&&TCut("mll>20&&mll<70"),"MCSystPlots/MET/ETH_OppositeFlavor_INCLUSIVE");
1850 +  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PFMET [GeV]",cutOSSF&&TCut("mll>120"),"MCSystPlots/MET/ETH_SameFlavor_INCLUSIVE_HighMass");
1851 +  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PFMET [GeV]",cutOSOF&&TCut("mll>120"),"MCSystPlots/MET/ETH_OppositeFlavor_INCLUSIVE_HighMass");
1852 +  QuickProduceMCSystematicPlot("pfJetGoodNum40",8,-0.5,7.5,"NJets",cutOSSF&&cutnJets&&TCut("mll>20&&mll<70&&met[4]>100"),"MCSystPlots/NJets/ETH_SameFlavor");
1853 +  QuickProduceMCSystematicPlot("pfJetGoodNum40",8,-0.5,7.5,"NJets",cutOSOF&&cutnJets&&TCut("mll>20&&mll<70&&met[4]>100"),"MCSystPlots/NJets/ETH_OppositeFlavor");
1854 +  
1855 +  
1856 +  
1857 +  cout << "Kicking cutWeight  " << (const char*) cutWeight << endl;
1858 +  cout << "Keeping OSSF cut " << (const char*)cutOSSF << endl;
1859 +  cutWeight="1.0";
1860 +  
1861 +  QuickProduceMCSystematicPlot("genMET",20,0,200,"genMET [GeV]",cutOSSF&&TCut("mll>20&&mll<70"),"MCSystPlots/genMET/ETH_SameFlavor_INCLUSIVE__NOPURW");
1862 +  QuickProduceMCSystematicPlot("genMET",20,0,200,"genMET [GeV]",cutOSOF&&TCut("mll>20&&mll<70"),"MCSystPlots/genMET/ETH_OppositeFlavor_INCLUSIVE__NOPURW");  
1863 +  QuickProduceMCSystematicPlot("genMET",20,0,200,"genMET [GeV]",cutOSSF&&TCut("mll>120"),"MCSystPlots/genMET/ETH_SameFlavor_INCLUSIVE_HighMass__NOPURW");
1864 +  QuickProduceMCSystematicPlot("genMET",20,0,200,"genMET [GeV]",cutOSOF&&TCut("mll>120"),"MCSystPlots/genMET/ETH_OppositeFlavor_INCLUSIVE_HighMass__NOPURW");  
1865 +  
1866 +  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PFMET [GeV]",cutOSSF&&TCut("mll>20&&mll<70"),"MCSystPlots/MET/ETH_SameFlavor_INCLUSIVE__NOPURW");
1867 +  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PFMET [GeV]",cutOSOF&&TCut("mll>20&&mll<70"),"MCSystPlots/MET/ETH_OppositeFlavor_INCLUSIVE__NOPURW");
1868 +  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PFMET [GeV]",cutOSSF&&TCut("mll>120"),"MCSystPlots/MET/ETH_SameFlavor_INCLUSIVE_HighMass__NOPURW");
1869 +  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PFMET [GeV]",cutOSOF&&TCut("mll>120"),"MCSystPlots/MET/ETH_OppositeFlavor_INCLUSIVE_HighMass__NOPURW");
1870 +  
1871 +  
1872 +  // --------------------------------------    ***** AACHEN *****      --------------------------------------    
1873 +  
1874 +  /*
1875 +  cutWeight=cutweightBKP;
1876 +  TCut essentialcutBKP = essentialcut;
1877 +  cout << (const char*) essentialcut << endl;
1878 +  
1879 +  essentialcut = TCut((ReplaceAll((const char*)essentialcut,"pt2>20","pt2>10")).c_str());
1880 +  essentialcut = TCut((ReplaceAll((const char*)essentialcut,"abs(eta1)<1.4","abs(eta1)<2.4")).c_str());
1881 +  essentialcut = TCut((ReplaceAll((const char*)essentialcut,"abs(eta2)<1.4","abs(eta2)<2.4")).c_str());
1882 +  
1883 +  TCut cutnJetsBKP = cutnJets;
1884 +  cutnJets = TCut((ReplaceAll((const char*)cutnJets,"pt2>20","pt2>10")).c_str());
1885 +  cutnJets = TCut((ReplaceAll((const char*)cutnJets,"pfJetGoodNum40>=3","pfJetGoodNum40>=2")).c_str());
1886 +  cutnJets = TCut((ReplaceAll((const char*)cutnJets,"abs(eta2)<1.4","abs(eta2)<2.4")).c_str());
1887 +  cutnJets = TCut((ReplaceAll((const char*)cutnJets,"abs(eta1)<1.4","abs(eta1)<2.4")).c_str());
1888 +  
1889 +  QuickProduceMCSystematicPlot("genMET",20,0,200,"genMET [GeV]",cutOSSF&&cutnJets&&TCut("mll>20&&mll<70"),"MCSystPlots/genMET/Aachen_SameFlavor");
1890 +  QuickProduceMCSystematicPlot("genMET",20,0,200,"genMET [GeV]",cutOSOF&&cutnJets&&TCut("mll>20&&mll<70"),"MCSystPlots/genMET/Aachen_OppositeFlavor");  
1891 +  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PFMET [GeV]",cutOSSF&&cutnJets&&TCut("mll>20&&mll<70"),"MCSystPlots/MET/Aachen_SameFlavor");
1892 +  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PFMET [GeV]",cutOSOF&&cutnJets&&TCut("mll>20&&mll<70"),"MCSystPlots/MET/Aachen_OppositeFlavor");
1893 +  
1894 +  QuickProduceMCSystematicPlot("genMET",20,0,200,"genMET [GeV]",cutOSSF&&TCut("mll>20&&mll<70"),"MCSystPlots/genMET/Aachen_SameFlavor_INCLUSIVE");
1895 +  QuickProduceMCSystematicPlot("genMET",20,0,200,"genMET [GeV]",cutOSOF&&TCut("mll>20&&mll<70"),"MCSystPlots/genMET/Aachen_OppositeFlavor_INCLUSIVE");  
1896 +  QuickProduceMCSystematicPlot("genMET",20,0,200,"genMET [GeV]",cutOSSF&&TCut("mll>120"),"MCSystPlots/genMET/Aachen_SameFlavor_INCLUSIVE_HighMass");
1897 +  QuickProduceMCSystematicPlot("genMET",20,0,200,"genMET [GeV]",cutOSOF&&TCut("mll>120"),"MCSystPlots/genMET/Aachen_OppositeFlavor_INCLUSIVE_HighMass");  
1898 +  
1899 +  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PFMET [GeV]",cutOSSF&&TCut("mll>20&&mll<70"),"MCSystPlots/MET/Aachen_SameFlavor_INCLUSIVE");
1900 +  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PFMET [GeV]",cutOSOF&&TCut("mll>20&&mll<70"),"MCSystPlots/MET/Aachen_OppositeFlavor_INCLUSIVE");
1901 +  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PFMET [GeV]",cutOSSF&&TCut("mll>120"),"MCSystPlots/MET/Aachen_SameFlavor_INCLUSIVE_HighMass");
1902 +  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PFMET [GeV]",cutOSOF&&TCut("mll>120"),"MCSystPlots/MET/Aachen_OppositeFlavor_INCLUSIVE_HighMass");
1903 +  QuickProduceMCSystematicPlot("pfJetGoodNum40",8,-0.5,7.5,"NJets",cutOSSF&&cutnJets&&TCut("mll>20&&mll<70&&met[4]>100"),"MCSystPlots/NJets/Aachen_SameFlavor");
1904 +  QuickProduceMCSystematicPlot("pfJetGoodNum40",8,-0.5,7.5,"NJets",cutOSOF&&cutnJets&&TCut("mll>20&&mll<70&&met[4]>100"),"MCSystPlots/NJets/Aachen_OppositeFlavor");
1905 +  
1906 +  
1907 +  
1908 +  cout << "Kicking cutWeight  " << (const char*) cutWeight << endl;
1909 +  cout << "Keeping OSSF cut " << (const char*)cutOSSF << endl;
1910 +  cutWeight="1.0";
1911 +  
1912 +  QuickProduceMCSystematicPlot("genMET",20,0,200,"genMET [GeV]",cutOSSF&&TCut("mll>20&&mll<70"),"MCSystPlots/genMET/Aachen_SameFlavor_INCLUSIVE__NOPURW");
1913 +  QuickProduceMCSystematicPlot("genMET",20,0,200,"genMET [GeV]",cutOSOF&&TCut("mll>20&&mll<70"),"MCSystPlots/genMET/Aachen_OppositeFlavor_INCLUSIVE__NOPURW");  
1914 +  QuickProduceMCSystematicPlot("genMET",20,0,200,"genMET [GeV]",cutOSSF&&TCut("mll>120"),"MCSystPlots/genMET/Aachen_SameFlavor_INCLUSIVE_HighMass__NOPURW");
1915 +  QuickProduceMCSystematicPlot("genMET",20,0,200,"genMET [GeV]",cutOSOF&&TCut("mll>120"),"MCSystPlots/genMET/Aachen_OppositeFlavor_INCLUSIVE_HighMass__NOPURW");  
1916 +  
1917 +  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PFMET [GeV]",cutOSSF&&TCut("mll>20&&mll<70"),"MCSystPlots/MET/Aachen_SameFlavor_INCLUSIVE__NOPURW");
1918 +  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PFMET [GeV]",cutOSOF&&TCut("mll>20&&mll<70"),"MCSystPlots/MET/Aachen_OppositeFlavor_INCLUSIVE__NOPURW");
1919 +  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PFMET [GeV]",cutOSSF&&TCut("mll>120"),"MCSystPlots/MET/Aachen_SameFlavor_INCLUSIVE_HighMass__NOPURW");
1920 +  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PFMET [GeV]",cutOSOF&&TCut("mll>120"),"MCSystPlots/MET/Aachen_OppositeFlavor_INCLUSIVE_HighMass__NOPURW");
1921 +  
1922 +  cutnJets  = cutnJetsBKP;
1923 +  cutWeight = cutweightBKP;
1924 +  essentialcut = essentialcutBKP;
1925 +  */
1926 +  write_error(__FUNCTION__,"Still need to add systematic shape");assert(0);
1927 + }
1928 +
1929 + void MakeTauPlot(string label, TCut pcut, string filename, bool TauOnly) {
1930 +  TCut cut=pcut&&basiccut;
1931 +  string variable="mll";
1932 +  string xlabel="m_{ll} [GeV]";
1933 +  int nbins=40;
1934 +  float min=0;
1935 +  float max=200;
1936 +
1937 +  TCanvas *ckin = new TCanvas("ckin","Kinematic Plots (in the making)",600,600);
1938 +  TH1F *datahistoSF = allsamples.Draw("datahistoSF",variable,nbins,min,max, xlabel, "events",cut&&cutOSSF,data,luminosity);
1939 +  TH1F *datahistoOF = allsamples.Draw("datahistoOF",variable,nbins,min,max, xlabel, "events",cut&&cutOSOF,data,luminosity);
1940 +  TH1F *tauSF = allsamples.Draw("tauSF",variable,nbins,min,max, xlabel, "events",cut&&cutOSSF,data,luminosity,systsamples.FindSample("DYToTauTau"));
1941 +  TH1F *tauOF = allsamples.Draw("tauOF",variable,nbins,min,max, xlabel, "events",cut&&cutOSOF,data,luminosity,systsamples.FindSample("DYToTauTau"));
1942 +  datahistoSF->SetMarkerSize(DataMarkerSize);
1943 +  datahistoSF->SetMaximum(1.3*datahistoSF->GetMaximum());
1944 +  datahistoOF->SetMarkerSize(DataMarkerSize);
1945 +  datahistoOF->SetMaximum(1.3*datahistoOF->GetMaximum());
1946 +
1947 +  THStack mcstackSF   = allsamples.DrawStack("mcstackSF",  variable,nbins,min,max,xlabel,"events",cut&&cutOSSF,mc,luminosity);
1948 +  THStack mcstackOF   = allsamples.DrawStack("mcstackOF",  variable,nbins,min,max,xlabel,"events",cut&&cutOSOF,mc,luminosity);
1949 +  datahistoSF->Draw("e1");
1950 +  ckin->Update();
1951 +  mcstackSF.Draw("histo,same");
1952 +  
1953 +  datahistoSF->Draw("same,e1");
1954 +  TLegend *kinleg = allsamples.allbglegend();
1955 +  kinleg->Draw();
1956 +  
1957 +  TPad *kinpad = new TPad("kinpad","kinpad",0,0,1,1);
1958 +  kinpad->cd();
1959 +  datahistoSF->Draw("e1");
1960 +  mcstackSF.Draw("histo,same");
1961 +  datahistoSF->Draw("same,e1");
1962 +  datahistoSF->Draw("same,axis");
1963 +  kinleg->Draw();
1964 +  DrawPrelim();
1965 +  Save_With_Ratio(datahistoSF,mcstackSF,kinpad->cd(),filename+"__SF_mc");
1966 +  
1967 +  kinpad->cd();
1968 +  datahistoOF->Draw("e1");
1969 +  mcstackOF.Draw("histo,same");
1970 +  datahistoOF->Draw("same,e1");
1971 +  datahistoOF->Draw("same,axis");
1972 +  kinleg->Draw();
1973 +  DrawPrelim();
1974 +  Save_With_Ratio(datahistoOF,mcstackOF,kinpad->cd(),filename+"__OF_mc");
1975 +  
1976 +  kinpad->cd();
1977 +  tauSF->Draw("e1");
1978 +  tauOF->Draw("histo,same");
1979 +  tauSF->Draw("e1,same");
1980 +  TLegend *legtau = make_legend();
1981 +  legtau->AddEntry(tauSF,"DY->#tau#tau, SF","p");
1982 +  legtau->AddEntry(tauSF,"DY->#tau#tau, OF","l");
1983 +  legtau->Draw();
1984 +  DrawPrelim();
1985 +  Save_With_Ratio(tauSF,tauOF,kinpad->cd(),filename+"__Tau_SF_vs_OF");
1986 +  
1987 +  delete datahistoSF;
1988 +  delete datahistoOF;
1989 +  delete tauSF;
1990 +  delete tauOF;
1991 +  delete kinpad;
1992 +  delete ckin;
1993 +  CleanLegends();
1994   }
1995 +  
1996  
1997 + void TauQuestion() {
1998 + //   MakeTauPlot("MET>100 GeV, #geq 3 jets",cutnJets&&TCut("met[4]>100"),"TauQ/MET100_3Jets",true);
1999 + //   MakeTauPlot("MET>100 GeV",TCut("met[4]>100"),"TauQ/MET100",true);
2000 + //   MakeTauPlot("MET>0 GeV",TCut("met[4]>0"),"TauQ/MET0",true);
2001 +  MakeTauPlot("b-tag veto, 50<MET<100",TCut("pfJetGoodNumBtag30==0&&met[4]>50&&met[4]<100"),"TauQ/ControlPlots",false);
2002 + }
2003  
2004   void do_kinematic_plots(string mcjzb, string datajzb, bool doPF=false)
2005   {
# Line 1027 | Line 2022 | void do_kinematic_plots(string mcjzb, st
2022    }
2023    
2024    if(MakeTwoThreeJetComparison) MakeElegantTwoThreeComparisons();
2025 +  
2026 +  //TauQuestion();
2027  
2028 +  //ProduceJanPlots();
2029 +  ProduceMCSystematicPlots();
2030 +  assert(0);
2031 + //  make_plain_kin_plot("pt",Cut2Str(cutOSSF&&TCut("mll>20&&pfJetGoodNumBtag30>=2")),40,0,200,nolog,"Z p_{T}","PlotForKostas",doPF,true);
2032 +  
2033    if ( doOFSF ) {
2034       make_OFSF_plots("mll", "met[4]>100", 60, 20., 320., false, "m_{ll}", "mll");
2035 +     make_OFSF_plots("met[4]", "met[4]>100", 30, 100., 400., false, "PFMET", "met");
2036 +     make_OFSF_plots("leptonNum", "met[4]>100", 3, 2, 5., false, "N(leptons)", "NLeptons");
2037  
2038 < //      make_OFSF_plots("pfJetGoodNum40", "met[4]>100",                        7, 3, 10, true, "#(jets)", "njets");
2039 < //      make_OFSF_plots("pfJetGoodNum40", "met[4]>100&&pfJetGoodNumBtag30==0", 7, 3, 10, true, "#(jets)", "njets_btagVeto");
2040 < //      make_OFSF_plots("pfJetGoodNum40", "met[4]>100&&pfJetGoodNumBtag30>0",  7, 3, 10, true, "#(jets)", "njets_AtLeastOneBJet30");
2041 <
2042 < //      make_OFSF_plots("pfJetGoodNumBtag30", "met[4]>100", 5, 0, 5, true, "#(b-jets)", "nbjets");
2043 < //      make_OFSF_plots("pfJetGoodPtBtag[0]", "met[4]>100&&pfJetGoodNumBtag30>0", 20, 0, 400, true, "p_{T}(leading b-jet)", "ptb1");
2044 <
2045 < //     make_OFSF_plots("iso1", "met[4]>100", 20, 0, 0.3, true, "lepton 1 isolation", "iso1");
2046 < //     make_OFSF_plots("iso2", "met[4]>100", 20, 0, 0.3, true, "lepton 2 isolation", "iso2");
2047 <    //  make_OFSF_plots("pt1",  "met[4]>100", 30, 0., 300., true, "p_{T,1}", "pt1");
2048 <    //  make_OFSF_plots("pt2",  "met[4]>100", 22, 0., 220., true, "p_{T,2}", "pt2");
2049 < //     make_OFSF_plots("eta1", "met[4]>100", 10, -2.5, 2.5, false, "#eta_{1}", "eta1", 0.15);
2050 < //     make_OFSF_plots("eta2", "met[4]>100", 10, -2.5, 2.5, false, "#eta_{2}", "eta2", 0.15);
2051 <    //  make_OFSF_plots("phi1", "met[4]>100", 10, -TMath::Pi(), TMath::Pi(), false, "#phi_{1}", "phi1", 0.2);
2052 <    //  make_OFSF_plots("phi2", "met[4]>100", 10, -TMath::Pi(), TMath::Pi(), false, "#phi_{2}", "phi2", 0.2);
2053 < //     make_OFSF_plots("pfJetGoodPt[0]/pfJetGoodPt[1]", "met[4]>100", 20, 1, 10, true, "pt_{j}^{1}/pt_{j}^{2}", "jpt1pt2", 0.2);
2054 <    make_OFSF_plots("TMath::Abs(pfJetDphiMet[0])", "met[4]>100", 16, 0, 3.2, false, "|#Delta#phi(jet1,MET)|", "dphij1met", 0.2);
2055 < //    make_OFSF_plots("TMath::Abs(dphi)", "met[4]>100", 16, 0, 3.2, false, "|#Delta#phi(l1,l2)|", "dphi", 0.2);
2056 < //    make_OFSF_plots("TMath::Abs(dphiMet1)", "met[4]>100", 16, 0, 3.2, false, "|#Delta#phi(l1,MET)|", "dphiMet1", 0.2);
2057 < //    make_OFSF_plots("TMath::Abs(dphiMet2)", "met[4]>100", 16, 0, 3.2, false, "|#Delta#phi(l2,MET)|", "dphiMet2", 0.2);
2058 < //    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");
2059 < //    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");
2060 < //    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");
2061 < //    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");
2038 >     make_OFSF_plots("pfJetGoodNum40", "met[4]>100",                        7, 3, 10, true, "#(jets)", "njets");
2039 >     make_OFSF_plots("pfJetGoodNum40", "met[4]>100&&pfJetGoodNumBtag30==0", 7, 3, 10, true, "#(jets)", "njets_btagVeto");
2040 >     make_OFSF_plots("pfJetGoodNum40", "met[4]>100&&pfJetGoodNumBtag30>0",  7, 3, 10, true, "#(jets)", "njets_AtLeastOneBJet30");
2041 >
2042 >     make_OFSF_plots("pfJetGoodNumBtag30", "met[4]>100", 5, 0, 5, true, "#(b-jets)", "nbjets");
2043 >     make_OFSF_plots("pfJetGoodPtBtag[0]", "met[4]>100&&pfJetGoodNumBtag30>0", 20, 0, 400, true, "p_{T}(leading b-jet)", "ptb1");
2044 >
2045 >     make_OFSF_plots("iso1", "met[4]>100", 20, 0, 0.3, true, "lepton 1 isolation", "iso1");
2046 >     make_OFSF_plots("iso2", "met[4]>100", 20, 0, 0.3, true, "lepton 2 isolation", "iso2");
2047 >     make_OFSF_plots("pt1",  "met[4]>100", 30, 0., 300., true, "p_{T,1}", "pt1");
2048 >     make_OFSF_plots("pt2",  "met[4]>100", 22, 0., 220., true, "p_{T,2}", "pt2");
2049 >     make_OFSF_plots("eta1", "met[4]>100", 10, -2.5, 2.5, false, "#eta_{1}", "eta1", 0.15);
2050 >     make_OFSF_plots("eta2", "met[4]>100", 10, -2.5, 2.5, false, "#eta_{2}", "eta2", 0.15);
2051 >     make_OFSF_plots("phi1", "met[4]>100", 10, -TMath::Pi(), TMath::Pi(), false, "#phi_{1}", "phi1", 0.2);
2052 >     make_OFSF_plots("phi2", "met[4]>100", 10, -TMath::Pi(), TMath::Pi(), false, "#phi_{2}", "phi2", 0.2);
2053 >     make_OFSF_plots("pfJetGoodPt[0]/pfJetGoodPt[1]", "met[4]>100", 20, 1, 10, true, "pt_{j}^{1}/pt_{j}^{2}", "jpt1pt2", 0.2);
2054 >     make_OFSF_plots("TMath::Abs(pfJetDphiMet[0])", "met[4]>100", 16, 0, 3.2, false, "|#Delta#phi(jet1,MET)|", "dphij1met", 0.2);
2055 >    make_OFSF_plots("TMath::Abs(dphi)", "met[4]>100", 16, 0, 3.2, false, "|#Delta#phi(l1,l2)|", "dphi", 0.2);
2056 >    make_OFSF_plots("TMath::Abs(dphiMet1)", "met[4]>100", 16, 0, 3.2, false, "|#Delta#phi(l1,MET)|", "dphiMet1", 0.2);
2057 >    make_OFSF_plots("TMath::Abs(dphiMet2)", "met[4]>100", 16, 0, 3.2, false, "|#Delta#phi(l2,MET)|", "dphiMet2", 0.2);
2058 >    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");
2059 >    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");
2060 >    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");
2061 >    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");
2062    }
2063  
2064    if ( doDataComp) {
# Line 1071 | Line 2075 | void do_kinematic_plots(string mcjzb, st
2075  
2076      TCut cutSignal = cutmass&&cutnJets&&"met[4]>100";
2077      
2078 < /*    make_data_comparison_plot("numVtx", "",40, -0.5, 39.5,-1., true, "N(Vertices)", "numVtx");
2078 >    make_data_comparison_plot("numVtx", "",40, -0.5, 39.5,-1., true, "N(Vertices)", "numVtx");
2079      make_data_comparison_plot("pfJetGoodEta[0]", "",50, -3.0, 3.0,-1., true, "N(Jets)", "pfJetGoodEta0");
2080      
2081      
# Line 1082 | Line 2086 | void do_kinematic_plots(string mcjzb, st
2086      make_data_comparison_plot("met[1]", cutOSOF,60, 0., 300.,-1., true, "type 1 corrected pfMET", "mett1_OF_inclusive");
2087      
2088      make_data_comparison_plot("met[4]", cutnJets&&cutOSSF,60, 0., 300.,-1., true, "pfMET", "met_SF_exclusive");
2089 < //    make_data_comparison_plot("met[1]", cutnJets&&cutOSSF,60, 0., 300.,-1., true, "type 1 corrected pfMET", "mett1_SF_exclusive");
2089 >    make_data_comparison_plot("met[1]", cutnJets&&cutOSSF,60, 0., 300.,-1., true, "type 1 corrected pfMET", "mett1_SF_exclusive");
2090      make_data_comparison_plot("met[4]", cutnJets&&cutOSOF,60, 0., 300.,-1., true, "pfMET", "met_OF_exclusive");
2091 < //    make_data_comparison_plot("met[1]", cutnJets&&cutOSOF,60, 0., 300.,-1., true, "type 1 corrected pfMET", "mett1_OF_exclusive");
2092 < */
2091 >    make_data_comparison_plot("met[1]", cutnJets&&cutOSOF,60, 0., 300.,-1., true, "type 1 corrected pfMET", "mett1_OF_exclusive");
2092 >
2093    
2094      string basiccutsaved = (const char*)basiccut;
2095      
# Line 1097 | Line 2101 | void do_kinematic_plots(string mcjzb, st
2101        newbasiccut.replace( found, string( "pt2>20" ).length(), "pt2>10" );
2102        found = newbasiccut.find( "pt2>20" );
2103      }
2104 < //    basiccut=TCut(newbasiccut.c_str());
2105 < //    make_data_comparison_plot("mll", TCut("pfJetGoodNum40>=2&&met[4]>150")&&cutOSSF,60, 0., 300.,-1., false, "mll", "mll_SF_Aachen_pt2010_met");
2106 < //    make_data_comparison_plot("mll", TCut("pfJetGoodNum40>=2&&met[4]>150")&&cutOSOF,60, 0., 300.,-1., false, "mll", "mll_OF_Aachen_pt2010_met");
2107 < //    make_data_comparison_plot("mll", TCut("pfJetGoodNum40>=2&&met[1]>150")&&cutOSSF,60, 0., 300.,-1., true, "mll", "mll_SF_Aachen_pt2010_t1cpfmet");
2108 < //    make_data_comparison_plot("mll", TCut("pfJetGoodNum40>=2&&met[1]>150")&&cutOSOF,60, 0., 300.,-1., true, "mll", "mll_OF_Aachen_pt2010_t1cpfmet");
2109 < //    basiccut=TCut(basiccutsaved.c_str());
2110 <    
2111 < //     make_data_comparison_plot("pfJetGoodNum40", cutOSSF, 8, 0., 8.,-1., true, "#(jets)", "njets_SF");
2112 < //     make_data_comparison_plot("pfJetGoodNum40", cutOSOF, 8, 0., 8.,-1., true, "#(jets)", "njets_OF");
2113 <    
2114 < //     make_data_comparison_plot("mll", TCut("pfJetGoodNum40>=3&&met[4]>100")&&cutOSSF,60, 0., 300.,-1., true, "mll", "mll_SF_ETH_met");
2115 < //     make_data_comparison_plot("mll", TCut("pfJetGoodNum40>=3&&met[4]>100")&&cutOSOF,60, 0., 300.,-1., true, "mll", "mll_OF_ETH_met");
2116 < //     make_data_comparison_plot("mll", TCut("pfJetGoodNum40>=3&&met[1]>100")&&cutOSSF,60, 0., 300.,-1., true, "mll", "mll_SF_ETH_t1cpfmet");
2117 < //     make_data_comparison_plot("mll", TCut("pfJetGoodNum40>=3&&met[1]>100")&&cutOSOF,60, 0., 300.,-1., true, "mll", "mll_OF_ETH_t1cpfmet");
2118 <
2119 <    
2120 < /*     make_data_comparison_plot("mll", cutOSSF,60, 15., 315.,-1., true, "m_{ll}", "mll_SF_inclusive");
2121 <     make_data_comparison_plot("mll", cutOSSF&&TCut("id1==0"),60, 15., 315.,-1., true, "m_{ll}", "mll_SF_inclusive_ee");
2122 <     make_data_comparison_plot("mll", cutOSSF&&TCut("id1==1"),60, 15., 315.,-1., true, "m_{ll}", "mll_SF_inclusive_mm");
2123 <     make_data_comparison_plot("mll", cutOSOF,60, 15., 315.,-1., true, "m_{ll}", "mll_OF_inclusive");
2104 >    basiccut=TCut(newbasiccut.c_str());
2105 >    make_data_comparison_plot("mll", TCut("pfJetGoodNum40>=2&&met[4]>150")&&cutOSSF,60, 0., 300.,-1., false, "mll", "mll_SF_Aachen_pt2010_met");
2106 >    make_data_comparison_plot("mll", TCut("pfJetGoodNum40>=2&&met[4]>150")&&cutOSOF,60, 0., 300.,-1., false, "mll", "mll_OF_Aachen_pt2010_met");
2107 >    make_data_comparison_plot("mll", TCut("pfJetGoodNum40>=2&&met[1]>150")&&cutOSSF,60, 0., 300.,-1., true, "mll", "mll_SF_Aachen_pt2010_t1cpfmet");
2108 >    make_data_comparison_plot("mll", TCut("pfJetGoodNum40>=2&&met[1]>150")&&cutOSOF,60, 0., 300.,-1., true, "mll", "mll_OF_Aachen_pt2010_t1cpfmet");
2109 >    basiccut=TCut(basiccutsaved.c_str());
2110 >    
2111 >    make_data_comparison_plot("pfJetGoodNum40", cutOSSF, 8, 0., 8.,-1., true, "#(jets)", "njets_SF");
2112 >    make_data_comparison_plot("pfJetGoodNum40", cutOSOF, 8, 0., 8.,-1., true, "#(jets)", "njets_OF");
2113 >    
2114 >    make_data_comparison_plot("mll", TCut("pfJetGoodNum40>=3&&met[4]>100")&&cutOSSF,60, 0., 300.,-1., true, "mll", "mll_SF_ETH_met");
2115 >    make_data_comparison_plot("mll", TCut("pfJetGoodNum40>=3&&met[4]>100")&&cutOSOF,60, 0., 300.,-1., true, "mll", "mll_OF_ETH_met");
2116 >    make_data_comparison_plot("mll", TCut("pfJetGoodNum40>=3&&met[1]>100")&&cutOSSF,60, 0., 300.,-1., true, "mll", "mll_SF_ETH_t1cpfmet");
2117 >    make_data_comparison_plot("mll", TCut("pfJetGoodNum40>=3&&met[1]>100")&&cutOSOF,60, 0., 300.,-1., true, "mll", "mll_OF_ETH_t1cpfmet");
2118 >
2119 >    
2120 >    make_data_comparison_plot("mll", cutOSSF,60, 15., 315.,-1., true, "m_{ll}", "mll_SF_inclusive");
2121 >    make_data_comparison_plot("mll", cutOSSF&&TCut("id1==0"),60, 15., 315.,-1., true, "m_{ll}", "mll_SF_inclusive_ee");
2122 >    make_data_comparison_plot("mll", cutOSSF&&TCut("id1==1"),60, 15., 315.,-1., true, "m_{ll}", "mll_SF_inclusive_mm");
2123 >    make_data_comparison_plot("mll", cutOSOF,60, 15., 315.,-1., true, "m_{ll}", "mll_OF_inclusive");
2124      make_data_comparison_plot("mll", cutnJets&&cutOSSF&&TCut("id1==0"),60, 15., 315.,-1., true, "m_{ll}", "mll_SF_exclusive_ee");
2125      make_data_comparison_plot("mll", cutnJets&&cutOSSF&&TCut("id1==1"),60, 15., 315.,-1., true, "m_{ll}", "mll_SF_exclusive_mm");
2126      make_data_comparison_plot("mll", cutnJets&&cutOSSF,60, 15., 315.,-1., true, "m_{ll}", "mll_SF_exclusive");
2127      make_data_comparison_plot("mll", cutnJets&&cutOSOF,60, 15., 315.,-1., true, "m_{ll}", "mll_OF_exclusive");
2128 < */
2128 >
2129      make_data_comparison_plot("mll", cutOSSF&&cutSignal&&mllCut,           massnbins, 15., 315.,-1., false, "m_{ll}", "mll_SF_sig");
2130      make_data_comparison_plot("mll", cutOSOF&&cutSignal&&mllCut,           massnbins, 15., 315.,-1., false, "m_{ll}", "mll_OF_sig");
2131      
# Line 1134 | Line 2138 | void do_kinematic_plots(string mcjzb, st
2138      make_data_comparison_plot("mll", cutOSSF&&cutSignal&&mllCut&&"pfJetGoodNumBtag30>0",  massnbins, 15., 315.,-1., false, "m_{ll}", "mll_SF_sig_AtLeastOneBJet");
2139      make_data_comparison_plot("mll", cutOSOF&&cutSignal&&mllCut&&"pfJetGoodNumBtag30>0",  massnbins, 15., 315.,-1., false, "m_{ll}", "mll_OF_sig_AtLeastOneBJet");
2140  
2141 < /*
2141 >
2142      make_data_comparison_plot("mll", mllCut&&cutOSOF&&cutSignal, massnbins, 15., 315.,-1., false, "m_{ll}", "mll_OF_sig");
2143      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");
2144      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 1143 | Line 2147 | void do_kinematic_plots(string mcjzb, st
2147      make_data_comparison_plot("pfJetGoodNum40", cutOSOF&&cutSignal&&mllCut, 8, 0., 8.,-1., false, "#(jets)", "njets_OF_sig");
2148      make_data_comparison_plot("pfJetGoodNumBtag30", cutOSSF&&cutSignal&&mllCut, 8, 0., 8.,-1., false, "#(b-jets)", "nbjets_SF_sig");
2149      make_data_comparison_plot("pfJetGoodNumBtag30", cutOSOF&&cutSignal&&mllCut, 8, 0., 8.,-1., false, "#(b-jets)", "nbjets_OF_sig");
2150 <  */
2150 >
2151    }
2152  
2153  
2154    if ( doKin ) {
2155      string mllCut("");
2156 < /*  
2156 >    
2157 >    
2158 >  
2159      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);
2160      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);
2161      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 1177 | Line 2183 | void do_kinematic_plots(string mcjzb, st
2183      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);
2184      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);
2185  
2186 <     make_plain_kin_plot("met[4]",Cut2Str(cutOSSF&&cutnJets&&TCut("mll>20&&mll<70")),50,0,300,dolog,"PFMET","MET_SF_20to70",doPF,true);
2187 <     make_plain_kin_plot("met[4]",Cut2Str(cutOSOF&&cutnJets&&TCut("mll>20&&mll<70")),50,0,300,dolog,"PFMET","MET_OF_20to70",doPF,true);
1182 <    
1183 <     make_plain_kin_plot("met[4]",Cut2Str(cutOSSF&&cutnJets&&TCut("mll>120")),50,0,300,dolog,"PFMET","MET_SF_above120",doPF,true);
1184 <     make_plain_kin_plot("met[4]",Cut2Str(cutOSOF&&cutnJets&&TCut("mll>120")),50,0,300,dolog,"PFMET","MET_OF_above120",doPF,true);*/
1185 <    
1186 < /*     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);
1187 <     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);
1188 <    
1189 <     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);
1190 <     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);
1191 < */
1192 <    
1193 <    
1194 <    
2186 >    make_plain_kin_plot("met[4]",Cut2Str(cutOSSF&&cutnJets&&TCut("mll>20&&mll<70")),50,0,300,dolog,"PFMET","MET_SF_20to70",doPF,true);
2187 >    make_plain_kin_plot("met[4]",Cut2Str(cutOSOF&&cutnJets&&TCut("mll>20&&mll<70")),50,0,300,dolog,"PFMET","MET_OF_20to70",doPF,true);
2188      
2189 +    make_plain_kin_plot("met[4]",Cut2Str(cutOSSF&&cutnJets&&TCut("mll>120")),50,0,300,dolog,"PFMET","MET_SF_above120",doPF,true);
2190 +    make_plain_kin_plot("met[4]",Cut2Str(cutOSOF&&cutnJets&&TCut("mll>120")),50,0,300,dolog,"PFMET","MET_OF_above120",doPF,true);
2191      
2192 +    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);
2193 +    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);
2194      
2195 +    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);
2196 +    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);
2197 +
2198      
2199 < //      make_kin_plot("pfJetGoodPt[0]/pfJetGoodPt[1]","",45,1,10,dolog,"pt_{j}^{1}/pt_{j}^{2}","j1j2ratio",doPF,true);
2200 < //      make_kin_plot("TMath::Abs(pfJetDphiMet[0])","",32,0,3.2,nolog,"|#Delta#phi(jet1,MET)|","dphiJ1MET",doPF,true);
2199 >    make_kin_plot("pfJetGoodPt[0]/pfJetGoodPt[1]","",45,1,10,dolog,"pt_{j}^{1}/pt_{j}^{2}","j1j2ratio",doPF,true);
2200 >    make_kin_plot("TMath::Abs(pfJetDphiMet[0])","",32,0,3.2,nolog,"|#Delta#phi(jet1,MET)|","dphiJ1MET",doPF,true);
2201      // Plots in signal region
2202 < //     make_kin_plot("met[4]","",70,0,350,dolog,"MET [GeV]","met",doPF,true);
1203 <
2202 >    make_kin_plot("met[4]","",70,0,350,dolog,"MET [GeV]","met",doPF,true);
2203  
1205     DoMCSystPlot("mll", (int)((mll_hi-mll_low)/5),mll_low,mll_hi,cutnJets&&cutOSSF,dolog,"m_{ll} [GeV]","kinSys/mll");
1206     DoMCSystPlot("mll", (int)((mll_hi-mll_low)/5),mll_low,mll_hi,cutnJets&&cutOSSF&&TCut("id1==0"),dolog,"m_{ll} [GeV]","kinSys/mll_ee");
1207     DoMCSystPlot("mll", (int)((mll_hi-mll_low)/5),mll_low,mll_hi,cutnJets&&cutOSSF&&TCut("id1==1"),dolog,"m_{ll} [GeV]","kinSys/mll_mm");
1208     DoMCSystPlot("mll", (int)((mll_hi-mll_low)/5),mll_low,mll_hi,cutnJets&&cutOSOF,dolog,"m_{ll} [GeV]","kinSys/mll_osof");
2204  
2205 <     DoMCSystPlot("mll", (int)((mll_hi-mll_low)/5),mll_low,mll_hi,cutOSSF,dolog,"m_{ll} [GeV]","kinSys/mll_inclusive");
1211 <     DoMCSystPlot("mll", (int)((mll_hi-mll_low)/5),mll_low,mll_hi,cutOSOF,dolog,"m_{ll} [GeV]","kinSys/mll_inclusive_osof");
1212 <
1213 <     DoMCSystPlot("pfJetGoodNum40", 9,-0.5,8.5,cutOSSF,dolog,"nJets","kinSys/nJets_ossf");
1214 <     DoMCSystPlot("pfJetGoodNum40", 9,-0.5,8.5,cutOSOF,dolog,"nJets","kinSys/nJets_osof");
1215 <    
1216 <     DoMCSystPlot("pfJetGoodPt[0]/pfJetGoodPt[1]",45,1,10,cutnJets&&cutOSSF,dolog,"p_{T}^{J1} / p_{T}^{J2}","kinSys/j1j2ratio");
1217 <     DoMCSystPlot("TMath::Abs(pfJetDphiMet[0])",32,0,3.2,cutnJets&&cutOSSF,dolog,"|#Delta#phi(jet1,MET)|","kinSys/j1j2ratio");
2205 >    make_kin_plot("MetFactor","",20,0,2,nolog,"MetFactor","MetFactor",doPF,true);
2206      
2207 <     DoMCSystPlot(datajzb,mcjzb, (int)((PlottingSetup::jzbHigh+110)/10),-110,PlottingSetup::jzbHigh,cutnJets&&cutOSSF&&Restrmasscut,dolog,"m_{ll} [GeV]","kinSys/jzb_ossf");
2208 <     DoMCSystPlot(datajzb,mcjzb, (int)((PlottingSetup::jzbHigh+110)/10),-110,PlottingSetup::jzbHigh,cutnJets&&cutOSOF&&Restrmasscut,dolog,"m_{ll} [GeV]","kinSys/jzb_ossf");
2207 >    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");
2208 >    /*
2209 >    DoMCSystPlot("met[4]",40,0,400,(cutOSOF&&TCut("mll>30&&mll<70&&pfJetGoodNum40==0")),dolog,"PFMET","Debunking/MET_OF_30to70_0j");
2210 >    DoMCSystPlot("met[4]",40,0,400,(cutOSOF&&TCut("mll>30&&mll<70&&pfJetGoodNum40==1")),dolog,"PFMET","Debunking/MET_OF_30to70_1j");
2211 >    DoMCSystPlot("met[4]",40,0,400,(cutOSOF&&TCut("mll>30&&mll<70&&pfTightHT>100&&pfJetGoodNum40==2")),dolog,"PFMET","Debunking/MET_OF_30to70_2j");
2212 >    DoMCSystPlot("met[4]",40,0,400,(cutOSOF&&TCut("mll>30&&mll<70&&pfTightHT>100&&pfJetGoodNum40==3")),dolog,"PFMET","Debunking/MET_OF_30to70_3j");
2213 >
2214 >    DoMCSystPlot("met[4]",40,0,400,(cutOSSF&&TCut("mll>30&&mll<70&&pfJetGoodNum40==0")),dolog,"PFMET","Debunking/MET_SF_30to70_0j");
2215 >    DoMCSystPlot("met[4]",40,0,400,(cutOSSF&&TCut("mll>30&&mll<70&&pfJetGoodNum40==1")),dolog,"PFMET","Debunking/MET_SF_30to70_1j");
2216 >    DoMCSystPlot("met[4]",40,0,400,(cutOSSF&&TCut("mll>30&&mll<70&&pfTightHT>100&&pfJetGoodNum40==2")),dolog,"PFMET","Debunking/MET_SF_30to70_2j");
2217 >    DoMCSystPlot("met[4]",40,0,400,(cutOSSF&&TCut("mll>30&&mll<70&&pfTightHT>100&&pfJetGoodNum40==3")),dolog,"PFMET","Debunking/MET_SF_30to70_3j");
2218 >
2219 >    DoMCSystPlot("met[4]",40,0,400,(cutOSOF&&TCut("mll>80&&mll<100&&pfJetGoodNum40==0")),dolog,"PFMET","Debunking/MET_OF_Z_0j");
2220 >    DoMCSystPlot("met[4]",40,0,400,(cutOSOF&&TCut("mll>80&&mll<100&&pfJetGoodNum40==1")),dolog,"PFMET","Debunking/MET_OF_Z_1j");
2221 >    DoMCSystPlot("met[4]",40,0,400,(cutOSOF&&TCut("mll>80&&mll<100&&pfTightHT>100&&pfJetGoodNum40==2")),dolog,"PFMET","Debunking/MET_OF_Z_2j");
2222 >    DoMCSystPlot("met[4]",40,0,400,(cutOSOF&&TCut("mll>80&&mll<100&&pfTightHT>100&&pfJetGoodNum40==3")),dolog,"PFMET","Debunking/MET_OF_Z_3j");
2223 >
2224 >    
2225 >    DoMCSystPlot("mll", (int)((mll_hi-mll_low)/5),mll_low,mll_hi,cutnJets&&cutOSSF,dolog,"m_{ll} [GeV]","kinSys/mll");
2226 >    DoMCSystPlot("mll", (int)((mll_hi-mll_low)/5),mll_low,mll_hi,cutnJets&&cutOSSF&&TCut("id1==0"),dolog,"m_{ll} [GeV]","kinSys/mll_ee");
2227 >    DoMCSystPlot("mll", (int)((mll_hi-mll_low)/5),mll_low,mll_hi,cutnJets&&cutOSSF&&TCut("id1==1"),dolog,"m_{ll} [GeV]","kinSys/mll_mm");
2228 >    DoMCSystPlot("mll", (int)((mll_hi-mll_low)/5),mll_low,mll_hi,cutnJets&&cutOSOF,dolog,"m_{ll} [GeV]","kinSys/mll_osof");
2229  
2230 +    DoMCSystPlot("mll", (int)((mll_hi-mll_low)/5),mll_low,mll_hi,cutOSSF,dolog,"m_{ll} [GeV]","kinSys/mll_inclusive");
2231 +    DoMCSystPlot("mll", (int)((mll_hi-mll_low)/5),mll_low,mll_hi,cutOSOF,dolog,"m_{ll} [GeV]","kinSys/mll_inclusive_osof");
2232 +
2233 +    DoMCSystPlot("pfJetGoodNum40", 9,-0.5,8.5,cutOSSF,dolog,"nJets","kinSys/nJets_ossf");
2234 +    DoMCSystPlot("pfJetGoodNum40", 9,-0.5,8.5,cutOSOF,dolog,"nJets","kinSys/nJets_osof");
2235      
2236 <    
2237 <     make_kin_plot("mll","mll>20"+mllCut,(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll",doPF,true);
2238 <     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);
2239 <     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);
2240 <     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);
2241 <    
2242 <     make_kin_plot("pfJetGoodNum40",mllCut,9,-0.5,8.5,dolog,"nJets","nJets",doPF);
2243 <     make_kin_plot("pfJetGoodNum40","",9,-0.5,8.5,dolog,"nJets","nJets_osof",doPF);
2244 <    
2245 < //     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);
2246 < //     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);
2247 < //     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);
2248 < //     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);
2236 >    DoMCSystPlot("pfJetGoodPt[0]/pfJetGoodPt[1]",45,1,10,cutnJets&&cutOSSF,dolog,"p_{T}^{J1} / p_{T}^{J2}","kinSys/j1j2ratio");
2237 >    DoMCSystPlot("TMath::Abs(pfJetDphiMet[0])",32,0,3.2,cutnJets&&cutOSSF,dolog,"|#Delta#phi(jet1,MET)|","kinSys/dphiJ1MET");
2238 >    DoMCSystPlot(datajzb,mcjzb, (int)((PlottingSetup::jzbHigh+110)/10),-110,PlottingSetup::jzbHigh,cutnJets&&cutOSSF&&Restrmasscut,dolog,"m_{ll} [GeV]","kinSys/jzb_OS_SFZP");
2239 >    DoMCSystPlot(datajzb,mcjzb, (int)((PlottingSetup::jzbHigh+110)/10),-110,PlottingSetup::jzbHigh,cutnJets&&cutOSOF&&Restrmasscut,dolog,"m_{ll} [GeV]","kinSys/jzb_OS_OFZP");
2240 >
2241 >    make_kin_plot("mll","mll>20"+mllCut,(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll",doPF,true);
2242 >    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);
2243 >    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);
2244 >    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);
2245 >    
2246 >    make_kin_plot("pfJetGoodNum40",mllCut,9,-0.5,8.5,dolog,"nJets","nJets",doPF);
2247 >    make_kin_plot("pfJetGoodNum40","",9,-0.5,8.5,dolog,"nJets","nJets_osof",doPF);
2248 >    
2249 >    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);
2250 >    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);
2251 >    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);
2252 >    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);
2253      
2254      
2255 < //     make_kin_plot("pfJetGoodNum40","met[4]>100"+mllCut,9,-0.5,8.5,dolog,"nJets","nJets_met100",doPF);
2256 < //     make_kin_plot("pfJetGoodNum40","met[4]>100",9,-0.5,8.5,dolog,"nJets","nJets_osof_met100",doPF);
2255 >    make_kin_plot("pfJetGoodNum40","met[4]>100"+mllCut,9,-0.5,8.5,dolog,"nJets","nJets_met100",doPF);
2256 >    make_kin_plot("pfJetGoodNum40","met[4]>100",9,-0.5,8.5,dolog,"nJets","nJets_osof_met100",doPF);
2257  
2258      // Further inclusive invariant mass plots
2259      make_kin_plot("mll",mllCut,(int)((mll_hi-mll_low))/5,mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive",doPF,true);
2260 < //     make_kin_plot("mll","",(int)((mll_hi-mll_low))/5,mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_ee",doPF,true);
2261 < //     make_kin_plot("mll","",(int)((mll_hi-mll_low))/5,mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_mm",doPF,true);
2260 >    make_kin_plot("mll","",(int)((mll_hi-mll_low))/5,mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_ee",doPF,true);
2261 >    make_kin_plot("mll","",(int)((mll_hi-mll_low))/5,mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_mm",doPF,true);
2262      make_kin_plot("mll",mllCut,(int)((mll_hi-mll_low))/5,mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_osof",doPF,true);
2263      
2264 <    //make_kin_plot("mll","",(int)((350-mll_low))/5,mll_low,350,dolog,"m_{ll} [GeV]","mll_inclusive_highrange",doPF);
2264 >    make_kin_plot("mll","",(int)((350-mll_low))/5,mll_low,350,dolog,"m_{ll} [GeV]","mll_inclusive_highrange",doPF);
2265      //if(!doPF) make_special_mll_plot((int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]");
2266      
2267      
2268      // Number of jets
2269      make_kin_plot("pfJetGoodNum40","",9,-0.5,8.5,dolog,"nJets","nJets_inclusive",doPF);
2270      make_kin_plot("pfJetGoodNum40","",9,-0.5,8.5,dolog,"nJets","nJets_osof_inclusive",doPF);
2271 <    //make_kin_plot("pfJetGoodNum40","",9,-0.5,8.5,dolog,"nJets","nJets_nocuts_except_mll_ossf",doPF);
2271 >    make_kin_plot("pfJetGoodNum40","",9,-0.5,8.5,dolog,"nJets","nJets_nocuts_except_mll_ossf",doPF);
2272      
2273      // Others
2274      make_kin_plot("numVtx","",(int)(30.5-(-0.5)),-0.5,30.5,nolog,"N(Vtx)","numVtx",doPF);
# Line 1283 | Line 2300 | void do_kinematic_plots(string mcjzb, st
2300      
2301      //   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);
2302      //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);
2303 <    //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);
2303 >    //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);*/
2304    }
2305 <    
2306 < //   make_special_obs_pred_mll_plot(datajzb,mcjzb,0);
2307 < //   make_special_obs_pred_mll_plot(datajzb,mcjzb,50);
2308 < //   make_special_obs_pred_mll_plot(datajzb,mcjzb,80);
2305 >    /*
2306 >   make_special_obs_pred_mll_plot(datajzb,mcjzb,0);
2307 >   make_special_obs_pred_mll_plot(datajzb,mcjzb,50);
2308 >   make_special_obs_pred_mll_plot(datajzb,mcjzb,80);
2309     make_special_obs_pred_mll_plot(datajzb,mcjzb,100);
2310 < //   make_special_obs_pred_mll_plot(datajzb,mcjzb,150);
2311 < //   make_special_obs_pred_mll_plot(datajzb,mcjzb,200);
2312 < //   make_special_obs_pred_mll_plot(datajzb,mcjzb,250);
1296 <
1297 < //   make_JES_plot(cutmass&&cutOSSF&&basiccut,"_ossf");
1298 < //   make_JES_plot(cutmass&&cutOSOF&&basiccut,"_osof");
2310 >   make_special_obs_pred_mll_plot(datajzb,mcjzb,150);
2311 >   make_special_obs_pred_mll_plot(datajzb,mcjzb,200);
2312 >   make_special_obs_pred_mll_plot(datajzb,mcjzb,250);
2313  
2314 +   make_JES_plot(cutmass&&cutOSSF&&basiccut,"_ossf");
2315 +   make_JES_plot(cutmass&&cutOSOF&&basiccut,"_osof");
2316 + */
2317    switch_overunderflow(false);
2318   }
2319  
# Line 1913 | Line 2930 | void do_prediction_plot(string jzb, TCan
2930   //    speciallegBpred->AddEntry(lm4RcorrJZBeemmC,"LM4","l");
2931   //     speciallegBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
2932      speciallegBpred->Draw();
2933 <    save_with_ratio(JRcorrJZBeemm,JBpred,predcomppad,subdir+"Bpred_Data_____PredictionComposition",true,true,"data/pred",BpredSys);
2933 >    Save_With_Ratio(JRcorrJZBeemm,JBpred,predcomppad,subdir+"Bpred_Data_____PredictionComposition",true,true,"data/pred",BpredSys);
2934 >    delete predcomppad;
2935      
2936      TCanvas *specialcanv = new TCanvas("specialcanv","specialcanv");
2937      specialcanv->SetLogy(1);
# Line 1996 | Line 3014 | void do_prediction_plot(string jzb, TCan
3014    string ytitle("ratio");
3015    if ( use_data==1 ) ytitle = "data/pred";
3016    //save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,Bpredsaveas,true,use_data!=1,ytitle);
3017 <  save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,subdir+Bpredsaveas,true,false,ytitle,BpredSys);//not extending the y range anymore up to 4
3017 >  Save_With_Ratio(JRcorrJZBeemm,JBpred,kinpad,subdir+Bpredsaveas,true,false,ytitle,BpredSys);//not extending the y range anymore up to 4
3018 >  
3019 >  delete kinpad;
3020  
3021  
3022    
# Line 2193 | Line 3213 | void lepton_comparison_plots() {
3213    eemmlegend->AddEntry(jmmd,"#mu#mu","l");
3214    eemmlegend->Draw();
3215    DrawPrelim();
3216 <  save_with_ratio(jeed,jmmd,eemmpad->cd(),"lepton_comparison/jzb_Comparing_ee_mm_data");
3216 >  Save_With_Ratio(jeed,jmmd,eemmpad->cd(),"lepton_comparison/jzb_Comparing_ee_mm_data");
3217    
3218    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"));
3219    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 2316 | Line 3336 | void draw_pure_jzb_histo(TCut cut,string
3336    TText *writeline1 = write_cut_on_canvas(write_cut.c_str());
3337    writeline1->SetTextSize(0.035);
3338    writeline1->Draw();
3339 <  if(!Contains(savename,"Dibosons")) save_with_ratio(datahisto,mcstack,jzbpad->cd(),("jzb/"+savename));
3340 <  else save_with_ratio(datahisto,mcstack,jzbpad->cd(),savename);
3339 >  if(!Contains(savename,"Dibosons")) Save_With_Ratio(datahisto,mcstack,jzbpad->cd(),("jzb/"+savename));
3340 >  else Save_With_Ratio(datahisto,mcstack,jzbpad->cd(),savename);
3341    TPad *jzbpad2 = new TPad("jzbpad2","jzbpad2",0,0,1,1);
3342    jzbpad2->cd();
3343    jzbpad2->SetLogy(1);
# Line 2332 | Line 3352 | void draw_pure_jzb_histo(TCut cut,string
3352    writeline1->SetTextSize(0.035);
3353    writeline1->Draw();
3354    DrawPrelim();
3355 <  if(!Contains(savename,"Dibosons")) save_with_ratio(datahisto,mcstack,jzbpad2->cd(),("jzb/PositiveSideOnly/"+savename+""));
3356 <  else save_with_ratio(datahisto,mcstack,jzbpad2->cd(),(savename+"__PosOnly"));
3355 >  if(!Contains(savename,"Dibosons")) Save_With_Ratio(datahisto,mcstack,jzbpad2->cd(),("jzb/PositiveSideOnly/"+savename+""));
3356 >  else Save_With_Ratio(datahisto,mcstack,jzbpad2->cd(),(savename+"__PosOnly"));
3357    datahisto->Delete();
3358    mcstack.Delete();
3359   }
# Line 2441 | Line 3461 | void draw_normalized_data_vs_data_histo(
3461    leg->AddEntry(datahisto2,legentry2.c_str());
3462    leg->Draw();
3463    
3464 <  save_with_ratio(datahisto1,datahisto2,jzbpad->cd(),("jzb/"+savename));
3464 >  Save_With_Ratio(datahisto1,datahisto2,jzbpad->cd(),("jzb/"+savename));
3465    
3466    datahisto1->Delete();
3467    datahisto2->Delete();
# Line 2935 | Line 3955 | void find_correction_factors(string &jzb
3955    
3956   }
3957  
3958 < void pick_up_events(string cut) {
3959 <  dout << "Picking up events with cut " << cut << endl;
2940 <  allsamples.PickUpEvents(cut);
3958 > void pick_up_events(string cut, string filename) {
3959 >  allsamples.PickUpEvents(cut,filename);
3960   }
3961  
3962   void save_template(string mcjzb, string datajzb,vector<float> jzb_cuts,float MCPeakError,float DataPeakError, vector<float> jzb_shape_limit_bins) {
# Line 3049 | Line 4068 | void ttbar_sidebands_comparison(string m
4068        
4069    float simulatedlumi = luminosity; //in pb please - adjust to your likings
4070  
4071 <  TH1F *TZem  = systsamples.Draw("TZem",     mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSOF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTT"));
4072 <  TH1F *nTZem = systsamples.Draw("nTZem","-"+mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSOF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTT"));
4071 >  TH1F *TZem  = allsamples.Draw("TZem",     mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSOF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("/TT"));
4072 >  TH1F *nTZem = allsamples.Draw("nTZem","-"+mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSOF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("/TT"));
4073    TH1F *TSem;
4074    TH1F *nTSem;
4075 <  TH1F *TZeemm  = systsamples.Draw("TZeemm",     mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTT"));
4076 <  TH1F *nTZeemm = systsamples.Draw("nTZeemm","-"+mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTT"));
4075 >  TH1F *TZeemm  = allsamples.Draw("TZeemm",     mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("/TT"));
4076 >  TH1F *nTZeemm = allsamples.Draw("nTZeemm","-"+mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("/TT"));
4077    TH1F *TSeemm;
4078    TH1F *nTSeemm;
4079    
4080    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
4081 <    TSem    = systsamples.Draw("TSem",       mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSOF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTT"));
4082 <    nTSem   = systsamples.Draw("nTSem",  "-"+mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSOF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTT"));
4083 <    TSeemm  = systsamples.Draw("TSeemm",     mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSSF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTT"));
4084 <    nTSeemm = systsamples.Draw("nTSeemm","-"+mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSSF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTT"));
4081 >    TSem    = allsamples.Draw("TSem",       mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSOF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("/TT"));
4082 >    nTSem   = allsamples.Draw("nTSem",  "-"+mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSOF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("/TT"));
4083 >    TSeemm  = allsamples.Draw("TSeemm",     mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSSF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("/TT"));
4084 >    nTSeemm = allsamples.Draw("nTSeemm","-"+mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSSF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("/TT"));
4085    }
4086  
4087    TCanvas *tcan = new TCanvas("tcan","tcan");
# Line 3630 | Line 4649 | void make_table(samplecollection &coll,
4649   }
4650  
4651   void met_jzb_cut(string datajzb, string mcjzb, vector<float> jzb_cut) {
4652 +  cout << "You probably don't want --met, you want --metplots ... " << endl;
4653 +  assert(0);
4654    /*we want a table like this:
4655      __________________     50   |   100  | ...
4656      | Data prediction |  a vs b | a vs b | ...
# Line 3863 | Line 4884 | void qcd_plots(string datajzb, string mc
4884    //3rd last argument: do special bpred ratio, 2nd last argument: extended range!, last: y-axis title
4885    string ytitle("ratio");
4886    if ( use_data==1 ) ytitle = "data/pred";
4887 <  save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,"QCD/Bpred",true,false,ytitle);
4887 >  Save_With_Ratio(JRcorrJZBeemm,JBpred,kinpad,"QCD/Bpred",true,false,ytitle);
4888 >  delete kinpad;
4889    
4890    TH1F *allevents = qcdsamples.Draw("allevents","pfJetGoodNum",1,0,100, "internal code", "events", "" ,mc, luminosity);
4891    TH1F *ossf = qcdsamples.Draw("ossf","pfJetGoodNum",1,0,100, "internal code", "events", cutOSSF ,mc, luminosity);
# Line 4100 | Line 5122 | void met_vs_jzb_plots(string datajzb, st
5122    lg->SetHeader("DY");
5123    
5124    lg->Draw();
5125 <  save_with_ratio(metright,metleft,metpad->cd(),"METvsJZBplots/ComparingLeftToRightinMETspectrum");
5125 >  Save_With_Ratio(metright,metleft,metpad->cd(),"METvsJZBplots/ComparingLeftToRightinMETspectrum");
5126    
5127    TPad *metpad3 = new TPad("metpad3","metpad3",0,0,1,1);
5128    metpad3->cd();
# Line 4118 | Line 5140 | void met_vs_jzb_plots(string datajzb, st
5140  
5141    lg2->Draw();
5142    
5143 <  save_with_ratio(obs,Bpred,metpad3->cd(),"METvsJZBplots/ComparingPredObsinMET");
5143 >  Save_With_Ratio(obs,Bpred,metpad3->cd(),"METvsJZBplots/ComparingPredObsinMET");
5144    
5145    TPad *metpad2 = new TPad("metpad2","metpad2",0,0,1,1);
5146    metpad2->cd();
# Line 4137 | Line 5159 | void met_vs_jzb_plots(string datajzb, st
5159    metlefta->Draw("histo");
5160    metrighta->Draw("same");
5161    lg->Draw();
5162 <  save_with_ratio(metrighta,metlefta,metpad2->cd(),"METvsJZBplots/ComparingLeftToRightinMET_type1_spectrum");
5162 >  Save_With_Ratio(metrighta,metlefta,metpad2->cd(),"METvsJZBplots/ComparingLeftToRightinMET_type1_spectrum");
5163    
5164    delete Bpred;
5165    delete obs;
# Line 4164 | Line 5186 | void met_vs_jzb_plots(string datajzb, st
5186    aobs->Draw("same");
5187    lg->SetHeader("All MC");
5188    lg->Draw();
5189 <  save_with_ratio(aobs,aBpred,metpad4->cd(),"METvsJZBplots/ComparingPredObsinMET_ALLSAMPLES");
5189 >  Save_With_Ratio(aobs,aBpred,metpad4->cd(),"METvsJZBplots/ComparingPredObsinMET_ALLSAMPLES");
5190    
5191    
5192    delete lg;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines