Dear all, I am facing an issue with ProfileLikelihoodCalculator (in PyRoot) and I really don’t understand what is happening here.
I have some PDFs (RooHistPdf and RooAddPdf) : p_tth, p_ttz, p_bkg , sig
From them I do a template as follow :
gen_tth = p_tth.generate(r.RooArgSet(x), ntth, r.RooFit.Extended())
gen_ttz = p_ttz.generate(r.RooArgSet(x), nttz, r.RooFit.Extended())
gen_bkg = p_bkg.generate(r.RooArgSet(x), nbkg, r.RooFit.Extended())
d_ttcomb = gen_tth
d_ttcomb.append(gen_ttz)
d_ttcomb.append(gen_bkg)
Then I was using RooFit with no issue as follow :
sig.fitTo(d_ttcomb,r.RooFit.SumW2Error(False),r.RooFit.PrintLevel(-1))
Now I would like to have a look at what would return RooStats so after several tries (and read a lot of examples and tutos) I arrived to what I believe to be right :
w = r.RooWorkspace("w")
getattr(w,'import')(sig)
getattr(w,'import')(d_ttcomb)
print " -> w.Print :"
w.Print()
#
model = r.RooStats.ModelConfig()
model.SetWorkspace(w)
model.SetPdf("sigBkg")
print " -> model.Print :"
model.Print()
print " -> d_ttcomb.Print :"
d_ttcomb.Print()
#
plc = r.RooStats.ProfileLikelihoodCalculator(d_ttcomb,model)
plc.SetConfidenceLevel(0.68)
print " -> print plc:"
print plc
#
plInt = plc.GetInterval()
print " -> plInt.Print():"
plInt.Print()
low = plInt.LowerLimit(w.var("alpha"))
high = plInt.HigherLimit(w.var("alpha"))
From the prints you can get what are the PDFs and my issue I have to understand :
-> w.Print :
RooWorkspace(w) w contents
variables
(alpha,sigFrac,x)
p.d.f.s
RooHistPdf::p_ttbkg[ pdfObs=(x) ] = 0.00034545
RooHistPdf::p_tth[ pdfObs=(x) ] = 1.27595e-05
RooHistPdf::p_ttz[ pdfObs=(x) ] = 5.44226e-06
RooAddPdf::sig[ alpha * p_ttz + [%] * p_tth ] = 8.30986e-06
RooAddPdf::sigBkg[ sigFrac * sig + [%] * p_ttbkg ] = 0.000311309
datasets
RooDataSet::wu(x)
embedded datasets (in pdfs and functions)
RooDataHist::d_ttz(x)
RooDataHist::d_tth(x)
RooDataHist::d_ttbkg(x)
-> model.Print :
=== Using the following for ===
PDF: RooAddPdf::sigBkg[ sigFrac * sig + [%] * p_ttbkg ] = 0.000311309
-> d_ttcomb.Print :
RooDataSet::wu[x,weight:weight] = 300 entries (2.20009e+06 weighted)
-> print plc:
<ROOT.RooStats::ProfileLikelihoodCalculator object at 0x6a1cdc0>
-> plInt.Print():
Traceback (most recent call last):
File “fit.py”, line 398, in
makePseudoExp(p_tth, p_ttz, bkg, sigBkg, alpha, int(ntth), int(nttz), int(nbkg), alpha_val, alpha_err)
File “fit.py”, line 173, in makePseudoExp
plInt.Print()
ReferenceError: attempt to access a null-pointer
*** glibc detected *** python: free(): invalid pointer: 0x0000000006672c04 ***
It seeems that everything is fine until I reach GetInterval. I have checked that all my histograms and properly accessed and the pdfs are not empty.
I really need help from experts to fix my problem.