Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RooDLLSignificanceMCSModule.cxx
Go to the documentation of this file.
1/*****************************************************************************
2 * Project: RooFit *
3 * Package: RooFitCore *
4 * @(#)root/roofitcore:$Id$
5 * Authors: *
6 * WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu *
7 * DK, David Kirkby, UC Irvine, dkirkby@uci.edu *
8 * *
9 * Copyright (c) 2000-2005, Regents of the University of California *
10 * and Stanford University. All rights reserved. *
11 * *
12 * Redistribution and use in source and binary forms, *
13 * with or without modification, are permitted according to the terms *
14 * listed in LICENSE (http://roofit.sourceforge.net/license.txt) *
15 *****************************************************************************/
16
17/**
18\file RooDLLSignificanceMCSModule.cxx
19\class RooDLLSignificanceMCSModule
20\ingroup Roofitcore
21
22RooDLLSignificanceMCSModule is an add-on modules to RooMCStudy that
23calculates the significance of a signal by comparing the likelihood of
24a fit fit with a given parameter floating with a fit with that given
25parameter fixed to a nominal value (usually zero). The difference in
26the -log(L) of those two fits can be interpreted as the probability
27that a statistical background fluctation may result in a signal as large
28or larger than the signal observed. This interpretation is contingent
29on underlying normal sampling distributions and a MC study is a good way
30to test that assumption.
31**/
32
33#include "Riostream.h"
34
35#include "RooDataSet.h"
36#include "RooRealVar.h"
37#include "TString.h"
38#include "RooFit.h"
39#include "RooFitResult.h"
41#include "RooMsgService.h"
42
43
44
45using namespace std;
46
48 ;
49
50
51
52////////////////////////////////////////////////////////////////////////////////
53/// Constructor of module with parameter to be interpreted as nSignal and the value of the
54/// null hypothesis for nSignal (usually zero)
55
57 RooAbsMCStudyModule(Form("RooDLLSignificanceMCSModule_%s",param.GetName()),Form("RooDLLSignificanceMCSModule_%s",param.GetName())),
58 _parName(param.GetName()),
59 _data(0), _nll0h(0), _dll0h(0), _sig0h(0), _nullValue(nullHypoValue)
60{
61}
62
63
64
65////////////////////////////////////////////////////////////////////////////////
66/// Constructor of module with parameter name to be interpreted as nSignal and the value of the
67/// null hypothesis for nSignal (usually zero)
68
70 RooAbsMCStudyModule(Form("RooDLLSignificanceMCSModule_%s",parName),Form("RooDLLSignificanceMCSModule_%s",parName)),
71 _parName(parName),
72 _data(0), _nll0h(0), _dll0h(0), _sig0h(0), _nullValue(nullHypoValue)
73{
74}
75
76
77
78////////////////////////////////////////////////////////////////////////////////
79/// Copy constructor
80
82 RooAbsMCStudyModule(other),
83 _parName(other._parName),
84 _data(0), _nll0h(0), _dll0h(0), _sig0h(0), _nullValue(other._nullValue)
85{
86}
87
88
89
90////////////////////////////////////////////////////////////////////////////////
91/// Destructor
92
94{
95 if (_nll0h) {
96 delete _nll0h ;
97 }
98 if (_dll0h) {
99 delete _dll0h ;
100 }
101 if (_sig0h) {
102 delete _sig0h ;
103 }
104 if (_data) {
105 delete _data ;
106 }
107}
108
109
110
111////////////////////////////////////////////////////////////////////////////////
112/// Initialize module after attachment to RooMCStudy object
113
115{
116 // Check that parameter is also present in fit parameter list of RooMCStudy object
117 if (!fitParams()->find(_parName.c_str())) {
118 coutE(InputArguments) << "RooDLLSignificanceMCSModule::initializeInstance:: ERROR: No parameter named " << _parName << " in RooMCStudy!" << endl ;
119 return kFALSE ;
120 }
121
122 // Construct variable that holds -log(L) fit with null hypothesis for given parameter
123 TString nll0hName = Form("nll_nullhypo_%s",_parName.c_str()) ;
124 TString nll0hTitle = Form("-log(L) with null hypothesis for param %s",_parName.c_str()) ;
125 _nll0h = new RooRealVar(nll0hName.Data(),nll0hTitle.Data(),0) ;
126
127 // Construct variable that holds -log(L) fit with null hypothesis for given parameter
128 TString dll0hName = Form("dll_nullhypo_%s",_parName.c_str()) ;
129 TString dll0hTitle = Form("-log(L) difference w.r.t null hypo for param %s",_parName.c_str()) ;
130 _dll0h = new RooRealVar(dll0hName.Data(),dll0hTitle.Data(),0) ;
131
132 // Construct variable that holds significance corresponding to delta(-log(L)) w.r.t to null hypothesis for given parameter
133 TString sig0hName = Form("significance_nullhypo_%s",_parName.c_str()) ;
134 TString sig0hTitle = Form("Gaussian signficiance of Delta(-log(L)) w.r.t null hypo for param %s",_parName.c_str()) ;
135 _sig0h = new RooRealVar(sig0hName.Data(),sig0hTitle.Data(),-10,100) ;
136
137 // Create new dataset to be merged with RooMCStudy::fitParDataSet
138 _data = new RooDataSet("DeltaLLSigData","Additional data for Delta(-log(L)) study",RooArgSet(*_nll0h,*_dll0h,*_sig0h)) ;
139
140 return kTRUE ;
141}
142
143
144
145////////////////////////////////////////////////////////////////////////////////
146/// Initialize module at beginning of RooCMStudy run
147
149{
150 _data->reset() ;
151 return kTRUE ;
152}
153
154
155
156////////////////////////////////////////////////////////////////////////////////
157/// Return auxiliary dataset with results of delta(-log(L))
158/// calculations of this module so that it is merged with
159/// RooMCStudy::fitParDataSet() by RooMCStudy
160
162{
163 return _data ;
164}
165
166
167
168////////////////////////////////////////////////////////////////////////////////
169/// Save likelihood from nominal fit, fix chosen parameter to its
170/// null hypothesis value and rerun fit Save difference in likelihood
171/// and associated Gaussian significance in auxilary dataset
172
174{
175 RooRealVar* par = static_cast<RooRealVar*>(fitParams()->find(_parName.c_str())) ;
176 par->setVal(_nullValue) ;
177 par->setConstant(kTRUE) ;
178 RooFitResult* frnull = refit() ;
179 par->setConstant(kFALSE) ;
180
181 _nll0h->setVal(frnull->minNll()) ;
182
183 Double_t deltaLL = (frnull->minNll() - nllVar()->getVal()) ;
184 Double_t signif = deltaLL>0 ? sqrt(2*deltaLL) : -sqrt(-2*deltaLL) ;
185 _sig0h->setVal(signif) ;
186 _dll0h->setVal(deltaLL) ;
187
188
190
191 delete frnull ;
192
193 return kTRUE ;
194}
#define coutE(a)
const Bool_t kFALSE
Definition RtypesCore.h:101
const Bool_t kTRUE
Definition RtypesCore.h:100
#define ClassImp(name)
Definition Rtypes.h:364
char * Form(const char *fmt,...)
RooAbsArg * find(const char *name) const
Find object with given name in list.
virtual void reset()
RooAbsMCStudyModule is a base class for add-on modules to RooMCStudy that can perform additional calc...
RooFitResult * refit(RooAbsData *inGenSample=0)
void setConstant(Bool_t value=kTRUE)
Double_t getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
Definition RooAbsReal.h:94
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition RooArgSet.h:35
RooDLLSignificanceMCSModule is an add-on modules to RooMCStudy that calculates the significance of a ...
RooDataSet * finalizeRun()
Return auxiliary dataset with results of delta(-log(L)) calculations of this module so that it is mer...
Bool_t processAfterFit(Int_t)
Save likelihood from nominal fit, fix chosen parameter to its null hypothesis value and rerun fit Sav...
RooDLLSignificanceMCSModule(const RooRealVar &param, Double_t nullHypoValue=0)
Constructor of module with parameter to be interpreted as nSignal and the value of the null hypothesi...
Bool_t initializeInstance()
Initialize module after attachment to RooMCStudy object.
Bool_t initializeRun(Int_t)
Initialize module at beginning of RooCMStudy run.
RooDataSet is a container class to hold unbinned data.
Definition RooDataSet.h:36
virtual void add(const RooArgSet &row, Double_t weight=1.0, Double_t weightError=0) override
Add a data point, with its coordinates specified in the 'data' argset, to the data set.
RooFitResult is a container class to hold the input and output of a PDF fit to a dataset.
Double_t minNll() const
Return minimized -log(L) value.
RooRealVar represents a variable that can be changed from the outside.
Definition RooRealVar.h:39
virtual void setVal(Double_t value)
Set value of variable to 'value'.
Basic string class.
Definition TString.h:136
const char * Data() const
Definition TString.h:369