Hi,
I have a spectrum with two peaks, which I want to fit both. In the drawing of the resulting histogram, I want to see both fit-results drawn, but I also want to store the fit-results in a file (i.e. “mean” and “mean2”). However, with the following code, even though in the drawing two different peaks are correctly fitted and drawn, the calls to GetParameter (both to “fitGauss” and “fitGauss2”) return the same values (the value for the first fit). How can I obtain the results of the second fit?
h1->Fit("gaus", "Q", "", xmin, xmax);
TF1* fitGauss = h1->GetFunction("gaus");
double mean = fitGauss->GetParameter(1);
double sigma = fitGauss->GetParameter(2);
h1->Fit("gaus", "Q+", "", xmin2, xmax2);
TF1* fitGauss2 = h1->GetFunction("gaus");
double mean2 = fitGauss2->GetParameter(1);
double sigma2 = fitGauss2->GetParameter(2);
Cheers,
Machiel