Example #1
0
//_____________________________________________________
void GFHistManager::AddLayers(GFHistManager* other)
{
  // append the layers from other to this, hists are not cloned, but legends?
  if(!other) return;
  const Int_t oldDepth = fDepth;
  for(Int_t iLayer = 0; iLayer < other->GetNumLayers(); ++iLayer){
    for(Int_t iPad = 0; iPad < other->GetNumHistsOf(iLayer); ++iPad){
      GFHistArray* hists = other->GetHistsOf(iLayer, iPad);
      this->AddHistsSame(hists, oldDepth + iLayer, iPad);
      TLegend* leg = other->GetLegendOf(iLayer, iPad);
      if(leg) this->AddLegend(static_cast<TLegend*>(leg->Clone()), iLayer, iPad);
    }
  }
}
Example #2
0
//_____________________________________________________
void GFHistManager::AddLayer(GFHistManager* other, Int_t layer)
{
  // append the layer 'layer' from other to this, hists are not cloned, but legends?
  if(!other || layer >= other->GetNumLayers()) return;

  const Int_t newLayer = fDepth;
  for(Int_t iPad = 0; iPad < other->GetNumHistsOf(layer); ++iPad){
    GFHistArray* hists = other->GetHistsOf(layer, iPad);
    this->AddHist(hists->At(0), newLayer);
    for(Int_t iHist = 1; iHist < hists->GetEntriesFast(); ++iHist){
      this->AddHistSame(hists->At(iHist), newLayer, iPad);
    }
    TLegend* leg = other->GetLegendOf(layer, iPad);
    if(leg) this->AddLegend(static_cast<TLegend*>(leg->Clone()), newLayer, iPad);
  }
}
Example #3
0
void plotHistHi() {



  gStyle->SetOptStat(0);

  set_plot_style();

  TFile *f = new TFile("./../root_files/hists.root");


  // sim-to-reco hists
  TH2F *hSim = (TH2F*) f->Get("hitrkEffAnalyzer/hsim"); hSim->GetYaxis()->SetRangeUser(0,10);
  TH2F *hAcc = (TH2F*) f->Get("hitrkEffAnalyzer/hacc"); hAcc->GetYaxis()->SetRangeUser(0,10);
  TH2F *hEff = (TH2F*) f->Get("hitrkEffAnalyzer/heff"); hEff->GetYaxis()->SetRangeUser(0,10);
  TH2F *hMul = (TH2F*) f->Get("hitrkEffAnalyzer/hmul"); hMul->GetYaxis()->SetRangeUser(0,10);

  // reco-to-sim hists
  TH2F *hRec = (TH2F*) f->Get("hitrkEffAnalyzer/hrec"); hRec->GetYaxis()->SetRangeUser(0,10);
  TH2F *hFak = (TH2F*) f->Get("hitrkEffAnalyzer/hfak"); hFak->GetYaxis()->SetRangeUser(0,10);
  TH2F *hSec = (TH2F*) f->Get("hitrkEffAnalyzer/hsec"); hSec->GetYaxis()->SetRangeUser(0,10);

  // ratio histograms
  TH2F *rAcc = (TH2F*) hAcc->Clone("rAcc");
  TH2F *rEff = (TH2F*) hEff->Clone("rEff");
  TH2F *rMul = (TH2F*) hMul->Clone("rMul");
  TH2F *rFak = (TH2F*) hFak->Clone("rFak");
  TH2F *rSec = (TH2F*) hSec->Clone("rSec");
  //TH2F *rDec = (TH2F*) hDec->Clone("rDec");

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

  // acceptance fraction
  TCanvas *c1 = new TCanvas("c1","Acceptance Fraction",600,500);
  gPad->SetRightMargin(0.15);
  rAcc->Divide(hAcc,hSim,1,1,"B");
  rAcc->SetStats(0);
  rAcc->SetMaximum(1.0); rAcc->SetMinimum(0.0);
  rAcc->SetTitle("Geometrical Acceptance");
  rAcc->Draw("colz");

  // reco efficiency fraction
  TCanvas *c2 = new TCanvas("c2","Reco Efficiency Fraction",600,500);
  gPad->SetRightMargin(0.15);
  rEff->Divide(hEff,hAcc,1,1,"B");
  rEff->SetStats(0);
  rEff->SetMaximum(1.0); rEff->SetMinimum(0.0);
  rEff->SetTitle("Algorithmic Efficiency");
  rEff->Draw("colz");

  // multiple reco fraction
  TCanvas *c3 = new TCanvas("c3","Multiple Reco Fraction",600,500);
  gPad->SetRightMargin(0.15);
  rMul->Divide(hMul,hAcc,1,1,"B");
  rMul->SetStats(0);
  rMul->SetMaximum(0.00049); rMul->SetMinimum(0.0);
  rMul->SetTitle("Multiple Reconstruction Fraction");
  rMul->Draw("colz");

  // fake reco fraction
  TCanvas *c4 = new TCanvas("c4","Fake Reco Fraction",600,500);
  gPad->SetRightMargin(0.15);
  rFak->Divide(hFak,hRec,1,1,"B");
  rFak->SetStats(0);
  rFak->SetMaximum(0.1); rFak->SetMinimum(0.0);
  rFak->SetTitle("Fake Reconstruction Fraction");
  rFak->Draw("colz");

  // secondary reco fraction
  TCanvas *c5 = new TCanvas("c5","Secondary Fraction",600,500);  
  gPad->SetRightMargin(0.15);
  rSec->Divide(hSec,hRec,1,1,"B");
  rSec->SetStats(0);
  rSec->SetMaximum(0.05); rSec->SetMinimum(0.0);
  rSec->SetTitle("Non-Primary Reconstruction Fraction");
  rSec->Draw("colz");

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

  // find bins corresponding to projections for below
  Int_t ptbin04=hSim->GetYaxis()->FindBin(0.91);
  Int_t ptbin20=hSim->GetYaxis()->FindBin(2.01);
  Int_t ptbins=hSim->GetYaxis()->GetNbins();
  Int_t etabin24m=hSim->GetXaxis()->FindBin(-2.39);
  Int_t etabin24p=hSim->GetXaxis()->FindBin(2.39);
  Int_t etabin10m=hSim->GetXaxis()->FindBin(-0.99);
  Int_t etabin10p=hSim->GetXaxis()->FindBin(0.99);

  cout << "etabin10m: " << etabin10m << " etabin10p: " << etabin10p << endl;
  cout << "etabin10m: " << etabin24m << " etabin10p: " << etabin24p << endl;

  // projected hists: pt > 0.9 GeV/c
  TH1D* hSimEta = (TH1D*) hSim->ProjectionX("hSimEta",ptbin04,ptbins,"e");
  TH1D* hAccEta = (TH1D*) hAcc->ProjectionX("hAccEta",ptbin04,ptbins,"e");
  TH1D* hEffEta = (TH1D*) hEff->ProjectionX("hEffEta",ptbin04,ptbins,"e");
  TH1D* hMulEta = (TH1D*) hMul->ProjectionX("hMulEta",ptbin04,ptbins,"e");
  TH1D* hRecEta = (TH1D*) hRec->ProjectionX("hRecEta",ptbin04,ptbins,"e");
  TH1D* hFakEta = (TH1D*) hFak->ProjectionX("hFakEta",ptbin04,ptbins,"e");
  TH1D* hSecEta = (TH1D*) hSec->ProjectionX("hSecEta",ptbin04,ptbins,"e");

  // projected hists: pt > 2.0 GeV/c
  TH1D* hSimEta2 = (TH1D*) hSim->ProjectionX("hSimEta2",ptbin20,ptbins,"e");
  TH1D* hAccEta2 = (TH1D*) hAcc->ProjectionX("hAccEta2",ptbin20,ptbins,"e");
  TH1D* hEffEta2 = (TH1D*) hEff->ProjectionX("hEffEta2",ptbin20,ptbins,"e");
  TH1D* hMulEta2 = (TH1D*) hMul->ProjectionX("hMulEta2",ptbin20,ptbins,"e");
  TH1D* hRecEta2 = (TH1D*) hRec->ProjectionX("hRecEta2",ptbin20,ptbins,"e");
  TH1D* hFakEta2 = (TH1D*) hFak->ProjectionX("hFakEta2",ptbin20,ptbins,"e");
  TH1D* hSecEta2 = (TH1D*) hSec->ProjectionX("hSecEta2",ptbin20,ptbins,"e");

  TH1D* hDumEta = new TH1D("hDumEta",";#eta",60,-2.4,2.4); hDumEta->SetMaximum(1.0);
  hDumEta->GetXaxis()->CenterTitle(); hDumEta->GetYaxis()->SetTitleOffset(1.8);
  TH1D* hDumEta2 = (TH1D*) hDumEta->Clone("hDumEta2"); hDumEta2->SetMaximum(0.1); 
  TH1D* hDumEta3 = (TH1D*) hDumEta->Clone("hDumEta3"); hDumEta3->SetMaximum(0.00049); 


  // projected hists: abs(eta) < 1.0
  TH1D* hSimPt  = (TH1D*) hSim->ProjectionY("hSimPt",etabin10m,etabin10p,"e");
  TH1D* hAccPt  = (TH1D*) hAcc->ProjectionY("hAccPt",etabin10m,etabin10p,"e");
  TH1D* hEffPt  = (TH1D*) hEff->ProjectionY("hEffPt",etabin10m,etabin10p,"e");
  TH1D* hMulPt  = (TH1D*) hMul->ProjectionY("hMulPt",etabin10m,etabin10p,"e");
  TH1D* hRecPt  = (TH1D*) hRec->ProjectionY("hRecPt",etabin10m,etabin10p,"e");
  TH1D* hFakPt  = (TH1D*) hFak->ProjectionY("hFakPt",etabin10m,etabin10p,"e");
  TH1D* hSecPt  = (TH1D*) hSec->ProjectionY("hSecPt",etabin10m,etabin10p,"e");

  // projected hists: abs(eta) < 2.4
  TH1D* hSimPt2  = (TH1D*) hSim->ProjectionY("hSimPt2",etabin24m,etabin24p,"e");
  TH1D* hAccPt2  = (TH1D*) hAcc->ProjectionY("hAccPt2",etabin24m,etabin24p,"e");
  TH1D* hEffPt2  = (TH1D*) hEff->ProjectionY("hEffPt2",etabin24m,etabin24p,"e");
  TH1D* hMulPt2  = (TH1D*) hMul->ProjectionY("hMulPt2",etabin24m,etabin24p,"e");
  TH1D* hRecPt2  = (TH1D*) hRec->ProjectionY("hRecPt2",etabin24m,etabin24p,"e");
  TH1D* hFakPt2  = (TH1D*) hFak->ProjectionY("hFakPt2",etabin24m,etabin24p,"e");
  TH1D* hSecPt2  = (TH1D*) hSec->ProjectionY("hSecPt2",etabin24m,etabin24p,"e");
  
  TH1D* hDumPt = new TH1D("hDumPt",";p_{T} [GeV/c]",80,0.0,10.0); hDumPt->SetMaximum(1.0);
  hDumPt->GetXaxis()->CenterTitle(); hDumPt->GetYaxis()->SetTitleOffset(1.8);
  TH1D* hDumPt2 = (TH1D*) hDumPt->Clone("hDumPt2"); hDumPt2->SetMaximum(0.1); 
  TH1D* hDumPt3 = (TH1D*) hDumPt->Clone("hDumPt3"); hDumPt3->SetMaximum(0.00049); 

  // Acceptance
  TGraphAsymmErrors *gAccEta = new TGraphAsymmErrors(); gAccEta->SetName("gAccEta");
  gAccEta->BayesDivide(hAccEta,hSimEta);
  gAccEta->SetMarkerStyle(25);
  gAccEta->SetLineStyle(2);
  gAccEta->SetLineColor(2);
  gAccEta->SetMarkerColor(2);

  TGraphAsymmErrors *gAccPt = new TGraphAsymmErrors(); gAccPt->SetName("gAccPt");
  gAccPt->BayesDivide(hAccPt,hSimPt);
  gAccPt->SetMarkerStyle(24);
  gAccPt->SetLineColor(4);
  gAccPt->SetMarkerColor(4);

  TGraphAsymmErrors *gAccEta2 = new TGraphAsymmErrors(); gAccEta2->SetName("gAccEta2");
  gAccEta2->BayesDivide(hAccEta2,hSimEta2);
  gAccEta2->SetMarkerStyle(24);
  gAccEta2->SetLineColor(4);
  gAccEta2->SetMarkerColor(4);

  TGraphAsymmErrors *gAccPt2 = new TGraphAsymmErrors(); gAccPt2->SetName("gAccPt2");
  gAccPt2->BayesDivide(hAccPt2,hSimPt2);
  gAccPt2->SetMarkerStyle(25);
  gAccPt2->SetLineStyle(2);
  gAccPt2->SetLineColor(2);
  gAccPt2->SetMarkerColor(2);

  TLegend *legEta = new TLegend(0.35,0.3,0.65,0.5);
  legEta->SetFillColor(0); legEta->SetBorderSize(0);
  legEta->AddEntry(gAccEta,"p_{T} > 0.9 GeV/c","lp");
  legEta->AddEntry(gAccEta2,"p_{T} > 2.0 GeV/c","lp");

  TLegend *legPt = new TLegend(0.4,0.3,0.6,0.5);
  legPt->SetFillColor(0); legPt->SetBorderSize(0);
  legPt->AddEntry(gAccPt2,"|#eta| < 2.4","lp");
  legPt->AddEntry(gAccPt,"|#eta| < 1.0","lp");

  TCanvas *c6 = new TCanvas("c6","Acceptance Fraction",900,500);
  c6->Divide(2,1);
  hDumEtaAcc=(TH1F*) hDumEta->Clone("hDumEtaAcc");
  hDumEtaAcc->GetYaxis()->SetTitle("Geometrical acceptance");
  hDumPtAcc=(TH1F*) hDumPt->Clone("hDumPtAcc");
  hDumPtAcc->GetYaxis()->SetTitle("Geometrical acceptance");
  c6->cd(1); hDumEtaAcc->Draw(); gAccEta->Draw("pc"); gAccEta2->Draw("pc"); legEta->Draw();
  c6->cd(2); hDumPtAcc->Draw(); gAccPt->Draw("pc"); gAccPt2->Draw("pc"); legPt->Draw();


  // Efficiency
  TGraphAsymmErrors *gEffEta = new TGraphAsymmErrors(); gEffEta->SetName("gEffEta");
  gEffEta->BayesDivide(hEffEta,hAccEta);
  gEffEta->SetMarkerStyle(25);
  gEffEta->SetLineStyle(2);
  gEffEta->SetLineColor(2);
  gEffEta->SetMarkerColor(2);

  TGraphAsymmErrors *gEffPt = new TGraphAsymmErrors(); gEffPt->SetName("gEffPt");
  gEffPt->BayesDivide(hEffPt,hAccPt);
  gEffPt->SetMarkerStyle(24);
  gEffPt->SetLineColor(4);
  gEffPt->SetMarkerColor(4);

  TGraphAsymmErrors *gEffEta2 = new TGraphAsymmErrors(); gEffEta2->SetName("gEffEta2");
  gEffEta2->BayesDivide(hEffEta2,hAccEta2);
  gEffEta2->SetMarkerStyle(24);
  gEffEta2->SetLineColor(4);
  gEffEta2->SetMarkerColor(4);

  TGraphAsymmErrors *gEffPt2 = new TGraphAsymmErrors(); gEffPt2->SetName("gEffPt2");
  gEffPt2->BayesDivide(hEffPt2,hAccPt2);
  gEffPt2->SetMarkerStyle(25);
  gEffPt2->SetLineStyle(2);
  gEffPt2->SetLineColor(2);
  gEffPt2->SetMarkerColor(2);

  TCanvas *c7 = new TCanvas("c7","Efficiency Fraction",900,500);
  c7->Divide(2,1);
  hDumEtaEff=(TH1F*) hDumEta->Clone("hDumEtaEff");
  hDumEtaEff->GetYaxis()->SetTitle("Algorithmic efficiency");
  hDumPtEff=(TH1F*) hDumPt->Clone("hDumPtEff");
  hDumPtEff->GetYaxis()->SetTitle("Algorithmic efficiency");
  c7->cd(1); hDumEtaEff->Draw(); gEffEta->Draw("pc"); gEffEta2->Draw("pc"); legEta->Draw();
  c7->cd(2); hDumPtEff->Draw(); gEffPt->Draw("pc"); gEffPt2->Draw("pc"); legPt->Draw();

  // Multiple Reco
  TGraphAsymmErrors *gMulEta = new TGraphAsymmErrors(); gMulEta->SetName("gMulEta");
  gMulEta->BayesDivide(hMulEta,hAccEta);
  gMulEta->SetMarkerStyle(25);
  gMulEta->SetLineStyle(2);
  gMulEta->SetLineColor(2);
  gMulEta->SetMarkerColor(2);

  TGraphAsymmErrors *gMulPt = new TGraphAsymmErrors(); gMulPt->SetName("gMulPt");
  gMulPt->BayesDivide(hMulPt,hAccPt);
  gMulPt->SetMarkerStyle(24);
  gMulPt->SetLineColor(4);
  gMulPt->SetMarkerColor(4);

  TGraphAsymmErrors *gMulEta2 = new TGraphAsymmErrors(); gMulEta2->SetName("gMulEta2");
  gMulEta2->BayesDivide(hMulEta2,hAccEta2);
  gMulEta2->SetMarkerStyle(24);
  gMulEta2->SetLineColor(4);
  gMulEta2->SetMarkerColor(4);

  TGraphAsymmErrors *gMulPt2 = new TGraphAsymmErrors(); gMulPt2->SetName("gMulPt2");
  gMulPt2->BayesDivide(hMulPt2,hAccPt2);
  gMulPt2->SetMarkerStyle(25);
  gMulPt2->SetLineStyle(2);
  gMulPt2->SetLineColor(2);
  gMulPt2->SetMarkerColor(2);

  TCanvas *c8 = new TCanvas("c8","Multiple Fraction",900,500);
  c8->Divide(2,1);
  hDumEtaMul=(TH1F*) hDumEta3->Clone("hDumEtaMul");
  hDumEtaMul->GetYaxis()->SetTitle("Multiple Reconstruction Fraction");
  hDumPtMul=(TH1F*) hDumPt3->Clone("hDumPtMul");
  hDumPtMul->GetYaxis()->SetTitle("Multiple Reconstruction Fraction");
  legEta2 = (TLegend*) legEta->Clone(); legEta2->SetY1(0.65); legEta2->SetY2(0.85);
  legPt2 = (TLegend*) legPt->Clone(); legPt2->SetY1(0.65); legPt2->SetY2(0.85);
  c8->cd(1); hDumEtaMul->Draw(); gMulEta->Draw("pc"); gMulEta2->Draw("pc"); legEta2->Draw();
  c8->cd(2); hDumPtMul->Draw(); gMulPt->Draw("pc"); gMulPt2->Draw("pc"); legPt2->Draw();

  // Fakes
  TGraphAsymmErrors *gFakEta = new TGraphAsymmErrors();  gFakEta->SetName("gFakEta");
  gFakEta->BayesDivide(hFakEta,hRecEta);
  gFakEta->SetMarkerStyle(25);
  gFakEta->SetLineStyle(2);
  gFakEta->SetLineColor(2);
  gFakEta->SetMarkerColor(2);

  TGraphAsymmErrors *gFakPt = new TGraphAsymmErrors(); gFakPt->SetName("gFakPt");
  gFakPt->BayesDivide(hFakPt,hRecPt);
  gFakPt->SetMarkerStyle(24);
  gFakPt->SetLineColor(4);
  gFakPt->SetMarkerColor(4);

  TGraphAsymmErrors *gFakEta2 = new TGraphAsymmErrors(); gFakEta2->SetName("gFakEta2");
  gFakEta2->BayesDivide(hFakEta2,hRecEta2);
  gFakEta2->SetMarkerStyle(24);
  gFakEta2->SetLineColor(4);
  gFakEta2->SetMarkerColor(4);

  TGraphAsymmErrors *gFakPt2 = new TGraphAsymmErrors();  gFakPt2->SetName("gFakPt2");
  gFakPt2->BayesDivide(hFakPt2,hRecPt2);
  gFakPt2->SetMarkerStyle(25);
  gFakPt2->SetLineStyle(2);
  gFakPt2->SetLineColor(2);
  gFakPt2->SetMarkerColor(2);

  TCanvas *c9 = new TCanvas("c9","Fake Fraction",900,500);
  c9->Divide(2,1);
  hDumEtaFak=(TH1F*) hDumEta2->Clone("hDumEtaMul");
  hDumEtaFak->GetYaxis()->SetTitle("Fake Reconstruction Fraction");
  hDumPtFak=(TH1F*) hDumPt2->Clone("hDumPtMul");
  hDumPtFak->GetYaxis()->SetTitle("Fake Reconstruction Fraction");
  c9->cd(1); hDumEtaFak->Draw(); gFakEta->Draw("pc"); gFakEta2->Draw("pc"); legEta2->Draw();
  c9->cd(2); hDumPtFak->Draw(); gFakPt->Draw("pc"); gFakPt2->Draw("pc"); legPt2->Draw();

  // Secondaries
  TGraphAsymmErrors *gSecEta = new TGraphAsymmErrors(); gSecEta->SetName("gSecEta");
  gSecEta->BayesDivide(hSecEta,hRecEta);
  gSecEta->SetMarkerStyle(25);
  gSecEta->SetLineStyle(2);
  gSecEta->SetLineColor(2);
  gSecEta->SetMarkerColor(2);

  TGraphAsymmErrors *gSecPt = new TGraphAsymmErrors(); gSecPt->SetName("gSecPt");
  gSecPt->BayesDivide(hSecPt,hRecPt);
  gSecPt->SetMarkerStyle(24);
  gSecPt->SetLineColor(4);
  gSecPt->SetMarkerColor(4);

  TGraphAsymmErrors *gSecEta2 = new TGraphAsymmErrors(); gSecEta2->SetName("gSecEta2");
  gSecEta2->BayesDivide(hSecEta2,hRecEta2);
  gSecEta2->SetMarkerStyle(24);
  gSecEta2->SetLineColor(4);
  gSecEta2->SetMarkerColor(4);

  TGraphAsymmErrors *gSecPt2 = new TGraphAsymmErrors();  gSecPt2->SetName("gSecPt2");
  gSecPt2->BayesDivide(hSecPt2,hRecPt2);
  gSecPt2->SetMarkerStyle(25);
  gSecPt2->SetLineStyle(2);
  gSecPt2->SetLineColor(2);
  gSecPt2->SetMarkerColor(2);

  TCanvas *c10 = new TCanvas("c10","Secondary Fraction",900,500);
  c10->Divide(2,1);
  hDumEtaSec=(TH1F*) hDumEta2->Clone("hDumEtaMul");
  hDumEtaSec->GetYaxis()->SetTitle("Non-Primary Reconstruction Fraction");
  hDumPtSec=(TH1F*) hDumPt2->Clone("hDumPtMul");
  hDumPtSec->GetYaxis()->SetTitle("Non-Primary Reconstruction Fraction");
  c10->cd(1); hDumEtaSec->Draw(); gSecEta->Draw("pc"); gSecEta2->Draw("pc"); legEta2->Draw();
  c10->cd(2); hDumPtSec->Draw(); gSecPt->Draw("pc"); gSecPt2->Draw("pc"); legPt2->Draw();

  /*
  printCanvases(c1,"hitrk_can1",0,1);
  printCanvases(c2,"hitrk_can2",0,1);
  printCanvases(c3,"hitrk_can3",0,1);
  printCanvases(c4,"hitrk_can4",0,1);
  printCanvases(c5,"hitrk_can5",0,1);
  printCanvases(c6,"hitrk_can6",0,1);
  printCanvases(c7,"hitrk_can7",0,1);
  printCanvases(c8,"hitrk_can8",0,1);
  printCanvases(c9,"hitrk_can9",0,1);
  printCanvases(c10,"hitrk_can10",0,1);
  */


  /*
  TFile *f = new TFile("trkEffPY8.root","RECREATE");
  gAccPt->Write(); gAccPt2->Write(); gAccEta->Write(); gAccEta2->Write();
  gEffPt->Write(); gEffPt2->Write(); gEffEta->Write(); gEffEta2->Write();
  gMulPt->Write(); gMulPt2->Write(); gMulEta->Write(); gMulEta2->Write();
  gFakPt->Write(); gFakPt2->Write(); gFakEta->Write(); gFakEta2->Write();
  gSecPt->Write(); gSecPt2->Write(); gSecEta->Write(); gSecEta2->Write();
  f->Close();
  */
}
Example #4
0
void plotHist3D() {

  RiceStyle();

  gStyle->SetOptStat(0);

  TFile *f = new TFile("../rootfile/PbPb_eff_MC_v1.root");

  char ndir[256] = "HITrackCorrections";
  double ptmax = 300.;

  // sim-to-reco hists
  TH3F *hSim = (TH3F*) f->Get(Form("%s/hsim3D",ndir)); hSim->GetYaxis()->SetRangeUser(0.2,ptmax);
  TH3F *hEff = (TH3F*) f->Get(Form("%s/heff3D",ndir)); hEff->GetYaxis()->SetRangeUser(0.2,ptmax);
  TH3F *hMul = (TH3F*) f->Get(Form("%s/hmul3D",ndir)); hMul->GetYaxis()->SetRangeUser(0.2,ptmax);

  // reco-to-sim hists
  TH3F *hRec = (TH3F*) f->Get(Form("%s/hrec3D",ndir)); hRec->GetYaxis()->SetRangeUser(0.2,ptmax);
  TH3F *hFak = (TH3F*) f->Get(Form("%s/hfak3D",ndir)); hFak->GetYaxis()->SetRangeUser(0.2,ptmax);
  TH3F *hSec = (TH3F*) f->Get(Form("%s/hsec3D",ndir)); hSec->GetYaxis()->SetRangeUser(0.2,ptmax);

  // ratio histograms
  TH3F *rEff = (TH3F*) hEff->Clone("rEff");
  TH3F *rMul = (TH3F*) hMul->Clone("rMul");
  TH3F *rFak = (TH3F*) hFak->Clone("rFak");
  TH3F *rSec = (TH3F*) hSec->Clone("rSec");

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

  // find bins corresponding to projections for below
  int ptbin04=hSim->GetYaxis()->FindBin(0.41);
  int ptbin10=hSim->GetYaxis()->FindBin(1.01);
  int ptbins=hSim->GetYaxis()->GetNbins();

  int etabin24m=hSim->GetXaxis()->FindBin(-2.39);
  int etabin24p=hSim->GetXaxis()->FindBin(2.39);
  int etabin10m=hSim->GetXaxis()->FindBin(-0.99);
  int etabin10p=hSim->GetXaxis()->FindBin(0.99);

  int occbin0 = hSim->GetZaxis()->FindBin(0);
  int occbin50 = hSim->GetZaxis()->FindBin(99);
  int occbin51 = hSim->GetZaxis()->FindBin(100);
  int occbin100 = hSim->GetZaxis()->FindBin(199);

  cout << "etabin10m: " << etabin10m << " etabin10p: " << etabin10p << endl;
  cout << "etabin10m: " << etabin24m << " etabin10p: " << etabin24p << endl;
  cout << "occbin0: " << occbin0 << "occbin50: " << occbin50 << endl;

  // projected hists: pt > 1.0 GeV/c, cBin (0,50%)
  TH1D* hSimEta = (TH1D*) hSim->ProjectionX("hSimEta",ptbin10,ptbins,occbin0,occbin50,"e");
  TH1D* hEffEta = (TH1D*) hEff->ProjectionX("hEffEta",ptbin10,ptbins,occbin0,occbin50,"e");
  TH1D* hMulEta = (TH1D*) hMul->ProjectionX("hMulEta",ptbin10,ptbins,occbin0,occbin50,"e");
  TH1D* hRecEta = (TH1D*) hRec->ProjectionX("hRecEta",ptbin10,ptbins,occbin0,occbin50,"e");
  TH1D* hFakEta = (TH1D*) hFak->ProjectionX("hFakEta",ptbin10,ptbins,occbin0,occbin50,"e");
  TH1D* hSecEta = (TH1D*) hSec->ProjectionX("hSecEta",ptbin10,ptbins,occbin0,occbin50,"e");

  // projected hists: pt > 1.0 GeV/c. cBin (50-100%)
  TH1D* hSimEta2 = (TH1D*) hSim->ProjectionX("hSimEta2",ptbin10,ptbins,occbin50,occbin100,"e");
  TH1D* hEffEta2 = (TH1D*) hEff->ProjectionX("hEffEta2",ptbin10,ptbins,occbin50,occbin100,"e");
  TH1D* hMulEta2 = (TH1D*) hMul->ProjectionX("hMulEta2",ptbin10,ptbins,occbin50,occbin100,"e");
  TH1D* hRecEta2 = (TH1D*) hRec->ProjectionX("hRecEta2",ptbin10,ptbins,occbin50,occbin100,"e");
  TH1D* hFakEta2 = (TH1D*) hFak->ProjectionX("hFakEta2",ptbin10,ptbins,occbin50,occbin100,"e");
  TH1D* hSecEta2 = (TH1D*) hSec->ProjectionX("hSecEta2",ptbin10,ptbins,occbin50,occbin100,"e");

  TH1D* hDumEta = new TH1D("hDumEta",";#eta",60,-2.4,2.4); hDumEta->SetMaximum(1.0); hDumEta->SetTitle("p_{T} > 1.0");
  hDumEta->GetXaxis()->CenterTitle(); hDumEta->GetYaxis()->SetTitleOffset(1.8);
  TH1D* hDumEta2 = (TH1D*) hDumEta->Clone("hDumEta2"); hDumEta2->SetMaximum(0.1); 
  TH1D* hDumEta3 = (TH1D*) hDumEta->Clone("hDumEta3"); hDumEta3->SetMaximum(0.00049); 

  // projected hists: abs(eta) < 1.0, cBin(0-50%)
  TH1D* hSimPt  = (TH1D*) hSim->ProjectionY("hSimPt",etabin10m,etabin10p,occbin0,occbin50,"e");
  TH1D* hEffPt  = (TH1D*) hEff->ProjectionY("hEffPt",etabin10m,etabin10p,occbin0,occbin50,"e");
  TH1D* hMulPt  = (TH1D*) hMul->ProjectionY("hMulPt",etabin10m,etabin10p,occbin0,occbin50,"e");
  TH1D* hRecPt  = (TH1D*) hRec->ProjectionY("hRecPt",etabin10m,etabin10p,occbin0,occbin50,"e");
  TH1D* hFakPt  = (TH1D*) hFak->ProjectionY("hFakPt",etabin10m,etabin10p,occbin0,occbin50,"e");
  TH1D* hSecPt  = (TH1D*) hSec->ProjectionY("hSecPt",etabin10m,etabin10p,occbin0,occbin50,"e");

  // projected hists: abs(eta) < 1.0, cBin(50-100%)
  TH1D* hSimPt2  = (TH1D*) hSim->ProjectionY("hSimPt2",etabin10m,etabin10p,occbin50,occbin100,"e");
  TH1D* hEffPt2  = (TH1D*) hEff->ProjectionY("hEffPt2",etabin10m,etabin10p,occbin50,occbin100,"e");
  TH1D* hMulPt2  = (TH1D*) hMul->ProjectionY("hMulPt2",etabin10m,etabin10p,occbin50,occbin100,"e");
  TH1D* hRecPt2  = (TH1D*) hRec->ProjectionY("hRecPt2",etabin10m,etabin10p,occbin50,occbin100,"e");
  TH1D* hFakPt2  = (TH1D*) hFak->ProjectionY("hFakPt2",etabin10m,etabin10p,occbin50,occbin100,"e");
  TH1D* hSecPt2  = (TH1D*) hSec->ProjectionY("hSecPt2",etabin10m,etabin10p,occbin50,occbin100,"e");
  
  TH1D* hDumPt = new TH1D("hDumPt",";p_{T} [GeV/c]",80,0.1,300.0); hDumPt->SetMaximum(1.0);
  hDumPt->GetXaxis()->CenterTitle(); hDumPt->GetYaxis()->SetTitleOffset(1.8); hDumPt->SetTitle("|#eta| < 1");
  TH1D* hDumPt2 = (TH1D*) hDumPt->Clone("hDumPt2"); hDumPt2->SetMaximum(0.1); 
  TH1D* hDumPt3 = (TH1D*) hDumPt->Clone("hDumPt3"); hDumPt3->SetMaximum(0.00049); 

  // Efficiency
  TGraphAsymmErrors *gEffEta = new TGraphAsymmErrors(); gEffEta->SetName("gEffEta");
  gEffEta->BayesDivide(hEffEta,hSimEta);
  gEffEta->SetMarkerStyle(25);
  gEffEta->SetLineStyle(2);
  gEffEta->SetLineColor(2);
  gEffEta->SetMarkerColor(2);

  TGraphAsymmErrors *gEffPt = new TGraphAsymmErrors(); gEffPt->SetName("gEffPt");
  gEffPt->BayesDivide(hEffPt,hSimPt);
  gEffPt->SetMarkerStyle(25);
  gEffPt->SetLineColor(2);
  gEffPt->SetMarkerColor(2);

  TGraphAsymmErrors *gEffEta2 = new TGraphAsymmErrors(); gEffEta2->SetName("gEffEta2");
  gEffEta2->BayesDivide(hEffEta2,hSimEta2);
  gEffEta2->SetMarkerStyle(24);
  gEffEta2->SetLineColor(4);
  gEffEta2->SetMarkerColor(4);

  TGraphAsymmErrors *gEffPt2 = new TGraphAsymmErrors(); gEffPt2->SetName("gEffPt2");
  gEffPt2->BayesDivide(hEffPt2,hSimPt2);
  gEffPt2->SetMarkerStyle(24);
  gEffPt2->SetLineStyle(4);
  gEffPt2->SetLineColor(4);
  gEffPt2->SetMarkerColor(4);

  TLegend *legEta = new TLegend(0.35,0.15,0.65,0.30);
  legEta->SetFillColor(0); legEta->SetBorderSize(0);
  legEta->AddEntry(gEffEta,"0-50%","lp");
  legEta->AddEntry(gEffEta2,"50-100%","lp");

  TLegend *legPt = new TLegend(0.35,0.2,0.65,0.35);
  legPt->SetFillColor(0); legPt->SetBorderSize(0);
  legPt->AddEntry(gEffPt,"0-50%","lp");
  legPt->AddEntry(gEffPt2,"50-100%","lp");

  TCanvas* c7 = makeMultiCanvas("c7", "Efficiency Fraction", 2,1 );
  hDumEtaEff=(TH1F*) hDumEta->Clone("hDumEtaEff"); fixedFontHist1D(hDumEtaEff,1.05,1.2);
  hDumEtaEff->GetYaxis()->SetTitle("Absolute efficiency");
  hDumPtEff=(TH1F*) hDumPt->Clone("hDumPtEff"); fixedFontHist1D(hDumPtEff,1.05,1.2);
  hDumPtEff->GetYaxis()->SetTitle("Absolute efficiency");
  c7->cd(1); gPad->SetTicks(); c7->GetPad(1)->SetLeftMargin(0.12); c7->GetPad(1)->SetBottomMargin(0.13); c7->GetPad(1)->SetLogx(0); hDumEtaEff->Draw(); gEffEta->Draw("pc"); gEffEta2->Draw("pc"); legEta->Draw();
  c7->cd(2); gPad->SetTicks(); c7->GetPad(2)->SetLeftMargin(0.12); c7->GetPad(2)->SetBottomMargin(0.13); c7->GetPad(2)->SetLogx(); hDumPtEff->Draw(); gEffPt->Draw("pc"); gEffPt2->Draw("pc"); legPt->Draw();
  saveCanvas(c7, "files", "AbsoluteEfficiency3D");

  // Multiple Reco
  TGraphAsymmErrors *gMulEta = new TGraphAsymmErrors(); gMulEta->SetName("gMulEta");
  gMulEta->BayesDivide(hMulEta,hSimEta);
  gMulEta->SetMarkerStyle(25);
  gMulEta->SetLineStyle(2);
  gMulEta->SetLineColor(2);
  gMulEta->SetMarkerColor(2);

  TGraphAsymmErrors *gMulPt = new TGraphAsymmErrors(); gMulPt->SetName("gMulPt");
  gMulPt->BayesDivide(hMulPt,hSimPt);
  gMulPt->SetMarkerStyle(25);
  gMulPt->SetLineColor(2);
  gMulPt->SetMarkerColor(2);

  TGraphAsymmErrors *gMulEta2 = new TGraphAsymmErrors(); gMulEta2->SetName("gMulEta2");
  gMulEta2->BayesDivide(hMulEta2,hSimEta2);
  gMulEta2->SetMarkerStyle(24);
  gMulEta2->SetLineColor(4);
  gMulEta2->SetMarkerColor(4);

  TGraphAsymmErrors *gMulPt2 = new TGraphAsymmErrors(); gMulPt2->SetName("gMulPt2");
  gMulPt2->BayesDivide(hMulPt2,hSimPt2);
  gMulPt2->SetMarkerStyle(24);
  gMulPt2->SetLineStyle(4);
  gMulPt2->SetLineColor(4);
  gMulPt2->SetMarkerColor(4);

  TCanvas *c8 = makeMultiCanvas("c8","Multiple Fraction", 2,1);
  hDumEtaMul=(TH1F*) hDumEta3->Clone("hDumEtaMul"); fixedFontHist1D(hDumEtaMul, 1.05,1.2); hDumEtaMul->GetYaxis()->SetRangeUser(0,0.0009);
  hDumEtaMul->GetYaxis()->SetTitle("Multiple Reconstruction Fraction");
  hDumPtMul=(TH1F*) hDumPt3->Clone("hDumPtMul"); fixedFontHist1D(hDumPtMul, 1.05, 1.2); hDumPtMul->GetYaxis()->SetRangeUser(0,0.0009);
  hDumPtMul->GetYaxis()->SetTitle("Multiple Reconstruction Fraction");
  legEta2 = (TLegend*) legEta->Clone(); legEta2->SetY1(0.65); legEta2->SetY2(0.85);
  legPt2 = (TLegend*) legPt->Clone(); legPt2->SetY1(0.65); legPt2->SetY2(0.85);
  c8->cd(1); gPad->SetLogx(0); gPad->SetTicks(); c8->GetPad(1)->SetLeftMargin(0.12); c8->GetPad(1)->SetBottomMargin(0.13); hDumEtaMul->Draw(); gMulEta->Draw("pc"); gMulEta2->Draw("pc"); legEta2->Draw();
  c8->cd(2); gPad->SetLogx(1); gPad->SetTicks(); c8->GetPad(2)->SetLeftMargin(0.12); c8->GetPad(2)->SetBottomMargin(0.13); hDumPtMul->Draw(); gMulPt->Draw("pc"); gMulPt2->Draw("pc"); legPt2->Draw();
  saveCanvas(c8, "files", "MultipleReconstruction3D");
  
  // Fakes
  TGraphAsymmErrors *gFakEta = new TGraphAsymmErrors();  gFakEta->SetName("gFakEta");
  gFakEta->BayesDivide(hFakEta,hRecEta);
  gFakEta->SetMarkerStyle(25);
  gFakEta->SetLineStyle(2);
  gFakEta->SetLineColor(2);
  gFakEta->SetMarkerColor(2);

  TGraphAsymmErrors *gFakPt = new TGraphAsymmErrors(); gFakPt->SetName("gFakPt");
  gFakPt->BayesDivide(hFakPt,hRecPt);
  gFakPt->SetMarkerStyle(25);
  gFakPt->SetLineColor(2);
  gFakPt->SetMarkerColor(2);

  TGraphAsymmErrors *gFakEta2 = new TGraphAsymmErrors(); gFakEta2->SetName("gFakEta2");
  gFakEta2->BayesDivide(hFakEta2,hRecEta2);
  gFakEta2->SetMarkerStyle(24);
  gFakEta2->SetLineColor(4);
  gFakEta2->SetMarkerColor(4);

  TGraphAsymmErrors *gFakPt2 = new TGraphAsymmErrors();  gFakPt2->SetName("gFakPt2");
  gFakPt2->BayesDivide(hFakPt2,hRecPt2);
  gFakPt2->SetMarkerStyle(24);
  gFakPt2->SetLineStyle(4);
  gFakPt2->SetLineColor(4);
  gFakPt2->SetMarkerColor(4);

  TCanvas* c9 = makeMultiCanvas("c9", "Fake Fraction", 2,1);
  hDumEtaFak=(TH1F*) hDumEta2->Clone("hDumEtaMul"); fixedFontHist1D(hDumEtaFak, 1.05,1.2); hDumEtaFak->GetYaxis()->SetRangeUser(0.,0.09);
  hDumEtaFak->GetYaxis()->SetTitle("Fake Reconstruction Fraction");
  hDumPtFak=(TH1F*) hDumPt2->Clone("hDumPtMul"); fixedFontHist1D(hDumPtFak, 1.05,1.2); hDumPtFak->GetYaxis()->SetRangeUser(0,1);
  hDumPtFak->GetYaxis()->SetTitle("Fake Reconstruction Fraction");
  c9->cd(1); hDumEtaFak->Draw(); gFakEta->Draw("pc"); gFakEta2->Draw("pc"); legEta2->Draw();
  gPad->SetTicks(); gPad->SetLeftMargin(0.12); gPad->SetBottomMargin(0.13);
  c9->cd(2); hDumPtFak->Draw(); gFakPt->Draw("pc"); gFakPt2->Draw("pc"); legPt2->Draw();
  gPad->SetTicks(); gPad->SetLeftMargin(0.12); gPad->SetBottomMargin(0.13); gPad->SetLogx(1);
  saveCanvas(c9, "files", "FakeRate3D");

  // Secondaries
  TGraphAsymmErrors *gSecEta = new TGraphAsymmErrors(); gSecEta->SetName("gSecEta");
  gSecEta->BayesDivide(hSecEta,hRecEta);
  gSecEta->SetMarkerStyle(25);
  gSecEta->SetLineStyle(2);
  gSecEta->SetLineColor(2);
  gSecEta->SetMarkerColor(2);

  TGraphAsymmErrors *gSecPt = new TGraphAsymmErrors(); gSecPt->SetName("gSecPt");
  gSecPt->BayesDivide(hSecPt,hRecPt);
  gSecPt->SetMarkerStyle(25);
  gSecPt->SetLineColor(2);
  gSecPt->SetMarkerColor(2);

  TGraphAsymmErrors *gSecEta2 = new TGraphAsymmErrors(); gSecEta2->SetName("gSecEta2");
  gSecEta2->BayesDivide(hSecEta2,hRecEta2);
  gSecEta2->SetMarkerStyle(24);
  gSecEta2->SetLineColor(4);
  gSecEta2->SetMarkerColor(4);

  TGraphAsymmErrors *gSecPt2 = new TGraphAsymmErrors();  gSecPt2->SetName("gSecPt2");
  gSecPt2->BayesDivide(hSecPt2,hRecPt2);
  gSecPt2->SetMarkerStyle(24);
  gSecPt2->SetLineStyle(4);
  gSecPt2->SetLineColor(4);
  gSecPt2->SetMarkerColor(4);

  TCanvas* c10 = makeMultiCanvas("c10", "Secondary Fraction", 2, 1);
  hDumEtaSec=(TH1F*) hDumEta2->Clone("hDumEtaMul"); fixedFontHist1D(hDumEtaSec, 1.05,1.3); hDumEtaSec->GetYaxis()->SetRangeUser(0.,0.012);
  hDumEtaSec->GetYaxis()->SetTitle("Non-Primary Reconstruction Fraction");
  hDumPtSec=(TH1F*) hDumPt2->Clone("hDumPtMul"); fixedFontHist1D(hDumPtSec, 1.05, 1.3);hDumPtSec->GetYaxis()->SetRangeUser(0.,0.1);
  hDumPtSec->GetYaxis()->SetTitle("Non-Primary Reconstruction Fraction");
  c10->cd(1); hDumEtaSec->Draw(); gSecEta->Draw("pc"); gSecEta2->Draw("pc"); legEta2->Draw();
  gPad->SetTicks(); gPad->SetLeftMargin(0.15); gPad->SetBottomMargin(0.13); 
  c10->cd(2); hDumPtSec->Draw(); gSecPt->Draw("pc"); gSecPt2->Draw("pc"); legPt2->Draw();
  gPad->SetTicks(); gPad->SetLeftMargin(0.15); gPad->SetBottomMargin(0.13); gPad->SetLogx(1);
  saveCanvas(c10, "files", "SecondaryReconstruction3D");

  TFile *fout = new TFile("test.root","RECREATE");
  gEffPt->Write(); gEffPt2->Write(); gEffEta->Write(); gEffEta2->Write();
  gMulPt->Write(); gMulPt2->Write(); gMulEta->Write(); gMulEta2->Write();
  gFakPt->Write(); gFakPt2->Write(); gFakEta->Write(); gFakEta2->Write();
  gSecPt->Write(); gSecPt2->Write(); gSecEta->Write(); gSecEta2->Write();
  fout->Close();
}
Example #5
0
void categories_sig() {

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

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

  TText *text = new TText();
  text->SetNDC();
  text->SetTextSize(0.05);

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

  TCanvas *c_bdtout = new TCanvas("c_bdtout","BDT output");

  bdtout_all_tot = (TH1*)bdtout_cat0_tot->Clone();
  bdtout_all_tot->Add(bdtout_cat1_tot);
  bdtout_all_tot->Add(bdtout_cat2_tot);
  bdtout_all_tot->Add(bdtout_cat3_tot);

  cout << bdtout_all_tot->Integral() << endl;
  cout << bdtout_all_tot->Integral(49,100)+bdtout_all_tot->GetBinContent(48)/2. << endl;
  cout << bdtout_all_tot->GetBinLowEdge(49) << endl;
  cout << bdtout_all_tot->GetBinLowEdge(48) << endl;
  cout << (bdtout_all_tot->Integral(49,100)+bdtout_all_tot->GetBinContent(48)/2.)/bdtout_all_tot->Integral() << endl;

  bdtout_passCiC_all_tot = (TH1*)bdtout_passCiC_cat0_tot->Clone();
  bdtout_passCiC_all_tot->Add(bdtout_passCiC_cat1_tot);
  bdtout_passCiC_all_tot->Add(bdtout_passCiC_cat2_tot);
  bdtout_passCiC_all_tot->Add(bdtout_passCiC_cat3_tot);

  bdtout_failpresel_cat0_tot->Rebin(2);
  bdtout_failpresel_cat1_tot->Rebin(2);
  bdtout_failpresel_cat2_tot->Rebin(2);
  bdtout_failpresel_cat3_tot->Rebin(2);

  bdtout_failpresel_all_tot = (TH1*)bdtout_failpresel_cat0_tot->Clone();
  bdtout_failpresel_all_tot->Add(bdtout_failpresel_cat1_tot);
  bdtout_failpresel_all_tot->Add(bdtout_failpresel_cat2_tot);
  bdtout_failpresel_all_tot->Add(bdtout_failpresel_cat3_tot);

  float nFail_m100180_bdtout005 = bdtout_all_tot->Integral(1,52) + bdtout_all_tot->GetBinContent(53)/2.;
  float nFail_m100180 = bdtout_all_tot->Integral(1,100);
  float frac_bdtout005 = nFail_m100180_bdtout005/nFail_m100180;
  float frac_bdtout005_err = frac_err(nFail_m100180_bdtout005,nFail_m100180);
  cout << bdtout_all_tot->Integral(1,52) << " " <<  bdtout_all_tot->GetBinContent(53)/2. << " " << bdtout_all_tot->Integral(1,100) << " " << bdtout_all_tot->GetBinLowEdge(53) << " " << frac_bdtout005 << " ± " << frac_bdtout005_err << endl;

  bdtout_all_tot->SetLineColor(1);
  bdtout_cat0_tot->SetLineColor(2);
  bdtout_cat1_tot->SetLineColor(3);
  bdtout_cat2_tot->SetLineColor(4);
  bdtout_cat3_tot->SetLineColor(6);

  bdtout_all_tot->SetLineWidth(2);
  bdtout_cat0_tot->SetLineWidth(2);
  bdtout_cat1_tot->SetLineWidth(2);
  bdtout_cat2_tot->SetLineWidth(2);
  bdtout_cat3_tot->SetLineWidth(2);

  bdtout_cat0_tot->SetMarkerColor(2);
  bdtout_cat1_tot->SetMarkerColor(3);
  bdtout_cat2_tot->SetMarkerColor(4);
  bdtout_cat3_tot->SetMarkerColor(6);

  bdtout_all_tot->SetMarkerStyle(20);
  bdtout_cat0_tot->SetMarkerStyle(20);
  bdtout_cat1_tot->SetMarkerStyle(20);
  bdtout_cat2_tot->SetMarkerStyle(20);
  bdtout_cat3_tot->SetMarkerStyle(20);

  bdtout_all_tot->SetMarkerSize(0.7);
  bdtout_cat0_tot->SetMarkerSize(0.7);
  bdtout_cat1_tot->SetMarkerSize(0.7);
  bdtout_cat2_tot->SetMarkerSize(0.7);
  bdtout_cat3_tot->SetMarkerSize(0.7);

  bdtout_passCiC_all_tot->SetLineColor(1);
  bdtout_passCiC_cat0_tot->SetLineColor(2);
  bdtout_passCiC_cat1_tot->SetLineColor(3);
  bdtout_passCiC_cat2_tot->SetLineColor(4);
  bdtout_passCiC_cat3_tot->SetLineColor(6);

  bdtout_passCiC_lowPt_cat0_tot->SetLineColor(2);
  bdtout_passCiC_lowPt_cat1_tot->SetLineColor(3);
  bdtout_passCiC_lowPt_cat2_tot->SetLineColor(4);
  bdtout_passCiC_lowPt_cat3_tot->SetLineColor(6);

  bdtout_passCiC_highPt_cat0_tot->SetLineColor(2);
  bdtout_passCiC_highPt_cat1_tot->SetLineColor(3);
  bdtout_passCiC_highPt_cat2_tot->SetLineColor(4);
  bdtout_passCiC_highPt_cat3_tot->SetLineColor(6);

  bdtout_failpresel_all_tot->SetLineColor(1);
  bdtout_failpresel_cat0_tot->SetLineColor(2);
  bdtout_failpresel_cat1_tot->SetLineColor(3);
  bdtout_failpresel_cat2_tot->SetLineColor(4);
  bdtout_failpresel_cat3_tot->SetLineColor(6);


  bdtout_all_tot->GetXaxis()->SetTitle("di-photon MVA output");

  float boundaries[4] = {-0.05,0.49,0.79,.91};
  float max = bdtout_all_tot->GetMaximum();

  TBox* box = new TBox(-1.,0.,boundaries[0],max*1.05);
  box->SetFillColor(38);
  box->SetFillStyle(3002);

  bdtout_all_tot->Draw("hist");
  box->Draw("hist,same");
  bdtout_all_tot->Draw("hist,same");
  bdtout_cat0_tot->Draw("hist,same");
  bdtout_cat1_tot->Draw("hist,same");
  bdtout_cat2_tot->Draw("hist,same");
  bdtout_cat3_tot->Draw("hist,same");

  TLegend *leg;
  leg = new TLegend(.14,.6,.46,.87);
  leg->SetBorderSize(0);
  leg->SetFillColor(10);
  leg->SetTextSize(.035);
  leg->AddEntry(bdtout_all_tot,"All");
  leg->AddEntry(bdtout_cat0_tot,"both EB, both R9>0.94");
  leg->AddEntry(bdtout_cat1_tot,"both EB, !both R9>0.94");
  leg->AddEntry(bdtout_cat2_tot,"!both EB, both R9>0.94");
  leg->AddEntry(bdtout_cat3_tot,"!both EB, !both R9>0.94");
  leg->Draw("hist");

  TLine* line[4];
  for (int i=0; i<4; i++) {
    line[i] = new TLine(boundaries[i],0.,boundaries[i],max*1.05);
    line[i]->SetLineColor(4);
    line[i]->SetLineWidth(2);
    line[i]->SetLineStyle(9);
    line[i]->Draw("hist");
  }

  gPad->RedrawAxis();

  c_bdtout->SaveAs("categories_sig.png");


  TCanvas *c_bdtout_passCiC = new TCanvas("c_bdtout_passCiC","BDT output, pass CiC");

  bdtout_passCiC_cat0_tot_clone = (TH1*)bdtout_passCiC_cat0_tot->Clone();
  bdtout_passCiC_cat1_tot_clone = (TH1*)bdtout_passCiC_cat1_tot->Clone();
  bdtout_passCiC_cat2_tot_clone = (TH1*)bdtout_passCiC_cat2_tot->Clone();
  bdtout_passCiC_cat3_tot_clone = (TH1*)bdtout_passCiC_cat3_tot->Clone();

  bdtout_passCiC_all_tot->SetLineWidth(2);
  bdtout_passCiC_cat0_tot_clone->SetLineWidth(2);
  bdtout_passCiC_cat1_tot_clone->SetLineWidth(2);
  bdtout_passCiC_cat2_tot_clone->SetLineWidth(2);
  bdtout_passCiC_cat3_tot_clone->SetLineWidth(2);

  bdtout_passCiC_all_tot->GetXaxis()->SetTitle("di-photon MVA output");

  max = bdtout_passCiC_all_tot->GetMaximum();
  TBox* box_passCiC = new TBox(-1.,0.,boundaries[0],max*1.05);
  box_passCiC->SetFillColor(38);
  box_passCiC->SetFillStyle(3002);

  bdtout_passCiC_all_tot->Draw("hist");
  box_passCiC->Draw("hist,same");
  bdtout_passCiC_all_tot->Draw("hist,same");
  bdtout_passCiC_cat0_tot_clone->Draw("hist,same");
  bdtout_passCiC_cat1_tot_clone->Draw("hist,same");
  bdtout_passCiC_cat2_tot_clone->Draw("hist,same");
  bdtout_passCiC_cat3_tot_clone->Draw("hist,same");

  leg->Draw("hist");

  TLine* line_passCiC[4];
  for (int i=0; i<4; i++) {
    line_passCiC[i] = new TLine(boundaries[i],0.,boundaries[i],max*1.05);
    line_passCiC[i]->SetLineColor(4);
    line_passCiC[i]->SetLineWidth(2);
    line_passCiC[i]->SetLineStyle(9);
    line_passCiC[i]->Draw("hist");
  }

  gPad->RedrawAxis();

  c_bdtout_passCiC->SaveAs("categories_passCiC_sig.png");

  /*
  TCanvas *c_bdtout_failpresel = new TCanvas("c_bdtout_failpresel","BDT output, pass CiC, fail presel");

  bdtout_failpresel_cat0_tot_clone = (TH1*)bdtout_failpresel_cat0_tot->Clone();
  bdtout_failpresel_cat1_tot_clone = (TH1*)bdtout_failpresel_cat1_tot->Clone();
  bdtout_failpresel_cat2_tot_clone = (TH1*)bdtout_failpresel_cat2_tot->Clone();
  bdtout_failpresel_cat3_tot_clone = (TH1*)bdtout_failpresel_cat3_tot->Clone();

  bdtout_failpresel_all_tot->SetLineWidth(2);
  bdtout_failpresel_cat0_tot_clone->SetLineWidth(2);
  bdtout_failpresel_cat1_tot_clone->SetLineWidth(2);
  bdtout_failpresel_cat2_tot_clone->SetLineWidth(2);
  bdtout_failpresel_cat3_tot_clone->SetLineWidth(2);

  bdtout_failpresel_all_tot->GetXaxis()->SetTitle("di-photon MVA output");

  max = bdtout_failpresel_all_tot->GetMaximum();
  TBox* box_failpresel = new TBox(-1.,0.,boundaries[0],max*1.05);
  box_failpresel->SetFillColor(38);
  box_failpresel->SetFillStyle(3002);

  bdtout_failpresel_all_tot->Draw("hist");
  box_failpresel->Draw("hist,same");
  bdtout_failpresel_all_tot->Draw("hist,same");
  bdtout_failpresel_cat0_tot_clone->Draw("hist,same");
  bdtout_failpresel_cat1_tot_clone->Draw("hist,same");
  bdtout_failpresel_cat2_tot_clone->Draw("hist,same");
  bdtout_failpresel_cat3_tot_clone->Draw("hist,same");

  leg->Draw("hist");

  TLine* line_failpresel[4];
  for (int i=0; i<4; i++) {
    line_failpresel[i] = new TLine(boundaries[i],0.,boundaries[i],max*1.05);
    line_failpresel[i]->SetLineColor(4);
    line_failpresel[i]->SetLineWidth(2);
    line_failpresel[i]->SetLineStyle(9);
    line_failpresel[i]->Draw("hist");
  }

  gPad->RedrawAxis();

  c_bdtout_failpresel->SaveAs("categories_failpresel_sig.png");
  */

  TCanvas *c_bdtout_compareCiC = new TCanvas("c_bdtout_compareCiC","BDT output: pass CiC supertight",1000,650);
  c_bdtout_compareCiC->Divide(2,2);

  bdtout_passCiC_cat0_tot->SetFillColor(2);
  bdtout_passCiC_cat1_tot->SetFillColor(3);
  bdtout_passCiC_cat2_tot->SetFillColor(4);
  bdtout_passCiC_cat3_tot->SetFillColor(6);

  bdtout_passCiC_cat0_tot->SetFillStyle(3002);
  bdtout_passCiC_cat1_tot->SetFillStyle(3002);
  bdtout_passCiC_cat2_tot->SetFillStyle(3002);
  bdtout_passCiC_cat3_tot->SetFillStyle(3002);

  bdtout_cat0_tot->GetXaxis()->SetTitle("di-photon MVA output");
  bdtout_cat1_tot->GetXaxis()->SetTitle("di-photon MVA output");
  bdtout_cat2_tot->GetXaxis()->SetTitle("di-photon MVA output");
  bdtout_cat3_tot->GetXaxis()->SetTitle("di-photon MVA output");
  bdtout_cat0_tot->GetXaxis()->SetTitleSize(0.05);
  bdtout_cat1_tot->GetXaxis()->SetTitleSize(0.05);
  bdtout_cat2_tot->GetXaxis()->SetTitleSize(0.05);
  bdtout_cat3_tot->GetXaxis()->SetTitleSize(0.05);

  c_bdtout_compareCiC->cd(1);

  box_passCiC_cat0 = (TBox*)box->Clone();
  box_passCiC_cat0->SetY2(bdtout_cat0_tot->GetMaximum()*1.05);

  bdtout_cat0_tot->Draw("hist");
  box_passCiC_cat0->Draw("hist,same");
  bdtout_cat0_tot->Draw("hist,same");
  bdtout_passCiC_cat0_tot->Draw("hist,same");

  TLine* line_passCiC_cat0[4];
  for (int i=0; i<4; i++) {
    line_passCiC_cat0[i] = (TLine*)line[i]->Clone();
    line_passCiC_cat0[i]->SetY2(bdtout_cat0_tot->GetMaximum()*1.05);
    line_passCiC_cat0[i]->Draw("hist");
  }
  text->DrawText(0.15,0.75,"both EB, both R9>0.94");
  gPad->RedrawAxis();

  c_bdtout_compareCiC->cd(2);

  box_passCiC_cat1 = (TBox*)box->Clone();
  box_passCiC_cat1->SetY2(bdtout_cat1_tot->GetMaximum()*1.05);

  bdtout_cat1_tot->Draw("hist");
  box_passCiC_cat1->Draw("hist,same");
  bdtout_cat1_tot->Draw("hist,same");
  bdtout_passCiC_cat1_tot->Draw("hist,same");

  TLine* line_passCiC_cat1[4];
  for (int i=0; i<4; i++) {
    line_passCiC_cat1[i] = (TLine*)line[i]->Clone();
    line_passCiC_cat1[i]->SetY2(bdtout_cat1_tot->GetMaximum()*1.05);
    line_passCiC_cat1[i]->Draw("hist");
  }
  text->DrawText(0.15,0.75,"both EB, !both R9>0.94");
  gPad->RedrawAxis();

  c_bdtout_compareCiC->cd(3);

  box_passCiC_cat2 = (TBox*)box->Clone();
  box_passCiC_cat2->SetY2(bdtout_cat2_tot->GetMaximum()*1.05);

  bdtout_cat2_tot->Draw("hist");
  box_passCiC_cat2->Draw("hist,same");
  bdtout_cat2_tot->Draw("hist,same");
  bdtout_passCiC_cat2_tot->Draw("hist,same");

  TLine* line_passCiC_cat2[4];
  for (int i=0; i<4; i++) {
    line_passCiC_cat2[i] = (TLine*)line[i]->Clone();
    line_passCiC_cat2[i]->SetY2(bdtout_cat2_tot->GetMaximum()*1.05);
    line_passCiC_cat2[i]->Draw("hist");
  }
  text->DrawText(0.15,0.75,"!both EB, both R9>0.94");
  gPad->RedrawAxis();

  c_bdtout_compareCiC->cd(4);

  box_passCiC_cat3 = (TBox*)box->Clone();
  box_passCiC_cat3->SetY2(bdtout_cat3_tot->GetMaximum()*1.05);

  bdtout_cat3_tot->Draw("hist");
  box_passCiC_cat3->Draw("hist,same");
  bdtout_cat3_tot->Draw("hist,same");
  bdtout_passCiC_cat3_tot->Draw("hist,same");

  TLine* line_passCiC_cat3[4];
  for (int i=0; i<4; i++) {
    line_passCiC_cat3[i] = (TLine*)line[i]->Clone();
    line_passCiC_cat3[i]->SetY2(bdtout_cat3_tot->GetMaximum()*1.05);
    line_passCiC_cat3[i]->Draw("hist");
  }
  text->DrawText(0.15,0.75,"!both EB, !both R9>0.94");
  gPad->RedrawAxis();

  c_bdtout_compareCiC->SaveAs("categories_compareCiC_sig.png");



  TCanvas *c_bdtout_lowPt = new TCanvas("c_bdtout_lowPt","BDT output: di-photon pT<40 GeV");

  bdtout_lowPt_all_tot = (TH1*)bdtout_lowPt_cat0_tot->Clone();
  bdtout_lowPt_all_tot->Add(bdtout_lowPt_cat1_tot);
  bdtout_lowPt_all_tot->Add(bdtout_lowPt_cat2_tot);
  bdtout_lowPt_all_tot->Add(bdtout_lowPt_cat3_tot);

  bdtout_lowPt_all_tot->SetLineColor(1);
  bdtout_lowPt_cat0_tot->SetLineColor(2);
  bdtout_lowPt_cat1_tot->SetLineColor(3);
  bdtout_lowPt_cat2_tot->SetLineColor(4);
  bdtout_lowPt_cat3_tot->SetLineColor(6);

  bdtout_lowPt_all_tot->SetLineWidth(2);
  bdtout_lowPt_cat0_tot->SetLineWidth(2);
  bdtout_lowPt_cat1_tot->SetLineWidth(2);
  bdtout_lowPt_cat2_tot->SetLineWidth(2);
  bdtout_lowPt_cat3_tot->SetLineWidth(2);

  bdtout_lowPt_all_tot->GetXaxis()->SetTitle("di-photon MVA output");
  bdtout_lowPt_all_tot->GetYaxis()->SetTitle("Events/0.02");
  bdtout_lowPt_all_tot->GetXaxis()->SetTitleSize(0.05);
  bdtout_lowPt_all_tot->GetXaxis()->SetLabelSize(0.05);
  bdtout_lowPt_all_tot->GetYaxis()->SetTitleSize(0.05);
  bdtout_lowPt_all_tot->GetYaxis()->SetLabelSize(0.05);

  max = bdtout_lowPt_all_tot->GetMaximum();
  TBox* box_lowPt = new TBox(-1.,0.,boundaries[0],max*1.05);
  box_lowPt->SetFillColor(38);
  box_lowPt->SetFillStyle(3002);

  bdtout_lowPt_all_tot->Draw("hist");
  box_lowPt->Draw("hist,same");
  bdtout_lowPt_all_tot->Draw("hist,same");
  bdtout_lowPt_cat0_tot->Draw("hist,same");
  bdtout_lowPt_cat1_tot->Draw("hist,same");
  bdtout_lowPt_cat2_tot->Draw("hist,same");
  bdtout_lowPt_cat3_tot->Draw("hist,same");

  TLegend *leg_lowPt = (TLegend*)leg->Clone();
  leg_lowPt->Clear();
  leg_lowPt->AddEntry(bdtout_all_tot,"All (p_{T}(#gamma#gamma) < 40 GeV)");
  leg_lowPt->AddEntry(bdtout_cat0_tot,"both EB, both R9>0.94");
  leg_lowPt->AddEntry(bdtout_cat1_tot,"both EB, !both R9>0.94");
  leg_lowPt->AddEntry(bdtout_cat2_tot,"!both EB, both R9>0.94");
  leg_lowPt->AddEntry(bdtout_cat3_tot,"!both EB, !both R9>0.94");
  leg_lowPt->Draw("hist");

  TLine* line_lowPt[4];
  for (int i=0; i<4; i++) {
    line_lowPt[i] = new TLine(boundaries[i],0.,boundaries[i],max*1.05);
    line_lowPt[i]->SetLineColor(4);
    line_lowPt[i]->SetLineWidth(2);
    line_lowPt[i]->SetLineStyle(9);
    line_lowPt[i]->Draw("hist");
  }

  gPad->RedrawAxis();

  c_bdtout_lowPt->SaveAs("categories_lowPt_sig.png");


  TCanvas *c_bdtout_compareCiC_lowPt = new TCanvas("c_bdtout_compareCiC_lowPt","BDT output: di-photon pT<40 GeV, pass CiC supertight",1000,650);
  c_bdtout_compareCiC_lowPt->Divide(2,2);

  bdtout_passCiC_lowPt_cat0_tot->SetFillColor(2);
  bdtout_passCiC_lowPt_cat1_tot->SetFillColor(3);
  bdtout_passCiC_lowPt_cat2_tot->SetFillColor(4);
  bdtout_passCiC_lowPt_cat3_tot->SetFillColor(6);

  bdtout_passCiC_lowPt_cat0_tot->SetFillStyle(3002);
  bdtout_passCiC_lowPt_cat1_tot->SetFillStyle(3002);
  bdtout_passCiC_lowPt_cat2_tot->SetFillStyle(3002);
  bdtout_passCiC_lowPt_cat3_tot->SetFillStyle(3002);

  bdtout_lowPt_cat0_tot->GetXaxis()->SetTitle("di-photon MVA output");
  bdtout_lowPt_cat1_tot->GetXaxis()->SetTitle("di-photon MVA output");
  bdtout_lowPt_cat2_tot->GetXaxis()->SetTitle("di-photon MVA output");
  bdtout_lowPt_cat3_tot->GetXaxis()->SetTitle("di-photon MVA output");
  bdtout_lowPt_cat0_tot->GetXaxis()->SetTitleSize(0.05);
  bdtout_lowPt_cat1_tot->GetXaxis()->SetTitleSize(0.05);
  bdtout_lowPt_cat2_tot->GetXaxis()->SetTitleSize(0.05);
  bdtout_lowPt_cat3_tot->GetXaxis()->SetTitleSize(0.05);

  c_bdtout_compareCiC_lowPt->cd(1);

  box_passCiC_lowPt_cat0 = (TBox*)box->Clone();
  box_passCiC_lowPt_cat0->SetY2(bdtout_lowPt_cat0_tot->GetMaximum()*1.05);

  bdtout_lowPt_cat0_tot->Draw("hist");
  box_passCiC_lowPt_cat0->Draw("hist,same");
  bdtout_lowPt_cat0_tot->Draw("hist,same");
  bdtout_passCiC_lowPt_cat0_tot->Draw("hist,same");

  TLine* line_passCiC_lowPt_cat0[4];
  for (int i=0; i<4; i++) {
    line_passCiC_lowPt_cat0[i] = (TLine*)line[i]->Clone();
    line_passCiC_lowPt_cat0[i]->SetY2(bdtout_lowPt_cat0_tot->GetMaximum()*1.05);
    line_passCiC_lowPt_cat0[i]->Draw("hist");
  }
  text->DrawText(0.15,0.75,"both EB, both R9>0.94");
  gPad->RedrawAxis();

  c_bdtout_compareCiC_lowPt->cd(2);

  box_passCiC_lowPt_cat1 = (TBox*)box->Clone();
  box_passCiC_lowPt_cat1->SetY2(bdtout_lowPt_cat1_tot->GetMaximum()*1.05);

  bdtout_lowPt_cat1_tot->Draw("hist");
  box_passCiC_lowPt_cat1->Draw("hist,same");
  bdtout_lowPt_cat1_tot->Draw("hist,same");
  bdtout_passCiC_lowPt_cat1_tot->Draw("hist,same");

  TLine* line_passCiC_lowPt_cat1[4];
  for (int i=0; i<4; i++) {
    line_passCiC_lowPt_cat1[i] = (TLine*)line[i]->Clone();
    line_passCiC_lowPt_cat1[i]->SetY2(bdtout_lowPt_cat1_tot->GetMaximum()*1.05);
    line_passCiC_lowPt_cat1[i]->Draw("hist");
  }
  text->DrawText(0.15,0.75,"both EB, !both R9>0.94");
  gPad->RedrawAxis();

  c_bdtout_compareCiC_lowPt->cd(3);

  box_passCiC_lowPt_cat2 = (TBox*)box->Clone();
  box_passCiC_lowPt_cat2->SetY2(bdtout_lowPt_cat2_tot->GetMaximum()*1.05);

  bdtout_lowPt_cat2_tot->Draw("hist");
  box_passCiC_lowPt_cat2->Draw("hist,same");
  bdtout_lowPt_cat2_tot->Draw("hist,same");
  bdtout_passCiC_lowPt_cat2_tot->Draw("hist,same");

  TLine* line_passCiC_lowPt_cat2[4];
  for (int i=0; i<4; i++) {
    line_passCiC_lowPt_cat2[i] = (TLine*)line[i]->Clone();
    line_passCiC_lowPt_cat2[i]->SetY2(bdtout_lowPt_cat2_tot->GetMaximum()*1.05);
    line_passCiC_lowPt_cat2[i]->Draw("hist");
  }
  text->DrawText(0.15,0.75,"!both EB, both R9>0.94");
  gPad->RedrawAxis();

  c_bdtout_compareCiC_lowPt->cd(4);

  box_passCiC_lowPt_cat3 = (TBox*)box->Clone();
  box_passCiC_lowPt_cat3->SetY2(bdtout_lowPt_cat3_tot->GetMaximum()*1.05);

  bdtout_lowPt_cat3_tot->Draw("hist");
  box_passCiC_lowPt_cat3->Draw("hist,same");
  bdtout_lowPt_cat3_tot->Draw("hist,same");
  bdtout_passCiC_lowPt_cat3_tot->Draw("hist,same");

  TLine* line_passCiC_lowPt_cat3[4];
  for (int i=0; i<4; i++) {
    line_passCiC_lowPt_cat3[i] = (TLine*)line[i]->Clone();
    line_passCiC_lowPt_cat3[i]->SetY2(bdtout_lowPt_cat3_tot->GetMaximum()*1.05);
    line_passCiC_lowPt_cat3[i]->Draw("hist");
  }
  text->DrawText(0.15,0.75,"!both EB, !both R9>0.94");
  gPad->RedrawAxis();

  c_bdtout_compareCiC_lowPt->SaveAs("categories_compareCiC_lowPt_sig.png");


  TCanvas *c_bdtout_highPt = new TCanvas("c_bdtout_highPt","BDT output: di-photon pT>40 GeV");

  bdtout_highPt_all_tot = (TH1*)bdtout_highPt_cat0_tot->Clone();
  bdtout_highPt_all_tot->Add(bdtout_highPt_cat1_tot);
  bdtout_highPt_all_tot->Add(bdtout_highPt_cat2_tot);
  bdtout_highPt_all_tot->Add(bdtout_highPt_cat3_tot);

  bdtout_highPt_all_tot->SetLineColor(1);
  bdtout_highPt_cat0_tot->SetLineColor(2);
  bdtout_highPt_cat1_tot->SetLineColor(3);
  bdtout_highPt_cat2_tot->SetLineColor(4);
  bdtout_highPt_cat3_tot->SetLineColor(6);

  bdtout_highPt_all_tot->SetLineWidth(2);
  bdtout_highPt_cat0_tot->SetLineWidth(2);
  bdtout_highPt_cat1_tot->SetLineWidth(2);
  bdtout_highPt_cat2_tot->SetLineWidth(2);
  bdtout_highPt_cat3_tot->SetLineWidth(2);

  bdtout_highPt_all_tot->GetXaxis()->SetTitle("di-photon MVA output");
  bdtout_highPt_all_tot->GetYaxis()->SetTitle("Events/0.02");
  bdtout_highPt_all_tot->GetXaxis()->SetTitleSize(0.05);
  bdtout_highPt_all_tot->GetXaxis()->SetLabelSize(0.05);
  bdtout_highPt_all_tot->GetYaxis()->SetTitleSize(0.05);
  bdtout_highPt_all_tot->GetYaxis()->SetLabelSize(0.05);

  max = 1.2*bdtout_highPt_all_tot->GetMaximum();
  bdtout_highPt_all_tot->SetMaximum(max);

  TBox* box_highPt = new TBox(-1.,0.,boundaries[0],max);
  box_highPt->SetFillColor(38);
  box_highPt->SetFillStyle(3002);

  bdtout_highPt_all_tot->Draw("hist");
  box_highPt->Draw("hist,same");
  bdtout_highPt_all_tot->Draw("hist,same");
  bdtout_highPt_cat0_tot->Draw("hist,same");
  bdtout_highPt_cat1_tot->Draw("hist,same");
  bdtout_highPt_cat2_tot->Draw("hist,same");
  bdtout_highPt_cat3_tot->Draw("hist,same");

  TLegend *leg_highPt = (TLegend*)leg->Clone();
  leg_highPt->Clear();
  leg_highPt->AddEntry(bdtout_all_tot,"All (p_{T}(#gamma#gamma) > 40 GeV)");
  leg_highPt->AddEntry(bdtout_cat0_tot,"both EB, both R9>0.94");
  leg_highPt->AddEntry(bdtout_cat1_tot,"both EB, !both R9>0.94");
  leg_highPt->AddEntry(bdtout_cat2_tot,"!both EB, both R9>0.94");
  leg_highPt->AddEntry(bdtout_cat3_tot,"!both EB, !both R9>0.94");
  leg_highPt->Draw("hist");

  TLine* line_highPt[4];
  for (int i=0; i<4; i++) {
    line_highPt[i] = new TLine(boundaries[i],0.,boundaries[i],max);
    line_highPt[i]->SetLineColor(4);
    line_highPt[i]->SetLineWidth(2);
    line_highPt[i]->SetLineStyle(9);
    line_highPt[i]->Draw("hist");
  }

  gPad->RedrawAxis();

  c_bdtout_highPt->SaveAs("categories_highPt_sig.png");



  TCanvas *c_bdtout_compareCiC_highPt = new TCanvas("c_bdtout_compareCiC_highPt","BDT output: di-photon pT>40 GeV, pass CiC supertight",1000,650);
  c_bdtout_compareCiC_highPt->Divide(2,2);

  bdtout_passCiC_highPt_cat0_tot->SetFillColor(2);
  bdtout_passCiC_highPt_cat1_tot->SetFillColor(3);
  bdtout_passCiC_highPt_cat2_tot->SetFillColor(4);
  bdtout_passCiC_highPt_cat3_tot->SetFillColor(6);

  bdtout_passCiC_highPt_cat0_tot->SetFillStyle(3002);
  bdtout_passCiC_highPt_cat1_tot->SetFillStyle(3002);
  bdtout_passCiC_highPt_cat2_tot->SetFillStyle(3002);
  bdtout_passCiC_highPt_cat3_tot->SetFillStyle(3002);

  bdtout_highPt_cat0_tot->GetXaxis()->SetTitle("di-photon MVA output");
  bdtout_highPt_cat1_tot->GetXaxis()->SetTitle("di-photon MVA output");
  bdtout_highPt_cat2_tot->GetXaxis()->SetTitle("di-photon MVA output");
  bdtout_highPt_cat3_tot->GetXaxis()->SetTitle("di-photon MVA output");
  bdtout_highPt_cat0_tot->GetXaxis()->SetTitleSize(0.05);
  bdtout_highPt_cat1_tot->GetXaxis()->SetTitleSize(0.05);
  bdtout_highPt_cat2_tot->GetXaxis()->SetTitleSize(0.05);
  bdtout_highPt_cat3_tot->GetXaxis()->SetTitleSize(0.05);

  c_bdtout_compareCiC_highPt->cd(1);

  box_passCiC_highPt_cat0 = (TBox*)box->Clone();
  box_passCiC_highPt_cat0->SetY2(bdtout_highPt_cat0_tot->GetMaximum()*1.05);

  bdtout_highPt_cat0_tot->Draw("hist");
  box_passCiC_highPt_cat0->Draw("hist,same");
  bdtout_highPt_cat0_tot->Draw("hist,same");
  bdtout_passCiC_highPt_cat0_tot->Draw("hist,same");

  TLine* line_passCiC_highPt_cat0[4];
  for (int i=0; i<4; i++) {
    line_passCiC_highPt_cat0[i] = (TLine*)line[i]->Clone();
    line_passCiC_highPt_cat0[i]->SetY2(bdtout_highPt_cat0_tot->GetMaximum()*1.05);
    line_passCiC_highPt_cat0[i]->Draw("hist");
  }
  text->DrawText(0.15,0.75,"both EB, both R9>0.94");
  gPad->RedrawAxis();

  c_bdtout_compareCiC_highPt->cd(2);

  box_passCiC_highPt_cat1 = (TBox*)box->Clone();
  box_passCiC_highPt_cat1->SetY2(bdtout_highPt_cat1_tot->GetMaximum()*1.05);

  bdtout_highPt_cat1_tot->Draw("hist");
  box_passCiC_highPt_cat1->Draw("hist,same");
  bdtout_highPt_cat1_tot->Draw("hist,same");
  bdtout_passCiC_highPt_cat1_tot->Draw("hist,same");

  TLine* line_passCiC_highPt_cat1[4];
  for (int i=0; i<4; i++) {
    line_passCiC_highPt_cat1[i] = (TLine*)line[i]->Clone();
    line_passCiC_highPt_cat1[i]->SetY2(bdtout_highPt_cat1_tot->GetMaximum()*1.05);
    line_passCiC_highPt_cat1[i]->Draw("hist");
  }
  text->DrawText(0.15,0.75,"both EB, !both R9>0.94");
  gPad->RedrawAxis();

  c_bdtout_compareCiC_highPt->cd(3);

  box_passCiC_highPt_cat2 = (TBox*)box->Clone();
  box_passCiC_highPt_cat2->SetY2(bdtout_highPt_cat2_tot->GetMaximum()*1.05);

  bdtout_highPt_cat2_tot->Draw("hist");
  box_passCiC_highPt_cat2->Draw("hist,same");
  bdtout_highPt_cat2_tot->Draw("hist,same");
  bdtout_passCiC_highPt_cat2_tot->Draw("hist,same");

  TLine* line_passCiC_highPt_cat2[4];
  for (int i=0; i<4; i++) {
    line_passCiC_highPt_cat2[i] = (TLine*)line[i]->Clone();
    line_passCiC_highPt_cat2[i]->SetY2(bdtout_highPt_cat2_tot->GetMaximum()*1.05);
    line_passCiC_highPt_cat2[i]->Draw("hist");
  }
  text->DrawText(0.15,0.75,"!both EB, both R9>0.94");
  gPad->RedrawAxis();

  c_bdtout_compareCiC_highPt->cd(4);

  box_passCiC_highPt_cat3 = (TBox*)box->Clone();
  box_passCiC_highPt_cat3->SetY2(bdtout_highPt_cat3_tot->GetMaximum()*1.05);

  bdtout_highPt_cat3_tot->Draw("hist");
  box_passCiC_highPt_cat3->Draw("hist,same");
  bdtout_highPt_cat3_tot->Draw("hist,same");
  bdtout_passCiC_highPt_cat3_tot->Draw("hist,same");

  TLine* line_passCiC_highPt_cat3[4];
  for (int i=0; i<4; i++) {
    line_passCiC_highPt_cat3[i] = (TLine*)line[i]->Clone();
    line_passCiC_highPt_cat3[i]->SetY2(bdtout_highPt_cat3_tot->GetMaximum()*1.05);
    line_passCiC_highPt_cat3[i]->Draw("hist");
  }
  text->DrawText(0.15,0.75,"!both EB, !both R9>0.94");
  gPad->RedrawAxis();

  c_bdtout_compareCiC_highPt->SaveAs("categories_compareCiC_highPt_sig.png");


  TCanvas *c_ptVsBdtout = new TCanvas("c_ptVsBdtout","pT(#gamma#gamma) vs MVA output",1000,650);
  c_ptVsBdtout->Divide(2,2);

  pt_vs_bdtout_cat0_all = (TH2*)pt_vs_bdtout_cat0_ggh_m125_8TeV->Clone();
  pt_vs_bdtout_cat1_all = (TH2*)pt_vs_bdtout_cat1_ggh_m125_8TeV->Clone();
  pt_vs_bdtout_cat2_all = (TH2*)pt_vs_bdtout_cat2_ggh_m125_8TeV->Clone();
  pt_vs_bdtout_cat3_all = (TH2*)pt_vs_bdtout_cat3_ggh_m125_8TeV->Clone();
  pt_vs_bdtout_cat4_all = (TH2*)pt_vs_bdtout_cat4_ggh_m125_8TeV->Clone();

  pt_vs_bdtout_cat0_all->Add(pt_vs_bdtout_cat0_vbf_m125_8TeV);
  pt_vs_bdtout_cat1_all->Add(pt_vs_bdtout_cat1_vbf_m125_8TeV);
  pt_vs_bdtout_cat2_all->Add(pt_vs_bdtout_cat2_vbf_m125_8TeV);
  pt_vs_bdtout_cat3_all->Add(pt_vs_bdtout_cat3_vbf_m125_8TeV);
  pt_vs_bdtout_cat4_all->Add(pt_vs_bdtout_cat4_vbf_m125_8TeV);

  pt_vs_bdtout_cat0_all->Add(pt_vs_bdtout_cat0_wzh_m125_8TeV);
  pt_vs_bdtout_cat1_all->Add(pt_vs_bdtout_cat1_wzh_m125_8TeV);
  pt_vs_bdtout_cat2_all->Add(pt_vs_bdtout_cat2_wzh_m125_8TeV);
  pt_vs_bdtout_cat3_all->Add(pt_vs_bdtout_cat3_wzh_m125_8TeV);
  pt_vs_bdtout_cat4_all->Add(pt_vs_bdtout_cat4_wzh_m125_8TeV);

  pt_vs_bdtout_cat0_all->Add(pt_vs_bdtout_cat0_tth_m125_8TeV);
  pt_vs_bdtout_cat1_all->Add(pt_vs_bdtout_cat1_tth_m125_8TeV);
  pt_vs_bdtout_cat2_all->Add(pt_vs_bdtout_cat2_tth_m125_8TeV);
  pt_vs_bdtout_cat3_all->Add(pt_vs_bdtout_cat3_tth_m125_8TeV);
  pt_vs_bdtout_cat4_all->Add(pt_vs_bdtout_cat4_tth_m125_8TeV);

  pt_vs_bdtout_cat0_all->GetXaxis()->SetTitle("di-photon MVA output");
  pt_vs_bdtout_cat1_all->GetXaxis()->SetTitle("di-photon MVA output");
  pt_vs_bdtout_cat2_all->GetXaxis()->SetTitle("di-photon MVA output");
  pt_vs_bdtout_cat3_all->GetXaxis()->SetTitle("di-photon MVA output");
  pt_vs_bdtout_cat0_all->GetXaxis()->SetTitleSize(0.05);
  pt_vs_bdtout_cat1_all->GetXaxis()->SetTitleSize(0.05);
  pt_vs_bdtout_cat2_all->GetXaxis()->SetTitleSize(0.05);
  pt_vs_bdtout_cat3_all->GetXaxis()->SetTitleSize(0.05);
  pt_vs_bdtout_cat0_all->GetYaxis()->SetTitle("di-photon p_{T} (GeV)");
  pt_vs_bdtout_cat1_all->GetYaxis()->SetTitle("di-photon p_{T} (GeV)");
  pt_vs_bdtout_cat2_all->GetYaxis()->SetTitle("di-photon p_{T} (GeV)");
  pt_vs_bdtout_cat3_all->GetYaxis()->SetTitle("di-photon p_{T} (GeV)");
  pt_vs_bdtout_cat0_all->GetYaxis()->SetTitleSize(0.05);
  pt_vs_bdtout_cat1_all->GetYaxis()->SetTitleSize(0.05);
  pt_vs_bdtout_cat2_all->GetYaxis()->SetTitleSize(0.05);
  pt_vs_bdtout_cat3_all->GetYaxis()->SetTitleSize(0.05);

  c_ptVsBdtout->cd(1);
  pt_vs_bdtout_cat0_all->Draw("colz");
  box_ptVsBdtout = (TBox*)box->Clone();
  box_ptVsBdtout->SetY2(200.);
  box_ptVsBdtout->Draw("hist");
  pt_vs_bdtout_cat0_all->Draw("colz,same");
  TLine* line_ptVsBdtout[4];
  for (int i=0; i<4; i++) {
    line_ptVsBdtout[i] = (TLine*)line[i]->Clone();
    line_ptVsBdtout[i]->SetY2(200.);
    line_ptVsBdtout[i]->Draw("hist");
  }
  text->DrawText(0.15,0.75,"both EB, both R9>0.94");
  gPad->RedrawAxis();
  c_ptVsBdtout->cd(2);
  pt_vs_bdtout_cat1_all->Draw("colz");
  box_ptVsBdtout->Draw("hist");
  pt_vs_bdtout_cat1_all->Draw("colz,same");
  for (int i=0; i<4; i++) line_ptVsBdtout[i]->Draw("hist");
  text->DrawText(0.15,0.75,"both EB, !both R9>0.94");
  gPad->RedrawAxis();
  c_ptVsBdtout->cd(3);
  pt_vs_bdtout_cat2_all->Draw("colz");
  box_ptVsBdtout->Draw("hist");
  pt_vs_bdtout_cat2_all->Draw("colz,same");
  for (int i=0; i<4; i++) line_ptVsBdtout[i]->Draw("hist");
  text->DrawText(0.15,0.75,"!both EB, both R9>0.94");
  gPad->RedrawAxis();
  c_ptVsBdtout->cd(4);
  pt_vs_bdtout_cat3_all->Draw("colz");
  box_ptVsBdtout->Draw("hist");
  pt_vs_bdtout_cat3_all->Draw("colz,same");
  for (int i=0; i<4; i++) line_ptVsBdtout[i]->Draw("hist");
  text->DrawText(0.15,0.75,"!both EB, !both R9>0.94");
  gPad->RedrawAxis();

  c_ptVsBdtout->SaveAs("ptVsBdtout_sig.png");


  TCanvas *c_2D = new TCanvas("c_2D","min(R9) vs max(eta), sublead eta vs lead eta",1250,500);
  c_2D->Divide(4,2);

  minR9_vs_maxEta_cat2_all = (TH2*)minR9_vs_maxEta_cat2_ggh_m125_8TeV->Clone();
  minR9_vs_maxEta_cat3_all = (TH2*)minR9_vs_maxEta_cat3_ggh_m125_8TeV->Clone();
  minR9_vs_maxEta_cat4_all = (TH2*)minR9_vs_maxEta_cat4_ggh_m125_8TeV->Clone();
  minR9_vs_maxEta_cat5_all = (TH2*)minR9_vs_maxEta_cat5_ggh_m125_8TeV->Clone();
  minR9_vs_maxEta_cat6_all = (TH2*)minR9_vs_maxEta_cat6_ggh_m125_8TeV->Clone();

  minR9_vs_maxEta_cat2_all->Add(minR9_vs_maxEta_cat2_vbf_m125_8TeV);
  minR9_vs_maxEta_cat3_all->Add(minR9_vs_maxEta_cat3_vbf_m125_8TeV);
  minR9_vs_maxEta_cat4_all->Add(minR9_vs_maxEta_cat4_vbf_m125_8TeV);
  minR9_vs_maxEta_cat5_all->Add(minR9_vs_maxEta_cat5_vbf_m125_8TeV);
  minR9_vs_maxEta_cat6_all->Add(minR9_vs_maxEta_cat6_vbf_m125_8TeV);

  minR9_vs_maxEta_cat2_all->Add(minR9_vs_maxEta_cat2_wzh_m125_8TeV);
  minR9_vs_maxEta_cat3_all->Add(minR9_vs_maxEta_cat3_wzh_m125_8TeV);
  minR9_vs_maxEta_cat4_all->Add(minR9_vs_maxEta_cat4_wzh_m125_8TeV);
  minR9_vs_maxEta_cat5_all->Add(minR9_vs_maxEta_cat5_wzh_m125_8TeV);
  minR9_vs_maxEta_cat6_all->Add(minR9_vs_maxEta_cat6_wzh_m125_8TeV);

  minR9_vs_maxEta_cat2_all->Add(minR9_vs_maxEta_cat2_tth_m125_8TeV);
  minR9_vs_maxEta_cat3_all->Add(minR9_vs_maxEta_cat3_tth_m125_8TeV);
  minR9_vs_maxEta_cat4_all->Add(minR9_vs_maxEta_cat4_tth_m125_8TeV);
  minR9_vs_maxEta_cat5_all->Add(minR9_vs_maxEta_cat5_tth_m125_8TeV);
  minR9_vs_maxEta_cat6_all->Add(minR9_vs_maxEta_cat6_tth_m125_8TeV);

  eta2_vs_eta1_cat2_all = (TH2*)eta2_vs_eta1_cat2_ggh_m125_8TeV->Clone();
  eta2_vs_eta1_cat3_all = (TH2*)eta2_vs_eta1_cat3_ggh_m125_8TeV->Clone();
  eta2_vs_eta1_cat4_all = (TH2*)eta2_vs_eta1_cat4_ggh_m125_8TeV->Clone();
  eta2_vs_eta1_cat5_all = (TH2*)eta2_vs_eta1_cat5_ggh_m125_8TeV->Clone();
  eta2_vs_eta1_cat6_all = (TH2*)eta2_vs_eta1_cat6_ggh_m125_8TeV->Clone();

  eta2_vs_eta1_cat2_all->Add(eta2_vs_eta1_cat2_vbf_m125_8TeV);
  eta2_vs_eta1_cat3_all->Add(eta2_vs_eta1_cat3_vbf_m125_8TeV);
  eta2_vs_eta1_cat4_all->Add(eta2_vs_eta1_cat4_vbf_m125_8TeV);
  eta2_vs_eta1_cat5_all->Add(eta2_vs_eta1_cat5_vbf_m125_8TeV);
  eta2_vs_eta1_cat6_all->Add(eta2_vs_eta1_cat6_vbf_m125_8TeV);

  eta2_vs_eta1_cat2_all->Add(eta2_vs_eta1_cat2_wzh_m125_8TeV);
  eta2_vs_eta1_cat3_all->Add(eta2_vs_eta1_cat3_wzh_m125_8TeV);
  eta2_vs_eta1_cat4_all->Add(eta2_vs_eta1_cat4_wzh_m125_8TeV);
  eta2_vs_eta1_cat5_all->Add(eta2_vs_eta1_cat5_wzh_m125_8TeV);
  eta2_vs_eta1_cat6_all->Add(eta2_vs_eta1_cat6_wzh_m125_8TeV);

  eta2_vs_eta1_cat2_all->Add(eta2_vs_eta1_cat2_tth_m125_8TeV);
  eta2_vs_eta1_cat3_all->Add(eta2_vs_eta1_cat3_tth_m125_8TeV);
  eta2_vs_eta1_cat4_all->Add(eta2_vs_eta1_cat4_tth_m125_8TeV);
  eta2_vs_eta1_cat5_all->Add(eta2_vs_eta1_cat5_tth_m125_8TeV);
  eta2_vs_eta1_cat6_all->Add(eta2_vs_eta1_cat6_tth_m125_8TeV);

  minR9_vs_maxEta_cat2_all->GetXaxis()->SetTitle("max(#eta)");
  minR9_vs_maxEta_cat3_all->GetXaxis()->SetTitle("max(#eta)");
  minR9_vs_maxEta_cat4_all->GetXaxis()->SetTitle("max(#eta)");
  minR9_vs_maxEta_cat5_all->GetXaxis()->SetTitle("max(#eta)");
  minR9_vs_maxEta_cat6_all->GetXaxis()->SetTitle("max(#eta)");
  minR9_vs_maxEta_cat2_all->GetYaxis()->SetTitle("min(R9)");
  minR9_vs_maxEta_cat3_all->GetYaxis()->SetTitle("min(R9)");
  minR9_vs_maxEta_cat4_all->GetYaxis()->SetTitle("min(R9)");
  minR9_vs_maxEta_cat5_all->GetYaxis()->SetTitle("min(R9)");
  minR9_vs_maxEta_cat6_all->GetYaxis()->SetTitle("min(R9)");

  minR9_vs_maxEta_cat2_all->GetXaxis()->SetTitleSize(0.05);
  minR9_vs_maxEta_cat3_all->GetXaxis()->SetTitleSize(0.05);
  minR9_vs_maxEta_cat4_all->GetXaxis()->SetTitleSize(0.05);
  minR9_vs_maxEta_cat5_all->GetXaxis()->SetTitleSize(0.05);
  minR9_vs_maxEta_cat6_all->GetXaxis()->SetTitleSize(0.05);
  minR9_vs_maxEta_cat2_all->GetYaxis()->SetTitleSize(0.05);
  minR9_vs_maxEta_cat3_all->GetYaxis()->SetTitleSize(0.05);
  minR9_vs_maxEta_cat4_all->GetYaxis()->SetTitleSize(0.05);
  minR9_vs_maxEta_cat5_all->GetYaxis()->SetTitleSize(0.05);
  minR9_vs_maxEta_cat6_all->GetYaxis()->SetTitleSize(0.05);

  line_minr9 = new TLine(0.,0.94,2.5,0.94);
  line_maxeta = new TLine(1.479,0.5,1.479,1.);
  //line_minr9->SetLineColor(4);
  line_minr9->SetLineWidth(2);
  line_minr9->SetLineStyle(9);
  //line_maxeta->SetLineColor(4);
  line_maxeta->SetLineWidth(2);
  line_maxeta->SetLineStyle(9);

  c_2D->cd(1);
  minR9_vs_maxEta_cat2_all->Draw("colz");
  line_minr9->Draw("hist");
  line_maxeta->Draw("hist");
  c_2D->cd(2);
  minR9_vs_maxEta_cat3_all->Draw("colz");
  line_minr9->Draw("hist");
  line_maxeta->Draw("hist");
  c_2D->cd(3);
  minR9_vs_maxEta_cat4_all->Draw("colz");
  line_minr9->Draw("hist");
  line_maxeta->Draw("hist");
  c_2D->cd(4);
  minR9_vs_maxEta_cat5_all->Draw("colz");
  line_minr9->Draw("hist");
  line_maxeta->Draw("hist");
  //c_2D->cd(5);
  //minR9_vs_maxEta_cat6_all->Draw("colz");
  //line_minr9->Draw("hist");
  //line_maxeta->Draw("hist");

  eta2_vs_eta1_cat2_all->GetYaxis()->SetTitle("sublead #eta");
  eta2_vs_eta1_cat3_all->GetYaxis()->SetTitle("sublead #eta");
  eta2_vs_eta1_cat4_all->GetYaxis()->SetTitle("sublead #eta");
  eta2_vs_eta1_cat5_all->GetYaxis()->SetTitle("sublead #eta");
  eta2_vs_eta1_cat6_all->GetYaxis()->SetTitle("sublead #eta");
  eta2_vs_eta1_cat2_all->GetXaxis()->SetTitle("lead #eta");
  eta2_vs_eta1_cat3_all->GetXaxis()->SetTitle("lead #eta");
  eta2_vs_eta1_cat4_all->GetXaxis()->SetTitle("lead #eta");
  eta2_vs_eta1_cat5_all->GetXaxis()->SetTitle("lead #eta");
  eta2_vs_eta1_cat6_all->GetXaxis()->SetTitle("lead #eta");

  eta2_vs_eta1_cat2_all->GetXaxis()->SetTitleSize(0.05);
  eta2_vs_eta1_cat3_all->GetXaxis()->SetTitleSize(0.05);
  eta2_vs_eta1_cat4_all->GetXaxis()->SetTitleSize(0.05);
  eta2_vs_eta1_cat5_all->GetXaxis()->SetTitleSize(0.05);
  eta2_vs_eta1_cat6_all->GetXaxis()->SetTitleSize(0.05);
  eta2_vs_eta1_cat2_all->GetYaxis()->SetTitleSize(0.05);
  eta2_vs_eta1_cat3_all->GetYaxis()->SetTitleSize(0.05);
  eta2_vs_eta1_cat4_all->GetYaxis()->SetTitleSize(0.05);
  eta2_vs_eta1_cat5_all->GetYaxis()->SetTitleSize(0.05);
  eta2_vs_eta1_cat6_all->GetYaxis()->SetTitleSize(0.05);

  c_2D->cd(5);
  eta2_vs_eta1_cat2_all->Draw("colz");
  c_2D->cd(6);
  eta2_vs_eta1_cat3_all->Draw("colz");
  c_2D->cd(7);
  eta2_vs_eta1_cat4_all->Draw("colz");
  c_2D->cd(8);
  eta2_vs_eta1_cat5_all->Draw("colz");
  //c_2D->cd(10);
  //eta2_vs_eta1_cat6_all->Draw("colz");

  c_2D->SaveAs("categories_2D_sig.png");

  /*
  TCanvas *c_2D_v2 = new TCanvas("c_2D_v2","min(R9) vs max(eta), |lead eta| vs |deltaEeta|",1500,500);
  c_2D_v2->Divide(5,2);

  minR9_vs_maxEta_cat2_tot->GetXaxis()->SetTitle("max(#eta)");
  minR9_vs_maxEta_cat3_tot->GetXaxis()->SetTitle("max(#eta)");
  minR9_vs_maxEta_cat4_tot->GetXaxis()->SetTitle("max(#eta)");
  minR9_vs_maxEta_cat5_tot->GetXaxis()->SetTitle("max(#eta)");
  minR9_vs_maxEta_cat6_tot->GetXaxis()->SetTitle("max(#eta)");
  minR9_vs_maxEta_cat2_tot->GetYaxis()->SetTitle("min(R9)");
  minR9_vs_maxEta_cat3_tot->GetYaxis()->SetTitle("min(R9)");
  minR9_vs_maxEta_cat4_tot->GetYaxis()->SetTitle("min(R9)");
  minR9_vs_maxEta_cat5_tot->GetYaxis()->SetTitle("min(R9)");
  minR9_vs_maxEta_cat6_tot->GetYaxis()->SetTitle("min(R9)");

  minR9_vs_maxEta_cat2_tot->GetXaxis()->SetTitleSize(0.05);
  minR9_vs_maxEta_cat3_tot->GetXaxis()->SetTitleSize(0.05);
  minR9_vs_maxEta_cat4_tot->GetXaxis()->SetTitleSize(0.05);
  minR9_vs_maxEta_cat5_tot->GetXaxis()->SetTitleSize(0.05);
  minR9_vs_maxEta_cat6_tot->GetXaxis()->SetTitleSize(0.05);
  minR9_vs_maxEta_cat2_tot->GetYaxis()->SetTitleSize(0.05);
  minR9_vs_maxEta_cat3_tot->GetYaxis()->SetTitleSize(0.05);
  minR9_vs_maxEta_cat4_tot->GetYaxis()->SetTitleSize(0.05);
  minR9_vs_maxEta_cat5_tot->GetYaxis()->SetTitleSize(0.05);
  minR9_vs_maxEta_cat6_tot->GetYaxis()->SetTitleSize(0.05);

  c_2D_v2->cd(1);
  minR9_vs_maxEta_cat2_tot->Draw("colz");
  line_minr9->Draw("hist");
  line_maxeta->Draw("hist");
  c_2D_v2->cd(2);
  minR9_vs_maxEta_cat3_tot->Draw("colz");
  line_minr9->Draw("hist");
  line_maxeta->Draw("hist");
  c_2D_v2->cd(3);
  minR9_vs_maxEta_cat4_tot->Draw("colz");
  line_minr9->Draw("hist");
  line_maxeta->Draw("hist");
  c_2D_v2->cd(4);
  minR9_vs_maxEta_cat5_tot->Draw("colz");
  line_minr9->Draw("hist");
  line_maxeta->Draw("hist");
  c_2D_v2->cd(5);
  minR9_vs_maxEta_cat6_tot->Draw("colz");
  line_minr9->Draw("hist");
  line_maxeta->Draw("hist");

  eta1_vs_deltaEta_cat2_tot->GetYaxis()->SetTitle("|lead #eta|");
  eta1_vs_deltaEta_cat3_tot->GetYaxis()->SetTitle("|lead #eta|");
  eta1_vs_deltaEta_cat4_tot->GetYaxis()->SetTitle("|lead #eta|");
  eta1_vs_deltaEta_cat5_tot->GetYaxis()->SetTitle("|lead #eta|");
  eta1_vs_deltaEta_cat6_tot->GetYaxis()->SetTitle("|lead #eta|");
  eta1_vs_deltaEta_cat2_tot->GetXaxis()->SetTitle("|#Delta#eta|");
  eta1_vs_deltaEta_cat3_tot->GetXaxis()->SetTitle("|#Delta#eta|");
  eta1_vs_deltaEta_cat4_tot->GetXaxis()->SetTitle("|#Delta#eta|");
  eta1_vs_deltaEta_cat5_tot->GetXaxis()->SetTitle("|#Delta#eta|");
  eta1_vs_deltaEta_cat6_tot->GetXaxis()->SetTitle("|#Delta#eta|");

  eta1_vs_deltaEta_cat2_tot->GetXaxis()->SetTitleSize(0.05);
  eta1_vs_deltaEta_cat3_tot->GetXaxis()->SetTitleSize(0.05);
  eta1_vs_deltaEta_cat4_tot->GetXaxis()->SetTitleSize(0.05);
  eta1_vs_deltaEta_cat5_tot->GetXaxis()->SetTitleSize(0.05);
  eta1_vs_deltaEta_cat6_tot->GetXaxis()->SetTitleSize(0.05);
  eta1_vs_deltaEta_cat2_tot->GetYaxis()->SetTitleSize(0.05);
  eta1_vs_deltaEta_cat3_tot->GetYaxis()->SetTitleSize(0.05);
  eta1_vs_deltaEta_cat4_tot->GetYaxis()->SetTitleSize(0.05);
  eta1_vs_deltaEta_cat5_tot->GetYaxis()->SetTitleSize(0.05);
  eta1_vs_deltaEta_cat6_tot->GetYaxis()->SetTitleSize(0.05);

  c_2D_v2->cd(6);
  eta1_vs_deltaEta_cat2_tot->Draw("colz");
  c_2D_v2->cd(7);
  eta1_vs_deltaEta_cat3_tot->Draw("colz");
  c_2D_v2->cd(8);
  eta1_vs_deltaEta_cat4_tot->Draw("colz");
  c_2D_v2->cd(9);
  eta1_vs_deltaEta_cat5_tot->Draw("colz");
  c_2D_v2->cd(10);
  eta1_vs_deltaEta_cat6_tot->Draw("colz");

  c_2D_v2->SaveAs("categories_2D_v2_sig.png");
  */
}
Example #6
0
void AccTimesEff::Loop()
{
   TStopwatch timer;
   timer.Start();
   // parameters /////////////////////////////////////////////////////////////
   vector<TString> files;
   files.push_back("file:////user/treis/mcsamples/ZprimeToEMu_M-500_noAccCuts_TuneZ2star_8TeV_madgraph_treis-Summer12_DR53X_PU_S10_START53_V7C1-v1_9999ev.root");
   files.push_back("file:////user/treis/mcsamples/ZprimeToEMu_M-750_noAccCuts_TuneZ2star_8TeV_madgraph_treis-Summer12_DR53X_PU_S10_START53_V7C1-v1_10000ev.root");
   files.push_back("file:////user/treis/mcsamples/ZprimeToEMu_M-1000_noAccCuts_TuneZ2star_8TeV_madgraph_treis-Summer12_DR53X_PU_S10_START53_V7C1-v1_9998ev.root");
   files.push_back("file:////user/treis/mcsamples/ZprimeToEMu_M-1250_noAccCuts_TuneZ2star_8TeV_madgraph_treis-Summer12_DR53X_PU_S10_START53_V7C1-v1_9998ev.root");
   files.push_back("file:////user/treis/mcsamples/ZprimeToEMu_M-1500_noAccCuts_TuneZ2star_8TeV_madgraph_treis-Summer12_DR53X_PU_S10_START53_V7C1-v1_9997ev.root");
   files.push_back("file:////user/treis/mcsamples/ZprimeToEMu_M-1750_noAccCuts_TuneZ2star_8TeV_madgraph_treis-Summer12_DR53X_PU_S10_START53_V7C1-v1_9997ev.root");
   files.push_back("file:////user/treis/mcsamples/ZprimeToEMu_M-2000_noAccCuts_TuneZ2star_8TeV_madgraph_treis-Summer12_DR53X_PU_S10_START53_V7C1-v1_9999ev.root");
   files.push_back("file:////user/treis/mcsamples/ZprimeToEMu_M-2500_noAccCuts_TuneZ2star_8TeV_madgraph_treis-Summer12_DR53X_PU_S10_START53_V7C1-v1_9999ev.root");
   files.push_back("file:////user/treis/mcsamples/ZprimeToEMu_M-3000_noAccCuts_TuneZ2star_8TeV_madgraph_treis-Summer12_DR53X_PU_S10_START53_V7C1-v1_10000ev.root");
   files.push_back("file:////user/treis/mcsamples/ZprimeToEMu_M-3500_noAccCuts_TuneZ2star_8TeV_madgraph_treis-Summer12_DR53X_PU_S10_START53_V7C1-v1_9898ev.root");
   files.push_back("file:////user/treis/mcsamples/ZprimeToEMu_M-4000_noAccCuts_TuneZ2star_8TeV_madgraph_treis-Summer12_DR53X_PU_S10_START53_V7C1-v1_9998ev.root");
   files.push_back("file:////user/treis/mcsamples/ZprimeToEMu_M-5000_noAccCuts_TuneZ2star_8TeV_madgraph_treis-Summer12_DR53X_PU_S10_START53_V7C1-v1_9966ev.root");
   string outfileName = "accTimesEffHistos";

   // output file formats
   const bool saveSpec = 0;
   const bool saveAsPdf = 0;
   const bool saveAsPng = 1;
   const bool saveAsRoot = 0;
   TString plotDir = "./plots/";

   int font = 42; //62
   // selection cuts /////////////////////////////////////////////////////////
   float elePtCut = 35.;
   float muPtCut = 35.;
   float minInvMass = 0.;

   TH1::SetDefaultSumw2(kTRUE);

   ///////////////////////////////////////////////////////////////////////////

   ///////////////////////////////////////////////////////////////////////////

   TH1F *hGenEvts = new TH1F("hGenEvts", "hGenEvts", 145, 0., 5010.);
   hGenEvts->GetXaxis()->SetTitle("M_{Z'}^{truth}");
   hGenEvts->GetXaxis()->SetTitleFont(font);
   hGenEvts->GetXaxis()->SetLabelFont(font);
   hGenEvts->GetYaxis()->SetTitle("Events");
   hGenEvts->GetYaxis()->SetTitleFont(font);
   hGenEvts->GetYaxis()->SetLabelFont(font);
   hGenEvts->GetYaxis()->SetTitleOffset(1.2);
   hGenEvts->SetLineColor(kBlack);
   hGenEvts->SetLineWidth(2);
   hGenEvts->SetMarkerStyle(20);
   hGenEvts->SetMarkerColor(kBlack);
   TH1F *hGenEvtsEleInAcc = (TH1F*)hGenEvts->Clone("hGenEvtsEleInAcc");
   TH1F *hGenEvtsEleInAccEB = (TH1F*)hGenEvts->Clone("hGenEvtsEleInAccEB");
   TH1F *hGenEvtsEleInAccEE = (TH1F*)hGenEvts->Clone("hGenEvtsEleInAccEE");
   TH1F *hGenEvtsMuInAcc = (TH1F*)hGenEvts->Clone("hGenEvtsMuInAcc");
   TH1F *hGenEvtsInAcc = (TH1F*)hGenEvts->Clone("hGenEvtsInAcc");
   TH1F *hTrgEvts = (TH1F*)hGenEvts->Clone("hTrgEvts");
   hTrgEvts->SetTitle("hTrgEvts");
   TH1F *hRecoEvts = (TH1F*)hGenEvts->Clone("hRecoEvts");
   hRecoEvts->SetTitle("hRecoEvts");
   TH1F *hRecoEvtsEB = (TH1F*)hRecoEvts->Clone("hRecoEvtsEB");
   TH1F *hRecoEvtsEE = (TH1F*)hRecoEvts->Clone("hRecoEvtsEE");
   TH1F *hRecoEleEvts = (TH1F*)hRecoEvts->Clone("hRecoEleEvts");
   TH1F *hRecoEleEvtsEB = (TH1F*)hRecoEvts->Clone("hRecoEleEvtsEB");
   TH1F *hRecoEleEvtsEE = (TH1F*)hRecoEvts->Clone("hRecoEleEvtsEE");
   TH1F *hRecoMuEvts = (TH1F*)hRecoEvts->Clone("hRecoMuEvts");
   TH1F *hRecoNoTrgEvts = (TH1F*)hGenEvts->Clone("hRecoNoTrgEvts");
   hRecoNoTrgEvts->SetTitle("hRecoNoTrgEvts");
   TH1F *hRecoNoTrgEvtsEB = (TH1F*)hRecoNoTrgEvts->Clone("hRecoNoTrgEvtsEB");
   TH1F *hRecoNoTrgEvtsEE = (TH1F*)hRecoNoTrgEvts->Clone("hRecoNoTrgEvtsEE");
   TH1F *hRecoNoTrgEleEvts = (TH1F*)hRecoNoTrgEvts->Clone("hRecoNoTrgEleEvts");
   TH1F *hRecoNoTrgEleEvtsEB = (TH1F*)hRecoNoTrgEvts->Clone("hRecoNoTrgEleEvtsEB");
   TH1F *hRecoNoTrgEleEvtsEE = (TH1F*)hRecoNoTrgEvts->Clone("hRecoNoTrgEleEvtsEE");
   TH1F *hRecoNoTrgMuEvts = (TH1F*)hRecoNoTrgEvts->Clone("hRecoNoTrgMuEvts");
   TH1F* hAcc;
   TH1F* hAccEle;
   TH1F* hAccEleEB;
   TH1F* hAccEleEE;
   TH1F* hAccMu;
   TH1F* hAccTimesTrgEff;
   TH1F* hTrgEff;
   TH1F* hAccTimesEff;
   TH1F* hAccTimesEffEB;
   TH1F* hAccTimesEffEE;
   TH1F* hAccTimesEffEle;
   TH1F* hAccTimesEffEleEB;
   TH1F* hAccTimesEffEleEE;
   TH1F* hAccTimesEffMu;
   TH1F* hAccTimesEffNoTrg;
   //TH1F* hAccTimesEffNoTrgEB;
   //TH1F* hAccTimesEffNoTrgEE;
   TH1F* hAccTimesEffNoTrgEle;
   TH1F* hAccTimesEffNoTrgEleEB;
   TH1F* hAccTimesEffNoTrgEleEE;
   TH1F* hAccTimesEffNoTrgMu;
   TH1F* hEffAftTrg;
   TH1F* hEffAftTrgEle;
   TH1F* hEffAftTrgEleEB;
   TH1F* hEffAftTrgEleEE;
   TH1F* hEffAftTrgMu;
   TH1F* hTrgRecoVsReco;
   //TH1F* hTrgRecoVsRecoEB;
   //TH1F* hTrgRecoVsRecoEE;
   TH1F* hTrgRecoVsRecoEle;
   TH1F* hTrgRecoVsRecoEleEB;
   TH1F* hTrgRecoVsRecoEleEE;
   TH1F* hTrgRecoVsRecoMu;

   // output file
   stringstream ssOutfile;
   ssOutfile << outfileName << ".root";
   TFile *output = new TFile(ssOutfile.str().c_str(), "recreate");

   ///////////////////////////////////////////////////////////////////////////
   //LOOP OVER FILES 
   ///////////////////////////////////////////////////////////////////////////
   for (unsigned int p = 0; p < files.size(); ++p) {
      TFile* input = new TFile(files[p]);
      TTree *thetree = (TTree*)input->Get("gsfcheckerjob/tree");
      Init(thetree);
      Long64_t nentries = fChain->GetEntriesFast();
      cout << nentries << " events" << endl;

      unsigned int evCounter = 0;
      /////////////////////////////////////////////////////////////////////////////////////////////
      //LOOP OVER EVENTS
      /////////////////////////////////////////////////////////////////////////////////////////////
      //nentries = 10000;
      for (Long64_t jentry = 0; jentry < nentries; ++jentry) {
         Long64_t ientry = LoadTree(jentry);
         if (ientry < 0) break;
         fChain->GetEntry(jentry);
         // if (Cut(ientry) < 0) continue;
         //if (jentry % 50000 == 0) cout << "Processing event " << jentry << endl;
         thetree->GetEntry(jentry);

         // fill the gen histograms
         hGenEvts->Fill(genelemom_mass[0]);

         // fill the acc histograms
         if (hardGenEle_pt[0] > elePtCut) {
            if (fabs(hardGenEle_eta[0]) < 1.442) {
               hGenEvtsEleInAcc->Fill(genelemom_mass[0]);
               hGenEvtsEleInAccEB->Fill(genelemom_mass[0]);
            }
            else if (fabs(hardGenEle_eta[0]) > 1.56 && fabs(hardGenEle_eta[0]) < 2.5) {
               hGenEvtsEleInAcc->Fill(genelemom_mass[0]);
               hGenEvtsEleInAccEE->Fill(genelemom_mass[0]);
            }
         }
         if (hardGenMu_pt[0] > muPtCut && fabs(hardGenMu_eta[0]) < 2.4) {
            hGenEvtsMuInAcc->Fill(genelemom_mass[0]);
            if (fabs(hardGenEle_eta[0]) < 1.442 || (fabs(hardGenEle_eta[0]) > 1.56 && fabs(hardGenEle_eta[0]) < 2.5)) {
               if (hardGenEle_pt[0] > elePtCut) hGenEvtsInAcc->Fill(genelemom_mass[0]);
            }
         }

         // trigger?
         if (HLT_Mu22_Photon22_CaloIdL) hTrgEvts->Fill(genelemom_mass[0]);

         // at least one gsf electron and one muon above the threshold
         if (gsf_size < 1 || muon_size < 1) continue;

         vector<int> GSF_passHEEP;
         vector<int> MU_passGOOD;
         /////////////////////////////////////////////////////////////////////////////////////////////
         //loop over electrons
         for (int j = 0; j < gsf_size; ++j) {
            //cleaning: fake electrons from muons
            bool fakeEle = false;
            for (int k = 0; k < muon_size; ++k) {
               float DeltaR = deltaR(gsf_eta[j], gsf_phi[j], muon_eta[k], muon_phi[k]);
               if (DeltaR < 0.1) {
                  fakeEle = true;
                  break;
               }
            }
            if (fakeEle) continue;

            if (PassHEEP(j)) GSF_passHEEP.push_back(j);
         }

         //loop over muons
         for (int j = 0; j < muon_size; ++j) {
            if (PassHighPtMu(j)) MU_passGOOD.push_back(j);
         }

         if (GSF_passHEEP.size() == 1) {
            if (HLT_Mu22_Photon22_CaloIdL) {
               hRecoEleEvts->Fill(genelemom_mass[0]);
               if (fabs(gsfsc_eta[GSF_passHEEP[0]]) < 1.5) hRecoEleEvtsEB->Fill(genelemom_mass[0]);
               if (fabs(gsfsc_eta[GSF_passHEEP[0]]) > 1.5) hRecoEleEvtsEE->Fill(genelemom_mass[0]);
            }
            hRecoNoTrgEleEvts->Fill(genelemom_mass[0]);
            if (fabs(gsfsc_eta[GSF_passHEEP[0]]) < 1.5) hRecoNoTrgEleEvtsEB->Fill(genelemom_mass[0]);
            if (fabs(gsfsc_eta[GSF_passHEEP[0]]) > 1.5) hRecoNoTrgEleEvtsEE->Fill(genelemom_mass[0]);
         } 
         if (MU_passGOOD.size() == 1) {
            if (HLT_Mu22_Photon22_CaloIdL) hRecoMuEvts->Fill(genelemom_mass[0]);
            hRecoNoTrgMuEvts->Fill(genelemom_mass[0]);
         }

         // veto when there are more than one good candidates
         if (GSF_passHEEP.size() != 1 || MU_passGOOD.size() != 1) continue;

         //HEEP ele + GOOD muon
         TLorentzVector ele1;
         TLorentzVector mu1;

         ele1.SetPtEtaPhiM(gsf_gsfet[GSF_passHEEP[0]], gsf_eta[GSF_passHEEP[0]], gsf_phi[GSF_passHEEP[0]], 0.000511);
         mu1.SetPtEtaPhiM(muon_pt[MU_passGOOD[0]], muon_eta[MU_passGOOD[0]], muon_phi[MU_passGOOD[0]], 0.10566);

         double invMass = (ele1 + mu1).M();

         //MASS CUT
         if (invMass < minInvMass) continue;

         if (HLT_Mu22_Photon22_CaloIdL) {
            hRecoEvts->Fill(genelemom_mass[0]);
            if (fabs(gsfsc_eta[GSF_passHEEP[0]]) < 1.5) hRecoEvtsEB->Fill(genelemom_mass[0]);
            if (fabs(gsfsc_eta[GSF_passHEEP[0]]) > 1.5) hRecoEvtsEE->Fill(genelemom_mass[0]);
         }
         hRecoNoTrgEvts->Fill(genelemom_mass[0]);
         if (fabs(gsfsc_eta[GSF_passHEEP[0]]) < 1.5) hRecoNoTrgEvtsEB->Fill(genelemom_mass[0]);
         if (fabs(gsfsc_eta[GSF_passHEEP[0]]) > 1.5) hRecoNoTrgEvtsEE->Fill(genelemom_mass[0]);
         ++evCounter;
        ///////////////////////////////////////////////////////////////////////
      } //END LOOP OVER EVENTS
        //////////////////////////////////////////////////////////////////////

     //////////////////////////////////////////////////////////////////////////
   } //END LOOP OVER FILES
     //////////////////////////////////////////////////////////////////////////
   hAcc = (TH1F*)hGenEvtsInAcc->Clone("hAcc");
   hAccEle = (TH1F*)hGenEvtsEleInAcc->Clone("hAccEle");
   hAccEleEB = (TH1F*)hGenEvtsEleInAccEB->Clone("hAccEleEB");
   hAccEleEE = (TH1F*)hGenEvtsEleInAccEE->Clone("hAccEleEE");
   hAccMu = (TH1F*)hGenEvtsMuInAcc->Clone("hAccMu");
   hAccTimesTrgEff = (TH1F*)hTrgEvts->Clone("hAccTimesTrgEff");
   hTrgEff = (TH1F*)hTrgEvts->Clone("hTrgEff");
   hAccTimesEff = (TH1F*)hRecoEvts->Clone("hAccTimesEff");
   hAccTimesEffEB = (TH1F*)hRecoEvtsEB->Clone("hAccTimesEffEB");
   hAccTimesEffEE = (TH1F*)hRecoEvtsEE->Clone("hAccTimesEffEE");
   hAccTimesEffEle = (TH1F*)hRecoEleEvts->Clone("hAccTimesEffEle");
   hAccTimesEffEleEB = (TH1F*)hRecoEleEvtsEB->Clone("hAccTimesEffEleEB");
   hAccTimesEffEleEE = (TH1F*)hRecoEleEvtsEE->Clone("hAccTimesEffEleEE");
   hAccTimesEffMu = (TH1F*)hRecoMuEvts->Clone("hAccTimesEffMu");
   hAccTimesEffNoTrg = (TH1F*)hRecoNoTrgEvts->Clone("hAccTimesEffNoTrg");
   //hAccTimesEffNoTrgEB = (TH1F*)hRecoNoTrgEvtsEB->Clone("hAccTimesEffNoTrgEB");
   //hAccTimesEffNoTrgEE = (TH1F*)hRecoNoTrgEvtsEE->Clone("hAccTimesEffNoTrgEE");
   hAccTimesEffNoTrgEle = (TH1F*)hRecoNoTrgEleEvts->Clone("hAccTimesEffNoTrgEle");
   hAccTimesEffNoTrgEleEB = (TH1F*)hRecoNoTrgEleEvtsEB->Clone("hAccTimesEffNoTrgEleEB");
   hAccTimesEffNoTrgEleEE = (TH1F*)hRecoNoTrgEleEvtsEE->Clone("hAccTimesEffNoTrgEleEE");
   hAccTimesEffNoTrgMu = (TH1F*)hRecoNoTrgMuEvts->Clone("hAccTimesEffNoTrgMu");
   hEffAftTrg = (TH1F*)hRecoEvts->Clone("hAccTimesEff");
   hEffAftTrgEle = (TH1F*)hRecoEleEvts->Clone("hAccTimesEffEle");
   hEffAftTrgEleEB = (TH1F*)hRecoEleEvtsEB->Clone("hAccTimesEffEleEB");
   hEffAftTrgEleEE = (TH1F*)hRecoEleEvtsEE->Clone("hAccTimesEffEleEE");
   hEffAftTrgMu = (TH1F*)hRecoMuEvts->Clone("hAccTimesEffMu");
   hTrgRecoVsReco = (TH1F*)hRecoEvts->Clone("hTrgRecoVsReco");
   //hTrgRecoVsRecoEB = (TH1F*)hRecoEvtsEB->Clone("hTrgRecoVsRecoEB");
   //hTrgRecoVsRecoEE = (TH1F*)hRecoEvtsEE->Clone("hTrgRecoVsRecoEE");
   hTrgRecoVsRecoEle = (TH1F*)hRecoEleEvts->Clone("hTrgRecoVsRecoEle");
   hTrgRecoVsRecoEleEB = (TH1F*)hRecoEleEvtsEB->Clone("hTrgRecoVsRecoEleEB");
   hTrgRecoVsRecoEleEE = (TH1F*)hRecoEleEvtsEE->Clone("hTrgRecoVsRecoEleEE");
   hTrgRecoVsRecoMu = (TH1F*)hRecoMuEvts->Clone("hTrgRecoVsRecoMu");
   hAcc->Divide(hGenEvts);
   hAccEle->Divide(hGenEvts);
   hAccEleEB->Divide(hGenEvts);
   hAccEleEE->Divide(hGenEvts);
   hAccMu->Divide(hGenEvts);
   hAccTimesTrgEff->Divide(hGenEvts);
   hTrgEff->Divide(hGenEvtsInAcc);
   hAccTimesEff->Divide(hGenEvts);
   hAccTimesEffEB->Divide(hGenEvts);
   hAccTimesEffEE->Divide(hGenEvts);
   hAccTimesEffEle->Divide(hGenEvts);
   hAccTimesEffEleEB->Divide(hGenEvts);
   hAccTimesEffEleEE->Divide(hGenEvts);
   hAccTimesEffMu->Divide(hGenEvts);
   hAccTimesEffNoTrg->Divide(hGenEvts);
   //hAccTimesEffNoTrgEB->Divide(hGenEvts);
   //hAccTimesEffNoTrgEE->Divide(hGenEvts);
   hAccTimesEffNoTrgEle->Divide(hGenEvts);
   hAccTimesEffNoTrgEleEB->Divide(hGenEvts);
   hAccTimesEffNoTrgEleEE->Divide(hGenEvts);
   hAccTimesEffNoTrgMu->Divide(hGenEvts);
   hEffAftTrg->Divide(hTrgEvts);
   hEffAftTrgEle->Divide(hTrgEvts);
   hEffAftTrgEleEB->Divide(hTrgEvts);
   hEffAftTrgEleEE->Divide(hTrgEvts);
   hEffAftTrgMu->Divide(hTrgEvts);
   hTrgRecoVsReco->Divide(hRecoNoTrgEvts);
   //hTrgRecoVsRecoEB->Divide(hRecoNoTrgEvtsEB);
   //hTrgRecoVsRecoEE->Divide(hRecoNoTrgEvtsEE);
   hTrgRecoVsRecoEle->Divide(hRecoNoTrgEleEvts);
   hTrgRecoVsRecoEleEB->Divide(hRecoNoTrgEleEvtsEB);
   hTrgRecoVsRecoEleEE->Divide(hRecoNoTrgEleEvtsEE);
   hTrgRecoVsRecoMu->Divide(hRecoNoTrgMuEvts);

   // plot
   TCanvas *accTimesEffPlot = new TCanvas("accTimesEffPlot", "acc x eff", 100, 100, 600, 600);
   TPad *accTimesEffPad = new TPad("accTimesEffPad", "acc x eff pad", 0., 0., 1., 1.);
   accTimesEffPad->SetBottomMargin(0.12);
   accTimesEffPad->SetBorderMode(0);
   accTimesEffPad->SetBorderSize(2);
   accTimesEffPad->SetFrameBorderMode(0);
   accTimesEffPad->SetFillColor(0);
   accTimesEffPad->SetFrameFillColor(0);
   accTimesEffPad->SetLeftMargin(0.11);
   accTimesEffPad->SetRightMargin(0.09);
   accTimesEffPad->SetTopMargin(0.08);
   accTimesEffPad->SetTickx(1);
   accTimesEffPad->SetTicky(1);
   accTimesEffPad->Draw();
   accTimesEffPad->cd();

   gStyle->SetTitleFont(font);
   gStyle->SetLabelFont(font);
   gStyle->SetLegendFont(font);
   gStyle->SetOptStat(0);
   gStyle->SetOptTitle(0);
   gStyle->SetOptFit(1111);
   gStyle->SetTitleXOffset(1.);
   gStyle->SetTitleYOffset(1.3);
   gPad->SetTicks(1, 1);
   gPad->SetGrid(1, 1);

   TH1F* hAccTimesEff2 = (TH1F*)hAccTimesEff->Clone("hAccTimesEff2");

   TF1 *fitFunc = new TF1("fitFunc", "[0] + [1]/ (x + [2]) + [3]*x", 10., 5010.);
   //TF1 *fitFuncEB = new TF1("fitFuncEB", "[0] + [1]/ (x + [2])", 10., 5010.);
   TF1 *fitFuncEB = new TF1("fitFuncEB", "[0] + [1]/ (x + [2]) + [3]*x", 10., 5010.);
   TF1 *fitFuncEE = new TF1("fitFuncEE", "[0] + [1]/ (x*x + [2])", 10., 5010.);
   fitFunc->SetLineColor(kBlue);
   fitFuncEB->SetLineColor(kBlue);
   fitFuncEE->SetLineColor(kBlue);
   hAccTimesEff->Fit("fitFunc", "", "", 480., 5010.);
   hAccTimesEffEB->Fit("fitFuncEB", "", "", 480., 5010.);
   hAccTimesEffEE->Fit("fitFuncEE", "", "", 480., 5010.);
   cout << "Chi^2 / NDF: " << fitFunc->GetChisquare() << " / " << fitFunc->GetNDF() << ", prob: " << fitFunc->GetProb() << endl;
   cout << "Chi^2 / NDF EB: " << fitFuncEB->GetChisquare() << " / " << fitFuncEB->GetNDF() << ", prob: " << fitFuncEB->GetProb() << endl;
   cout << "Chi^2 / NDF EE: " << fitFuncEE->GetChisquare() << " / " << fitFuncEE->GetNDF() << ", prob: " << fitFuncEE->GetProb() << endl;

   hAccTimesEff->GetYaxis()->SetTitle("acc x eff");
   hAccTimesEff->GetYaxis()->SetRangeUser(0., 1.);
   hAccTimesEff->Draw();
   TLatex *tex = new TLatex(0.22, 0.21, "P(M|p0,p1,p2,p3) = p0 + #frac{p1}{M+p2} + p3*M");
   tex->SetNDC();
   tex->SetTextFont(font);
   tex->SetLineWidth(2);
   tex->SetTextSize(0.03);
   tex->Draw();
   tex->DrawLatex(0.109, 0.935, "CMS Simulation, 8 TeV");
   tex->DrawLatex(0.17, 0.85, "trg + electron + muon");

   TCanvas *accTimesEffPlotEB = new TCanvas("accTimesEffPlotEB", "acc x eff, barrel electron + muon", 100, 100, 600, 600);
   TPad *accTimesEffPadEB = (TPad*)accTimesEffPad->Clone("accTimesEffPadEB");
   accTimesEffPadEB->Draw(); 
   accTimesEffPadEB->cd();
   hAccTimesEffEB->GetYaxis()->SetTitle("acc x eff");
   hAccTimesEffEB->GetYaxis()->SetRangeUser(0., 1.);
   hAccTimesEffEB->Draw();
   tex->DrawLatex(0.109, 0.935, "CMS Simulation, 8 TeV");
   //tex->DrawLatex(0.46, 0.21, "P(M|p0,p1,p2) = p0 + #frac{p1}{M+p2}");
   tex->DrawLatex(0.22, 0.21, "P(M|p0,p1,p2,p3) = p0 + #frac{p1}{M+p2} + p3*M");
   tex->DrawLatex(0.17, 0.85, "trg + barrel electron + muon");

   TCanvas *accTimesEffPlotEE = new TCanvas("accTimesEffPlotEE", "acc x eff, endcap electron + muon", 100, 100, 600, 600);
   TPad *accTimesEffPadEE = (TPad*)accTimesEffPad->Clone("accTimesEffPadEE");
   accTimesEffPadEE->Draw(); 
   accTimesEffPadEE->cd();
   hAccTimesEffEE->GetYaxis()->SetTitle("acc x eff");
   hAccTimesEffEE->GetYaxis()->SetRangeUser(0., 1.);
   hAccTimesEffEE->Draw();
   tex->DrawLatex(0.109, 0.935, "CMS Simulation, 8 TeV");
   tex->DrawLatex(0.45, 0.38, "P(M|p0,p1,p2) = p0 + #frac{p1}{M^{2}+p2}");
   tex->DrawLatex(0.17, 0.85, "trg + endcap electron + muon");

   TCanvas *accTimesEffObjPlot = new TCanvas("accTimesEffObjPlot", "acc x eff, objects", 100, 100, 600, 600);
   TPad *accTimesEffObjPad = (TPad*)accTimesEffPad->Clone("accTimesEffObjPad");
   accTimesEffObjPad->Draw(); 
   accTimesEffObjPad->cd();
   hAccTimesEffEle->GetYaxis()->SetTitle("acc x eff");
   hAccTimesEffEle->GetYaxis()->SetRangeUser(0., 1.);
   hAccTimesEffEle->SetMarkerStyle(kFullSquare);
   hAccTimesEffEle->SetMarkerColor(kViolet);
   hAccTimesEffEle->SetLineColor(kViolet);
   hAccTimesEffEle->Draw();
   hAccTimesEffEleEB->SetMarkerStyle(kFullTriangleUp);
   hAccTimesEffEleEB->SetMarkerColor(kRed);
   hAccTimesEffEleEB->SetLineColor(kRed);
   hAccTimesEffEleEB->Draw("same");
   hAccTimesEffEleEE->SetMarkerStyle(kFullTriangleDown);
   hAccTimesEffEleEE->SetMarkerColor(kBlue);
   hAccTimesEffEleEE->SetLineColor(kBlue);
   hAccTimesEffEleEE->Draw("same");
   hAccTimesEffMu->SetMarkerStyle(34);
   hAccTimesEffMu->SetMarkerColor(kGreen+1);
   hAccTimesEffMu->SetLineColor(kGreen+1);
   hAccTimesEffMu->Draw("same");
   hAccTimesEff2->Draw("same");
   TLegend* legend = new TLegend(0.592, 0.279, 0.881, 0.467);
   legend->SetTextFont(font);
   legend->SetTextSize(0.03);
   legend->SetBorderSize(0);
   legend->SetLineColor(1);
   legend->SetLineStyle(1);
   legend->SetLineWidth(1);
   legend->SetFillColor(19);
   legend->SetFillStyle(0);
   legend->AddEntry(hAccTimesEff, "total acc x eff");
   legend->AddEntry(hAccTimesEffMu, "muons");
   legend->AddEntry(hAccTimesEffEle, "all electrons");
   legend->AddEntry(hAccTimesEffEleEB, "barrel electrons");
   legend->AddEntry(hAccTimesEffEleEE, "endcap electrons");
   legend->Draw("same");
   tex->DrawLatex(0.109, 0.935, "CMS Simulation, 8 TeV");
   tex->DrawLatex(0.17, 0.85, "trg: HLT_Mu22_Photon22_CaloIdL");

   // acc x eff with no trg applied
   TCanvas *accTimesEffNoTrgObjPlot = new TCanvas("accTimesEffNoTrgObjPlot", "acc x eff, no trigger, objects", 100, 100, 600, 600);
   TPad *accTimesEffNoTrgObjPad = (TPad*)accTimesEffPad->Clone("accTimesEffNoTrgObjPad");
   accTimesEffNoTrgObjPad->Draw(); 
   accTimesEffNoTrgObjPad->cd();
   hAccTimesEffNoTrgEle->GetYaxis()->SetTitle("acc x eff");
   hAccTimesEffNoTrgEle->GetYaxis()->SetRangeUser(0., 1.);
   hAccTimesEffNoTrgEle->SetMarkerStyle(kFullSquare);
   hAccTimesEffNoTrgEle->SetMarkerColor(kViolet);
   hAccTimesEffNoTrgEle->SetLineColor(kViolet);
   hAccTimesEffNoTrgEle->Draw();
   hAccTimesEffNoTrgEleEB->SetMarkerStyle(kFullTriangleUp);
   hAccTimesEffNoTrgEleEB->SetMarkerColor(kRed);
   hAccTimesEffNoTrgEleEB->SetLineColor(kRed);
   hAccTimesEffNoTrgEleEB->Draw("same");
   hAccTimesEffNoTrgEleEE->SetMarkerStyle(kFullTriangleDown);
   hAccTimesEffNoTrgEleEE->SetMarkerColor(kBlue);
   hAccTimesEffNoTrgEleEE->SetLineColor(kBlue);
   hAccTimesEffNoTrgEleEE->Draw("same");
   hAccTimesEffNoTrgMu->SetMarkerStyle(34);
   hAccTimesEffNoTrgMu->SetMarkerColor(kGreen+1);
   hAccTimesEffNoTrgMu->SetLineColor(kGreen+1);
   hAccTimesEffNoTrgMu->Draw("same");
   hAccTimesEffNoTrg->Draw("same");
   TLegend* accXeffNoTrg = (TLegend*)legend->Clone("effAftTrgLegend");
   accXeffNoTrg->Clear();
   accXeffNoTrg->AddEntry(hAccTimesEffNoTrg, "total acc x eff");
   accXeffNoTrg->AddEntry(hAccTimesEffNoTrgMu, "muons");
   accXeffNoTrg->AddEntry(hAccTimesEffNoTrgEle, "all electrons");
   accXeffNoTrg->AddEntry(hAccTimesEffNoTrgEleEB, "barrel electrons");
   accXeffNoTrg->AddEntry(hAccTimesEffNoTrgEleEE, "endcap electrons");
   accXeffNoTrg->Draw("same");
   tex->DrawLatex(0.109, 0.935, "CMS Simulation, 8 TeV");
   tex->DrawLatex(0.17, 0.85, "trg: none");

   // efficiency on triggered events
   TCanvas *effAftTrgPlot = new TCanvas("effAftTrgPlot", "efficiency after trigger", 100, 100, 600, 600);
   TPad *effAftTrgPad = (TPad*)accTimesEffPad->Clone("effAftTrgPad");
   effAftTrgPad->Draw(); 
   effAftTrgPad->cd();
   hEffAftTrgEle->GetYaxis()->SetTitle("eff");
   hEffAftTrgEle->GetYaxis()->SetRangeUser(0., 1.);
   hEffAftTrgEle->SetMarkerStyle(kFullSquare);
   hEffAftTrgEle->SetMarkerColor(kViolet);
   hEffAftTrgEle->SetLineColor(kViolet);
   hEffAftTrgEle->Draw();
   hEffAftTrgEleEB->SetMarkerStyle(kFullTriangleUp);
   hEffAftTrgEleEB->SetMarkerColor(kRed);
   hEffAftTrgEleEB->SetLineColor(kRed);
   hEffAftTrgEleEB->Draw("same");
   hEffAftTrgEleEE->SetMarkerStyle(kFullTriangleDown);
   hEffAftTrgEleEE->SetMarkerColor(kBlue);
   hEffAftTrgEleEE->SetLineColor(kBlue);
   hEffAftTrgEleEE->Draw("same");
   hEffAftTrgMu->SetMarkerStyle(34);
   hEffAftTrgMu->SetMarkerColor(kGreen+1);
   hEffAftTrgMu->SetLineColor(kGreen+1);
   hEffAftTrgMu->Draw("same");
   hEffAftTrg->Draw("same");
   TLegend* effAftTrgLegend = (TLegend*)legend->Clone("effAftTrgLegend");
   effAftTrgLegend->Clear();
   effAftTrgLegend->AddEntry(hEffAftTrg, "total eff after trigger");
   effAftTrgLegend->AddEntry(hEffAftTrgMu, "muons");
   effAftTrgLegend->AddEntry(hEffAftTrgEle, "all electrons");
   effAftTrgLegend->AddEntry(hEffAftTrgEleEB, "barrel electrons");
   effAftTrgLegend->AddEntry(hEffAftTrgEleEE, "endcap electrons");
   effAftTrgLegend->Draw("same");
   tex->DrawLatex(0.109, 0.935, "CMS Simulation, 8 TeV");
   tex->DrawLatex(0.14, 0.15, "trg: HLT_Mu22_Photon22_CaloIdL");

   // acceptance
   TCanvas *accPlot = new TCanvas("accPlot", "acc", 100, 100, 600, 600);
   TPad *accPad = (TPad*)accTimesEffPad->Clone("accPad");
   accPad->Draw(); 
   accPad->cd();
   hAcc->GetYaxis()->SetTitle("acc");
   hAcc->GetYaxis()->SetRangeUser(0., 1.);
   hAccEle->SetMarkerStyle(kFullSquare);
   hAccEle->SetMarkerColor(kViolet);
   hAccEle->SetLineColor(kViolet);
   hAccEle->Draw();
   hAccEleEB->SetMarkerStyle(kFullTriangleUp);
   hAccEleEB->SetMarkerColor(kRed);
   hAccEleEB->SetLineColor(kRed);
   hAccEleEB->Draw("same");
   hAccEleEE->SetMarkerStyle(kFullTriangleDown);
   hAccEleEE->SetMarkerColor(kBlue);
   hAccEleEE->SetLineColor(kBlue);
   hAccEleEE->Draw("same");
   hAccMu->SetMarkerStyle(34);
   hAccMu->SetMarkerColor(kGreen+1);
   hAccMu->SetLineColor(kGreen+1);
   hAccMu->Draw("same");
   hAcc->Draw("same");
   TLegend* accLegend = (TLegend*)legend->Clone("accLegend");
   accLegend->Clear();
   accLegend->AddEntry(hAcc, "total acceptance");
   accLegend->AddEntry(hAccMu, "muons");
   accLegend->AddEntry(hAccEle, "all electrons");
   accLegend->AddEntry(hAccEleEB, "barrel electrons");
   accLegend->AddEntry(hAccEleEE, "endcap electrons");
   accLegend->Draw("same");
   tex->DrawLatex(0.109, 0.935, "CMS Simulation, 8 TeV");

   // reco with trg vs. reco
   TCanvas *trgRecoVsRecoPlot = new TCanvas("trgRecoVsRecoPlot", "reco with trg vs. reco", 100, 100, 600, 600);
   TPad *trgRecoVsRecoPad = (TPad*)accTimesEffPad->Clone("trgRecoVsRecoPad");
   trgRecoVsRecoPad->Draw(); 
   trgRecoVsRecoPad->cd();
   hTrgRecoVsRecoEle->GetYaxis()->SetTitle("eff");
   hTrgRecoVsRecoEle->GetYaxis()->SetRangeUser(0., 1.);
   hTrgRecoVsRecoEle->SetMarkerStyle(kFullSquare);
   hTrgRecoVsRecoEle->SetMarkerColor(kViolet);
   hTrgRecoVsRecoEle->SetLineColor(kViolet);
   hTrgRecoVsRecoEle->Draw();
   //hTrgRecoVsRecoEleEB->SetMarkerStyle(kFullTriangleUp);
   //hTrgRecoVsRecoEleEB->SetMarkerColor(kRed);
   //hTrgRecoVsRecoEleEB->SetLineColor(kRed);
   //hTrgRecoVsRecoEleEB->Draw("same");
   //hTrgRecoVsRecoEleEE->SetMarkerStyle(kFullTriangleDown);
   //hTrgRecoVsRecoEleEE->SetMarkerColor(kBlue);
   //hTrgRecoVsRecoEleEE->SetLineColor(kBlue);
   //hTrgRecoVsRecoEleEE->Draw("same");
   hTrgRecoVsRecoMu->SetMarkerStyle(34);
   hTrgRecoVsRecoMu->SetMarkerColor(kGreen+1);
   hTrgRecoVsRecoMu->SetLineColor(kGreen+1);
   hTrgRecoVsRecoMu->Draw("same");
   hTrgRecoVsReco->Draw("same");
   TLegend* trgRecoVsRecoLegend = (TLegend*)legend->Clone("trgRecoVsRecoLegend");
   trgRecoVsRecoLegend->Clear();
   trgRecoVsRecoLegend->AddEntry(hTrgRecoVsReco, "total");
   trgRecoVsRecoLegend->AddEntry(hTrgRecoVsRecoMu, "muons");
   trgRecoVsRecoLegend->AddEntry(hTrgRecoVsRecoEle, "electrons");
   //trgRecoVsRecoLegend->AddEntry(hTrgRecoVsRecoEleEB, "barrel electrons");
   //trgRecoVsRecoLegend->AddEntry(hTrgRecoVsRecoEleEE, "endcap electrons");
   trgRecoVsRecoLegend->Draw("same");
   tex->DrawLatex(0.109, 0.935, "CMS Simulation, 8 TeV");

   TCanvas *accTimesTrgEffPlot = new TCanvas("accTimesTrgEffPlot", "acc x trigger eff", 100, 100, 600, 600);
   TPad *accTimesTrgEffPad = (TPad*)accTimesEffPad->Clone("accTimesTrgEffPad");
   accTimesTrgEffPad->Draw(); 
   accTimesTrgEffPad->cd();
   hAccTimesTrgEff->GetYaxis()->SetTitle("acc x trg eff");
   hAccTimesTrgEff->GetYaxis()->SetRangeUser(0., 1.);
   hAccTimesTrgEff->SetMarkerStyle(20);
   hAccTimesTrgEff->SetMarkerColor(kCyan);
   hAccTimesTrgEff->SetLineColor(kCyan);
   hAccTimesTrgEff->Draw();
   hTrgEff->SetMarkerStyle(21);
   hTrgEff->SetMarkerColor(kMagenta);
   hTrgEff->SetLineColor(kMagenta);
   hTrgEff->Draw("same");
   TLegend* trgLegend = (TLegend*)legend->Clone("trgLegend");
   trgLegend->Clear();
   trgLegend->AddEntry(hTrgEff, "trigger eff in acc");
   trgLegend->AddEntry(hAccTimesTrgEff, "acc x trigger eff");
   trgLegend->Draw("same");
   tex->DrawLatex(0.109, 0.935, "CMS Simulation, 8 TeV");

   // safe in various file formats
   if (saveSpec) {
     if (saveAsPdf) {
        accTimesTrgEffPlot->Print(plotDir + accTimesTrgEffPlot->GetName() + ".pdf", "pdf");
        accTimesEffPlot->Print(plotDir + accTimesEffPlot->GetName() + ".pdf", "pdf");
        accTimesEffPlotEB->Print(plotDir + accTimesEffPlotEB->GetName() + ".pdf", "pdf");
        accTimesEffPlotEE->Print(plotDir + accTimesEffPlotEE->GetName() + ".pdf", "pdf");
        accTimesEffObjPlot->Print(plotDir + accTimesEffObjPlot->GetName() + ".pdf", "pdf");
        accTimesEffNoTrgObjPlot->Print(plotDir + accTimesEffNoTrgObjPlot->GetName() + ".pdf", "pdf");
        effAftTrgPlot->Print(plotDir + effAftTrgPlot->GetName() + ".pdf", "pdf");
        trgRecoVsRecoPlot->Print(plotDir + trgRecoVsRecoPlot->GetName() + ".pdf", "pdf");
        accPlot->Print(plotDir + accPlot->GetName() + ".pdf", "pdf");
     }
     if (saveAsPng) {
        accTimesTrgEffPlot->Print(plotDir + accTimesTrgEffPlot->GetName() + ".png", "png");
        accTimesEffPlot->Print(plotDir + accTimesEffPlot->GetName() + ".png", "png");
        accTimesEffPlotEB->Print(plotDir + accTimesEffPlotEB->GetName() + ".png", "png");
        accTimesEffPlotEE->Print(plotDir + accTimesEffPlotEE->GetName() + ".png", "png");
        accTimesEffObjPlot->Print(plotDir + accTimesEffObjPlot->GetName() + ".png", "png");
        accTimesEffNoTrgObjPlot->Print(plotDir + accTimesEffNoTrgObjPlot->GetName() + ".png", "png");
        effAftTrgPlot->Print(plotDir + effAftTrgPlot->GetName() + ".png", "png");
        trgRecoVsRecoPlot->Print(plotDir + trgRecoVsRecoPlot->GetName() + ".png", "png");
        accPlot->Print(plotDir + accPlot->GetName() + ".png", "png");
     }
     if (saveAsRoot) {
        accTimesTrgEffPlot->Print(plotDir + accTimesTrgEffPlot->GetName() + ".root", "root");
        accTimesEffPlot->Print(plotDir + accTimesEffPlot->GetName() + ".root", "root");
        accTimesEffPlotEB->Print(plotDir + accTimesEffPlotEB->GetName() + ".root", "root");
        accTimesEffPlotEE->Print(plotDir + accTimesEffPlotEE->GetName() + ".root", "root");
        accTimesEffObjPlot->Print(plotDir + accTimesEffObjPlot->GetName() + ".root", "root");
        accTimesEffNoTrgObjPlot->Print(plotDir + accTimesEffNoTrgObjPlot->GetName() + ".root", "root");
        effAftTrgPlot->Print(plotDir + effAftTrgPlot->GetName() + ".root", "root");
        trgRecoVsRecoPlot->Print(plotDir + trgRecoVsRecoPlot->GetName() + ".root", "root");
        accPlot->Print(plotDir + accPlot->GetName() + ".root", "root");
     }
   }

   // write histos to file
   output->cd();
   hGenEvts->Write();
   hGenEvtsEleInAcc->Write();
   hGenEvtsEleInAccEB->Write();
   hGenEvtsEleInAccEE->Write();
   hGenEvtsMuInAcc->Write();
   hGenEvtsInAcc->Write();
   hTrgEvts->Write();
   hRecoEvts->Write();
   hRecoEvtsEB->Write();
   hRecoEvtsEE->Write();
   hRecoEleEvts->Write();
   hRecoEleEvtsEB->Write();
   hRecoEleEvtsEE->Write();
   hRecoMuEvts->Write();
   hAccEle->Write();
   hAccEleEB->Write();
   hAccEleEE->Write();
   hAccMu->Write();
   hAccTimesTrgEff->Write();
   hTrgEff->Write();
   hAccTimesEff->Write();
   hAccTimesEffEB->Write();
   hAccTimesEffEE->Write();
   hAccTimesEffEle->Write();
   hAccTimesEffEleEB->Write();
   hAccTimesEffEleEE->Write();
   hAccTimesEffMu->Write();
   hEffAftTrg->Write();
   hEffAftTrgEle->Write();
   hEffAftTrgEleEB->Write();
   hEffAftTrgEleEE->Write();
   hEffAftTrgMu->Write();
   fitFunc->Write();
   fitFuncEB->Write();
   fitFuncEE->Write();

   output->Close();
   timer.Stop();
   timer.Print();
}