Re: TH1::FillError() function

Rene Brun (Rene.Brun@cern.ch)
Thu, 03 Dec 1998 15:46:16 +0100


Faouzi Attallah wrote:
>
> Hi Rene,
>
> On Wed, 2 Dec 1998, Rene Brun wrote:
>
> > Faouzi Attallah wrote:
> > >
> > > Hi Everybody
> > >
> > > I would like to fill up a histogram (hf) with a user-weight-error,
> > > such as
> > > hf->Fill(xval, xweight) ;
> > > hf->FillError(xval, error) ;
> > >
> > > The problem is my *vector(xval, xweight, error) is not sorted to
> > > allow any use of TH1::SetBinContent()/SetBinError()
> > > Any suggestion ..
> > >
> > > Greetings,
> >
> > Hi Faouzi,
> > The normal procedure to fill an histogram with weights and correct
> > storage of the error bars is:
> > TH1F *hf = new TH1F("hf",...
> > hf->Sumw2();
> > hf->Fill(xval,xweight);
> >
> > The error in bin I will be computed by taking sqrt((sum of xweight)^2)
> >
> > Rene Brun
> >
>
> You are right as long as its a statistical error, which is not my
> case where , e.g.,
> error = xweight/sqrt(n) ;
> n being the Number of averages in Schottky spectra.
> Any other suggestion..
>
> Greetings,
> Faouzi

Hi Faouzi,
If your problem is simply to draw a list of unordered points
n,x[n],y[n] with associated errors ex[n],ey[n], you should use
the TGraphErrors class.
See an example in $ROOTSYS/tutorials/gerrors2.C

Rene Brun