LikelihoodInterval.h

Go to the documentation of this file.
00001 // @(#)root/roostats:$Id: LikelihoodInterval.h 33206 2010-04-26 09:59:06Z moneta $
00002 // Author: Kyle Cranmer, Lorenzo Moneta, Gregory Schott, Wouter Verkerke
00003 /*************************************************************************
00004  * Copyright (C) 1995-2008, Rene Brun and Fons Rademakers.               *
00005  * All rights reserved.                                                  *
00006  *                                                                       *
00007  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00008  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00009  *************************************************************************/
00010 
00011 #ifndef RooStats_LikelihoodInterval
00012 #define RooStats_LikelihoodInterval
00013 
00014 #ifndef RooStats_ConfInterval
00015 #include "RooStats/ConfInterval.h"
00016 #endif
00017 
00018 #ifndef ROO_ARG_SET
00019 #include "RooArgSet.h"
00020 #endif
00021 
00022 #ifndef ROO_ABS_REAL
00023 #include "RooAbsReal.h"
00024 #endif
00025 
00026 #ifndef ROOT_Math_IFunctionfwd
00027 #include "Math/IFunctionfwd.h"
00028 #endif
00029 
00030 #include <map>
00031 #include <memory>
00032 
00033 namespace ROOT { 
00034    namespace Math { 
00035       class Minimizer; 
00036    }
00037 }
00038 
00039 namespace RooStats {
00040 
00041    class LikelihoodInterval : public ConfInterval {
00042 
00043    public:
00044 
00045       // defult constructor 
00046       explicit LikelihoodInterval(const char* name = 0);
00047 
00048       /// construct the interval from a Profile Likelihood object, parameter of interest and optionally a snapshot of 
00049       /// POI with their best fit values 
00050       LikelihoodInterval(const char* name, RooAbsReal*, const RooArgSet*,  RooArgSet * = 0);
00051 
00052       // destructor
00053       virtual ~LikelihoodInterval();
00054       
00055       // check if given point is in the interval
00056       virtual Bool_t IsInInterval(const RooArgSet&) const;
00057 
00058       // set the confidence level for the interval (e.g 0.682 for a 1-sigma interval) 
00059       virtual void SetConfidenceLevel(Double_t cl) {fConfidenceLevel = cl; ResetLimits(); }
00060 
00061       // return confidence level
00062       virtual Double_t ConfidenceLevel() const {return fConfidenceLevel;}
00063  
00064       // return a cloned list of parameters of interest.  User manages the return object
00065       virtual  RooArgSet* GetParameters() const;
00066 
00067       // check if parameters are correct (i.e. they are the POI of this interval) 
00068       Bool_t CheckParameters(const RooArgSet&) const ;
00069 
00070 
00071       // return the lower bound of the interval on a given parameter 
00072       Double_t LowerLimit(const RooRealVar& param) { bool ok; return LowerLimit(param,ok); }
00073       Double_t LowerLimit(const RooRealVar& param, bool & status) ;
00074 
00075       // return the upper bound of the interval on a given parameter 
00076       Double_t UpperLimit(const RooRealVar& param) { bool ok; return UpperLimit(param,ok); }
00077       Double_t UpperLimit(const RooRealVar& param, bool & status) ;
00078 
00079       // find both lower and upper interval boundaries for a given parameter
00080       // retun false if the bounds have not been found
00081       Bool_t FindLimits(const RooRealVar & param, double & lower, double &upper);
00082 
00083       /**
00084          return the 2D-contour points for the given subset of parameters
00085          by default make the contour using 30 points. The User has to preallocate the x and y array which will return 
00086          the set of x and y points defining the contour. 
00087          The return value of the funciton specify the number of contour point found.
00088          In case of error a zero is returned
00089       */
00090       Int_t GetContourPoints(const RooRealVar & paramX, const RooRealVar & paramY, Double_t * x, Double_t *y, Int_t npoints = 30);
00091 
00092       // return the profile log-likelihood ratio function
00093       RooAbsReal* GetLikelihoodRatio() {return fLikelihoodRatio;}
00094 
00095       // return a pointer to a snapshot with best fit parameter of interest
00096       const RooArgSet * GetBestFitParameters() const { return fBestFitParams; }
00097 
00098    protected: 
00099 
00100       // reset the cached limit values
00101       void ResetLimits(); 
00102 
00103       // internal function to create the minimizer for finding the contours
00104       bool CreateMinimizer();
00105 
00106    private:
00107 
00108       RooArgSet   fParameters; // parameters of interest for this interval
00109       RooArgSet * fBestFitParams; // snapshot of the model parameters with best fit value (managed internally)
00110       RooAbsReal* fLikelihoodRatio; // likelihood ratio function used to make contours (managed internally)
00111       Double_t fConfidenceLevel; // Requested confidence level (eg. 0.95 for 95% CL)
00112       std::map<std::string, double> fLowerLimits; // map with cached lower bound values
00113       std::map<std::string, double> fUpperLimits; // map with cached upper bound values
00114       std::auto_ptr<ROOT::Math::Minimizer > fMinimizer; //! transient pointer to minimizer class used to find limits and contour
00115       std::auto_ptr<RooFunctor>           fFunctor;   //! transient pointer to functor class used by the minimizer
00116       std::auto_ptr<ROOT::Math::IMultiGenFunction> fMinFunc; //! transient pointer to the minimization function 
00117 
00118       ClassDef(LikelihoodInterval,1)  // Concrete implementation of a ConfInterval based on a likelihood ratio
00119       
00120    };
00121 }
00122 
00123 #endif

Generated on Tue Jul 5 14:26:23 2011 for ROOT_528-00b_version by  doxygen 1.5.1