Re: Fitting multiple subranges with user defined functions

From: Rene Brun <Rene.Brun_at_cern.ch>
Date: Thu, 17 May 2007 12:29:47 +0200


Simply define one single function like shown below

Rene Brun

double myfunc(double *x, double *par) {

   double sx = ???;
   double dx = ???;
   if (x[0] < sx || x[0] > dx)

      return par[1]/TMath::Sin(x-par[0]);    else

      return par[2]*TMath::Gaus(x[0],par[3],par[4]); }

define a function like
  TF1 *total = new TF1("total",myfunc,mina,maxa,5);   total->SetParameters(A,x0,gnorm,gmean,gsig);

Rene Brun

Gabriele Postorino wrote:
> Hai scritto:
>
>> Hi Gabriele,
>>
>> Expressions like
>>
>> total = new TF1("fit","ruth(0)+moliere(2)+ruth(5)",mina,maxa);
>>
>> are not supported by TF1 (see doc).
>>
>> You should proceed like shown in our tutorial FittingDemo.C
>>
>> Rene Brun
>>
>
> The tutorial you talk about refers to a fit on all values with a sum of
> functions. What I would like to do is to fit with a function defined in
> different ways on different ranges:
> A/sin(x-x0)^4 x < sx || x > dx
> func =
> gaus sx < x <dx
>
> Probably I'm missing something but I couldn't manage to do it.
>
> Gabriele
>
Received on Thu May 17 2007 - 12:29:53 CEST

This archive was generated by hypermail 2.2.0 : Fri May 18 2007 - 11:50:01 CEST