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