Logo ROOT   6.12/07
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
virtual const RooArgSet * GetDetailedOutput(void) const
return detailed output: for fits this can be pulls, processing time, ... The returned pointer will no...
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:86
Basic string class.
Definition: TString.h:125
virtual void EnableDetailedOutput(bool e=true, bool withErrorsAndPulls=false)
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
virtual const TString GetVarName() const
virtual Double_t EvaluateProfileLikelihood(int type, RooAbsData &data, RooArgSet &paramsOfInterest)
internal function to evaluate test statistics can do depending on type:
#define ClassDef(name, id)
Definition: Rtypes.h:320
virtual void removeAll()
Remove all arguments from our set, deleting them if we own them.
virtual void SetGlobalObservables(const RooArgSet &set)
interface to set global observables. If a test statistics needs them it will re-implement this functi...
static const std::string & DefaultMinimizerType()
virtual void SetConditionalObservables(const RooArgSet &set)
interface to set conditional observables. If a test statistics needs them it will re-implement this f...
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...
RooAbsData is the common abstract base class for binned and unbinned datasets.
Definition: RooAbsData.h:37
ProfileLikelihoodTestStat is an implementation of the TestStatistic interface that calculates the pro...
Namespace for the RooStats classes.
Definition: Asimov.h:20
double Double_t
Definition: RtypesCore.h:55
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition: RooAbsReal.h:53
int type
Definition: TGX11.cxx:120
you should not use this method at all Int_t Int_t Double_t Double_t Double_t e
Definition: TRolke.cxx:630
bool IsNLLOffset()
RooAbsPdf is the abstract interface for all probability density functions The class provides hybrid a...
Definition: RooAbsPdf.h:41
Short_t Max(Short_t a, Short_t b)
Definition: TMathBase.h:200
RooFitResult * GetMinNLL()
find minimum of NLL using RooMinimizer
virtual void SetVarName(const char *name)
TestStatistic is an interface class to provide a facility for construction test statistics distributi...
Definition: TestStatistic.h:31
const Bool_t kTRUE
Definition: RtypesCore.h:87
char name[80]
Definition: TGX11.cxx:109