CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

ProfiledLikelihoodRatioTestStatOpt Class Reference

#include <ProfiledLikelihoodRatioTestStatExt.h>

List of all members.

Public Member Functions

virtual Double_t Evaluate (RooAbsData &data, RooArgSet &nullPOI)
virtual const TString GetVarName () const
 ProfiledLikelihoodRatioTestStatOpt (const RooArgSet &obs, RooAbsPdf &pdfNull, RooAbsPdf &pdfAlt, const RooArgSet *nuisances, const RooArgSet &paramsNull=RooArgSet(), const RooArgSet &paramsAlt=RooArgSet(), int verbosity=0)
void setPrintLevel (Int_t level)

Private Member Functions

bool createNLL (RooAbsPdf &pdf, RooAbsData &data, std::auto_ptr< RooAbsReal > &nll)
double minNLL (std::auto_ptr< RooAbsReal > &nll)

Private Attributes

std::auto_ptr< RooAbsReal > nllAlt_
std::auto_ptr< RooAbsReal > nllNull_
RooArgSet nuisances_
std::auto_ptr< RooArgSet > paramsAlt_
std::auto_ptr< RooArgSet > paramsNull_
RooAbsPdf * pdfAlt_
RooAbsPdf * pdfNull_
RooArgSet snapAlt_
RooArgSet snapNull_
Int_t verbosity_

Detailed Description

Definition at line 19 of file ProfiledLikelihoodRatioTestStatExt.h.


Constructor & Destructor Documentation

ProfiledLikelihoodRatioTestStatOpt::ProfiledLikelihoodRatioTestStatOpt ( const RooArgSet &  obs,
RooAbsPdf &  pdfNull,
RooAbsPdf &  pdfAlt,
const RooArgSet *  nuisances,
const RooArgSet &  paramsNull = RooArgSet(),
const RooArgSet &  paramsAlt = RooArgSet(),
int  verbosity = 0 
)

Definition at line 40 of file ProfiledLikelihoodRatioTestStatExt.cc.

References gather_cfg::cout, DBG, nuisances_, pdfAlt_, pdfNull_, snapAlt_, and snapNull_.

: 
    pdfNull_(&pdfNull), pdfAlt_(&pdfAlt),
    paramsNull_(pdfNull_->getVariables()), 
    paramsAlt_(pdfAlt_->getVariables()), 
    verbosity_(verbosity)
{
    snapNull_.addClone(paramsNull);
    snapAlt_.addClone(paramsAlt);
    DBG(DBG_TestStat_params, (std::cout << "Null snapshot" << pdfNull_->GetName())) DBG(DBG_TestStat_params, (snapNull_.Print("V")))
    DBG(DBG_TestStat_params, (std::cout << "Alt  snapshot" << pdfAlt_->GetName()))  DBG(DBG_TestStat_params, (snapAlt_.Print("V")))
    if (nuisances) nuisances_.addClone(*nuisances);
}

Member Function Documentation

bool ProfiledLikelihoodRatioTestStatOpt::createNLL ( RooAbsPdf &  pdf,
RooAbsData &  data,
std::auto_ptr< RooAbsReal > &  nll 
) [private]

Definition at line 85 of file ProfiledLikelihoodRatioTestStatExt.cc.

References nuisances_.

Referenced by Evaluate().

{
    if (typeid(pdf) == typeid(RooSimultaneousOpt)) {
        if (nll_.get() == 0) nll_.reset(pdf.createNLL(data, RooFit::Constrain(nuisances_)));
        else ((cacheutils::CachingSimNLL&)(*nll_)).setData(data);
        return true;
    } else {
        nll_.reset(pdf.createNLL(data, RooFit::Constrain(nuisances_)));
        return false;
    }
}
Double_t ProfiledLikelihoodRatioTestStatOpt::Evaluate ( RooAbsData &  data,
RooArgSet &  nullPOI 
) [virtual]

Definition at line 59 of file ProfiledLikelihoodRatioTestStatExt.cc.

References gather_cfg::cout, createNLL(), DBG, DBGV, minNLL(), nllAlt_, nllNull_, nuisances_, paramsAlt_, paramsNull_, pdfAlt_, pdfNull_, snapAlt_, and snapNull_.

{
    *paramsNull_ = nuisances_;
    *paramsNull_ = snapNull_;
    *paramsNull_ = nullPOI;
        
    DBGV(DBG_TestStat_params, (std::cout << "Parameters of null pdf (pre fit)" << pdfNull_->GetName()))
    DBGV(DBG_TestStat_params, (paramsNull_->Print("V")))

    bool canKeepNullNLL = createNLL(*pdfNull_, data, nllNull_);
    double nullNLL = minNLL(nllNull_);
    if (!canKeepNullNLL) nllNull_.reset();
    
    *paramsAlt_ = nuisances_;
    *paramsAlt_ = snapAlt_;
        
    DBGV(DBG_TestStat_params, (std::cout << "Parameters of alt pdf " << pdfAlt_->GetName()))
    DBGV(DBG_TestStat_params, (paramsAlt_->Print("V")))
    bool canKeepAltNLL = createNLL(*pdfAlt_, data, nllAlt_);
    double altNLL = minNLL(nllAlt_);
    if (!canKeepAltNLL) nllAlt_.reset();
    
    DBG(DBG_TestStat_params, (printf("Pln: null = %+8.4f, alt = %+8.4f\n", nullNLL, altNLL)))
    return nullNLL-altNLL;
}
virtual const TString ProfiledLikelihoodRatioTestStatOpt::GetVarName ( ) const [inline, virtual]

Definition at line 27 of file ProfiledLikelihoodRatioTestStatExt.h.

References pdfAlt_, and pdfNull_.

                                                 {
            return TString::Format("-log(%s/%s)", pdfNull_->GetName(), pdfAlt_->GetName()); 
        }
double ProfiledLikelihoodRatioTestStatOpt::minNLL ( std::auto_ptr< RooAbsReal > &  nll) [private]

Definition at line 98 of file ProfiledLikelihoodRatioTestStatExt.cc.

References gather_cfg::cout, data, nuisances_, and verbosity_.

Referenced by Evaluate().

{
#if defined(DBG_TestStat_NOFIT) && (DBG_TestStat_NOFIT > 0)
    if (verbosity_ > 0) std::cout << "Profiling likelihood for pdf " << pdf.GetName() << std::endl;
    std::auto_ptr<RooAbsReal> nll_(pdf.createNLL(data, RooFit::Constrain(nuisances_)));
    return nll_->getVal();
#endif
    RooMinimizer minim(*nll_);
    minim.setStrategy(0);
    minim.setPrintLevel(verbosity_-2);
    minim.minimize(ROOT::Math::MinimizerOptions::DefaultMinimizerType().c_str(), ROOT::Math::MinimizerOptions::DefaultMinimizerAlgo().c_str());
    if (verbosity_ > 1) {
        std::auto_ptr<RooFitResult> res(minim.save());
        res->Print("V");
    }
    return nll_->getVal();
}
void ProfiledLikelihoodRatioTestStatOpt::setPrintLevel ( Int_t  level) [inline]

Definition at line 32 of file ProfiledLikelihoodRatioTestStatExt.h.

References testEve_cfg::level, and verbosity_.


Member Data Documentation

std::auto_ptr<RooAbsReal> ProfiledLikelihoodRatioTestStatOpt::nllAlt_ [private]

Definition at line 39 of file ProfiledLikelihoodRatioTestStatExt.h.

Referenced by Evaluate().

std::auto_ptr<RooAbsReal> ProfiledLikelihoodRatioTestStatOpt::nllNull_ [private]

Definition at line 39 of file ProfiledLikelihoodRatioTestStatExt.h.

Referenced by Evaluate().

std::auto_ptr<RooArgSet> ProfiledLikelihoodRatioTestStatOpt::paramsAlt_ [private]

Definition at line 38 of file ProfiledLikelihoodRatioTestStatExt.h.

Referenced by Evaluate().

std::auto_ptr<RooArgSet> ProfiledLikelihoodRatioTestStatOpt::paramsNull_ [private]

Definition at line 38 of file ProfiledLikelihoodRatioTestStatExt.h.

Referenced by Evaluate().

Definition at line 40 of file ProfiledLikelihoodRatioTestStatExt.h.

Referenced by minNLL(), and setPrintLevel().