Re: TH1::FillError() function

Nick van Eijndhoven (Nick@phys.uu.nl)
Wed, 02 Dec 1998 17:33:18 +0100


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

Hi Faouzi,
If I correctly understand what you want, you could use a
TGraphErrors object instead of a TH1F.
Here you can enter points (x,y) and the errors dx and dy as you
like and you can Draw(), Fit() etc....

-- 

Cheers,

_/_/ _/ _/ _/_/_/_/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/_/ _/ _/_/ _/ _/ _/ _/ _/ _/ _/ _/_/_/_/ _/ _/

*----------------------------------------------------------------------* Dr. Nick van Eijndhoven Department of Subatomic Physics email : nick@phys.uu.nl Utrecht University / NIKHEF tel. +31-30-2532331 (direct) P.O. Box 80.000 tel. +31-30-2531492 (secr.) NL-3508 TA Utrecht fax. +31-30-2518689 The Netherlands WWW : http://www.phys.uu.nl/~nick Office : Ornstein lab. 172 ---------------------------------------------------------------------- tel. +41-22-7679751 (direct) CERN PPE Division / ALICE exp. tel. +41-22-7675857 (secr.) CH-1211 Geneva 23 fax. +41-22-7679480 Switzerland CERN beep : 13+7294 Office : B 160 1-012 *----------------------------------------------------------------------*