Would anyone have a code snippet of how to return some goodness-of-fit value for an unbinned likelihood fit? In particular, how would I print a chisquared value on a unbinned liklihood fit? I assume I need to generate a binned histogram to get this chisquared? I also see there is a rooabsgoodnessoffit class, but the documentation is sparse on this one too.
I don’t have a Root-specific comment, but 1) the likelihood itself is something of a goodness of fit (although hard to interpret) and 2) I think you’re on the right track by making a binned histogram. If you are using the standard Gaussian chi^2, you may want to rebin so that you have at least 10 expected entries per bin (20 works even better). There are other chi^2 that work on small expected numbers of events.
For >1D fits this clearly works too but doesn’t tell the whole story in that case. One could make a multi-dimensional chi^2, e.g. as follows
RooChi2Var chi2(“chi2”,“chi2”,pdf,data) ;
Double_t val = chi2.getVal() ;
which would be the ‘raw’ chi2, i.e. not per d.o.f, but be aware that this is tricky because you tend to have many empty and low statistics bins for >1D datasets. Multi-dimensional goodness-of-fit is generally a hard problem.
So is there a way to return the number of floating or the number of fit parameters from a rooabspdf/rooplot?
Right now I have to manually put in the number of degrees of freedom into chisquare() funciton. I tried scouring the class libraries, but I can’t seem to find this.