RooClassFactory passing additional objects to constructor


I am trying to make my own custom PDF with the RooClassFactory::makePdf method. I want the constructor to take additional member variables (e.g. a RooDataHist) for use in the evaluate method. Implementing this in the constructor is not a problem but the additional methods are not available from the evaluate method (can access the members but their values are random). Some debugging revealed that the evaluate method is not called by the instance of my custom Pdf object (perhaps instead from an instance of its inherited class?) which explains the above.

I have not found any documentation on how to write custom Pdf classes which have additional members which are not of type RooRealProxy.

Can anyone help?

MyPdf.h (1.08 KB)
MyPdf.cxx (1.3 KB)
temp.C (1.4 KB)