Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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 fCachedBestFitParams = nullptr;
39 fLastData = nullptr;
41 fSigned = false;
44 fDetailedOutput = nullptr;
46
47 fVarName = "Profile Likelihood Ratio";
48 fReuseNll = false;
52 }
53
55 fPdf = &pdf;
56 fCachedBestFitParams = nullptr;
57 fLastData = nullptr;
59 fSigned = false;
62 fDetailedOutput = nullptr;
64
65 fVarName = "Profile Likelihood Ratio";
66 fReuseNll = false;
68 // avoid default tolerance to be too small (1. is default in RooMinimizer)
71 }
72
76 }
77
78 void SetOneSided(bool flag=true) {fLimitType = (flag ? oneSided : twoSided);}
79 void SetOneSidedDiscovery(bool flag=true) {fLimitType = (flag ? oneSidedDiscovery : twoSided);}
80 void SetSigned(bool flag=true) {fSigned = flag;} // +/- t_mu instead of t_mu>0 with one-sided settings
81
82 bool IsTwoSided() const { return fLimitType == twoSided; }
84
85 static void SetAlwaysReuseNLL(bool flag);
86
87 void SetReuseNLL(bool flag) { fReuseNll = flag ; }
88 void SetLOffset(bool flag=true) { fLOffset = flag ; }
89
90 void SetMinimizer(const char* minimizer){ fMinimizer=minimizer;}
91 void SetStrategy(Int_t strategy){fStrategy=strategy;}
92 void SetTolerance(double tol){fTolerance=tol;}
93 void SetPrintLevel(Int_t printlevel){fPrintLevel=printlevel;}
94
95 /// Main interface to evaluate the test statistic on a dataset
96 double Evaluate(RooAbsData& data, RooArgSet& paramsOfInterest) override {
97 return EvaluateProfileLikelihood(0, data, paramsOfInterest);
98 }
99
100 /// evaluate the profile likelihood ratio (type = 0) or the minimum of likelihood (type=1) or the conditional LL (type = 2)
101 virtual double EvaluateProfileLikelihood(int type, RooAbsData &data, RooArgSet & paramsOfInterest);
102
103 virtual void EnableDetailedOutput( bool e=true, bool withErrorsAndPulls=false ) {
105 fDetailedOutputWithErrorsAndPulls = withErrorsAndPulls;
106 delete fDetailedOutput;
107 fDetailedOutput = nullptr;
108 }
109 /// Returns detailed output. The value returned by this function is updated after each call to Evaluate().
110 /// The returned RooArgSet contains the following:
111 ///
112 /// - the minimum nll, fitstatus and convergence quality for each fit
113 /// - for each fit and for each non-constant parameter, the value, error and pull of the parameter are stored
114 ///
115 const RooArgSet* GetDetailedOutput(void) const override {
116 return fDetailedOutput;
117 }
118
119 /// set the conditional observables which will be used when creating the NLL
120 /// so the pdf's will not be normalized on the conditional observables when computing the NLL
122
123 /// set the global observables which will be used when creating the NLL
124 /// so the constraint pdf's will be normalized correctly on the global observables when computing the NLL
126
127 virtual void SetVarName(const char* name) { fVarName = name; }
128 const TString GetVarName() const override {return fVarName;}
129
130 virtual RooAbsPdf * GetPdf() const { return fPdf; }
131
132 private:
133
134 std::unique_ptr<RooFitResult> GetMinNLL();
135
136 private:
137
139 std::unique_ptr<RooAbsReal> fNll; //!
142 // double fLastMLE;
145
146 /// this will store a snapshot of the unconditional nuisance
147 /// parameter fit.
151 RooArgSet fConditionalObs; ///< conditional observables
152 RooArgSet fGlobalObs; ///< global observables
153
155
156 static bool fgAlwaysReuseNll ;
162 bool fLOffset ;
163
164 protected:
165
166 ClassDefOverride(ProfileLikelihoodTestStat,10) // implements the profile likelihood ratio as a test statistic to be used with several tools
167 };
168}
169
170
171#endif
#define e(i)
Definition RSha256.hxx:103
#define ClassDefOverride(name, id)
Definition Rtypes.h:341
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.
Abstract base class for binned and unbinned datasets.
Definition RooAbsData.h:57
Abstract interface for all probability density functions.
Definition RooAbsPdf.h:40
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition RooArgSet.h:55
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)
std::unique_ptr< 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...
Basic string class.
Definition TString.h:139
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