# chi2/DOF value

Hello all,

I have 2 questions regarding the chi2 value returned by roofit:

1. I perform a simple extended chi2 fit as follows:

RooRealVar n_sig(“n_sig”,“n_sig”, 10.0, -500.0, 500.0);
RooRealVar n_bkgd(“n_bkgd”,“n_bkgd”, 130.0, -500.0, 500.0);

RooAddPdf sum_PDF(“sum_PDF”, “sum_PDF”, RooArgList(sig_PDF, bkgd_PDF), RooArgList(n_sig, n_bkgd));

//data_hist is a RooDataHist
RooChi2Var chi2(“chi2”,“chi2”,sum_PDF,*data_hist, Extended());

RooMinuit m2(chi2);
RooFitResult* fitres1 = m2.save() ;

## //The data_hist contains 12 bins, and the only floating parameters are the yields (n_sig & n_bkgd). Since the sum of the yields =1, //I conclude that the number of free parameters is 1 (correct?). So, to calculate the chi2/DOF, I do the following: double chi2_val = chi2.getVal(); double red_chi2 = chi2_val/(12-1);

However, the value that I get for chi2_val (and for red_chi2) is very high: ~2.2. If I calculate the chi2 by hand (from the plot), I only get ~1.0.

1. My second question is in regards to calculating the chi2 for a simultaneous fit. The simultaneous fit is constructed as follows:

RooRealVar f_sig(“f_sig”, “f_sig”, 0.5, 0.0, 1.0);

RooChi2Var chi2_1(“chi2_1”,“chi2_1”, PDF_1, *HIST_1);
RooChi2Var chi2_2(“chi2_2”,“chi2_2”, PDF_2, *HIST_2);

//I then add the chi2 as suggested by Wouter: root.cern.ch/phpBB2/viewtopic.php?p=24938#24938 (Thanks again!!)

RooMinuit m2_sum(chi2_sum);
RooFitResult* fitres1 = m2_sum.save();

## //Here is where I run into trouble. Each of the two histograms (HIST_1 and HIST_2) contain 5 bins, and the only floated parameter is f_sig. //So, If I were to follow the logic used in my question above, I would write: double chi2_val = chi2_sum.getVal(); double red_chi2 = chi2_val/(10-1);

Once again, I get a very high value for chi2_val…

Can anyone please tell me if I am doing something incorrect in either (or both) of the two cases?!