Rebinning with variable binsize


((i have edited this entry, as a) error is known, b) my “workaround” is only working in special cases.

So my only summary could be that rebinning with variable binsize is broken in all, including the newest (5.21.04), root versions.

Looks like this seems to be fixed already in svn
bug #42306: Bug in TH1::Rebin


I’m using ROOT 5.23/02 on Ubuntu 8.11 (also tried on ROOT 5.18 on SLC4)

I can not get variable re-binning to work. May be I’m doing some thing crazy (I hope so). Here’s a simple test I did in the ROOT command line that gave me the same results as in my ROOT script.

root [0] TH1D h1 = new TH1D(“h1”,"",100,0,10);
root [1] for(int i = 1; i < 101; i++) h1->SetBinContent(i, 0.25
root [2] h1->Draw();
root [3] double xbins[5];
root [4] xbins[0] = 0;
root [5] xbins[1] = 5;
root [6] xbins[2] = 20;
root [8] xbins[3] = 50;
root [9] xbins[4] = 100;
root [10] h1_2 = h1->Rebin(4,“h1_2”,xbins);
root [11] h1_2->Draw();

I get a blank TCanvas and no error message? Thanks for any help on this.



the array xbins[] represents the low edge of the bins. In your case the array should contains values between 0,10 the range of your histograms.
If you use xbins[] ={0,0.5,2,5,10}, it will work fine in 5.23.02

Best Regards