Re: problem with TH1F::Rebin()

From: Rene Brun (Rene.Brun@cern.ch)
Date: Thu Jul 01 1999 - 08:50:52 MEST


Hi Chris,
Thanks for reporting this problem with the last bin in case of
TH1::Rebin.
I have now fixed the problem in my development version.
Your fix is not sufficient. I have reorganized a bit the logic.

Rene Brun

Chris Jillings wrote:
> 
> 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         =
> =                                                                =
> ==================================================================



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