Okay, I cannot for the life of me figure out how to fit a basic TGraph using either TF1 or TF2. I have a set of data points that I want to fit to a user-defined function where I get the x position where y is a maximum value. Does anyone know how this can be done? Thanks.

If you have a TF1* f1 and a TGraph* g, do

g->Fit(f1)

Fitting a TGraph is much similar to fitting a histogram. See examples in $ROOTSYS/tutorials/fit

Rene

Okay. Stupid user error. I’ve got it to work, sort of.

For some reason, the user-defined function I’m using isn’t fitting well. When I re-plug in the parameters found into a spreadsheet and run it on the same x values, the fit is very poor. I can then adjust the parameters found in ROOT to get something that matches the data better.

Why is ROOT not fitting to more proper values?

Could you send the shortest possible RUNNING script explaining/reproducing your problem?

Rene