Plot of Fit Residuals

I’m new to ROOT and was hoping someone could help me with this problem.

I’ve been fitting user-defined functions to histograms of data. I define the function in a separate macro and use Fit() to fit it to the histogram.
This seems to work fine but now I want to make a plot of the fit residuals: a plot of the difference between the bin contents and the value of the fit function, plotted with the errors associated with the bin contents.
There seems to be no simple way of doing this. In particular, I can’t find any way to get the value of the fit function from a certain bin.

I thought there must be a simple way to make these simple plots!
Thanks in advance,
Kim

Use TF1::Eval to compute the value of the function at x

If you have a hsitogram TH1* h and the fitted function TF1 *f,
You can compute the residuals with

for (int i =1,i<=h->GetNbins();i++) { double res = h->GetBinContent(i) - f->Eval(h->GetBinCenter(i)); }
Rene