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
00030
00031
00032
00033 #include "Riostream.h"
00034
00035 #include "RooDataSet.h"
00036 #include "RooRealVar.h"
00037 #include "TString.h"
00038 #include "RooFit.h"
00039 #include "RooFitResult.h"
00040 #include "RooDLLSignificanceMCSModule.h"
00041 #include "RooMsgService.h"
00042
00043
00044
00045 ClassImp(RooDLLSignificanceMCSModule)
00046 ;
00047
00048
00049
00050
00051 RooDLLSignificanceMCSModule::RooDLLSignificanceMCSModule(const RooRealVar& param, Double_t nullHypoValue) :
00052 RooAbsMCStudyModule(Form("RooDLLSignificanceMCSModule_%s",param.GetName()),Form("RooDLLSignificanceMCSModule_%s",param.GetName())),
00053 _parName(param.GetName()),
00054 _data(0), _nll0h(0), _dll0h(0), _sig0h(0), _nullValue(nullHypoValue)
00055 {
00056
00057
00058 }
00059
00060
00061
00062
00063 RooDLLSignificanceMCSModule::RooDLLSignificanceMCSModule(const char* parName, Double_t nullHypoValue) :
00064 RooAbsMCStudyModule(Form("RooDLLSignificanceMCSModule_%s",parName),Form("RooDLLSignificanceMCSModule_%s",parName)),
00065 _parName(parName),
00066 _data(0), _nll0h(0), _dll0h(0), _sig0h(0), _nullValue(nullHypoValue)
00067 {
00068
00069
00070 }
00071
00072
00073
00074
00075 RooDLLSignificanceMCSModule::RooDLLSignificanceMCSModule(const RooDLLSignificanceMCSModule& other) :
00076 RooAbsMCStudyModule(other),
00077 _parName(other._parName),
00078 _data(0), _nll0h(0), _dll0h(0), _sig0h(0), _nullValue(other._nullValue)
00079 {
00080
00081 }
00082
00083
00084
00085
00086 RooDLLSignificanceMCSModule:: ~RooDLLSignificanceMCSModule()
00087 {
00088
00089
00090 if (_nll0h) {
00091 delete _nll0h ;
00092 }
00093 if (_dll0h) {
00094 delete _dll0h ;
00095 }
00096 if (_sig0h) {
00097 delete _sig0h ;
00098 }
00099 if (_data) {
00100 delete _data ;
00101 }
00102 }
00103
00104
00105
00106
00107 Bool_t RooDLLSignificanceMCSModule::initializeInstance()
00108 {
00109
00110
00111
00112 if (!fitParams()->find(_parName.c_str())) {
00113 coutE(InputArguments) << "RooDLLSignificanceMCSModule::initializeInstance:: ERROR: No parameter named " << _parName << " in RooMCStudy!" << endl ;
00114 return kFALSE ;
00115 }
00116
00117
00118 TString nll0hName = Form("nll_nullhypo_%s",_parName.c_str()) ;
00119 TString nll0hTitle = Form("-log(L) with null hypothesis for param %s",_parName.c_str()) ;
00120 _nll0h = new RooRealVar(nll0hName.Data(),nll0hTitle.Data(),0) ;
00121
00122
00123 TString dll0hName = Form("dll_nullhypo_%s",_parName.c_str()) ;
00124 TString dll0hTitle = Form("-log(L) difference w.r.t null hypo for param %s",_parName.c_str()) ;
00125 _dll0h = new RooRealVar(dll0hName.Data(),dll0hTitle.Data(),0) ;
00126
00127
00128 TString sig0hName = Form("significance_nullhypo_%s",_parName.c_str()) ;
00129 TString sig0hTitle = Form("Gaussian signficiance of Delta(-log(L)) w.r.t null hypo for param %s",_parName.c_str()) ;
00130 _sig0h = new RooRealVar(sig0hName.Data(),sig0hTitle.Data(),-10,100) ;
00131
00132
00133 _data = new RooDataSet("DeltaLLSigData","Additional data for Delta(-log(L)) study",RooArgSet(*_nll0h,*_dll0h,*_sig0h)) ;
00134
00135 return kTRUE ;
00136 }
00137
00138
00139
00140
00141 Bool_t RooDLLSignificanceMCSModule::initializeRun(Int_t )
00142 {
00143
00144
00145 _data->reset() ;
00146 return kTRUE ;
00147 }
00148
00149
00150
00151
00152 RooDataSet* RooDLLSignificanceMCSModule::finalizeRun()
00153 {
00154
00155
00156
00157
00158 return _data ;
00159 }
00160
00161
00162
00163
00164 Bool_t RooDLLSignificanceMCSModule::processAfterFit(Int_t )
00165 {
00166
00167
00168
00169
00170 RooRealVar* par = static_cast<RooRealVar*>(fitParams()->find(_parName.c_str())) ;
00171 par->setVal(_nullValue) ;
00172 par->setConstant(kTRUE) ;
00173 RooFitResult* frnull = refit() ;
00174 par->setConstant(kFALSE) ;
00175
00176 _nll0h->setVal(frnull->minNll()) ;
00177
00178 Double_t deltaLL = (frnull->minNll() - nllVar()->getVal()) ;
00179 Double_t signif = deltaLL>0 ? sqrt(2*deltaLL) : -sqrt(-2*deltaLL) ;
00180 _sig0h->setVal(signif) ;
00181 _dll0h->setVal(deltaLL) ;
00182
00183
00184 _data->add(RooArgSet(*_nll0h,*_dll0h,*_sig0h)) ;
00185
00186 delete frnull ;
00187
00188 return kTRUE ;
00189 }