CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
ProfiledLikelihoodRatioTestStatOpt Class Reference

#include <ProfiledLikelihoodRatioTestStatExt.h>

Inheritance diagram for ProfiledLikelihoodRatioTestStatOpt:

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_.

46 :
47  pdfNull_(&pdfNull), pdfAlt_(&pdfAlt),
48  paramsNull_(pdfNull_->getVariables()),
49  paramsAlt_(pdfAlt_->getVariables()),
51 {
52  snapNull_.addClone(paramsNull);
53  snapAlt_.addClone(paramsAlt);
54  DBG(DBG_TestStat_params, (std::cout << "Null snapshot" << pdfNull_->GetName())) DBG(DBG_TestStat_params, (snapNull_.Print("V")))
55  DBG(DBG_TestStat_params, (std::cout << "Alt snapshot" << pdfAlt_->GetName())) DBG(DBG_TestStat_params, (snapAlt_.Print("V")))
56  if (nuisances) nuisances_.addClone(*nuisances);
57 }
perl if(1 lt scalar(@::datatypes))
Definition: edlooper.cc:31
#define DBG(X, Z)
tuple cout
Definition: gather_cfg.py:121

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().

86 {
87  if (typeid(pdf) == typeid(RooSimultaneousOpt)) {
88  if (nll_.get() == 0) nll_.reset(pdf.createNLL(data, RooFit::Constrain(nuisances_)));
89  else ((cacheutils::CachingSimNLL&)(*nll_)).setData(data);
90  return true;
91  } else {
92  nll_.reset(pdf.createNLL(data, RooFit::Constrain(nuisances_)));
93  return false;
94  }
95 }
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
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_.

60 {
63  *paramsNull_ = nullPOI;
64 
65  DBGV(DBG_TestStat_params, (std::cout << "Parameters of null pdf (pre fit)" << pdfNull_->GetName()))
66  DBGV(DBG_TestStat_params, (paramsNull_->Print("V")))
67 
68  bool canKeepNullNLL = createNLL(*pdfNull_, data, nllNull_);
69  double nullNLL = minNLL(nllNull_);
70  if (!canKeepNullNLL) nllNull_.reset();
71 
74 
75  DBGV(DBG_TestStat_params, (std::cout << "Parameters of alt pdf " << pdfAlt_->GetName()))
76  DBGV(DBG_TestStat_params, (paramsAlt_->Print("V")))
77  bool canKeepAltNLL = createNLL(*pdfAlt_, data, nllAlt_);
78  double altNLL = minNLL(nllAlt_);
79  if (!canKeepAltNLL) nllAlt_.reset();
80 
81  DBG(DBG_TestStat_params, (printf("Pln: null = %+8.4f, alt = %+8.4f\n", nullNLL, altNLL)))
82  return nullNLL-altNLL;
83 }
vector< ParameterSet > Parameters
double f[11][100]
double minNLL(std::auto_ptr< RooAbsReal > &nll)
#define DBGV(X, Z)
bool createNLL(RooAbsPdf &pdf, RooAbsData &data, std::auto_ptr< RooAbsReal > &nll)
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
#define DBG(X, Z)
perl if(1 lt scalar(@::datatypes))
Definition: edlooper.cc:31
tuple cout
Definition: gather_cfg.py:121
void reset(double vett[256])
Definition: TPedValues.cc:11
virtual const TString ProfiledLikelihoodRatioTestStatOpt::GetVarName ( ) const
inlinevirtual

Definition at line 27 of file ProfiledLikelihoodRatioTestStatExt.h.

References pdfAlt_, and pdfNull_.

27  {
28  return TString::Format("-log(%s/%s)", pdfNull_->GetName(), pdfAlt_->GetName());
29  }
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().

99 {
100 #if defined(DBG_TestStat_NOFIT) && (DBG_TestStat_NOFIT > 0)
101  if (verbosity_ > 0) std::cout << "Profiling likelihood for pdf " << pdf.GetName() << std::endl;
102  std::auto_ptr<RooAbsReal> nll_(pdf.createNLL(data, RooFit::Constrain(nuisances_)));
103  return nll_->getVal();
104 #endif
105  RooMinimizer minim(*nll_);
106  minim.setStrategy(0);
107  minim.setPrintLevel(verbosity_-2);
108  minim.minimize(ROOT::Math::MinimizerOptions::DefaultMinimizerType().c_str(), ROOT::Math::MinimizerOptions::DefaultMinimizerAlgo().c_str());
109  if (verbosity_ > 1) {
110  std::auto_ptr<RooFitResult> res(minim.save());
111  res->Print("V");
112  }
113  return nll_->getVal();
114 }
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
tuple cout
Definition: gather_cfg.py:121
void ProfiledLikelihoodRatioTestStatOpt::setPrintLevel ( Int_t  level)
inline

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().

RooArgSet ProfiledLikelihoodRatioTestStatOpt::nuisances_
private
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().

RooAbsPdf * ProfiledLikelihoodRatioTestStatOpt::pdfAlt_
private
RooAbsPdf* ProfiledLikelihoodRatioTestStatOpt::pdfNull_
private
RooArgSet ProfiledLikelihoodRatioTestStatOpt::snapAlt_
private
RooArgSet ProfiledLikelihoodRatioTestStatOpt::snapNull_
private
Int_t ProfiledLikelihoodRatioTestStatOpt::verbosity_
private

Definition at line 40 of file ProfiledLikelihoodRatioTestStatExt.h.

Referenced by minNLL(), and setPrintLevel().