Re: Integral of 1-D histos
Rene Brun (Rene.Brun@cern.ch)
Thu, 11 Jun 1998 12:03:26 +0200
Nick van Eijndhoven wrote:
>
> Dear friends,
> I have several 1-D histos of which I want to determine the
> integral of the bin contents above some x-value and the error
> on the integral value.
> Currently I do this in my private C++ code by looping over the
> bins and calculating everything myself, however I saw the
> TH1F::Integral in the docs and wonder if there is something
> available to obtain the above.
> What would be convenient to my opinion is something like
>
> TH1F* h // The 1-D histo which is then filled with data
>
> float lower,upper; // The lower- and upper bounds for the integral
>
> float val,err; // Value and error of the integral
>
> val=h->Integral(lower,upper,err)
>
> Is something like this available already ?
> Note that I prefer the integral to be specified between the real
> boundaries instead if the bin numbers. To my opinion this makes
> complicated operations more clear in the code.
> --
Nick,
If you look in the TH1 specs, you will see
TH1::Integral()
TH1::Integral(int binmin, int binmax)
The reason for choosing bins and not abscissa values has been discussed
several times in roottalk
- problem with variable bin sizes 1-d, 2-d and 3-d histograms
- what is the meaning of xmin or xmax if they do not correspond
exactly to the edges of the bin.
In the case of Integral, for example, do you expect Integral
to consider the partial integral of the bins at the edges?
or to assume the complete bin?
Errors on the Integral are not implemented now.
Rene