00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #include "RooFit.h"
00030 #include "Riostream.h"
00031
00032 #include "RooNLLVar.h"
00033 #include "RooAbsData.h"
00034 #include "RooAbsPdf.h"
00035 #include "RooCmdConfig.h"
00036 #include "RooMsgService.h"
00037
00038 #include "RooRealVar.h"
00039
00040
00041 ClassImp(RooNLLVar)
00042 ;
00043
00044 RooArgSet RooNLLVar::_emptySet ;
00045
00046
00047
00048 RooNLLVar::RooNLLVar(const char *name, const char* title, RooAbsPdf& pdf, RooAbsData& indata,
00049 const RooCmdArg& arg1, const RooCmdArg& arg2,const RooCmdArg& arg3,
00050 const RooCmdArg& arg4, const RooCmdArg& arg5,const RooCmdArg& arg6,
00051 const RooCmdArg& arg7, const RooCmdArg& arg8,const RooCmdArg& arg9) :
00052 RooAbsOptTestStatistic(name,title,pdf,indata,
00053 *(const RooArgSet*)RooCmdConfig::decodeObjOnTheFly("RooNLLVar::RooNLLVar","ProjectedObservables",0,&_emptySet
00054 ,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9),
00055 RooCmdConfig::decodeStringOnTheFly("RooNLLVar::RooNLLVar","RangeWithName",0,"",arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9),
00056 RooCmdConfig::decodeStringOnTheFly("RooNLLVar::RooNLLVar","AddCoefRange",0,"",arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9),
00057 RooCmdConfig::decodeIntOnTheFly("RooNLLVar::RooNLLVar","NumCPU",0,1,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9),
00058 kFALSE,
00059 RooCmdConfig::decodeIntOnTheFly("RooNLLVar::RooNLLVar","Verbose",0,1,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9),
00060 RooCmdConfig::decodeIntOnTheFly("RooNLLVar::RooNLLVar","SplitRange",0,0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9),
00061 RooCmdConfig::decodeIntOnTheFly("RooNLLVar::RooNLLVar","CloneData",0,1,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9))
00062 {
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074 RooCmdConfig pc("RooNLLVar::RooNLLVar") ;
00075 pc.allowUndefined() ;
00076 pc.defineInt("extended","Extended",0,kFALSE) ;
00077
00078 pc.process(arg1) ; pc.process(arg2) ; pc.process(arg3) ;
00079 pc.process(arg4) ; pc.process(arg5) ; pc.process(arg6) ;
00080 pc.process(arg7) ; pc.process(arg8) ; pc.process(arg9) ;
00081
00082 _extended = pc.getInt("extended") ;
00083 _weightSq = kFALSE ;
00084
00085 }
00086
00087
00088
00089
00090 RooNLLVar::RooNLLVar(const char *name, const char *title, RooAbsPdf& pdf, RooAbsData& indata,
00091 Bool_t extended, const char* rangeName, const char* addCoefRangeName,
00092 Int_t nCPU, Bool_t interleave, Bool_t verbose, Bool_t splitRange, Bool_t cloneData) :
00093 RooAbsOptTestStatistic(name,title,pdf,indata,RooArgSet(),rangeName,addCoefRangeName,nCPU,interleave,verbose,splitRange,cloneData),
00094 _extended(extended),
00095 _weightSq(kFALSE)
00096 {
00097
00098
00099
00100 }
00101
00102
00103
00104
00105 RooNLLVar::RooNLLVar(const char *name, const char *title, RooAbsPdf& pdf, RooAbsData& indata,
00106 const RooArgSet& projDeps, Bool_t extended, const char* rangeName,const char* addCoefRangeName,
00107 Int_t nCPU,Bool_t interleave,Bool_t verbose, Bool_t splitRange, Bool_t cloneData) :
00108 RooAbsOptTestStatistic(name,title,pdf,indata,projDeps,rangeName,addCoefRangeName,nCPU,interleave,verbose,splitRange,cloneData),
00109 _extended(extended),
00110 _weightSq(kFALSE)
00111 {
00112
00113
00114
00115
00116 }
00117
00118
00119
00120
00121 RooNLLVar::RooNLLVar(const RooNLLVar& other, const char* name) :
00122 RooAbsOptTestStatistic(other,name),
00123 _extended(other._extended),
00124 _weightSq(other._weightSq)
00125 {
00126
00127 }
00128
00129
00130
00131
00132
00133 RooNLLVar::~RooNLLVar()
00134 {
00135
00136 }
00137
00138
00139
00140
00141 Double_t RooNLLVar::evaluatePartition(Int_t firstEvent, Int_t lastEvent, Int_t stepSize) const
00142 {
00143
00144
00145
00146
00147
00148 Int_t i ;
00149 Double_t result(0) ;
00150
00151 RooAbsPdf* pdfClone = (RooAbsPdf*) _funcClone ;
00152
00153 Double_t sumWeight(0) ;
00154 for (i=firstEvent ; i<lastEvent ; i+=stepSize) {
00155
00156
00157
00158
00159
00160 _dataClone->get(i);
00161
00162 if (!_dataClone->valid()) {
00163 continue ;
00164 }
00165
00166 if (_dataClone->weight()==0) continue ;
00167
00168
00169 Double_t eventWeight = _dataClone->weight() ;
00170 if (_weightSq) eventWeight *= eventWeight ;
00171
00172 Double_t term = eventWeight * pdfClone->getLogVal(_normSet);
00173 sumWeight += eventWeight ;
00174
00175 result-= term;
00176 }
00177
00178
00179 if(_extended && firstEvent==0) {
00180 if (_weightSq) {
00181
00182
00183 Double_t sumW2(0) ;
00184 for (i=0 ; i<_dataClone->numEntries() ; i++) {
00185 _dataClone->get(i) ;
00186 Double_t eventWeight = _dataClone->weight() ;
00187
00188 sumW2 += eventWeight * eventWeight ;
00189 }
00190
00191
00192 result+= pdfClone->extendedTerm((Int_t)sumW2,_dataClone->get());
00193 } else {
00194 result+= pdfClone->extendedTerm((Int_t)_dataClone->sumEntries(),_dataClone->get());
00195 }
00196 }
00197
00198
00199
00200 if (_simCount>1) {
00201 result += sumWeight*log(1.0*_simCount) ;
00202 }
00203
00204
00205
00206 return result ;
00207 }
00208
00209
00210