Re: TH1 Basic (and old) questions

Rene Brun (Rene.Brun@cern.ch)
Tue, 04 Nov 1997 15:07:50 +0100


Laurent Aphecetche wrote:

> Hi,
>
> 1) What's the equivalent of PAW H/PLOT ID(xmin:xmax) ?
>
> By now, I just found this (heavy) way to do it :
>
> TH1F* h = ...
> .
> .
> Int_t i1 = h->GetXaxis()->FindBin(xmin) ;
> Int_t i2 = h->GetXaxis()->FindBin(xmax) ;
>
> h->GetXaxis()->SetRange(i1,i2) ;
>
> Why about a TH1::SetRange(xmin,xmax) function ? or maybe
> TH1::Draw(xmin,xmax) ?
>

This could be implemented. However, to be consistent, one would haveto
also implement
TH1::SetRange(xmin,xmax,ymin,ymax)
TH1::setRange(xmin,xmax,ymin,ymax,zmin,zmax)
TH1::SetRange(binx1,binx2)
TH1::SetRange(binx1,binx2,biny1,biny2),etc
TH1::SetRange(binx1,xmax,...) and all possible combinations

If we implement TH1::Draw(xmin,xmax), we should also support
all the above combinations.
and what about TH1::Fit
and what about the function you are proposing below as well.

> 2) What about a TH1::GetIntegral(xmin,xmax) function to have to sum of
> weights between xmin and xmax ?

I would prefer TH1::GetIntegral(binx1,binx2) and same for 2-D.
Otherwise if xmin,xmax do not coincide with the lower/upper limits
of a bin, do you expect this function to compute an approximation
for the integral in the bins at the edge, or do you simply want
to compute the bin number where xmin and xmax (bin1,bin2)correspond
and return the integral as the suim of bin contents from bin1 to bin2
included?

I also would like to mention the already existing possibility to zoom an

histogram via the DrawPanel and to fit a subset of an histogram
via FitPanel.

If you activate the "Show Event Status" item in the "Options" menu,
you can also get the integral of an histogram from bin 1 up to
the bin corresponding to the mouse position.

Rene Brun