Root way of doing fit

Hi all!

I have to very general questions:

Doing fit with root, I tried to understand deeply how it does the chi square calculation. But I cannot find exactly where this thing is done, can you just
tell me in which part of che code is it ? minuit sources ?

I have to fit a spectrum of events, in which every bin has more or less few hudreds of events for each bin.
After doing the fit I have to scale the results with a pure fixed numerical factor, that reduce the fit result of the order of 10^-2.

For example the fit says for a parameter 10^4 but after the scaling I have 25.

But I can come to this result in two ways:

  1. I can fit the distribution unscaled, with number of events for every bin more than 10^2, and after obtaining the results, I can scale them by this numerical factor


  1. I can do the same things as point 1 just doing the numerical scaling on each bin before doing the fit, in this way the output of the fit is just in right values

In case 1 i obtain a value with the error of the order of magnitude of few %

In case 2 I obtain the same value of point 1, BUT with an error about the order of magnitude of 90% of the value itself !!

Any suggestion ?

Thanks a lot, I hope to have been clear explaining my questions


the chi2 evaluation is done in the function FitUtil::EvaluateChi2 implemented in the MathCore library (file FitUtil.cxx), see: … tml#l00323

Concerning your second question, it looks to me that when you do the numerical scaling you are not scaling correctly the errors of the bin content.
For doing this, you need to call Th1::Sumw2() after having created your histogram.

Best Regards


Thanks a lot!
Very kind from you !