Subtract a ROOchebychev function from a histogram in ROOFIT

Hi,

we discussed this here:

but it’s a bit long to read.

The gist is:
You can create a standard ROOT histogram from a PDF:
RooAbsReal::createHistogram

The options for the generation of the histogram are also listed in the documentation I linked above.
When you have the TH1x, subtraction of the histograms should be easy.

Note:

  • You have to match the binning of the histograms, so something like Binning(200, 0., 500.) is what you should use when you ask for a histogram.
  • You likely have to adjust the normalisation. Without doing anything, RooFit will always normalise the PDF to unity. If you need custom scaling, you can either scale the histogram manually hxx->Add(hyy, -1. * nbkg.getVal()) , or you can have it scaled when creating the histogram. Have a look at the documentation again:
    RooAbsPdf::createHistogram docs
    Extended() should enable automatic scaling (hopefully to the value of nbkg).
1 Like