Logo ROOT  
Reference Guide
ProfileLikelihoodTestStat.h
Go to the documentation of this file.
1 // @(#)root/roostats:$Id$
2 // Author: Kyle Cranmer, Lorenzo Moneta, Gregory Schott, Wouter Verkerke
3 // Additional Contributions: Giovanni Petrucciani
4 /*************************************************************************
5  * Copyright (C) 1995-2008, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOSTATS_ProfileLikelihoodTestStat
13 #define ROOSTATS_ProfileLikelihoodTestStat
14 
15 
16 #include "Rtypes.h"
17 
18 #include "RooStats/TestStatistic.h"
19 
20 
21 #include "RooRealVar.h"
22 
23 #include "RooNLLVar.h"
24 
25 #include "Math/MinimizerOptions.h"
26 
27 #include "RooStats/RooStatsUtils.h"
28 
29 
30 namespace RooStats {
31 
33 
35 
36  public:
38  // Proof constructor. Do not use.
39  fPdf = 0;
40  fNll = 0;
42  fLastData = 0;
44  fSigned = false;
46  fDetailedOutputEnabled = false;
47  fDetailedOutput = NULL;
49 
50  fVarName = "Profile Likelihood Ratio";
51  fReuseNll = false;
56 
57  }
59  fPdf = &pdf;
60  fNll = 0;
62  fLastData = 0;
64  fSigned = false;
66  fDetailedOutputEnabled = false;
67  fDetailedOutput = NULL;
69 
70  fVarName = "Profile Likelihood Ratio";
71  fReuseNll = false;
74  // avoid default tolerance to be too small (1. is default in RooMinimizer)
77  }
78 
80  if(fNll) delete fNll;
83  }
84 
85  //LM use default copy constructor and assignment copying the pointers. Is this what we want ?
86 
87  void SetOneSided(Bool_t flag=true) {fLimitType = (flag ? oneSided : twoSided);}
89  void SetSigned(Bool_t flag=true) {fSigned = flag;} // +/- t_mu instead of t_mu>0 with one-sided settings
90  //void SetOneSidedDiscovery(Bool_t flag=true) {fOneSidedDiscovery = flag;}
91 
92  bool IsTwoSided() const { return fLimitType == twoSided; }
93  bool IsOneSidedDiscovery() const { return fLimitType == oneSidedDiscovery; }
94 
95  static void SetAlwaysReuseNLL(Bool_t flag);
96 
97  void SetReuseNLL(Bool_t flag) { fReuseNll = flag ; }
98  void SetLOffset(Bool_t flag=kTRUE) { fLOffset = flag ; }
99 
100  void SetMinimizer(const char* minimizer){ fMinimizer=minimizer;}
101  void SetStrategy(Int_t strategy){fStrategy=strategy;}
102  void SetTolerance(double tol){fTolerance=tol;}
103  void SetPrintLevel(Int_t printlevel){fPrintLevel=printlevel;}
104 
105  // Main interface to evaluate the test statistic on a dataset
106  virtual Double_t Evaluate(RooAbsData& data, RooArgSet& paramsOfInterest) {
107  return EvaluateProfileLikelihood(0, data, paramsOfInterest);
108  }
109 
110  // evaluate the profile likelihood ratio (type = 0) or the minimum of likelihood (type=1) or the conditional LL (type = 2)
111  virtual Double_t EvaluateProfileLikelihood(int type, RooAbsData &data, RooArgSet & paramsOfInterest);
112 
113  virtual void EnableDetailedOutput( bool e=true, bool withErrorsAndPulls=false ) {
115  fDetailedOutputWithErrorsAndPulls = withErrorsAndPulls;
116  delete fDetailedOutput;
117  fDetailedOutput = NULL;
118  }
119  virtual const RooArgSet* GetDetailedOutput(void) const {
120  // Returns detailed output. The value returned by this function is updated after each call to Evaluate().
121  // The returned RooArgSet contains the following:
122  // <ul>
123  // <li> the minimum nll, fitstatus and convergence quality for each fit </li>
124  // <li> for each fit and for each non-constant parameter, the value, error and pull of the parameter are stored </li>
125  // </ul>
126  return fDetailedOutput;
127  }
128 
129  // set the conditional observables which will be used when creating the NLL
130  // so the pdf's will not be normalized on the conditional observables when computing the NLL
132 
133  // set the global observables which will be used when creating the NLL
134  // so the constraint pdf's will be normalized correctly on the global observables when computing the NLL
135  virtual void SetGlobalObservables(const RooArgSet& set) {fGlobalObs.removeAll(); fGlobalObs.add(set);}
136 
137  virtual void SetVarName(const char* name) { fVarName = name; }
138  virtual const TString GetVarName() const {return fVarName;}
139 
140  virtual RooAbsPdf * GetPdf() const { return fPdf; }
141 
142 
143  // const bool PValueIsRightTail(void) { return false; } // overwrites default
144 
145  private:
146 
148 
149  private:
150 
155  // Double_t fLastMLE;
158 
159  // this will store a snapshot of the unconditional nuisance
160  // parameter fit.
164  RooArgSet fConditionalObs; // conditional observables
165  RooArgSet fGlobalObs; // global observables
166 
168 
176 
177  protected:
178 
179  ClassDef(ProfileLikelihoodTestStat,10) // implements the profile likelihood ratio as a test statistic to be used with several tools
180  };
181 }
182 
183 
184 #endif
RooStats::ProfileLikelihoodTestStat::GetDetailedOutput
virtual const RooArgSet * GetDetailedOutput(void) const
return detailed output: for fits this can be pulls, processing time, ... The returned pointer will no...
Definition: ProfileLikelihoodTestStat.h:119
RooStats::ProfileLikelihoodTestStat::fCachedBestFitParams
const RooArgSet * fCachedBestFitParams
Definition: ProfileLikelihoodTestStat.h:153
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
RooStats::IsNLLOffset
bool IsNLLOffset()
Test of RooStats should by default offset NLL calculations.
Definition: RooStatsUtils.cxx:66
e
#define e(i)
Definition: RSha256.hxx:103
RooAbsData
RooAbsData is the common abstract base class for binned and unbinned datasets.
Definition: RooAbsData.h:46
TMath::Max
Short_t Max(Short_t a, Short_t b)
Definition: TMathBase.h:212
RooStats::ProfileLikelihoodTestStat::SetReuseNLL
void SetReuseNLL(Bool_t flag)
Definition: ProfileLikelihoodTestStat.h:97
RooStats::ProfileLikelihoodTestStat::fLOffset
Bool_t fLOffset
Definition: ProfileLikelihoodTestStat.h:175
RooStats::ProfileLikelihoodTestStat::IsTwoSided
bool IsTwoSided() const
Definition: ProfileLikelihoodTestStat.h:92
RooStats::ProfileLikelihoodTestStat::fPdf
RooAbsPdf * fPdf
Definition: ProfileLikelihoodTestStat.h:151
RooStats::ProfileLikelihoodTestStat::fStrategy
Int_t fStrategy
Definition: ProfileLikelihoodTestStat.h:172
RooStats::ProfileLikelihoodTestStat::SetMinimizer
void SetMinimizer(const char *minimizer)
Definition: ProfileLikelihoodTestStat.h:100
RooStats::ProfileLikelihoodTestStat::IsOneSidedDiscovery
bool IsOneSidedDiscovery() const
Definition: ProfileLikelihoodTestStat.h:93
RooStats::TestStatistic
TestStatistic is an interface class to provide a facility for construction test statistics distributi...
Definition: TestStatistic.h:31
RooStats::ProfileLikelihoodTestStat::oneSidedDiscovery
@ oneSidedDiscovery
Definition: ProfileLikelihoodTestStat.h:34
RooStats::ProfileLikelihoodTestStat::fTolerance
Double_t fTolerance
Definition: ProfileLikelihoodTestStat.h:173
RooStats::ProfileLikelihoodTestStat::fPrintLevel
Int_t fPrintLevel
Definition: ProfileLikelihoodTestStat.h:174
RooArgSet::add
virtual Bool_t add(const RooAbsCollection &col, Bool_t silent=kFALSE)
Add a collection of arguments to this collection by calling add() for each element in the source coll...
Definition: RooArgSet.h:88
RooStats::ProfileLikelihoodTestStat::fgAlwaysReuseNll
static Bool_t fgAlwaysReuseNll
Definition: ProfileLikelihoodTestStat.h:169
RooAbsReal
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition: RooAbsReal.h:61
RooStats::ProfileLikelihoodTestStat::SetStrategy
void SetStrategy(Int_t strategy)
Definition: ProfileLikelihoodTestStat.h:101
RooStats::ProfileLikelihoodTestStat::~ProfileLikelihoodTestStat
virtual ~ProfileLikelihoodTestStat()
Definition: ProfileLikelihoodTestStat.h:79
TString
Basic string class.
Definition: TString.h:136
RooStats::ProfileLikelihoodTestStat::ProfileLikelihoodTestStat
ProfileLikelihoodTestStat()
Definition: ProfileLikelihoodTestStat.h:37
RooStats::ProfileLikelihoodTestStat::SetSigned
void SetSigned(Bool_t flag=true)
Definition: ProfileLikelihoodTestStat.h:89
MinimizerOptions.h
RooStats::ProfileLikelihoodTestStat::GetVarName
virtual const TString GetVarName() const
Definition: ProfileLikelihoodTestStat.h:138
RooStats::ProfileLikelihoodTestStat::EnableDetailedOutput
virtual void EnableDetailedOutput(bool e=true, bool withErrorsAndPulls=false)
Definition: ProfileLikelihoodTestStat.h:113
RooNLLVar.h
bool
RooStats::ProfileLikelihoodTestStat::fReuseNll
Bool_t fReuseNll
Definition: ProfileLikelihoodTestStat.h:170
RooFitResult
RooFitResult is a container class to hold the input and output of a PDF fit to a dataset.
Definition: RooFitResult.h:40
RooStats::ProfileLikelihoodTestStat::SetLOffset
void SetLOffset(Bool_t flag=kTRUE)
Definition: ProfileLikelihoodTestStat.h:98
RooStats::ProfileLikelihoodTestStat::fNll
RooAbsReal * fNll
Definition: ProfileLikelihoodTestStat.h:152
RooStats::ProfileLikelihoodTestStat::Evaluate
virtual Double_t Evaluate(RooAbsData &data, RooArgSet &paramsOfInterest)
Main interface to evaluate the test statistic on a dataset given the values for the Null Parameters O...
Definition: ProfileLikelihoodTestStat.h:106
RooStats::ProfileLikelihoodTestStat::EvaluateProfileLikelihood
virtual Double_t EvaluateProfileLikelihood(int type, RooAbsData &data, RooArgSet &paramsOfInterest)
internal function to evaluate test statistics can do depending on type:
Definition: ProfileLikelihoodTestStat.cxx:56
RooStats::ProfileLikelihoodTestStat::fDetailedOutputWithErrorsAndPulls
bool fDetailedOutputWithErrorsAndPulls
Definition: ProfileLikelihoodTestStat.h:162
RooStats::ProfileLikelihoodTestStat::GetMinNLL
RooFitResult * GetMinNLL()
find minimum of NLL using RooMinimizer
Definition: ProfileLikelihoodTestStat.cxx:300
RooStats::ProfileLikelihoodTestStat::ProfileLikelihoodTestStat
ProfileLikelihoodTestStat(RooAbsPdf &pdf)
Definition: ProfileLikelihoodTestStat.h:58
ROOT::Math::MinimizerOptions::DefaultMinimizerType
static const std::string & DefaultMinimizerType()
Definition: MinimizerOptions.cxx:92
RooStats::ProfileLikelihoodTestStat::twoSided
@ twoSided
Definition: ProfileLikelihoodTestStat.h:34
RooStats::ProfileLikelihoodTestStat::fConditionalObs
RooArgSet fConditionalObs
Definition: ProfileLikelihoodTestStat.h:164
RooStats::ProfileLikelihoodTestStat::SetPrintLevel
void SetPrintLevel(Int_t printlevel)
Definition: ProfileLikelihoodTestStat.h:103
RooStats::ProfileLikelihoodTestStat::LimitType
LimitType
Definition: ProfileLikelihoodTestStat.h:34
TestStatistic.h
RooStats::ProfileLikelihoodTestStat::fSigned
Bool_t fSigned
Definition: ProfileLikelihoodTestStat.h:157
RooStats::ProfileLikelihoodTestStat::SetAlwaysReuseNLL
static void SetAlwaysReuseNLL(Bool_t flag)
Definition: ProfileLikelihoodTestStat.cxx:47
RooStats::ProfileLikelihoodTestStat::fMinimizer
TString fMinimizer
Definition: ProfileLikelihoodTestStat.h:171
RooRealVar.h
ROOT::Math::MinimizerOptions::DefaultStrategy
static int DefaultStrategy()
Definition: MinimizerOptions.cxx:88
RooStats::ProfileLikelihoodTestStat::SetConditionalObservables
virtual void SetConditionalObservables(const RooArgSet &set)
interface to set conditional observables. If a test statistics needs them it will re-implement this f...
Definition: ProfileLikelihoodTestStat.h:131
RooStats::ProfileLikelihoodTestStat::fLastData
RooAbsData * fLastData
Definition: ProfileLikelihoodTestStat.h:154
RooStatsUtils.h
Double_t
double Double_t
Definition: RtypesCore.h:59
ROOT::Math::MinimizerOptions::DefaultTolerance
static double DefaultTolerance()
Definition: MinimizerOptions.cxx:84
RooStats::ProfileLikelihoodTestStat::SetGlobalObservables
virtual void SetGlobalObservables(const RooArgSet &set)
interface to set global observables. If a test statistics needs them it will re-implement this functi...
Definition: ProfileLikelihoodTestStat.h:135
RooStats::ProfileLikelihoodTestStat::SetOneSidedDiscovery
void SetOneSidedDiscovery(Bool_t flag=true)
Definition: ProfileLikelihoodTestStat.h:88
RooStats
Namespace for the RooStats classes.
Definition: Asimov.h:19
RooStats::ProfileLikelihoodTestStat::fLimitType
LimitType fLimitType
Definition: ProfileLikelihoodTestStat.h:156
RooStats::ProfileLikelihoodTestStat::fVarName
TString fVarName
Definition: ProfileLikelihoodTestStat.h:167
RooStats::ProfileLikelihoodTestStat::SetVarName
virtual void SetVarName(const char *name)
Definition: ProfileLikelihoodTestStat.h:137
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
ROOT::Math::MinimizerOptions::DefaultPrintLevel
static int DefaultPrintLevel()
Definition: MinimizerOptions.cxx:89
name
char name[80]
Definition: TGX11.cxx:110
RooStats::ProfileLikelihoodTestStat::fDetailedOutputEnabled
bool fDetailedOutputEnabled
Definition: ProfileLikelihoodTestStat.h:161
RooStats::ProfileLikelihoodTestStat::fGlobalObs
RooArgSet fGlobalObs
Definition: ProfileLikelihoodTestStat.h:165
RooAbsPdf
Definition: RooAbsPdf.h:40
RooStats::ProfileLikelihoodTestStat::SetTolerance
void SetTolerance(double tol)
Definition: ProfileLikelihoodTestStat.h:102
RooStats::ProfileLikelihoodTestStat
ProfileLikelihoodTestStat is an implementation of the TestStatistic interface that calculates the pro...
Definition: ProfileLikelihoodTestStat.h:32
type
int type
Definition: TGX11.cxx:121
RooAbsCollection::removeAll
virtual void removeAll()
Remove all arguments from our set, deleting them if we own them.
Definition: RooAbsCollection.cxx:643
RooStats::ProfileLikelihoodTestStat::SetOneSided
void SetOneSided(Bool_t flag=true)
Definition: ProfileLikelihoodTestStat.h:87
RooStats::ProfileLikelihoodTestStat::GetPdf
virtual RooAbsPdf * GetPdf() const
Definition: ProfileLikelihoodTestStat.h:140
Rtypes.h
RooStats::ProfileLikelihoodTestStat::fDetailedOutput
RooArgSet * fDetailedOutput
Definition: ProfileLikelihoodTestStat.h:163
RooArgSet
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:28
RooStats::ProfileLikelihoodTestStat::oneSided
@ oneSided
Definition: ProfileLikelihoodTestStat.h:34
int