Half Gaussian fit

Hi there,
I was trying to fit a histogram which has range (0,200) by half a gaussian function but it does seem to work for the interval I specify (which is from 10 to 200 ):

TF1 func = newTF1(“func”,“gaus”**,0,200);
func->SetParameters(100,0,50);
func->FixParameter(1,0);
ab_delta_z->Fit(func,“”, “” , 10,200);

It turned out that even though the mean value was fixed to 0, the fit still gives a mean value at about 40.

I also tried ab_delta_z->Fit(“gaus”,“”,“”,10,200) and it gives much better fit results but I cannot fix the mean value to exactly 0. Any solution to this?

Cheers,
Yi

First, welcome to the ROOT Forum!
Then, maybe @jonas can help with this, but I guess more details are needed, like for example the data (or its shape) you’re trying to apply your fit to…

Hi, Sorry I can’t post the plot here but the shape is just like the right part of a gaussian (x axis from 0 to 200). The bins close to 0 are not fully filled so the histogram looks like a bell without the peak/well in the centre. That is why the fit needs to be performed over [10,200].

Try: ab_delta_z->Fit(func, "B", "", 10., 200.);

1 Like

Hi Thanks a lot. This works well for me.