Hello everyone.
Before everything I’m new to RooFit so I chose the newbie category.
I have a toy MC generated from a 2d distribution with 3 parameters and another one for scale in the following way (t, p = theta and phi independent variables):
RooRealVar t("t","t",0,2*M_PI) ;
RooRealVar p("p","p", 0, 2*M_PI) ;
//Defining Parameters according to RooFit.
//Initial value is the 3rd argument, 4th and 5th arg
//are the range of existance of the parameter.
RooRealVar alpha("alpha", "alpha", 0.65, 0.62, 0.66);
RooRealVar beta("beta", "beta", 0.06, 0.04, 0.075);
RooRealVar gamma("gamma", "gamma", -0.18, -.2, -0.16);
RooRealVar scale("scale", "scale", 5., 0., 10.);
RooAbsPdf* genpdf = RooClassFactory::makePdfInstance("GenPdf","scale*(3./(4.*M_PI))*(0.5*(1.-alpha) + (0.5)*(3.*alpha-1)*cos(t)*cos(t) - beta*sin(t)*sin(t)*cos(2.*p)- sqrt(2.)*gamma*sin(2.*t)*cos(p))",RooArgSet(t,p,alpha, beta, gamma, scale)) ;
// Generate a toy MC dataset from the interpreted p.d.f
//data will contain unbinned data.
RooDataSet* data = genpdf->generate(RooArgSet(t,p),50000) ;
Now I can do an unbind likelihood fit and everything seems to work ok(results at the end):
RooFitResult* r_ML = genpdf->fitTo(*data, Save()) ;
Then I create a binned dataset (resolution on theta and phi of 0.01 rad) and perform a chi2 but the results are quite different/suspicious from what I expected:
t.setBins(624);
p.setBins(624);
RooDataHist data_hist("data_hist","binned version of data",RooArgSet(t,p),*data) ;
RooAbsReal* chi2 = genpdf->createChi2(data_hist, Extended(true), DataError(RooAbsData::Expected), PrintLevel(1), Save());
RooMinimizer n(*chi2);
n.migrad() ;
n.hesse() ;
RooFitResult* r_chi2 = n.save();
Here are the results of the RooFitResults.
==> Chi2 Fit results
RooFitResult: minimized FCN value: 0, estimated distance to minimum: 0
covariance matrix quality: Approximation only, not accurate
Status : MIGRAD=0 HESSE=0
Floating Parameter FinalValue +/- Error
-------------------- --------------------------
alpha 6.3022e-01 +/- 2.50e-02
beta 6.1174e-02 +/- 2.75e-02
gamma -1.7819e-01 +/- 3.06e-02
scale 8.7985e+00 +/- 8.21e+00
==> ML Fit results
RooFitResult: minimized FCN value: 176472, estimated distance to minimum: 2.35474e-06
covariance matrix quality: Full, accurate covariance matrix
Status : MINIMIZE=0 HESSE=0
Floating Parameter FinalValue +/- Error
-------------------- --------------------------
alpha 6.4211e-01 +/- 3.41e-03
beta 5.9586e-02 +/- 2.77e-03
gamma -1.7837e-01 +/- 1.95e-03
scale 5.7338e+00 +/- 4.16e+00
Moreover, some not pleasant messages appear while it is chi2 fitting:
[#0] ERROR:Eval -- RooChi2Var::RooChi2Var(chi2_GenPdf_data_hist) INFINITY ERROR: bin 2 has zero error
I suppose it has something to do with empty bins (from other posts) but I do not know how to solve this. Is anything allright or shll I change something?
Thank you in advance.
Giacomo