Esempio n. 1
0
// ----------------------------------------------------------------------
void plotRatio(string era = "2016BF") {
  gStyle->SetOptStat(0);

  if (era == "all") {
    plotRatio("2011");
    plotRatio("2012");
    plotRatio("2016BF");
    plotRatio("2016GH");
    return;
  }


  TH1D *hresult = new TH1D("hresult", Form("n(gauss(5.28))/n(gauss(5.37)) %s", era.c_str()), 40, 0., 0.4);
  hresult->GetXaxis()->SetTitle("BDT > ");
  TH1D *hbdtcut = new TH1D("hbdtcut", Form("n(gauss(5.28))/n(gauss(5.37)) %s", era.c_str()), 40, 0., 0.4);
  hbdtcut->SetMarkerColor(kBlue);
  invertedMuonID(era, 0.15, hresult);
  invertedMuonID(era, 0.20, hresult);
  invertedMuonID(era, 0.25, hresult);
  invertedMuonID(era, 0.30, hresult);
  invertedMuonID(era, -99., hbdtcut);

  c0->Clear();
  double ymax(50.);
  if (hresult->GetMaximum() < 5.)  ymax = 10.;
  if (hresult->GetMaximum() < 0.5) ymax = 1.0;
  hresult->SetMinimum(-ymax);
  hresult->SetMaximum(ymax);
  hresult->Draw();
  hbdtcut->Draw("same");
  pl->DrawLine(0., 0., 0.4, 0.);
  c0->SaveAs(Form("invertedMuonID-%s-result.pdf", era.c_str()));
}
void plotBackgroundSystematics(){
   
   TCanvas *c1 = new TCanvas("c1","",1650,430);
   makeMultiPanelCanvas(c1,5,1,0.0,0.0,0.2,0.15,0.02);
   
   c1->cd(1);
   plotRatio(4,"mix.root","mix.root","pythia.root",false,false,false);
   drawText("50-100%",0.76,0.24);
   drawPatch(0.976,0.0972,1.1,0.171);
   gPad->SetLeftMargin(0.25);
   gPad->SetBottomMargin(0.18);
   
  c1->cd(2);
  plotRatio(3,"mix.root","mix.root","pythia.root",false,false,false);
  drawText("30-50%",0.75,0.24);
  drawPatch(-0.00007,0.0972,0.0518,0.171);
  drawPatch(0.976,0.0972,1.1,0.171);
  gPad->SetBottomMargin(0.18);

  c1->cd(3);
  plotRatio(2,"mix.root","mix.root","pythia.root",false,true,false);
  drawText("20-30%",0.75,0.24);
  drawPatch(-0.00007,0.0972,0.0518,0.171);
  gPad->SetBottomMargin(0.18);
  drawPatch(0.976,0.0972,1.1,0.171);

  c1->cd(4);
  plotRatio(1,"mix.root","mix.root","pythia.root",false,false,false);
  drawText("10-20%",0.75,0.24);
  drawPatch(-0.00007,0.0972,0.0518,0.171);
  gPad->SetBottomMargin(0.18);
  drawPatch(0.976,0.0972,1.1,0.171);

  c1->cd(5);
  plotRatio(0,"mix.root","mix.root","pythia.root",false,false,true);
  drawText("0-10%",0.75,0.24);
  gPad->SetBottomMargin(0.18);
  drawPatch(-0.00007,0.0972,0.0518,0.171);

  TLatex *cms = new TLatex(0.086,4.5,"CMS Preliminary");
  cms->SetTextFont(63);
  cms->SetTextSize(18);
  cms->Draw();                                                                                                                                        

  TLatex *lumi = new TLatex(0.15,4.1,"#intL dt = 7 #mub^{-1}");
  lumi->SetTextFont(63);
  lumi->SetTextSize(15);
//  lumi->Draw(); 

  c1->Print("./fig/ratio_pythiaToMix_20101207_v0.gif");
  c1->Print("./fig/ratio_pythiaToMix_20101207_v0.eps");
  c1->Print("./fig/ratio_pythiaToMix_20101207_v0.pdf");

}
Esempio n. 3
0
//----------------------------------------//
// Plot Two histograms
//----------------------------------------//
void plot(TFile* f_mix, TFile* f_g4, TString append)
{

  // Make Canvas
  TCanvas* c = makeCanvas("c");
  c->SetLogy();

  // Make Legend
  TLegend* leg = makeLegend(0.7,0.9,0.75,0.92);
  leg->SetTextSize(0.05);

  // Some plot particles
  TString xtitle = "Shower Depth [cm]";
  TString ytitle = "<N(e^{-}-e^{+})>";

  // Get profile from g4 results
  //TProfile* p_g4 = getProfile(f_g4,"NPartSum",xtitle,ytitle,kBlack,20);
  TProfile* p_g4 = getProfile(f_g4,"NPartDiff",xtitle,ytitle,kBlack,20);
  p_g4->SetMarkerSize(0.75);

  // Get profile from mixed file
  int nbins = p_g4->GetNbinsX();
  float xmin = p_g4->GetXaxis()->GetXmin();
  float xmax = p_g4->GetXaxis()->GetXmax();
  TProfile* p_mix = getMixProfile(f_mix,nbins,xmin,xmax,kBlue,25);

  // Add to legend
  leg->AddEntry(p_g4,"G4", "lep");
  leg->AddEntry(p_mix,"G4 Mixed", "lep");

  // Draw
  //p_g4->Draw();
  //p_mix->Draw("same");
  //leg->Draw("same");

  // Make ratio plot
  plotRatio(p_mix, p_g4, leg, c, "Mixed/G4", append);

}
Esempio n. 4
0
void bdtout_syst(bool passMVAcut=false, bool equalArea=true) {

  gStyle->SetOptTitle(0);
  gStyle->SetOptStat(0);

  gStyle->SetCanvasColor(0);
  gStyle->SetFrameBorderMode(0);
  
  gStyle->SetPalette(1);
  gStyle->SetLineColor(1);

  TString txt_passcut = "";
  if (passMVAcut) txt_passcut = "_passcut";

  TFile *file = TFile::Open("histograms_CMS-HGG_zeevalidation.root");
  file->cd();

  bdtout_cat0_Data->Rebin(2);
  bdtout_cat1_Data->Rebin(2);
  bdtout_cat2_Data->Rebin(2);
  bdtout_cat3_Data->Rebin(2);
  bdtout_cat4_Data->Rebin(2);
  bdtoutEB_cat0_Data->Rebin(2);
  bdtoutEBEE_cat0_Data->Rebin(2);
  bdtoutEE_cat0_Data->Rebin(2);

  bdtout_cat0_DYJetsToLL->Rebin(2);
  bdtout_cat1_DYJetsToLL->Rebin(2);
  bdtout_cat2_DYJetsToLL->Rebin(2);
  bdtout_cat3_DYJetsToLL->Rebin(2);
  bdtout_cat4_DYJetsToLL->Rebin(2);
  bdtoutEB_cat0_DYJetsToLL->Rebin(2);
  bdtoutEBEE_cat0_DYJetsToLL->Rebin(2);
  bdtoutEE_cat0_DYJetsToLL->Rebin(2);

  bdtout_up_cat0_DYJetsToLL->Rebin(2);
  bdtout_up_cat1_DYJetsToLL->Rebin(2);
  bdtout_up_cat2_DYJetsToLL->Rebin(2);
  bdtout_up_cat3_DYJetsToLL->Rebin(2);
  bdtout_up_cat4_DYJetsToLL->Rebin(2);
  bdtoutEB_up_cat0_DYJetsToLL->Rebin(2);
  bdtoutEBEE_up_cat0_DYJetsToLL->Rebin(2);
  bdtoutEE_up_cat0_DYJetsToLL->Rebin(2);

  bdtout_down_cat0_DYJetsToLL->Rebin(2);
  bdtout_down_cat1_DYJetsToLL->Rebin(2);
  bdtout_down_cat2_DYJetsToLL->Rebin(2);
  bdtout_down_cat3_DYJetsToLL->Rebin(2);
  bdtout_down_cat4_DYJetsToLL->Rebin(2);
  bdtoutEB_down_cat0_DYJetsToLL->Rebin(2);
  bdtoutEBEE_down_cat0_DYJetsToLL->Rebin(2);
  bdtoutEE_down_cat0_DYJetsToLL->Rebin(2);

  bdtout_cat0_Data->GetXaxis()->SetTitle("di-photon BDT output");
  bdtout_cat1_Data->GetXaxis()->SetTitle("di-photon BDT output, CiC cat0");
  bdtout_cat2_Data->GetXaxis()->SetTitle("di-photon BDT output, CiC cat1");
  bdtout_cat3_Data->GetXaxis()->SetTitle("di-photon BDT output, CiC cat2");
  bdtout_cat4_Data->GetXaxis()->SetTitle("di-photon BDT output, CiC cat3");
  bdtoutEB_cat0_Data->GetXaxis()->SetTitle("di-photon BDT output (both EB)");
  bdtoutEBEE_cat0_Data->GetXaxis()->SetTitle("di-photon BDT output (one EB, one EE)");
  bdtoutEE_cat0_Data->GetXaxis()->SetTitle("di-photon BDT output (both EE)");

  bdtout_cat0_Data->GetYaxis()->SetTitle("");
  bdtout_cat1_Data->GetYaxis()->SetTitle("");
  bdtout_cat2_Data->GetYaxis()->SetTitle("");
  bdtout_cat3_Data->GetYaxis()->SetTitle("");
  bdtout_cat4_Data->GetYaxis()->SetTitle("");
  bdtoutEB_cat0_Data->GetYaxis()->SetTitle("");
  bdtoutEBEE_cat0_Data->GetYaxis()->SetTitle("");
  bdtoutEE_cat0_Data->GetYaxis()->SetTitle("");

  bdtout_cat0_Data->GetXaxis()->SetTitleSize(0.05);
  bdtout_cat1_Data->GetXaxis()->SetTitleSize(0.05);
  bdtout_cat2_Data->GetXaxis()->SetTitleSize(0.05);
  bdtout_cat3_Data->GetXaxis()->SetTitleSize(0.05);
  bdtout_cat4_Data->GetXaxis()->SetTitleSize(0.05);
  bdtoutEB_cat0_Data->GetXaxis()->SetTitleSize(0.05);
  bdtoutEBEE_cat0_Data->GetXaxis()->SetTitleSize(0.05);
  bdtoutEE_cat0_Data->GetXaxis()->SetTitleSize(0.05);

  bdtout_cat0_DYJetsToLL->SetFillColor(38);
  bdtout_cat1_DYJetsToLL->SetFillColor(38);
  bdtout_cat2_DYJetsToLL->SetFillColor(38);
  bdtout_cat3_DYJetsToLL->SetFillColor(38);
  bdtout_cat4_DYJetsToLL->SetFillColor(38);
  bdtoutEB_cat0_DYJetsToLL->SetFillColor(38);
  bdtoutEBEE_cat0_DYJetsToLL->SetFillColor(38);
  bdtoutEE_cat0_DYJetsToLL->SetFillColor(38);

  bdtout_up_cat0_DYJetsToLL->SetLineColor(2);
  bdtout_up_cat1_DYJetsToLL->SetLineColor(2);
  bdtout_up_cat2_DYJetsToLL->SetLineColor(2);
  bdtout_up_cat3_DYJetsToLL->SetLineColor(2);
  bdtout_up_cat4_DYJetsToLL->SetLineColor(2);
  bdtoutEB_up_cat0_DYJetsToLL->SetLineColor(2);
  bdtoutEBEE_up_cat0_DYJetsToLL->SetLineColor(2);
  bdtoutEE_up_cat0_DYJetsToLL->SetLineColor(2);

  bdtout_up_cat0_DYJetsToLL->SetMarkerStyle(0);
  bdtout_up_cat1_DYJetsToLL->SetMarkerStyle(0);
  bdtout_up_cat2_DYJetsToLL->SetMarkerStyle(0);
  bdtout_up_cat3_DYJetsToLL->SetMarkerStyle(0);
  bdtout_up_cat4_DYJetsToLL->SetMarkerStyle(0);
  bdtoutEB_up_cat0_DYJetsToLL->SetMarkerStyle(0);
  bdtoutEBEE_up_cat0_DYJetsToLL->SetMarkerStyle(0);
  bdtoutEE_up_cat0_DYJetsToLL->SetMarkerStyle(0);

  bdtout_down_cat0_DYJetsToLL->SetLineColor(2);
  bdtout_down_cat1_DYJetsToLL->SetLineColor(2);
  bdtout_down_cat2_DYJetsToLL->SetLineColor(2);
  bdtout_down_cat3_DYJetsToLL->SetLineColor(2);
  bdtout_down_cat4_DYJetsToLL->SetLineColor(2);
  bdtoutEB_down_cat0_DYJetsToLL->SetLineColor(2);
  bdtoutEBEE_down_cat0_DYJetsToLL->SetLineColor(2);
  bdtoutEE_down_cat0_DYJetsToLL->SetLineColor(2);

  bdtout_cat0_Data->SetMarkerStyle(20);
  bdtout_cat1_Data->SetMarkerStyle(20);
  bdtout_cat2_Data->SetMarkerStyle(20);
  bdtout_cat3_Data->SetMarkerStyle(20);
  bdtout_cat4_Data->SetMarkerStyle(20);
  bdtoutEB_cat0_Data->SetMarkerStyle(20);
  bdtoutEBEE_cat0_Data->SetMarkerStyle(20);
  bdtoutEE_cat0_Data->SetMarkerStyle(20);

  bdtout_cat0_Data->SetMarkerSize(0.4);
  bdtout_cat1_Data->SetMarkerSize(0.4);
  bdtout_cat2_Data->SetMarkerSize(0.4);
  bdtout_cat3_Data->SetMarkerSize(0.4);
  bdtout_cat4_Data->SetMarkerSize(0.4);
  bdtoutEB_cat0_Data->SetMarkerSize(0.4);
  bdtoutEBEE_cat0_Data->SetMarkerSize(0.4);
  bdtoutEE_cat0_Data->SetMarkerSize(0.4);

  bdtout_cat0_Data->SetLineColor(1);
  bdtout_cat1_Data->SetLineColor(1);
  bdtout_cat2_Data->SetLineColor(1);
  bdtout_cat3_Data->SetLineColor(1);
  bdtout_cat4_Data->SetLineColor(1);
  bdtoutEB_cat0_Data->SetLineColor(1);
  bdtoutEBEE_cat0_Data->SetLineColor(1);
  bdtoutEE_cat0_Data->SetLineColor(1);

  if (passMVAcut) {
    bdtout_cat0_Data->GetXaxis()->SetRangeUser(-0.05,1.);
    bdtout_cat1_Data->GetXaxis()->SetRangeUser(-0.05,1.);
    bdtout_cat2_Data->GetXaxis()->SetRangeUser(-0.05,1.);
    bdtout_cat3_Data->GetXaxis()->SetRangeUser(-0.05,1.);
    bdtout_cat4_Data->GetXaxis()->SetRangeUser(-0.05,1.);
    bdtoutEB_cat0_Data->GetXaxis()->SetRangeUser(-0.05,1.);
    bdtoutEBEE_cat0_Data->GetXaxis()->SetRangeUser(-0.05,1.);
    bdtoutEE_cat0_Data->GetXaxis()->SetRangeUser(-0.05,1.);
  }

  txt = new TLatex();
  txt->SetNDC();
  txt->SetTextSize(0.08);

  hist_syst = (TH1*)bdtout_up_cat0_DYJetsToLL->Clone();
  hist_syst->SetFillStyle(3013);
  hist_syst->SetFillColor(2);

  TLegend *leg;
  leg = new TLegend(.6,.65,.87,.87);
  leg->SetBorderSize(0);
  leg->SetFillColor(10);
  leg->SetTextSize(.035);
  leg->AddEntry(bdtout_cat0_Data,"Data (19.6fb^{-1})");
  leg->AddEntry(bdtout_cat0_DYJetsToLL,"DYJetsToLL MC","F");
  leg->AddEntry(hist_syst,"MC with idmva�01","F");

  TLegend *leg2;
  leg2 = new TLegend(.2,.65,.52,.87);
  leg2->SetBorderSize(0);
  leg2->SetFillColor(10);
  leg2->SetTextSize(.035);
  leg2->AddEntry(bdtout_cat0_Data,"Data (19.6fb^{-1})");
  leg2->AddEntry(bdtout_cat0_DYJetsToLL,"DYJetsToLL MC","F");
  leg2->AddEntry(hist_syst,"MC with idmva�01","F");

  TLine *line;
  if (passMVAcut) {
    line = new TLine(-0.06,1.,1.,1.);
  } else {
    line = new TLine(-1.,1.,1.,1.);
  }
  line->SetLineColor(4);
  line->SetLineWidth(2);

  float sf_presel = bdtout_cat0_Data->Integral()/bdtout_cat0_DYJetsToLL->Integral();


  TCanvas *c_bdtout = new TCanvas("c_bdtout","BDT output",2200,800);
  c_bdtout->Divide(4,2);

  c_bdtout->cd(1);
  plotDataMC(bdtout_cat0_Data, bdtout_cat0_DYJetsToLL, bdtout_up_cat0_DYJetsToLL, bdtout_down_cat0_DYJetsToLL, passMVAcut, equalArea, leg2);

  c_bdtout->cd(2);
  plotDataMC(bdtoutEB_cat0_Data, bdtoutEB_cat0_DYJetsToLL, bdtoutEB_up_cat0_DYJetsToLL, bdtoutEB_down_cat0_DYJetsToLL, passMVAcut, equalArea, leg2);

  c_bdtout->cd(3);
  plotDataMC(bdtoutEBEE_cat0_Data, bdtoutEBEE_cat0_DYJetsToLL, bdtoutEBEE_up_cat0_DYJetsToLL, bdtoutEBEE_down_cat0_DYJetsToLL, passMVAcut, equalArea, leg);

  c_bdtout->cd(4);
  plotDataMC(bdtoutEE_cat0_Data, bdtoutEE_cat0_DYJetsToLL, bdtoutEE_up_cat0_DYJetsToLL, bdtoutEE_down_cat0_DYJetsToLL, passMVAcut, equalArea, leg);

  c_bdtout->cd(5);
  plotRatio(bdtout_cat0_Data,bdtout_cat0_DYJetsToLL,bdtout_up_cat0_DYJetsToLL,bdtout_down_cat0_DYJetsToLL, passMVAcut);
  line->Draw();

  c_bdtout->cd(6);
  plotRatio(bdtoutEB_cat0_Data,bdtoutEB_cat0_DYJetsToLL,bdtoutEB_up_cat0_DYJetsToLL,bdtoutEB_down_cat0_DYJetsToLL, passMVAcut);
  line->Draw();

  c_bdtout->cd(7);
  plotRatio(bdtoutEBEE_cat0_Data,bdtoutEBEE_cat0_DYJetsToLL,bdtoutEBEE_up_cat0_DYJetsToLL,bdtoutEBEE_down_cat0_DYJetsToLL, passMVAcut);
  line->Draw();

  c_bdtout->cd(8);
  plotRatio(bdtoutEE_cat0_Data,bdtoutEE_cat0_DYJetsToLL,bdtoutEE_up_cat0_DYJetsToLL,bdtoutEE_down_cat0_DYJetsToLL, passMVAcut);
  line->Draw();

  c_bdtout->SaveAs("bdtout"+txt_passcut+"_syst.png");


  TCanvas *c_bdtout_basecat = new TCanvas("c_bdtout_basecat","BDT output in CiC categories",2200,800);
  c_bdtout_basecat->Divide(4,2);

  c_bdtout_basecat->cd(1);
  plotDataMC(bdtout_cat1_Data, bdtout_cat1_DYJetsToLL, bdtout_up_cat1_DYJetsToLL, bdtout_down_cat1_DYJetsToLL, passMVAcut, equalArea, leg2);

  c_bdtout_basecat->cd(2);
  plotDataMC(bdtout_cat2_Data, bdtout_cat2_DYJetsToLL, bdtout_up_cat2_DYJetsToLL, bdtout_down_cat2_DYJetsToLL, passMVAcut, equalArea, leg2);

  c_bdtout_basecat->cd(3);
  plotDataMC(bdtout_cat3_Data, bdtout_cat3_DYJetsToLL, bdtout_up_cat3_DYJetsToLL, bdtout_down_cat3_DYJetsToLL, passMVAcut, equalArea, leg);

  c_bdtout_basecat->cd(4);
  plotDataMC(bdtout_cat4_Data, bdtout_cat4_DYJetsToLL, bdtout_up_cat4_DYJetsToLL, bdtout_down_cat4_DYJetsToLL, passMVAcut, equalArea, leg);

  c_bdtout_basecat->cd(5);
  plotRatio(bdtout_cat1_Data,bdtout_cat1_DYJetsToLL,bdtout_up_cat1_DYJetsToLL,bdtout_down_cat1_DYJetsToLL, passMVAcut);
  line->Draw();

  c_bdtout_basecat->cd(6);
  plotRatio(bdtout_cat2_Data,bdtout_cat2_DYJetsToLL,bdtout_up_cat2_DYJetsToLL,bdtout_down_cat2_DYJetsToLL, passMVAcut);
  line->Draw();

  c_bdtout_basecat->cd(7);
  plotRatio(bdtout_cat3_Data,bdtout_cat3_DYJetsToLL,bdtout_up_cat3_DYJetsToLL,bdtout_down_cat3_DYJetsToLL, passMVAcut);
  line->Draw();

  c_bdtout_basecat->cd(8);
  plotRatio(bdtout_cat4_Data,bdtout_cat4_DYJetsToLL,bdtout_up_cat4_DYJetsToLL,bdtout_down_cat4_DYJetsToLL, passMVAcut);
  line->Draw();

  c_bdtout_basecat->SaveAs("bdtout_basecat"+txt_passcut+"_syst.png");


}
Esempio n. 5
0
void bdtout_etaR9bins(TString r9bin, bool preselNorm=false, bool passcut=false) {

  gStyle->SetOptTitle(0);
  gStyle->SetOptStat(0);

  gStyle->SetCanvasColor(0);
  gStyle->SetFrameBorderMode(0);
  
  gStyle->SetPalette(1);

  TString r9_str;
  if (r9bin=="lowR9") {r9_str="both R9<0.9";}
  else if (r9bin=="mixedR9") {r9_str="one R9<0.9, one R9>0.9";}
  else if (r9bin=="highR9") {r9_str="both R9>0.9";}
  else {
    cout << "1st argument must be lowR9, midR9 or highR9" << endl;
    return;
  }

  TString passcut_str="";
  if (passcut) passcut_str="_passcut";

  TFile *file = TFile::Open("histograms_CMS-HGG_zeevalidation.root");
  file->cd();

  txt = new TLatex();
  txt->SetNDC();
  txt->SetTextSize(0.08);

  TH1* hist_Data[4];
  TH1* hist_MC[4];
  TH1* hist_MC_up[4];
  TH1* hist_MC_down[4];
  TH1* hist_syst[4];

  TString eta_str[4] = {"Inclusive","EBEB","EBEE","EEEE"};
  
  float sf_presel = bdtout_cat0_Data->Integral()/bdtout_cat0_DYJetsToLL->Integral();

  for (int i=0; i<4; i++) {
    TString iStr;
    iStr+=i;
    hist_Data[i] = (TH1*)(file->Get("bdtout_"+r9bin+"_cat"+iStr+"_Data"))->Clone();
    hist_MC[i] = (TH1*)(file->Get("bdtout_"+r9bin+"_cat"+iStr+"_DYJetsToLL"))->Clone();
    hist_MC_up[i] = (TH1*)(file->Get("bdtout_"+r9bin+"_up_cat"+iStr+"_DYJetsToLL"))->Clone();
    hist_MC_down[i] = (TH1*)(file->Get("bdtout_"+r9bin+"_down_cat"+iStr+"_DYJetsToLL"))->Clone();

    if (passcut) {
      hist_Data[i]->Rebin(2);
      hist_MC[i]->Rebin(2);
      hist_MC_up[i]->Rebin(2);
      hist_MC_down[i]->Rebin(2);
    } else {
      hist_Data[i]->Rebin(4);
      hist_MC[i]->Rebin(4);
      hist_MC_up[i]->Rebin(4);
      hist_MC_down[i]->Rebin(4);
    }

    hist_MC_up[i]->SetLineColor(2);
    hist_MC_down[i]->SetLineColor(2);

    hist_Data[i]->GetYaxis()->SetTitle("");
    hist_Data[i]->GetXaxis()->SetTitle("diphoMVA output ("+r9_str+", "+eta_str[i]+")");
    hist_Data[i]->GetXaxis()->SetTitleSize(0.05);
    hist_MC[i]->SetFillColor(38);
    hist_Data[i]->SetMarkerStyle(20);
    hist_Data[i]->SetMarkerSize(.5);

    hist_syst[i] = (TH1*)hist_MC_up[i]->Clone();
    hist_syst[i]->Add(hist_MC_down[i]);
    hist_syst[i]->Scale(0.5);
    for (int j=1; j<hist_syst[i]->GetNbinsX()+1; j++) {
      float up = hist_MC_up[i]->GetBinContent(j);
      float down = hist_MC_down[i]->GetBinContent(j);
      hist_syst[i]->SetBinError(j,fabs(up-down)/2.);
    }
  }

  TLegend *leg;
  leg = new TLegend(.6,.65,.87,.87);
  leg->SetBorderSize(0);
  leg->SetFillColor(10);
  leg->SetTextSize(.035);
  leg->AddEntry(hist_Data[0],"Data (19.6fb^{-1})");
  leg->AddEntry(hist_MC[0],"DYJetsToLL MC","F");
  leg->AddEntry(hist_syst[0],"MC with idmva�01","F");

  TLegend *leg2;
  leg2 = new TLegend(.2,.65,.52,.87);
  leg2->SetBorderSize(0);
  leg2->SetFillColor(10);
  leg2->SetTextSize(.035);
  leg2->AddEntry(hist_Data[0],"Data (19.6fb^{-1})");
  leg2->AddEntry(hist_MC[0],"DYJetsToLL MC","F");
  leg2->AddEntry(hist_syst[0],"MC with idmva�01","F");

  TLine *line;
  if (passcut) {
    line = new TLine(-0.05,1.,1.,1.);
  } else {
    line = new TLine(-1.,1.,1.,1.);
  }
  line->SetLineColor(4);
  line->SetLineWidth(2);

  TCanvas *c = new TCanvas("c","",2200,800);
  c->Divide(4,2);

  c->cd(1);
  plotDataMC(hist_Data[0],hist_MC[0],hist_MC_up[0],hist_MC_down[0], hist_syst[0],passcut,preselNorm,sf_presel);
  gPad->RedrawAxis();
  if (r9bin=="highR9" || !passcut) leg2->Draw();

  c->cd(2);
  plotDataMC(hist_Data[1],hist_MC[1],hist_MC_up[1],hist_MC_down[1], hist_syst[1],passcut,preselNorm,sf_presel);
  gPad->RedrawAxis();
  if (r9bin=="highR9" || !passcut) leg2->Draw();

  c->cd(3);
  plotDataMC(hist_Data[2],hist_MC[2],hist_MC_up[2],hist_MC_down[2], hist_syst[2],passcut,preselNorm,sf_presel);
  gPad->RedrawAxis();
  leg->Draw();

  c->cd(4);
  plotDataMC(hist_Data[3],hist_MC[3],hist_MC_up[3],hist_MC_down[3], hist_syst[3],passcut,preselNorm,sf_presel);
  gPad->RedrawAxis();
  leg->Draw();

  c->cd(5);
  gPad->SetGrid();
  plotRatio(hist_Data[0],hist_MC[0],hist_MC_up[0],hist_MC_down[0],passcut);
  line->Draw();

  c->cd(6);
  gPad->SetGrid();
  plotRatio(hist_Data[1],hist_MC[1],hist_MC_up[1],hist_MC_down[1],passcut);
  line->Draw();

  c->cd(7);
  gPad->SetGrid();
  plotRatio(hist_Data[2],hist_MC[2],hist_MC_up[2],hist_MC_down[2],passcut);
  line->Draw();

  c->cd(8);
  gPad->SetGrid();
  plotRatio(hist_Data[3],hist_MC[3],hist_MC_up[3],hist_MC_down[3],passcut);
  line->Draw();

  if (preselNorm) {
    c->SaveAs("bdtout_"+r9bin+passcut_str+"_preselNorm.png");
  } else {
    c->SaveAs("bdtout_"+r9bin+passcut_str+"_equalArea.png");
  }

}
Esempio n. 6
0
void diphomva_inputs(bool passMVAcut=false, bool equalArea=true) {

  gStyle->SetOptTitle(0);
  gStyle->SetOptStat(0);

  gStyle->SetCanvasColor(0);
  gStyle->SetFrameBorderMode(0);
  
  gStyle->SetPalette(1);
  gStyle->SetLineColor(1);

  TString preselNorm_str = "";
  if (!equalArea) preselNorm_str = "_preselNorm";

  TFile *file = TFile::Open("histograms_CMS-HGG_zeevalidation.root");
  file->cd();

  txt = new TLatex();
  txt->SetNDC();
  txt->SetTextSize(0.08);

  bdtout_cat0_DYJetsToLL->Rebin(2);
  bdtout_cat1_DYJetsToLL->Rebin(2);
  bdtout_cat2_DYJetsToLL->Rebin(2);
  bdtout_cat3_DYJetsToLL->Rebin(2);
  bdtout_cat4_DYJetsToLL->Rebin(2);
  bdtoutEB_cat0_DYJetsToLL->Rebin(2);
  bdtoutEBEE_cat0_DYJetsToLL->Rebin(2);
  bdtoutEE_cat0_DYJetsToLL->Rebin(2);
  bdtout_cat0_Data->Rebin(2);
  bdtout_cat1_Data->Rebin(2);
  bdtout_cat2_Data->Rebin(2);
  bdtout_cat3_Data->Rebin(2);
  bdtout_cat4_Data->Rebin(2);
  bdtoutEB_cat0_Data->Rebin(2);
  bdtoutEBEE_cat0_Data->Rebin(2);
  bdtoutEE_cat0_Data->Rebin(2);

  bdtout_cat0_Data->GetXaxis()->SetTitle("di-photon BDT output");
  bdtout_cat1_Data->GetXaxis()->SetTitle("di-photon BDT output, CiC cat0");
  bdtout_cat2_Data->GetXaxis()->SetTitle("di-photon BDT output, CiC cat1");
  bdtout_cat3_Data->GetXaxis()->SetTitle("di-photon BDT output, CiC cat2");
  bdtout_cat4_Data->GetXaxis()->SetTitle("di-photon BDT output, CiC cat3");
  bdtoutEB_cat0_Data->GetXaxis()->SetTitle("di-photon BDT output (both EB)");
  bdtoutEBEE_cat0_Data->GetXaxis()->SetTitle("di-photon BDT output (one EB, one EE)");
  bdtoutEE_cat0_Data->GetXaxis()->SetTitle("di-photon BDT output (both EE)");
  pho1_phoidMva_cat0_Data->GetXaxis()->SetTitle("lead photon ID MVA output");
  pho2_phoidMva_cat0_Data->GetXaxis()->SetTitle("sublead photon ID MVA output");
  sigmaMOverM_cat0_Data->GetXaxis()->SetTitle("#sigma_{M}/M_{#gamma#gamma} (right vertex)");
  sigmaMOverM_wrongVtx_cat0_Data->GetXaxis()->SetTitle("#sigma_{M}/M_{#gamma#gamma} (wrong vertex)");
  sigmaMOverM_EB_cat0_Data->GetXaxis()->SetTitle("#sigma_{M}/M_{#gamma#gamma} (right vertex, both EB)");
  sigmaMOverM_wrongVtx_EB_cat0_Data->GetXaxis()->SetTitle("#sigma_{M}/M_{#gamma#gamma} (wrong vertex, both EB)");
  sigmaMOverM_EE_cat0_Data->GetXaxis()->SetTitle("#sigma_{M}/M_{#gamma#gamma} (right vertex, both EE)");
  sigmaMOverM_wrongVtx_EE_cat0_Data->GetXaxis()->SetTitle("#sigma_{M}/M_{#gamma#gamma} (wrong vertex, both EE)");
  vtxProb_cat0_Data->GetXaxis()->SetTitle("Vertex probabilty");
  pho1_ptOverM_cat0_Data->GetXaxis()->SetTitle("lead p_{T}/M_{#gamma#gamma}");
  pho2_ptOverM_cat0_Data->GetXaxis()->SetTitle("sublead p_{T}/M_{#gamma#gamma}");
  pho1_eta_cat0_Data->GetXaxis()->SetTitle("lead #eta");
  pho2_eta_cat0_Data->GetXaxis()->SetTitle("sublead #eta");
  cosDeltaPhi_cat0_Data->GetXaxis()->SetTitle("cos(#Delta#phi)");

  bdtout_cat0_Data->GetYaxis()->SetTitle("");
  bdtout_cat1_Data->GetYaxis()->SetTitle("");
  bdtout_cat2_Data->GetYaxis()->SetTitle("");
  bdtout_cat3_Data->GetYaxis()->SetTitle("");
  bdtout_cat4_Data->GetYaxis()->SetTitle("");
  bdtoutEB_cat0_Data->GetYaxis()->SetTitle("");
  bdtoutEBEE_cat0_Data->GetYaxis()->SetTitle("");
  bdtoutEE_cat0_Data->GetYaxis()->SetTitle("");
  pho1_phoidMva_cat0_Data->GetYaxis()->SetTitle("");
  pho2_phoidMva_cat0_Data->GetYaxis()->SetTitle("");
  sigmaMOverM_cat0_Data->GetYaxis()->SetTitle("");
  sigmaMOverM_wrongVtx_cat0_Data->GetYaxis()->SetTitle("");
  sigmaMOverM_EB_cat0_Data->GetYaxis()->SetTitle("");
  sigmaMOverM_wrongVtx_EB_cat0_Data->GetYaxis()->SetTitle("");
  sigmaMOverM_EE_cat0_Data->GetYaxis()->SetTitle("");
  sigmaMOverM_wrongVtx_EE_cat0_Data->GetYaxis()->SetTitle("");
  vtxProb_cat0_Data->GetYaxis()->SetTitle("");
  pho1_ptOverM_cat0_Data->GetYaxis()->SetTitle("");
  pho2_ptOverM_cat0_Data->GetYaxis()->SetTitle("");
  pho1_eta_cat0_Data->GetYaxis()->SetTitle("");
  pho2_eta_cat0_Data->GetYaxis()->SetTitle("");
  cosDeltaPhi_cat0_Data->GetYaxis()->SetTitle("");

  bdtout_cat0_Data->GetXaxis()->SetTitleSize(0.05);
  bdtout_cat1_Data->GetXaxis()->SetTitleSize(0.05);
  bdtout_cat2_Data->GetXaxis()->SetTitleSize(0.05);
  bdtout_cat3_Data->GetXaxis()->SetTitleSize(0.05);
  bdtout_cat4_Data->GetXaxis()->SetTitleSize(0.05);
  bdtoutEB_cat0_Data->GetXaxis()->SetTitleSize(0.05);
  bdtoutEBEE_cat0_Data->GetXaxis()->SetTitleSize(0.05);
  bdtoutEE_cat0_Data->GetXaxis()->SetTitleSize(0.05);
  pho1_phoidMva_cat0_Data->GetXaxis()->SetTitleSize(0.05);
  pho2_phoidMva_cat0_Data->GetXaxis()->SetTitleSize(0.05);
  sigmaMOverM_cat0_Data->GetXaxis()->SetTitleSize(0.05);
  sigmaMOverM_wrongVtx_cat0_Data->GetXaxis()->SetTitleSize(0.05);
  sigmaMOverM_EB_cat0_Data->GetXaxis()->SetTitleSize(0.05);
  sigmaMOverM_wrongVtx_EB_cat0_Data->GetXaxis()->SetTitleSize(0.05);
  sigmaMOverM_EE_cat0_Data->GetXaxis()->SetTitleSize(0.05);
  sigmaMOverM_wrongVtx_EE_cat0_Data->GetXaxis()->SetTitleSize(0.05);
  vtxProb_cat0_Data->GetXaxis()->SetTitleSize(0.05);
  pho1_ptOverM_cat0_Data->GetXaxis()->SetTitleSize(0.05);
  pho2_ptOverM_cat0_Data->GetXaxis()->SetTitleSize(0.05);
  pho1_eta_cat0_Data->GetXaxis()->SetTitleSize(0.05);
  pho2_eta_cat0_Data->GetXaxis()->SetTitleSize(0.05);
  cosDeltaPhi_cat0_Data->GetXaxis()->SetTitleSize(0.05);

  bdtout_cat0_DYJetsToLL->SetFillColor(38);
  bdtout_cat1_DYJetsToLL->SetFillColor(38);
  bdtout_cat2_DYJetsToLL->SetFillColor(38);
  bdtout_cat3_DYJetsToLL->SetFillColor(38);
  bdtout_cat4_DYJetsToLL->SetFillColor(38);
  bdtoutEB_cat0_DYJetsToLL->SetFillColor(38);
  bdtoutEBEE_cat0_DYJetsToLL->SetFillColor(38);
  bdtoutEE_cat0_DYJetsToLL->SetFillColor(38);
  pho1_phoidMva_cat0_DYJetsToLL->SetFillColor(38);
  pho2_phoidMva_cat0_DYJetsToLL->SetFillColor(38);
  sigmaMOverM_cat0_DYJetsToLL->SetFillColor(38);
  sigmaMOverM_wrongVtx_cat0_DYJetsToLL->SetFillColor(38);
  sigmaMOverM_EB_cat0_DYJetsToLL->SetFillColor(38);
  sigmaMOverM_wrongVtx_EB_cat0_DYJetsToLL->SetFillColor(38);
  sigmaMOverM_EE_cat0_DYJetsToLL->SetFillColor(38);
  sigmaMOverM_wrongVtx_EE_cat0_DYJetsToLL->SetFillColor(38);
  vtxProb_cat0_DYJetsToLL->SetFillColor(38);
  pho1_ptOverM_cat0_DYJetsToLL->SetFillColor(38);
  pho2_ptOverM_cat0_DYJetsToLL->SetFillColor(38);
  pho1_eta_cat0_DYJetsToLL->SetFillColor(38);
  pho2_eta_cat0_DYJetsToLL->SetFillColor(38);
  cosDeltaPhi_cat0_DYJetsToLL->SetFillColor(38);

  bdtout_cat0_DYJetsToLL->SetLineColor(1);
  bdtoutEB_cat0_DYJetsToLL->SetLineColor(1);
  bdtoutEBEE_cat0_DYJetsToLL->SetLineColor(1);
  bdtoutEE_cat0_DYJetsToLL->SetLineColor(1);
  pho1_phoidMva_cat0_DYJetsToLL->SetLineColor(1);
  pho2_phoidMva_cat0_DYJetsToLL->SetLineColor(1);
  sigmaMOverM_cat0_DYJetsToLL->SetLineColor(1);
  sigmaMOverM_wrongVtx_cat0_DYJetsToLL->SetLineColor(1);
  sigmaMOverM_EB_cat0_DYJetsToLL->SetLineColor(1);
  sigmaMOverM_wrongVtx_EB_cat0_DYJetsToLL->SetLineColor(1);
  sigmaMOverM_EE_cat0_DYJetsToLL->SetLineColor(1);
  sigmaMOverM_wrongVtx_EE_cat0_DYJetsToLL->SetLineColor(1);
  vtxProb_cat0_DYJetsToLL->SetLineColor(1);
  pho1_ptOverM_cat0_DYJetsToLL->SetLineColor(1);
  pho2_ptOverM_cat0_DYJetsToLL->SetLineColor(1);
  pho1_eta_cat0_DYJetsToLL->SetLineColor(1);
  pho2_eta_cat0_DYJetsToLL->SetLineColor(1);
  cosDeltaPhi_cat0_DYJetsToLL->SetLineColor(1);

  bdtout_cat0_Data->SetMarkerStyle(20);
  bdtout_cat1_Data->SetMarkerStyle(20);
  bdtout_cat2_Data->SetMarkerStyle(20);
  bdtout_cat3_Data->SetMarkerStyle(20);
  bdtout_cat4_Data->SetMarkerStyle(20);
  bdtoutEB_cat0_Data->SetMarkerStyle(20);
  bdtoutEBEE_cat0_Data->SetMarkerStyle(20);
  bdtoutEE_cat0_Data->SetMarkerStyle(20);
  pho1_phoidMva_cat0_Data->SetMarkerStyle(20);
  pho2_phoidMva_cat0_Data->SetMarkerStyle(20);
  sigmaMOverM_cat0_Data->SetMarkerStyle(20);
  sigmaMOverM_wrongVtx_cat0_Data->SetMarkerStyle(20);
  sigmaMOverM_EB_cat0_Data->SetMarkerStyle(20);
  sigmaMOverM_wrongVtx_EB_cat0_Data->SetMarkerStyle(20);
  sigmaMOverM_EE_cat0_Data->SetMarkerStyle(20);
  sigmaMOverM_wrongVtx_EE_cat0_Data->SetMarkerStyle(20);
  vtxProb_cat0_Data->SetMarkerStyle(20);
  pho1_ptOverM_cat0_Data->SetMarkerStyle(20);
  pho2_ptOverM_cat0_Data->SetMarkerStyle(20);
  pho1_eta_cat0_Data->SetMarkerStyle(20);
  pho2_eta_cat0_Data->SetMarkerStyle(20);
  cosDeltaPhi_cat0_Data->SetMarkerStyle(20);

  bdtout_cat0_Data->SetMarkerSize(0.4);
  bdtout_cat1_Data->SetMarkerSize(0.4);
  bdtout_cat2_Data->SetMarkerSize(0.4);
  bdtout_cat3_Data->SetMarkerSize(0.4);
  bdtout_cat4_Data->SetMarkerSize(0.4);
  bdtoutEB_cat0_Data->SetMarkerSize(0.4);
  bdtoutEBEE_cat0_Data->SetMarkerSize(0.4);
  bdtoutEE_cat0_Data->SetMarkerSize(0.4);
  pho1_phoidMva_cat0_Data->SetMarkerSize(0.4);
  pho2_phoidMva_cat0_Data->SetMarkerSize(0.4);
  sigmaMOverM_cat0_Data->SetMarkerSize(0.4);
  sigmaMOverM_wrongVtx_cat0_Data->SetMarkerSize(0.4);
  sigmaMOverM_EB_cat0_Data->SetMarkerSize(0.4);
  sigmaMOverM_wrongVtx_EB_cat0_Data->SetMarkerSize(0.4);
  sigmaMOverM_EE_cat0_Data->SetMarkerSize(0.4);
  sigmaMOverM_wrongVtx_EE_cat0_Data->SetMarkerSize(0.4);
  vtxProb_cat0_Data->SetMarkerSize(0.4);
  pho1_ptOverM_cat0_Data->SetMarkerSize(0.4);
  pho2_ptOverM_cat0_Data->SetMarkerSize(0.4);
  pho1_eta_cat0_Data->SetMarkerSize(0.4);
  pho2_eta_cat0_Data->SetMarkerSize(0.4);
  cosDeltaPhi_cat0_Data->SetMarkerSize(0.4);

  bdtout_cat0_Data->SetLineColor(1);
  bdtout_cat1_Data->SetLineColor(1);
  bdtout_cat2_Data->SetLineColor(1);
  bdtout_cat3_Data->SetLineColor(1);
  bdtout_cat4_Data->SetLineColor(1);
  bdtoutEB_cat0_Data->SetLineColor(1);
  bdtoutEBEE_cat0_Data->SetLineColor(1);
  bdtoutEE_cat0_Data->SetLineColor(1);
  pho1_phoidMva_cat0_Data->SetLineColor(1);
  pho2_phoidMva_cat0_Data->SetLineColor(1);
  sigmaMOverM_cat0_Data->SetLineColor(1);
  sigmaMOverM_wrongVtx_cat0_Data->SetLineColor(1);
  sigmaMOverM_EB_cat0_Data->SetLineColor(1);
  sigmaMOverM_wrongVtx_EB_cat0_Data->SetLineColor(1);
  sigmaMOverM_EE_cat0_Data->SetLineColor(1);
  sigmaMOverM_wrongVtx_EE_cat0_Data->SetLineColor(1);
  vtxProb_cat0_Data->SetLineColor(1);
  pho1_ptOverM_cat0_Data->SetLineColor(1);
  pho2_ptOverM_cat0_Data->SetLineColor(1);
  pho1_eta_cat0_Data->SetLineColor(1);
  pho2_eta_cat0_Data->SetLineColor(1);
  cosDeltaPhi_cat0_Data->SetLineColor(1);

  if (passMVAcut) {
    bdtout_cat0_Data->GetXaxis()->SetRangeUser(-0.05,1.);
    bdtout_cat1_Data->GetXaxis()->SetRangeUser(-0.05,1.);
    bdtout_cat2_Data->GetXaxis()->SetRangeUser(-0.05,1.);
    bdtout_cat3_Data->GetXaxis()->SetRangeUser(-0.05,1.);
    bdtout_cat4_Data->GetXaxis()->SetRangeUser(-0.05,1.);
    bdtoutEB_cat0_Data->GetXaxis()->SetRangeUser(-0.05,1.);
    bdtoutEBEE_cat0_Data->GetXaxis()->SetRangeUser(-0.05,1.);
    bdtoutEE_cat0_Data->GetXaxis()->SetRangeUser(-0.05,1.);
  }

  TLegend *leg;
  leg = new TLegend(.6,.65,.87,.87);
  leg->SetBorderSize(0);
  leg->SetFillColor(10);
  leg->SetTextSize(.035);
  leg->AddEntry(vtxProb_cat0_Data,"Data (19.6fb^{-1})");
  leg->AddEntry(vtxProb_cat0_DYJetsToLL,"DYJetsToLL MC","F");

  TLegend *leg2;
  leg2 = new TLegend(.2,.65,.52,.87);
  leg2->SetBorderSize(0);
  leg2->SetFillColor(10);
  leg2->SetTextSize(.035);
  leg2->AddEntry(vtxProb_cat0_Data,"Data (19.6fb^{-1})");
  leg2->AddEntry(vtxProb_cat0_DYJetsToLL,"DYJetsToLL MC","F");

  float sf_presel = bdtout_cat0_Data->Integral()/bdtout_cat0_DYJetsToLL->Integral();
  cout << "sf_presel " << sf_presel << endl;

  //------------------------------------------------------------------------------

  TCanvas *c_bdtout = new TCanvas("c_bdtout","BDT output",2200,800);
  c_bdtout->Divide(4,2);

  c_bdtout->cd(1);
  float sf;
  if (passMVAcut) {
    sf = bdtout_cat0_Data->Integral(48,100)/bdtout_cat0_DYJetsToLL->Integral(48,100);
  } else {
    sf = bdtout_cat0_Data->Integral()/bdtout_cat0_DYJetsToLL->Integral();
  }
  bdtout_cat0_DYJetsToLL->Scale(sf);
  bdtout_cat0_Data->Draw("e");
  leg2->Draw();
  bdtout_cat0_DYJetsToLL->Draw("hist,same");
  bdtout_cat0_Data->Draw("e,same");
  gPad->RedrawAxis();

  c_bdtout->cd(2);
  if (passMVAcut) {
    sf = bdtoutEB_cat0_Data->Integral(48,100)/bdtoutEB_cat0_DYJetsToLL->Integral(48,100);
  } else {
    sf = bdtoutEB_cat0_Data->Integral()/bdtoutEB_cat0_DYJetsToLL->Integral();
    if (!equalArea) sf = sf_presel;
  }
  bdtoutEB_cat0_DYJetsToLL->Scale(sf);
  bdtoutEB_cat0_Data->Draw("e");
  leg2->Draw();
  bdtoutEB_cat0_DYJetsToLL->Draw("hist,same");
  bdtoutEB_cat0_Data->Draw("e,same");
  gPad->RedrawAxis();

  c_bdtout->cd(3);
  if (passMVAcut) {
    sf = bdtoutEBEE_cat0_Data->Integral(48,100)/bdtoutEBEE_cat0_DYJetsToLL->Integral(48,100);
  } else {
    sf = bdtoutEBEE_cat0_Data->Integral()/bdtoutEBEE_cat0_DYJetsToLL->Integral();
    if (!equalArea) sf = sf_presel;
  }
  bdtoutEBEE_cat0_DYJetsToLL->Scale(sf);
  bdtoutEBEE_cat0_Data->Draw("e");
  leg->Draw();
  bdtoutEBEE_cat0_DYJetsToLL->Draw("hist,same");
  bdtoutEBEE_cat0_Data->Draw("e,same");
  gPad->RedrawAxis();

  c_bdtout->cd(4);
  if (passMVAcut) {
    sf = bdtoutEE_cat0_Data->Integral(48,100)/bdtoutEE_cat0_DYJetsToLL->Integral(48,100);
  } else {
    sf = bdtoutEE_cat0_Data->Integral()/bdtoutEE_cat0_DYJetsToLL->Integral();
    if (!equalArea) sf = sf_presel;
  }
  bdtoutEE_cat0_DYJetsToLL->Scale(sf);
  bdtoutEE_cat0_Data->Draw("e");
  leg->Draw();
  bdtoutEE_cat0_DYJetsToLL->Draw("hist,same");
  bdtoutEE_cat0_Data->Draw("e,same");
  gPad->RedrawAxis();

  TLine *line;
  if (passMVAcut) {
    line = new TLine(-0.06,1.,1.,1.);
  } else {
    line = new TLine(-1.,1.,1.,1.);
  }
  line->SetLineColor(4);
  line->SetLineWidth(2);

  c_bdtout->cd(5);
  plotRatio(bdtout_cat0_Data,bdtout_cat0_DYJetsToLL);
  line->Draw();

  c_bdtout->cd(6);
  plotRatio(bdtoutEB_cat0_Data,bdtoutEB_cat0_DYJetsToLL);
  line->Draw();

  c_bdtout->cd(7);
  plotRatio(bdtoutEBEE_cat0_Data,bdtoutEBEE_cat0_DYJetsToLL);
  line->Draw();

  c_bdtout->cd(8);
  plotRatio(bdtoutEE_cat0_Data,bdtoutEE_cat0_DYJetsToLL);
  line->Draw();

  c_bdtout->SaveAs("bdtout"+preselNorm_str+".png");

  //------------------------------------------------------------------------------

  TCanvas *c_bdtout_basecat = new TCanvas("c_bdtout_basecat","BDT output in CiC categories",2200,800);
  c_bdtout_basecat->Divide(4,2);

  c_bdtout_basecat->cd(1);
  if (passMVAcut) {
    sf = bdtout_cat1_Data->Integral(48,100)/bdtout_cat1_DYJetsToLL->Integral(48,100);
  } else {
    sf = bdtout_cat1_Data->Integral()/bdtout_cat1_DYJetsToLL->Integral();
    if (!equalArea) sf = sf_presel;
  }
  bdtout_cat1_DYJetsToLL->Scale(sf);
  bdtout_cat1_Data->Draw("e");
  leg2->Draw();
  bdtout_cat1_DYJetsToLL->Draw("hist,same");
  bdtout_cat1_Data->Draw("e,same");
  gPad->RedrawAxis();

  c_bdtout_basecat->cd(2);
  if (passMVAcut) {
    sf = bdtout_cat2_Data->Integral(48,100)/bdtout_cat2_DYJetsToLL->Integral(48,100);
  } else {
    sf = bdtout_cat2_Data->Integral()/bdtout_cat2_DYJetsToLL->Integral();
    if (!equalArea) sf = sf_presel;
  }
  bdtout_cat2_DYJetsToLL->Scale(sf);
  bdtout_cat2_Data->Draw("e");
  leg2->Draw();
  bdtout_cat2_DYJetsToLL->Draw("hist,same");
  bdtout_cat2_Data->Draw("e,same");
  gPad->RedrawAxis();

  c_bdtout_basecat->cd(3);
  if (passMVAcut) {
    sf = bdtout_cat3_Data->Integral(48,100)/bdtout_cat3_DYJetsToLL->Integral(48,100);
  } else {
    sf = bdtout_cat3_Data->Integral()/bdtout_cat3_DYJetsToLL->Integral();
    if (!equalArea) sf = sf_presel;
  }
  bdtout_cat3_DYJetsToLL->Scale(sf);
  bdtout_cat3_Data->Draw("e");
  leg->Draw();
  bdtout_cat3_DYJetsToLL->Draw("hist,same");
  bdtout_cat3_Data->Draw("e,same");
  gPad->RedrawAxis();

  c_bdtout_basecat->cd(4);
  if (passMVAcut) {
    sf = bdtout_cat4_Data->Integral(48,100)/bdtout_cat4_DYJetsToLL->Integral(48,100);
  } else {
    sf = bdtout_cat4_Data->Integral()/bdtout_cat4_DYJetsToLL->Integral();
    if (!equalArea) sf = sf_presel;
  }
  bdtout_cat4_DYJetsToLL->Scale(sf);
  bdtout_cat4_Data->Draw("e");
  leg->Draw();
  bdtout_cat4_DYJetsToLL->Draw("hist,same");
  bdtout_cat4_Data->Draw("e,same");
  gPad->RedrawAxis();

  c_bdtout_basecat->cd(5);
  plotRatio(bdtout_cat1_Data,bdtout_cat1_DYJetsToLL);
  line->Draw();

  c_bdtout_basecat->cd(6);
  plotRatio(bdtout_cat2_Data,bdtout_cat2_DYJetsToLL);
  line->Draw();

  c_bdtout_basecat->cd(7);
  plotRatio(bdtout_cat3_Data,bdtout_cat3_DYJetsToLL);
  line->Draw();

  c_bdtout_basecat->cd(8);
  plotRatio(bdtout_cat4_Data,bdtout_cat4_DYJetsToLL);
  line->Draw();

  c_bdtout_basecat->SaveAs("bdtout_basecat"+preselNorm_str+".png");

  //------------------------------------------------------------------------------

  TCanvas *c_bdtin_1 = new TCanvas("c_bdtin_1","BDT input variables",1600,800);
  c_bdtin_1->Divide(4,2);

  c_bdtin_1->cd(1);
  sf = pho1_phoidMva_cat0_Data->Integral()/pho1_phoidMva_cat0_DYJetsToLL->Integral();
  pho1_phoidMva_cat0_DYJetsToLL->Scale(sf);
  pho1_phoidMva_cat0_Data->GetXaxis()->SetRangeUser(-0.3,0.6);
  pho1_phoidMva_cat0_Data->Draw("e");
  pho1_phoidMva_cat0_DYJetsToLL->Draw("hist,same");
  pho1_phoidMva_cat0_Data->Draw("e,same");
  gPad->RedrawAxis();
  leg->Draw();

  c_bdtin_1->cd(2);
  sf = pho2_phoidMva_cat0_Data->Integral()/pho2_phoidMva_cat0_DYJetsToLL->Integral();
  pho2_phoidMva_cat0_DYJetsToLL->Scale(sf);
  pho2_phoidMva_cat0_Data->GetXaxis()->SetRangeUser(-0.3,0.6);
  pho2_phoidMva_cat0_Data->Draw("e");
  pho2_phoidMva_cat0_DYJetsToLL->Draw("hist,same");
  pho2_phoidMva_cat0_Data->Draw("e,same");
  gPad->RedrawAxis();
  leg->Draw();

  c_bdtin_1->cd(3);
  gPad->SetLogy();
  sf = vtxProb_cat0_Data->Integral()/vtxProb_cat0_DYJetsToLL->Integral();
  vtxProb_cat0_DYJetsToLL->Scale(sf);
  //vtxProb_cat0_Data->GetXaxis()->SetRangeUser(0.2,1.);
  vtxProb_cat0_Data->Draw("e");
  vtxProb_cat0_DYJetsToLL->Draw("hist,same");
  vtxProb_cat0_Data->Draw("e,same");
  gPad->RedrawAxis();
  leg2->Draw();

  c_bdtin_1->cd(4);
  gPad->SetLogy();
  sf = cosDeltaPhi_cat0_Data->Integral()/cosDeltaPhi_cat0_DYJetsToLL->Integral();
  cosDeltaPhi_cat0_DYJetsToLL->Scale(sf);
  cosDeltaPhi_cat0_Data->Draw("e");
  cosDeltaPhi_cat0_DYJetsToLL->Draw("hist,same");
  cosDeltaPhi_cat0_Data->Draw("e,same");
  gPad->RedrawAxis();
  leg->Draw();

  c_bdtin_1->cd(5);
  plotRatio(pho1_phoidMva_cat0_Data,pho1_phoidMva_cat0_DYJetsToLL);
  line1 = (TLine*)line->Clone();
  line1->SetX1(-0.3);
  line1->SetX2(0.6);
  line1->Draw();

  c_bdtin_1->cd(6);
  plotRatio(pho2_phoidMva_cat0_Data,pho2_phoidMva_cat0_DYJetsToLL);
  line1->Draw();

  c_bdtin_1->cd(7);
  plotRatio(vtxProb_cat0_Data,vtxProb_cat0_DYJetsToLL);
  line->Draw();

  c_bdtin_1->cd(8);
  plotRatio(cosDeltaPhi_cat0_Data,cosDeltaPhi_cat0_DYJetsToLL);
  line->Draw();

  c_bdtin_1->SaveAs("bdtin_1.png");

  //------------------------------------------------------------------------------

  TCanvas *c_bdtin_2 = new TCanvas("c_bdtin_2","BDT input variables",1500,900);
  c_bdtin_2->Divide(4,3);
  c_bdtin_2->cd(1);

  sf = sigmaMOverM_cat0_Data->Integral()/sigmaMOverM_cat0_DYJetsToLL->Integral();
  sigmaMOverM_cat0_DYJetsToLL->Scale(sf);
  sigmaMOverM_cat0_Data->Draw("e");
  sigmaMOverM_cat0_DYJetsToLL->Draw("hist,same");
  sigmaMOverM_cat0_Data->Draw("e,same");
  gPad->RedrawAxis();
  leg->Draw();

  c_bdtin_2->cd(2);
  sf = sigmaMOverM_wrongVtx_cat0_Data->Integral()/sigmaMOverM_wrongVtx_cat0_DYJetsToLL->Integral();
  sigmaMOverM_wrongVtx_cat0_DYJetsToLL->Scale(sf);
  sigmaMOverM_wrongVtx_cat0_Data->Draw("e");
  sigmaMOverM_wrongVtx_cat0_DYJetsToLL->Draw("hist,same");
  sigmaMOverM_wrongVtx_cat0_Data->Draw("e,same");
  gPad->RedrawAxis();
  leg2->Draw();

  c_bdtin_2->cd(3);
  sf = pho1_ptOverM_cat0_Data->Integral()/pho1_ptOverM_cat0_DYJetsToLL->Integral();
  pho1_ptOverM_cat0_DYJetsToLL->Scale(sf);
  pho1_ptOverM_cat0_Data->GetXaxis()->SetRangeUser(0.2,1.2);
  pho1_ptOverM_cat0_Data->Draw("e");
  pho1_ptOverM_cat0_DYJetsToLL->Draw("hist,same");
  pho1_ptOverM_cat0_Data->Draw("e,same");
  gPad->RedrawAxis();
  leg->Draw();

  c_bdtin_2->cd(4);
  sf = pho2_ptOverM_cat0_Data->Integral()/pho2_ptOverM_cat0_DYJetsToLL->Integral();
  pho2_ptOverM_cat0_DYJetsToLL->Scale(sf);
  pho2_ptOverM_cat0_Data->GetXaxis()->SetRangeUser(0.2,.9);
  pho2_ptOverM_cat0_Data->Draw("e");
  pho2_ptOverM_cat0_DYJetsToLL->Draw("hist,same");
  pho2_ptOverM_cat0_Data->Draw("e,same");
  gPad->RedrawAxis();
  leg->Draw();

  c_bdtin_2->cd(5);
  gPad->SetLogy();
  sigmaMOverM_cat0_Data->Draw("e");
  sigmaMOverM_cat0_DYJetsToLL->Draw("hist,same");
  sigmaMOverM_cat0_Data->Draw("e,same");
  gPad->RedrawAxis();
  leg->Draw();

  c_bdtin_2->cd(6);
  gPad->SetLogy();
  sigmaMOverM_wrongVtx_cat0_Data->Draw("e");
  sigmaMOverM_wrongVtx_cat0_DYJetsToLL->Draw("hist,same");
  sigmaMOverM_wrongVtx_cat0_Data->Draw("e,same");
  gPad->RedrawAxis();

  c_bdtin_2->cd(7);
  gPad->SetLogy();
  pho1_ptOverM_cat0_Data->Draw("e");
  pho1_ptOverM_cat0_DYJetsToLL->Draw("hist,same");
  pho1_ptOverM_cat0_Data->Draw("e,same");
  gPad->RedrawAxis();
  leg->Draw();

  c_bdtin_2->cd(8);
  gPad->SetLogy();
  pho2_ptOverM_cat0_Data->Draw("e");
  pho2_ptOverM_cat0_DYJetsToLL->Draw("hist,same");
  pho2_ptOverM_cat0_Data->Draw("e,same");
  gPad->RedrawAxis();
  leg->Draw();

  c_bdtin_2->cd(9);
  plotRatio(sigmaMOverM_cat0_Data,sigmaMOverM_cat0_DYJetsToLL);
  line3 = (TLine*)line->Clone();
  line3->SetX1(0.);
  line3->SetX2(0.06);
  line3->Draw();

  c_bdtin_2->cd(10);
  plotRatio(sigmaMOverM_wrongVtx_cat0_Data,sigmaMOverM_wrongVtx_cat0_DYJetsToLL);
  line3->Draw();

  c_bdtin_2->cd(11);
  plotRatio(pho1_ptOverM_cat0_Data,pho1_ptOverM_cat0_DYJetsToLL);
  line4 = (TLine*)line->Clone();
  line4->SetX1(0.2);
  line4->SetX2(1.2);
  line4->Draw();

  c_bdtin_2->cd(12);
  plotRatio(pho2_ptOverM_cat0_Data,pho2_ptOverM_cat0_DYJetsToLL);
  line5 = (TLine*)line->Clone();
  line5->SetX1(0.2);
  line5->SetX2(0.9);
  line5->Draw();

  c_bdtin_2->SaveAs("bdtin_2.png");

  //------------------------------------------------------------------------------

  TCanvas *c_bdtin_3 = new TCanvas("c_bdtin_3","BDT input variables",1200,800);
  c_bdtin_3->Divide(2,2);
  c_bdtin_3->cd(1);

  c_bdtin_3->cd(1);
  sf = pho1_eta_cat0_Data->Integral()/pho1_eta_cat0_DYJetsToLL->Integral();
  pho1_eta_cat0_DYJetsToLL->Scale(sf);
  pho1_eta_cat0_Data->Draw("e");
  pho1_eta_cat0_DYJetsToLL->Draw("hist,same");
  pho1_eta_cat0_Data->Draw("e,same");
  gPad->RedrawAxis();

  c_bdtin_3->cd(2);
  sf = pho2_eta_cat0_Data->Integral()/pho2_eta_cat0_DYJetsToLL->Integral();
  pho2_eta_cat0_DYJetsToLL->Scale(sf);
  pho2_eta_cat0_Data->Draw("e");
  pho2_eta_cat0_DYJetsToLL->Draw("hist,same");
  pho2_eta_cat0_Data->Draw("e,same");
  gPad->RedrawAxis();

  c_bdtin_3->cd(3);
  plotRatio(pho1_eta_cat0_Data,pho1_eta_cat0_DYJetsToLL);
  line6 = (TLine*)line->Clone();
  line6->SetX1(-2.5);
  line6->SetX2(2.5);
  line6->Draw();

  c_bdtin_3->cd(4);
  plotRatio(pho2_eta_cat0_Data,pho2_eta_cat0_DYJetsToLL);
  line6->Draw();

  c_bdtin_3->SaveAs("bdtin_3.png");

  //------------------------------------------------------------------------------

  TCanvas *c_sigmam_ebee = new TCanvas("c_sigmam_ebee","BDT input variables",1500,900);
  c_sigmam_ebee->Divide(4,3);
  c_sigmam_ebee->cd(1);

  sf = sigmaMOverM_EB_cat0_Data->Integral()/sigmaMOverM_EB_cat0_DYJetsToLL->Integral();
  sigmaMOverM_EB_cat0_DYJetsToLL->Scale(sf);
  sigmaMOverM_EB_cat0_Data->Draw("e");
  sigmaMOverM_EB_cat0_DYJetsToLL->Draw("hist,same");
  sigmaMOverM_EB_cat0_Data->Draw("e,same");
  gPad->RedrawAxis();
  leg->Draw();

  c_sigmam_ebee->cd(2);
  sf = sigmaMOverM_wrongVtx_EB_cat0_Data->Integral()/sigmaMOverM_wrongVtx_EB_cat0_DYJetsToLL->Integral();
  sigmaMOverM_wrongVtx_EB_cat0_DYJetsToLL->Scale(sf);
  sigmaMOverM_wrongVtx_EB_cat0_Data->Draw("e");
  sigmaMOverM_wrongVtx_EB_cat0_DYJetsToLL->Draw("hist,same");
  sigmaMOverM_wrongVtx_EB_cat0_Data->Draw("e,same");
  gPad->RedrawAxis();
  leg->Draw();

  c_sigmam_ebee->cd(3);
  sf = sigmaMOverM_EE_cat0_Data->Integral()/sigmaMOverM_EE_cat0_DYJetsToLL->Integral();
  sigmaMOverM_EE_cat0_DYJetsToLL->Scale(sf);
  sigmaMOverM_EE_cat0_Data->Draw("e");
  sigmaMOverM_EE_cat0_DYJetsToLL->Draw("hist,same");
  sigmaMOverM_EE_cat0_Data->Draw("e,same");
  gPad->RedrawAxis();
  leg->Draw();

  c_sigmam_ebee->cd(4);
  sf = sigmaMOverM_wrongVtx_EE_cat0_Data->Integral()/sigmaMOverM_wrongVtx_EE_cat0_DYJetsToLL->Integral();
  sigmaMOverM_wrongVtx_EE_cat0_DYJetsToLL->Scale(sf);
  sigmaMOverM_wrongVtx_EE_cat0_Data->Draw("e");
  sigmaMOverM_wrongVtx_EE_cat0_DYJetsToLL->Draw("hist,same");
  sigmaMOverM_wrongVtx_EE_cat0_Data->Draw("e,same");
  gPad->RedrawAxis();
  leg2->Draw();

  c_sigmam_ebee->cd(5);
  gPad->SetLogy();
  sigmaMOverM_EB_cat0_Data->Draw("e");
  sigmaMOverM_EB_cat0_DYJetsToLL->Draw("hist,same");
  sigmaMOverM_EB_cat0_Data->Draw("e,same");
  gPad->RedrawAxis();
  leg->Draw();

  c_sigmam_ebee->cd(6);
  gPad->SetLogy();
  sigmaMOverM_wrongVtx_EB_cat0_Data->Draw("e");
  sigmaMOverM_wrongVtx_EB_cat0_DYJetsToLL->Draw("hist,same");
  sigmaMOverM_wrongVtx_EB_cat0_Data->Draw("e,same");
  gPad->RedrawAxis();

  c_sigmam_ebee->cd(7);
  gPad->SetLogy();
  sigmaMOverM_EE_cat0_Data->Draw("e");
  sigmaMOverM_EE_cat0_DYJetsToLL->Draw("hist,same");
  sigmaMOverM_EE_cat0_Data->Draw("e,same");
  gPad->RedrawAxis();
  leg->Draw();

  c_sigmam_ebee->cd(8);
  gPad->SetLogy();
  sigmaMOverM_wrongVtx_EE_cat0_Data->Draw("e");
  sigmaMOverM_wrongVtx_EE_cat0_DYJetsToLL->Draw("hist,same");
  sigmaMOverM_wrongVtx_EE_cat0_Data->Draw("e,same");
  gPad->RedrawAxis();

  c_sigmam_ebee->cd(9);
  plotRatio(sigmaMOverM_EB_cat0_Data,
	    sigmaMOverM_EB_cat0_DYJetsToLL);
  line3->Draw();

  c_sigmam_ebee->cd(10);
  plotRatio(sigmaMOverM_wrongVtx_EB_cat0_Data,
	    sigmaMOverM_wrongVtx_EB_cat0_DYJetsToLL);
  line3->Draw();

  c_sigmam_ebee->cd(11);
  plotRatio(sigmaMOverM_EE_cat0_Data,
	    sigmaMOverM_EE_cat0_DYJetsToLL);
  line3->Draw();

  c_sigmam_ebee->cd(12);
  plotRatio(sigmaMOverM_wrongVtx_EE_cat0_Data,
	    sigmaMOverM_wrongVtx_EE_cat0_DYJetsToLL);
  line3->Draw();

  c_sigmam_ebee->SaveAs("sigmam_ebee.png");


}