Hi Dmitri, See documentation of TH1::Add. It says: // if errors are defined (see TH1::Sumw2), errors are also recalculated // Note that if h1 or h2 have Sumw2 set, Sumw2 is automatically called for this // if not already set. // // IMPORTANT NOTE: If you intend to use the errors of this histogram later // you should call Sumw2 before making this operation. // This is particularly important if you fit the histogram after TH1::Add Rene Brun On Thu, 25 Jul 2002, Dmitri Litvintsev wrote: > > > Hi ROOTers, > > I have attached GIF file of that depicts two histograms. > > Top histogram is obtained by subtracting using TH1::Add(): > > h1->Add(h2,h3,1,-1); > > A glance at error bars of this histogram tells that errors weren't > calculated correctly. The closer the value to zero the smaller is the > error bar (it looks like that error=sqrt(abs(value))...) > > Bottom histogram contains right subtraction, done by handwritten > function: > > void subtract(TH1* h1, TH1*h2, TH1* h3, double a=1, double b=1) { > for (int i=0;i<h1->GetNbinsX(); i++) { > double value = a*h1->GetBinContent(i)+b*h2->GetBinContent(i); > double error = sqrt((a*a*h1->GetBinError(i)*h1->GetBinError(i))+(b*b*h2->GetBinError(i)*h2->GetBinError(i))); > h3->SetBinContent(i,value); > h3->SetBinError(i,error); > } > } > > Errors look right on the bottom one. > > Q: Is this a known feature and I just overlooked the documentation and > there is a switch to calculate the errors right? > > If it is a bug, then I am amazed that: > > - it is overlooked > - the same thing has been in early versions of PAW, > is it a legacy thing... > > > thanks, > Dmitri Litvintsev > > /----------------------------------------------------------\ > | Tel: (630) 840 5005 | > | FAX: (630) 840 2968 | > | office: 149-L CDF Trailers | > | E-mail: litvinse@fnal.gov | > \----------------------------------------------------------/ > > > >
This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:01 MET