How to use ProfileLikelihoodCalculator to calculate upperlimit?

Hi experts,

I am using macro to calculate the upper limit on the signal yield.

I have, no. of observed event = 2
no. of background =0.9
uncertainty on background = 0.35
uncertainty on signal efficiency =0.05
need to to calculate 90% CL UL

So I modified the macro accordingly as attached herers101_limitexample.C (9.0 KB) :

insert the uncertainties here

  wspace->factory("Gaussian::sigConstraint(1,ratioSigEff,0.05)"); // uncertainty on signal efficiency
  wspace->factory("Gaussian::bkgConstraint(1,ratioBkgEff,0.35)"); // uncrtainty on backgound
  // Create an example dataset with 2 observed events

But I couldn’t figure out where shall I insert the no. of backgrounds here in the code?
Also are the uncertainties and the number of observed events is inserted correctly here?

Please let me know someone.

Thanks in advance


You should add this line:


before setting b to a constant (b->setConstant()).


Hi @moneta

Thank You for the quick reply!

Can you please let me know why it is not giving any UL when I set no. of observed event = 0 ? while other values are not changed.

The error is followed as:

[#1] INFO:Minization -- RooMinimizer::optimizeConst: deactivating const optimization
Error in <TDecompLU::InvertLU>: matrix is singular, 1 diag elements < tolerance of 2.2204e-16
[#1] INFO:Minization -- createNLL picked up cached consraints from workspace with 2 entries
[#1] INFO:Minization --  Including the following contraint terms in minimization: (sigConstraint,bkgConstraint)
[#1] INFO:Minization -- The following global observables have been defined: ()
Metropolis-Hastings progress: ....................................................................................................
[#1] INFO:Eval -- Proposal acceptance rate: 0.005%
[#1] INFO:Eval -- Number of steps in chain: 1
[#0] ERROR:InputArguments -- MCMCInterval::CreateVector: creation of vector failed: Number of burn-in steps (num steps to ignore) >= number of steps in Markov chain.
terminate called after throwing an instance of 'std::length_error'
  what():  vector::_M_default_append

This macro gives three types of limits. Can one expect similar results between them?
If not, which one is better to adopt?


I can reproduce your problem in the tutorial with nobs=0. The problem is that the creation of the proposal function failed for that particular case, you should comment (or remove) the line"


That will make the MCMC working.
The results should be similar in case of higer statistics , when nobs is small it is expected to observe differences, since also Bayesian and Frequentist interval are conceptually different.

Which one to use depends also on the recoomendation of your experiment. For example at LHC normally upper limits based on the CL(s) procedure are typically used.
If you have low statistics one should use a method based on pseudo-experiments (Feldman-Cousins or CL(s) with toys, for higher statistics where one can use asymptotic approximation, limits based on the Profile likelihood are typically used. However, for upper limits it is typically used the asymptotic CLs, with the AsymptoticCalculator in RooStats.
See the tutorial StandardHypoTestInvDemo.C,

Some general documentation of RooStats is available in these slides , presented at a tutorial,

more info with more example also here:


This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.