87#include "RConfigure.h"
107struct LikelihoodFunction {
109 fFunc(
f), fPrior(prior),
110 fOffset(offset), fMaxL(0) {
111 fFunc.binding().resetNumCall();
114 void SetPrior(
RooFunctor * prior) { fPrior = prior; }
116 double operator() (
const double *
x )
const {
117 double nll = fFunc(
x) - fOffset;
118 double likelihood = std::exp(-nll);
120 if (fPrior) likelihood *= (*fPrior)(
x);
122 int nCalls = fFunc.binding().numCall();
123 if (nCalls > 0 && nCalls % 1000 == 0) {
124 ooccoutD((
TObject*)0,Eval) <<
"Likelihood evaluation ncalls = " << nCalls
125 <<
" x0 " <<
x[0] <<
" nll = " << nll+fOffset;
128 <<
" max Likelihood " << fMaxL << std::endl;
131 if (likelihood > fMaxL ) {
133 if ( likelihood > 1.E10) {
134 ooccoutW((
TObject*)0,Eval) <<
"LikelihoodFunction::() WARNING - Huge likelihood value found for parameters ";
135 for (
int i = 0; i < fFunc.nObs(); ++i)
137 ooccoutW((
TObject*)0,Eval) <<
" nll = " << nll <<
" L = " << likelihood << std::endl;
145 double operator() (
double x)
const {
147 assert(fFunc.nObs() == 1);
149 return (*
this)(&tmp);
155 mutable double fMaxL;
170 fLikelihood(fFunctor, 0, nllMinimum),
171 fIntegrator(
ROOT::
Math::IntegratorMultiDim::GetType(integType) ),
172 fXmin(bindParams.getSize() ),
173 fXmax(bindParams.getSize() ),
174 fNorm(1.0), fNormErr(0.0), fOffset(0), fMaxPOI(0),
175 fHasNorm(false), fUseOldValues(true), fError(false)
179 fPriorFunc = std::make_shared<RooFunctor>(*prior, bindParams,
RooArgList());
180 fLikelihood.SetPrior(fPriorFunc.get() );
183 fIntegrator.SetFunction(fLikelihood, bindParams.
getSize() );
185 ooccoutD((
TObject*)0,NumIntegration) <<
"PosteriorCdfFunction::Compute integral of posterior in nuisance and poi. "
186 <<
" nllMinimum is " << nllMinimum << std::endl;
188 std::vector<double> par(bindParams.
getSize());
189 for (
unsigned int i = 0; i < fXmin.size(); ++i) {
195 <<
" in interval [ " << fXmin[i] <<
" , " << fXmax[i] <<
" ] " << std::endl;
204 fNorm = (*this)( fMaxPOI );
205 if (fError)
ooccoutE((
TObject*)0,NumIntegration) <<
"PosteriorFunction::Error computing normalization - norm = " << fNorm << std::endl;
207 fNormCdfValues.insert(std::make_pair(fXmin[0], 0) );
208 fNormCdfValues.insert(std::make_pair(fXmax[0], 1.0) );
215 PosteriorCdfFunction(
const PosteriorCdfFunction & rhs) :
217 fFunctor(rhs.fFunctor),
219 fPriorFunc(rhs.fPriorFunc),
220 fLikelihood(fFunctor, fPriorFunc.get(), rhs.fLikelihood.fOffset),
225 fNormErr( rhs.fNormErr),
226 fOffset(rhs.fOffset),
227 fMaxPOI(rhs.fMaxPOI),
228 fHasNorm(rhs.fHasNorm),
229 fUseOldValues(rhs.fUseOldValues),
231 fNormCdfValues(rhs.fNormCdfValues)
233 fIntegrator.SetFunction(fLikelihood, fXmin.size() );
242 bool HasError()
const {
return fError; }
246 ooccoutD((
TObject*)0,NumIntegration) <<
" cloning function .........." << std::endl;
247 return new PosteriorCdfFunction(*
this);
251 void SetOffset(
double offset) { fOffset = offset; }
256 PosteriorCdfFunction&
operator=(
const PosteriorCdfFunction &) {
260 double DoEval (
double x)
const {
264 if (
x <= fXmin[0] )
return -fOffset;
266 if (
x >= fMaxPOI && fHasNorm)
return 1. - fOffset;
270 if (fHasNorm && fUseOldValues) {
272 std::map<double,double>::iterator itr = fNormCdfValues.upper_bound(
x);
274 if (itr != fNormCdfValues.end() ) {
275 fXmin[0] = itr->first;
276 normcdf0 = itr->second;
282 fFunctor.binding().resetNumCall();
284 double cdf = fIntegrator.Integral(&fXmin[0],&fXmax[0]);
285 double error = fIntegrator.Error();
286 double normcdf = cdf/fNorm;
288 ooccoutD((
TObject*)0,NumIntegration) <<
"PosteriorCdfFunction: poi = [" << fXmin[0] <<
" , "
289 << fXmax[0] <<
"] integral = " << cdf <<
" +/- " << error
290 <<
" norm-integ = " << normcdf <<
" cdf(x) = " << normcdf+normcdf0
291 <<
" ncalls = " << fFunctor.binding().numCall() << std::endl;
293 if (
TMath::IsNaN(cdf) || cdf > std::numeric_limits<double>::max()) {
294 ooccoutE((
TObject*)0,NumIntegration) <<
"PosteriorFunction::Error computing integral - cdf = "
299 if (cdf != 0 && error/cdf > 0.2 )
300 oocoutW((
TObject*)0,NumIntegration) <<
"PosteriorCdfFunction: integration error is larger than 20 % x0 = " << fXmin[0]
301 <<
" x = " <<
x <<
" cdf(x) = " << cdf <<
" +/- " << error << std::endl;
304 oocoutI((
TObject*)0,NumIntegration) <<
"PosteriorCdfFunction - integral of posterior = "
305 << cdf <<
" +/- " << error << std::endl;
314 fNormCdfValues.insert(std::make_pair(
x, normcdf) );
317 double errnorm =
sqrt( error*error + normcdf*normcdf * fNormErr * fNormErr )/fNorm;
318 if (normcdf > 1. + 3 * errnorm) {
319 oocoutW((
TObject*)0,NumIntegration) <<
"PosteriorCdfFunction: normalized cdf values is larger than 1"
320 <<
" x = " <<
x <<
" normcdf(x) = " << normcdf <<
" +/- " << error/fNorm << std::endl;
323 return normcdf - fOffset;
327 mutable std::shared_ptr<RooFunctor> fPriorFunc;
328 LikelihoodFunction fLikelihood;
330 mutable std::vector<double> fXmin;
331 mutable std::vector<double> fXmax;
333 mutable double fNormErr;
339 mutable std::map<double,double> fNormCdfValues;
353 norm = 1.0,
double nllOffset = 0,
int niter = 0) :
356 fLikelihood(fFunctor, 0, nllOffset),
358 fXmin(nuisParams.getSize() ),
359 fXmax(nuisParams.getSize() ),
365 fPriorFunc = std::make_shared<RooFunctor>(*prior, nuisParams,
RooArgList());
366 fLikelihood.SetPrior(fPriorFunc.get() );
369 ooccoutD((
TObject*)0,NumIntegration) <<
"PosteriorFunction::Evaluate the posterior function by integrating the nuisances: " << std::endl;
370 for (
unsigned int i = 0; i < fXmin.size(); ++i) {
375 <<
" in interval [" << fXmin[i] <<
" , " << fXmax[i] <<
" ] " << std::endl;
377 if (fXmin.size() == 1) {
380 fIntegratorOneDim->SetFunction(fLikelihood);
383 fIntegratorOneDim->Options().Print(
ooccoutD((
TObject*)0,NumIntegration) );
385 else if (fXmin.size() > 1) {
387 fIntegratorMultiDim->SetFunction(fLikelihood, fXmin.size());
391 fIntegratorMultiDim->SetOptions(opt);
405 double Error()
const {
return fError;}
409 double DoEval (
double x)
const {
414 fFunctor.binding().resetNumCall();
418 if (fXmin.size() == 1) {
419 f = fIntegratorOneDim->Integral(fXmin[0],fXmax[0]);
420 error = fIntegratorOneDim->Error();
422 else if (fXmin.size() > 1) {
423 f = fIntegratorMultiDim->Integral(&fXmin[0],&fXmax[0]);
424 error = fIntegratorMultiDim->Error();
431 ooccoutD((
TObject*)0,NumIntegration) <<
"PosteriorFunction: POI value = "
432 <<
x <<
"\tf(x) = " <<
f <<
" +/- " << error
433 <<
" norm-f(x) = " <<
f/fNorm
434 <<
" ncalls = " << fFunctor.binding().numCall() << std::endl;
439 if (
f != 0 && error/
f > 0.2 )
440 ooccoutW((
TObject*)0,NumIntegration) <<
"PosteriorFunction::DoEval - Error from integration in "
441 << fXmin.size() <<
" Dim is larger than 20 % "
442 <<
"x = " <<
x <<
" p(x) = " <<
f <<
" +/- " << error << std::endl;
444 fError = error / fNorm;
449 mutable std::shared_ptr<RooFunctor> fPriorFunc;
450 LikelihoodFunction fLikelihood;
452 std::unique_ptr<ROOT::Math::Integrator> fIntegratorOneDim;
453 std::unique_ptr<ROOT::Math::IntegratorMultiDim> fIntegratorMultiDim;
454 std::vector<double> fXmin;
455 std::vector<double> fXmax;
457 mutable double fError;
469 nllOffset = 0,
int niter = 0,
bool redoToys =
true ) :
472 fLikelihood(fFunctor, 0, nllOffset),
475 fNuisParams(nuisParams),
477 fNumIterations(niter),
481 if (niter == 0) fNumIterations = 100;
484 fPriorFunc = std::make_shared<RooFunctor>(*prior, nuisParams,
RooArgList());
485 fLikelihood.SetPrior(fPriorFunc.get() );
488 ooccoutI((
TObject*)0,InputArguments) <<
"PosteriorFunctionFromToyMC::Evaluate the posterior function by randomizing the nuisances: niter " << fNumIterations << std::endl;
490 ooccoutI((
TObject*)0,InputArguments) <<
"PosteriorFunctionFromToyMC::Pdf used for randomizing the nuisance is " << fPdf->GetName() << std::endl;
493 for (
int i = 0; i < fNuisParams.getSize(); ++i) {
494 if (!vars->
find( fNuisParams[i].GetName() ) ) {
496 <<
" is not part of sampling pdf. "
497 <<
"they will be treated as constant " << std::endl;
503 ooccoutI((
TObject*)0,InputArguments) <<
"PosteriorFunctionFromToyMC::Generate nuisance toys only one time (for all POI points)" << std::endl;
508 virtual ~PosteriorFunctionFromToyMC() {
if (fGenParams)
delete fGenParams; }
511 void GenerateToys()
const {
512 if (fGenParams)
delete fGenParams;
513 fGenParams = fPdf->generate(fNuisParams, fNumIterations);
515 ooccoutE((
TObject*)0,InputArguments) <<
"PosteriorFunctionFromToyMC - failed to generate nuisance parameters" << std::endl;
519 double Error()
const {
return fError;}
531 double DoEval(
double x)
const {
533 int npar = fNuisParams.getSize();
538 if (fRedoToys) GenerateToys();
539 if (!fGenParams)
return 0;
549 for(
int iter=0; iter<fNumIterations; ++iter) {
552 std::vector<double> p(npar);
553 for (
int i = 0; i < npar; ++i) {
554 const RooArgSet* genset=fGenParams->get(iter);
563 double fval = fLikelihood( &p.front() );
569 double nuisPdfVal = fPdf->getVal(&arg);
573 if( fval > std::numeric_limits<double>::max() ) {
574 ooccoutE((
TObject*)0,Eval) <<
"BayesianCalculator::EvalPosteriorFunctionFromToy : "
575 <<
"Likelihood evaluates to infinity " << std::endl;
578 for (
int i = 0; i < npar; ++i)
579 ooccoutE((
TObject*)0,Eval) << fNuisParams[i].GetName() <<
" = " << p[i] <<
" ";
586 ooccoutE((
TObject*)0,Eval) <<
"BayesianCalculator::EvalPosteriorFunctionFromToy : "
587 <<
"Likelihood is a NaN " << std::endl;
590 for (
int i = 0; i < npar; ++i)
591 ooccoutE((
TObject*)0,Eval) << fNuisParams[i].GetName() <<
" = " << p[i] <<
" ";
605 double dval2 = std::max( sum2/
double(fNumIterations) - val*val, 0.0);
606 fError = std::sqrt( dval2 / fNumIterations);
609 ooccoutD((
TObject*)0,NumIntegration) <<
"PosteriorFunctionFromToyMC: POI value = "
610 <<
x <<
"\tp(x) = " << val <<
" +/- " << fError << std::endl;
613 if (val != 0 && fError/val > 0.2 ) {
614 ooccoutW((
TObject*)0,NumIntegration) <<
"PosteriorFunctionFromToyMC::DoEval"
615 <<
" - Error in estimating posterior is larger than 20% ! "
616 <<
"x = " <<
x <<
" p(x) = " << val <<
" +/- " << fError << std::endl;
624 mutable std::shared_ptr<RooFunctor> fPriorFunc;
625 LikelihoodFunction fLikelihood;
631 mutable double fError;
648 fProductPdf (0), fLogLike(0), fLikelihood (0), fIntegratedLikelihood (0), fPosteriorPdf(0),
649 fPosteriorFunction(0), fApproxPosterior(0),
650 fLower(0), fUpper(0),
652 fSize(0.05), fLeftSideFraction(0.5),
653 fBrfPrecision(0.00005),
656 fValidInterval(false)
674 fPriorPdf(&priorPdf),
676 fProductPdf (0), fLogLike(0), fLikelihood (0), fIntegratedLikelihood (0), fPosteriorPdf(0),
677 fPosteriorFunction(0), fApproxPosterior(0),
678 fLower(0), fUpper(0),
680 fSize(0.05), fLeftSideFraction(0.5),
681 fBrfPrecision(0.00005),
684 fValidInterval(false)
699 fPdf(model.GetPdf()),
700 fPriorPdf( model.GetPriorPdf()),
702 fProductPdf (0), fLogLike(0), fLikelihood (0), fIntegratedLikelihood (0), fPosteriorPdf(0),
703 fPosteriorFunction(0), fApproxPosterior(0),
704 fLower(0), fUpper(0),
706 fSize(0.05), fLeftSideFraction(0.5),
707 fBrfPrecision(0.00005),
710 fValidInterval(false)
789 coutE(InputArguments) <<
"BayesianCalculator::GetPosteriorPdf - missing pdf model" << std::endl;
793 coutE(InputArguments) <<
"BayesianCalculator::GetPosteriorPdf - missing parameter of interest" << std::endl;
797 coutE(InputArguments) <<
"BayesianCalculator::GetPosteriorPdf - current implementation works only on 1D intervals" << std::endl;
813 ccoutD(Eval) <<
"BayesianCalculator::GetPosteriorFunction : "
822 if ( nllVal > std::numeric_limits<double>::max() ) {
823 coutE(Eval) <<
"BayesianCalculator::GetPosteriorFunction : "
824 <<
" Negative log likelihood evaluates to infinity " << std::endl
825 <<
" Non-const Parameter values : ";
827 for (
int i = 0; i < p.
getSize(); ++i) {
831 ccoutE(Eval) << std::endl;
832 ccoutE(Eval) <<
"-- Perform a full likelihood fit of the model before or set more reasonable parameter values"
834 coutE(Eval) <<
"BayesianCalculator::GetPosteriorFunction : " <<
" cannot compute posterior function " << std::endl;
854 coutI(Eval) <<
"BayesianCalculator::GetPosteriorFunction : "
855 <<
" nll value " << nllVal <<
" poi value = " << poi->
getVal() << std::endl;
860 bool ret = minim.
Minimize(100,1.E-3,1.E-3);
864 coutI(Eval) <<
"BayesianCalculator::GetPosteriorFunction : minimum of NLL vs POI for POI = "
869 delete constrainedParams;
874 ccoutD(Eval) <<
"BayesianCalculator::GetPosteriorFunction : use ROOFIT integration "
932 bool doToysEveryIteration =
true;
938 ccoutI(Eval) <<
"BayesianCalculator::GetPosteriorFunction : no nuisance pdf is provided, try using global pdf (this will be slower)"
968 coutW(Eval) <<
"BayesianCalculator::GetPosteriorFunction : " <<
RooAbsReal::numEvalErrors() <<
" errors reported in evaluating log-likelihood function "
986 if (!plike)
return 0;
1032 if (!posterior)
return 0;
1041 if (!plot)
return 0;
1114 coutW(Eval) <<
"BayesianCalculator::GetInterval - recomputing interval for the same CL and same model" << std::endl;
1118 coutE(Eval) <<
"BayesianCalculator::GetInterval - no parameter of interest is set " << std::endl;
1157 coutW(Eval) <<
"BayesianCalculator::GetInterval - computing integral from cdf failed - do a scan in "
1175 coutE(Eval) <<
"BayesianCalculator::GetInterval - cannot compute a valid interval - return a dummy [1,0] interval"
1179 coutI(Eval) <<
"BayesianCalculator::GetInterval - found a valid interval : [" <<
fLower <<
" , "
1180 <<
fUpper <<
" ]" << std::endl;
1185 interval->
SetTitle(
"SimpleInterval from BayesianCalculator");
1210 coutI(Eval) <<
"BayesianCalculator: Compute interval using RooFit: posteriorPdf + createCdf + RooBrentRootFinder " << std::endl;
1223 if (!cdf_bind)
return;
1228 double tmpVal = poi->
getVal();
1231 if (lowerCutOff > 0) {
1232 double y = lowerCutOff;
1238 if (upperCutOff < 1.0) {
1239 double y=upperCutOff;
1244 if (!ret)
coutE(Eval) <<
"BayesianCalculator::GetInterval "
1245 <<
"Error returned from Root finder, estimated interval is not fully correct"
1264 coutI(InputArguments) <<
"BayesianCalculator:GetInterval Compute the interval from the posterior cdf " << std::endl;
1269 coutE(InputArguments) <<
"BayesianCalculator::GetInterval() cannot make posterior Function " << std::endl;
1283 if( cdf.HasError() ) {
1284 coutE(Eval) <<
"BayesianCalculator: Numerical error computing CDF integral - try a different method " << std::endl;
1292 ccoutD(Eval) <<
"BayesianCalculator::GetInterval - finding roots of posterior using RF " << rf.
Name()
1295 if (lowerCutOff > 0) {
1296 cdf.SetOffset(lowerCutOff);
1297 ccoutD(NumIntegration) <<
"Integrating posterior to get cdf and search lower limit at p =" << lowerCutOff << std::endl;
1299 if( cdf.HasError() )
1300 coutW(Eval) <<
"BayesianCalculator: Numerical error integrating the CDF " << std::endl;
1302 coutE(NumIntegration) <<
"BayesianCalculator::GetInterval - Error from root finder when searching lower limit !" << std::endl;
1310 if (upperCutOff < 1.0) {
1311 cdf.SetOffset(upperCutOff);
1312 ccoutD(NumIntegration) <<
"Integrating posterior to get cdf and search upper interval limit at p =" << upperCutOff << std::endl;
1314 if( cdf.HasError() )
1315 coutW(Eval) <<
"BayesianCalculator: Numerical error integrating the CDF " << std::endl;
1317 coutE(NumIntegration) <<
"BayesianCalculator::GetInterval - Error from root finder when searching upper limit !" << std::endl;
1348 if (!posterior)
return;
1356 coutI(Eval) <<
"BayesianCalculator - scan posterior function in nbins = " << tmp->
GetNpx() << std::endl;
1383 ccoutD(Eval) <<
"BayesianCalculator: Compute interval from the approximate posterior " << std::endl;
1389 double limits[2] = {0,0};
1390 prob[0] = lowerCutOff;
1391 prob[1] = upperCutOff;
1403 coutI(Eval) <<
"BayesianCalculator - computing shortest interval with CL = " << 1.-
fSize << std::endl;
1416 std::vector<int> index(
n);
1421 double actualCL = 0;
1426 for (
int i = 0; i <
n; ++i) {
1428 double p = bins[ idx] / norm;
1442 ccoutD(Eval) <<
"BayesianCalculator::ComputeShortestInterval - actual interval CL = "
1443 << actualCL <<
" difference from requested is " << (actualCL-(1.-
fSize))/
fSize*100. <<
"% "
1444 <<
" limits are [ " << lower <<
" , " <<
" upper ] " << std::endl;
1447 if (lower < upper) {
1453 if ( std::abs(actualCL-(1.-
fSize)) > 0.1*(1.-
fSize) )
1454 coutW(Eval) <<
"BayesianCalculator::ComputeShortestInterval - actual interval CL = "
1455 << actualCL <<
" differs more than 10% from desired CL value - must increase nbins "
1456 <<
n <<
" to an higher value " << std::endl;
1459 coutE(Eval) <<
"BayesianCalculator::ComputeShortestInterval " <<
n <<
" bins are not sufficient " << std::endl;
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
Binding & operator=(OUT(*fun)(void))
User class for performing function minimization.
virtual bool Minimize(int maxIter, double absTol=1.E-8, double relTol=1.E-10)
Find minimum position iterating until convergence specified by the absolute and relative tolerance or...
void SetFunction(const ROOT::Math::IGenFunction &f, double xlow, double xup)
Sets function to be minimized.
virtual double FValMinimum() const
Return function value at current estimate of the minimum.
Functor1D class for one-dimensional functions.
Interface (abstract class) for generic functions objects of one-dimension Provides a method to evalua...
Numerical multi dimensional integration options.
void Print(std::ostream &os=std::cout) const
print all the options
void SetNCalls(unsigned int calls)
set maximum number of function calls
User class for performing multidimensional integration.
static IntegrationMultiDim::Type GetType(const char *name)
static function to get the enumeration from a string
User Class for performing numerical integration of a function in one dimension.
static IntegrationOneDim::Type GetType(const char *name)
static function to get the enumeration from a string
User Class to find the Root of one dimensional functions.
const char * Name() const
Return the current and latest estimate of the lower value of the Root-finding interval (for bracketin...
bool Solve(Function &f, Derivative &d, double start, int maxIter=100, double absTol=1E-8, double relTol=1E-10)
double Root() const
Return the current and latest estimate of the Root.
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
RooArgSet * getParameters(const RooAbsData *data, bool stripDisconnected=true) const
Create a list of leaf nodes in the arg tree starting with ourself as top node that don't match any of...
virtual void removeAll()
Remove all arguments from our set, deleting them if we own them.
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Add the specified argument to list.
RooAbsArg * first() const
const char * GetName() const
Returns name of object.
RooAbsArg * find(const char *name) const
Find object with given name in list.
RooAbsData is the common abstract base class for binned and unbinned datasets.
Abstract interface for evaluating a real-valued function of one real variable and performing numerica...
virtual RooAbsReal * createNLL(RooAbsData &data, const RooLinkedList &cmdList)
Construct representation of -log(L) of PDFwith given dataset.
RooAbsReal * createCdf(const RooArgSet &iset, const RooArgSet &nset=RooArgSet())
Create a cumulative distribution function of this p.d.f in terms of the observables listed in iset.
RooAbsRealLValue is the common abstract base class for objects that represent a real value that may a...
virtual Double_t getMax(const char *name=0) const
Get maximum of currently defined range.
RooPlot * frame(const RooCmdArg &arg1, const RooCmdArg &arg2=RooCmdArg::none(), const RooCmdArg &arg3=RooCmdArg::none(), const RooCmdArg &arg4=RooCmdArg::none(), const RooCmdArg &arg5=RooCmdArg::none(), const RooCmdArg &arg6=RooCmdArg::none(), const RooCmdArg &arg7=RooCmdArg::none(), const RooCmdArg &arg8=RooCmdArg::none()) const
Create a new RooPlot on the heap with a drawing frame initialized for this object,...
virtual Double_t getMin(const char *name=0) const
Get miniminum of currently defined range.
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
virtual RooPlot * plotOn(RooPlot *frame, const RooCmdArg &arg1=RooCmdArg(), const RooCmdArg &arg2=RooCmdArg(), const RooCmdArg &arg3=RooCmdArg(), const RooCmdArg &arg4=RooCmdArg(), const RooCmdArg &arg5=RooCmdArg(), const RooCmdArg &arg6=RooCmdArg(), const RooCmdArg &arg7=RooCmdArg(), const RooCmdArg &arg8=RooCmdArg(), const RooCmdArg &arg9=RooCmdArg(), const RooCmdArg &arg10=RooCmdArg()) const
Plot (project) PDF on specified frame.
TF1 * asTF(const RooArgList &obs, const RooArgList &pars=RooArgList(), const RooArgSet &nset=RooArgSet()) const
Return a ROOT TF1,2,3 object bound to this RooAbsReal with given definition of observables and parame...
Double_t getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
RooAbsReal * createIntegral(const RooArgSet &iset, const RooCmdArg &arg1, const RooCmdArg &arg2=RooCmdArg::none(), const RooCmdArg &arg3=RooCmdArg::none(), const RooCmdArg &arg4=RooCmdArg::none(), const RooCmdArg &arg5=RooCmdArg::none(), const RooCmdArg &arg6=RooCmdArg::none(), const RooCmdArg &arg7=RooCmdArg::none(), const RooCmdArg &arg8=RooCmdArg::none()) const
Create an object that represents the integral of the function over one or more observables listed in ...
RooAbsFunc * bindVars(const RooArgSet &vars, const RooArgSet *nset=0, Bool_t clipInvalid=kFALSE) const
Create an interface adaptor f(vars) that binds us to the specified variables (in arbitrary order).
static Int_t numEvalErrors()
Return the number of logged evaluation errors since the last clearing.
static void setEvalErrorLoggingMode(ErrorLoggingMode m)
Set evaluation error logging mode.
static void clearEvalErrorLog()
Clear the stack of evaluation error messages.
RooFunctor * functor(const RooArgList &obs, const RooArgList &pars=RooArgList(), const RooArgSet &nset=RooArgSet()) const
Return a RooFunctor object bound to this RooAbsReal with given definition of observables and paramete...
RooArgList is a container object that can hold multiple RooAbsArg objects.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE) override
Add element to non-owning set.
Implement the abstract 1-dimensional root finding interface using the Brent-Decker method.
virtual Bool_t findRoot(Double_t &result, Double_t xlo, Double_t xhi, Double_t value=0) const
Do the root finding using the Brent-Decker method.
void setTol(Double_t tol)
RooDataSet is a container class to hold unbinned data.
RooCFunction1Binding is a templated implementation of class RooAbsReal that binds generic C(++) funct...
Lightweight interface adaptor that exports a RooAbsPdf as a functor.
RooGenericPdf is a concrete implementation of a probability density function, which takes a RooArgLis...
A RooPlot is a plot frame and a container for graphics objects within that frame.
void SetTitle(const char *name)
Set the title of the RooPlot to 'title'.
RooProdPdf is an efficient implementation of a product of PDFs of the form.
RooRealVar represents a variable that can be changed from the outside.
virtual void setVal(Double_t value)
Set value of variable to 'value'.
BayesianCalculator is a concrete implementation of IntervalCalculator, providing the computation of a...
ROOT::Math::IGenFunction * fPosteriorFunction
RooAbsPdf * GetPosteriorPdf() const
Build and return the posterior pdf (i.e posterior function normalized to all range of poi) Note that ...
virtual SimpleInterval * GetInterval() const
Compute the interval.
RooPlot * GetPosteriorPlot(bool norm=false, double precision=0.01) const
return a RooPlot with the posterior and the credibility region NOTE: User takes ownership of the retu...
void ClearAll() const
clear all cached pdf objects
virtual Double_t ConfidenceLevel() const
Get the Confidence level for the test.
void ComputeShortestInterval() const
compute the shortest interval from the histogram representing the posterior
RooArgSet fConditionalObs
RooAbsReal * fIntegratedLikelihood
virtual ~BayesianCalculator()
void ApproximatePosterior() const
approximate posterior in nbins using a TF1 scan the poi values and evaluate the posterior at each poi...
RooArgSet fNuisanceParameters
virtual void SetModel(const ModelConfig &model)
set the model to use The model pdf, prior pdf, parameter of interest and nuisances will be taken acco...
double GetMode() const
Returns the value of the parameter for the point in parameter-space that is the most likely.
RooAbsReal * GetPosteriorFunction() const
Build and return the posterior function (not normalized) as a RooAbsReal the posterior is obtained fr...
void SetIntegrationType(const char *type)
set the integration type (possible type are) :
RooAbsPdf * fPosteriorPdf
TH1 * GetPosteriorHistogram() const
When am approximate posterior is computed binninig the parameter of interest (poi) range (see SetScan...
void ComputeIntervalFromApproxPosterior(double c1, double c2) const
compute the interval using the approximate posterior function
BayesianCalculator()
default constructor
void ComputeIntervalUsingRooFit(double c1, double c2) const
internal function compute the interval using RooFit
void ComputeIntervalFromCdf(double c1, double c2) const
internal function compute the interval using Cdf integration
ModelConfig is a simple class that holds configuration information specifying how a model should be u...
const RooArgSet * GetConditionalObservables() const
get RooArgSet for conditional observables (return NULL if not existing)
const RooArgSet * GetGlobalObservables() const
get RooArgSet for global observables (return NULL if not existing)
const RooArgSet * GetParametersOfInterest() const
get RooArgSet containing the parameter of interest (return NULL if not existing)
const RooArgSet * GetNuisanceParameters() const
get RooArgSet containing the nuisance parameters (return NULL if not existing)
RooAbsPdf * GetPdf() const
get model PDF (return NULL if pdf has not been specified or does not exist)
RooAbsPdf * GetPriorPdf() const
get parameters prior pdf (return NULL if not existing)
SimpleInterval is a concrete implementation of the ConfInterval interface.
Use TF1, TF2, TF3 functions as RooFit objects.
const Float_t * GetArray() const
virtual Double_t GetBinUpEdge(Int_t bin) const
Return up edge of bin.
virtual TH1 * GetHistogram() const
Return a pointer to the histogram used to visualise the function Note that this histogram is managed ...
virtual void SetNpx(Int_t npx=100)
Set the number of points used to draw the function.
virtual Int_t GetQuantiles(Int_t nprobSum, Double_t *q, const Double_t *probSum)
Compute Quantiles for density distribution of this function.
TObject * Clone(const char *newname=0) const
Make a complete copy of the underlying object.
virtual Int_t GetNpx() const
1-D histogram with a double per channel (see TH1 documentation)}
TH1 is the base class of all histogram classes in ROOT.
virtual Double_t GetBinCenter(Int_t bin) const
Return bin center for 1D histogram.
TAxis * GetXaxis()
Get the behaviour adopted by the object about the statoverflows. See EStatOverflows for more informat...
virtual Double_t GetBinLowEdge(Int_t bin) const
Return bin lower edge for 1D histogram.
virtual void SetName(const char *name)
Change the name of this histogram.
virtual Double_t GetSumOfWeights() const
Return the sum of weights excluding under/overflows.
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
virtual const char * GetTitle() const
Returns title of object.
virtual const char * GetName() const
Returns name of object.
Mother of all ROOT objects.
void ToUpper()
Change string to upper case.
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
RooCmdArg Constrain(const RooArgSet ¶ms)
RooCmdArg GlobalObservables(const RooArgSet &globs)
RooCmdArg ConditionalObservables(const RooArgSet &set)
RooCmdArg DrawOption(const char *opt)
RooCmdArg FillColor(Color_t color)
RooCmdArg Precision(Double_t prec)
RooCmdArg Range(const char *rangeName, Bool_t adjustNorm=kTRUE)
Namespace for new Math classes and functions.
IBaseFunctionOneDim IGenFunction
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
Type GetType(const std::string &Name)
Namespace for the RooStats classes.
void RemoveConstantParameters(RooArgSet *set)
const ROOT::Math::RootFinder::EType kRootFinderType
void Sort(Index n, const Element *a, Index *index, Bool_t down=kTRUE)
static uint64_t sum(uint64_t i)