I wanna draw 2 fitting graph. But it shows only one graph

Hi experts!
I wanna fitting 2 graph on my histogram. But it only one comes out. What is the problem?

void MultiFitIntegral()
{
double initparms[] = {68.37, 3, 0.51, 24.1, -8.2, 0.74};
TF1 *f1 = new TF1(“f1”,“gaus(0)+pol2(3)”);
f1->SetParameters(initparms);
hdet_y->Fit(f1,“R”,"",0,6);
double initparms2[] = {68.37, 3, 0.51};
TF1 *f2 = new TF1(“f2”,“gaus”);
f2->SetParameters(initparms2);
f2->SetLineColor(kBlue);
f2->SetLineStyle(3);
hdet_y->Fit(f2,“R+”,“I”,0,20);
auto fitresult1 = hdet_y->Fit(f1,“S”,"",0,6);
auto fitresult2 = hdet_y->Fit(f2,“S”,"",0,6);

double integral1 = f1->Integral(0,6);
double integral2 = f2->Integral(0,6);

auto covMatrix1 = fitresult1->GetCovarianceMatrix();
auto covMatrix2 = fitresult2->GetCovarianceMatrix();

double sigma_integral1 = f1->IntegralError(0,6,fitresult1->GetParams(),covMatrix1.GetMatrixArray());
double sigma_integral2 = f2->IntegralError(0,6,fitresult2->GetParams(),covMatrix2.GetMatrixArray());
std::cout << "Integral = " << 2integral2-2(integral1-integral2) << " +/- " << 2sigma_integral2-2(sigma_integ
ral1-sigma_integral2) << std::endl;
}
This is the result.
Screenshot from 2021-06-06 23-29-24


Please read tips for efficient and successful posting and posting code

ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided


Try:

auto fitresult1 = hdet_y->Fit(f1, "S", "", 0, 6);
auto fitresult2 = hdet_y->Fit(f2, "S+", "", 0, 6);
1 Like

Thanks for helping me!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.