{ // Compute the efficiency uncertainty for a counting experiment // using an inversion of the binomial distribution // N is the number of trials // p is the success probability // K is the number of success Int_t N = 400; Int_t nBinsP = 101; Int_t nK = 7; // number of K cases to plot Double_t effEstimate; // Histo for the confidence belt TH2F hbelt( "hbelt", "The confidence belt", nBinsP, 0., 1.01, N+1, 0, N+1); hbelt.SetXTitle("p"); hbelt.SetYTitle("K"); // Construct the belt using a fixed p Double_t p; Double_t expectedMean; Double_t expectedRMS; Int_t Kmin; Int_t Kmax; Double_t proba; for( Int_t iP=0; iP " << proba << endl; //hbelt.Fill( p, K, proba ); hbelt.SetBinContent( iP+1, K+1, proba); } } // We observe K, what is the distribution of P ? Kmin = 0; Kmax = N; TH1F *hp = new TH1F[nK]; Char_t text[30]; for( Int_t iK=0; iKSetTitle("Conditional prob. of p with K"); } // Display gStyle->SetOptStat(0); TCanvas c("c","Uncertainty on efficiency from belt", 700, 500); TString s; TLatex t; c.Divide(2,1); c.cd(1); hbelt.Draw("colz"); gPad->SetLogz(); gPad->SetGrid(1,1); c.cd(2); TLatex l; l.SetTextSize(.025); for( Int_t iK=0; iKDraw( iK?"Lsame":"L"); sprintf( text, "K=%d", K); l.DrawLatex( (Float_t)K/N, hp[iK]->GetMaximum(), text); } }