# Upper Limit calculation using RooFit

Hi all,

I have a two-dimensional fit, with two floating paramaters, nsig and nbkg. Now I try to calculate the 90% CL UL from the log-likelihood. What I am doing is (in a Python environment):

``````nll  = RooNLLVar("nll","nll",FitPdf, Data, ROOT.RooFit.Extended(ROOT.kTRUE))
nll2 = RooFormulaVar("nll2","nll+6550.",RooArgList(nll));
llhood = RooFormulaVar("llhood","exp(-0.5*nll2)",RooArgList(nll2));
nsig.setRange("IntRange1",0,1000.)
Int1 = llhood.createIntegral(RooArgSet(nsig), ROOT.RooFit.Range('IntRange1'))
Int1Val = Int1.getVal()
i = 0
hit = False
while not(hit):
i=i+1
nsig.setRange("IntRange2",0,float(i))
Int2 = llhood.createIntegral(RooArgSet(nsig), ROOT.RooFit.Range('IntRange2'))
if Int2.getVal() >= Int1Val*0.9:
print i
hit=True``````

My suspicion is that the integral is done with fixed nbkg, and thus I obtain a false upper limit. Is that correct? And how can I get RooFit to integrate along the optimal nbkg values?
The two-dimensional llhood looks as follows:

So, instead of integrating parallel to the x-aixs, I would like to follow the major-axis of the ellipse.

Cheers and Thanks,

Torsten

Okay, I managed to get a bit further. It seems that I need the profile-likelihood which looks fine. But I am not able to convert it into the log-likelihood like with my nll2

``````nll  = RooNLLVar("nll","nll",FitPdf, Data, ROOT.RooFit.Extended(ROOT.kTRUE))
nll2 = RooFormulaVar("nll2","nll+6548.3",RooArgList(nll));
Profile = nll.createProfile(RooArgSet(nsig))
llhoodP = RooFormulaVar("llhood","exp(-0.5*Profile)",RooArgList(Profile));
llhoodN = RooFormulaVar("llhood","exp(-0.5*nll2)",RooArgList(nll2));``````

When I draw “nll2” and “Profile” everything looks fine

But when I draw “llhoodN” and “llhoodP”, the first looks good, the latter is constantly zero

Since RooFormulaVar as well as createProfile return a RooAbsReal I don’t understand this different behavior. How can I get this working?

Cheers and Thanks,

Torsten

Okay, so to complete this topic, I found a solution. Apparently the use of createProfile returns a RooProfileLL object which cannot be evaluated. To circumvent this I directly create a RooProfileLL which seems to work without any problems.

``````nll  = RooNLLVar("nll", "nll", FitPdf, Data, ROOT.RooFit.Extended(ROOT.kTRUE))
Profile = RooProfileLL("Profile", "Profile", nll, RooArgSet(nsig))
llhoodP = RooFormulaVar("llhoodP","exp(-0.5*Profile)",RooArgList(Profile));``````

Cheers,

Torsten