ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/cbrown/Development/Plotting/Modules/Plotting_Functions.C
(Generate patch)

Comparing UserCode/cbrown/Development/Plotting/Modules/Plotting_Functions.C (file contents):
Revision 1.77 by buchmann, Fri Dec 14 13:24:29 2012 UTC vs.
Revision 1.79 by buchmann, Wed Jan 23 16:50:48 2013 UTC

# Line 437 | Line 437 | float make_one_OFSF_plot(string variable
437    mleg->Draw();
438    DrawPrelim();
439    if (datahistoOF->Integral()>0) {
440 <    save_with_ratio( datahistoSF, datahistoOF, rcan, "SFOF/" + filename, false, false, "SF/OF" );
440 >    Save_With_Ratio( datahistoSF, datahistoOF, rcan, "SFOF/" + filename, false, false, "SF/OF" );
441    } else {
442      CompleteSave(rcan, "SFOF/" + filename);
443      delete rcan;
# Line 448 | Line 448 | float make_one_OFSF_plot(string variable
448    //signalhisto->Delete();
449    delete mleg;
450    delete ckin;
451 +  delete rcan;
452  
453    return ymaxSet;
454  
# Line 500 | Line 501 | float make_data_comparison_plot(string v
501    data2->Draw("HIST,SAMES");
502    mleg->Draw();
503    DrawPrelim();
504 <  save_with_ratio( data1, data2, rcan, "compareData/" + filename, false, false, "new/old" );
504 >  Save_With_Ratio( data1, data2, rcan, "compareData/" + filename, false, false, "new/old" );
505  
506    data1->Delete();
507    data2->Delete();
508    delete mleg;
509 +  delete rcan;
510    delete ckin;
511  
512   }
# Line 810 | Line 812 | void make_kin_plot(string variable, stri
812          DrawPrelim();
813          string saveas="kin/"+filename;
814          if(isPF) saveas="kin/"+filename+"__PF";
815 <        save_with_ratio(datahisto,mcstack,kinpad->cd(),saveas);
815 >        Save_With_Ratio(datahisto,mcstack,kinpad->cd(),saveas);
816   //      if(isPF) CompleteSave(with_ratio,"kin/"+filename+"__PF_withratio");
817   //      else CompleteSave(with_ratio,"kin/"+filename+"_withratio");
818   //      delete with_ratio;
# Line 873 | Line 875 | void make_plain_kin_plot(string variable
875          DrawPrelim();
876          string saveas="kin/"+filename;
877          if(isPF) saveas="kin/"+filename+"__PF";
878 <        save_with_ratio(datahisto,mcstack,kinpad->cd(),saveas);
878 >        Save_With_Ratio(datahisto,mcstack,kinpad->cd(),saveas);
879    } else {
880          if(isPF) CompleteSave(ckin,"kin/"+filename+"__PF");
881          else CompleteSave(ckin,"kin/"+filename);
# Line 965 | Line 967 | void MakeElegantTwoThreeComparisons() {
967      leg_SFOF_Two->AddEntry(TwoOF,"OF, nJets==2","l");
968      leg_SFOF_Two->AddEntry(TwoSF,"SF, nJets==2","lp");
969      leg_SFOF_Two->Draw();
970 <    save_with_ratio(TwoSF,TwoOF,kin3->cd(),"DoubleRatios/SFOF_Two");
970 >    Save_With_Ratio(TwoSF,TwoOF,kin3->cd(),"DoubleRatios/SFOF_Two");
971      
972      TPad *kin4 = new TPad("kin4","kin4",0,0,1,1);
973      kin4->cd();
# Line 976 | Line 978 | void MakeElegantTwoThreeComparisons() {
978      leg_SFOF_Three->AddEntry(TwoOF,"OF, nJet#geq3","l");
979      leg_SFOF_Three->AddEntry(TwoSF,"SF, nJets#geq3","lp");
980      leg_SFOF_Three->Draw();
981 <    save_with_ratio(ThreeSF,ThreeOF,kin4->cd(),"DoubleRatios/SFOF_Three");
981 >    Save_With_Ratio(ThreeSF,ThreeOF,kin4->cd(),"DoubleRatios/SFOF_Three");
982      
983      
984      TwoSF->Scale(ThreeSF->Integral()/TwoSF->Integral());
# Line 989 | Line 991 | void MakeElegantTwoThreeComparisons() {
991      leg_SF_Two_Three->AddEntry(TwoSF,"#splitline{SF, nJets==2}{ (scaled)}","l");
992      leg_SF_Two_Three->AddEntry(ThreeSF,"SF, nJets#geq3","lp");
993      leg_SF_Two_Three->Draw();
994 <    save_with_ratio(TwoSF,ThreeSF,kin->cd(),"DoubleRatios/SF_Two_Three");
994 >    Save_With_Ratio(TwoSF,ThreeSF,kin->cd(),"DoubleRatios/SF_Two_Three");
995      
996      TwoOF->Scale(ThreeOF->Integral()/TwoOF->Integral());
997      TPad *kin2 = new TPad("kin2","kin2",0,0,1,1);
# Line 1001 | Line 1003 | void MakeElegantTwoThreeComparisons() {
1003      leg_OF_Two_Three->AddEntry(TwoSF,"#splitline{OF, nJets==2}{ (scaled)}","l");
1004      leg_OF_Two_Three->AddEntry(ThreeSF,"OF, nJets#geq3","lp");
1005      leg_OF_Two_Three->Draw();
1006 <    save_with_ratio(TwoOF,ThreeOF,kin2->cd(),"DoubleRatios/OF_Two_Three");
1006 >    Save_With_Ratio(TwoOF,ThreeOF,kin2->cd(),"DoubleRatios/OF_Two_Three");
1007      
1008   }
1009  
1010 + void PresentRange(TH1F *Down, TH1F *Up, TH1F *central, TVirtualPad *pad, string title) {
1011 +  pad->cd();
1012 +  TGraphErrors *gr = new TGraphErrors(Down->GetNbinsX());
1013 +  for(int i=1;i<=Down->GetNbinsX();i++) {
1014 +    float average=0.5*(Down->GetBinContent(i)+Up->GetBinContent(i));
1015 +    float error=abs(Down->GetBinContent(i)-average);
1016 +    gr->SetPoint(i-1,Down->GetBinCenter(i),average);
1017 +    gr->SetPointError(i-1,Down->GetBinWidth(i)/2.0,error);
1018 +  }
1019 +  gr->SetFillColor(TColor::GetColor("#F79F81"));
1020 +  gr->GetYaxis()->SetRangeUser(0,2);
1021 +  gr->GetXaxis()->SetTitle(central->GetXaxis()->GetTitle());
1022 +  gr->GetYaxis()->SetTitle(central->GetYaxis()->GetTitle());
1023 +  gr->GetXaxis()->CenterTitle();
1024 +  gr->GetYaxis()->CenterTitle();
1025 +  
1026 +  gr->Draw("A2");
1027 +  central->Draw("e1,same");
1028 +  DrawMCPrelim();
1029 +  TText *rtitle = write_text(0.8,0.8,title);
1030 +  TLine *line = new TLine(Down->GetBinLowEdge(1),1.0,Down->GetBinLowEdge(Down->GetNbinsX())+Down->GetBinWidth(Down->GetNbinsX()),1.0);
1031 +  line->SetLineColor(kBlue);
1032 +  line->SetLineStyle(2);
1033 +  line->Draw("same");
1034 +  rtitle->Draw("same");
1035 + }
1036 +
1037 + TH1F* ProduceTTbarRatio(TH1F *datahisto, TH1F *fullmc, TH1F *originalttbar, TH1F *httbar) {
1038 +  TH1F *basehisto = (TH1F*)fullmc->Clone("basehisto");
1039 +  basehisto->Add(originalttbar,-1);
1040 +  basehisto->Add(httbar);
1041 +  
1042 +  string sname=httbar->GetName();
1043 +  sname="R"+sname.substr(1,sname.length());
1044 +  TH1F *ratio = (TH1F*)datahisto->Clone(sname.c_str());
1045 +  ratio->Divide(basehisto);
1046 +  delete basehisto;
1047 +  return ratio;
1048 + }
1049 +  
1050 + void make_ttbar_comparison(string datavariable, string mcvariable, int nbins, float min, float max, TCut addcut, bool dolog, string xlabel, string filename) {
1051 +  
1052 +  TCut cut=addcut&&basiccut;
1053 +  
1054 +  TCanvas *ckin = new TCanvas("ckin","Kinematic Plots (in the making)",600,600);
1055 +  ckin->SetLogy(dolog);
1056 +  cout << "\r Creating " << filename << " : data   (1/11)" << std::flush;
1057 +  TH1F *datahisto = allsamples.Draw("datahisto",datavariable,nbins,min,max, xlabel, "events",cut,data,luminosity);
1058 +  datahisto->SetMarkerSize(DataMarkerSize);
1059 +  if ( !dolog ) datahisto->SetMinimum(0); // Defaults
1060 +  else datahisto->SetMinimum(0.5);
1061 +  if (dolog) datahisto->SetMaximum(5.3*datahisto->GetMaximum());
1062 +  else datahisto->SetMaximum(1.3*datahisto->GetMaximum());
1063 +  cout << "\r Creating " << filename << " : MC central  (stack) (2/11)" << std::flush;
1064 +  THStack mcstack   = allsamples.DrawStack("mcstack",  mcvariable,nbins,min,max,xlabel,"events",cut,mc,luminosity);
1065 +  TH1F *MCcentral = CollapseStack(mcstack);
1066 +
1067 +  cout << "\r Creating " << filename << " : MC central (histo)   (3/11)" << std::flush;
1068 +  TH1F *TCentral        = allsamples.Draw ("TCentral",     mcvariable,nbins,min,max,xlabel,"events",cut,mc,luminosity,allsamples.FindSample("TTJets_"));
1069 +  TH1F *RCentral        = ProduceTTbarRatio(datahisto,MCcentral,TCentral,TCentral);
1070 +  
1071 +  cout << "\r Creating " << filename << " : MC Matching up   (4/11)" << std::flush;
1072 +  TH1F *TMatchingUp     = systsamples.Draw("TMatchingUp",  mcvariable,nbins,min,max,xlabel,"events",cut,mc,luminosity,systsamples.FindSample("TTJets_matchingup"));
1073 +  TH1F *RMatchingUp     = ProduceTTbarRatio(datahisto,MCcentral,TCentral,TMatchingUp);
1074 +  
1075 +  cout << "\r Creating " << filename << " : MC Matching down   (5/11)" << std::flush;
1076 +  TH1F *TMatchingDown   = systsamples.Draw("TMatchingDown",mcvariable,nbins,min,max,xlabel,"events",cut,mc,luminosity,systsamples.FindSample("TTJets_matchingdown"));
1077 +  TH1F *RMatchingDown   = ProduceTTbarRatio(datahisto,MCcentral,TCentral,TMatchingDown);
1078 +  
1079 +  cout << "\r Creating " << filename << " : MC Scale up   (6/11)" << std::flush;
1080 +  TH1F *TScaleUp        = systsamples.Draw("TScaleUp",     mcvariable,nbins,min,max,xlabel,"events",cut,mc,luminosity,systsamples.FindSample("TTJets_scaleup"));
1081 +  TH1F *RScaleUp        = ProduceTTbarRatio(datahisto,MCcentral,TCentral,TScaleUp);
1082 +  
1083 +  cout << "\r Creating " << filename << " : MC Scale down   (7/11)" << std::flush;
1084 +  TH1F *TScaleDown      = systsamples.Draw("TScaleDown",   mcvariable,nbins,min,max,xlabel,"events",cut,mc,luminosity,systsamples.FindSample("TTJets_scaledown"));
1085 +  TH1F *RScaleDown      = ProduceTTbarRatio(datahisto,MCcentral,TCentral,TScaleDown);
1086 +  
1087 +  cout << "\r Creating " << filename << " : MC mass=166   (8/11)" << std::flush;
1088 +  TH1F *Ttmass166       = systsamples.Draw("Ttmass166",    mcvariable,nbins,min,max,xlabel,"events",cut,mc,luminosity,systsamples.FindSample("TTJets_mass166"));
1089 +  TH1F *Rtmass166       = ProduceTTbarRatio(datahisto,MCcentral,TCentral,Ttmass166);
1090 +  
1091 +  cout << "\r Creating " << filename << " : MC mass=169   (9/11)" << std::flush;
1092 +  TH1F *Ttmass169       = systsamples.Draw("Ttmass169",    mcvariable,nbins,min,max,xlabel,"events",cut,mc,luminosity,systsamples.FindSample("TTJets_mass169"));
1093 +  TH1F *Rtmass169       = ProduceTTbarRatio(datahisto,MCcentral,TCentral,Ttmass169);
1094 +  
1095 +  cout << "\r Creating " << filename << " : MC mass=175   (10/11)" << std::flush;
1096 +  TH1F *Ttmass175       = systsamples.Draw("Ttmass175",    mcvariable,nbins,min,max,xlabel,"events",cut,mc,luminosity,systsamples.FindSample("TTJets_mass175"));
1097 +  TH1F *Rtmass175       = ProduceTTbarRatio(datahisto,MCcentral,TCentral,Ttmass175);
1098 +  
1099 +  cout << "\r Creating " << filename << " : MC mass=178   (11/11)" << std::flush;
1100 +  TH1F *Ttmass178       = systsamples.Draw("Ttmass178",    mcvariable,nbins,min,max,xlabel,"events",cut,mc,luminosity,systsamples.FindSample("TTJets_mass178"));
1101 +  TH1F *Rtmass178       = ProduceTTbarRatio(datahisto,MCcentral,TCentral,Ttmass178);
1102 +  
1103 +  
1104 +  datahisto->Draw("e1");
1105 +  ckin->Update();
1106 +  mcstack.Draw("histo,same");
1107 +  
1108 +  datahisto->Draw("same,e1");
1109 +  TLegend *kinleg = allsamples.allbglegend();
1110 +  kinleg->Draw();
1111 +
1112 +  TPad *kinpad = new TPad("kinpad","kinpad",0,0,1,1);
1113 +  kinpad->SetLogy(dolog);
1114 +  kinpad->cd();
1115 +  datahisto->Draw("e1");
1116 +  mcstack.Draw("histo,same");
1117 +  datahisto->Draw("same,e1");
1118 +  datahisto->Draw("same,axis");
1119 +  
1120 +  kinleg->Draw("same");
1121 +  DrawPrelim();
1122 +  string saveas="kin/"+filename;
1123 +  
1124 +  cout << "Passing filename to be saved : " << filename << " as " << saveas << endl;
1125 +  Save_With_Ratio( datahisto, CollapseStack(mcstack), kinpad->cd(), saveas, false, false, "data/mc");
1126 +  delete kinpad;
1127 +  
1128 +  ckin->cd();
1129 +  TCentral->SetLineColor(kBlack);
1130 +  
1131 +  TMatchingUp->SetLineColor(TColor::GetColor("#2c17b1"));//blue
1132 +  TMatchingUp->SetLineStyle(2);//dashed
1133 +  TMatchingDown->SetLineColor(TColor::GetColor("#2c17b1"));
1134 +  TMatchingDown->SetLineStyle(3);//dotted
1135 +  
1136 +  TScaleUp->SetLineColor(TColor::GetColor("#FF8500"));//orange
1137 +  TScaleUp->SetLineStyle(2);//dashed
1138 +  TScaleDown->SetLineColor(TColor::GetColor("#FF8500"));
1139 +  TScaleDown->SetLineStyle(3);//dotted
1140 +  
1141 +  Ttmass166->SetLineColor(TColor::GetColor("#0acf00"));//green
1142 +  Ttmass166->SetLineStyle(3);//dotted
1143 +  Ttmass178->SetLineColor(TColor::GetColor("#0acf00"));
1144 +  Ttmass178->SetLineStyle(2);//dashed
1145 +  
1146 +  
1147 +  Ttmass169->SetLineColor(TColor::GetColor("#FF52F1"));//purple
1148 +  Ttmass169->SetLineStyle(3);//dotted
1149 +  Ttmass175->SetLineColor(TColor::GetColor("#FF52F1"));
1150 +  Ttmass175->SetLineStyle(2);//dashed
1151 +  
1152 +  
1153 +  
1154 +  
1155 +  MCcentral->SetLineStyle(3);
1156 +  MCcentral->SetLineColor(kRed);
1157 +  
1158 +  TCentral->Draw("e1,same");
1159 +  TCentral->Draw("histo,same");
1160 +  TMatchingUp->Draw("histo,same");
1161 +  TMatchingDown->Draw("histo,same");
1162 +  TScaleUp->Draw("histo,same");
1163 +  TScaleDown->Draw("histo,same");
1164 +  Ttmass166->Draw("histo,same");
1165 +  Ttmass169->Draw("histo,same");
1166 +  Ttmass175->Draw("histo,same");
1167 +  Ttmass178->Draw("histo,same");
1168 +  
1169 +  TLegend *sleg = make_legend();
1170 +  sleg->AddEntry(TCentral,"Central","L");
1171 +  sleg->AddEntry(TMatchingUp,"matching up","L");
1172 +  sleg->AddEntry(TMatchingDown,"matching down","L");
1173 +  sleg->AddEntry(TScaleUp,"scale up","L");
1174 +  sleg->AddEntry(TScaleDown,"scale down","L");
1175 +  sleg->AddEntry(Ttmass166,"m_{t}=166","L");
1176 +  sleg->AddEntry(Ttmass169,"m_{t}=169","L");
1177 +  sleg->AddEntry(Ttmass175,"m_{t}=175","L");
1178 +  sleg->AddEntry(Ttmass178,"m_{t}=178","L");
1179 +  sleg->Draw();
1180 +  
1181 +  CompleteSave(ckin,saveas+"___AllLines");
1182 +  ckin->cd();
1183 +  ckin->SetLogy(0);
1184 +  
1185 +  RCentral->SetLineColor(kBlack);
1186 +  
1187 +  RMatchingUp->SetLineColor(TColor::GetColor("#2c17b1"));//blue
1188 +  RMatchingUp->SetLineStyle(2);//dashed
1189 +  RMatchingDown->SetLineColor(TColor::GetColor("#2c17b1"));
1190 +  RMatchingDown->SetLineStyle(3);//dotted
1191 +  
1192 +  RScaleUp->SetLineColor(TColor::GetColor("#FF8500"));//orange
1193 +  RScaleUp->SetLineStyle(2);//dashed
1194 +  RScaleDown->SetLineColor(TColor::GetColor("#FF8500"));
1195 +  RScaleDown->SetLineStyle(3);//dotted
1196 +  
1197 +  Rtmass166->SetLineColor(TColor::GetColor("#0acf00"));//green
1198 +  Rtmass166->SetLineStyle(3);//dotted
1199 +  Rtmass178->SetLineColor(TColor::GetColor("#0acf00"));
1200 +  Rtmass178->SetLineStyle(2);//dashed
1201 +  
1202 +  
1203 +  Rtmass169->SetLineColor(TColor::GetColor("#FF52F1"));//purple
1204 +  Rtmass169->SetLineStyle(3);//dotted
1205 +  Rtmass175->SetLineColor(TColor::GetColor("#FF52F1"));
1206 +  Rtmass175->SetLineStyle(2);//dashed
1207 +
1208 +  
1209 +  RCentral->GetYaxis()->SetRangeUser(0,2);
1210 +  RCentral->Draw("e1");
1211 +  RMatchingUp->Draw("histo,same");
1212 +  RMatchingDown->Draw("histo,same");
1213 +  RScaleUp->Draw("histo,same");
1214 +  RScaleDown->Draw("histo,same");
1215 +  Rtmass166->Draw("histo,same");
1216 +  Rtmass169->Draw("histo,same");
1217 +  Rtmass175->Draw("histo,same");
1218 +  Rtmass178->Draw("histo,same");
1219 +  
1220 +  CompleteSave(ckin,saveas+"___AllRatios");
1221 +
1222 +  TCanvas *multicanvas = new TCanvas("multicanvas","multicanvas",1000,1000);
1223 +  multicanvas->Divide(2,2);
1224 +  PresentRange(RMatchingUp,RMatchingDown,RCentral,multicanvas->cd(1),"Matching");
1225 +  PresentRange(RScaleUp,RScaleDown,RCentral,multicanvas->cd(2),"Scale");
1226 +  PresentRange(Rtmass166,Rtmass178,RCentral,multicanvas->cd(3),"m_{t} (2#sigma)");
1227 +  PresentRange(Rtmass169,Rtmass175,RCentral,multicanvas->cd(4),"m_{t} (1#sigma)");
1228 +  CompleteSave(multicanvas,saveas+"___RangeIllustration");
1229 +  
1230 +  
1231 +  delete datahisto;
1232 +  delete   TCentral;
1233 +  delete   TMatchingUp;
1234 +  delete   TMatchingDown;
1235 +  delete   TScaleUp;
1236 +  delete   TScaleDown;
1237 +  delete   Ttmass166;
1238 +  delete   Ttmass169;
1239 +  delete   Ttmass175;
1240 +  delete   Ttmass178;
1241 +  
1242 +  delete ckin;
1243 +  
1244 + }
1245 +  
1246 + void make_ttbar_comparison(string variable, int nbins, float min, float max, TCut addcut, bool dolog, string xlabel, string filename) {
1247 +  make_ttbar_comparison(variable, variable, nbins, min, max, addcut, dolog, xlabel, filename);
1248 + }
1249 +
1250 + void ProduceJanPlots() {
1251 +  TCanvas *c1 = new TCanvas("c1","c1");
1252 +  TH1F *metSF = allsamples.Draw("metSF","met[4]",30,100,400, "E_{T}^{miss} [GeV]", "events", cutmass&&cutOSSF&&cutnJets,data, luminosity);
1253 +  TH1F *metOF = allsamples.Draw("metOF","met[4]",30,100,400, "E_{T}^{miss} [GeV]", "events", cutmass&&cutOSOF&&cutnJets,data, luminosity);
1254 +  
1255 +  TPad* rcan = new TPad("rcan","rcan",0,0,1,1);
1256 +  rcan->cd();
1257 +
1258 +  metOF->SetLineColor(kRed);
1259 +  metSF->Draw("e1");
1260 +  metOF->Draw("histo,same");
1261 +  metSF->Draw("e1,same");
1262 +  
1263 +  TLegend *leg = make_legend();
1264 +  
1265 +  leg->AddEntry(metSF,"Data SF","p");
1266 +  leg->AddEntry(metOF,"Data OF","l");
1267 +  leg->Draw();
1268 +  
1269 +  DrawPrelim();
1270 +  
1271 +  Save_With_Ratio(metSF,metOF,rcan,"JanPlots/ETHConfig",false,false,"SF/OF");
1272 +  
1273 +  delete rcan;
1274 +  delete metSF;
1275 +  delete metOF;
1276 +  delete c1;
1277 + }
1278 +
1279 + THStack MakeOneSystematicsPlot(TCut cut, string saveas, string variation, TH1F *hdata, string variable, int nbins, float bmin, float bmax, string label) {
1280 +  THStack SystPlot = allsamples.DrawStack(variation,variable,nbins,bmin,bmax,label,"events",cut,mc,PlottingSetup::luminosity);
1281 +  
1282 +  //now need to process the plot (calculate the variation and set the member of thstack accordingly!)
1283 +  if(variation!="Central") {
1284 +    TH1F *varttbar;
1285 +    if(variation=="MatchingUp") varttbar = systsamples.Draw("varttbar",variable,nbins,bmin,bmax,label,"events",cut,mc,PlottingSetup::luminosity,systsamples.FindSample("TTJets_matchingup_TuneZ2s"));
1286 +    if(variation=="MatchingDown") varttbar = systsamples.Draw("varttbar",variable,nbins,bmin,bmax,label,"events",cut,mc,PlottingSetup::luminosity,systsamples.FindSample("TTJets_matchingdown"));
1287 +    if(variation=="ScaleUp") varttbar = systsamples.Draw("varttbar",variable,nbins,bmin,bmax,label,"events",cut,mc,PlottingSetup::luminosity,systsamples.FindSample("TTJets_scaleup"));
1288 +    if(variation=="ScaleDown") varttbar = systsamples.Draw("varttbar",variable,nbins,bmin,bmax,label,"events",cut,mc,PlottingSetup::luminosity,systsamples.FindSample("TTJets_scaledown"));
1289 +    assert(varttbar);
1290 +    
1291 +    TIter nextHisto(SystPlot.GetHists());
1292 +    TH1F* h;
1293 +    while ( h = (TH1F*)nextHisto() ) {
1294 +      if(Contains(h->GetName(),"t_bar_t")) {
1295 +        varttbar->Scale(h->Integral()/varttbar->Integral());
1296 +        for(int i=0;i<=h->GetNbinsX()+1;i++) {//note that we deliberatly consider the under/overflow bin as well!
1297 +          h->SetBinContent(i,varttbar->GetBinContent(i));
1298 +          h->SetBinError(i,varttbar->GetBinError(i));
1299 +        }
1300 +        SystPlot.Modified();
1301 +      }
1302 +    }
1303 +    delete varttbar;
1304 +  }
1305 +  
1306 +  TLegend *fullleg = allsamples.allbglegend();
1307 +  fullleg->SetHeader(variation.c_str());
1308 +  TPad *kinpad = new TPad("kinpad","kinpad",0,0,1,1);
1309 +  kinpad->SetLogy(1);
1310 +  kinpad->cd();
1311 +  
1312 +  hdata->Draw("e1");
1313 +  SystPlot.Draw("histo,same");
1314 +  hdata->Draw("e1,same");
1315 +  fullleg->Draw();
1316 +  DrawPrelim();
1317 +  
1318 +  Save_With_Ratio(hdata,SystPlot,kinpad,saveas+"_"+variation);
1319 +  CleanLegends();
1320 +  
1321 +  delete kinpad;
1322 +  return SystPlot;
1323 + }
1324 +  
1325 +
1326 +
1327 + void ProduceMCSystematicPlot(string variable, int nbins, float bmin, float bmax, string label, TCut thiscut, string saveas) {
1328 +  TCanvas *ca = new TCanvas("ca","ca");
1329 +
1330 +  TH1F *hdata = allsamples.Draw("hdata",variable,nbins,bmin,bmax,label,"events",thiscut,data,luminosity);
1331 +  
1332 +  THStack ScaleUp      = MakeOneSystematicsPlot(thiscut,saveas,"ScaleUp",hdata,variable, nbins, bmin, bmax, label);
1333 +  THStack ScaleDown    = MakeOneSystematicsPlot(thiscut,saveas,"ScaleDown",hdata,variable, nbins, bmin, bmax, label);
1334 +  THStack MatchingUp   = MakeOneSystematicsPlot(thiscut,saveas,"MatchingUp",hdata,variable, nbins, bmin, bmax, label);
1335 +  THStack MatchingDown = MakeOneSystematicsPlot(thiscut,saveas,"MatchingDown",hdata,variable, nbins, bmin, bmax, label);
1336 +  
1337 +  TH1F *HScaleUp = CollapseStack(ScaleUp);
1338 +  TH1F *HScaleDown = CollapseStack(ScaleDown);
1339 +  TH1F *HMatchingUp = CollapseStack(MatchingUp);
1340 +  TH1F *HMatchingDown = CollapseStack(MatchingDown);
1341 +  
1342 +  DeleteStack(ScaleUp);
1343 +  DeleteStack(ScaleDown);
1344 +  DeleteStack(MatchingUp);
1345 +  DeleteStack(MatchingDown);
1346 +  
1347 +  THStack Central = MakeOneSystematicsPlot(thiscut,saveas,"Central",hdata,variable, nbins, bmin, bmax, label);
1348 +  TH1F *HCentral = CollapseStack(Central);
1349 +  
1350 +  TH1F *Systematic = (TH1F*)hdata->Clone("Systematic");
1351 +  for(int i=1;i<=Systematic->GetNbinsX();i++) {
1352 +    float matchingup   = abs(HMatchingUp->GetBinContent(i)-HCentral->GetBinContent(i));
1353 +    float matchingdown = abs(HMatchingDown->GetBinContent(i)-HCentral->GetBinContent(i));
1354 +    float scaleup   = abs(HScaleUp->GetBinContent(i)-HCentral->GetBinContent(i));
1355 +    float scaledown = abs(HScaleDown->GetBinContent(i)-HCentral->GetBinContent(i));
1356 +    
1357 +    float matching = matchingup>matchingdown?matchingup:matchingdown;
1358 +    float scale    = scaleup>scaledown?scaleup:scaledown;
1359 +    
1360 +    float sys=sqrt(matching*matching+scale*scale);
1361 +    sys/=HCentral->GetBinContent(i);
1362 +    if(HCentral->GetBinContent(i)==0) sys=0;
1363 +    Systematic->SetBinContent(i,sys);
1364 +  }
1365 +  
1366 +  TPad *kinpad = new TPad("kinpad","kinpad",0,0,1,1);
1367 +  kinpad->SetLogy(1);
1368 +  kinpad->cd();
1369 +  hdata->Draw("e1");
1370 +  Central.Draw("histo,same");
1371 +  hdata->Draw("e1,same");
1372 +  DrawPrelim();
1373 +
1374 +  save_with_ratio_and_sys_band( hdata, HCentral, kinpad->cd(), saveas, false, false, "data/mc",Systematic );
1375 +  
1376 +  CleanLegends();
1377 +  DeleteStack(Central);
1378 +  delete Systematic;
1379 +  delete HScaleUp;
1380 +  delete HScaleDown;
1381 +  delete HMatchingUp;
1382 +  delete HMatchingDown;
1383 +  delete hdata;
1384 +  delete HCentral;
1385 +  delete ca;
1386 + }
1387 +
1388 + void ProduceMCSystematicPlots() {
1389 +  TCut cutweightBKP = cutWeight;
1390 +  
1391 +  ProduceMCSystematicPlot("met[4]",80,0,400,"PFMET [GeV]",cutOSSF&&cutnJets&&TCut("mll>20&&mll<70"),"MCSystPlots/MET/ETH_SameFlavor");
1392 +  ProduceMCSystematicPlot("met[4]",80,0,400,"PFMET [GeV]",cutOSOF&&cutnJets&&TCut("mll>20&&mll<70"),"MCSystPlots/MET/ETH_OppositeFlavor");
1393 +  ProduceMCSystematicPlot("pfJetGoodNum40",8,-0.5,7.5,"NJets",cutOSSF&&cutnJets&&TCut("mll>20&&mll<70&&met[4]>100"),"MCSystPlots/NJets/ETH_SameFlavor");
1394 +  ProduceMCSystematicPlot("pfJetGoodNum40",8,-0.5,7.5,"NJets",cutOSOF&&cutnJets&&TCut("mll>20&&mll<70&&met[4]>100"),"MCSystPlots/NJets/ETH_OppositeFlavor");
1395 +  
1396 +  TCut cutnJetsBKP = cutnJets;
1397 +  cutnJets = TCut((ReplaceAll((const char*)cutnJets,"pt2>20","pt2>10")).c_str());
1398 +  cutnJets = TCut((ReplaceAll((const char*)cutnJets,"pfJetGoodNum40>=3","pfJetGoodNum40>=2")).c_str());
1399 +  cutnJets = TCut((ReplaceAll((const char*)cutnJets,"abs(eta2)<1.4","abs(eta2)<2.4")).c_str());
1400 +  cutnJets = TCut((ReplaceAll((const char*)cutnJets,"abs(eta1)<1.4","abs(eta1)<2.4")).c_str());
1401 +  
1402 +  ProduceMCSystematicPlot("met[4]",80,0,400,"PFMET [GeV]",cutOSSF&&cutnJets&&TCut("mll>20&&mll<70"),"MCSystPlots/MET/Aachen_SameFlavor");
1403 +  ProduceMCSystematicPlot("met[4]",80,0,400,"PFMET [GeV]",cutOSOF&&cutnJets&&TCut("mll>20&&mll<70"),"MCSystPlots/MET/Aachen_OppositeFlavor");
1404 +  ProduceMCSystematicPlot("pfJetGoodNum40",8,-0.5,7.5,"NJets",cutOSSF&&cutnJets&&TCut("mll>20&&mll<70&&met[4]>150"),"MCSystPlots/NJets/Aachen_SameFlavor");
1405 +  ProduceMCSystematicPlot("pfJetGoodNum40",8,-0.5,7.5,"NJets",cutOSOF&&cutnJets&&TCut("mll>20&&mll<70&&met[4]>150"),"MCSystPlots/NJets/Aachen_OppositeFlavor");
1406 +  cutnJets  = cutnJetsBKP;
1407 +  cutWeight = cutweightBKP;
1408 + }
1409  
1410   void do_kinematic_plots(string mcjzb, string datajzb, bool doPF=false)
1411   {
# Line 1028 | Line 1429 | void do_kinematic_plots(string mcjzb, st
1429    
1430    if(MakeTwoThreeJetComparison) MakeElegantTwoThreeComparisons();
1431  
1432 +  //ProduceJanPlots();
1433 +  ProduceMCSystematicPlots();
1434 +  make_plain_kin_plot("pt",Cut2Str(cutOSSF&&TCut("mll>20&&pfJetGoodNumBtag30>=2")),40,0,200,nolog,"Z p_{T}","PlotForKostas",doPF,true);
1435 +  
1436    if ( doOFSF ) {
1437       make_OFSF_plots("mll", "met[4]>100", 60, 20., 320., false, "m_{ll}", "mll");
1438  
# Line 1149 | Line 1554 | void do_kinematic_plots(string mcjzb, st
1554  
1555    if ( doKin ) {
1556      string mllCut("");
1557 +    
1558 +    
1559   /*  
1560      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);
1561      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 1202 | Line 1609 | void do_kinematic_plots(string mcjzb, st
1609   //     make_kin_plot("met[4]","",70,0,350,dolog,"MET [GeV]","met",doPF,true);
1610  
1611  
1612 +
1613 +
1614 +    
1615 +     make_kin_plot("MetFactor","",20,0,2,nolog,"MetFactor","MetFactor",doPF,true);
1616 +    
1617 +     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");
1618 +    
1619 +     DoMCSystPlot("met[4]",40,0,400,(cutOSOF&&TCut("mll>30&&mll<70&&pfJetGoodNum40==0")),dolog,"PFMET","Debunking/MET_OF_30to70_0j");
1620 +     DoMCSystPlot("met[4]",40,0,400,(cutOSOF&&TCut("mll>30&&mll<70&&pfJetGoodNum40==1")),dolog,"PFMET","Debunking/MET_OF_30to70_1j");
1621 +     DoMCSystPlot("met[4]",40,0,400,(cutOSOF&&TCut("mll>30&&mll<70&&pfTightHT>100&&pfJetGoodNum40==2")),dolog,"PFMET","Debunking/MET_OF_30to70_2j");
1622 +     DoMCSystPlot("met[4]",40,0,400,(cutOSOF&&TCut("mll>30&&mll<70&&pfTightHT>100&&pfJetGoodNum40==3")),dolog,"PFMET","Debunking/MET_OF_30to70_3j");
1623 +
1624 +     DoMCSystPlot("met[4]",40,0,400,(cutOSOF&&TCut("mll>80&&mll<100&&pfJetGoodNum40==0")),dolog,"PFMET","Debunking/MET_OF_Z_0j");
1625 +     DoMCSystPlot("met[4]",40,0,400,(cutOSOF&&TCut("mll>80&&mll<100&&pfJetGoodNum40==1")),dolog,"PFMET","Debunking/MET_OF_Z_1j");
1626 +     DoMCSystPlot("met[4]",40,0,400,(cutOSOF&&TCut("mll>80&&mll<100&&pfTightHT>100&&pfJetGoodNum40==2")),dolog,"PFMET","Debunking/MET_OF_Z_2j");
1627 +     DoMCSystPlot("met[4]",40,0,400,(cutOSOF&&TCut("mll>80&&mll<100&&pfTightHT>100&&pfJetGoodNum40==3")),dolog,"PFMET","Debunking/MET_OF_Z_3j");
1628 +
1629 +    
1630       DoMCSystPlot("mll", (int)((mll_hi-mll_low)/5),mll_low,mll_hi,cutnJets&&cutOSSF,dolog,"m_{ll} [GeV]","kinSys/mll");
1631       DoMCSystPlot("mll", (int)((mll_hi-mll_low)/5),mll_low,mll_hi,cutnJets&&cutOSSF&&TCut("id1==0"),dolog,"m_{ll} [GeV]","kinSys/mll_ee");
1632       DoMCSystPlot("mll", (int)((mll_hi-mll_low)/5),mll_low,mll_hi,cutnJets&&cutOSSF&&TCut("id1==1"),dolog,"m_{ll} [GeV]","kinSys/mll_mm");
# Line 1214 | Line 1639 | void do_kinematic_plots(string mcjzb, st
1639       DoMCSystPlot("pfJetGoodNum40", 9,-0.5,8.5,cutOSOF,dolog,"nJets","kinSys/nJets_osof");
1640      
1641       DoMCSystPlot("pfJetGoodPt[0]/pfJetGoodPt[1]",45,1,10,cutnJets&&cutOSSF,dolog,"p_{T}^{J1} / p_{T}^{J2}","kinSys/j1j2ratio");
1642 <     DoMCSystPlot("TMath::Abs(pfJetDphiMet[0])",32,0,3.2,cutnJets&&cutOSSF,dolog,"|#Delta#phi(jet1,MET)|","kinSys/j1j2ratio");
1643 <    
1644 <     DoMCSystPlot(datajzb,mcjzb, (int)((PlottingSetup::jzbHigh+110)/10),-110,PlottingSetup::jzbHigh,cutnJets&&cutOSSF&&Restrmasscut,dolog,"m_{ll} [GeV]","kinSys/jzb_ossf");
1645 <     DoMCSystPlot(datajzb,mcjzb, (int)((PlottingSetup::jzbHigh+110)/10),-110,PlottingSetup::jzbHigh,cutnJets&&cutOSOF&&Restrmasscut,dolog,"m_{ll} [GeV]","kinSys/jzb_ossf");
1642 >     DoMCSystPlot("TMath::Abs(pfJetDphiMet[0])",32,0,3.2,cutnJets&&cutOSSF,dolog,"|#Delta#phi(jet1,MET)|","kinSys/dphiJ1MET");
1643 >
1644 >     DoMCSystPlot(datajzb,mcjzb, (int)((PlottingSetup::jzbHigh+110)/10),-110,PlottingSetup::jzbHigh,cutnJets&&cutOSSF&&Restrmasscut,dolog,"m_{ll} [GeV]","kinSys/jzb_OS_SFZP");
1645 >     DoMCSystPlot(datajzb,mcjzb, (int)((PlottingSetup::jzbHigh+110)/10),-110,PlottingSetup::jzbHigh,cutnJets&&cutOSOF&&Restrmasscut,dolog,"m_{ll} [GeV]","kinSys/jzb_OS_OFZP");
1646  
1647      
1648      
# Line 1913 | Line 2338 | void do_prediction_plot(string jzb, TCan
2338   //    speciallegBpred->AddEntry(lm4RcorrJZBeemmC,"LM4","l");
2339   //     speciallegBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
2340      speciallegBpred->Draw();
2341 <    save_with_ratio(JRcorrJZBeemm,JBpred,predcomppad,subdir+"Bpred_Data_____PredictionComposition",true,true,"data/pred",BpredSys);
2341 >    Save_With_Ratio(JRcorrJZBeemm,JBpred,predcomppad,subdir+"Bpred_Data_____PredictionComposition",true,true,"data/pred",BpredSys);
2342 >    delete predcomppad;
2343      
2344      TCanvas *specialcanv = new TCanvas("specialcanv","specialcanv");
2345      specialcanv->SetLogy(1);
# Line 1996 | Line 2422 | void do_prediction_plot(string jzb, TCan
2422    string ytitle("ratio");
2423    if ( use_data==1 ) ytitle = "data/pred";
2424    //save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,Bpredsaveas,true,use_data!=1,ytitle);
2425 <  save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,subdir+Bpredsaveas,true,false,ytitle,BpredSys);//not extending the y range anymore up to 4
2425 >  Save_With_Ratio(JRcorrJZBeemm,JBpred,kinpad,subdir+Bpredsaveas,true,false,ytitle,BpredSys);//not extending the y range anymore up to 4
2426 >  
2427 >  delete kinpad;
2428  
2429  
2430    
# Line 2193 | Line 2621 | void lepton_comparison_plots() {
2621    eemmlegend->AddEntry(jmmd,"#mu#mu","l");
2622    eemmlegend->Draw();
2623    DrawPrelim();
2624 <  save_with_ratio(jeed,jmmd,eemmpad->cd(),"lepton_comparison/jzb_Comparing_ee_mm_data");
2624 >  Save_With_Ratio(jeed,jmmd,eemmpad->cd(),"lepton_comparison/jzb_Comparing_ee_mm_data");
2625    
2626    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"));
2627    TH1F *zjmmd = allsamples.Draw("zjmmd",jzbvariablemc,    int((jzbHigh+150)/5),-150,jzbHigh , "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&"(id1==1)",mc,  luminosity,allsamples.FindSample("/DY"));
# Line 2316 | Line 2744 | void draw_pure_jzb_histo(TCut cut,string
2744    TText *writeline1 = write_cut_on_canvas(write_cut.c_str());
2745    writeline1->SetTextSize(0.035);
2746    writeline1->Draw();
2747 <  if(!Contains(savename,"Dibosons")) save_with_ratio(datahisto,mcstack,jzbpad->cd(),("jzb/"+savename));
2748 <  else save_with_ratio(datahisto,mcstack,jzbpad->cd(),savename);
2747 >  if(!Contains(savename,"Dibosons")) Save_With_Ratio(datahisto,mcstack,jzbpad->cd(),("jzb/"+savename));
2748 >  else Save_With_Ratio(datahisto,mcstack,jzbpad->cd(),savename);
2749    TPad *jzbpad2 = new TPad("jzbpad2","jzbpad2",0,0,1,1);
2750    jzbpad2->cd();
2751    jzbpad2->SetLogy(1);
# Line 2332 | Line 2760 | void draw_pure_jzb_histo(TCut cut,string
2760    writeline1->SetTextSize(0.035);
2761    writeline1->Draw();
2762    DrawPrelim();
2763 <  if(!Contains(savename,"Dibosons")) save_with_ratio(datahisto,mcstack,jzbpad2->cd(),("jzb/PositiveSideOnly/"+savename+""));
2764 <  else save_with_ratio(datahisto,mcstack,jzbpad2->cd(),(savename+"__PosOnly"));
2763 >  if(!Contains(savename,"Dibosons")) Save_With_Ratio(datahisto,mcstack,jzbpad2->cd(),("jzb/PositiveSideOnly/"+savename+""));
2764 >  else Save_With_Ratio(datahisto,mcstack,jzbpad2->cd(),(savename+"__PosOnly"));
2765    datahisto->Delete();
2766    mcstack.Delete();
2767   }
# Line 2441 | Line 2869 | void draw_normalized_data_vs_data_histo(
2869    leg->AddEntry(datahisto2,legentry2.c_str());
2870    leg->Draw();
2871    
2872 <  save_with_ratio(datahisto1,datahisto2,jzbpad->cd(),("jzb/"+savename));
2872 >  Save_With_Ratio(datahisto1,datahisto2,jzbpad->cd(),("jzb/"+savename));
2873    
2874    datahisto1->Delete();
2875    datahisto2->Delete();
# Line 3630 | Line 4058 | void make_table(samplecollection &coll,
4058   }
4059  
4060   void met_jzb_cut(string datajzb, string mcjzb, vector<float> jzb_cut) {
4061 +  cout << "You probably don't want --met, you want --metplots ... " << endl;
4062 +  assert(0);
4063    /*we want a table like this:
4064      __________________     50   |   100  | ...
4065      | Data prediction |  a vs b | a vs b | ...
# Line 3863 | Line 4293 | void qcd_plots(string datajzb, string mc
4293    //3rd last argument: do special bpred ratio, 2nd last argument: extended range!, last: y-axis title
4294    string ytitle("ratio");
4295    if ( use_data==1 ) ytitle = "data/pred";
4296 <  save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,"QCD/Bpred",true,false,ytitle);
4296 >  Save_With_Ratio(JRcorrJZBeemm,JBpred,kinpad,"QCD/Bpred",true,false,ytitle);
4297 >  delete kinpad;
4298    
4299    TH1F *allevents = qcdsamples.Draw("allevents","pfJetGoodNum",1,0,100, "internal code", "events", "" ,mc, luminosity);
4300    TH1F *ossf = qcdsamples.Draw("ossf","pfJetGoodNum",1,0,100, "internal code", "events", cutOSSF ,mc, luminosity);
# Line 4100 | Line 4531 | void met_vs_jzb_plots(string datajzb, st
4531    lg->SetHeader("DY");
4532    
4533    lg->Draw();
4534 <  save_with_ratio(metright,metleft,metpad->cd(),"METvsJZBplots/ComparingLeftToRightinMETspectrum");
4534 >  Save_With_Ratio(metright,metleft,metpad->cd(),"METvsJZBplots/ComparingLeftToRightinMETspectrum");
4535    
4536    TPad *metpad3 = new TPad("metpad3","metpad3",0,0,1,1);
4537    metpad3->cd();
# Line 4118 | Line 4549 | void met_vs_jzb_plots(string datajzb, st
4549  
4550    lg2->Draw();
4551    
4552 <  save_with_ratio(obs,Bpred,metpad3->cd(),"METvsJZBplots/ComparingPredObsinMET");
4552 >  Save_With_Ratio(obs,Bpred,metpad3->cd(),"METvsJZBplots/ComparingPredObsinMET");
4553    
4554    TPad *metpad2 = new TPad("metpad2","metpad2",0,0,1,1);
4555    metpad2->cd();
# Line 4137 | Line 4568 | void met_vs_jzb_plots(string datajzb, st
4568    metlefta->Draw("histo");
4569    metrighta->Draw("same");
4570    lg->Draw();
4571 <  save_with_ratio(metrighta,metlefta,metpad2->cd(),"METvsJZBplots/ComparingLeftToRightinMET_type1_spectrum");
4571 >  Save_With_Ratio(metrighta,metlefta,metpad2->cd(),"METvsJZBplots/ComparingLeftToRightinMET_type1_spectrum");
4572    
4573    delete Bpred;
4574    delete obs;
# Line 4164 | Line 4595 | void met_vs_jzb_plots(string datajzb, st
4595    aobs->Draw("same");
4596    lg->SetHeader("All MC");
4597    lg->Draw();
4598 <  save_with_ratio(aobs,aBpred,metpad4->cd(),"METvsJZBplots/ComparingPredObsinMET_ALLSAMPLES");
4598 >  Save_With_Ratio(aobs,aBpred,metpad4->cd(),"METvsJZBplots/ComparingPredObsinMET_ALLSAMPLES");
4599    
4600    
4601    delete lg;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines