Re: Get fit parameters from a TGraph

From: John Idarraga <idarraga_at_cern.ch>
Date: Tue, 28 Sep 2010 17:38:52 +0200


Yeah, you can look for the predefined function you used at the moment you called TGraph::Fit. That's what you are doing here. Check the TGraph::Fit documentation in case you need more control on that function, like changing parameter values before fitting, or using a completely user-defined function.

cheers,

John

Julia Campa Romero wrote:
> I have change to
> TF1 *myfunc=n->GetFunction("gaus");
>
> and works!!
>
> Thanks,
> Julia
> John Idarraga wrote:
>> Hello Julia,
>>
>> Your fitting fuction is not "n". "n" is your TGraph. What you need
>> is here:
>>
>> http://root.cern.ch/root/html/TGraph.html#TGraph:Fit
>>
>> see section, "Access to the Fit results" and "Associated functions".
>> What you are trying to do is described in "Associated functions".
>>
>> John
>>
>> Campa Romero, Julia Monica wrote:
>>>
>>> Hi,
>>>
>>> I want to access to the fit parameters once a TGraph is fitted with
>>> a gaussian. I am using GetFunction but it doesn't work. Bellow is my
>>> program. It displays the fit parameters but then if I use
>>> GetFunction as in the program bellow, it breaks when it gets the
>>> parameters. Could you help me to find the errors. A piece of the
>>> program is bellow:
>>>
>>> *******************
>>>
>>> TGraph *n= new TGraph(8,sig,l);
>>> n->Fit("gaus","V");
>>> TF1 *myfunc=n->GetFunction("n");
>>>
>>> Double_t p0=myfunc->GetParameter(0);
>>> Double_t p1=myfunc->GetParameter(1);
>>> Double_t p2=myfunc->GetParameter(2);
>>> **********************
>>> Cheers,
>>>
>>>
>>> Julia
>>> ---------------------------- Confidencialidad: Este
>>> mensaje y sus ficheros adjuntos se dirige exclusivamente a su
>>> destinatario y puede contener información privilegiada o
>>> confidencial. Si no es vd. el destinatario indicado, queda
>>> notificado de que la utilización, divulgación y/o copia sin
>>> autorización está prohibida en virtud de la legislación vigente. Si
>>> ha recibido este mensaje por error, le rogamos que nos lo comunique
>>> inmediatamente respondiendo al mensaje y proceda a su destrucción.
>>> Disclaimer: This message and its attached files is intended
>>> exclusively for its recipients and may contain confidential
>>> information. If you received this e-mail in error you are hereby
>>> notified that any dissemination, copy or disclosure of this
>>> communication is strictly prohibited and may be unlawful. In this
>>> case, please notify us by a reply and delete this email and its
>>> contents immediately. ----------------------------
>>
>
Received on Tue Sep 28 2010 - 17:40:18 CEST

This archive was generated by hypermail 2.2.0 : Tue Sep 28 2010 - 23:50:02 CEST