Dear all,
I am running the attached script which needs the attached root file.
It never passes line 87 (auto bcInterval = bc.GetInterval();); here it is the releavant output:
[...]
Before bc.GetInterval()
[#1] INFO:Minization -- p.d.f. provides expected number of events, including extended term in likelihood.
[#1] INFO:Minization -- createNLL: caching constraint set under name CONSTR_OF_PDF_totPDF_FOR_OBS_mass with 0 entries
[#1] INFO:Eval -- BayesianCalculator::GetPosteriorFunction : nll value -2191.47 poi value = 4.61953
[#1] INFO:Eval -- BayesianCalculator::GetPosteriorFunction : minimum of NLL vs POI for POI = 4.63183 min NLL = -2191.47
[#1] INFO:Minization -- p.d.f. provides expected number of events, including extended term in likelihood.
[#1] INFO:Minization -- Including the following contraint terms in minimization: (prior)
[#1] INFO:Minization -- The following global observables have been defined: ()
[#1] INFO:Eval -- BayesianCalculator: Compute interval using RooFit: posteriorPdf + createCdf + RooBrentRootFinder
[#1] INFO:NumericIntegration -- RooRealIntegral::init(_posteriorPdf_likelihood_times_prior_product_totPDF_prior_cdf_Int[Npsi_prime]) using numeric integrator RooIntegrator1D to calculate Int(Npsi_prime)
[#1] INFO:NumericIntegration -- RooRealIntegral::init(_posteriorPdf_likelihood_times_prior_product_totPDF_prior_cdf_Int[Npsi_prime|CDF]_Norm[Npsi_prime]) using numeric integrator RooIntegrator1D to calculate Int(Npsi_prime)
After almost half an hour it is still stuck there. As a comparison a python version of the script works in reasonable time - please find it in attachment.
exercise_2.py (3.7 KB) Many thanks in advance and kind regards,
Marco Bomben
For some reason your variable “Npsi” (the poi) that is in the workspace is not linked to the PDF.
So when computing the Bayesian calculator it is done in a too large range.
The solution is adding these lines to set a shorter range (e.g. 0,30)
RooArgSet * vars = sbModel.GetPdf()->getVariables() ;
RooRealVar * p = (RooRealVar*) vars->find("Npsi");
p->setRange(0., 30.); // set range
You can also set the BayesianCalculator to perform a simple scan that is normally faster
int npoints = 100;
bc.SetScanOfPosterior(points);
In the Python script you did not have the problem, because the HypoTestInverter calculator was run it before and it was setting the range of the poi
RooRealVar varpoi = (*(w->var("Npsi")));
varpoi.setRange(0.,20.); // this is mostly for plotting
Here, you are creating a copy of the variable, by assigning to a new RooRealVar. Above, you are only setting the range of the copy, but the original is not affected. Interestingly, you uncovered a bug in the numerical integrator with this, as it’s getting stuck in an infinite loop when integrating over a range of size zero. I’ll have a look into that.
Lorenzo suggested to retrieve the variable and save the pointer, which is totally fine, or if you want to stay closer to your initial macro, you can use a reference.