"error-bars" in TH1::GetAsymmetry calculation

Hi.

I’m looking at the implementation of the TH1::GetAsymmetry method (link).

The documentation clearly states that for the uncertainty on the bin contents a Poisson distribution is assumed [ie. sigma(N_i) = sqrt(N_i) ].

Wouldn’t it be better to implement a generic formula where the uncertainty is given by the GetBinError method? the user could then use this tool for the (common) case where the asymmetry is extracted from a data sample with background (resulting in error bars larger than the binomial ones).

The modification is pretty simple. If I did the math correctly, one has to replace

``error = TMath::Sqrt((1-as)*(1-as)*a+(1+as)*(1+as)*(c2*c2*b+b*b*dc2*dc2))/bot;``

by

``error = 2*TMath::Sqrt(a*a*c2*c2*db*db + c2*c2*b*b*da*da+a*a*b*b*dc2*dc2)/(a+b)``

where

`````` da   = h1->GetBinError(i,j,k);
db   = h2->GetBinError(i,j,k);``````

Just a thought.

Cheers,

–Christos

Jonathan Hays pointed out that the uncertainty formula

``error = 2*TMath::Sqrt(a*a*c2*c2*db*db + c2*c2*b*b*da*da+a*a*b*b*dc2*dc2)/(a+b)``

needs to be modified as follows:

``error = 2*TMath::Sqrt(a*a*c2*c2*db*db + c2*c2*b*b*da*da+a*a*b*b*dc2*dc2)/(bot*bot)``

ie. the denominator should be code[/code] and not code[/code].

–Christos

Christos,

I introduced the fix in your original code as suggested by Jonathan.

Rene