Home | News | Documentation | Download

Parametric range definition

Hi Rooters,
I need help with a parametric function definition.
Is it possible to use a parameter also for the range definition of the function?

Here is my precise problem:
I have to fit a beta-gamma spectrum and I tried to fit it with the following function:

TF1 *betaPbGamma = new TF1("betaPbGamma","[0]*TMath::Sqrt((x-[1])*(x-[1])+2*511*(x-[1]))*([2]-(x-[1]))*([2]-(x-[1]))*((x-[1])+511)+[3]*TMath::Gaus(x,[1],[4])",45,70)
betaPbGamma->SetParameters(7e-6,45,17,50,1)

but the fit is always failing.
I guess the problem is that the [1] parameter is not really free to move because it have to be equal to the xmin of the range definition.
In fact if it is not, the obtained function explodes…

Is there any solution/trick for this issue?

Many thanks in advance!!


Please read tips for efficient and successful posting and posting code

ROOT Version: 6.08.06
Platform: Debian 3.16.43-2+deb8u5 (2017-09-19) x86_64 GNU/Linux
Compiler: gcc version 4.9.2


betaPbGamma->FixParameter(1, betaPbGamma->GetXmin());

This is fixing my parameter.
It has to be free to change with the fit: what I was looking for is a “moving” range for the function definition…but I have no idea if this is possible…
Otherwise I will use a step function…

The declared range of the function does not matter when fitting unless you explicitly request it (e.g. by the “R” fitting option). Usually, fitting is driven by the available data points which then define the actually used xmin and xmax.

The problem is not in the fit but in the function definition.
I have a function that explodes if [1] is not equal to betaPbGamma->GetMin() but I want to have [1] free to change in the fit.
Unfortunately this is not possible if the function is defined in this way because if the fit wants to try [1]>betaPbGamma->GetMin(), the resulting function explodes in the interval [ betaPbGamma->GetMin() - [1] ]
My only possibility I would say is to define the function with betaPbGamma->GetMin() > [1] but in this way I lose quite some important points for the fit estimation…

Maybe:

betaPbGamma->SetParLimits(1, betaPbGamma->GetXmin(), betaPbGamma->GetXmax());