Fitting using two Gaussian

Dear All,
after posting too many inquires here, I could with your help to obtain a good fitting for the alpha peak I am analyzing.

herein the final script

TF1 *gausBi1= new TF1("gausBi1","gaus",80,220);
coin_timeBi->Fit(gausBi1, "R0");

TF1 *gausBi2= new TF1("gausBi2","gaus",220,1100);
coin_timeBi->Fit(gausBi2, "R0+");

TF1 *gausBi1_gausBi2 = new TF1("gausBi1_gausBi2", "(x < 220) * gausBi1 + (x >= 220) * gausBi2", 80., 1100.);

   Double_t xmin = gausBi1_gausBi2->GetXmin();
  Double_t xmax = gausBi1_gausBi2->GetXmax();
  Double_t IntegralBi=(gausBi1_gausBi2->Integral(xmin,xmax))/Bin_widthBi;
  Double_t IntegralErrorBi=(gausBi1_gausBi2->IntegralError(xmin,xmax,0,0,1E-2))/Bin_widthBi;

  Double_t MeanBi = gausBi1_gausBi2->Mean(xmin, xmax);
  Double_t SigmaBi = TMath::Sqrt(gausBi1_gausBi2->Variance(xmin, xmax));
  cout << "MeanBi = "       << MeanBi << endl;
  cout << "SigmaBi = "      << SigmaBi << endl;
  cout << "IntegralBi = "  << IntegralBi<<"+-"<<IntegralErrorBi<< endl;

fit1.pdf (17.6 KB)

I wonder now how can I find the error propagation the mean and sigma values, is there a direct method using root?

your help is always appreciated.


I have not understood your question. Which mean and sigma values would you like to find ?


the final fitting function I used is “gausBi1_gausBi2”
and I obtained the mean and sigma values as
" Double_t MeanBi = gausBi1_gausBi2->Mean(xmin, xmax); Double_t SigmaBi = TMath::Sqrt(gausBi1_gausBi2->Variance(xmin, xmax));"

my question about the -Error propagation- of the mean and sigma values.


OK I understand now the question. No we don’t have this implemented in ROOT for TF1::Mean and TF1::Variance (i.e. we don’t have a TF1::MeanError or TF1::VarianceError) function.
But you could implement easily just as it is done in IntegralError using TF1::GradientPar.

See the code in


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