Re: Function normalization after a fit to a histogram.

From: Rene Brun (Rene.Brun@cern.ch)
Date: Mon May 26 1997 - 09:56:03 MEST


OLSZEWSKI@vsk02.ifj.edu.pl wrote:
> 
>  Hi,
> 
>   There is a difference in behaviour between PAW and ROOT in function
> normalization after it was fit to a histogram. In PAW I get the same
> sum of weigths for a function and a histogram. In ROOT function is
> visualized by default in a 100 bin histogram, independend of the number
> of histogram bins. Then the two sums of weights differ.
>   If the above is true it should be either changed or a warning somewhere
> should be placed.

By default, Root always draws the fitted function computed
at 100 equidistant points. This is better than PAW when drawing
histograms with only a few channels.

The chunk of code below is an example illustrating how to get
a fitted function associated to an histogram and how to return
the function integral normalized to the number of bins in
in the histogram:

    Root > h->Fit("gaus");
    Root > TF1 *g = h->GetFunction("gaus");
    Root > TH1F *htemp = g->GetHistogram();
    Root > Double_t integral = htemp->GetSum()*h->GetNbinsX()/100.

Note that this example is valid only for a fixed bin size histogram.
We should may be provide a service function in TH1 returning
the integral (normalized or not) of a function with a given name.
(More than one function can be fitted to an histogram).

Rene Brun



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:26:19 MET