Fitting graphs made with TMultiGraph and Integrating the Fits

I was introduced to ROOT only in September, and need to use it for a project where I plot data, fit a curve to the data, and integrate the curve from the fit. I found the documentation on fitting graphs, and was unsure if the TGraph::Fit method worked with TMultiGraph (I am plotting multiple data sets on one canvas). If it does work, where can I find the function that results from the fit?
After getting the function from the fit, can I integrate it using the TF1::Integrate function that I found while searching integration methods?

(I hope this isn’t too much to ask)

ROOT Version: 6.26/06
Platform: Windows 11
Compiler: Not Provided

Maybe this is what you want:
If you want to fit each graph separately you can fit them directly (not from the multigraph), as shown also in that page (in “Fit box position”). If you want to retrieve each graph when they are already in the multigraph, you can use GetListOfGraphs, as shown here:

You can look at the integration methods in the Documentation (maybe Integral() is what you want), and to get the fit parameters you can search for examples in this forum, e.g.

What do these parameters mean?

grep -r Integral ${ROOTSYS}/t[eu]*

Scroll down to IntegralMultiple() [2/3]; it explains the parameters (in this case, a,b and epsrel mean the same as in Integral); you could also scroll to IntegralOneDim(), which Integral() calls, as it says there, but IntegralOneDim only explains a and b for some reason. You can always click on the link at the line “Definition at line XXX…” to see the code and follow the variables; if you can read the code, sometimes it’s faster.

That’s a lot, where does the function you are integrating go?

If your TF1 is func, you do Integral on func, e.g. something like:

TF1 *func = new TF1("fit",fitf,-3,3,3);

Check out the explanations and examples in the Fitting Manual.

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