00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef ROOSTATS_RatioOfProfiledLikelihoodsTestStat
00012 #define ROOSTATS_RatioOfProfiledLikelihoodsTestStat
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef ROOT_Rtypes
00025 #include "Rtypes.h"
00026 #endif
00027
00028 #ifndef ROO_NLL_VAR
00029 #include "RooNLLVar.h"
00030 #endif
00031
00032 #ifndef ROOSTATS_TestStatistic
00033 #include "RooStats/TestStatistic.h"
00034 #endif
00035
00036 namespace RooStats {
00037
00038 class RatioOfProfiledLikelihoodsTestStat: public TestStatistic {
00039
00040 public:
00041
00042 RatioOfProfiledLikelihoodsTestStat() :
00043 fNullPdf(NULL),
00044 fAltPdf(NULL),
00045 fAltPOI(NULL),
00046 fSubtractMLE(true)
00047 {
00048
00049 }
00050
00051 RatioOfProfiledLikelihoodsTestStat(RooAbsPdf& nullPdf, RooAbsPdf& altPdf,
00052 const RooArgSet* altPOI=0) :
00053 fNullPdf(&nullPdf), fAltPdf(&altPdf), fSubtractMLE(true)
00054 {
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081 if(altPOI)
00082 fAltPOI = (RooArgSet*) altPOI->snapshot();
00083 else
00084 fAltPOI = new RooArgSet();
00085
00086 }
00087
00088
00089 ~RatioOfProfiledLikelihoodsTestStat(void) {
00090 if(fAltPOI) delete fAltPOI;
00091 }
00092
00093
00094 Double_t ProfiledLikelihood(RooAbsData& data, RooArgSet& poi, RooAbsPdf& pdf) {
00095
00096
00097
00098
00099 RooAbsReal* nll = pdf.createNLL(data, RooFit::CloneData(kFALSE));
00100 RooAbsReal* profile = nll->createProfile(poi);
00101
00102 RooArgSet* attachedSet = nll->getVariables();
00103 *attachedSet = poi;
00104
00105 double nllVal = profile->getVal();
00106
00107 if(!fSubtractMLE) nllVal = nll->getVal();
00108
00109 delete attachedSet;
00110 delete profile;
00111 delete nll;
00112
00113 return nllVal;
00114 }
00115
00116
00117 virtual Double_t Evaluate(RooAbsData& data, RooArgSet& nullParamsOfInterest) {
00118 RooFit::MsgLevel msglevel = RooMsgService::instance().globalKillBelow();
00119 RooMsgService::instance().setGlobalKillBelow(RooFit::FATAL);
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133 double nullNLL = ProfiledLikelihood(data, nullParamsOfInterest, *fNullPdf);
00134
00135
00136 double altNLL = ProfiledLikelihood(data, *fAltPOI, *fAltPdf);
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146 RooMsgService::instance().setGlobalKillBelow(msglevel);
00147 return nullNLL -altNLL;
00148 }
00149
00150
00151 virtual const TString GetVarName() const { return "log(L(#mu_{1},#hat{#nu}_{1}) / L(#mu_{0},#hat{#nu}_{0}))"; }
00152
00153
00154
00155 void SetSubtractMLE(bool subtract){fSubtractMLE = subtract;}
00156
00157 private:
00158 RooAbsPdf* fNullPdf;
00159 RooAbsPdf* fAltPdf;
00160 RooArgSet* fAltPOI;
00161 Bool_t fSubtractMLE;
00162
00163 protected:
00164 ClassDef(RatioOfProfiledLikelihoodsTestStat,2)
00165 };
00166
00167 }
00168
00169
00170 #endif