void eff(){ //TFile *myFile = TFile::Open("OniaTree_JpsiMM_5p02TeV_TuneCUETP8M1_nofilter_pp502Fall15-MCRUN2_71_V1-v1_GENONLY.root"); TFile *myFile = TFile::Open("/home/christos/public_html/Pythia/pythia8226/examples/hist1.root"); TTree *tree = (TTree*)myFile->Get("tree"); TH2D *histoPtEta = new TH2D("histoPtEta","Pt Vs. Eta",100,-2.5,2.5,100,0,.5); histoPtEta->GetXaxis()->SetTitle("#eta"); histoPtEta->GetYaxis()->SetTitle("P_{T} (GeV)"); TH2D *histoPtEta_num = new TH2D("histoPtEta_num","Pt Vs. Eta (After Cuts)",100,-2.5,2.5,100,0,.5); histoPtEta_num->GetXaxis()->SetTitle("#eta"); histoPtEta_num->GetYaxis()->SetTitle("P_{T} (GeV)"); TH2D *histoPtEta_eff = new TH2D("histoPtEta_eff","Pt Vs. Eta Eff.",100,-2.5,2.5,100,0,.5); histoPtEta_eff->GetXaxis()->SetTitle("#eta"); histoPtEta_eff->GetYaxis()->SetTitle("P_{T} (GeV)"); TCanvas *c0 = new TCanvas(); tree->Draw("electronPt:electronRap>>histoPtEta","","COLZ"); TCanvas *c1 = new TCanvas(); tree->Draw("electronPt:electronRap>>histoPtEta_num","((electronPt>3.5&&TMath::Abs(electronRap)<1.2)||(electronPt>(5.77-1.8*TMath::Abs(electronRap))&&TMath::Abs(electronRap)>=1.2&&TMath::Abs(electronRap)<2.1)||(electronPt>1.8&&TMath::Abs(electronRap)>=2.1&&TMath::Abs(electronRap)<2.4))","COLZ"); histoPtEta_eff->Sumw2(); histoPtEta_eff->Divide(histoPtEta_num,histoPtEta,1,1,"B"); TCanvas *c2 = new TCanvas(); histoPtEta_eff->Draw("COLZ"); }