void example_TEfficiency2D() { //canvas only needed for the documentation // auto c1 = new TCanvas("c1","",600,400); double xbins[] = {0., 1. , 3, 7, 15 }; double ybins[] = {0., 5, 20 }; auto hpass = new TH2D("pass","passed events",4,xbins,2,ybins); auto htot = new TH2D("pass","total events",4,xbins,2,ybins); bool bPassed; TF2 f2("f2","xygaus",0,100,0,100); f2.SetParameters(1,0,5,0,4); double x,y; for(int i=0; i<1000; ++i) { f2.GetRandom2(x,y); auto t = gRandom->Rndm(); if (t < .5) hpass->Fill(x,y); htot->Fill(x,y); } auto c1 = new TCanvas(); c1->Divide(1,2); c1->cd(1); hpass->Draw("COLZ"); c1->cd(2); htot->Draw("COLZ"); TEfficiency* pEff = new TEfficiency(*hpass,*htot); pEff->SetStatisticOption(TEfficiency::kBBayesian); pEff->SetConfidenceLevel(0.68); auto c2 = new TCanvas(); pEff->Draw("EY"); c2->Update(); // needed to get the painted histogram auto heff = pEff->GetPaintedHistogram(); heff->SetMinimum(0.0); c2->Update(); c2->Draw(); }