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
19
20
21#include "RooRealVar.h"
22
24
26
27
28namespace RooStats {
29
31
33
34 public:
36 // Proof constructor. Do not use.
37 fPdf = nullptr;
38 fNll = nullptr;
39 fCachedBestFitParams = nullptr;
40 fLastData = nullptr;
42 fSigned = false;
45 fDetailedOutput = nullptr;
47
48 fVarName = "Profile Likelihood Ratio";
49 fReuseNll = false;
53 }
54
56 fPdf = &pdf;
57 fNll = nullptr;
58 fCachedBestFitParams = nullptr;
59 fLastData = nullptr;
61 fSigned = false;
64 fDetailedOutput = nullptr;
66
67 fVarName = "Profile Likelihood Ratio";
68 fReuseNll = false;
70 // avoid default tolerance to be too small (1. is default in RooMinimizer)
73 }
74
76 if(fNll) delete fNll;
79 }
80
81 void SetOneSided(bool flag=true) {fLimitType = (flag ? oneSided : twoSided);}
82 void SetOneSidedDiscovery(bool flag=true) {fLimitType = (flag ? oneSidedDiscovery : twoSided);}
83 void SetSigned(bool flag=true) {fSigned = flag;} // +/- t_mu instead of t_mu>0 with one-sided settings
84
85 bool IsTwoSided() const { return fLimitType == twoSided; }
87
88 static void SetAlwaysReuseNLL(bool flag);
89
90 void SetReuseNLL(bool flag) { fReuseNll = flag ; }
91 void SetLOffset(bool flag=true) { fLOffset = flag ; }
92
93 void SetMinimizer(const char* minimizer){ fMinimizer=minimizer;}
94 void SetStrategy(Int_t strategy){fStrategy=strategy;}
95 void SetTolerance(double tol){fTolerance=tol;}
96 void SetPrintLevel(Int_t printlevel){fPrintLevel=printlevel;}
97
98 /// Main interface to evaluate the test statistic on a dataset
99 double Evaluate(RooAbsData& data, RooArgSet& paramsOfInterest) override {
100 return EvaluateProfileLikelihood(0, data, paramsOfInterest);
101 }
102
103 /// evaluate the profile likelihood ratio (type = 0) or the minimum of likelihood (type=1) or the conditional LL (type = 2)
104 virtual double EvaluateProfileLikelihood(int type, RooAbsData &data, RooArgSet & paramsOfInterest);
105
106 virtual void EnableDetailedOutput( bool e=true, bool withErrorsAndPulls=false ) {
108 fDetailedOutputWithErrorsAndPulls = withErrorsAndPulls;
109 delete fDetailedOutput;
110 fDetailedOutput = nullptr;
111 }
112 /// Returns detailed output. The value returned by this function is updated after each call to Evaluate().
113 /// The returned RooArgSet contains the following:
114 ///
115 /// - the minimum nll, fitstatus and convergence quality for each fit </li>
116 /// - for each fit and for each non-constant parameter, the value, error and pull of the parameter are stored </li>
117 ///
118 const RooArgSet* GetDetailedOutput(void) const override {
119 return fDetailedOutput;
120 }
121
122 /// set the conditional observables which will be used when creating the NLL
123 /// so the pdf's will not be normalized on the conditional observables when computing the NLL
125
126 /// set the global observables which will be used when creating the NLL
127 /// so the constraint pdf's will be normalized correctly on the global observables when computing the NLL
129
130 virtual void SetVarName(const char* name) { fVarName = name; }
131 const TString GetVarName() const override {return fVarName;}
132
133 virtual RooAbsPdf * GetPdf() const { return fPdf; }
134
135 private:
136
138
139 private:
140
145 // double fLastMLE;
148
149 /// this will store a snapshot of the unconditional nuisance
150 /// parameter fit.
154 RooArgSet fConditionalObs; ///< conditional observables
155 RooArgSet fGlobalObs; ///< global observables
156
158
159 static bool fgAlwaysReuseNll ;
165 bool fLOffset ;
166
167 protected:
168
169 ClassDefOverride(ProfileLikelihoodTestStat,10) // implements the profile likelihood ratio as a test statistic to be used with several tools
170 };
171}
172
173
174#endif
#define e(i)
Definition: RSha256.hxx:103
#define ClassDefOverride(name, id)
Definition: Rtypes.h:339
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
char name[80]
Definition: TGX11.cxx:110
virtual void removeAll()
Remove all arguments from our set, deleting them if we own them.
virtual bool add(const RooAbsArg &var, bool silent=false)
Add the specified argument to list.
RooAbsData is the common abstract base class for binned and unbinned datasets.
Definition: RooAbsData.h:62
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition: RooAbsReal.h:62
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:56
RooFitResult is a container class to hold the input and output of a PDF fit to a dataset.
Definition: RooFitResult.h:40
ProfileLikelihoodTestStat is an implementation of the TestStatistic interface that calculates the pro...
RooArgSet fConditionalObs
conditional observables
virtual void EnableDetailedOutput(bool e=true, bool withErrorsAndPulls=false)
double Evaluate(RooAbsData &data, RooArgSet &paramsOfInterest) override
Main interface to evaluate the test statistic on a dataset.
void SetConditionalObservables(const RooArgSet &set) override
set the conditional observables which will be used when creating the NLL so the pdf's will not be nor...
void SetGlobalObservables(const RooArgSet &set) override
set the global observables which will be used when creating the NLL so the constraint pdf's will be n...
virtual double EvaluateProfileLikelihood(int type, RooAbsData &data, RooArgSet &paramsOfInterest)
evaluate the profile likelihood ratio (type = 0) or the minimum of likelihood (type=1) or the conditi...
const RooArgSet * GetDetailedOutput(void) const override
Returns detailed output.
const TString GetVarName() const override
virtual void SetVarName(const char *name)
RooFitResult * GetMinNLL()
find minimum of NLL using RooMinimizer
bool fDetailedOutputEnabled
this will store a snapshot of the unconditional nuisance parameter fit.
TestStatistic is an interface class to provide a facility for construction test statistics distributi...
Definition: TestStatistic.h:31
Basic string class.
Definition: TString.h:136
Namespace for the RooStats classes.
Definition: Asimov.h:19
bool IsNLLOffset()
function returning if the flag to check if the flag to use NLLOffset is set
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
Definition: TMathBase.h:250