Problems with fitting and fitpanel

Hi,

I have problems with fitting parabolas to a TGraph(Errors). The fit that I make with my own defined function is not the best fit and is even totally different as the fit I acquire when I fit with the fitpanel.

I can show my problem with the folowing interactive session :

root [0] TCanvas c1 = new TCanvas()
root [1] TGraphErrors * gr1 = new TGraphErrors(“Run00088842_5st_lateral55.txt”,"%lg %lg %lg")
root [2] gr1->Draw("A
")
root [3] gStyle->SetOptFit(1111)
root [4] TF1 *fit = new TF1(“fit”,“pol2”,1.7,2.7);
root [5] Fitting results:
Parameters:
NO. VALUE ERROR
0 14.423373 0.727944
1 -11.539979 0.756400
2 2.383357 0.195939

The above results are the fit results obtained from the fitpanel, when fitting a pol2

root [5] gr1->Fit(fit)
Fitting results:
Parameters:
NO. VALUE ERROR
0 -0.286274 0.639518
1 3.274469 0.670442
2 -1.317574 0.175321
(Int_t)0

These are the fit results obtained from when fitting a defined pol2. These fit results are totally different. Why?

root [14] TF1 fit2 = new TF1(“fit”,"-[0](x-2)(x-2)-[1](x-2)+[2]",1.7,2.7);

I now define a parabola myself

root [15] gr1->Fit(fit2)


** 5 **MIGRAD 5000 2.874e-06


MIGRAD MINIMIZATION HAS CONVERGED.
MIGRAD WILL VERIFY CONVERGENCE AND ERROR MATRIX.
FCN=2947.66 FROM MIGRAD STATUS=CONVERGED 62 CALLS 63 TOTAL
EDM=6.08427e-17 STRATEGY= 1 ERROR MATRIX ACCURATE
EXT PARAMETER STEP FIRST
NO. NAME VALUE ERROR SIZE DERIVATIVE
1 p0 1.31757e+00 1.75321e-01 1.10009e-03 1.92219e-07
2 p1 1.99583e+00 4.60246e-02 2.42141e-04 -7.46514e-07
3 p2 9.92370e-01 7.05961e-03 5.03829e-05 -2.66262e-06
FCN=2947.66 FROM MIGRAD STATUS=CONVERGED 62 CALLS 63 TOTAL
EDM=6.08427e-17 STRATEGY= 1 ERROR MATRIX ACCURATE
EXT PARAMETER STEP FIRST
NO. NAME VALUE ERROR SIZE DERIVATIVE
1 p0 1.31757e+00 1.75321e-01 1.10009e-03 1.92219e-07
2 p1 1.99583e+00 4.60246e-02 2.42141e-04 -7.46514e-07
3 p2 9.92370e-01 7.05961e-03 5.03829e-05 -2.66262e-06
(Int_t)0

And this gives essentially the same results as the fit done with pol2 except the parameter values of course, but again totally different as the fitpanel.

So my question is : what is the different between the user-defined pol2 or parabola, and the one that fitpanel uses? And how can I obtain the best parabola fit?

Thanks,
Tom
Run00088842_5st_lateral55.txt (427 Bytes)

Hi Tom,

Please tell us the version of ROOT in use.

Thank you, Ilka

Hi,

I’m using ROOT version 4.04/02 on a x86_64 computer with SUSE Linux 10.0.

Tom

Could you send the shortest possible RUNNING script reproducing the problem?

Rene

My problem is not that the script is not running. My problem is that the parabola fit that I define is not the same as the one that I get when I use the fitpanel in an interactive ROOT session.
I get two totally different fits when I run the script and when I fit the same pol2 function with the fitpanel. Why is this so? What is the difference between the fit function of a TGraph (when fitting a pol2) and the fitting procedure of the fitpanel?
And how do I get the best fit?

Thanks
Tom
fitproblem.C (661 Bytes)

You for got to post the data file used by your script

Rene

I have added the datafile with my first message…but I will add both the script and datafile once again…

Regards,
Tom
fitproblem.C (661 Bytes)
Run00088842_5st_lateral55.txt (427 Bytes)

Hi Tom,

The fit panel interface was changed last year and related classes used in version 4.04/02 were removed from cvs. The new interface covers the old functionality and involves much more but it is still under development. The first prototype took place in version 5.14/00 and was explained at root.cern.ch/root/Version515.news.html

I will use your example and investigate the current behavior.

Cheers, Ilka

Thank you for the answer.

So this means that it is possible that in the ROOT version I’m using the pol2 function from the Fitpanel is somehow different from the pol2 function when used with the Fit option of TGraph and that this could be the reason why I get two (totally) different fits? So it is perhaps the best to use the latest ROOT version and test this again? Because I need the best fit and was confused by those 2 different fits…

Thanks,
Tom

Hi Tom,

Yes, it is better to move to a recent ROOT version. I cannot say anything about the use of pol2 right now - as I wrote I will investigate and will keep you informed. If you wish wait for my post. Currently, the option “R” is selected by default when using the fit panel interface and this leads to an error. I have to fix that. If you are going to use latest version of ROOT, please unselect the check button “Use Range” to get a correct result.

Cheers, Ilka

Hi Tom,

I do not see different fits when using pol2 in both ways: via the new fit panel interface and via calling TGraph::Fit method. Please remember that with current cvs you should unselect the “Use range” check button. A fix about this bug will be uploaded in cvs very soon.

Best regards, Ilka

Thank you very much for your help…

Regards,
Tom