Problems with 'gaussian' fit

Hallo,

I have a user defined gaussian fit.
The only thing that makes it ‘user defined’, is that its sigma value changes
(depending on whether its to the left or right of the mean), otherwise its just a copy of the normal ROOT Gaus function.

Now the problem is that it sometimes returns a negative value for the left sigma,
which then messes up everything. Yes I could just do: abs(left sigma), but I want to know,
why its doing that if, anyone can help me.

I sometimes also get very wierd parameters returned from it too. As in,
I’ll provide an initial mean parameter to the fit function of about 300, but it’ll return 2000,
and thats not even in the range of the histogram!

This is why I’m beginning to think there maybe something wrong with the fit function,
which I have attached. (The code I use the function in, is not attached, but if you would like to have a look, please just ask),

Thankyou
twogausfit.cxx (4.21 KB)

To get an answer, you should provide a concrete RUNNING script that we can
use to investigate your problem.
When fitting with a gaussian, ROOT standard fitting always returns a positive
value for sigma. You can force a postive value by specifying boundary limits
for your parameters,eg
myfunc->SetParLimits(1,0,sigma_max);

Rene

hi no1else,

Look at your function expression :

double sigma;
if (y <= mean) sigma = sigmaleft;
if (y > mean) sigma = sigmaright;

double arg = (y-mean)/sigma;
double theexp = TMath::Exp(-0.5argarg);

As you have just experienced, the value of this function does not
depend on the sign of the sigma’s . So minuit could deliver either one .

Usually, the normalization depends on sigma . But you have commented
out that part because you could not get its expression correct .

Now, the height parameter will depend on the value of sigma and
that explains its large range of values .

Just improve your function parametrization .

Eddy

Thankyou, for both replies.

I have now attached a running script (t0calibRobust.C) and a data file so the problem can be seen.

I use the left sigma and the mean to calculate the time of half maximum (ie when the gaussian exponential is equal to a half), which is called t0.
There is no reason why t0 should be different for different binnings and ranges.

But for example, it will work when I execute the script as:
Drkam_monitor(“trackfitting”,1101, -0.5, 1100.5)
but not as:
Drkam_monitor(“trackfitting”,129, -6.0, 1200.0)
where:
Drkam_monitor(“datafilename”,bins, xlow, xmax)

I can see what you mean about my parameters not being very good, but I’m not sure how to make it any better. what do you suggest i do?

Thanks Sid.

P.S. actually, I’m not being able to upload the datafile its 47.2MB … is there another way to make it accessible?
t0calibRobust.C (17.7 KB)