void efficiency() { //TEfficiency* pEff = 0; TEfficiency* pEff = new TEfficiency("eff","my efficiency;x;#epsilon",20,0,10); TFile* f= new TFile("for_tefficiency.root","recreate"); //TH1F *h1; //TH1F *h2; h1 = (TH1F*)f->Get("Num_p"); h2 = (TH1F*)f->Get("Den_p"); //h_pass and h_total are valid and consistent histograms TFile* pFile = new TFile("myfile.root","recreate"); if(TEfficiency::CheckConsistency(*h1,*h2)) { pEff = new TEfficiency(*h1,*h2); pEff->Write(); pEff->Draw("AP"); } } /*TEfficiency* pEff = 0; TH1D *h_pass = new TH1D("h_pass","pass",10,0,10); TH1D *h_tot = new TH1D("h_tot","tot",10,0,10); for (int i=1;i<11;i++) { h_pass->SetBinContent(i,i); h_tot->SetBinContent(i,2*i); // no need to set the errors (they are automatically = sqrt(content) } h_tot->Draw(); h_pass->Draw("same"); TFile* pFile = new TFile("myfile.root","recreate"); if(TEfficiency::CheckConsistency(*h_pass,*h_tot)) { pEff = new TEfficiency(*h_pass,*h_tot); pEff->Write(); pEff->Draw("AP"); } }*/