Go to the documentation of this file.00001 #ifndef HiggsAnalysis_CombinedLimit_SimplerLikelihoodRatioTestStat_h
00002 #define HiggsAnalysis_CombinedLimit_SimplerLikelihoodRatioTestStat_h
00003 #include <memory>
00004 #include <stdexcept>
00005
00006 #include <RooAbsPdf.h>
00007 #include <RooAbsData.h>
00008 #include <RooArgSet.h>
00009 #include <RooStats/TestStatistic.h>
00010
00011 class SimplerLikelihoodRatioTestStat : public RooStats::TestStatistic {
00012 public:
00013 SimplerLikelihoodRatioTestStat(RooAbsPdf &pdfNull, RooAbsPdf &pdfAlt, const RooArgSet & paramsNull = RooArgSet(), const RooArgSet & paramsAlt = RooArgSet()) :
00014 pdfNull_(&pdfNull), pdfAlt_(&pdfAlt),
00015 paramsNull_(pdfNull_->getVariables()),
00016 paramsAlt_(pdfAlt_->getVariables())
00017 {
00018 snapNull_.addClone(paramsNull);
00019 snapAlt_.addClone(paramsAlt);
00020 }
00021
00022 virtual Double_t Evaluate(RooAbsData& data, RooArgSet& nullPOI)
00023 {
00024 if (data.numEntries() != 1) throw std::invalid_argument("HybridNew::TestSimpleStatistics: dataset doesn't have exactly 1 entry.");
00025 const RooArgSet *entry = data.get(0);
00026 *paramsNull_ = *entry;
00027 *paramsNull_ = snapNull_;
00028 *paramsNull_ = nullPOI;
00029 double nullNLL = pdfNull_->getVal();
00030
00031 *paramsAlt_ = *entry;
00032 *paramsAlt_ = snapAlt_;
00033 double altNLL = pdfAlt_->getVal();
00034
00035 return -log(nullNLL/altNLL);
00036 }
00037
00038 virtual const TString GetVarName() const {
00039 return TString::Format("-log(%s/%s)", pdfNull_->GetName(), pdfAlt_->GetName());
00040 }
00041
00042 private:
00043 RooAbsPdf *pdfNull_, *pdfAlt_;
00044 RooArgSet snapNull_, snapAlt_;
00045 std::auto_ptr<RooArgSet> paramsNull_, paramsAlt_;
00046 };
00047
00048 #endif