Logo ROOT   6.10/09
Reference Guide
LikelihoodInterval.h
Go to the documentation of this file.
1 // @(#)root/roostats:$Id$
2 // Author: Kyle Cranmer, Lorenzo Moneta, Gregory Schott, Wouter Verkerke
3 /*************************************************************************
4  * Copyright (C) 1995-2008, Rene Brun and Fons Rademakers. *
5  * All rights reserved. *
6  * *
7  * For the licensing terms see $ROOTSYS/LICENSE. *
8  * For the list of contributors see $ROOTSYS/README/CREDITS. *
9  *************************************************************************/
10 
11 #ifndef RooStats_LikelihoodInterval
12 #define RooStats_LikelihoodInterval
13 
14 #include "RooStats/ConfInterval.h"
15 
16 #include "RooArgSet.h"
17 
18 #include "RooAbsReal.h"
19 
20 #include "Math/IFunctionfwd.h"
21 
22 #include <map>
23 #include <memory>
24 
25 namespace ROOT {
26  namespace Math {
27  class Minimizer;
28  }
29 }
30 
31 namespace RooStats {
32 
34 
35  public:
36 
37  /// default constructor
38  explicit LikelihoodInterval(const char* name = 0);
39 
40  //// construct the interval from a Profile Likelihood object, parameter of interest and optionally a snapshot of
41  //// POI with their best fit values
42  LikelihoodInterval(const char* name, RooAbsReal*, const RooArgSet*, RooArgSet * = 0);
43 
44  /// destructor
45  virtual ~LikelihoodInterval();
46 
47  /// check if given point is in the interval
48  virtual Bool_t IsInInterval(const RooArgSet&) const;
49 
50  /// set the confidence level for the interval (e.g 0.682 for a 1-sigma interval)
51  virtual void SetConfidenceLevel(Double_t cl) {fConfidenceLevel = cl; ResetLimits(); }
52 
53  /// return confidence level
54  virtual Double_t ConfidenceLevel() const {return fConfidenceLevel;}
55 
56  /// return a cloned list of parameters of interest. User manages the return object
57  virtual RooArgSet* GetParameters() const;
58 
59  /// check if parameters are correct (i.e. they are the POI of this interval)
60  Bool_t CheckParameters(const RooArgSet&) const ;
61 
62 
63  /// return the lower bound of the interval on a given parameter
64  Double_t LowerLimit(const RooRealVar& param) { bool ok; return LowerLimit(param,ok); }
65  Double_t LowerLimit(const RooRealVar& param, bool & status) ;
66 
67  /// return the upper bound of the interval on a given parameter
68  Double_t UpperLimit(const RooRealVar& param) { bool ok; return UpperLimit(param,ok); }
69  Double_t UpperLimit(const RooRealVar& param, bool & status) ;
70 
71  /// find both lower and upper interval boundaries for a given parameter
72  /// return false if the bounds have not been found
73  Bool_t FindLimits(const RooRealVar & param, double & lower, double &upper);
74 
75  /// return the 2D-contour points for the given subset of parameters
76  /// by default make the contour using 30 points. The User has to preallocate the x and y array which will return
77  /// the set of x and y points defining the contour.
78  /// The return value of the function specify the number of contour point found.
79  /// In case of error a zero is returned
80  Int_t GetContourPoints(const RooRealVar & paramX, const RooRealVar & paramY, Double_t * x, Double_t *y, Int_t npoints = 30);
81 
82  /// return the profile log-likelihood ratio function
83  RooAbsReal* GetLikelihoodRatio() {return fLikelihoodRatio;}
84 
85  /// return a pointer to a snapshot with best fit parameter of interest
86  const RooArgSet * GetBestFitParameters() const { return fBestFitParams; }
87 
88  protected:
89 
90  /// reset the cached limit values
91  void ResetLimits();
92 
93  /// internal function to create the minimizer for finding the contours
94  bool CreateMinimizer();
95 
96  private:
97 
98  RooArgSet fParameters; /// parameters of interest for this interval
99  RooArgSet * fBestFitParams; /// snapshot of the model parameters with best fit value (managed internally)
100  RooAbsReal* fLikelihoodRatio; /// likelihood ratio function used to make contours (managed internally)
101  Double_t fConfidenceLevel; /// Requested confidence level (eg. 0.95 for 95% CL)
102  std::map<std::string, double> fLowerLimits; /// map with cached lower bound values
103  std::map<std::string, double> fUpperLimits; /// map with cached upper bound values
104  std::shared_ptr<ROOT::Math::Minimizer > fMinimizer; //! transient pointer to minimizer class used to find limits and contour
105  std::shared_ptr<RooFunctor> fFunctor; //! transient pointer to functor class used by the minimizer
106  std::shared_ptr<ROOT::Math::IMultiGenFunction> fMinFunc; //! transient pointer to the minimization function
107 
108  ClassDef(LikelihoodInterval,1) /// Concrete implementation of a ConfInterval based on a likelihood ratio
109 
110  };
111 }
112 
113 #endif
const RooArgSet * GetBestFitParameters() const
return a pointer to a snapshot with best fit parameter of interest
RooAbsReal * fLikelihoodRatio
snapshot of the model parameters with best fit value (managed internally)
std::map< std::string, double > fLowerLimits
Requested confidence level (eg. 0.95 for 95% CL)
std::shared_ptr< ROOT::Math::Minimizer > fMinimizer
map with cached upper bound values
Namespace for new ROOT classes and functions.
Definition: StringConv.hxx:21
std::map< std::string, double > fUpperLimits
map with cached lower bound values
LikelihoodInterval is a concrete implementation of the RooStats::ConfInterval interface.
std::shared_ptr< ROOT::Math::IMultiGenFunction > fMinFunc
transient pointer to functor class used by the minimizer
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
virtual Double_t ConfidenceLevel() const
return confidence level
RooArgSet * fBestFitParams
parameters of interest for this interval
Double_t LowerLimit(const RooRealVar &param)
return the lower bound of the interval on a given parameter
RooAbsReal * GetLikelihoodRatio()
return the profile log-likelihood ratio function
Double_t x[n]
Definition: legend1.C:17
#define ClassDef(name, id)
Definition: Rtypes.h:297
RooRealVar represents a fundamental (non-derived) real valued object.
Definition: RooRealVar.h:36
Double_t UpperLimit(const RooRealVar &param)
return the upper bound of the interval on a given parameter
RooCmdArg Minimizer(const char *type, const char *alg=0)
void GetParameters(TFitEditor::FuncParams_t &pars, TF1 *func)
Stores the parameters of the given function into pars.
Definition: TFitEditor.cxx:270
std::shared_ptr< RooFunctor > fFunctor
transient pointer to minimizer class used to find limits and contour
ConfInterval is an interface class for a generic interval in the RooStats framework.
Definition: ConfInterval.h:35
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
Double_t y[n]
Definition: legend1.C:17
Namespace for new Math classes and functions.
virtual void SetConfidenceLevel(Double_t cl)
set the confidence level for the interval (e.g 0.682 for a 1-sigma interval)
Double_t fConfidenceLevel
likelihood ratio function used to make contours (managed internally)