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:
35 /// Proof constructor. Do not use.
37 : fStrategy(::ROOT::Math::MinimizerOptions::DefaultStrategy()),
38 fTolerance(std::max(1., ::ROOT::Math::MinimizerOptions::DefaultTolerance())),
39 fPrintLevel(::ROOT::Math::MinimizerOptions::DefaultPrintLevel()),
41 {
42 }
43
45 : fPdf(&pdf),
46 fStrategy(::ROOT::Math::MinimizerOptions::DefaultStrategy()),
47 fTolerance(std::max(1., ::ROOT::Math::MinimizerOptions::DefaultTolerance())),
48 fPrintLevel(::ROOT::Math::MinimizerOptions::DefaultPrintLevel()),
50 {
51 // avoid default tolerance to be too small (1. is default in RooMinimizer)
52 }
53
56 }
57
58 void SetOneSided(bool flag=true) {fLimitType = (flag ? oneSided : twoSided);}
59 void SetOneSidedDiscovery(bool flag=true) {fLimitType = (flag ? oneSidedDiscovery : twoSided);}
60 void SetSigned(bool flag=true) {fSigned = flag;} // +/- t_mu instead of t_mu>0 with one-sided settings
61
62 bool IsTwoSided() const { return fLimitType == twoSided; }
64
65 static void SetAlwaysReuseNLL(bool flag);
66
67 void SetReuseNLL(bool flag) { fReuseNll = flag ; }
68 void SetLOffset(bool flag=true) { fLOffset = flag ; }
69
70 void SetMinimizer(const char* minimizer){ fMinimizer=minimizer;}
71 void SetStrategy(Int_t strategy){fStrategy=strategy;}
72 void SetTolerance(double tol){fTolerance=tol;}
73 void SetPrintLevel(Int_t printlevel){fPrintLevel=printlevel;}
74
75 /// Main interface to evaluate the test statistic on a dataset
76 double Evaluate(RooAbsData& data, RooArgSet& paramsOfInterest) override {
77 return EvaluateProfileLikelihood(0, data, paramsOfInterest);
78 }
79
80 /// evaluate the profile likelihood ratio (type = 0) or the minimum of likelihood (type=1) or the conditional LL (type = 2)
81 virtual double EvaluateProfileLikelihood(int type, RooAbsData &data, RooArgSet & paramsOfInterest);
82
83 virtual void EnableDetailedOutput( bool e=true, bool withErrorsAndPulls=false ) {
85 fDetailedOutputWithErrorsAndPulls = withErrorsAndPulls;
86 fDetailedOutput = nullptr;
87 }
88 /// Returns detailed output. The value returned by this function is updated after each call to Evaluate().
89 /// The returned RooArgSet contains the following:
90 ///
91 /// - the minimum nll, fitstatus and convergence quality for each fit
92 /// - for each fit and for each non-constant parameter, the value, error and pull of the parameter are stored
93 ///
94 const RooArgSet* GetDetailedOutput(void) const override {
95 return fDetailedOutput.get();
96 }
97
98 /// set the conditional observables which will be used when creating the NLL
99 /// so the pdf's will not be normalized on the conditional observables when computing the NLL
101
102 /// set the global observables which will be used when creating the NLL
103 /// so the constraint pdf's will be normalized correctly on the global observables when computing the NLL
105
106 virtual void SetVarName(const char* name) { fVarName = name; }
107 const TString GetVarName() const override {return fVarName;}
108
109 virtual RooAbsPdf * GetPdf() const { return fPdf; }
110
111 private:
112
113 std::unique_ptr<RooFitResult> GetMinNLL();
114
115 RooAbsPdf* fPdf = nullptr;
116 std::unique_ptr<RooAbsReal> fNll; //!
120 bool fSigned = false;
121
122 /// this will store a snapshot of the unconditional nuisance
123 /// parameter fit.
126 std::unique_ptr<RooArgSet> fDetailedOutput; ///<!
127 RooArgSet fConditionalObs; ///< conditional observables
128 RooArgSet fGlobalObs; ///< global observables
129
130 TString fVarName = "Profile Likelihood Ratio";
131
132 static bool fgAlwaysReuseNll ;
133 bool fReuseNll = false;
138 bool fLOffset ;
139
140 protected:
141
142 ClassDefOverride(ProfileLikelihoodTestStat,10) // implements the profile likelihood ratio as a test statistic to be used with several tools
143 };
144}
145
146
147#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.
Storage_t const & get() const
Const access to the underlying stl container.
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...
std::unique_ptr< RooArgSet > fDetailedOutput
!
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...
ProfileLikelihoodTestStat()
Proof constructor. Do not use.
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 new Math classes and functions.
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
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