Problem with Fitting Data using Fit Panel

Hello !

Respectful Greetings !

I’m trying to fit a data set, plotted through TGraph, using the Fit Panel and with a “user” defined function. The same is a Lorentzian and is being expressed as ([0]*[1]**2)/([1]**2+(x-[2])**2).

There are 512 data points with several absorption “peaks” and, to begin with, I’m trying to fit (any) one of them. I have selected the fitting range appropriately.

But, I note that the fitting is not being done while the same function is known to fit the same data through a different software.

Initially I was suspecting the following error messages that appear in the terminal when I opt for “user” defined function for fitting.

 root [2] input_line_149:2:56: error: use of undeclared identifier 'user'
Double_t TFormula____id12462700919757399674(){ return {user} ; }
                                                       ^
input_line_150:2:56: error: use of undeclared identifier 'user'
Double_t TFormula____id12462700919757399674(){ return {user} ; }
                                                       ^
Error in <prepareMethod>: Can't compile function TFormula____id12462700919757399674 prototype with arguments 
Error in <TFormula::InputFormulaIntoCling>: Error compiling formula expression in Cling
Error in <TFormula::ProcessFormula>: "user" has not been matched in the formula expression
Error in <TFormula::ProcessFormula>: Formula "user" is invalid !
TFitEditor::DoFit - using function PrevFitTMP  0x3074450

However, I have tried out other (simpler) fits through user defined expressions and they have turned out fine.

I’m using ROOT 6.20 on Fedora 30 (64-bit) LINUX platform.

Could someone please help ?

Best regards.

There is an undeclared identifier in your code. Can you post a macro example reproducing the problem ?

Thank you very much for your response.

I have tried capturing the “look” of the issue and the same is attached herewith.

Best regards.

Thanks for the screen dump, I let @moneta give you some hints. I see that selecting the "user’ choice in the Type menu produces the errors you mentioned earlier.

Gratitude ! I’ll eagerly look forward to it.

However, as I mentioned earlier, those errors that appear in the terminal following the choice of the “user” option is probably not afflicting the fit procedure. I have exercised the same option for simpler fits.

Hi,
In the Fit panel, if you want to type your formula, you need to fill it in the texts field above selected, as I see in your screen shot.
But afterwards you need to type enter, to pass the formula to the fit panel. I see in the screen shot that you have “user” as selected. This is not correct.
It should be as following:

image

This works for me. For you it is like the expression is not passed and it uses user at expression. We should probably remove the name user from the list off pre-defined functions.

Cheers

Lorenzo

For this kind of data, you might also like this old thread:

Thank you very much, for this insight. I’ve implemented the same.

However, I don’t think this is the issue. Since, I have been able to fit other simpler (linear) data through the “user” defined function and even without passing the formula.

Nevertheless, many thanks for the education and I’ll do it this way hereafter.

Best regards.

Gratitude for sharing the thread.

I’ll try implementing the function therein.

Best regards.