Hi Root and RooFit experts,
Is it possible to create a custom RooFit pdf from python? I am trying to make a pdf that uses a gaussian process with the scikit-learn library in python. I am running into problems trying to make a new python class that inherets from RooAbsPdf. What I am trying is this:
import ROOT
Class RooMyPdf(ROOT.RooAbsPdf):
def __init__(self, name, title, x, alpha):
super(RooMyPdf, self).__init__(name, title)
def evaluate(self):
#Do some calculations here
return 1.0
Then trying create an instance of this class:
import ROOT
import RooMyPdf
x = ROOT.RooRealVar('x','x',-1.0,1.0)
alpha = ROOT.RooRealVar('alpha','alpha',0.0,1.0)
pdf = RooMyPdf.RooMyPdf("mypdf", "CustomPDF",x ,alpha)
And the output I get is:
Traceback (most recent call last):
File "pdfTest.py", line 7, in <module>
pdf = RooMyPdf.RooMyPdf("mypdf", "CustomPDF",x ,alpha)
File "/Users/rob/Documents/Atlas/software/DiphotonAnalysis/GPBackgrounds/GPBackgrounds/RooMyPdf.py", line 5, in __init__
super(RooMyPdf, self).__init__()
TypeError: none of the 3 overloaded methods succeeded. Full details:
RooAbsPdf is abstract and can not be instantiated
RooAbsPdf is abstract and can not be instantiated
RooAbsPdf is abstract and can not be instantiated
Looking in the c++ implementation of the RooAbsPdf class, it doesnt look like the constructor is an abstract method so Im not really sure whats going on here. Am I doing something dumb or is this not possible to do in python? Any help would be greatly appreciated.