How to compare (get the ratio) of Roofit result and data

Hello,

I’m trying to get a ratio plot for roofit result and data historgram like this:

const int nBinY = 20;
const Double_t binsY[nBinY+1] = {-0.0734,-0.0562,-0.0428,-0.0320,-0.0236,-0.0170,-0.0118,-0.0078,-0.0046,-0.002,0.0,0.002,0.0046,0.0078,0.0118,0.0170,0.0236,0.0320,0.0428,0.0562,0.0734};
RooBinning bin_dcaxy(nBinY,binsY);

TH1D* h_DcaData= somthing....
RooDataHist h_Data("h_Data","h_Data",RooArgSet(x),h_DcaData);
RooGaussian MCP_pdf("gauss","gaussian PDF",x,mean,sigma);
RooGenericPdf power_pdf("power_pdf","power_odf","1/pow((1+power_a*abs(x)),power_n)",RooArgSet(x,power_a,power_n));
RooAddPdf MCDCAmix_pdf("MCDCAmix_pdf","P+NP exML",RooArgList(MCP_pdf,power_pdf),RooArgList(pNum,npNum));
MCDCAmix_pdf.fitTo(h_Data,Extended(kTRUE));

I could follow the tutorial to get the two component pdf with data plot. But in order to check how good is the fit, I need to draw the data/fit plot (ie. RooDataHist h_Data / RooAddPdf MCDCAmix_pdf ), totally no idea about it especially for the data has special binning.

Thanks.

I tried a indirect method, covert everything to TH1, then I can compare them:

TH1D h_fromRooData = (TH1D)h_Data.createHistogram(“h_fromRooData”,x,Binning( bin_dcaxy));
RooDataHist *pdfDataHis=MCDCAmix_pdf.generateBinned(x,0,true);
TH1D h_pdfDataHis= (TH1D)pdfDataHis->createHistogram(“h_pdfDataHis”,x,Binning( bin_dcaxy));

then just do the normal TH1 divide.

is there any direct way to do that?
Thanks.

See also: TRatioPlot

Thanks,
The TRatioPlot seems very useful for ratio and residue plot, but does it compatible with Roofit class RooAbsPdf ? Still looking for a direct way to compare RooAbsPdf and RooDataHist, any thing in Roofit can do things similar to TRatioPlot?