Re: Linear Fitter without "++"

From: Lorenzo Moneta <Lorenzo.Moneta_at_cern.ch>
Date: Fri, 18 Dec 2009 14:27:40 +0100


Hello,

 You can force the use of the linear fitter by doing:

TF1 * f = new TF1("f",fitfun,xmin, xmax, npar); TVirtualFitter::SetDefaultFitter("Linear") h->Fit( f,"G");

The option "G" is needed to tell the fitter to use the derivatives of fitfun with respect to the parameters as basis functions for the linear fitter. When using "++" the basis functions are automatically determined from the formula.

    Best Regards

 Lorenzo   

On Dec 17, 2009, at 4:26 PM, Gemmel, Claudia wrote:

> Hello,
>
> could anyone tell me if there is a possibility to tell ROOT to use the linear fitter without using the syntax "++"? My fit function is a piecewise defined function, but it is linear in the parameters. So I would like to use a C function in the following way:
>
> Double_t fitfun(Double_t *x, Double_t *par)
> {
> Double_t returnval;
> Double_t t =x[0];
> Double_t ws = 7.2921150e-5;
> Double_t t01 = 0;
> Double_t t02 = 137554;
> Double_t tmess1 = 52000;
> Double_t tmess2 = 47000;
>
> if (t <= tmess1) {
> returnval= par[2] + par[3]*(t-t01) + TMath::TwoPi()/ws*(par[0]*sin(ws*t)-par[1]*cos(ws*t));
> }
> else {
> if ((t > t02) && (t <= (t02+tmess2)))
> returnval= par[6] + par[7]*(t-t02) + TMath::TwoPi()/ws*(par[0]*sin(ws*t)-par[1]*cos(ws*t));
> }
> return returnval;
> }
>
> But here I cannot use the "++" notation...
> Thanks in advance for your help!
> Claudia
Received on Fri Dec 18 2009 - 14:27:44 CET

This archive was generated by hypermail 2.2.0 : Fri Dec 18 2009 - 17:50:03 CET