Hello,
I need to fit Gaussian function to a histogram. The histogram is the TH1D. The code goes like this:
cout << "Center of fit range: " << exp_mean << "\tsigma: " << exp_sigma << endl;
TF1 *fitHits = new TF1("fitHits", "gaus(0)");
fitHits->SetParNames("constant", "mean", "sigma");
fitHits->SetParameters(100., exp_mean, exp_sigma);
fitHits->FixParameter(1, exp_mean);
histogram->Fit("fitHits");
mean = fitHits->GetParameter(1);
sigma = abs(fitHits->GetParameter(2));
cout << "mean: " << mean << "\tsigma: " << sigma << endl;
Problem is that despite the mean parameter is fixed. The actual value differs later. The output looks like this:
Center of fit range: 158 sigma: 12.56980509
FCN=15129 FROM HESSE STATUS=FAILED 11 CALLS 101 TOTAL
EDM=0 STRATEGY= 1 ERROR MATRIX UNCERTAINTY 100.0 per cent
EXT PARAMETER APPROXIMATE STEP FIRST
NO. NAME VALUE ERROR SIZE DERIVATIVE
1 constant -3.47861e+06 1.41421e+00 0.00000e+00 0.00000e+00
2 mean 5.06221e+02 fixed
3 sigma 7.03222e-01 3.04562e+05 0.00000e+00 0.00000e+00
mean: 506.2210254 sigma: 0.7032215815
From here you can see that the value used as the mean is different than the one I provided to the function despite it is fixed. When I looked at the parameters in the ROOT browser, it looked like this:
The mean parameter is fixed as it should be but its value is not from the range, which contains only the fixed value.
Thanks in advance
ROOT Version: 6.05/03
Platform: CentOS 7.3
Compiler: g++ 4.8.5