I would like to be able to make a ratio plot for the data and a fit in RooFit. It would of course be convenient to use TRatioPlot to do so, however the constructor for this
In principle this should be possible, almost all the information needed for TFitResult is in the RooFitResult, but
it might be not trivial.
Since you are doing a TRatioPlot for comparing an histogram with a function, this is a rather simple fit. The easiest solution is to convert your RooFit pdf to a TF1 using the asTF function and do a histogram fit to obtain a TFitResult
In the more general case where one has a RooFitResult then (in PyROOT) you’re suggesting to do this?
# model is our RooAbsPdf (let's say a RooGaussian)
# datahist is the RooDataHist that we fit model to
# x is our observable RooRealVar
# x_range is the fit range we care about
# roo_fit_result = model.fitTo(datahist, ...) # Assume something like this has been done
fit_result_func = model.asTF(ROOT.RooArgList(x))
hist = datahist.createHistogram('hist name', x)
# This gets us the TFitResult
fit_result = hist.Fit(fit_result_func.GetName(), 'ILS', '', x_range[0], x_range[1])
# Now fit_result_func should have the parameters of the fit
integral = fit_result_func.Integral(x_range[0], x_range[1])
If this is what you are suggesting, then I think this seems to work and can easily have a user wrapper function that handles all of this (however a quick test results in an error with illegal number of parameters from hist.Fit()). However, I am a bit concerned about the fact that RooFit and ROOT’s fits do NOT seem to give consistent results (c.f. my chi-square question). Do you have advice here?