Confused code in the process of combineFit

Hello guys,
In the process of combined fit, I try to understand the meaning of below code.
I am appreciate if you can explain the below code in detail.

ROOT::Fit::Chi2Function chi2_B(dataB, wfB);
ROOT::Fit::Chi2Function chi2_SB(dataSB, wfSB);
GlobalChi2 globalChi2(chi2_B, chi2_SB);

My understanding:

ROOT::Fit::Chi2Function chi2_B(dataB, wfB);

is to fit dataB using wfB function using least-square fit.
And:

ROOT::Fit::Chi2Function chi2_SB(dataSB, wfSB);

is to fit dataSB using wfSB function using least-square fit.
And:

GlobalChi2 globalChi2(chi2_B, chi2_SB);

To choose best one comined the last two fit.
But why the fit again like below?

fitter.FitFCN(6,globalChi2,par0,dataB.Size()+dataSB.Size());

Thans lot.
Yao

I’m sure @moneta can give you all the explanation you need

Hi,

The fit is performed only when calling this line:

The lines before just create the least square function objects, that will be used later for fitting.
Note that ROOT::Fit::Chi2Function is a typedef to a templated class Chi2FCN defined in namespace ROOT::Fit. See
https://root.cern.ch/doc/master/classROOT_1_1Fit_1_1Chi2FCN.html

Lorenzo

Nice. Got your point. Thanks a lot.

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