Poisson errors for RooHist

Hello,

I have a data distribution stored as a RooHist which I need to plot with Poisson errors (the equivalent of TH1::SetBinErrorOption(TH1::kPoisson)).

Is there an easy way to do it?

Alternatively, is there a ROOT class/ method that returns the above 68% Poisson CI for a given observed number of events?

Thanks.

Dear devdatta,

If I am not mistaken, RooHist uses Poisson errors by default. Is this no behaving as you would expect?

G Ganis

Hello Ganis,

That was my impression as well.

I am accessing the RooHist object from a TCanvas where it was plotted using RooDataHist::plotOn.
I am not sure if the RooDataHist was built with histograms with PoissonErrors. Would that matter?

Dear devdatta,

I would guess so.

Can you check visually if the errors displayed are compatible with being poissonians?

G Ganis

Yes, they look sadly symmetric. :frowning:

Dear devdatta,

Well, the errors are poissonian, i.e. sqrt(bin_content), but plotted symmetrically, which is good approximation only for a bin content >= 4 .
(Btw, I think this is the same that TH1::SetBinErrorOption(TH1::kPoisson)) does.)

The only solution is to set the asymmetric bins by your self. RooHist is a (derives from) TGraphAsymmErrors: you can use the methods SetPointError to set the errors you need.

G Ganis

Hi Ganis,

Sure, this can be done. That brings me to the second part of my original question:

Alternatively, is there a ROOT class/ method that returns the above 68% Poisson CI for a given observed number of events? :slight_smile:

Thanks.

Hi,

In RooFit to plot Poisson (which is the default if you have unweighted data) you need to use the plot option DataError(RooAbsData::Poisson). Your plot looks to me done with the option DataError(RooAbsData::SumW2).
Probably you have weighted data.

For your second question you can use the code below:

double alpha = 1. - confLevel;
double lower = ROOT::Math::gamma_quantile( alpha/2, n, 1.);
double upper = ROOT::Math::gamma_quantile_c( alpha/2, n+1, 1)

See also the code in TH1.cxx,

and

Lorenzo

Hi Lorenzo,

thanks. this is very helpful. I believe this implementation also gives the correct upper for 0 bin contents, right, as opposed to the standard RooFit value?

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.