Trouble with showing the results of a fit on a graph

_ROOT Version:6.14/08
Compiler: Not Provided

I’m trying to create a graph with a couple of fits, using the attached macro. I am trying to get the result of my fits to appear on the graph (The value/error of parameters, etc). I am trying to use TFitResultPtr to show the results of the fit, but there only seems to be a method for printing the results, Print(); , and no way to store the results to a string so that I can put it on the graph (Perhaps using the TPaveText method).

analysis.cxx (2.8 KB)

two_peaks_15.txt (5.3 KB)


you are right aa TPaveText it is the right solution.
Have a look how I modified your code.
analysis.cxx (3.2 KB)



Thanks Stefano!
It is a shame that there isn’t some function to put all of the results of fit onto a graph, especially since parameters are shown automatically in a histogram. However, this will have to do, it doesn’t require that much more effort to put each parameter one by one to the graph, eh?


just came to my mind, you can use gStyle->SetOptFit(0011); before fitting.
Have a look here for the method SetFitStat().

My bad I didn’t think of it.


I actually tried this already before I posted. If I add the SetOptFit statement at the beginning of the “analysis” method, then the output remains unchanged. It would seem that this statement only works if a histogram (such as TH1F) is being fitted. Then the SetOptFit statement works. However, for a TGraph, it appears to do nothing.

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