Re: Question w.r.t. errors on histogram bins

From: Rene Brun (Rene.Brun@cern.ch)
Date: Wed May 27 1998 - 15:14:04 MEST


Nick van Eijndhoven wrote:
> 
> Dear ROOTers,
> I send this mail just to have a clear idea how exactly
> the errors are treated when adding etc.... several histograms.
> I have two 1-D histograms (TH1F *h1, *h2) for which I have set
> the error for each bin by hand via the SetBinError() facility.
> This I had to do because h1 and h2 are particle spectra which have
> been corrected for reconstruction efficiencies and obviously these
> rec. eff. factors have also an uncertainty.
> Now I have to sum these h1 and h2 into a new histogram :
> 
> TH1F *h3->Add(h1,h2)
> 
> Now my question is whether the error of each bin in h3 is correctly
> set to the sum of the errors of h1 and h2 bins or not.
> Or is the error of the h3 bin just set to the sqrt() of the bin
> content ?
> Note that I did NOT specify h3->Sumw2() since from the docs I
> understand that in that case the error of each h3 bin is just
> the sqrt() of the sum of the squared errors of the h1 and h2 bins.
> The latter is correct for multiplication and division of independent
> histos, but not for additions and subtractions.
> Or do I misunderstand something here ?
> Of course I could calculate and set all the errors by hand, but
> it is convenient if TH1::Add() would treat the errors correctly.
> It would make sense to me if h3->Sumw2() would trigger the
> correct error handling in case of TH1::Add(), whereas without the
> h3->Sumw2() the error would become just the sqrt() of the bin content.
> --

Nick,
To fill an histogram h3 with an operation on h1 and h2 with correct
errors calculations, one possible sequence is:
  //Create h3 as a clone of h1 or h2
  TH1F *h3 = (TH1F*)h1->Clone();

  //Make sure Sumw2 is called for h3
  h3->Sumw2();

  //Perform operation
  h3->Add(h1,h2,c1,c2);

Rene



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