Is there any support in ROOT/RooFit for 2D histogram fitting/interpolation, or does anyone have any experience doing this? I’d be happy if there was support for bicubic interpolation, or something like TH2::Fit (which doesn’t exist as far as I can see.) Would it be a lot of work to add a TH2::Fit that could take a TF2? Or is there a practical workaround?
a TH2 is a TH1 so you can use TH1::Fit for TH1, TH2, TH3 objects
Rene
Thanks! I do wonder if there is any genuinely 2D fitting support (or plans to add such a thing) - in the meantime, I can just take 1D slices and do simple interpolation.
I am not sure to understand your question. If you have a TH2F* h2 histogram, you can call h2->Fit(…). See the tutorials like fit2.C, fit2a.C, etc in $ROOTSYS/tutorials/fit
Rene
I just ran fit2.C and it looks like what I’m trying to do, but I guess my confusion comes down to this point:
In fit2.C, the function fun2() appears to be in a single variable x. Is it possible to define a function of two variables, x and y, and fit a TH2F to such a function?
In the function fun2 x is an array of double* such that the same interface works for all dimensions. For a 2-d fit you can internally do
double xx = x[0];
double yy = x[1];
Rene
Thanks - I’m up and running now! Sorry I missed that.