TSpline3 for TH2D

Hi,
I found TSpline3 class that makes interpolation of TH1 histogram, is there something like this for 2-dim histograms?

This is probably what you are looking for: https://root.cern.ch/doc/master/classTMVA_1_1TSpline2.html

Hi,
The problem is that I would like to eval 2-dim histogram, not 1-dim graph. If I correctly understood TSpline2 might eval only TGraph therefore there is only TSpline2::Eval(x), I need class with TSplineX::Eval(x,y).

I understand now. You want to have an interpolator that allows you to get values for your function at points not defined in your 2D histogram. I am not sure such functionality is available in ROOT. If you do not need smooth interpolation (i.e. continuous is enough), you can try to implement a bilinear interpolator. Otherwise, that should be an interesting thing to add in future versions of ROOT.

Hi,
you could convert your 2d hist into a TGraph2D and then
use TGraph2D::Interpolate(x,y)
Consult TGraph2Ds docu for the algorithm used.
Cheers
Otto

1 Like

Thanks @OSchaile!

Here is a link to the documentation for @dwielane:
https://root.cern.ch/doc/master/classTGraph2D.html#a0dfb623f2a9f55c98ebe323384cf3f0d

I hope that is enough for your needs.

Remark:

TGraph2D::Interpolate is fine to retrieve a value but it does a linear interpolation. Not a spline.

1 Like

Thank you, this is more or less what i want.
@amadio what about bicubic interpolation? Actually I implemented one, maybe it will be useful to add it somewhere or just create new class like TInterpolated2D?

@dwielane If you implemented one and you would like to make it available in ROOT, you can try to get it into a pull request on GitHub. See the link below for more information on how to do that.

https://root.cern.ch/creating-pull-request

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.