Problem fitting RooProdPdf of RooHistPdf in 2D

I am attempting a 2D extended ML fit with a RooHistPdf (taken from phase space monte carlo from evtgen) as part of my fitting function.

The total PDF is of the form: PHSP[x,y] * (num1* BreitWigner[x] + num2)

I’ve constructed this in multiple ways (pseudocode):

RooProdPdf(PHSP,RooAddPdf(num1*BW[x],num2))

RooAddPdf(RooProdPdf(PHSP,BW),PHSP)

But the result is always roughly the same: whenever I use the RooHistPdf in a RooProdPdf and then attempt to fit, I receive a number of errors along the lines of:

Parameter values: mean1=10.5646, nBW=10, npdf=10, sigma1=0.04
PID18694/RooRealMPFE::nll_eTotal_argarggaussData_1776380_MPFE0[ arg=nll_eTotal_argarggaussData_GOF0 vars=(mean1,nBW,npdf,sigma1) ]
getLogVal() top-level p.d.f evaluates to zero @ !pdfs=(BWOne = 21.9396,pdfhist = 0/99989.4)
getLogVal() top-level p.d.f evaluates to zero @ !pdfs=(BWOne = 25.3746,pdfhist = 0/99989.4)
getLogVal() top-level p.d.f evaluates to zero @ !pdfs=(BWOne = 28.2436,pdfhist = 0/99989.4)
getLogVal() top-level p.d.f evaluates to zero @ !pdfs=(BWOne = 25.7128,pdfhist = 0/99989.4)
getLogVal() top-level p.d.f evaluates to zero @ !pdfs=(BWOne = 21.4127,pdfhist = 0/99989.4)
getLogVal() top-level p.d.f evaluates to zero @ !pdfs=(BWOne = 18.0406,pdfhist = 0/99989.4)
getLogVal() top-level p.d.f evaluates to zero @ !pdfs=(BWOne = 20.348,pdfhist = 0/99989.4)

and the fit does not converge.

I’ve tried this on 5.27.2, 5.27.6, (both Linux64), 5.24, 5.29 (both Windows). I have seen other posts mentioning bugs in the numerical integration handling in RooHistPdf, but they were allegedly fixed.

I’ve included versions of my code that can be run self-contained, that generate their own events (and the same errors), and the version that takes data from .root files.

Any help would be appreciated. Thanks.

Edit: I just saw that RooFit questions belong in another section. Please move this, if so.
selfContained.C (1.81 KB)
requiresRoots.C (1.37 KB)

With some more investigating, I’ve found that I get the same problem whenever I attempt to fit a RooProdPdf of a RooHistPdf in 2D, regardless of what the other element of the product is.

This happens consistently EXCEPT in the particular circumstance in which I use the
final pdf to generate the data that I then fit to it. I’m not sure why
it works in this circumstance.

For instance:

Thing that works:

pdf1(x,y)->generate Monte Carlo events 1->hist1(x,y)->hist1pdf(x,y)

pdf2(x,y)->generate MC2->hist2(x,y)->hist2pdf(x,y)

finalpdf = hist1pdf*hist2pdf

finalpdf->generated MC3

finalpdf.fitTo(MC3)

Thing that doesn’t work:

pdf1(x,y)->generate events MC1->hist1(x,y)->hist1pdf(x,y)

pdf2(x,y)->generate events MC2->hist2(x,y)->hist2pdf(x,y)

finalpdf = hist1pdf*hist2pdf

pdf1*pdf2->generate events MC3

finalpdf.fitTo(MC3)

where a->b indicates that I’m using a to create b.