TH3 rebin?

Hi,
It looks like TH3 does not have the rebinning methods in each axis like RebinX(),RebinY() and RebinZ() yet. There is any good reason why they are not there?

Thanks,
Zhiyi.

Hi,

no, it requires onlly some time to implement it. If you are willing to do it, I could then include it in the class
Cheers,
Lorenzo

Thanks.

Okay, I extended the functions Rebin2D of TH2 to the case of TH3, which is called Rebin3D. The extension is pretty straightforward. However, before checking it into svn, it will be great if somebody can check the code.

There is a function used in Rebin3D (SetBins) that was added into TH1.

Cheers,
Zhiyi.

[quote=“moneta”]Hi,
no, it requires onlly some time to implement it. If you are willing to do it, I could then include it in the class
Cheers,
Lorenzo[/quote]
TH1.cxx (320 KB)
TH1.h (29.2 KB)
TH3.h (18.6 KB)
TH3.cxx (160 KB)

Hi,

Thank you for your code. I will test it and include in ROOT.
The function SetBins is already in TH1 since 5.28. I notice you have started from old source versions, from this summer (25/8/2010).
Some bug have been fixed in TH2::Rebin for 5.28 after that. In particular see
root.cern.ch/viewvc?view=rev&revision=36322

Can you please check that this is fixes are in TH3::Rebin ?

Thank you
Lorenzo

Thanks for the reminding. I checked out 5.28.00 and also trunk version. The modified version files are attached based on the 5.28.00 version (in which the 2 files are same as ones in the trunk version of revision 37921). As you mentioned, no modification on TH1 any more.

Cheers,
Zhiyi.
TH3.h (18.6 KB)
TH3.cxx (161 KB)

Hi,

Thanks for the updated file. I have tested your new function and it failed.
Can you please investigate it ? I attach my test program,

Thanks

Lorenzo
test3DRebin.C (3.78 KB)

Thanks for your test code. Yes, my original code is very buggy. The attached one looks good. There is a bug in your code too:

...
for ( int h = 0; h <= h1->GetNbinsZ() + 1; ++h )
...

GetNbinsZ instead of GetNbinsY.

Cheers,
Zhiyi.
TH3.cxx (167 KB)

Hi,
Thank you for the updated file and to find that bug in the test program !
I have now added in ROOT SVN (revision 37961) your new Rebin3D method

Cheers,
Lorenzo