30 ClassImp(RooJeffreysPrior);
32 using namespace RooFit;
42 RooJeffreysPrior::RooJeffreysPrior(
const char* name,
const char* title,
44 const RooArgList& paramSet,
45 const RooArgList& obsSet) :
46 RooAbsPdf(name, title),
47 _nominal(
"nominal",
"nominal",this, nominal, false, false),
48 _obsSet(
"!obsSet",
"Observables",this, false, false),
49 _paramSet(
"!paramSet",
"Parameters",this),
50 _cacheMgr(this, 1, true, false)
52 for (
const auto comp : obsSet) {
53 if (!dynamic_cast<RooAbsReal*>(comp)) {
54 coutE(InputArguments) <<
"RooJeffreysPrior::ctor(" << GetName() <<
") ERROR: component " << comp->GetName()
55 <<
" in observable list is not of type RooAbsReal" << endl ;
56 RooErrorHandler::softAbort() ;
61 for (
const auto comp : paramSet) {
62 if (!dynamic_cast<RooAbsReal*>(comp)) {
63 coutE(InputArguments) <<
"RooJeffreysPrior::ctor(" << GetName() <<
") ERROR: component " << comp->GetName()
64 <<
" in parameter list is not of type RooAbsReal" << endl ;
65 RooErrorHandler::softAbort() ;
67 _paramSet.add(*comp) ;
71 if(paramSet.getSize()==1)
72 this->specialIntegratorConfig(kTRUE)->method1D().setLabel(
"RooAdaptiveGaussKronrodIntegrator1D") ;
78 RooJeffreysPrior::RooJeffreysPrior(
const RooJeffreysPrior& other,
const char* name) :
79 RooAbsPdf(other, name),
80 _nominal(
"!nominal",this,other._nominal),
81 _obsSet(
"!obsSet",this,other._obsSet),
82 _paramSet(
"!paramSet",this,other._paramSet),
83 _cacheMgr(this, 1, true, false)
91 RooJeffreysPrior::~RooJeffreysPrior()
99 Double_t RooJeffreysPrior::evaluate()
const
101 RooHelpers::LocalChangeMsgLevel msgLvlRAII(RooFit::WARNING);
104 CacheElem* cacheElm = (CacheElem*) _cacheMgr.getObj(
nullptr);
110 auto& pdf = _nominal.arg();
111 RooAbsPdf* clonePdf =
static_cast<RooAbsPdf*
>(pdf.cloneTree());
112 auto vars = clonePdf->getParameters(_obsSet);
113 for (
auto varTmp : *vars) {
114 auto& var =
static_cast<RooRealVar&
>(*varTmp);
115 auto range = var.getRange();
116 double span = range.second - range.first;
117 var.setRange(range.first - 0.1*span, range.second + 0.1 * span);
120 cacheElm =
new CacheElem;
121 cacheElm->_pdf.reset(clonePdf);
122 cacheElm->_pdfVariables.reset(vars);
124 _cacheMgr.setObj(
nullptr, cacheElm);
127 auto& cachedPdf = *cacheElm->_pdf;
128 auto& pdfVars = *cacheElm->_pdfVariables;
131 std::unique_ptr<RooDataHist> data( cachedPdf.generateBinned(_obsSet,ExpectedData()) );
132 std::unique_ptr<RooFitResult> res( cachedPdf.fitTo(*data, Save(),PrintLevel(-1),Minos(
false),SumW2Error(
false)) );
133 TMatrixDSym cov = res->covarianceMatrix();
136 return sqrt(cov.Determinant());