#ifndef ROOT_TEfficiency_cxx #define ROOT_TEfficiency_cxx #include "TEfficiency.h" #include "TGraphAsymmErrors.h" #include "TStyle.h" #include "TROOT.h" void eff_new_barrel_v1(){ gStyle->SetOptStat(0); // gROOT->SetStyle("Plain"); gStyle->SetFillColor(10); TCanvas *c1 = new TCanvas("c1", "c1",66,52,700,500); c1->SetFillColor(kWhite); // c1->SetGrid(); const int nbins = 4; double genPartPBins[nbins] = {20.,30.,50.,200.}; TH1F *h3 = new TH1F("h3","PT",nbins-1, genPartPBins); TH1F *h4 = new TH1F("h4","PT",nbins-1, genPartPBins); TH1F *h5 = new TH1F("h5","PT",nbins-1, genPartPBins); TH1F *h6 = new TH1F("h6","PT",nbins-1, genPartPBins); TH1F *h7 = new TH1F("h7","PT",nbins-1, genPartPBins); TH1F *h8 = new TH1F("h8","PT",nbins-1, genPartPBins); TH1F *h9 = new TH1F("h9","PT",nbins-1, genPartPBins); TH1F *h10 = new TH1F("h10","PT",nbins-1, genPartPBins); //Tight ID Barrel float tight_barrel_pass[nbins] = {67499.,412038.,90759.}; float tight_barrel_total[nbins] = {120746.,555850.,108583.}; //Medium ID Barrel float medium_barrel_pass[nbins] = {83113.,468552.,97678.}; float medium_barrel_total[nbins] = {120746.,555850.,108583.}; //Loose ID Barrel float loose_barrel_pass[nbins] = {96315.,510840.,103196.}; float loose_barrel_total[nbins] = {120746.,555850.,108583.}; //Veto ID Barrel float veto_barrel_pass[nbins] = {105184,529357,105127}; float veto_barrel_total[nbins] = {120746,555850,108583}; for(int i=0;i<3;i++) { h3->SetBinContent(i+1,tight_barrel_pass[i]); h4->SetBinContent(i+1,tight_barrel_total[i]); h5->SetBinContent(i+1,medium_barrel_pass[i]); h6->SetBinContent(i+1,medium_barrel_total[i]); h7->SetBinContent(i+1,loose_barrel_pass[i]); h8->SetBinContent(i+1,loose_barrel_total[i]); h9->SetBinContent(i+1,veto_barrel_pass[i]); h10->SetBinContent(i+1,veto_barrel_total[i]); } h3->Sumw2(); h4->Sumw2(); h5->Sumw2(); h6->Sumw2(); h7->Sumw2(); h8->Sumw2(); h9->Sumw2(); h10->Sumw2(); for(int j=0;j<3;j++) { h3->SetBinError(j+1,sqrt(h3->GetBinContent(j+1))); h4->SetBinError(j+1,sqrt(h4->GetBinContent(j+1))); h5->SetBinError(j+1,sqrt(h5->GetBinContent(j+1))); h6->SetBinError(j+1,sqrt(h6->GetBinContent(j+1))); h7->SetBinError(j+1,sqrt(h7->GetBinContent(j+1))); h8->SetBinError(j+1,sqrt(h8->GetBinContent(j+1))); h9->SetBinError(j+1,sqrt(h9->GetBinContent(j+1))); h10->SetBinError(j+1,sqrt(h10->GetBinContent(j+1))); } for(int k = 1; k < 4 ; k++){ cout << "Contents in " << k << " bin = " << h3->GetBinContent(k) << endl; cout << "Errors in " << k << " bin = " << h3->GetBinError(k) << endl; } // Add Two Graphs to MultiGraph TMultiGraph *mg = new TMultiGraph(); TGraphAsymmErrors* gr = new TGraphAsymmErrors(); TGraphAsymmErrors* gr1 = new TGraphAsymmErrors(); TGraphAsymmErrors* gr2 = new TGraphAsymmErrors(); TGraphAsymmErrors* gr3 = new TGraphAsymmErrors(); if(TEfficiency::CheckConsistency(*h3,*h4,"w") && TEfficiency::CheckConsistency(*h5,*h6,"w") && TEfficiency::CheckConsistency(*h7,*h8,"w") && TEfficiency::CheckConsistency(*h9,*h10,"w") ) { gr->BayesDivide(h3,h4,"cl=0.683 b(1,1) mode"); gr1->BayesDivide(h5,h6,"cl=0.683 b(1,1) mode"); gr2->BayesDivide(h7,h8,"cl=0.683 b(1,1) mode"); gr3->BayesDivide(h9,h10,"cl=0.683 b(1,1) mode"); gr->SetTitle("Efficiency Plot in P_{T} Bins"); gr->SetMarkerColor(kRed); gr->SetMarkerStyle(21); gr1->SetTitle("Efficiency Plot in P_{T} Bins"); gr1->SetMarkerColor(kBlue); gr1->SetMarkerStyle(22); gr2->SetTitle("Efficiency Plot in P_{T} Bins"); gr2->SetMarkerColor(kGreen); gr2->SetMarkerStyle(23); gr3->SetTitle("Efficiency Plot in P_{T} Bins"); gr3->SetMarkerColor(kOrange); gr3->SetMarkerStyle(23); mg->Add(gr); mg->Add(gr1); mg->Add(gr2); mg->Add(gr3); } mg->SetTitle("ID+Iso Efficiency Plot in PT Bins (Barrel);P_{T}; ID+Iso Efficiency"); mg->Draw("AP"); gPad->Modified(); mg->SetMinimum(0.60); mg->SetMaximum(1.); mg->GetXaxis()->CenterTitle(1); mg->GetXaxis()->SetTitleOffset(1.2); mg->GetYaxis()->CenterTitle(1); mg->GetYaxis()->SetTitleOffset(1.4); leg = new TLegend(0.4,0.4,0.58,0.6); leg->AddEntry(gr,"Tight Id","lep"); leg->AddEntry(gr1,"Medium Id","lep"); leg->AddEntry(gr2,"Loose Id","lep"); leg->AddEntry(gr3,"Veto Id","lep"); leg->Draw(); c1->SaveAs("PTEff_Id_barrel.png"); }