Normalization uncertainties in VisualizeError

I’m trying to use the VisualizeError option in RooAbsPdf::plotOn. However, I can’t figure out how to get it to account for the normalization uncertainty on the PDF. I’m using an extended pdf, so I would expect the error on the overall normalization to be accounted for, but it’s not.

I declare a pdf like this:
RooRealSumPdf* bkgOnlyPdf = new RooRealSumPdf(modelName1 + “_bkgOnly”,modelName1 + “_bkgOnly”,myFuncs, myCoefs, true);

and then plot it using a RooFitResult called fitresGlobal:

But the error band does not include the uncertainty on the overall normalization of bkgOnlyPdf. Is there a way to include this?


maybe I am more lucky.

Same question: why VisualizeError don’t propagate normalization errors?

x = ROOT.RooRealVar('x', 'x', 0, 100)
n = ROOT.RooRealVar('n', 'n', 50, 0, 1000)
shape = ROOT.RooUniform('shape', 'shape', ROOT.RooArgSet(x))
pdf = ROOT.RooExtendPdf('pdf', 'pdf', shape, n)

data = pdf.generate(ROOT.RooArgSet(x), ROOT.RooFit.Extended())

fit_result = pdf.fitTo(data, ROOT.RooFit.Save())

canvas = ROOT.TCanvas()
frame = x.frame(10)
pdf.plotOn(frame, ROOT.RooFit.VisualizeError(fit_result, 1, False), ROOT.RooFit.FillColor(ROOT.kOrange))


that’s probably because the error visualisation only takes care of shapes, not normalisations. At the moment, I cannot do more than report it:

Has someone perhaps found a workaround for this in the mean time?

Hi @bibsession!

Actually including the normalization uncertainties was always possible, you just had to know the right command arguments for plot on :slight_smile:

You just have to add the Normalization() command with the RelativeExpected parameter. For the example posted in the second post of this thread, it would look like this:

pdf.plotOn(frame, ROOT.RooFit.VisualizeError(fit_result, 1, False),
           ROOT.RooFit.Normalization(1.0, ROOT.RooAbsReal.RelativeExpected))

To make this easier to figure out in the future, I’m about to add some more documentation to RooAbsReal::fitTo():

I hope that’s fine for you!


I have tried implementing it this way, but unfortunately it does not work in my case. When I add in the normalization into the plotOn() function, the error bands just disappear. The same happens when I add the normalization in a plotOn function where I’m not trying to visualize the error, but just the pdf itself.
I’m suspecting it has something to do with the fact that I’m using a RooSimultaneous pdf. For the regular pdfs, when I use Slice() to restrict the plot just to one of my categories, eg.

pdf.plotOn(frame, ProjWData(sample, data),
           Normalization(1.0, ROOT.RooAbsReal.RelativeExpected), Slice(sample,"cat1"))

it reappears, but this trick does not work for the error bands (eg. when I include VisualizeError(fit_result, 1, kFALSE)). Any ideas how I could solve this problem?