// RooJeffreysPrior
// END_HTML
#include "RooFit.h"
#include "Riostream.h"
#include "Riostream.h"
#include <math.h>
#include "RooJeffreysPrior.h"
#include "RooAbsReal.h"
#include "RooAbsPdf.h"
#include "RooErrorHandler.h"
#include "RooArgSet.h"
#include "RooMsgService.h"
#include "RooFitResult.h"
#include "TMatrixDSym.h"
#include "RooDataHist.h"
#include "RooFitResult.h"
#include "RooNumIntConfig.h"
#include "RooRealVar.h"
ClassImp(RooJeffreysPrior)
;
using namespace RooFit;
RooJeffreysPrior::RooJeffreysPrior(const char* name, const char* title,
RooAbsPdf& nominal,
const RooArgList& paramSet,
const RooArgList& obsSet) :
RooAbsPdf(name, title),
_nominal("nominal","nominal",this,nominal,kFALSE,kFALSE),
_obsSet("!obsSet","obs-side variation",this,kFALSE,kFALSE),
_paramSet("!paramSet","high-side variation",this)
{
_obsIter = _obsSet.createIterator() ;
_paramIter = _paramSet.createIterator() ;
TIterator* inputIter1 = obsSet.createIterator() ;
RooAbsArg* comp ;
while((comp = (RooAbsArg*)inputIter1->Next())) {
if (!dynamic_cast<RooAbsReal*>(comp)) {
coutE(InputArguments) << "RooJeffreysPrior::ctor(" << GetName() << ") ERROR: component " << comp->GetName()
<< " in first list is not of type RooAbsReal" << endl ;
RooErrorHandler::softAbort() ;
}
_obsSet.add(*comp) ;
}
delete inputIter1 ;
TIterator* inputIter3 = paramSet.createIterator() ;
while((comp = (RooAbsArg*)inputIter3->Next())) {
if (!dynamic_cast<RooAbsReal*>(comp)) {
coutE(InputArguments) << "RooJeffreysPrior::ctor(" << GetName() << ") ERROR: component " << comp->GetName()
<< " in first list is not of type RooAbsReal" << endl ;
RooErrorHandler::softAbort() ;
}
_paramSet.add(*comp) ;
}
delete inputIter3 ;
if(paramSet.getSize()==1)
this->specialIntegratorConfig(kTRUE)->method1D().setLabel("RooAdaptiveGaussKronrodIntegrator1D") ;
}
RooJeffreysPrior::RooJeffreysPrior(const RooJeffreysPrior& other, const char* name) :
RooAbsPdf(other, name),
_nominal("!nominal",this,other._nominal),
_obsSet("!obsSet",this,other._obsSet),
_paramSet("!paramSet",this,other._paramSet)
{
_obsIter = _obsSet.createIterator() ;
_paramIter = _paramSet.createIterator() ;
}
RooJeffreysPrior::RooJeffreysPrior()
{
_obsIter = NULL;
_paramIter = NULL;
}
RooJeffreysPrior::~RooJeffreysPrior()
{
if (_obsIter) delete _obsIter ;
if (_paramIter) delete _paramIter ;
}
Double_t RooJeffreysPrior::evaluate() const
{
RooFit::MsgLevel msglevel = RooMsgService::instance().globalKillBelow();
RooMsgService::instance().setGlobalKillBelow(RooFit::WARNING);
*(_nominal.arg().getVariables()) = _paramSet;
RooDataHist* data = ((RooAbsPdf&)(_nominal.arg())).generateBinned(_obsSet,ExpectedData());
RooFitResult* res = ((RooAbsPdf&)(_nominal.arg())).fitTo(*data, Save(),PrintLevel(-1),Minos(kFALSE),SumW2Error(kFALSE));
TMatrixDSym cov = res->covarianceMatrix();
cov.Invert();
double ret = sqrt(cov.Determinant());
delete data;
delete res;
RooMsgService::instance().setGlobalKillBelow(msglevel);
return ret;
}
Int_t RooJeffreysPrior::getAnalyticalIntegral(RooArgSet& , RooArgSet& , const char* ) const
{
return 0 ;
}
Double_t RooJeffreysPrior::analyticalIntegral(Int_t code, const char* ) const
{
assert(code==1 );
return 1.;
}