problem with TH1F::Rebin()

Chris Jillings (chris@owl.phy.queensu.ca)
Wed, 30 Jun 1999 14:21:31 -0400 (EDT)


Hello,
I think I have found a problem with Rebin. It seems to show itself in
the last bin of a histogram.
I have a 100-bin histo, h, which I rebin to 50 with h->Rebin().
The 50th bin of the histo contains fewer counts than it should. In fact in
contains counts from the 99th, but not the 100th bin of the original
histo.

Looking at the html/source file I think I might have found the problem.

Double_t binContent, binError;
for (bin = 1;bin<=newbins;bin++) {
binContent = 0;
binError = 0;
for (i=0;i<ngroup;i++) {
if (oldbin+i >= nbins) break; // PROBLEM HERE ?? should be >nbins
binContent += oldBins[oldbin+i];
if (oldErrors) binError += oldErrors[oldbin+i]*oldErrors[oldbin+i];
}
hnew->SetBinContent(bin,binContent);
if (oldErrors) hnew->SetBinError(bin,TMath::Sqrt(binError));
oldbin += ngroup;
}

Am I correct?

Thanks,

Chris

==================================================================
= =
= Chris Jillings =
= Department of Physics phone/voice mail: (613) 533-6000x74805 =
= Queen's University fax: (613) 533-6813 =
= Kingston, Ontario email: chris@sno.phy.queensu.ca =
= Canada, K7L 3N6 web: http://sno.phy.queensu.ca =
= =
==================================================================