library: libPhysics #include "TRolke.h"

# TRolke

class description - source file - inheritance tree (.ps)

## class TRolke : public TObject

| Inheritance Chart:

`TObject`

<-

`TRolke`

        protected:

          static Double_t Chi2Percentile(Double_t df, Double_t CL1)
                 Double_t EvalLikeMod1(Double_t mu, Int_t x, Int_t y, Int_t z, Double_t e, Double_t tau, Double_t b, Int_t m, Int_t what)
                 Double_t EvalLikeMod2(Double_t mu, Int_t x, Int_t y, Double_t em, Double_t e, Double_t sde, Double_t tau, Double_t b, Int_t what)
                 Double_t EvalLikeMod3(Double_t mu, Int_t x, Double_t bm, Double_t em, Double_t e, Double_t sde, Double_t sdb, Double_t b, Int_t what)
                 Double_t EvalLikeMod4(Double_t mu, Int_t x, Int_t y, Double_t tau, Double_t b, Int_t what)
                 Double_t EvalLikeMod5(Double_t mu, Int_t x, Double_t bm, Double_t sdb, Double_t b, Int_t what)
                 Double_t EvalLikeMod6(Double_t mu, Int_t x, Int_t z, Double_t e, Double_t b, Int_t m, Int_t what)
                 Double_t EvalLikeMod7(Double_t mu, Int_t x, Double_t em, Double_t e, Double_t sde, Double_t b, Int_t what)
          static Double_t EvalMonomial(Double_t x, const Int_t* coef, Int_t N)
          static Double_t EvalPolynomial(Double_t x, const Int_t* coef, Int_t N)
          static Double_t InverseIncompleteGamma(Double_t df, Double_t CL1)
          static Double_t InverseNormal(Double_t CL1)
                 Double_t LikeGradMod1(Double_t e, Double_t mu, Int_t x, Int_t y, Int_t z, Double_t tau, Int_t m)
                 Double_t Likelihood(Double_t mu, Int_t x, Int_t y, Int_t z, Double_t bm, Double_t em, Double_t e, Int_t mid, Double_t sde, Double_t sdb, Double_t tau, Double_t b, Int_t m, Int_t what)
                 Double_t LikeMod1(Double_t mu, Double_t b, Double_t e, Int_t x, Int_t y, Int_t z, Double_t tau, Int_t m)
                 Double_t LikeMod2(Double_t mu, Double_t b, Double_t e, Int_t x, Int_t y, Double_t em, Double_t tau, Double_t v)
                 Double_t LikeMod3(Double_t mu, Double_t b, Double_t e, Int_t x, Double_t bm, Double_t em, Double_t u, Double_t v)
                 Double_t LikeMod4(Double_t mu, Double_t b, Int_t x, Int_t y, Double_t tau)
                 Double_t LikeMod5(Double_t mu, Double_t b, Int_t x, Double_t bm, Double_t u)
                 Double_t LikeMod6(Double_t mu, Double_t b, Double_t e, Int_t x, Int_t z, Int_t m)
                 Double_t LikeMod7(Double_t mu, Double_t b, Double_t e, Int_t x, Double_t em, Double_t v)
                     void ProfLikeMod1(Double_t mu, Double_t& b, Double_t& e, Int_t x, Int_t y, Int_t z, Double_t tau, Int_t m)

        public:

                          TRolke(Double_t CL = 0.9, Option_t* option)
                          TRolke(const TRolke&)
                  virtual ~TRolke()
                 Double_t CalculateInterval(Int_t x, Int_t y, Int_t z, Double_t bm, Double_t em, Double_t e, Int_t mid, Double_t sde, Double_t sdb, Double_t tau, Double_t b, Int_t m)
           static TClass* Class()
                 Double_t GetCL() const
                 Double_t GetLowerLimit() const
                 Double_t GetUpperLimit() const
          virtual TClass* IsA() const
                  TRolke& operator=(const TRolke&)
                     void SetCL(Double_t CL)
             virtual void ShowMembers(TMemberInspector& insp, char* parent)
             virtual void Streamer(TBuffer& b)
                     void StreamerNVirtual(TBuffer& b)

### Data Members

        protected:

          Double_t fCL          confidence level as a fraction [e.g. 90% = 0.9]
          Double_t fUpperLimit  the calculated upper limit
          Double_t fLowerLimit  the calculated lower limit

## Class Description

      TRolke

      This class computes confidence intervals for the rate of a Poisson
      in the presence of background and efficiency with a fully frequentist
      treatment of the uncertainties in the efficiency and background estimate
      using the profile likelihood method.

       The signal is always assumed to be Poisson.

       It allows the following Models:

           1: Background - Poisson, Efficiency - Binomial  (cl,x,y,z,tau,m)
           2: Background - Poisson, Efficiency - Gaussian  (cl,xd,y,em,tau,sde)
           3: Background - Gaussian, Efficiency - Gaussian (cl,x,bm,em,sd)
           4: Background - Poisson, Efficiency - known     (cl,x,y,tau,e)
           5: Background - Gaussian, Efficiency - known    (cl,x,y,z,sdb,e)
           6: Background - known, Efficiency - Binomial    (cl,x,z,m,b)
           7: Background - known, Efficiency - Gaussian    (cl,x,em,sde,b)

      Parameter definition:

      cl  =  Confidence level

      x = number of observed events

      y = number of background events

      z = number of simulated signal events

      em = measurement of the efficiency.

      bm = background estimate

      tau = ratio between signal and background region (in case background is
      observed) ratio between observed and simulated livetime in case
      background is determined from MC.

      sd(x) = sigma of the Gaussian

      e = true efficiency (in case known)

      b = expected background (in case known)

      m = number of MC runs

      mid = ID number of the model ...

      For a description of the method and its properties:

      W.Rolke, A. Lopez, J. Conrad
      "A marvelous and completely perfect method without flaws"
      NiM xyz blabla

     Author: Jan Conrad (CERN)

     see example in tutorial Rolke.C

     Copyright CERN 2004                Jan.Conrad@cern.ch

TRolke(Double_t CL, Option_t * /*option*/)

~TRolke()

Double_t CalculateInterval(Int_t x, Int_t y, Int_t z, Double_t bm, Double_t em,Double_t e, Int_t mid, Double_t sde, Double_t sdb, Double_t tau, Double_t b, Int_t m)

     Calculates the Confidence Interval

Double_t Likelihood(Double_t mu, Int_t x, Int_t y, Int_t z, Double_t bm,Double_t em, Double_t e, Int_t mid, Double_t sde, Double_t sdb, Double_t tau, Double_t b, Int_t m, Int_t what)

     Chooses between the different profile likelihood functions to use for the
     different models.
     Returns evaluation of the profile likelihood functions.

Double_t EvalLikeMod1(Double_t mu, Int_t x, Int_t y, Int_t z, Double_t e, Double_t tau, Double_t b, Int_t m, Int_t what)

     Calculates the Profile Likelihood for MODEL 1:
      Poisson background/ Binomial Efficiency
     what = 1: Maximum likelihood estimate is returned
     what = 2: Profile Likelihood of Maxmimum Likelihood estimate is returned.
     what = 3: Profile Likelihood of Test hypothesis is returned
     otherwise parameters as described in the beginning of the class)

Double_t LikeMod1(Double_t mu,Double_t b, Double_t e, Int_t x, Int_t y, Int_t z, Double_t tau, Int_t m)

     Profile Likelihood function for MODEL 1:
     Poisson background/ Binomial Efficiency

void ProfLikeMod1(Double_t mu,Double_t &b,Double_t &e,Int_t x,Int_t y, Int_t z,Double_t tau,Int_t m)

     Void needed to calculate estimates of efficiency and background for model 1

Double_t LikeGradMod1(Double_t e, Double_t mu, Int_t x,Int_t y,Int_t z,Double_t tau,Int_t m)

Double_t EvalLikeMod2(Double_t mu, Int_t x, Int_t y, Double_t em, Double_t e,Double_t sde, Double_t tau, Double_t b, Int_t what)

     Calculates the Profile Likelihood for MODEL 2:
      Poisson background/ Gauss Efficiency
     what = 1: Maximum likelihood estimate is returned
     what = 2: Profile Likelihood of Maxmimum Likelihood estimate is returned.
     what = 3: Profile Likelihood of Test hypothesis is returned
     otherwise parameters as described in the beginning of the class)

Double_t LikeMod2(Double_t mu, Double_t b, Double_t e,Int_t x,Int_t y,Double_t em,Double_t tau, Double_t v)

     Profile Likelihood function for MODEL 2:
     Poisson background/Gauss Efficiency

Double_t EvalLikeMod3(Double_t mu, Int_t x, Double_t bm, Double_t em, Double_t e, Double_t sde, Double_t sdb, Double_t b, Int_t what)

     Calculates the Profile Likelihood for MODEL 3:
     Gauss  background/ Gauss Efficiency
     what = 1: Maximum likelihood estimate is returned
     what = 2: Profile Likelihood of Maxmimum Likelihood estimate is returned.
     what = 3: Profile Likelihood of Test hypothesis is returned
     otherwise parameters as described in the beginning of the class)

Double_t LikeMod3(Double_t mu,Double_t b,Double_t e,Int_t x,Double_t bm,Double_t em,Double_t u,Double_t v)

     Profile Likelihood function for MODEL 3:
     Gauss background/Gauss Efficiency

Double_t EvalLikeMod4(Double_t mu, Int_t x, Int_t y, Double_t tau, Double_t b, Int_t what)

     Calculates the Profile Likelihood for MODEL 4:
     Poiss  background/Efficiency known
     what = 1: Maximum likelihood estimate is returned
     what = 2: Profile Likelihood of Maxmimum Likelihood estimate is returned.
     what = 3: Profile Likelihood of Test hypothesis is returned
     otherwise parameters as described in the beginning of the class)

Double_t LikeMod4(Double_t mu,Double_t b,Int_t x,Int_t y,Double_t tau)

     Profile Likelihood function for MODEL 4:
     Poiss background/Efficiency known

Double_t EvalLikeMod5(Double_t mu, Int_t x, Double_t bm, Double_t sdb, Double_t b, Int_t what)

     Calculates the Profile Likelihood for MODEL 5:
     Gauss  background/Efficiency known
     what = 1: Maximum likelihood estimate is returned
     what = 2: Profile Likelihood of Maxmimum Likelihood estimate is returned.
     what = 3: Profile Likelihood of Test hypothesis is returned
     otherwise parameters as described in the beginning of the class)

Double_t LikeMod5(Double_t mu,Double_t b,Int_t x,Double_t bm,Double_t u)

     Profile Likelihood function for MODEL 5:
     Gauss background/Efficiency known

Double_t EvalLikeMod6(Double_t mu, Int_t x, Int_t z, Double_t e, Double_t b, Int_t m, Int_t what)

     Calculates the Profile Likelihood for MODEL 6:
     Gauss  known/Efficiency binomial
     what = 1: Maximum likelihood estimate is returned
     what = 2: Profile Likelihood of Maxmimum Likelihood estimate is returned.
     what = 3: Profile Likelihood of Test hypothesis is returned
     otherwise parameters as described in the beginning of the class)

Double_t LikeMod6(Double_t mu,Double_t b,Double_t e,Int_t x,Int_t z,Int_t m)

     Profile Likelihood function for MODEL 6:
     background known/ Efficiency binomial

Double_t EvalLikeMod7(Double_t mu, Int_t x, Double_t em, Double_t e, Double_t sde, Double_t b, Int_t what)

     Calculates the Profile Likelihood for MODEL 7:
     background known/Efficiency Gauss
     what = 1: Maximum likelihood estimate is returned
     what = 2: Profile Likelihood of Maxmimum Likelihood estimate is returned.
     what = 3: Profile Likelihood of Test hypothesis is returned
     otherwise parameters as described in the beginning of the class)

Double_t LikeMod7(Double_t mu,Double_t b,Double_t e,Int_t x,Double_t em,Double_t v)

     Profile Likelihood function for MODEL 6:
     background known/ Efficiency binomial

Double_t Chi2Percentile(Double_t df,Double_t CL1)

     Finds the Chi-square argument x such that the integral
     from x to infinity of the Chi-square density is equal
     to the given cumulative probability y.

     This is accomplished using the inverse gamma integral
     function and the relation
        x/2 = igami( df/2, y );

       Author Jan Conrad (CERN) Jan.Conrad@cern.ch
       Copyright by Stephen L. Moshier (Cephes Math Library)

Double_t InverseIncompleteGamma(Double_t df,Double_t CL1)

     calculates the inverse of the incomplete (complemented)gamma integral
     for df degrees of freedom and fraction CL1
     * Given p, the function finds x such that
     Starting with the approximate value
              3
      x = df t

     where

      t = 1 - d - InverseNormal(p) sqrt(df)

     and

     d = 1/9df,

     the routine performs up to 10 Newton iterations to find the
     root of 1- TMath::Gamma(df,CL1) - p = 0.
     Author Jan Conrad (CERN) Jan.Conrad@cern.ch
     Copyright by Stephen L. Moshier (Cephes Math Library)

Double_t InverseNormal(Double_t CL1)

Double_t EvalPolynomial(Double_t x, const Int_t coef[], Int_t N)

     evaluate polynomial

Double_t EvalMonomial(Double_t x, const Int_t coef[], Int_t N)

     evaluate mononomial

### Inline Functions

               Double_t GetUpperLimit() const
               Double_t GetLowerLimit() const
               Double_t GetCL() const
                   void SetCL(Double_t CL)
                TClass* Class()
                TClass* IsA() const
                   void ShowMembers(TMemberInspector& insp, char* parent)
                   void Streamer(TBuffer& b)
                   void StreamerNVirtual(TBuffer& b)
                 TRolke TRolke(const TRolke&)
                TRolke& operator=(const TRolke&)

Author: Jan Conrad 9/2/2004
Last update: root/physics:$Name: $:$Id: TRolke.cxx,v 1.3 2004/02/13 14:27:00 rdm Exp $
Copyright (C) 1995-2004, Rene Brun and Fons Rademakers. *