How to fit within a 2D boundary w/ RooProdPdf

Hello,

I’d like to fit a simple pdf within a 2D boundary, and set the pdf to zero outside the boundary. Here is the pdf for fitting:

Here x,y are observables, and a1,a2 are fit parameters that will float. To constrain this pdf within a boundary (like a circle, say) I wrote my own class using RooClassFactory::makePdf, e.g.

This function returns 0 if x,y are outside some boundary, and returns 1 if they are inside. It is NOT dependent on any fit parameter, only x,y.

Now, both functions work fine separately. I can generate events, and in the case of the “shape” pdf it will return the correctly fitted values of a1, a2. So now I’d like to multiply them, so that the total pdf is 0 outside the boundary, and the fit is performed inside:

Is there something obviously wrong about this? Do I need to specify that x,y are shared between each pdf, but fit params a1,a2 are only in one pdf? I’m getting strange errors, many from “RooIntegrator1D::integral” not converging, then consequently “TPad::ResizePad: Inf/NaN propagated to the pad”. Any suggestions why this doesn’t work?

Thank you!
Eric