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","*TMath::Sqrt((x-)*(x-)+2*511*(x-))*(-(x-))*(-(x-))*((x-)+511)+*TMath::Gaus(x,,)",45,70)
but the fit is always failing.
I guess the problem is that the  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
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  is not equal to betaPbGamma->GetMin() but I want to have  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 >betaPbGamma->GetMin(), the resulting function explodes in the interval [ betaPbGamma->GetMin() -  ]
My only possibility I would say is to define the function with betaPbGamma->GetMin() >  but in this way I lose quite some important points for the fit estimation…
betaPbGamma->SetParLimits(1, betaPbGamma->GetXmin(), betaPbGamma->GetXmax());
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.