RooAbsPDF CreateNLL

Hello!

I am trying to use the CreateNLL function for RooAbsPDF. There are two versions on the class function page. When I use this function:

nlls[cat_name] = pdftmp.createNLL(datatmp, RF.Constrain(constrainedParams), RF.GlobalObservables(glbObs), RF.Offset(1), RF.NumCPU(4,3), RF.Optimize(2))

I see this error complaining I should use the other constructor:

File “test.py”, line 152, in
TypeError: none of the 2 overloaded methods succeeded. Full details:
RooAbsReal* RooAbsPdf::createNLL(RooAbsData& data, const RooLinkedList& cmdList) =>
takes at most 2 arguments (6 given)
handshake: xferraw read: Broken pipe (C++ exception)

So I tried the other constructor:

    cmdList = RooLinkedList()
    cmdList.Add(RF.GlobalObservables(glbObs))
    cmdList.Add(RF.Offset(1))
    cmdList.Add(RF.NumCPU(4,3))
    cmdList.Add(RF.Optimize(2))
    nlls[cat_name] = pdftmp.createNLL(datatmp, cmdList)

I get errors complaining I should use the fist constructor.

The code marches through these errors but if I call createNLL multiple times I start to see real crashes. What am I doing wrong??

I am relatively new to python so apologies if the solution is obvious.

Hi,

here you can find a profile likelihood example that can get you started.

import ROOT

w = ROOT.RooWorkspace("w")
w.factory("Gaussian::sig(x[-10,10],mean[5,0,10],0.5)")
pdf = w.pdf("sig")
x = w.var("x")
mean = w.var("mean")

data = pdf.generate(ROOT.RooArgSet(x),1000)

RF=ROOT.RooFit
nll = pdf.createNLL(data, RF.Offset(1), RF.NumCPU(3), RF.Optimize(2))


ROOT.RooMinuit(nll).migrad()

frame = mean.frame(RF.Bins(10),RF.Range(0,10),RF.Title("LL and profileLL in mean")) ;
nll.plotOn(frame,RF.ShiftToZero())
frame.Draw()

Cheers,
Danilo