diff --git a/roofit/roostats/src/BayesianCalculator.cxx b/roofit/roostats/src/BayesianCalculator.cxx index 9aa06507d688688795ddd2de95c8dedc83de459d..818a751801718deb69148a716329994b4e4397a1 100644 --- a/roofit/roostats/src/BayesianCalculator.cxx +++ b/roofit/roostats/src/BayesianCalculator.cxx @@ -27,6 +27,7 @@ // include header file of this class #include "RooStats/BayesianCalculator.h" #include "RooStats/ModelConfig.h" +#include "RooStats/RooStatsUtils.h" #include "Math/IFunction.h" #include "Math/IntegratorMultiDim.h" @@ -249,7 +250,8 @@ private: } if (f != 0 && error/f > 0.2 ) - ooccoutW((TObject*)0,NumIntegration) << "PosteriorFunction::DoEval - Error from integration is larger than 20 % " + ooccoutW((TObject*)0,NumIntegration) << "PosteriorFunction::DoEval - Error from integration in " + << fXmin.size() << " Dim is larger than 20 % " << "x = " << x << " p(x) = " << f << " +/- " << error << std::endl; return f / fNorm; @@ -402,6 +404,9 @@ RooAbsReal* BayesianCalculator::GetPosteriorFunction() const fProductPdf = new RooProdPdf(prodName,"",RooArgList(*fPdf,*fPriorPOI)); RooArgSet* constrainedParams = fProductPdf->getParameters(*fData); + // remove the constant parameters + RemoveConstantParameters(constrainedParams); + // use RooFit::Constrain() to make product of likelihood with prior pdf fLogLike = fProductPdf->createNLL(*fData, RooFit::Constrain(*constrainedParams) ); @@ -463,6 +468,10 @@ RooPlot* BayesianCalculator::GetPosteriorPlot(bool norm, double precision ) cons /// return a RooPlot with the posterior and the credibility region if (!fLikelihood) GetPosteriorFunction(); + + // if a scan is requested approximate the posterior + if (fNScanBins > 0) ApproximatePosterior(); + RooAbsReal * posterior = fIntegratedLikelihood; if (norm) posterior = fPosteriorPdf; if (!posterior) { @@ -480,6 +489,7 @@ RooPlot* BayesianCalculator::GetPosteriorPlot(bool norm, double precision ) cons RooAbsRealLValue* poi = dynamic_cast<RooAbsRealLValue*>( fPOI.first() ); assert(poi); + RooPlot* plot = poi->frame(); // try to reduce some error messages @@ -696,6 +706,9 @@ void BayesianCalculator::ApproximatePosterior() const { RooAbsReal * posterior = GetPosteriorFunction(); + // try to reduce some error messages + posterior->setEvalErrorLoggingMode(RooAbsReal::CountErrors); + TF1 * tmp = posterior->asTF(fPOI); assert(tmp != 0); // binned the function in nbins and evaluate at thos points