RooFit goodness of fit

Dear ROOTers,

I’m using RooFit in order to estimate the level of signal in my data distribution.
I construct my pdf the following way:

RooDataHist data(“data”,“data to be fitted to”,sinin,hData);

RooExtendPdf extpdfsig(“Signal”,“extpdfsig”,realpdf,signum,“sigrange”);
RooExtendPdf extpdffake(“Background”,“extpdffake”,fakepdf,fakenum,“sigrange”);

RooAddPdf model(“model”,“sig + background”,RooArgList(extpdfsig,extpdffake));


then, in order to get the chi square, I do:

RooChi2Var chi2_lowstat(“chi2_lowstat”,“chi2”,model,data) ;
cout << "my chi2 is " << chi2_lowstat.getVal() << endl ;

However, I do get always a chi2 of 0, having the following error:

[#0] ERROR:Eval – RooChi2Var::RooChi2Var(chi2_lowstat) INFINITY ERROR: bin 0 has zero error
my chi2 is 0

Unfortunately, I cannot overcome the problems of bins with zero entries in my data distribution and I cannot rebin this distribution as well. I was thinking of creating a clone of the data distribution where I would set the content of the bins with 0 entries to 1.e-5 or so but I would like to know how to exclude that from the chi2 calculation. In general, how can I exclude specific bins from the chi2 calculation ?