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.80 by buchmann, Thu Jan 24 08:16:17 2013 UTC vs.
Revision 1.92 by buchmann, Tue Apr 30 09:49:05 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 234 | Line 329 | void make_special_obs_pred_mll_plot(stri
329    
330    TLegend *leg = allsamples.allbglegend();
331    leg->SetX1(0.58);
332 <  leg->AddEntry(RcorrJZBeemm,"observed (data)","l");
332 > //  leg->AddEntry(RcorrJZBeemm,"observed (data)","l");
333    leg->AddEntry(Bpred,"predicted (data)","l");
334    leg->Draw("same");
335    
# Line 262 | Line 357 | void make_special_obs_pred_mll_plot(stri
357    RcorrJZBeemm->Draw("same");
358    
359    TLegend *leg2 = make_legend("",0.52,0.7);
360 <  leg2->AddEntry(RcorrJZBeemm,"observed (data)","lp");
360 > //  leg2->AddEntry(RcorrJZBeemm,"observed (data)","lp");
361    leg2->AddEntry(Bpred,"predicted (data)","l");
362    leg2->AddEntry(SFN,  "  SF JZB<0","l");
363    leg2->AddEntry(OFN,  "  OF JZB<0","l");
# 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 382 | Line 479 | float make_one_OFSF_plot(string variable
479    TCut cutSF;
480    TCut cutOF;
481  
482 +  cout << "Going to use cutOSSF " << (const char*) cutOSSF << " and cutnJets " << (const char*) cutnJets << " and ibasiccut " << (const char*) ibasiccut << endl;
483    cutOF = cutOSOF&&cutnJets&&ibasiccut;
484    cutSF = cutOSSF&&cutnJets&&ibasiccut;
485 +  
486 +  TCanvas *ofsf_can = new TCanvas("ofsf_can","ofsf_can");
487  
488    TPad* rcan = new TPad("rcan","rcan",0,0,1,1);
489    rcan->SetLogy(logscale);
# Line 409 | Line 509 | float make_one_OFSF_plot(string variable
509    }
510    if (ymax<0) {
511      if ( logscale ) datahistoSF->SetMaximum(5.3*datahistoSF->GetMaximum());
512 <    else datahistoSF->SetMaximum(1.8*datahistoSF->GetMaximum());
512 >    else datahistoSF->SetMaximum(0.8*datahistoSF->GetMaximum());
513    } else {
514      datahistoSF->SetMaximum(ymax);
515    }
# Line 446 | Line 546 | float make_one_OFSF_plot(string variable
546    //signalhisto->Delete();
547    delete mleg;
548    delete rcan;
549 +  delete ofsf_can;
550  
551    return ymaxSet;
552  
# Line 615 | Line 716 | void DoMCSystPlot(string datavariable, s
716    string saveas="kin/"+filename;
717    
718    cout << "Passing filename to be saved : " << filename << " as " << saveas << endl;
719 <  save_with_ratio_and_sys_band( datahisto, CollapseStack(mcstack), kinpad->cd(), saveas, false, false, "data/mc",Systematic );
719 >  save_with_ratio_and_sys_band(0.0, datahisto, CollapseStack(mcstack), kinpad->cd(), saveas, false, false, "data/mc",Systematic );
720    
721    ckin->cd();
722    MCcentral->SetFillColor(kWhite);
# Line 924 | Line 1025 | void make_JES_plot(TCut cut, string name
1025    CompleteSave(ckin,"Systematics/JES"+name);
1026    datahisto->Delete();
1027    delete ckin;
1028 <
1028 >  delete JESunc;
1029 >  delete JESup;
1030 >  delete JESdn;
1031 >  CleanLegends();
1032   }
1033  
1034   string Cut2Str(TCut cut) {
# Line 1050 | Line 1154 | void make_ttbar_comparison(string datava
1154    
1155    TCanvas *ckin = new TCanvas("ckin","Kinematic Plots (in the making)",600,600);
1156    ckin->SetLogy(dolog);
1157 <  cout << "\r Creating " << filename << " : data   (1/11)" << std::flush;
1157 >  cout << "\r Creating " << filename << " : data   (1/7)" << std::flush;
1158    TH1F *datahisto = allsamples.Draw("datahisto",datavariable,nbins,min,max, xlabel, "events",cut,data,luminosity);
1159    datahisto->SetMarkerSize(DataMarkerSize);
1160    if ( !dolog ) datahisto->SetMinimum(0); // Defaults
1161    else datahisto->SetMinimum(0.5);
1162    if (dolog) datahisto->SetMaximum(5.3*datahisto->GetMaximum());
1163    else datahisto->SetMaximum(1.3*datahisto->GetMaximum());
1164 <  cout << "\r Creating " << filename << " : MC central  (stack) (2/11)" << std::flush;
1164 >  cout << "\r Creating " << filename << " : MC central  (stack) (2/7)" << std::flush;
1165    THStack mcstack   = allsamples.DrawStack("mcstack",  mcvariable,nbins,min,max,xlabel,"events",cut,mc,luminosity);
1166    TH1F *MCcentral = CollapseStack(mcstack);
1167  
1168 <  cout << "\r Creating " << filename << " : MC central (histo)   (3/11)" << std::flush;
1168 >  cout << "\r Creating " << filename << " : MC central (histo)   (3/7)" << std::flush;
1169    TH1F *TCentral        = allsamples.Draw ("TCentral",     mcvariable,nbins,min,max,xlabel,"events",cut,mc,luminosity,allsamples.FindSample("TTJets_"));
1170    TH1F *RCentral        = ProduceTTbarRatio(datahisto,MCcentral,TCentral,TCentral);
1171    
1172 <  cout << "\r Creating " << filename << " : MC Matching up   (4/11)" << std::flush;
1172 >  cout << "\r Creating " << filename << " : MC Matching up   (4/7)" << std::flush;
1173    TH1F *TMatchingUp     = systsamples.Draw("TMatchingUp",  mcvariable,nbins,min,max,xlabel,"events",cut,mc,luminosity,systsamples.FindSample("TTJets_matchingup"));
1174    TH1F *RMatchingUp     = ProduceTTbarRatio(datahisto,MCcentral,TCentral,TMatchingUp);
1175    
1176 <  cout << "\r Creating " << filename << " : MC Matching down   (5/11)" << std::flush;
1176 >  cout << "\r Creating " << filename << " : MC Matching down   (5/7)" << std::flush;
1177    TH1F *TMatchingDown   = systsamples.Draw("TMatchingDown",mcvariable,nbins,min,max,xlabel,"events",cut,mc,luminosity,systsamples.FindSample("TTJets_matchingdown"));
1178    TH1F *RMatchingDown   = ProduceTTbarRatio(datahisto,MCcentral,TCentral,TMatchingDown);
1179    
1180 <  cout << "\r Creating " << filename << " : MC Scale up   (6/11)" << std::flush;
1180 >  cout << "\r Creating " << filename << " : MC Scale up   (6/7)" << std::flush;
1181    TH1F *TScaleUp        = systsamples.Draw("TScaleUp",     mcvariable,nbins,min,max,xlabel,"events",cut,mc,luminosity,systsamples.FindSample("TTJets_scaleup"));
1182    TH1F *RScaleUp        = ProduceTTbarRatio(datahisto,MCcentral,TCentral,TScaleUp);
1183    
1184 <  cout << "\r Creating " << filename << " : MC Scale down   (7/11)" << std::flush;
1184 >  cout << "\r Creating " << filename << " : MC Scale down   (7/7)" << std::flush;
1185    TH1F *TScaleDown      = systsamples.Draw("TScaleDown",   mcvariable,nbins,min,max,xlabel,"events",cut,mc,luminosity,systsamples.FindSample("TTJets_scaledown"));
1186    TH1F *RScaleDown      = ProduceTTbarRatio(datahisto,MCcentral,TCentral,TScaleDown);
1187    
1084  cout << "\r Creating " << filename << " : MC mass=166   (8/11)" << std::flush;
1085  TH1F *Ttmass166       = systsamples.Draw("Ttmass166",    mcvariable,nbins,min,max,xlabel,"events",cut,mc,luminosity,systsamples.FindSample("TTJets_mass166"));
1086  TH1F *Rtmass166       = ProduceTTbarRatio(datahisto,MCcentral,TCentral,Ttmass166);
1087  
1088  cout << "\r Creating " << filename << " : MC mass=169   (9/11)" << std::flush;
1089  TH1F *Ttmass169       = systsamples.Draw("Ttmass169",    mcvariable,nbins,min,max,xlabel,"events",cut,mc,luminosity,systsamples.FindSample("TTJets_mass169"));
1090  TH1F *Rtmass169       = ProduceTTbarRatio(datahisto,MCcentral,TCentral,Ttmass169);
1091  
1092  cout << "\r Creating " << filename << " : MC mass=175   (10/11)" << std::flush;
1093  TH1F *Ttmass175       = systsamples.Draw("Ttmass175",    mcvariable,nbins,min,max,xlabel,"events",cut,mc,luminosity,systsamples.FindSample("TTJets_mass175"));
1094  TH1F *Rtmass175       = ProduceTTbarRatio(datahisto,MCcentral,TCentral,Ttmass175);
1095  
1096  cout << "\r Creating " << filename << " : MC mass=178   (11/11)" << std::flush;
1097  TH1F *Ttmass178       = systsamples.Draw("Ttmass178",    mcvariable,nbins,min,max,xlabel,"events",cut,mc,luminosity,systsamples.FindSample("TTJets_mass178"));
1098  TH1F *Rtmass178       = ProduceTTbarRatio(datahisto,MCcentral,TCentral,Ttmass178);
1099  
1100  
1188    datahisto->Draw("e1");
1189    ckin->Update();
1190    mcstack.Draw("histo,same");
# Line 1135 | Line 1222 | void make_ttbar_comparison(string datava
1222    TScaleDown->SetLineColor(TColor::GetColor("#FF8500"));
1223    TScaleDown->SetLineStyle(3);//dotted
1224    
1138  Ttmass166->SetLineColor(TColor::GetColor("#0acf00"));//green
1139  Ttmass166->SetLineStyle(3);//dotted
1140  Ttmass178->SetLineColor(TColor::GetColor("#0acf00"));
1141  Ttmass178->SetLineStyle(2);//dashed
1142  
1143  
1144  Ttmass169->SetLineColor(TColor::GetColor("#FF52F1"));//purple
1145  Ttmass169->SetLineStyle(3);//dotted
1146  Ttmass175->SetLineColor(TColor::GetColor("#FF52F1"));
1147  Ttmass175->SetLineStyle(2);//dashed
1148  
1149  
1150  
1151  
1225    MCcentral->SetLineStyle(3);
1226    MCcentral->SetLineColor(kRed);
1227    
# Line 1158 | Line 1231 | void make_ttbar_comparison(string datava
1231    TMatchingDown->Draw("histo,same");
1232    TScaleUp->Draw("histo,same");
1233    TScaleDown->Draw("histo,same");
1161  Ttmass166->Draw("histo,same");
1162  Ttmass169->Draw("histo,same");
1163  Ttmass175->Draw("histo,same");
1164  Ttmass178->Draw("histo,same");
1234    
1235    TLegend *sleg = make_legend();
1236    sleg->AddEntry(TCentral,"Central","L");
# Line 1169 | Line 1238 | void make_ttbar_comparison(string datava
1238    sleg->AddEntry(TMatchingDown,"matching down","L");
1239    sleg->AddEntry(TScaleUp,"scale up","L");
1240    sleg->AddEntry(TScaleDown,"scale down","L");
1172  sleg->AddEntry(Ttmass166,"m_{t}=166","L");
1173  sleg->AddEntry(Ttmass169,"m_{t}=169","L");
1174  sleg->AddEntry(Ttmass175,"m_{t}=175","L");
1175  sleg->AddEntry(Ttmass178,"m_{t}=178","L");
1241    sleg->Draw();
1242    
1243    CompleteSave(ckin,saveas+"___AllLines");
# Line 1191 | Line 1256 | void make_ttbar_comparison(string datava
1256    RScaleDown->SetLineColor(TColor::GetColor("#FF8500"));
1257    RScaleDown->SetLineStyle(3);//dotted
1258    
1194  Rtmass166->SetLineColor(TColor::GetColor("#0acf00"));//green
1195  Rtmass166->SetLineStyle(3);//dotted
1196  Rtmass178->SetLineColor(TColor::GetColor("#0acf00"));
1197  Rtmass178->SetLineStyle(2);//dashed
1198  
1199  
1200  Rtmass169->SetLineColor(TColor::GetColor("#FF52F1"));//purple
1201  Rtmass169->SetLineStyle(3);//dotted
1202  Rtmass175->SetLineColor(TColor::GetColor("#FF52F1"));
1203  Rtmass175->SetLineStyle(2);//dashed
1204
1205  
1259    RCentral->GetYaxis()->SetRangeUser(0,2);
1260    RCentral->Draw("e1");
1261    RMatchingUp->Draw("histo,same");
1262    RMatchingDown->Draw("histo,same");
1263    RScaleUp->Draw("histo,same");
1264    RScaleDown->Draw("histo,same");
1212  Rtmass166->Draw("histo,same");
1213  Rtmass169->Draw("histo,same");
1214  Rtmass175->Draw("histo,same");
1215  Rtmass178->Draw("histo,same");
1265    
1266    CompleteSave(ckin,saveas+"___AllRatios");
1267  
1268 <  TCanvas *multicanvas = new TCanvas("multicanvas","multicanvas",1000,1000);
1269 <  multicanvas->Divide(2,2);
1268 >  TCanvas *multicanvas = new TCanvas("multicanvas","multicanvas",1400,700);
1269 >  multicanvas->Divide(2,1);
1270    PresentRange(RMatchingUp,RMatchingDown,RCentral,multicanvas->cd(1),"Matching");
1271    PresentRange(RScaleUp,RScaleDown,RCentral,multicanvas->cd(2),"Scale");
1223  PresentRange(Rtmass166,Rtmass178,RCentral,multicanvas->cd(3),"m_{t} (2#sigma)");
1224  PresentRange(Rtmass169,Rtmass175,RCentral,multicanvas->cd(4),"m_{t} (1#sigma)");
1272    CompleteSave(multicanvas,saveas+"___RangeIllustration");
1273    
1274    
# Line 1231 | Line 1278 | void make_ttbar_comparison(string datava
1278    delete   TMatchingDown;
1279    delete   TScaleUp;
1280    delete   TScaleDown;
1281 <  delete   Ttmass166;
1282 <  delete   Ttmass169;
1283 <  delete   Ttmass175;
1284 <  delete   Ttmass178;
1281 > //   delete   Ttmass166;
1282 > //   delete   Ttmass169;
1283 > //   delete   Ttmass175;
1284 > //   delete   Ttmass178;
1285    
1286    delete ckin;
1287    
# Line 1273 | Line 1320 | void ProduceJanPlots() {
1320    delete c1;
1321   }
1322  
1323 < THStack MakeOneSystematicsPlot(TCut cut, string saveas, string variation, TH1F *hdata, string variable, int nbins, float bmin, float bmax, string label) {
1323 > THStack MakeOneSystematicsPlot(TCut cut, string saveas, string variation, TH1F *hdata, string variable, int nbins, float bmin, float bmax, string label, TH1F* &thisto) {
1324    THStack SystPlot = allsamples.DrawStack(variation,variable,nbins,bmin,bmax,label,"events",cut,mc,PlottingSetup::luminosity);
1325    
1326    //now need to process the plot (calculate the variation and set the member of thstack accordingly!)
# Line 1294 | Line 1341 | THStack MakeOneSystematicsPlot(TCut cut,
1341            h->SetBinContent(i,varttbar->GetBinContent(i));
1342            h->SetBinError(i,varttbar->GetBinError(i));
1343          }
1344 +        thisto=(TH1F*)varttbar->Clone(variation.c_str());
1345          SystPlot.Modified();
1346        }
1347      }
1348      delete varttbar;
1349 +  } else {
1350 +    TIter nextHisto(SystPlot.GetHists());
1351 +    TH1F* h;
1352 +    while ( h = (TH1F*)nextHisto() ) {
1353 +      if(Contains(h->GetName(),"t_bar_t")) thisto=(TH1F*)h->Clone(variation.c_str());
1354 +    }
1355    }
1356 <  
1356 >    
1357    TLegend *fullleg = allsamples.allbglegend();
1358    fullleg->SetHeader(variation.c_str());
1359    TPad *kinpad = new TPad("kinpad","kinpad",0,0,1,1);
# Line 1323 | Line 1377 | THStack MakeOneSystematicsPlot(TCut cut,
1377  
1378   void ProduceMCSystematicPlot(string variable, int nbins, float bmin, float bmax, string label, TCut thiscut, string saveas) {
1379    TCanvas *ca = new TCanvas("ca","ca");
1326
1380    TH1F *hdata = allsamples.Draw("hdata",variable,nbins,bmin,bmax,label,"events",thiscut,data,luminosity);
1381    
1382 <  THStack ScaleUp      = MakeOneSystematicsPlot(thiscut,saveas,"ScaleUp",hdata,variable, nbins, bmin, bmax, label);
1383 <  THStack ScaleDown    = MakeOneSystematicsPlot(thiscut,saveas,"ScaleDown",hdata,variable, nbins, bmin, bmax, label);
1384 <  THStack MatchingUp   = MakeOneSystematicsPlot(thiscut,saveas,"MatchingUp",hdata,variable, nbins, bmin, bmax, label);
1385 <  THStack MatchingDown = MakeOneSystematicsPlot(thiscut,saveas,"MatchingDown",hdata,variable, nbins, bmin, bmax, label);
1382 >  TH1F *tScaleUp,*tScaleDown,*tMatchingUp,*tMatchingDown,*tCentral;
1383 >  
1384 >  THStack ScaleUp      = MakeOneSystematicsPlot(thiscut,saveas,"ScaleUp",hdata,variable, nbins, bmin, bmax, label,tScaleUp);
1385 >  THStack ScaleDown    = MakeOneSystematicsPlot(thiscut,saveas,"ScaleDown",hdata,variable, nbins, bmin, bmax, label,tScaleDown);
1386 >  THStack MatchingUp   = MakeOneSystematicsPlot(thiscut,saveas,"MatchingUp",hdata,variable, nbins, bmin, bmax, label,tMatchingUp);
1387 >  THStack MatchingDown = MakeOneSystematicsPlot(thiscut,saveas,"MatchingDown",hdata,variable, nbins, bmin, bmax, label,tMatchingDown);
1388    
1389    TH1F *HScaleUp = CollapseStack(ScaleUp);
1390    TH1F *HScaleDown = CollapseStack(ScaleDown);
1391    TH1F *HMatchingUp = CollapseStack(MatchingUp);
1392    TH1F *HMatchingDown = CollapseStack(MatchingDown);
1393    
1394 <  DeleteStack(ScaleUp);
1340 <  DeleteStack(ScaleDown);
1341 <  DeleteStack(MatchingUp);
1342 <  DeleteStack(MatchingDown);
1343 <  
1344 <  THStack Central = MakeOneSystematicsPlot(thiscut,saveas,"Central",hdata,variable, nbins, bmin, bmax, label);
1394 >  THStack Central = MakeOneSystematicsPlot(thiscut,saveas,"Central",hdata,variable, nbins, bmin, bmax, label,tCentral);
1395    TH1F *HCentral = CollapseStack(Central);
1396    
1397    TH1F *Systematic = (TH1F*)hdata->Clone("Systematic");
# Line 1363 | Line 1413 | void ProduceMCSystematicPlot(string vari
1413    TPad *kinpad = new TPad("kinpad","kinpad",0,0,1,1);
1414    kinpad->SetLogy(1);
1415    kinpad->cd();
1416 <  hdata->Draw("e1");
1417 <  Central.Draw("histo,same");
1418 <  hdata->Draw("e1,same");
1416 >  if(variable=="genMET") {
1417 >    Central.Draw("histo");
1418 >  } else {
1419 >    hdata->Draw("e1");
1420 >    Central.Draw("histo,same");
1421 >    hdata->Draw("e1,same");
1422 >  }
1423 >  
1424    DrawPrelim();
1370
1371  save_with_ratio_and_sys_band( hdata, HCentral, kinpad->cd(), saveas, false, false, "data/mc",Systematic );
1425    
1426 +  save_with_ratio_and_sys_band( 0.0, hdata, HCentral, kinpad->cd(), saveas, false, false, "data/mc",Systematic );
1427 +  
1428 +  kinpad->cd();
1429 +  tCentral->SetFillColor(kWhite);
1430 +  tCentral->SetLineColor(kBlack);
1431 +  tScaleUp->SetLineColor(kRed);
1432 +  tScaleDown->SetLineColor(kRed);
1433 +  tMatchingUp->SetLineColor(kBlue);
1434 +  tMatchingDown->SetLineColor(kBlue);
1435 +  tScaleUp->SetLineStyle(2);
1436 +  tScaleDown->SetLineStyle(3);
1437 +  tMatchingUp->SetLineStyle(2);
1438 +  tMatchingDown->SetLineStyle(3);
1439 +  
1440 +  TLegend *leg2 = make_legend();
1441 +  leg2->AddEntry(hdata,"Data","p");
1442 +  leg2->AddEntry(tCentral,"Central (ttbar)","l");
1443 +  leg2->AddEntry(tScaleUp,"ScaleUp (ttbar)","l");
1444 +  leg2->AddEntry(tScaleDown,"ScaleDown (ttbar)","l");
1445 +  leg2->AddEntry(tMatchingUp,"MatchingUp (ttbar)","l");
1446 +  leg2->AddEntry(tMatchingDown,"MatchingDown (ttbar)","l");
1447 +  if(variable=="genMET") {
1448 +    Central.Draw("histo");
1449 +  }else {
1450 +    hdata->Draw("e1");
1451 +    Central.Draw("histo,same");
1452 +    hdata->Draw("e1,same");
1453 +  }
1454 +  tCentral->Draw("histo,same");
1455 +  tScaleUp->Draw("histo,same");
1456 +  tScaleDown->Draw("histo,same");
1457 +  tMatchingUp->Draw("histo,same");
1458 +  tMatchingDown->Draw("histo,same");
1459 +  leg2->Draw();
1460 +  
1461 +  CompleteSave(kinpad,saveas+"__TTbarComparison");
1462 +  
1463 +  gStyle->SetOptFit(0);
1464 +  
1465 +  kinpad->cd();
1466 +  kinpad->SetLogy(0);
1467 +  TH1F *MatchingRatio = (TH1F*)tMatchingUp->Clone("MatchingRatio");
1468 +  MatchingRatio->Divide(tMatchingDown);
1469 +  TLine *lone = new TLine(tScaleUp->GetBinLowEdge(1),1,tScaleUp->GetBinLowEdge(tScaleUp->GetNbinsX())+tScaleUp->GetBinWidth(tScaleUp->GetNbinsX()),1);
1470 +  lone->SetLineColor(TColor::GetColor("#01DF01"));
1471 +  lone->SetLineStyle(2);
1472 +  TH1F *ScaleRatio = (TH1F*)tScaleUp->Clone("ScaleRatio");
1473 +  ScaleRatio->Divide(tScaleDown);
1474 +  MatchingRatio->GetYaxis()->SetRangeUser(0,3);
1475 +  MatchingRatio->Draw("e1");
1476 +  TF1 *QP1 = new TF1("QP1","[0]+[1]*x",50,200);//simple linear function ranging from 50 to 200
1477 +  MatchingRatio->Fit("QP1","R");
1478 +  lone->Draw();
1479 +  stringstream summary;
1480 +  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);
1481 +  summary << " +/- " << DigitsAfterComma(QP1->GetParError(1),4) << "}}";
1482 +  TText *infobox = write_title(summary.str());
1483 +  infobox->SetX(0.75);
1484 +  infobox->SetTextSize(0.03);
1485 +  infobox->SetY(0.75);
1486 +  infobox->Draw();
1487 +  CompleteSave(kinpad,saveas+"__TTbarComparison_MatchingUpDividedMatchingDown");
1488 +  kinpad->cd();
1489 +  ScaleRatio->GetYaxis()->SetRangeUser(0,3);
1490 +  ScaleRatio->Draw("e1");
1491 +  ScaleRatio->Fit("QP1","R");
1492 +  summary.str("");
1493 +  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);
1494 +  summary << " +/- " << DigitsAfterComma(QP1->GetParError(1),4) << "}}";
1495 +  TText *infobox2 = write_title(summary.str());
1496 +  infobox2->SetX(0.75);
1497 +  infobox2->SetTextSize(0.03);
1498 +  infobox2->SetY(0.75);
1499 +  infobox2->Draw();
1500 +
1501 +  lone->Draw();
1502 +  CompleteSave(kinpad,saveas+"__TTbarComparison_ScaleUpDividedScaleDown");
1503 +  
1504 +  
1505 +  delete QP1;
1506 +  delete infobox;
1507 +  delete infobox2;
1508 +  delete MatchingRatio;
1509 +  delete ScaleRatio;
1510 +  DeleteStack(ScaleUp);
1511 +  DeleteStack(ScaleDown);
1512 +  DeleteStack(MatchingUp);
1513 +  DeleteStack(MatchingDown);
1514 +  delete leg2;
1515    CleanLegends();
1516    DeleteStack(Central);
1517    delete Systematic;
# Line 1382 | Line 1524 | void ProduceMCSystematicPlot(string vari
1524    delete ca;
1525   }
1526  
1527 + TH1F* ImposeBinning(TH1F *binninghisto, TH1F* histo) {
1528 +  float val=0,err=0;
1529 +  vector<float> bins;
1530 +  vector<float> vals;
1531 +  vector<float> errs;
1532 +  
1533 +  bins.push_back(binninghisto->GetBinLowEdge(1));
1534 +  int iBin=1;
1535 +  
1536 +  for(unsigned int i=1;i<histo->GetNbinsX();i++) {//going to second last one on purpose!
1537 +    if((histo->GetBinLowEdge(i)+0.00001>=binninghisto->GetBinLowEdge(iBin)+binninghisto->GetBinWidth(iBin))) {
1538 +      bins.push_back(histo->GetBinLowEdge(i));
1539 +      vals.push_back(val);val=0;
1540 +      errs.push_back(err);err=0;
1541 +      iBin++;
1542 +    }
1543 +    val+=histo->GetBinContent(i);
1544 +    err=sqrt(err*err+histo->GetBinError(i)*histo->GetBinError(i));
1545 +  }
1546 +  bins.push_back(histo->GetBinLowEdge(histo->GetNbinsX())+histo->GetBinWidth(histo->GetNbinsX()));
1547 +  vals.push_back(val);val=0;
1548 +  errs.push_back(err);err=0;
1549 +  
1550 +  TH1F *h = new TH1F(("r"+(string)histo->GetName()).c_str(),("r"+(string)histo->GetName()).c_str(),bins.size()-1,&bins[0]);
1551 +  for(unsigned int i=0;i<vals.size();i++) {
1552 +    h->SetBinContent(i+1,vals[i]);
1553 +    h->SetBinError(i+1,errs[i]);
1554 +  }
1555 +  
1556 +  h->GetXaxis()->SetTitle(histo->GetXaxis()->GetTitle());
1557 +  h->GetYaxis()->SetTitle(histo->GetYaxis()->GetTitle());
1558 +  
1559 +  h->GetXaxis()->CenterTitle();
1560 +  h->GetYaxis()->CenterTitle();
1561 +
1562 +  return h;
1563 + }
1564 +
1565 +
1566 + TH1F* ReBinOptimizingStats(int nbins, TH1F *histo) {
1567 +  float statsperbin = (1/(float)nbins) * histo->Integral();
1568 +  float val=0,err=0;
1569 +  vector<float> bins;
1570 +  vector<float> vals;
1571 +  vector<float> errs;
1572 +  
1573 +  bins.push_back(histo->GetBinLowEdge(1));
1574 +  for(unsigned int i=1;i<=histo->GetNbinsX();i++) {
1575 +    val+=histo->GetBinContent(i);
1576 +    err=sqrt(err*err+histo->GetBinError(i)*histo->GetBinError(i));
1577 +    if( val/statsperbin > 0.85) {
1578 +      if(bins.size()<nbins) {
1579 +        bins.push_back(histo->GetBinLowEdge(i)+histo->GetBinWidth(i));
1580 +        vals.push_back(val);val=0;
1581 +        errs.push_back(err);err=0;
1582 +      }
1583 +    }
1584 +    if(i==histo->GetNbinsX()) {
1585 +      bins.push_back(histo->GetBinLowEdge(i)+histo->GetBinWidth(i));
1586 +      vals.push_back(val);val=0;
1587 +      errs.push_back(err);err=0;
1588 +    }
1589 +  }
1590 +  TH1F *h = new TH1F(("r"+(string)histo->GetName()).c_str(),("r"+(string)histo->GetName()).c_str(),bins.size()-1,&bins[0]);
1591 +  
1592 +  h->GetXaxis()->SetTitle(histo->GetXaxis()->GetTitle());
1593 +  h->GetYaxis()->SetTitle(histo->GetYaxis()->GetTitle());
1594 +  
1595 +  h->GetXaxis()->CenterTitle();
1596 +  h->GetYaxis()->CenterTitle();
1597 +  
1598 +  for(unsigned int i=0;i<vals.size();i++) {
1599 +    h->SetBinContent(i+1,vals[i]);
1600 +    h->SetBinError(i+1,errs[i]);
1601 +  }
1602 +  
1603 +  return h;
1604 + }
1605 +
1606 +
1607 +  
1608 + void ShowBinning(TH1F *histo) {
1609 +  cout << "Showing binning for " << histo->GetName() << " (\" " << histo->GetTitle() << "\")" << endl;
1610 +  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;
1611 + }
1612 +  
1613 + void QuickProduceMCSystematicPlot(string variable, int nbins, float bmin, float bmax, string label, TCut thiscut, string saveas) {
1614 +  TCanvas *ca = new TCanvas("ca","ca");
1615 +  TH1F *tScaleUp = systsamples.Draw("tScaleUp",variable,nbins,bmin,bmax,label,"events",thiscut,mc,luminosity,systsamples.FindSample("scaleup"));
1616 +  TH1F *tScaleDown = systsamples.Draw("tScaleDown",variable,nbins,bmin,bmax,label,"events",thiscut,mc,luminosity,systsamples.FindSample("scaledown"));
1617 +  TH1F *tMatchingUp = systsamples.Draw("tMatchingUp",variable,nbins,bmin,bmax,label,"events",thiscut,mc,luminosity,systsamples.FindSample("matchingup"));
1618 +  TH1F *tMatchingDown = systsamples.Draw("tMatchingDown",variable,nbins,bmin,bmax,label,"events",thiscut,mc,luminosity,systsamples.FindSample("matchingdown"));
1619 +  TH1F *tCentral = systsamples.Draw("tCentral",variable,nbins,bmin,bmax,label,"events",thiscut,mc,luminosity,systsamples.FindSample("TTJets_MassiveBinDECAY_TuneZ2sta"));
1620 +  
1621 +  tScaleUp->Scale(1.0/tScaleUp->Integral());
1622 +  tScaleDown->Scale(1.0/tScaleDown->Integral());
1623 +  tMatchingDown->Scale(1.0/tMatchingDown->Integral());
1624 +  tMatchingUp->Scale(1.0/tMatchingUp->Integral());
1625 +  tCentral->Scale(1.0/tCentral->Integral());
1626 +  
1627 +  cout << "At this point we want to rebin the scale/matching histograms so we get decent stats!" << endl;
1628 +  
1629 +  
1630 +  TH1F *rtScaleUp = ReBinOptimizingStats(7,tScaleUp); // using the scale up sample to get the binning (shouldn't use the central one for obvious reasons)
1631 +  TH1F *rtScaleDown = ImposeBinning(rtScaleUp,tScaleDown);
1632 +  TH1F *rtMatchingDown = ImposeBinning(rtScaleUp,tMatchingDown);
1633 +  TH1F *rtMatchingUp = ImposeBinning(rtScaleUp,tMatchingUp);
1634 +  TH1F *rtCentral = ImposeBinning(rtScaleUp,tCentral);
1635 +  
1636 +  float min=rtScaleUp->GetMinimum();
1637 +  float max=rtScaleUp->GetMaximum();
1638 +  
1639 +  if(rtScaleDown->GetMinimum()<min) min=rtScaleDown->GetMinimum();
1640 +  if(rtMatchingDown->GetMinimum()<min) min=rtMatchingDown->GetMinimum();
1641 +  if(rtMatchingDown->GetMinimum()<min) min=rtMatchingDown->GetMinimum();
1642 +  if(rtMatchingUp->GetMinimum()<min) min=rtMatchingUp->GetMinimum();
1643 +  if(rtCentral->GetMinimum()<min) min=rtCentral->GetMinimum();
1644 +  
1645 +  if(rtScaleDown->GetMaximum()<min) max=rtScaleDown->GetMaximum();
1646 +  if(rtMatchingDown->GetMaximum()<min) max=rtMatchingDown->GetMaximum();
1647 +  if(rtMatchingDown->GetMaximum()<min) max=rtMatchingDown->GetMaximum();
1648 +  if(rtMatchingUp->GetMaximum()<min) max=rtMatchingUp->GetMaximum();
1649 +  if(rtCentral->GetMaximum()<min) max=rtCentral->GetMaximum();
1650 +  
1651 +  rtCentral->SetMaximum(1.2*max);
1652 +  rtCentral->SetMinimum(0.8*min);
1653 +  
1654 + /*  tScaleUp->Rebin(40);
1655 +  tScaleDown->Rebin(40);
1656 +  tMatchingDown->Rebin(40);
1657 +  tMatchingUp->Rebin(40);
1658 +  tCentral->Rebin(40);*/
1659 +  
1660 +  TPad *kinpad = new TPad("kinpad","kinpad",0,0,1,1);
1661 +  kinpad->SetLogy(1);
1662 +  kinpad->cd();
1663 +  tCentral->SetFillColor(kWhite);
1664 +  tCentral->SetLineColor(kBlack);
1665 +  tScaleUp->SetLineColor(kRed);
1666 +  tScaleDown->SetLineColor(kRed);
1667 +  tMatchingUp->SetLineColor(kBlue);
1668 +  tMatchingDown->SetLineColor(kBlue);
1669 +  tScaleUp->SetLineStyle(2);
1670 +  tScaleDown->SetLineStyle(3);
1671 +  tMatchingUp->SetLineStyle(2);
1672 +  tMatchingDown->SetLineStyle(3);
1673 +  
1674 +  rtScaleDown->SetLineColor(kRed);
1675 +  rtMatchingUp->SetLineColor(kBlue);
1676 +  rtMatchingDown->SetLineColor(kBlue);
1677 +  rtScaleUp->SetLineStyle(2);
1678 +  rtScaleDown->SetLineStyle(3);
1679 +  rtMatchingUp->SetLineStyle(2);
1680 +  rtMatchingDown->SetLineStyle(3);
1681 +  
1682 +  TLegend *leg2 = make_legend();
1683 +  leg2->AddEntry(tCentral,"Central (ttbar)","l");
1684 +  leg2->AddEntry(tScaleUp,"ScaleUp (ttbar)","l");
1685 +  leg2->AddEntry(tScaleDown,"ScaleDown (ttbar)","l");
1686 +  leg2->AddEntry(tMatchingUp,"MatchingUp (ttbar)","l");
1687 +  leg2->AddEntry(tMatchingDown,"MatchingDown (ttbar)","l");
1688 +  
1689 +  tCentral->Draw("histo");
1690 +  tScaleUp->Draw("histo,same");
1691 +  tScaleDown->Draw("histo,same");
1692 +  tMatchingUp->Draw("histo,same");
1693 +  tMatchingDown->Draw("histo,same");
1694 +  leg2->Draw();
1695 +  DrawMCPrelim();
1696 +  CompleteSave(kinpad,saveas+"__TTbarComparison");
1697 +  kinpad->cd();
1698 +  kinpad->SetLogy(0);
1699 +  rtCentral->Draw("histo");
1700 +  rtScaleUp->Draw("histo,same");
1701 +  rtScaleDown->Draw("histo,same");
1702 +  rtMatchingUp->Draw("histo,same");
1703 +  rtMatchingDown->Draw("histo,same");
1704 +  leg2->Draw();
1705 +  DrawMCPrelim();
1706 +  CompleteSave(kinpad,saveas+"__TTbarComparison__REBINNED");
1707 +  
1708 +  
1709 +  gStyle->SetOptFit(0);
1710 +
1711 +  kinpad->cd();
1712 +  kinpad->SetLogy(0);
1713 +  TH1F *MatchingRatio = (TH1F*)rtMatchingUp->Clone("MatchingRatio");
1714 +  MatchingRatio->Divide(rtMatchingDown);
1715 +  TLine *lone = new TLine(tScaleUp->GetBinLowEdge(1),1,tScaleUp->GetBinLowEdge(tScaleUp->GetNbinsX())+tScaleUp->GetBinWidth(tScaleUp->GetNbinsX()),1);
1716 +  lone->SetLineColor(TColor::GetColor("#01DF01"));
1717 +  lone->SetLineStyle(2);
1718 +  TH1F *ScaleRatio = (TH1F*)rtScaleUp->Clone("ScaleRatio");
1719 +  ScaleRatio->Divide(rtScaleDown);
1720 +  MatchingRatio->GetYaxis()->SetRangeUser(0,3);
1721 +  MatchingRatio->Draw("e1");
1722 +  TF1 *QP1 = new TF1("QP1","[0]+[1]*x",50,200);//simple linear function ranging from 50 to 200
1723 +  if(variable=="genMET" || variable=="met[4]" || variable=="met[1]") MatchingRatio->Fit("QP1","RQ");
1724 +  lone->Draw();
1725 +  stringstream summary;
1726 +  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);
1727 +  summary << " +/- " << DigitsAfterComma(QP1->GetParError(1),4) << "}}";
1728 +  TText *infobox = write_title(summary.str());
1729 +  infobox->SetX(0.75);
1730 +  infobox->SetTextSize(0.03);
1731 +  infobox->SetY(0.75);
1732 +  if(variable=="genMET" || variable=="met[4]" || variable=="met[1]") infobox->Draw();
1733 +  DrawMCPrelim();
1734 +  CompleteSave(kinpad,saveas+"__TTbarComparison_MatchingUpDividedMatchingDown");
1735 +  kinpad->cd();
1736 +  ScaleRatio->GetYaxis()->SetRangeUser(0,3);
1737 +  ScaleRatio->Draw("e1");
1738 +  if(variable=="genMET" || variable=="met[4]" || variable=="met[1]") ScaleRatio->Fit("QP1","RQ");
1739 +  summary.str("");
1740 +  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);
1741 +  summary << " +/- " << DigitsAfterComma(QP1->GetParError(1),4) << "}}";
1742 +  TText *infobox2 = write_title(summary.str());
1743 +  infobox2->SetX(0.75);
1744 +  infobox2->SetTextSize(0.03);
1745 +  infobox2->SetY(0.75);
1746 +  if(variable=="genMET" || variable=="met[4]" || variable=="met[1]") infobox2->Draw();
1747 +
1748 +  lone->Draw();
1749 +  DrawMCPrelim();
1750 +  CompleteSave(kinpad,saveas+"__TTbarComparison_ScaleUpDividedScaleDown");
1751 +  
1752 +  kinpad->cd();
1753 +  TH1F *SysMatching = (TH1F*)rtMatchingDown->Clone("SysMatching");
1754 +  TH1F *SysScale = (TH1F*)rtScaleDown->Clone("SysMatching");
1755 +  TH1F *SysHisto = (TH1F*)rtScaleDown->Clone("SysHisto");
1756 +  
1757 +  for(int i=1;i<=SysScale->GetNbinsX();i++) {
1758 +    float matching, scale;
1759 +    bool AssumeFactor=false;
1760 +    if(AssumeFactor) {
1761 +      // assume that an upward/downward variation means a change by a constant factor, i.e. f(up) = alpha * f(central)
1762 +      matching=0.;
1763 +      scale=0.;
1764 +    } else {
1765 +      // assume that the central value is exactly between up & down, i.e. central = (up-down)/2
1766 +      matching = fabs(    ( rtMatchingUp->GetBinContent(i) - rtMatchingDown->GetBinContent(i)) / (rtMatchingUp->GetBinContent(i) + rtMatchingDown->GetBinContent(i)) );
1767 +      scale    = fabs(    ( rtScaleUp->GetBinContent(i) - rtScaleDown->GetBinContent(i)) / (rtScaleUp->GetBinContent(i) + rtScaleDown->GetBinContent(i)) );
1768 +    }
1769 +    
1770 +    SysMatching->SetBinContent(i,1+matching);
1771 +    SysScale->SetBinContent(i,1+scale);
1772 +    SysHisto->SetBinContent(i,sqrt(matching*matching+scale*scale)+1);
1773 +  }
1774 +  
1775 +  SysHisto->SetLineColor(kGreen);
1776 +  
1777 +  SysMatching->SetMaximum(3.0);
1778 +  SysMatching->SetMinimum(0.0);
1779 +  SysMatching->Draw("histo");
1780 +  SysScale->Draw("histo,same");
1781 +  SysHisto->Draw("histo,same");
1782 +  CompleteSave(kinpad,saveas+"__TTbarComparison_DerivedSystematic");
1783 +  
1784 +  delete SysMatching;
1785 +  delete SysScale;
1786 +  
1787 +  if(!Contains(variable,"gen")) {
1788 +    TH1F *hdata  = allsamples.Draw("hdata",   variable,nbins,bmin,bmax,label,"events",thiscut,data,luminosity);
1789 +    THStack smc = allsamples.DrawStack("smc",variable,nbins,bmin,bmax,label,"events",thiscut,mc,luminosity);
1790 +    
1791 +    TH1F *Systematic = (TH1F*)hdata->Clone("Systematic");
1792 +    
1793 +    for(int i=1;i<=Systematic->GetNbinsX();i++) {
1794 +      int iBin=SysHisto->FindBin(Systematic->GetBinCenter(i));
1795 +      if(iBin>SysHisto->GetNbinsX()) --iBin; // if we're over the end of the histo, use the last bin
1796 +      float sys = SysHisto->GetBinContent(iBin)-1;
1797 +      Systematic->SetBinContent(i,sys);
1798 +    }
1799 +    
1800 +    kinpad->cd();
1801 +    TLegend *leg = allsamples.allbglegend();
1802 +    hdata->Draw();
1803 +    smc.Draw("histo,same");
1804 +    hdata->Draw("same");
1805 +    leg->Draw();
1806 +    DrawPrelim();
1807 +    save_with_ratio_and_sys_band( 0.0, hdata, CollapseStack(smc), kinpad->cd(), saveas+"__DataVsMC", false, false, "data/mc",Systematic );
1808 +    
1809 +    delete Systematic;
1810 +    delete hdata;
1811 +  }
1812 +  
1813 +  
1814 +  delete SysHisto;
1815 +  delete tScaleUp;
1816 +  delete tScaleDown;
1817 +  delete tCentral;
1818 +  delete tMatchingUp;
1819 +  delete tMatchingDown;
1820 +  delete rtScaleUp;
1821 +  delete rtScaleDown;
1822 +  delete rtCentral;
1823 +  delete rtMatchingUp;
1824 +  delete rtMatchingDown;
1825 +  delete QP1;
1826 +  delete infobox;
1827 +  delete infobox2;
1828 +  delete MatchingRatio;
1829 +  delete ScaleRatio;
1830 +  delete leg2;
1831 +  CleanLegends();
1832 +  delete ca;
1833 + }
1834 +
1835   void ProduceMCSystematicPlots() {
1836 +  cout << "Getting ready to produce systematic plots " << endl;
1837    TCut cutweightBKP = cutWeight;
1838    
1839 <  ProduceMCSystematicPlot("met[4]",80,0,400,"PFMET [GeV]",cutOSSF&&cutnJets&&TCut("mll>20&&mll<70"),"MCSystPlots/MET/ETH_SameFlavor");
1840 <  ProduceMCSystematicPlot("met[4]",80,0,400,"PFMET [GeV]",cutOSOF&&cutnJets&&TCut("mll>20&&mll<70"),"MCSystPlots/MET/ETH_OppositeFlavor");
1841 <  ProduceMCSystematicPlot("pfJetGoodNum40",8,-0.5,7.5,"NJets",cutOSSF&&cutnJets&&TCut("mll>20&&mll<70&&met[4]>100"),"MCSystPlots/NJets/ETH_SameFlavor");
1842 <  ProduceMCSystematicPlot("pfJetGoodNum40",8,-0.5,7.5,"NJets",cutOSOF&&cutnJets&&TCut("mll>20&&mll<70&&met[4]>100"),"MCSystPlots/NJets/ETH_OppositeFlavor");
1839 >  QuickProduceMCSystematicPlot("genMET",20,0,200,"gen#slash{E}_{T} [GeV]",cutOSSF&&cutnJets&&TCut("mll>20&&mll<70"),"MCSystPlots/genMET/ETH_SameFlavor");
1840 >  QuickProduceMCSystematicPlot("genMET",20,0,200,"gen#slash{E}_{T} [GeV]",cutOSOF&&cutnJets&&TCut("mll>20&&mll<70"),"MCSystPlots/genMET/ETH_OppositeFlavor");
1841 >  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PF#slash{E}_{T} [GeV]",cutOSSF&&cutnJets&&TCut("mll>20&&mll<70"),"MCSystPlots/MET/ETH_SameFlavor");
1842 >  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PF#slash{E}_{T} [GeV]",cutOSOF&&cutnJets&&TCut("mll>20&&mll<70"),"MCSystPlots/MET/ETH_OppositeFlavor");
1843 >  
1844 >  QuickProduceMCSystematicPlot("genMET",20,0,200,"gen#slash{E}_{T} [GeV]",cutOSSF&&TCut("mll>20&&mll<70"),"MCSystPlots/genMET/ETH_SameFlavor_INCLUSIVE");
1845 >  QuickProduceMCSystematicPlot("genMET",20,0,200,"gen#slash{E}_{T} [GeV]",cutOSOF&&TCut("mll>20&&mll<70"),"MCSystPlots/genMET/ETH_OppositeFlavor_INCLUSIVE");  
1846 >  QuickProduceMCSystematicPlot("genMET",20,0,200,"gen#slash{E}_{T} [GeV]",cutOSSF&&TCut("mll>120"),"MCSystPlots/genMET/ETH_SameFlavor_INCLUSIVE_HighMass");
1847 >  QuickProduceMCSystematicPlot("genMET",20,0,200,"gen#slash{E}_{T} [GeV]",cutOSOF&&TCut("mll>120"),"MCSystPlots/genMET/ETH_OppositeFlavor_INCLUSIVE_HighMass");  
1848 >  
1849 >  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PF#slash{E}_{T} [GeV]",cutOSSF&&TCut("mll>20&&mll<70"),"MCSystPlots/MET/ETH_SameFlavor_INCLUSIVE");
1850 >  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PF#slash{E}_{T} [GeV]",cutOSOF&&TCut("mll>20&&mll<70"),"MCSystPlots/MET/ETH_OppositeFlavor_INCLUSIVE");
1851 >  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PF#slash{E}_{T} [GeV]",cutOSSF&&TCut("mll>120"),"MCSystPlots/MET/ETH_SameFlavor_INCLUSIVE_HighMass");
1852 >  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PF#slash{E}_{T} [GeV]",cutOSOF&&TCut("mll>120"),"MCSystPlots/MET/ETH_OppositeFlavor_INCLUSIVE_HighMass");
1853 >  QuickProduceMCSystematicPlot("pfJetGoodNum40",8,-0.5,7.5,"NJets",cutOSSF&&cutnJets&&TCut("mll>20&&mll<70&&met[4]>100"),"MCSystPlots/NJets/ETH_SameFlavor");
1854 >  QuickProduceMCSystematicPlot("pfJetGoodNum40",8,-0.5,7.5,"NJets",cutOSOF&&cutnJets&&TCut("mll>20&&mll<70&&met[4]>100"),"MCSystPlots/NJets/ETH_OppositeFlavor");
1855 >  
1856 >  
1857 >  
1858 >  cout << "Kicking cutWeight  " << (const char*) cutWeight << endl;
1859 >  cout << "Keeping OSSF cut " << (const char*)cutOSSF << endl;
1860 >  cutWeight="1.0";
1861 >  
1862 >  QuickProduceMCSystematicPlot("genMET",20,0,200,"gen#slash{E}_{T} [GeV]",cutOSSF&&TCut("mll>20&&mll<70"),"MCSystPlots/genMET/ETH_SameFlavor_INCLUSIVE__NOPURW");
1863 >  QuickProduceMCSystematicPlot("genMET",20,0,200,"gen#slash{E}_{T} [GeV]",cutOSOF&&TCut("mll>20&&mll<70"),"MCSystPlots/genMET/ETH_OppositeFlavor_INCLUSIVE__NOPURW");  
1864 >  QuickProduceMCSystematicPlot("genMET",20,0,200,"gen#slash{E}_{T} [GeV]",cutOSSF&&TCut("mll>120"),"MCSystPlots/genMET/ETH_SameFlavor_INCLUSIVE_HighMass__NOPURW");
1865 >  QuickProduceMCSystematicPlot("genMET",20,0,200,"gen#slash{E}_{T} [GeV]",cutOSOF&&TCut("mll>120"),"MCSystPlots/genMET/ETH_OppositeFlavor_INCLUSIVE_HighMass__NOPURW");  
1866 >  
1867 >  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PF#slash{E}_{T} [GeV]",cutOSSF&&TCut("mll>20&&mll<70"),"MCSystPlots/MET/ETH_SameFlavor_INCLUSIVE__NOPURW");
1868 >  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PF#slash{E}_{T} [GeV]",cutOSOF&&TCut("mll>20&&mll<70"),"MCSystPlots/MET/ETH_OppositeFlavor_INCLUSIVE__NOPURW");
1869 >  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PF#slash{E}_{T} [GeV]",cutOSSF&&TCut("mll>120"),"MCSystPlots/MET/ETH_SameFlavor_INCLUSIVE_HighMass__NOPURW");
1870 >  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PF#slash{E}_{T} [GeV]",cutOSOF&&TCut("mll>120"),"MCSystPlots/MET/ETH_OppositeFlavor_INCLUSIVE_HighMass__NOPURW");
1871 >  
1872 >  
1873 >  // --------------------------------------    ***** AACHEN *****      --------------------------------------    
1874 >  
1875 >  /*
1876 >  cutWeight=cutweightBKP;
1877 >  TCut essentialcutBKP = essentialcut;
1878 >  cout << (const char*) essentialcut << endl;
1879 >  
1880 >  essentialcut = TCut((ReplaceAll((const char*)essentialcut,"pt2>20","pt2>10")).c_str());
1881 >  essentialcut = TCut((ReplaceAll((const char*)essentialcut,"abs(eta1)<1.4","abs(eta1)<2.4")).c_str());
1882 >  essentialcut = TCut((ReplaceAll((const char*)essentialcut,"abs(eta2)<1.4","abs(eta2)<2.4")).c_str());
1883    
1884    TCut cutnJetsBKP = cutnJets;
1885    cutnJets = TCut((ReplaceAll((const char*)cutnJets,"pt2>20","pt2>10")).c_str());
# Line 1396 | Line 1887 | void ProduceMCSystematicPlots() {
1887    cutnJets = TCut((ReplaceAll((const char*)cutnJets,"abs(eta2)<1.4","abs(eta2)<2.4")).c_str());
1888    cutnJets = TCut((ReplaceAll((const char*)cutnJets,"abs(eta1)<1.4","abs(eta1)<2.4")).c_str());
1889    
1890 <  ProduceMCSystematicPlot("met[4]",80,0,400,"PFMET [GeV]",cutOSSF&&cutnJets&&TCut("mll>20&&mll<70"),"MCSystPlots/MET/Aachen_SameFlavor");
1891 <  ProduceMCSystematicPlot("met[4]",80,0,400,"PFMET [GeV]",cutOSOF&&cutnJets&&TCut("mll>20&&mll<70"),"MCSystPlots/MET/Aachen_OppositeFlavor");
1892 <  ProduceMCSystematicPlot("pfJetGoodNum40",8,-0.5,7.5,"NJets",cutOSSF&&cutnJets&&TCut("mll>20&&mll<70&&met[4]>150"),"MCSystPlots/NJets/Aachen_SameFlavor");
1893 <  ProduceMCSystematicPlot("pfJetGoodNum40",8,-0.5,7.5,"NJets",cutOSOF&&cutnJets&&TCut("mll>20&&mll<70&&met[4]>150"),"MCSystPlots/NJets/Aachen_OppositeFlavor");
1890 >  QuickProduceMCSystematicPlot("genMET",20,0,200,"gen#slash{E}_{T} [GeV]",cutOSSF&&cutnJets&&TCut("mll>20&&mll<70"),"MCSystPlots/genMET/Aachen_SameFlavor");
1891 >  QuickProduceMCSystematicPlot("genMET",20,0,200,"gen#slash{E}_{T} [GeV]",cutOSOF&&cutnJets&&TCut("mll>20&&mll<70"),"MCSystPlots/genMET/Aachen_OppositeFlavor");  
1892 >  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PF#slash{E}_{T} [GeV]",cutOSSF&&cutnJets&&TCut("mll>20&&mll<70"),"MCSystPlots/MET/Aachen_SameFlavor");
1893 >  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PF#slash{E}_{T} [GeV]",cutOSOF&&cutnJets&&TCut("mll>20&&mll<70"),"MCSystPlots/MET/Aachen_OppositeFlavor");
1894 >  
1895 >  QuickProduceMCSystematicPlot("genMET",20,0,200,"gen#slash{E}_{T} [GeV]",cutOSSF&&TCut("mll>20&&mll<70"),"MCSystPlots/genMET/Aachen_SameFlavor_INCLUSIVE");
1896 >  QuickProduceMCSystematicPlot("genMET",20,0,200,"gen#slash{E}_{T} [GeV]",cutOSOF&&TCut("mll>20&&mll<70"),"MCSystPlots/genMET/Aachen_OppositeFlavor_INCLUSIVE");  
1897 >  QuickProduceMCSystematicPlot("genMET",20,0,200,"gen#slash{E}_{T} [GeV]",cutOSSF&&TCut("mll>120"),"MCSystPlots/genMET/Aachen_SameFlavor_INCLUSIVE_HighMass");
1898 >  QuickProduceMCSystematicPlot("genMET",20,0,200,"gen#slash{E}_{T} [GeV]",cutOSOF&&TCut("mll>120"),"MCSystPlots/genMET/Aachen_OppositeFlavor_INCLUSIVE_HighMass");  
1899 >  
1900 >  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PF#slash{E}_{T} [GeV]",cutOSSF&&TCut("mll>20&&mll<70"),"MCSystPlots/MET/Aachen_SameFlavor_INCLUSIVE");
1901 >  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PF#slash{E}_{T} [GeV]",cutOSOF&&TCut("mll>20&&mll<70"),"MCSystPlots/MET/Aachen_OppositeFlavor_INCLUSIVE");
1902 >  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PF#slash{E}_{T} [GeV]",cutOSSF&&TCut("mll>120"),"MCSystPlots/MET/Aachen_SameFlavor_INCLUSIVE_HighMass");
1903 >  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PF#slash{E}_{T} [GeV]",cutOSOF&&TCut("mll>120"),"MCSystPlots/MET/Aachen_OppositeFlavor_INCLUSIVE_HighMass");
1904 >  QuickProduceMCSystematicPlot("pfJetGoodNum40",8,-0.5,7.5,"NJets",cutOSSF&&cutnJets&&TCut("mll>20&&mll<70&&met[4]>100"),"MCSystPlots/NJets/Aachen_SameFlavor");
1905 >  QuickProduceMCSystematicPlot("pfJetGoodNum40",8,-0.5,7.5,"NJets",cutOSOF&&cutnJets&&TCut("mll>20&&mll<70&&met[4]>100"),"MCSystPlots/NJets/Aachen_OppositeFlavor");
1906 >  
1907 >  
1908 >  
1909 >  cout << "Kicking cutWeight  " << (const char*) cutWeight << endl;
1910 >  cout << "Keeping OSSF cut " << (const char*)cutOSSF << endl;
1911 >  cutWeight="1.0";
1912 >  
1913 >  QuickProduceMCSystematicPlot("genMET",20,0,200,"gen#slash{E}_{T} [GeV]",cutOSSF&&TCut("mll>20&&mll<70"),"MCSystPlots/genMET/Aachen_SameFlavor_INCLUSIVE__NOPURW");
1914 >  QuickProduceMCSystematicPlot("genMET",20,0,200,"gen#slash{E}_{T} [GeV]",cutOSOF&&TCut("mll>20&&mll<70"),"MCSystPlots/genMET/Aachen_OppositeFlavor_INCLUSIVE__NOPURW");  
1915 >  QuickProduceMCSystematicPlot("genMET",20,0,200,"gen#slash{E}_{T} [GeV]",cutOSSF&&TCut("mll>120"),"MCSystPlots/genMET/Aachen_SameFlavor_INCLUSIVE_HighMass__NOPURW");
1916 >  QuickProduceMCSystematicPlot("genMET",20,0,200,"gen#slash{E}_{T} [GeV]",cutOSOF&&TCut("mll>120"),"MCSystPlots/genMET/Aachen_OppositeFlavor_INCLUSIVE_HighMass__NOPURW");  
1917 >  
1918 >  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PF#slash{E}_{T} [GeV]",cutOSSF&&TCut("mll>20&&mll<70"),"MCSystPlots/MET/Aachen_SameFlavor_INCLUSIVE__NOPURW");
1919 >  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PF#slash{E}_{T} [GeV]",cutOSOF&&TCut("mll>20&&mll<70"),"MCSystPlots/MET/Aachen_OppositeFlavor_INCLUSIVE__NOPURW");
1920 >  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PF#slash{E}_{T} [GeV]",cutOSSF&&TCut("mll>120"),"MCSystPlots/MET/Aachen_SameFlavor_INCLUSIVE_HighMass__NOPURW");
1921 >  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PF#slash{E}_{T} [GeV]",cutOSOF&&TCut("mll>120"),"MCSystPlots/MET/Aachen_OppositeFlavor_INCLUSIVE_HighMass__NOPURW");
1922 >  
1923    cutnJets  = cutnJetsBKP;
1924    cutWeight = cutweightBKP;
1925 +  essentialcut = essentialcutBKP;
1926 +  */
1927 +  write_error(__FUNCTION__,"Still need to add systematic shape");assert(0);
1928 + }
1929 +
1930 + void MakeTauPlot(string label, TCut pcut, string filename, bool TauOnly) {
1931 +  TCut cut=pcut&&basiccut;
1932 +  string variable="mll";
1933 +  string xlabel="m_{ll} [GeV]";
1934 +  int nbins=40;
1935 +  float min=0;
1936 +  float max=200;
1937 +
1938 +  TCanvas *ckin = new TCanvas("ckin","Kinematic Plots (in the making)",600,600);
1939 +  TH1F *datahistoSF = allsamples.Draw("datahistoSF",variable,nbins,min,max, xlabel, "events",cut&&cutOSSF,data,luminosity);
1940 +  TH1F *datahistoOF = allsamples.Draw("datahistoOF",variable,nbins,min,max, xlabel, "events",cut&&cutOSOF,data,luminosity);
1941 +  TH1F *tauSF = allsamples.Draw("tauSF",variable,nbins,min,max, xlabel, "events",cut&&cutOSSF,data,luminosity,systsamples.FindSample("DYToTauTau"));
1942 +  TH1F *tauOF = allsamples.Draw("tauOF",variable,nbins,min,max, xlabel, "events",cut&&cutOSOF,data,luminosity,systsamples.FindSample("DYToTauTau"));
1943 +  datahistoSF->SetMarkerSize(DataMarkerSize);
1944 +  datahistoSF->SetMaximum(1.3*datahistoSF->GetMaximum());
1945 +  datahistoOF->SetMarkerSize(DataMarkerSize);
1946 +  datahistoOF->SetMaximum(1.3*datahistoOF->GetMaximum());
1947 +
1948 +  THStack mcstackSF   = allsamples.DrawStack("mcstackSF",  variable,nbins,min,max,xlabel,"events",cut&&cutOSSF,mc,luminosity);
1949 +  THStack mcstackOF   = allsamples.DrawStack("mcstackOF",  variable,nbins,min,max,xlabel,"events",cut&&cutOSOF,mc,luminosity);
1950 +  datahistoSF->Draw("e1");
1951 +  ckin->Update();
1952 +  mcstackSF.Draw("histo,same");
1953 +  
1954 +  datahistoSF->Draw("same,e1");
1955 +  TLegend *kinleg = allsamples.allbglegend();
1956 +  kinleg->Draw();
1957 +  
1958 +  TPad *kinpad = new TPad("kinpad","kinpad",0,0,1,1);
1959 +  kinpad->cd();
1960 +  datahistoSF->Draw("e1");
1961 +  mcstackSF.Draw("histo,same");
1962 +  datahistoSF->Draw("same,e1");
1963 +  datahistoSF->Draw("same,axis");
1964 +  kinleg->Draw();
1965 +  DrawPrelim();
1966 +  Save_With_Ratio(datahistoSF,mcstackSF,kinpad->cd(),filename+"__SF_mc");
1967 +  
1968 +  kinpad->cd();
1969 +  datahistoOF->Draw("e1");
1970 +  mcstackOF.Draw("histo,same");
1971 +  datahistoOF->Draw("same,e1");
1972 +  datahistoOF->Draw("same,axis");
1973 +  kinleg->Draw();
1974 +  DrawPrelim();
1975 +  Save_With_Ratio(datahistoOF,mcstackOF,kinpad->cd(),filename+"__OF_mc");
1976 +  
1977 +  kinpad->cd();
1978 +  tauSF->Draw("e1");
1979 +  tauOF->Draw("histo,same");
1980 +  tauSF->Draw("e1,same");
1981 +  TLegend *legtau = make_legend();
1982 +  legtau->AddEntry(tauSF,"DY->#tau#tau, SF","p");
1983 +  legtau->AddEntry(tauSF,"DY->#tau#tau, OF","l");
1984 +  legtau->Draw();
1985 +  DrawPrelim();
1986 +  Save_With_Ratio(tauSF,tauOF,kinpad->cd(),filename+"__Tau_SF_vs_OF");
1987 +  
1988 +  delete datahistoSF;
1989 +  delete datahistoOF;
1990 +  delete tauSF;
1991 +  delete tauOF;
1992 +  delete kinpad;
1993 +  delete ckin;
1994 +  CleanLegends();
1995 + }
1996 +  
1997 +
1998 + void TauQuestion() {
1999 + //   MakeTauPlot("MET>100 GeV, #geq 3 jets",cutnJets&&TCut("met[4]>100"),"TauQ/MET100_3Jets",true);
2000 + //   MakeTauPlot("MET>100 GeV",TCut("met[4]>100"),"TauQ/MET100",true);
2001 + //   MakeTauPlot("MET>0 GeV",TCut("met[4]>0"),"TauQ/MET0",true);
2002 +  MakeTauPlot("b-tag veto, 50<MET<100",TCut("pfJetGoodNumBtag30==0&&met[4]>50&&met[4]<100"),"TauQ/ControlPlots",false);
2003 + }
2004 +
2005 + void ProduceOFSFPlots(string mcjzb, string datajzb, bool isAachen) {
2006 +  string BaseMetCut="met[4]>100";
2007 +  string Prefix="ETH/";
2008 +  if(isAachen) {
2009 +    BaseMetCut="met[4]>150";
2010 +    Prefix="Aachen/";
2011 +  }
2012 + //        make_OFSF_plots("st", BaseMetCut, 20, 0, 2000., false, "S_{T}", Prefix+"FrankT");
2013 +      make_OFSF_plots("mt2j", BaseMetCut, 35, 0, 700., false, "M_{T2J}", Prefix+"MT2J");
2014 +
2015 +      make_OFSF_plots("ml1b", BaseMetCut, 20, 0, 800., false, "m_{l_{1}b}", Prefix+"ML1B");
2016 +      make_OFSF_plots("ml2b", BaseMetCut, 20, 0, 400., false, "m_{l_{2}b}", Prefix+"ML2B");
2017 +      make_OFSF_plots("min(ml1b,ml2b)", BaseMetCut, 20, 0, 400., false, "m_{lb}", Prefix+"MLB");
2018 +  
2019 + //      make_OFSF_plots(datajzb, BaseMetCut, 55, -100, 450., false, "JZB", Prefix+"JZB_In_Signal_Region");
2020 +      make_OFSF_plots("mt2", BaseMetCut, 15, 0, 150., false, "M_{T2}", Prefix+"MT2");
2021 +      make_OFSF_plots("d2", BaseMetCut, 20, 0, 200., true, "D2", Prefix+"D2");
2022 +      make_OFSF_plots("pfJetGoodNum40", BaseMetCut, 10, -0.5, 9.5, true, "N_{jets}", Prefix+"nJets");
2023 +      
2024 + //      make_OFSF_plots("mll", BaseMetCut, 60, 20., 320., false, "m_{ll}", Prefix+"mll");
2025 + //      make_OFSF_plots("leptonNum", BaseMetCut, 3, 2, 5., false, "N(leptons)", Prefix+"NLeptons");
2026 +
2027 + //      make_OFSF_plots("pfJetGoodNum40", BaseMetCut,                        7, 3, 10, true, "#(jets)", Prefix+"njets");
2028 + //      make_OFSF_plots("pfJetGoodNum40", BaseMetCut+"&&pfJetGoodNumBtag30==0", 7, 3, 10, true, "#(jets)", Prefix+"njets_btagVeto");
2029 + //      make_OFSF_plots("pfJetGoodNum40", BaseMetCut"&&pfJetGoodNumBtag30>0",  7, 3, 10, true, "#(jets)", Prefix+"njets_AtLeastOneBJet30");
2030 +
2031 + //      make_OFSF_plots("pfJetGoodNumBtag30", BaseMetCut, 5, -0.5, 4.5, true, "N_{b-jets}", Prefix+"nbjets");
2032 + //      make_OFSF_plots("pfJetGoodPtBtag[0]", BaseMetCut+"&&pfJetGoodNumBtag30>0", 20, 0, 400, true, "p_{T}(leading b-jet)", Prefix+"ptb1");
2033 + //      make_OFSF_plots("pfJetGoodPt",  BaseMetCut, 30, 0., 400., true, "p_{T}^{J}", Prefix+"ptJet");
2034 +
2035 + //      make_OFSF_plots("iso1", BaseMetCut, 20, 0, 0.3, true, "lepton 1 isolation", Prefix+"iso1");
2036 + //      make_OFSF_plots("iso2", BaseMetCut, 20, 0, 0.3, true, "lepton 2 isolation", Prefix+"iso2");
2037 +      make_OFSF_plots("pt",  BaseMetCut, 30, 0., 300., true, "p_{ll}", Prefix+"pt");
2038 +      make_OFSF_plots("pt1",  BaseMetCut, 30, 0., 300., true, "p_{T,1}", Prefix+"pt1");
2039 +      make_OFSF_plots("pt2",  BaseMetCut, 22, 0., 220., true, "p_{T,2}", Prefix+"pt2");
2040 + //      make_OFSF_plots("eta1", BaseMetCut, 10, -2.5, 2.5, false, "#eta_{1}", Prefix+"eta1", 0.15);
2041 + //      make_OFSF_plots("eta2", BaseMetCut, 10, -2.5, 2.5, false, "#eta_{2}", Prefix+"eta2", 0.15);
2042 + //      make_OFSF_plots("phi1", BaseMetCut, 10, -TMath::Pi(), TMath::Pi(), false, "#phi_{1}", Prefix+"phi1", 0.2);
2043 + //      make_OFSF_plots("phi2", BaseMetCut, 10, -TMath::Pi(), TMath::Pi(), false, "#phi_{2}", Prefix+"phi2", 0.2);
2044 + //      make_OFSF_plots("pfJetGoodPt[0]/pfJetGoodPt[1]", BaseMetCut, 20, 1, 10, true, "pt_{j}^{1}/pt_{j}^{2}", Prefix+"jpt1pt2", 0.2);
2045 + //      make_OFSF_plots("TMath::Abs(pfJetDphiMet[0])", BaseMetCut, 16, 0, 3.2, false, "|#Delta#phi(jet1,MET)|", Prefix+"dphij1met", 0.2);
2046 +    
2047 + //      make_OFSF_plots("met[4]",  BaseMetCut, 30, 100., 400., true, "E_{T}^{miss}", Prefix+"MET");
2048 + //      make_OFSF_plots("TMath::Abs(dphi)", BaseMetCut, 16, 0, 3.2, false, "|#Delta#phi(l1,l2)|", Prefix+"dphi", 0.2);
2049 + //      make_OFSF_plots("TMath::Abs(dphiMet1)", BaseMetCut, 16, 0, 3.2, false, "|#Delta#phi(l1,MET)|", Prefix+"dphiMet1", 0.2);
2050 + //      make_OFSF_plots("TMath::Abs(dphiMet2)", BaseMetCut, 16, 0, 3.2, false, "|#Delta#phi(l2,MET)|", Prefix+"dphiMet2", 0.2);
2051 + //      make_OFSF_plots("TMath::Min(TMath::Abs(dphiMet1), TMath::Abs(dphiMet2))", BaseMetCut, 16, 0, 3.2, false, "Min(|#Delta#phi(l,MET)|)", Prefix+"dphilc");
2052 + //      make_OFSF_plots("TMath::Min(TMath::Abs(pfJetDphiMet[0]), TMath::Min(TMath::Abs(pfJetDphiMet[1]), TMath::Abs(pfJetDphiMet[2])))", BaseMetCut, 16, 0, 3.2, false, "Min(|#Delta#phi(jet,MET)|)", Prefix+"dphijc");
2053 + //      make_OFSF_plots("TMath::Min((TMath::Pi()-TMath::Abs(dphiMet1)), (TMath::Pi() - TMath::Abs(dphiMet2)))", BaseMetCut, 16, 0, 3.2, false, "Min(#pi - |#Delta#phi(l,MET)|)", Prefix+"dphilco");
2054 + //      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]))))", BaseMetCut, 16, 0, 3.2, false, "Min(#pi - |#Delta#phi(jet,MET)|)", Prefix+"dphijco");
2055 +      
2056 + }
2057 +
2058 + void ProduceOFSFPlots(string mcjzb, string datajzb) {
2059 +  
2060 +  
2061 +  //FIRST : ETH SELECTION
2062 +  ProduceOFSFPlots(mcjzb,datajzb,0); // this is the ETH selection
2063 +  
2064 +  
2065 +  
2066 +  string backup_cutnJets = (const char*)cutnJets;
2067 +  cutnJets = ReplaceInCut(cutnJets,"pfJetGoodNum40>=3","pfJetGoodNum40>=2");
2068 +  cutnJets = ReplaceInCut(cutnJets,"1.4","2.4");
2069 +  
2070 +  string backup_basiccut = (const char*)basiccut;
2071 +  basiccut = ReplaceInCut(basiccut,"1.4","2.4");
2072 +  
2073 +  string backup_essential = (const char*) essentialcut;
2074 +  essentialcut = ReplaceInCut(essentialcut,"1.4","2.4");
2075 +  
2076 +  ProduceOFSFPlots(mcjzb,datajzb,1); // this is the Aachen selection
2077 +  
2078 +  cutnJets     = TCut(backup_cutnJets.c_str());
2079 +  basiccut     = TCut(backup_basiccut.c_str());
2080 +  essentialcut = TCut(backup_essential.c_str());
2081   }
2082 +  
2083  
2084   void do_kinematic_plots(string mcjzb, string datajzb, bool doPF=false)
2085   {
# Line 1411 | Line 2088 | void do_kinematic_plots(string mcjzb, st
2088    bool nolog=false;
2089  
2090    bool doOFSF = true;
2091 <  bool doKin  = true;
2092 <  bool doDataComp = true;
2093 <  bool MakeTwoThreeJetComparison = true;
2091 >  bool doKin  = false;
2092 >  bool doDataComp = false;
2093 >  bool MakeTwoThreeJetComparison = false;
2094    
2095  
2096    if(doPF) write_warning(__FUNCTION__,"Please use caution when trying to produce PF plots; not all versions of the JZB trees have these variables!");
# Line 1425 | Line 2102 | void do_kinematic_plots(string mcjzb, st
2102    }
2103    
2104    if(MakeTwoThreeJetComparison) MakeElegantTwoThreeComparisons();
2105 +  
2106 +  //TauQuestion();
2107  
2108    //ProduceJanPlots();
2109 < //   ProduceMCSystematicPlots();
2110 <  make_plain_kin_plot("pt",Cut2Str(cutOSSF&&TCut("mll>20&&pfJetGoodNumBtag30>=2")),40,0,200,nolog,"Z p_{T}","PlotForKostas",doPF,true);
2109 >  //ProduceMCSystematicPlots();
2110 >  //assert(0);
2111 > //  make_plain_kin_plot("pt",Cut2Str(cutOSSF&&TCut("mll>20&&pfJetGoodNumBtag30>=2")),40,0,200,nolog,"Z p_{T}","PlotForKostas",doPF,true);
2112    
2113 <  if ( doOFSF ) {
2114 <     make_OFSF_plots("mll", "met[4]>100", 60, 20., 320., false, "m_{ll}", "mll");
1435 <
1436 <     make_OFSF_plots("pfJetGoodNum40", "met[4]>100",                        7, 3, 10, true, "#(jets)", "njets");
1437 <     make_OFSF_plots("pfJetGoodNum40", "met[4]>100&&pfJetGoodNumBtag30==0", 7, 3, 10, true, "#(jets)", "njets_btagVeto");
1438 <     make_OFSF_plots("pfJetGoodNum40", "met[4]>100&&pfJetGoodNumBtag30>0",  7, 3, 10, true, "#(jets)", "njets_AtLeastOneBJet30");
1439 <
1440 <     make_OFSF_plots("pfJetGoodNumBtag30", "met[4]>100", 5, 0, 5, true, "#(b-jets)", "nbjets");
1441 <     make_OFSF_plots("pfJetGoodPtBtag[0]", "met[4]>100&&pfJetGoodNumBtag30>0", 20, 0, 400, true, "p_{T}(leading b-jet)", "ptb1");
1442 <
1443 <     make_OFSF_plots("iso1", "met[4]>100", 20, 0, 0.3, true, "lepton 1 isolation", "iso1");
1444 <     make_OFSF_plots("iso2", "met[4]>100", 20, 0, 0.3, true, "lepton 2 isolation", "iso2");
1445 <     make_OFSF_plots("pt1",  "met[4]>100", 30, 0., 300., true, "p_{T,1}", "pt1");
1446 <     make_OFSF_plots("pt2",  "met[4]>100", 22, 0., 220., true, "p_{T,2}", "pt2");
1447 <     make_OFSF_plots("eta1", "met[4]>100", 10, -2.5, 2.5, false, "#eta_{1}", "eta1", 0.15);
1448 <     make_OFSF_plots("eta2", "met[4]>100", 10, -2.5, 2.5, false, "#eta_{2}", "eta2", 0.15);
1449 <     make_OFSF_plots("phi1", "met[4]>100", 10, -TMath::Pi(), TMath::Pi(), false, "#phi_{1}", "phi1", 0.2);
1450 <     make_OFSF_plots("phi2", "met[4]>100", 10, -TMath::Pi(), TMath::Pi(), false, "#phi_{2}", "phi2", 0.2);
1451 <     make_OFSF_plots("pfJetGoodPt[0]/pfJetGoodPt[1]", "met[4]>100", 20, 1, 10, true, "pt_{j}^{1}/pt_{j}^{2}", "jpt1pt2", 0.2);
1452 <     make_OFSF_plots("TMath::Abs(pfJetDphiMet[0])", "met[4]>100", 16, 0, 3.2, false, "|#Delta#phi(jet1,MET)|", "dphij1met", 0.2);
1453 <    make_OFSF_plots("TMath::Abs(dphi)", "met[4]>100", 16, 0, 3.2, false, "|#Delta#phi(l1,l2)|", "dphi", 0.2);
1454 <    make_OFSF_plots("TMath::Abs(dphiMet1)", "met[4]>100", 16, 0, 3.2, false, "|#Delta#phi(l1,MET)|", "dphiMet1", 0.2);
1455 <    make_OFSF_plots("TMath::Abs(dphiMet2)", "met[4]>100", 16, 0, 3.2, false, "|#Delta#phi(l2,MET)|", "dphiMet2", 0.2);
1456 <    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");
1457 <    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");
1458 <    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");
1459 <    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");
1460 <  }
2113 >  if ( doOFSF ) ProduceOFSFPlots(mcjzb,datajzb);
2114 >  assert(0);
2115  
2116    if ( doDataComp) {
2117      TCut mllCut("");
# Line 1552 | Line 2206 | void do_kinematic_plots(string mcjzb, st
2206    if ( doKin ) {
2207      string mllCut("");
2208      
2209 +    make_plain_kin_plot("mll",Cut2Str(cutOSSF&&TCut("mll>20")),56,20,300,dolog,"m_{ll}","NoPreselection/mll_SF",doPF,true);
2210 +    make_plain_kin_plot("mll",Cut2Str(cutOSOF&&TCut("mll>20")),56,20,300,dolog,"m_{ll}","NoPreselection/mll_OF",doPF,true);
2211 +
2212 +    make_plain_kin_plot("met[4]",Cut2Str(cutOSSF&&TCut("mll>20")),80,0,400,dolog,"E_{T}^{miss}","NoPreselection/met_SF",doPF,true);
2213 +    make_plain_kin_plot("met[4]",Cut2Str(cutOSOF&&TCut("mll>20")),80,0,400,dolog,"E_{T}^{miss}","NoPreselection/met_OF",doPF,true);
2214 +
2215 +    make_plain_kin_plot("pfTightHT",Cut2Str(cutOSSF&&TCut("mll>20")),20,0,800,dolog,"H_{T}","NoPreselection/HT_SF",doPF,true);
2216 +    make_plain_kin_plot("pfTightHT",Cut2Str(cutOSOF&&TCut("mll>20")),20,0,800,dolog,"H_{T}","NoPreselection/HT_OF",doPF,true);
2217 +    
2218 +    make_plain_kin_plot("pfJetGoodNum40",Cut2Str(cutOSSF&&TCut("mll>20")),10,-0.5,9.5,dolog,"n_{jets}","NoPreselection/NJets_SF",doPF,true);
2219 +    make_plain_kin_plot("pfJetGoodNum40",Cut2Str(cutOSOF&&TCut("mll>20")),10,-0.5,9.5,dolog,"n_{jets}","NoPreselection/NJets_OF",doPF,true);
2220 +    
2221 +    make_plain_kin_plot("pfJetGoodNumBtag30",Cut2Str(cutOSSF&&TCut("mll>20")),10,-0.5,9.5,dolog,"n_{btags}","NoPreselection/NBTags_SF",doPF,true);
2222 +    make_plain_kin_plot("pfJetGoodNumBtag30",Cut2Str(cutOSOF&&TCut("mll>20")),10,-0.5,9.5,dolog,"n_{btags}","NoPreselection/NBTags_OF",doPF,true);
2223 +    
2224 +    make_plain_kin_plot("pt1",Cut2Str(cutOSSF&&TCut("mll>20")),80,0,400,dolog,"p_{T}^{1}","NoPreselection/Pt1_SF",doPF,true);
2225 +    make_plain_kin_plot("pt1",Cut2Str(cutOSOF&&TCut("mll>20")),80,0,400,dolog,"p_{T}^{1}","NoPreselection/Pt1_OF",doPF,true);
2226      
2227 +    make_plain_kin_plot("pt2",Cut2Str(cutOSSF&&TCut("mll>20")),80,0,400,dolog,"p_{T}^{2}","NoPreselection/Pt2_SF",doPF,true);
2228 +    make_plain_kin_plot("pt2",Cut2Str(cutOSOF&&TCut("mll>20")),80,0,400,dolog,"p_{T}^{2}","NoPreselection/Pt2_OF",doPF,true);
2229 +    
2230 +    
2231 +    assert(0);
2232 +    make_plain_kin_plot("mll",Cut2Str(cutOSSF&&TCut("mll>60&&mll<120")),60,60,120,dolog,"m_{ll}","TestingLuminosity_SF",doPF,true);
2233 +    make_plain_kin_plot("mll",Cut2Str(cutOSOF&&TCut("mll>60&&mll<120")),60,60,120,dolog,"m_{ll}","TestingLuminosity_OF",doPF,true);
2234    
2235      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);
2236      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);
# Line 1597 | Line 2275 | void do_kinematic_plots(string mcjzb, st
2275      make_kin_plot("pfJetGoodPt[0]/pfJetGoodPt[1]","",45,1,10,dolog,"pt_{j}^{1}/pt_{j}^{2}","j1j2ratio",doPF,true);
2276      make_kin_plot("TMath::Abs(pfJetDphiMet[0])","",32,0,3.2,nolog,"|#Delta#phi(jet1,MET)|","dphiJ1MET",doPF,true);
2277      // Plots in signal region
2278 <    make_kin_plot("met[4]","",70,0,350,dolog,"MET [GeV]","met",doPF,true);
2278 >    make_kin_plot("met[4]","",70,0,350,dolog,"#slash{E}_{T} [GeV]","met",doPF,true);
2279  
2280  
2281      make_kin_plot("MetFactor","",20,0,2,nolog,"MetFactor","MetFactor",doPF,true);
2282      
2283      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");
2284 <    
2284 >    /*
2285      DoMCSystPlot("met[4]",40,0,400,(cutOSOF&&TCut("mll>30&&mll<70&&pfJetGoodNum40==0")),dolog,"PFMET","Debunking/MET_OF_30to70_0j");
2286      DoMCSystPlot("met[4]",40,0,400,(cutOSOF&&TCut("mll>30&&mll<70&&pfJetGoodNum40==1")),dolog,"PFMET","Debunking/MET_OF_30to70_1j");
2287      DoMCSystPlot("met[4]",40,0,400,(cutOSOF&&TCut("mll>30&&mll<70&&pfTightHT>100&&pfJetGoodNum40==2")),dolog,"PFMET","Debunking/MET_OF_30to70_2j");
2288      DoMCSystPlot("met[4]",40,0,400,(cutOSOF&&TCut("mll>30&&mll<70&&pfTightHT>100&&pfJetGoodNum40==3")),dolog,"PFMET","Debunking/MET_OF_30to70_3j");
2289  
2290 +    DoMCSystPlot("met[4]",40,0,400,(cutOSSF&&TCut("mll>30&&mll<70&&pfJetGoodNum40==0")),dolog,"PFMET","Debunking/MET_SF_30to70_0j");
2291 +    DoMCSystPlot("met[4]",40,0,400,(cutOSSF&&TCut("mll>30&&mll<70&&pfJetGoodNum40==1")),dolog,"PFMET","Debunking/MET_SF_30to70_1j");
2292 +    DoMCSystPlot("met[4]",40,0,400,(cutOSSF&&TCut("mll>30&&mll<70&&pfTightHT>100&&pfJetGoodNum40==2")),dolog,"PFMET","Debunking/MET_SF_30to70_2j");
2293 +    DoMCSystPlot("met[4]",40,0,400,(cutOSSF&&TCut("mll>30&&mll<70&&pfTightHT>100&&pfJetGoodNum40==3")),dolog,"PFMET","Debunking/MET_SF_30to70_3j");
2294 +
2295      DoMCSystPlot("met[4]",40,0,400,(cutOSOF&&TCut("mll>80&&mll<100&&pfJetGoodNum40==0")),dolog,"PFMET","Debunking/MET_OF_Z_0j");
2296      DoMCSystPlot("met[4]",40,0,400,(cutOSOF&&TCut("mll>80&&mll<100&&pfJetGoodNum40==1")),dolog,"PFMET","Debunking/MET_OF_Z_1j");
2297      DoMCSystPlot("met[4]",40,0,400,(cutOSOF&&TCut("mll>80&&mll<100&&pfTightHT>100&&pfJetGoodNum40==2")),dolog,"PFMET","Debunking/MET_OF_Z_2j");
# Line 1693 | Line 2376 | void do_kinematic_plots(string mcjzb, st
2376      
2377      //   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);
2378      //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);
2379 <    //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);
2379 >    //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);*/
2380    }
2381      
2382     make_special_obs_pred_mll_plot(datajzb,mcjzb,0);
# Line 1703 | Line 2386 | void do_kinematic_plots(string mcjzb, st
2386     make_special_obs_pred_mll_plot(datajzb,mcjzb,150);
2387     make_special_obs_pred_mll_plot(datajzb,mcjzb,200);
2388     make_special_obs_pred_mll_plot(datajzb,mcjzb,250);
2389 <
2389 > /*
2390     make_JES_plot(cutmass&&cutOSSF&&basiccut,"_ossf");
2391     make_JES_plot(cutmass&&cutOSOF&&basiccut,"_osof");
2392 <
2392 > */
2393    switch_overunderflow(false);
2394   }
2395  
# Line 1790 | Line 2473 | void region_comparison_plots(string mcjz
2473      make_comp_plot("TMath::Abs(pfJetDphiMet[0])","|#Delta#phi(jet1,MET)|","dphiJ1MET",jzbcut,mcjzb,datajzb,32,0,3.2,false,0,0,true);
2474  
2475      make_comp_plot("mll","m_{ll} [GeV]","mll",jzbcut,mcjzb,datajzb,56,mll_low,mll_high,false,0,16.);
2476 <    make_comp_plot("met[4]","pfMET [GeV]","pfmet",jzbcut,mcjzb,datajzb,18,0,360,false,0,16.);
2476 >    make_comp_plot("met[4]","E_{T}^{miss} [GeV]","pfmet",jzbcut,mcjzb,datajzb,18,0,360,false,0,16.);
2477      make_comp_plot("pfJetGoodNum40","#(jets)","njets",jzbcut,mcjzb,datajzb,10,0,10, false,0,35.);
2478      make_comp_plot("pfJetGoodNumBtag","#(b-jets)","nBjets",jzbcut,mcjzb,datajzb,10,0,10, false,0,35.);
2479      make_comp_plot("pt","Z p_{T} [GeV]","Zpt",jzbcut,mcjzb,datajzb,26,0,525,false,0.,21.);
# Line 1822 | Line 2505 | void signal_bg_comparison()
2505    
2506    float simulatedlumi=luminosity;//in pb please - adjust to your likings
2507    
2508 <  TH1F *JZBplotZJETs = allsamples.Draw("JZBplotZJETs",jzbvariablemc,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("/DY"));
2508 >  TH1F *JZBplotZJETs = allsamples.Draw("JZBplotZJETs",jzbvariablemc,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("DYJetsToLL"));
2509    TH1F *JZBplotLM4;
2510    if(PlottingSetup::RestrictToMassPeak) JZBplotLM4 = allsamples.Draw("JZBplotLM4",jzbvariablemc,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("LM4"));
2511    else JZBplotLM4 = allsamples.Draw("JZBplotLM4",jzbvariablemc,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("LM3"));
# Line 2542 | Line 3225 | void lepton_comparison_plots() {
3225    Float_t ymin = 1.e-5, ymax = 0.25;
3226    TCanvas *can = new TCanvas("can","Lepton Comparison Canvas");
3227    can->SetLogy(1);
3228 <  TH1F *eemc = allsamples.Draw("eemc","mll",50,50,150, "mll [GeV]", "events", cutOSSF&&cutnJets&&"(id1==0)",mc, luminosity,allsamples.FindSample("/DY"));
3229 <  TH1F *mmmc = allsamples.Draw("mmmc","mll",50,50,150, "mll [GeV]", "events", cutOSSF&&cutnJets&&"(id1==1)",mc, luminosity,allsamples.FindSample("/DY"));
3228 >  TH1F *eemc = allsamples.Draw("eemc","mll",50,50,150, "mll [GeV]", "events", cutOSSF&&cutnJets&&"(id1==0)",mc, luminosity,allsamples.FindSample("DYJetsToLL"));
3229 >  TH1F *mmmc = allsamples.Draw("mmmc","mll",50,50,150, "mll [GeV]", "events", cutOSSF&&cutnJets&&"(id1==1)",mc, luminosity,allsamples.FindSample("DYJetsToLL"));
3230    eemc->SetLineColor(kBlue);
3231    mmmc->SetLineColor(kRed);
3232    eemc->SetMinimum(0.1);
# Line 2608 | Line 3291 | void lepton_comparison_plots() {
3291    DrawPrelim();
3292    Save_With_Ratio(jeed,jmmd,eemmpad->cd(),"lepton_comparison/jzb_Comparing_ee_mm_data");
3293    
3294 <  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"));
3295 <  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"));
3296 <  TH1F *zjeemmd = allsamples.Draw("zjeemmd",jzbvariablemc,int((jzbHigh+150)/5),-150,jzbHigh , "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,            mc,  luminosity,allsamples.FindSample("/DY"));
3294 >  TH1F *zjeed = allsamples.Draw("zjeed",jzbvariablemc,    int((jzbHigh+150)/5),-150,jzbHigh , "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&"(id1==0)",mc,  luminosity,allsamples.FindSample("DYJetsToLL"));
3295 >  TH1F *zjmmd = allsamples.Draw("zjmmd",jzbvariablemc,    int((jzbHigh+150)/5),-150,jzbHigh , "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&"(id1==1)",mc,  luminosity,allsamples.FindSample("DYJetsToLL"));
3296 >  TH1F *zjeemmd = allsamples.Draw("zjeemmd",jzbvariablemc,int((jzbHigh+150)/5),-150,jzbHigh , "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,            mc,  luminosity,allsamples.FindSample("DYJetsToLL"));
3297    dout << "Z+Jets ee : " << zjeed->GetMean() << "+/-" << zjeed->GetMeanError() << endl;
3298    dout << "Z+Jets ee : " << zjmmd->GetMean() << "+/-" << zjmmd->GetMeanError() << endl;
3299    dout << "Z+Jets eemd : " << zjeemmd->GetMean() << "+/-" << zjeemmd->GetMeanError() << endl;
# Line 3348 | Line 4031 | void find_correction_factors(string &jzb
4031    
4032   }
4033  
4034 < void pick_up_events(string cut) {
4035 <  dout << "Picking up events with cut " << cut << endl;
3353 <  allsamples.PickUpEvents(cut);
4034 > void pick_up_events(string cut, string filename, bool QuietMode=false) {
4035 >  allsamples.PickUpEvents(cut,filename,QuietMode);
4036   }
4037  
4038   void save_template(string mcjzb, string datajzb,vector<float> jzb_cuts,float MCPeakError,float DataPeakError, vector<float> jzb_shape_limit_bins) {
# Line 3462 | Line 4144 | void ttbar_sidebands_comparison(string m
4144        
4145    float simulatedlumi = luminosity; //in pb please - adjust to your likings
4146  
4147 <  TH1F *TZem  = systsamples.Draw("TZem",     mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSOF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTT"));
4148 <  TH1F *nTZem = systsamples.Draw("nTZem","-"+mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSOF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTT"));
4147 >  TH1F *TZem  = allsamples.Draw("TZem",     mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSOF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("/TT"));
4148 >  TH1F *nTZem = allsamples.Draw("nTZem","-"+mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSOF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("/TT"));
4149    TH1F *TSem;
4150    TH1F *nTSem;
4151 <  TH1F *TZeemm  = systsamples.Draw("TZeemm",     mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTT"));
4152 <  TH1F *nTZeemm = systsamples.Draw("nTZeemm","-"+mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTT"));
4151 >  TH1F *TZeemm  = allsamples.Draw("TZeemm",     mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("/TT"));
4152 >  TH1F *nTZeemm = allsamples.Draw("nTZeemm","-"+mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("/TT"));
4153    TH1F *TSeemm;
4154    TH1F *nTSeemm;
4155    
4156    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
4157 <    TSem    = systsamples.Draw("TSem",       mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSOF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTT"));
4158 <    nTSem   = systsamples.Draw("nTSem",  "-"+mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSOF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTT"));
4159 <    TSeemm  = systsamples.Draw("TSeemm",     mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSSF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTT"));
4160 <    nTSeemm = systsamples.Draw("nTSeemm","-"+mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSSF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTT"));
4157 >    TSem    = allsamples.Draw("TSem",       mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSOF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("/TT"));
4158 >    nTSem   = allsamples.Draw("nTSem",  "-"+mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSOF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("/TT"));
4159 >    TSeemm  = allsamples.Draw("TSeemm",     mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSSF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("/TT"));
4160 >    nTSeemm = allsamples.Draw("nTSeemm","-"+mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSSF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("/TT"));
4161    }
4162  
4163    TCanvas *tcan = new TCanvas("tcan","tcan");
# Line 3763 | Line 4445 | void zjets_prediction_comparison(string
4445    }
4446  
4447    
4448 +  
4449    vector<float> binning;
4450    binning.push_back(0);
4451    binning.push_back(10);
# Line 3780 | Line 4463 | void zjets_prediction_comparison(string
4463    
4464    TCut kPos((mcjzb+">0").c_str());
4465    TCut kNeg((mcjzb+"<0").c_str());
4466 +  TCut reducedNJets(cutnJets);
4467    string var( "abs("+mcjzb+")" );
4468    
4469 +  
4470    TCut notTau("abs(genMID1)!=15");
4471    TCut ee_mm_tautau("mll>0");
4472    
4473  
4474 <  TH1F *hJZBpos = systsamples.Draw("hJZBpos",var,binning, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets&&notTau&&kPos&&massregioncut,mc,simulatedlumi,systsamples.FindSample("/DY"));
4475 <  TH1F *hJZBneg = systsamples.Draw("hJZBneg",var,binning, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets&&notTau&&kNeg&&massregioncut,mc,simulatedlumi,systsamples.FindSample("/DY"));
4474 >  TH1F *hJZBpos = allsamples.Draw("hJZBpos",var,binning, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets&&notTau&&kPos&&massregioncut,mc,simulatedlumi,allsamples.FindSample("DYJetsToLL"));
4475 >  TH1F *hJZBneg = allsamples.Draw("hJZBneg",var,binning, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets&&notTau&&kNeg&&massregioncut,mc,simulatedlumi,allsamples.FindSample("DYJetsToLL"));
4476    
4477    hJZBpos->SetLineColor(kBlack);
4478    hJZBneg->SetLineColor(kRed);
# Line 3808 | Line 4493 | void zjets_prediction_comparison(string
4493    hratio->Divide(hJZBneg);
4494    
4495    for(int i=1;i<=hJZBpos->GetNbinsX();i++) {
4496 <    cout << "Positive: " << hJZBpos->GetBinContent(i) << "   vs    Negative : " << hJZBneg->GetBinContent(i) << "   (ratio : " << hJZBpos->GetBinContent(i) / hJZBneg->GetBinContent(i) << endl;
4496 >    cout << "Positive: " << hJZBpos->GetBinContent(i) << "   vs    Negative : " << hJZBneg->GetBinContent(i) << "   (ratio : " << hJZBpos->GetBinContent(i) / hJZBneg->GetBinContent(i) << " +/- " << (hJZBpos->GetBinContent(i) / hJZBneg->GetBinContent(i)) * sqrt(1.0/hJZBpos->GetBinContent(i) +  1.0/hJZBneg->GetBinContent(i)) << ")" << endl;
4497    }
4498    
4499   //  zcan->SetLogy(0);
# Line 3816 | Line 4501 | void zjets_prediction_comparison(string
4501    hratio->GetYaxis()->SetTitle("Observed/Predicted");
4502    hratio->Draw("e1");
4503    
4504 <  TLine *top = new TLine(binning[0],1.25,binning[binning.size()-1],1.25);
4504 >  TLine *top = new TLine(binning[0],1.2,binning[binning.size()-1],1.2);
4505    TLine *center = new TLine(binning[0],1.0,binning[binning.size()-1],1.0);
4506 <  TLine *bottom = new TLine(binning[0],0.75,binning[binning.size()-1],0.75);
4506 >  TLine *bottom = new TLine(binning[0],0.8,binning[binning.size()-1],0.8);
4507    
4508  
4509    top->SetLineColor(kBlue);top->SetLineStyle(2);
# Line 3836 | Line 4521 | void zjets_prediction_comparison(string
4521    DrawMCPrelim(simulatedlumi);
4522    CompleteSave(zcan,"Systematics/ZJets/zjets_eemm_prediction_ratio"+any2string(massregionname));
4523    
3839  TCut reducedNJets(cutnJets);
4524    
4525 <  TH1F *TAUhJZBpos       = systsamples.Draw("TAUhJZBpos",var,binning, "JZB [GeV]", "events",cutmass&&cutOSSF&&reducedNJets&&ee_mm_tautau&&kPos&&massregioncut,mc,simulatedlumi,systsamples.FindSample("/DY"));
4526 <  TH1F *LcorrJZBeemm     = systsamples.Draw("LcorrJZBeemm",var,binning, "JZB [GeV]", "events",cutmass&&cutOSSF&&reducedNJets&&ee_mm_tautau&&kNeg&&massregioncut,mc,simulatedlumi,systsamples.FindSample("/DY"));
4527 <  TH1F *RcorrJZBem       = systsamples.Draw("RcorrJZBem",var,binning, "JZB [GeV]", "events",cutmass&&cutOSOF&&reducedNJets&&ee_mm_tautau&&kPos&&massregioncut,mc,simulatedlumi,systsamples.FindSample("/DY"));
4528 <  TH1F *LcorrJZBem       = systsamples.Draw("LcorrJZBem",var,binning, "JZB [GeV]", "events",cutmass&&cutOSOF&&reducedNJets&&ee_mm_tautau&&kNeg&&massregioncut,mc,simulatedlumi,systsamples.FindSample("/DY"));
4525 >  TH1F *TAUhJZBpos       = allsamples.Draw("TAUhJZBpos",var,binning, "JZB [GeV]", "events",cutmass&&cutOSSF&&reducedNJets&&ee_mm_tautau&&kPos&&massregioncut,mc,simulatedlumi,allsamples.FindSample("DYJetsToLL"));
4526 >  TH1F *LcorrJZBeemm     = allsamples.Draw("LcorrJZBeemm",var,binning, "JZB [GeV]", "events",cutmass&&cutOSSF&&reducedNJets&&ee_mm_tautau&&kNeg&&massregioncut,mc,simulatedlumi,allsamples.FindSample("DYJetsToLL"));
4527 >  TH1F *RcorrJZBem       = allsamples.Draw("RcorrJZBem",var,binning, "JZB [GeV]", "events",cutmass&&cutOSOF&&reducedNJets&&ee_mm_tautau&&kPos&&massregioncut,mc,simulatedlumi,allsamples.FindSample("DYJetsToLL"));
4528 >  TH1F *LcorrJZBem       = allsamples.Draw("LcorrJZBem",var,binning, "JZB [GeV]", "events",cutmass&&cutOSOF&&reducedNJets&&ee_mm_tautau&&kNeg&&massregioncut,mc,simulatedlumi,allsamples.FindSample("DYJetsToLL"));
4529  
4530    TH1F *RcorrJZBSBem;
4531    TH1F *LcorrJZBSBem;
# Line 3849 | Line 4533 | void zjets_prediction_comparison(string
4533    TH1F *LcorrJZBSBeemm;
4534  
4535    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
4536 <    RcorrJZBSBem   = systsamples.Draw("RcorrJZBSBem",var,binning, "JZB [GeV]", "events",sidebandcut&&cutOSOF&&reducedNJets&&ee_mm_tautau&&kPos&&massregioncut,mc,simulatedlumi,systsamples.FindSample("/DY"));
4537 <    LcorrJZBSBem   = systsamples.Draw("LcorrJZBSBem",var,binning, "JZB [GeV]", "events",sidebandcut&&cutOSOF&&reducedNJets&&ee_mm_tautau&&kNeg&&massregioncut,mc,simulatedlumi,systsamples.FindSample("/DY"));
4538 <    RcorrJZBSBeemm = systsamples.Draw("RcorrJZBSBeemm",var,binning, "JZB [GeV]", "events",sidebandcut&&cutOSSF&&reducedNJets&&ee_mm_tautau&&kPos&&massregioncut,mc,simulatedlumi,systsamples.FindSample("/DY"));
4539 <    LcorrJZBSBeemm = systsamples.Draw("LcorrJZBSBeemm",var,binning, "JZB [GeV]", "events",sidebandcut&&cutOSSF&&reducedNJets&&ee_mm_tautau&&kNeg&&massregioncut,mc,simulatedlumi,systsamples.FindSample("/DY"));
4536 >    RcorrJZBSBem   = allsamples.Draw("RcorrJZBSBem",var,binning, "JZB [GeV]", "events",sidebandcut&&cutOSOF&&reducedNJets&&ee_mm_tautau&&kPos&&massregioncut,mc,simulatedlumi,allsamples.FindSample("DYJetsToLL"));
4537 >    LcorrJZBSBem   = allsamples.Draw("LcorrJZBSBem",var,binning, "JZB [GeV]", "events",sidebandcut&&cutOSOF&&reducedNJets&&ee_mm_tautau&&kNeg&&massregioncut,mc,simulatedlumi,allsamples.FindSample("DYJetsToLL"));
4538 >    RcorrJZBSBeemm = allsamples.Draw("RcorrJZBSBeemm",var,binning, "JZB [GeV]", "events",sidebandcut&&cutOSSF&&reducedNJets&&ee_mm_tautau&&kPos&&massregioncut,mc,simulatedlumi,allsamples.FindSample("DYJetsToLL"));
4539 >    LcorrJZBSBeemm = allsamples.Draw("LcorrJZBSBeemm",var,binning, "JZB [GeV]", "events",sidebandcut&&cutOSSF&&reducedNJets&&ee_mm_tautau&&kNeg&&massregioncut,mc,simulatedlumi,allsamples.FindSample("DYJetsToLL"));
4540    }
4541    
4542    TH1F *Bpred = (TH1F*)LcorrJZBeemm->Clone("Bpred");
# Line 3923 | Line 4607 | void zjets_prediction_comparison(string
4607      delete LcorrJZBSBeemm;
4608    }
4609    
4610 +  //***************************************************************************************************
4611 +  
4612 +  string jzbvar=var;
4613 +  for(int i=0;i<60;i+=10) {
4614 +    stringstream sSpecialJZBCut;
4615 +    sSpecialJZBCut << jzbvar << ">" << i;
4616 +  TCut SpecialJZBCut(sSpecialJZBCut.str().c_str());
4617 +  
4618 +  var="mll";
4619 +  
4620 +  TH1F *FullJZBhJZBpos       = allsamples.Draw("FullJZBhJZBpos",var,10,0,200, "m_{ll} [GeV]", "events",cutmass&&cutOSSF&&reducedNJets&&notTau&&kPos&&massregioncut&&SpecialJZBCut,mc,simulatedlumi,allsamples.FindSample("DYJetsToLL"));
4621 +  TH1F *LcorrJZBPluseemm     = allsamples.Draw("LcorrJZBPluseemm",var,10,0,200, "m_{ll} [GeV]", "events",cutmass&&cutOSSF&&reducedNJets&&notTau&&kNeg&&massregioncut&&SpecialJZBCut,mc,simulatedlumi,allsamples.FindSample("DYJetsToLL"));
4622 +  TH1F *RcorrJZBPlusem       = allsamples.Draw("RcorrJZBPlusem",var,10,0,200, "m_{ll} [GeV]", "events",cutmass&&cutOSOF&&reducedNJets&&notTau&&kPos&&massregioncut&&SpecialJZBCut,mc,simulatedlumi,allsamples.FindSample("DYJetsToLL"));
4623 +  TH1F *LcorrJZBPlusem       = allsamples.Draw("LcorrJZBPlusem",var,10,0,200, "m_{ll} [GeV]", "events",cutmass&&cutOSOF&&reducedNJets&&notTau&&kNeg&&massregioncut&&SpecialJZBCut,mc,simulatedlumi,allsamples.FindSample("DYJetsToLL"));
4624 +
4625 +  TH1F *RcorrJZBPlusSBem;
4626 +  TH1F *LcorrJZBPlusSBem;
4627 +  TH1F *RcorrJZBPlusSBeemm;
4628 +  TH1F *LcorrJZBPlusSBeemm;
4629 +
4630 +  
4631 +  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
4632 +    RcorrJZBPlusSBem   = allsamples.Draw("RcorrJZBPlusSBem",var,10,0,200, "m_{ll} [GeV]", "events",sidebandcut&&cutOSOF&&reducedNJets&&notTau&&kPos&&massregioncut&&SpecialJZBCut,mc,simulatedlumi,allsamples.FindSample("DYJetsToLL"));
4633 +    LcorrJZBPlusSBem   = allsamples.Draw("LcorrJZBPlusSBem",var,10,0,200, "m_{ll} [GeV]", "events",sidebandcut&&cutOSOF&&reducedNJets&&notTau&&kNeg&&massregioncut&&SpecialJZBCut,mc,simulatedlumi,allsamples.FindSample("DYJetsToLL"));
4634 +    RcorrJZBPlusSBeemm = allsamples.Draw("RcorrJZBPlusSBeemm",var,10,0,200, "m_{ll} [GeV]", "events",sidebandcut&&cutOSSF&&reducedNJets&&notTau&&kPos&&massregioncut&&SpecialJZBCut,mc,simulatedlumi,allsamples.FindSample("DYJetsToLL"));
4635 +    LcorrJZBPlusSBeemm = allsamples.Draw("LcorrJZBPlusSBeemm",var,10,0,200, "m_{ll} [GeV]", "events",sidebandcut&&cutOSSF&&reducedNJets&&notTau&&kNeg&&massregioncut&&SpecialJZBCut,mc,simulatedlumi,allsamples.FindSample("DYJetsToLL"));
4636 +  }
4637 +  
4638 +  TH1F *BpredPrime = (TH1F*)LcorrJZBPluseemm->Clone("BpredPrime");
4639 +  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
4640 +    BpredPrime->Add(RcorrJZBPlusem,1.0/3.);
4641 +    BpredPrime->Add(LcorrJZBPlusem,-1.0/3.);
4642 +    BpredPrime->Add(RcorrJZBPlusSBem,1.0/3.);
4643 +    BpredPrime->Add(LcorrJZBPlusSBem,-1.0/3.);
4644 +    BpredPrime->Add(RcorrJZBPlusSBeemm,1.0/3.);
4645 +    BpredPrime->Add(LcorrJZBPlusSBeemm,-1.0/3.);
4646 +  } else {
4647 +    BpredPrime->Add(RcorrJZBPlusem,1.0);
4648 +    BpredPrime->Add(LcorrJZBPlusem,-1.0);
4649 +  }
4650 +  
4651 +  BpredPrime->SetLineColor(kRed);
4652 +
4653 +  FullJZBhJZBpos->SetLineColor(kBlack);
4654 +  BpredPrime->SetLineColor(kRed);
4655 +  
4656 +  FullJZBhJZBpos->SetMinimum(1.0);
4657 +  FullJZBhJZBpos->Draw("e1");
4658 +  BpredPrime->Draw("same,hist");
4659 +  FullJZBhJZBpos->Draw("same,e1");
4660 +  
4661 +  TLegend *FullJZBleg = make_legend("MC Z+jets #rightarrow ee,#mu#mu",0.55,0.75,false);
4662 +  FullJZBleg->AddEntry(FullJZBhJZBpos,"Observed","pe");
4663 +  FullJZBleg->AddEntry(BpredPrime,"Predicted","l");
4664 +  FullJZBleg->Draw("same");
4665 +  DrawMCPrelim(simulatedlumi);
4666 +  CompleteSave(zcan,"Systematics/ZJets/Mll_Distribution_JZB"+any2string(i)+"_zjets_eemumu_prediction__"+any2string(massregionname));
4667 +  
4668 +  TH1F* FullJZBhratio = (TH1F*)FullJZBhJZBpos->Clone("FullJZBhratio");
4669 +  FullJZBhratio->Divide(BpredPrime);
4670 +  
4671 +  zcan->SetLogy(0);
4672 +  FullJZBhratio->GetYaxis()->SetRangeUser(0,2.5);
4673 +  FullJZBhratio->GetYaxis()->SetTitle("Observed/Predicted");
4674 +  FullJZBhratio->Draw("e1");
4675 +  
4676 +  TLine *atop = new TLine(0,1.2,200,1.2);
4677 +  TLine *acenter = new TLine(0,1.0,200,1.0);
4678 +  TLine *abottom = new TLine(0,0.8,200,0.8);
4679 +  
4680 +  atop->SetLineColor(kBlue);
4681 +  atop->SetLineStyle(2);
4682 +  acenter->SetLineColor(kBlue);
4683 +  abottom->SetLineColor(kBlue);
4684 +  abottom->SetLineStyle(2);
4685 +  
4686 +  atop->Draw("same");
4687 +  acenter->Draw("same");
4688 +  abottom->Draw("same");
4689 +  
4690 +  TLegend *FullJZBleg2 = make_legend("MC Z+jets #rightarrow ee,#mu#mu",0.25,0.75,false);
4691 +  FullJZBleg2->AddEntry(FullJZBhratio,"obs / pred","pe");
4692 +  FullJZBleg2->AddEntry(abottom,"syst. envelope","l");
4693 +  FullJZBleg2->Draw("same");
4694 +  DrawMCPrelim(simulatedlumi);
4695 +  CompleteSave(zcan,"Systematics/ZJets/Mll_Distribution_JZB"+any2string(i)+"zjets_eemumu_prediction_ratio"+any2string(massregionname));
4696 +  
4697 +  
4698 +  delete BpredPrime;
4699 +  delete FullJZBhJZBpos;
4700 +  delete LcorrJZBPluseemm;
4701 +  delete RcorrJZBPlusem;
4702 +  delete LcorrJZBPlusem;
4703 + //  delete FullJZBhJZBpos;
4704 +  
4705 +  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
4706 +    delete RcorrJZBPlusSBem;
4707 +    delete LcorrJZBPlusSBem;
4708 +    delete RcorrJZBPlusSBeemm;
4709 +    delete LcorrJZBPlusSBeemm;
4710 +  }
4711 +  
4712 +  }
4713 +  //***************************************************************************************************
4714    
4715    delete zcan;
4716    cutWeight=weightbackup;
# Line 3930 | Line 4718 | void zjets_prediction_comparison(string
4718  
4719  
4720   void zjets_prediction_comparison(string mcjzbWithPUa) {
4721 <  zjets_prediction_comparison(mcjzbWithPUa, TCut(""), "nomasscut");
4722 <  zjets_prediction_comparison(mcjzbWithPUa, TCut("abs(mll-91)<20"), "Zwindow_20");
4721 >  zjets_prediction_comparison(mcjzbWithPUa, TCut("mll>20"), "nomasscut");
4722 >  zjets_prediction_comparison(mcjzbWithPUa, TCut("abs(mll-91)<10"), "Zwindow_10");
4723 >  zjets_prediction_comparison(mcjzbWithPUa, TCut("abs(mll-91)>10&&mll>20"), "Outside_Zwindow_10");
4724    zjets_prediction_comparison(mcjzbWithPUa, TCut("mll>20&&mll<70"), "LowMassRegion2070");
4725    zjets_prediction_comparison(mcjzbWithPUa, TCut("mll>110"), "HighMassRegion110");
4726   }
# Line 4487 | Line 5276 | void met_vs_jzb_plots(string datajzb, st
5276    sRIGHT << "((" << mcjzb << ")>0)";
5277    TCut RIGHT(sRIGHT.str().c_str());
5278    
5279 <  TH1F *metleft   = allsamples.Draw("metleft","met[4]",nbins,low,high, "MET [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&LEFT,mc, luminosity, allsamples.FindSample("DYJets"));
5280 <  TH1F *metleftO  = allsamples.Draw("metleftO","met[4]",nbins,low,high, "MET [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&LEFT,mc, luminosity, allsamples.FindSample("DYJets"));
5281 <  TH1F *metright  = allsamples.Draw("metright","met[4]",nbins,low,high, "MET [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&RIGHT,mc, luminosity, allsamples.FindSample("DYJets"));
5282 <  TH1F *metrightO = allsamples.Draw("metrightO","met[4]",nbins,low,high, "MET [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&RIGHT,mc, luminosity, allsamples.FindSample("DYJets"));
5279 >  TH1F *metleft   = allsamples.Draw("metleft","met[4]",nbins,low,high, "#slash{E}_{T} [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&LEFT,mc, luminosity, allsamples.FindSample("DYJets"));
5280 >  TH1F *metleftO  = allsamples.Draw("metleftO","met[4]",nbins,low,high, "#slash{E}_{T} [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&LEFT,mc, luminosity, allsamples.FindSample("DYJets"));
5281 >  TH1F *metright  = allsamples.Draw("metright","met[4]",nbins,low,high, "#slash{E}_{T} [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&RIGHT,mc, luminosity, allsamples.FindSample("DYJets"));
5282 >  TH1F *metrightO = allsamples.Draw("metrightO","met[4]",nbins,low,high, "#slash{E}_{T} [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&RIGHT,mc, luminosity, allsamples.FindSample("DYJets"));
5283    
5284    
5285    TH1F *Bpred =  (TH1F*)metleft->Clone("Bpred");
# Line 4540 | Line 5329 | void met_vs_jzb_plots(string datajzb, st
5329    metpad2->cd();
5330    metpad2->SetLogy(1);
5331    
5332 <  TH1F *metlefta   = allsamples.Draw("metlefta","met[2]",nbins,low,high, "MET [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&LEFT,mc, luminosity, allsamples.FindSample("DYJets"));
5333 <  TH1F *metleftOa  = allsamples.Draw("metleftOa","met[2]",nbins,low,high, "MET [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&LEFT,mc, luminosity, allsamples.FindSample("DYJets"));
5334 <  TH1F *metrighta  = allsamples.Draw("metrighta","met[2]",nbins,low,high, "MET [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&RIGHT,mc, luminosity, allsamples.FindSample("DYJets"));
5335 <  TH1F *metrightOa = allsamples.Draw("metrightOa","met[2]",nbins,low,high, "MET [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&RIGHT,mc, luminosity, allsamples.FindSample("DYJets"));
5332 >  TH1F *metlefta   = allsamples.Draw("metlefta","met[2]",nbins,low,high, "#slash{E}_{T} [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&LEFT,mc, luminosity, allsamples.FindSample("DYJets"));
5333 >  TH1F *metleftOa  = allsamples.Draw("metleftOa","met[2]",nbins,low,high, "#slash{E}_{T} [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&LEFT,mc, luminosity, allsamples.FindSample("DYJets"));
5334 >  TH1F *metrighta  = allsamples.Draw("metrighta","met[2]",nbins,low,high, "#slash{E}_{T} [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&RIGHT,mc, luminosity, allsamples.FindSample("DYJets"));
5335 >  TH1F *metrightOa = allsamples.Draw("metrightOa","met[2]",nbins,low,high, "#slash{E}_{T} [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&RIGHT,mc, luminosity, allsamples.FindSample("DYJets"));
5336    
5337    metlefta->Add(metleftOa,-1);
5338    metrighta->Add(metrightOa,-1);
# Line 4562 | Line 5351 | void met_vs_jzb_plots(string datajzb, st
5351    int newNBins=30;
5352    
5353    TPad *metpad4 = new TPad("metpad4","metpad4",0,0,1,1);
5354 <  TH1F *Ametleft   = allsamples.Draw("Ametleft","met[4]",newNBins,low,newhigh, "MET [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&LEFT,mc, luminosity);
5355 <  TH1F *AmetleftO  = allsamples.Draw("AmetleftO","met[4]",newNBins,low,newhigh, "MET [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&LEFT,mc, luminosity);
5356 <  TH1F *Ametright  = allsamples.Draw("Ametright","met[4]",newNBins,low,newhigh, "MET [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&RIGHT,mc, luminosity);
5357 <  TH1F *AmetrightO = allsamples.Draw("AmetrightO","met[4]",newNBins,low,newhigh, "MET [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&RIGHT,mc, luminosity);
5354 >  TH1F *Ametleft   = allsamples.Draw("Ametleft","met[4]",newNBins,low,newhigh, "#slash{E}_{T} [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&LEFT,mc, luminosity);
5355 >  TH1F *AmetleftO  = allsamples.Draw("AmetleftO","met[4]",newNBins,low,newhigh, "#slash{E}_{T} [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&LEFT,mc, luminosity);
5356 >  TH1F *Ametright  = allsamples.Draw("Ametright","met[4]",newNBins,low,newhigh, "#slash{E}_{T} [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&RIGHT,mc, luminosity);
5357 >  TH1F *AmetrightO = allsamples.Draw("AmetrightO","met[4]",newNBins,low,newhigh, "#slash{E}_{T} [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&RIGHT,mc, luminosity);
5358    
5359    TH1F *aBpred = (TH1F*)Ametleft->Clone("aBpred");
5360    aBpred->Add(AmetleftO,-1);
# Line 4590 | Line 5379 | void met_vs_jzb_plots(string datajzb, st
5379    delete metright;
5380    delete metrightO;
5381   }
5382 +
5383 +
5384 + void do_one_ttbar_test(TH1F* &observed, TH1F* &predicted, TH1F* &ratio, TH1F* &ratio2, string mcjzb, string prestring) {
5385 +  
5386 +  if(PlottingSetup::RestrictToMassPeak) {
5387 +    write_error(__FUNCTION__,"This function (ttbar_tests) was not written for on-peak studies - sorry.");
5388 +    assert(!PlottingSetup::RestrictToMassPeak);
5389 +  }
5390 +  
5391 +  vector<float> binning;
5392 +  
5393 +  binning.push_back(-200);
5394 +  binning.push_back(-150);
5395 +  binning.push_back(-125);
5396 +  binning.push_back(-100);
5397 +  binning.push_back(-75);
5398 +  binning.push_back(-50);
5399 +  binning.push_back(-25);
5400 +  binning.push_back(0);
5401 +  binning.push_back(25);
5402 +  binning.push_back(50);
5403 +  binning.push_back(75);
5404 +  binning.push_back(100);
5405 +  binning.push_back(125);
5406 +  binning.push_back(150);
5407 +  binning.push_back(200);
5408 +  
5409 +  switch_overunderflow(true);
5410 +  
5411 +  TH1F *TZem  = allsamples.Draw("TZem",     mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSOF&&cutnJets,mc,luminosity,allsamples.FindSample("/TT"));
5412 +  TH1F *nTZem = allsamples.Draw("nTZem","-"+mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSOF&&cutnJets,mc,luminosity,allsamples.FindSample("/TT"));
5413 +  TH1F *TZeemm  = allsamples.Draw("TZeemm",     mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSSF&&cutnJets,mc,luminosity,allsamples.FindSample("/TT"));
5414 +  TH1F *nTZeemm = allsamples.Draw("nTZeemm","-"+mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSSF&&cutnJets,mc,luminosity,allsamples.FindSample("/TT"));
5415 +  
5416 +  TCanvas *tcan = new TCanvas("tcan","tcan");
5417 +  tcan->SetLogy(1);
5418 +  
5419 +  TZeemm->SetLineColor(kBlack);
5420 +  TZem->SetLineColor(kRed);
5421 +  TZeemm->SetMarkerColor(kBlack);
5422 +  TZem->SetMarkerColor(kRed);
5423 +  
5424 +  vector<TH1F*> histos;
5425 + //  TZem->GetXaxis()->SetRangeUser(-100,binning[binning.size()-1]);
5426 + //  TZeemm->GetXaxis()->SetRangeUser(-100,binning[binning.size()-1]);
5427 +  histos.push_back(TZem);
5428 +  histos.push_back(TZeemm);
5429 +  draw_all_ttbar_histos(tcan,histos,"histo",8);
5430 +  
5431 +  TLegend *leg = make_legend("MC t#bar{t}",0.6,0.65,false);
5432 +  leg->AddEntry(TZeemm,"SFZP","l");
5433 +  leg->AddEntry(TZem,"OFZP","l");
5434 +  leg->Draw("same");
5435 +  DrawMCPrelim();
5436 +  CompleteSave(tcan,"Systematics/TtbarTests/"+prestring+"/ttbar_shape_comparison");
5437 +  
5438 +  TH1F *TZemcopy = (TH1F*)TZem->Clone("TZemcopy");
5439 +  TH1F *TZeemmcopy = (TH1F*)TZeemm->Clone("TZeemmcopy");
5440 +  TH1F *TSeemmcopy;
5441 +  TH1F *TSemcopy;
5442 +  
5443 +  predicted=(TH1F*)TZem->Clone(((string)"predicted_"+prestring).c_str());
5444 +  observed=(TH1F*)TZeemm->Clone(((string)"observed_"+prestring).c_str());
5445 +  
5446 +  vector<float> posbinning;
5447 +  for(unsigned int i=0;i<binning.size();i++) {
5448 +    if(binning[i]<0) continue;
5449 +    posbinning.push_back(binning[i]);
5450 +  }
5451 +  
5452 +  TH1F *pred2 = new TH1F("pred2","pred2",posbinning.size()-1,&posbinning[0]);pred2->Sumw2();
5453 +  TH1F *obs2 = new TH1F("obs2","obs2",posbinning.size()-1,&posbinning[0]);obs2->Sumw2();
5454 +  
5455 +  for(unsigned int i=1;i<=predicted->GetNbinsX();i++) {
5456 +    int index=pred2->FindBin(abs(TZem->GetBinCenter(i)));
5457 +    if(TZem->GetBinCenter(i)<0) {
5458 +      //we're on the left: subtract em!
5459 +      pred2->SetBinContent(index,pred2->GetBinContent(index)-TZem->GetBinContent(i));
5460 +      pred2->SetBinError(index,sqrt(pow(pred2->GetBinError(index),2)+pow(TZem->GetBinError(i),2)));
5461 +      //we're on the left: add eemm!
5462 +      pred2->SetBinContent(index,pred2->GetBinContent(index)+TZeemm->GetBinContent(i));
5463 +      pred2->SetBinError(index,sqrt(pow(pred2->GetBinError(index),2)+pow(TZeemm->GetBinError(i),2)));
5464 +    } else {
5465 +      //we're on the right: add em!
5466 +      pred2->SetBinContent(index,pred2->GetBinContent(index)+TZem->GetBinContent(i));
5467 +      pred2->SetBinError(index,sqrt(pow(pred2->GetBinError(index),2)+pow(TZem->GetBinError(i),2)));
5468 +      //we're on the left: add eemm!
5469 +      obs2->SetBinContent(index,obs2->GetBinContent(index)+TZeemm->GetBinContent(i));
5470 +      obs2->SetBinError(index,sqrt(pow(pred2->GetBinError(index),2)+pow(TZeemm->GetBinError(i),2)));
5471 +    }
5472 +  }
5473 +  
5474 +  ratio2 = (TH1F*)pred2->Clone(((string)"ratio2_"+prestring).c_str());
5475 +  ratio2->Divide(obs2);
5476 +
5477 +  TZem->Divide(TZeemm);
5478 +  TZem->SetMarkerStyle(21);
5479 +
5480 +  TZem->SetTitle("OF / SF");
5481 +  ratio = (TH1F*)TZem->Clone(((string)"ratio_"+prestring).c_str());
5482 +  
5483 +  tcan->SetLogy(0);
5484 +  TZem->GetYaxis()->SetRangeUser(0,2.5);
5485 +  TZem->GetYaxis()->SetTitle("ratio");
5486 +  TZem->Draw();
5487 +  
5488 +  float linepos=emuncertOFFPEAK;
5489 +  
5490 +  TLine *top = new TLine(binning[0],1.0+linepos,binning[binning.size()-1],1.0+linepos);
5491 +  TLine *center = new TLine(binning[0],1.0,binning[binning.size()-1],1.0);
5492 +  TLine *bottom = new TLine(binning[0],1.0-linepos,binning[binning.size()-1],1.0-linepos);
5493 +  
5494 +  top->SetLineColor(kBlue);top->SetLineStyle(2);
5495 +  bottom->SetLineColor(kBlue);bottom->SetLineStyle(2);
5496 +  center->SetLineColor(kBlue);
5497 +  
5498 +  top->Draw("same");
5499 +  center->Draw("same");
5500 +  bottom->Draw("same");
5501 +  
5502 +  TLegend *leg2 = make_legend("MC t#bar{t}",0.55,0.75,false);
5503 +  leg2->AddEntry(TZem,"OFZP / SFZP","ple");
5504 +  leg2->AddEntry(bottom,"syst. envelope","l");
5505 +  leg2->SetX1(0.25);leg2->SetX2(0.6);
5506 +  leg2->SetY1(0.65);
5507 +  
5508 +  leg2->Draw("same");
5509 +  
5510 +  DrawMCPrelim();
5511 +  CompleteSave(tcan,"Systematics/TtbarTests/"+prestring+"/ttbar_shape_comparison_ratio");
5512 +  
5513 +  ratio2->SetLineColor(TZem->GetLineColor());
5514 +  ratio2->SetMarkerColor(TZem->GetMarkerColor());
5515 +  ratio2->GetYaxis()->SetRangeUser(0,2.5);
5516 +  ratio2->GetYaxis()->SetTitle("ratio");
5517 +  ratio2->Draw();
5518 +  
5519 +  TLine *top2 = new TLine(0,1.0+linepos,binning[binning.size()-1],1.0+linepos);
5520 +  TLine *center2 = new TLine(0,1.0,binning[binning.size()-1],1.0);
5521 +  TLine *bottom2 = new TLine(0,1.0-linepos,binning[binning.size()-1],1.0-linepos);
5522 +  
5523 +  top2->SetLineColor(kBlue);top->SetLineStyle(2);
5524 +  bottom2->SetLineColor(kBlue);bottom->SetLineStyle(2);
5525 +  center2->SetLineColor(kBlue);
5526 +  
5527 +  top2->Draw("same");
5528 +  center2->Draw("same");
5529 +  bottom2->Draw("same");
5530 +  
5531 +  leg2->Draw("same");
5532 +  
5533 +  DrawMCPrelim();
5534 +  CompleteSave(tcan,"Systematics/TtbarTests/"+prestring+"/ttbar_shape_comparison_FINALratio");
5535 +  
5536 +  delete TZem;
5537 +  delete nTZem;
5538 +  delete TZeemm;
5539 +  delete nTZeemm;
5540 +  delete obs2;
5541 +  delete pred2;
5542 +  delete tcan;
5543 +  switch_overunderflow(false);
5544 + }
5545 +
5546 + void IllustrateVariation(TH1F *vanilla_ratio, TH1F *response_only_up_ratio, TH1F *response_only_down_ratio, TH1F *reponse_plus_peak_up_ratio, TH1F *reponse_plus_peak_down_ratio, string PostString) {
5547      
5548 +  
5549 +  TCanvas *ttcan2 = new TCanvas("ttcan2","ttcan2");
5550 +  vanilla_ratio->GetYaxis()->SetRangeUser(0.6,1.4);
5551 +  vanilla_ratio->SetFillColor(kGreen);
5552 +  vanilla_ratio->SetLineColor(kGreen);
5553 +  vanilla_ratio->SetMarkerColor(kGreen);
5554 +  vanilla_ratio->SetFillStyle(3001);
5555 +  vanilla_ratio->Draw("e3");
5556 +  
5557 +  response_only_up_ratio->SetFillColor(kRed);
5558 +  response_only_up_ratio->SetMarkerColor(kRed);
5559 +  response_only_up_ratio->SetLineColor(kRed);
5560 +  response_only_up_ratio->SetFillStyle(3003);
5561 +  response_only_up_ratio->Draw("e3,same");
5562 +  
5563 +  response_only_down_ratio->SetFillColor(kOrange);
5564 +  response_only_down_ratio->SetMarkerColor(kOrange);
5565 +  response_only_down_ratio->SetLineColor(kOrange);
5566 +  response_only_down_ratio->SetFillStyle(3004);
5567 +  response_only_down_ratio->Draw("e3,same");
5568 +  
5569 +  reponse_plus_peak_up_ratio->SetFillColor(TColor::GetColor("#BDBDBD"));
5570 +  reponse_plus_peak_up_ratio->SetMarkerColor(TColor::GetColor("#BDBDBD"));
5571 +  reponse_plus_peak_up_ratio->SetLineColor(TColor::GetColor("#BDBDBD"));
5572 +  reponse_plus_peak_up_ratio->SetFillStyle(3005);
5573 +  reponse_plus_peak_up_ratio->Draw("e3,same");
5574 +  
5575 +  reponse_plus_peak_down_ratio->SetFillColor(kBlue);
5576 +  reponse_plus_peak_down_ratio->SetMarkerColor(kBlue);
5577 +  reponse_plus_peak_down_ratio->SetLineColor(kBlue);
5578 +  reponse_plus_peak_down_ratio->SetFillStyle(3006);
5579 +  reponse_plus_peak_down_ratio->Draw("e3,same");
5580 +  
5581 +  TLine *llow = new TLine(vanilla_ratio->GetBinLowEdge(1),1.0-emuncertOFFPEAK,vanilla_ratio->GetBinLowEdge(vanilla_ratio->GetNbinsX())+vanilla_ratio->GetBinWidth(vanilla_ratio->GetNbinsX()),1.0-emuncertOFFPEAK);
5582 +  TLine *lhi = new TLine(vanilla_ratio->GetBinLowEdge(1),1.0+emuncertOFFPEAK,vanilla_ratio->GetBinLowEdge(vanilla_ratio->GetNbinsX())+vanilla_ratio->GetBinWidth(vanilla_ratio->GetNbinsX()),1.0+emuncertOFFPEAK);
5583 +  TLine *lOne = new TLine(vanilla_ratio->GetBinLowEdge(1),1.0,vanilla_ratio->GetBinLowEdge(vanilla_ratio->GetNbinsX())+vanilla_ratio->GetBinWidth(vanilla_ratio->GetNbinsX()),1.0);
5584 +  
5585 +  TLine *llowA = new TLine(vanilla_ratio->GetBinLowEdge(1),1.0-0.07,vanilla_ratio->GetBinLowEdge(vanilla_ratio->GetNbinsX())+vanilla_ratio->GetBinWidth(vanilla_ratio->GetNbinsX()),1.0-0.07);
5586 +  TLine *lhiA = new TLine(vanilla_ratio->GetBinLowEdge(1),1.0+0.07,vanilla_ratio->GetBinLowEdge(vanilla_ratio->GetNbinsX())+vanilla_ratio->GetBinWidth(vanilla_ratio->GetNbinsX()),1.0+0.07);
5587 +  
5588 +  lhiA->SetLineColor(kRed);
5589 +  lhiA->SetLineStyle(2);
5590 +  llowA->SetLineColor(kRed);
5591 +  llowA->SetLineStyle(2);
5592 +  
5593 +  llow->SetLineColor(kBlue);
5594 +  llow->SetLineStyle(2);
5595 +  lhi->SetLineColor(kBlue);
5596 +  lhi->SetLineStyle(2);
5597 +  lOne->SetLineColor(kBlue);
5598 +  
5599 +  llow->Draw();
5600 +  lhi->Draw();
5601 +  lOne->Draw();
5602 +  
5603 +  llowA->Draw();
5604 +  lhiA->Draw();
5605 +  
5606 +  TLegend *leg = make_legend();
5607 +  leg->SetX1(0.15);
5608 +  leg->SetY1(0.7);
5609 +  leg->AddEntry(vanilla_ratio,"Raw JZB","pf");
5610 +  leg->AddEntry(response_only_up_ratio,"With response correction","pf");
5611 +  leg->AddEntry(response_only_down_ratio,"With inverted response correction","pf");
5612 +  leg->AddEntry(reponse_plus_peak_up_ratio,"With response and peak correction","pf");
5613 +  leg->AddEntry(reponse_plus_peak_down_ratio,"With response and inverted peak corr.","pf");
5614 +  leg->AddEntry(lhi,"Systematic envelope","l");
5615 + //  leg->SetNColumns(2);
5616 +  leg->Draw();
5617 +  
5618 +  CompleteSave(ttcan2,"Systematics/TtbarTests/Comparison"+PostString);
5619 +  
5620 +  vanilla_ratio->GetYaxis()->SetRangeUser(0.6,1.4);
5621 +  vanilla_ratio->Draw("e3");
5622 +  response_only_up_ratio->Draw("e3 same");
5623 +  response_only_down_ratio->Draw("e3 same");
5624 +  TLegend *leg2 = make_legend();
5625 +  leg2->SetX1(0.15);
5626 +  leg2->SetY1(0.7);
5627 +  leg2->AddEntry(vanilla_ratio,"Raw JZB","pf");
5628 +  leg2->AddEntry(response_only_up_ratio,"With response correction","pf");
5629 +  leg2->AddEntry(response_only_down_ratio,"With inverted response correction","pf");
5630 +  leg2->AddEntry(lhi,"Systematic envelope","l");
5631 +  leg2->Draw();
5632 +  llow->Draw();
5633 +  lOne->Draw();
5634 +  llowA->Draw();
5635 +  lhiA->Draw();
5636 +  
5637 +  CompleteSave(ttcan2,"Systematics/TtbarTests/Comparison_Response"+PostString);
5638 +  
5639 +  response_only_up_ratio->GetYaxis()->SetRangeUser(0.6,1.4);
5640 +  response_only_up_ratio->Draw("e3");
5641 +  reponse_plus_peak_up_ratio->Draw("e3 same");
5642 +  reponse_plus_peak_down_ratio->Draw("e3 same");
5643 +  TLegend *leg3 = make_legend();
5644 +  leg3->SetX1(0.15);
5645 +  leg3->SetY1(0.7);
5646 +  leg3->AddEntry(response_only_up_ratio,"With response correction","pf");
5647 +  leg3->AddEntry(reponse_plus_peak_up_ratio,"With response and peak correction","pf");
5648 +  leg3->AddEntry(reponse_plus_peak_down_ratio,"With response and inverted peak corr.","pf");
5649 +  leg3->AddEntry(lhi,"Systematic envelope","l");
5650 +  leg3->Draw();
5651 +  llow->Draw();
5652 +  lOne->Draw();
5653 +  llowA->Draw();
5654 +  lhiA->Draw();
5655 +  
5656 +  CompleteSave(ttcan2,"Systematics/TtbarTests/Comparison_Peak"+PostString);
5657 +  
5658 +  delete ttcan2;
5659 + }
5660 +
5661 + void ttbar_correction_tests() {
5662 +  TCanvas *ttcan = new TCanvas("ttcan","ttcan");
5663 +    
5664 +  TH1F *vanilla_observed, *response_only_up_observed, *response_only_down_observed, *reponse_plus_peak_up_observed, *reponse_plus_peak_down_observed;
5665 +  
5666 +  TH1F *vanilla_predicted, *response_only_up_predicted, *response_only_down_predicted, *reponse_plus_peak_up_predicted, *reponse_plus_peak_down_predicted;
5667 +  
5668 +  TH1F *vanilla_ratio, *response_only_up_ratio, *response_only_down_ratio, *reponse_plus_peak_up_ratio, *reponse_plus_peak_down_ratio;
5669 +  
5670 +  TH1F *vanilla_ratio2, *response_only_up_ratio2, *response_only_down_ratio2, *reponse_plus_peak_up_ratio2, *reponse_plus_peak_down_ratio2;
5671 +  
5672 +  string vanilla="jzb[1]";
5673 +  string response_only_up="((jzb[1]+0.034665*pt))";
5674 +  string response_only_down="((jzb[1]-0.034665*pt))";
5675 +  string reponse_plus_peak_up="((jzb[1]+0.034665*pt)- 3.58273 )";
5676 +  string reponse_plus_peak_down="((jzb[1]+0.034665*pt)+ 3.58273 )";
5677 +
5678 +  do_one_ttbar_test(vanilla_observed,vanilla_predicted,vanilla_ratio,vanilla_ratio2,vanilla,"vanilla");
5679 +  do_one_ttbar_test(response_only_up_observed,response_only_up_predicted,response_only_up_ratio,response_only_up_ratio2,response_only_up,"response_only_up");
5680 +  do_one_ttbar_test(response_only_down_observed,response_only_down_predicted,response_only_down_ratio,response_only_down_ratio2,response_only_down,"response_only_down");
5681 +  do_one_ttbar_test(reponse_plus_peak_up_observed,reponse_plus_peak_up_predicted,reponse_plus_peak_up_ratio,reponse_plus_peak_up_ratio2,reponse_plus_peak_up,"reponse_plus_peak_up");
5682 +  do_one_ttbar_test(reponse_plus_peak_down_observed,reponse_plus_peak_down_predicted,reponse_plus_peak_down_ratio,reponse_plus_peak_down_ratio2,reponse_plus_peak_down,"reponse_plus_peak_down");
5683 +  
5684 +  ttcan->cd();
5685 +  
5686 +  IllustrateVariation(vanilla_ratio,response_only_up_ratio,response_only_down_ratio,reponse_plus_peak_up_ratio,reponse_plus_peak_down_ratio,"PartialRatio");
5687 +  IllustrateVariation(vanilla_ratio2,response_only_up_ratio2,response_only_down_ratio2,reponse_plus_peak_up_ratio2,reponse_plus_peak_down_ratio2,"FullRatio");
5688 +  
5689 +  delete vanilla_observed;
5690 +  delete response_only_up_observed;
5691 +  delete response_only_down_observed;
5692 +  delete reponse_plus_peak_up_observed;
5693 +  delete reponse_plus_peak_down_observed;
5694 +  
5695 +  delete vanilla_predicted;
5696 +  delete response_only_up_predicted;
5697 +  delete response_only_down_predicted;
5698 +  delete reponse_plus_peak_up_predicted;
5699 +  delete reponse_plus_peak_down_predicted;
5700 +  
5701 +  delete vanilla_ratio;
5702 +  delete response_only_up_ratio;
5703 +  delete response_only_down_ratio;
5704 +  delete reponse_plus_peak_up_ratio;
5705 +  delete reponse_plus_peak_down_ratio;
5706 +  
5707 +  delete ttcan;
5708 + }
5709 +
5710 + void ttbar_region_search(string mcjzb) {
5711 +  cout << "Looking for a nice control region" << endl;
5712 +  TCanvas *can = new TCanvas("can","can",1200,1200);
5713 +  can->Divide(2,2);
5714 +  can->cd(1);
5715 +  can->cd(1)->SetLogy(1);
5716 +  
5717 +  THStack JZBdistSF = allsamples.DrawStack("JZBdistSF",mcjzb,100,-150,150, "JZB [GeV]", "events", cutmass&&cutOSSF&&TCut("pfJetGoodNum40==2"),mc, luminosity);
5718 +  THStack JZBdistOF = allsamples.DrawStack("JZBdistOF",mcjzb,100,-150,150, "JZB [GeV]", "events", cutmass&&cutOSOF&&TCut("pfJetGoodNum40==2"),mc, luminosity);
5719 +  
5720 +  JZBdistSF.Draw("histo");
5721 +  JZBdistSF.SetMaximum(1000);
5722 +  JZBdistSF.SetMinimum(0.1);
5723 +  JZBdistSF.Draw("histo");
5724 +  DrawMCPrelim();
5725 +  
5726 +  can->cd(2);
5727 +  can->cd(2)->SetLogy(1);
5728 +  JZBdistOF.Draw("histo");
5729 +  JZBdistOF.SetMaximum(1000);
5730 +  JZBdistOF.SetMinimum(0.1);
5731 +  JZBdistOF.Draw("histo");
5732 +  DrawMCPrelim();
5733 +  
5734 +  can->cd(3);
5735 +  
5736 +  
5737 +  write_warning(__FUNCTION__,"Missing negative JZB subtraction  ");
5738 +  
5739 +  DrawMCPrelim();
5740 +  
5741 +  /*
5742 +  THStack *Subtracted = new THStack();
5743 +  
5744 +  TIter nextSF(JZBdistSF.GetHists());
5745 +  TIter nextOF(JZBdistOF.GetHists());
5746 +  TObject* SFobj;
5747 +  TObject* OFobj;
5748 +  
5749 +  TH1* sfh = NULL;
5750 +  TH1* ofh = NULL;
5751 +  
5752 +  while ( (SFobj = nextSF()) && (OFobj = nextOF()) ) {
5753 +    TH1F *sfstart = (TH1*)SFobj->Clone();
5754 +    TH1F *ofstart = (TH1*)OFobj->Clone();
5755 +    TH1F *obs, *pred;
5756 +    MakeObservationPrediction(obs,pred,sfstart,ofstart);
5757 +    
5758 +    if ( !hratio ) {
5759 +      hratio = (TH1*)obj->Clone();
5760 +      hratio->SetName("hratio");
5761 +    } else hratio->Add( (TH1*)obj );
5762 +    
5763 +  }
5764 +  hratio->Divide(hdata);
5765 +  */
5766 +  
5767 +  
5768 +  can->cd(4);
5769 +  JZBdistOF.Draw("histo");
5770 +  DrawMCPrelim();
5771 +  
5772 +  
5773 +  
5774 +  CompleteSave(can,"Systematics/TtbarTests/ControlRegion");
5775 +  
5776 +  CleanLegends();
5777 +  delete can;
5778 + }
5779 +
5780 + void ttbar_tests(string mcjzb) {
5781 +  //ttbar_correction_tests();
5782 +  ttbar_region_search(mcjzb);
5783 + }
5784  
5785   void test() {
5786    
5787 +  
5788 +  float MCPeak, MCPeakError, DataPeak, DataPeakError;
5789 +  stringstream result, datajzb, mcjzb;
5790 +  bool doPUreweighting=true;
5791 +  bool SwitchOffNJetsCut=false;
5792 +  
5793 +  
5794 +  TCanvas *can = new TCanvas("can","can");
5795 +  float mcSigma,mcSigmaError,dataSigma,dataSigmaError;
5796 +  
5797 +  float NumVtxBin[6] = {0,5,10,15,20,30};
5798 +  
5799 +  stringstream NowCut;
5800 +  
5801 +  TGraphErrors *gMCPeak = new TGraphErrors();
5802 +  gMCPeak->SetTitle("gMCPeak");
5803 +  gMCPeak->SetName("gMCPeak");
5804 +  TGraphErrors *gDataPeak = new TGraphErrors();
5805 +  gDataPeak->SetTitle("gDataPeak");
5806 +  gDataPeak->SetName("gDataPeak");
5807 +  TGraphErrors *gMCWidth = new TGraphErrors();
5808 +  gMCWidth->SetTitle("gMCWidth");
5809 +  gMCWidth->SetName("gMCWidth");
5810 +  TGraphErrors *gDataWidth = new TGraphErrors();
5811 +  gDataWidth->SetTitle("gDataWidth");
5812 +  gDataWidth->SetName("gDataWidth");
5813 +  
5814 +  float AllMCPeaks[200];
5815 +  float AllMCPeaksErrors[200];
5816 +  
5817 +  for(int i=10;i<180;i+=20) {
5818 +    NowCut.str("");
5819 +    NowCut << "mll>=" << i << "&&mll<" << i+20;
5820 +    find_one_peak_combination(TCut(NowCut.str().c_str()),SwitchOffNJetsCut,MCPeak,MCPeakError, DataPeak,DataPeakError,mcSigma,mcSigmaError, dataSigma,dataSigmaError,result,doPUreweighting,"");
5821 +    AllMCPeaks[i]=MCPeak;
5822 +    AllMCPeaksErrors[i]=MCPeakError;
5823 +  }
5824 +  
5825 +  dout << "Summary : " << endl;
5826 +  for(int i=10;i<180;i+=20) {
5827 +    dout << "For the slice at [" << i << " , " << i+20 << "] we get a peak at " << AllMCPeaks[i] << " +/- " << AllMCPeaksErrors[i] << endl;
5828 +  }
5829 +  /*
5830    TCanvas *testcanv = new TCanvas("testcanv","testcanv");
5831    testcanv->cd();
5832   //  switch_overunderflow(true);
5833 <  TH1F *ptdistr   = allsamples.Draw("ptdistr","pt1",100,30,200, "p_{T} [GeV]", "events", cutOSSF,data,luminosity);
5834 <  switch_overunderflow(false);
5835 <  ptdistr->Draw();
5836 <  testcanv->SaveAs("test.png");
4604 <  dout << "HELLO there!" << endl;
5833 >  TH1F *histo1 = new TH1F("histo","histo",100,0,1);
5834 >  histo1->Sumw2();
5835 >  TH1F *histo2 = new TH1F("histo2","histo2",100,0,1);
5836 >  histo2->Sumw2();
5837    
5838 +  for(int i=0;i<100;i++) {
5839 +    histo1->Fill(1.0/i,i);
5840 +    histo2->Fill(1.0/(i*i),i);
5841 +  }
5842 +
5843 +  histo1->Draw();
5844 +  histo2->Draw("e1,same");
5845 +  
5846 +  Save_With_Ratio( histo1, histo2, testcanv->cd(), "Bullshit", false, false, "AnyCrap" );
5847 +  
5848 +  
5849 +  dout << "HELLO there!" << endl;
5850 +  */
5851   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines