Hi Gerco, You have a good point. The current algorithm assumes that the number of bins is a multiple of ngroup. I have implemented your suggestion, including support for overflows and update of the statistics. Rene Brun On Fri, 2 Jun 2000, Gerco Onderwater wrote: > Hi Rooters, > > When rebinning my histograms I ran into the following interesting > behaviour: > > root [0] h = new TH1F("h","h",4695,0,700425) > (class TH1F*)0x886f260 > root [1] h->GetBinWidth(1) > (Axis_t)1.49185303514376983e+02 > root [2] h->Rebin(2) > (class TH1*)0x886f260 > root [3] h->GetBinWidth(1)/2. > (double)1.49217085641244154e+02 > > In other words: the binwidth and thus the x-scale changes by as much as > 213 parts-per-million, which is rather annoying if you try to measure a > frequency to less than 1 ppm!!! > > I traced this down to TH1::Rebin (not so difficult) where I found: > > Int_t nbins = fXaxis.GetNbins(); > Float_t xmin = fXaxis.GetXmin(); > Float_t xmax = fXaxis.GetXmax(); > ..... > Int_t newbins = nbins/ngroup; > ..... > hnew->SetBins(newbins,xmin,xmax); > > This of course only works if nbins/ngroup is integer to begin with!!!! > The fix for this would be to add the line > > xmax = fXaxis.GetBinUpEdge(newbins*ngroup); > > just before hnew->SetBins(newbins,xmin,xmax). And then it would be more > elegant to not ignore the underflows and overflows, where the latter also > contains the content of those bins that were lost in the rebinning. > > Greetings, > > -- Gerco > > Dr. C.J.G. Onderwater > Nuclear Physics Laboratory > 312 Loomis Laboratory of Physics > University of Illinois at Urbana-Champaign > 1110 West Green Street > Urbana, IL 61801-3080 > Phone : (217) 244-7363 > Fax : (217) 333-1215 > E-mail: onderwat@uiuc.edu > >
This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:27 MET