Thanks for the old post. That’s my real sample data indeed.
Anyways. my code is already similar for these parts. However, you and me, like others, always focus on the net area and its error. The real problem is the estimation of a background indeed.
When I quickly ckeck the code, you emphasized the “fixed background” part in these lines:
if (fit_with_fixed_background) {
f1->FixParameter(3, f1->GetParameter(3));
f1->FixParameter(4, f1->GetParameter(4));
g1->Fit(f1, “WEMR”);
std::cout << “note: background parameters are fixed” << std::endl;
std::cout << "gaus peak integral = " << f1->GetParameter(0)
<< " +/- " << f1->GetParError(0)
<< std::endl;
}
Here again, you comment out the gauss integral while fixing the background parameters. Since the fixed parameters error will be ZERO, then it should also affect the result of gauss integral’s error.
I wonder what happens if you print out the background integral and its error in your code!
Does using graph instead of histogram or using gausn instead of gaus make ANY DIFFERENCE on results?