Fitting 2D Histogram with xygaus


I am trying to fit a 2D histogram with the predefined xygaus function. It works without a problem if I use the fit window and get the desired results. However, I am trying to do this in a macro. Whenever I try to fit the histogram with:


It returns Unknown function: xygaus

How is it that this function is undefined when it says it is predefined in the root fit window? And How do I fit the 2D histogram with a xygaus function? This seems like a simple question, but I have been searching for an answer for about a day now.


Hi Chris,

You need to explicitly create a function with the right range, for example:TF2 *f2 = new TF2("f2","xygaus",-4,4,-4,4);and use “f2” is the fit request.