I use roofit to do a 2D binned ML fit.
RooFitResult* r=model.fitTo(*data,Save(kTRUE));
Then I want to get the chi2 . I use the following codes:
RooChi2Var chi2("chi2", "chi2", model, RooDataHist("data","data",RooArgSet(M,Q),hmqrs));
Double_t chi2_val = chi2.getVal();
cout << "chi2 from RooChi2Var = " << chi2_val/(hmqrs->GetNbinsX()*hmqrs->GetNbinsY()-2.0) << endl;
I get the error information:
[#0] ERROR:Eval -- RooChi2Var::RooChi2Var(chi2) INFINITY ERROR: bin 0 has zero error, but function is not zero (0.000535416)
chi2 from RooChi2Var = 0
How can I solve this problem? Or are there any other good methods to get chi2.