CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_14/src/HiggsAnalysis/CombinedLimit/interface/ProfiledLikelihoodRatioTestStatExt.h

Go to the documentation of this file.
00001 #ifndef HiggsAnalysis_CombinedLimit_ProfiledLikelihoodRatioTestStatExt_h
00002 #define HiggsAnalysis_CombinedLimit_ProfiledLikelihoodRatioTestStatExt_h
00003 
00004 #include <memory>
00005 #include <vector>
00006 
00007 class RooMinimizerOpt;
00008 #include <RooAbsPdf.h>
00009 #include <RooAbsData.h>
00010 #include <RooArgSet.h>
00011 #include <RooStats/TestStatistic.h>
00012 #include "../interface/RooSimultaneousOpt.h"
00013 #include "../interface/CachingNLL.h"
00014 
00015 namespace nllutils {
00016     bool robustMinimize(RooAbsReal &nll, RooMinimizerOpt &minimizer, int verbosity=0);
00017 }
00018 
00019 class ProfiledLikelihoodRatioTestStatOpt : public RooStats::TestStatistic {
00020     public:
00021         ProfiledLikelihoodRatioTestStatOpt(const RooArgSet &obs, RooAbsPdf &pdfNull, RooAbsPdf &pdfAlt, 
00022                 const RooArgSet *nuisances, const RooArgSet & paramsNull = RooArgSet(), const RooArgSet & paramsAlt = RooArgSet(),
00023                 int verbosity=0) ;
00024  
00025         virtual Double_t Evaluate(RooAbsData& data, RooArgSet& nullPOI) ;
00026 
00027         virtual const TString GetVarName() const {
00028             return TString::Format("-log(%s/%s)", pdfNull_->GetName(), pdfAlt_->GetName()); 
00029         }
00030 
00031         // Verbosity (default: 0)
00032         void setPrintLevel(Int_t level) { verbosity_ = level; }
00033 
00034     private:
00035         RooAbsPdf *pdfNull_, *pdfAlt_;
00036         RooArgSet snapNull_, snapAlt_; 
00037         RooArgSet nuisances_; 
00038         std::auto_ptr<RooArgSet> paramsNull_, paramsAlt_;
00039         std::auto_ptr<RooAbsReal> nllNull_, nllAlt_;
00040         Int_t verbosity_;
00041 
00042         // create NLL. if returns true, it can be kept, if false it should be deleted at the end of Evaluate
00043         bool createNLL(RooAbsPdf &pdf, RooAbsData &data, std::auto_ptr<RooAbsReal> &nll) ;
00044 
00045         double minNLL(std::auto_ptr<RooAbsReal> &nll) ;
00046 }; // TestSimpleStatistics
00047 
00048 
00049 class ProfiledLikelihoodTestStatOpt : public RooStats::TestStatistic {
00050     public:
00051         enum OneSidedness { twoSidedDef = 0, oneSidedDef = 1, signFlipDef = 2 };
00052 
00053         ProfiledLikelihoodTestStatOpt(const RooArgSet & observables,
00054                 RooAbsPdf &pdf, 
00055                 const RooArgSet *nuisances, 
00056                 const RooArgSet & params, const RooArgSet & poi, const RooArgList &gobsParams, const RooArgList &gobs, int verbosity=0, OneSidedness oneSided = oneSidedDef) ; 
00057 
00058         virtual Double_t Evaluate(RooAbsData& data, RooArgSet& nullPOI) ;
00059         virtual std::vector<Double_t> Evaluate(RooAbsData& data, RooArgSet& nullPOI, const std::vector<Double_t> &rVals) ;
00060 
00061         virtual const TString GetVarName() const { return "- log (#lambda)"; }
00062 
00063         // Verbosity (default: 0)
00064         void setPrintLevel(Int_t level) { verbosity_ = level; }
00065 
00066         void SetOneSided(OneSidedness oneSided) { oneSided_ = oneSided; }
00067     private:
00068 
00069         RooAbsPdf *pdf_;
00070         RooArgSet snap_, poi_; // snapshot of parameters, and of the subset which are POI
00071         std::auto_ptr<RooArgSet>  params_;
00072         RooArgSet                 nuisances_; // subset of params which are nuisances (not a snapshot)
00073         RooArgSet                 poiParams_; // subset of params which are POI (not a snapshot)
00074         std::auto_ptr<RooAbsReal> nll_;
00075         RooArgList gobsParams_, gobs_;
00076         Int_t verbosity_;
00077         OneSidedness oneSided_;
00078 
00079         // create NLL. if returns true, it can be kept, if false it should be deleted at the end of Evaluate
00080         bool createNLL(RooAbsPdf &pdf, RooAbsData &data) ;
00081         double minNLL(bool constrained, RooRealVar *r=0) ;
00082 }; // TestSimpleStatistics
00083 
00084 
00085 #endif