TRolke.h

Go to the documentation of this file.
00001 
00002 //////////////////////////////////////////////////////////////////////////////
00003 //
00004 //  TRolke
00005 //
00006 //  This class computes confidence intervals for the rate of a Poisson
00007 //  in the presence of background and efficiency with a fully frequentist
00008 //  treatment of the uncertainties in the efficiency and background estimate
00009 //  using the profile likelihood method.
00010 //
00011 //      Author: Jan Conrad (CERN) 2004
00012 //      Updated: Johan Lundberg (CERN) 2009
00013 //
00014 //      Copyright CERN 2004,2009           Jan.Conrad@cern.ch,
00015 //                                     Johan.Lundberg@cern.ch
00016 //
00017 //  For information about the statistical meaning of the parameters
00018 //  and the syntax, consult TRolke.cxx
00019 //                  ------------------
00020 //
00021 //  Examples are found in the file Rolke.C
00022 //  --------------------------------------
00023 //
00024 //////////////////////////////////////////////////////////////////////////////
00025 
00026 #ifndef ROOT_TRolke
00027 #define ROOT_TRolke
00028 
00029 #include "TObject.h"
00030 #include "TMath.h"
00031 
00032 // Class definition. This class is not intended to be used as a base class.
00033 class TRolke : public TObject
00034 {
00035 
00036 private:
00037    Double_t fCL;         // confidence level as a fraction [0.9 for 90% ]
00038    Double_t fUpperLimit; // the calculated upper limit
00039    Double_t fLowerLimit; // the calculated lower limit
00040    bool fBounding;       // false for unbounded likelihood
00041                          // true for bounded likelihood   
00042    Int_t fNumWarningsDeprecated1;
00043    Int_t fNumWarningsDeprecated2;
00044 
00045    /* ----------------------------------------------------------------- */
00046    /* These variables are set by the Set methods for the various models */
00047    Int_t f_x;
00048    Int_t f_y;
00049    Int_t f_z;
00050    Double_t f_bm;
00051    Double_t f_em;
00052    Double_t f_e;
00053    Int_t f_mid;
00054    Double_t f_sde;
00055    Double_t f_sdb;
00056    Double_t f_tau;
00057    Double_t f_b;
00058    Int_t f_m;
00059 
00060    /* ----------------------------------------------------------------- */
00061    /* Internal helper functions and methods */
00062    // The Calculator
00063    Double_t Interval(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);
00064 
00065    // LIKELIHOOD ROUTINE
00066    Double_t Likelihood(Double_t mu, Int_t x, Int_t y, Int_t z, Double_t bm, Double_t em, Int_t mid, Double_t sde, Double_t sdb, Double_t tau, Double_t b, Int_t m, Int_t what);
00067 
00068    //MODEL 1
00069    Double_t EvalLikeMod1(Double_t mu, Int_t x, Int_t y, Int_t z, Double_t tau, Int_t m, Int_t what);
00070    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);
00071    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);
00072    Double_t LikeGradMod1(Double_t e, Double_t mu, Int_t x, Int_t y, Int_t z, Double_t tau, Int_t m);
00073 
00074    //MODEL 2
00075    Double_t EvalLikeMod2(Double_t mu, Int_t x, Int_t y, Double_t em, Double_t sde, Double_t tau, Int_t what);
00076 
00077    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);
00078 
00079    //MODEL 3
00080    Double_t EvalLikeMod3(Double_t mu, Int_t x, Double_t bm, Double_t em, Double_t sde, Double_t sdb, Int_t what);
00081    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);
00082 
00083    //MODEL 4
00084    Double_t EvalLikeMod4(Double_t mu, Int_t x, Int_t y, Double_t tau, Int_t what);
00085    Double_t LikeMod4(Double_t mu, Double_t b, Int_t x, Int_t y, Double_t tau);
00086 
00087    //MODEL 5
00088    Double_t EvalLikeMod5(Double_t mu, Int_t x, Double_t bm, Double_t sdb, Int_t what);
00089    Double_t LikeMod5(Double_t mu, Double_t b, Int_t x, Double_t bm, Double_t u);
00090 
00091    //MODEL 6
00092    Double_t EvalLikeMod6(Double_t mu, Int_t x, Int_t z, Double_t b, Int_t m, Int_t what);
00093    Double_t LikeMod6(Double_t mu, Double_t b, Double_t e, Int_t x, Int_t z, Int_t m);
00094 
00095    //MODEL 7
00096    Double_t EvalLikeMod7(Double_t mu, Int_t x, Double_t em, Double_t sde, Double_t b, Int_t what);
00097    Double_t LikeMod7(Double_t mu, Double_t b, Double_t e, Int_t x, Double_t em, Double_t v);
00098 
00099    //MISC
00100    static Double_t EvalPolynomial(Double_t x, const Int_t coef[], Int_t N);
00101    static Double_t EvalMonomial(Double_t x, const Int_t coef[], Int_t N);
00102    Double_t LogFactorial(Int_t n);
00103 
00104    Double_t ComputeInterval(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);
00105 
00106    void SetModelParameters(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);
00107 
00108    void SetModelParameters();
00109 
00110    Double_t GetBackground();
00111 
00112 public:
00113 
00114    /* Constructor */
00115    TRolke(Double_t CL = 0.9, Option_t *option = "");
00116 
00117    /* Destructor */
00118    virtual ~TRolke();
00119 
00120    /* Get and set the Confidence Level */
00121    Double_t GetCL() const         {
00122       return fCL;
00123    }
00124    void     SetCL(Double_t CL)  {
00125       fCL = CL;
00126    }
00127 
00128    /* Set the Confidence Level in terms of Sigmas. */
00129    void SetCLSigmas(Double_t CLsigmas) {
00130       fCL = TMath::Erf(CLsigmas / TMath::Sqrt(2.0)) ;
00131    }
00132    
00133    // The Set methods for the different models are described in Rolke.cxx
00134    // model 1
00135    void SetPoissonBkgBinomEff(Int_t x, Int_t y, Int_t z, Double_t tau, Int_t m);
00136 
00137    // model 2
00138    void SetPoissonBkgGaussEff(Int_t x, Int_t y, Double_t em, Double_t tau, Double_t sde);
00139 
00140    // model 3
00141    void SetGaussBkgGaussEff(Int_t x, Double_t bm, Double_t em, Double_t sde, Double_t sdb);
00142 
00143    // model 4
00144    void SetPoissonBkgKnownEff(Int_t x, Int_t y, Double_t tau, Double_t e);
00145 
00146    // model 5
00147    void SetGaussBkgKnownEff(Int_t x, Double_t bm, Double_t sdb, Double_t e);
00148 
00149    // model 6
00150    void SetKnownBkgBinomEff(Int_t x, Int_t z, Int_t m, Double_t b);
00151 
00152    // model 7
00153    void SetKnownBkgGaussEff(Int_t x, Double_t em, Double_t sde, Double_t b);
00154 
00155    /* Deprecated interface method (read Rolke.cxx). May be removed from future releases */
00156    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);
00157 
00158    // get the upper and lower limits based on the specified model
00159    bool GetLimits(Double_t& low, Double_t& high);
00160    Double_t GetUpperLimit();
00161    Double_t GetLowerLimit();
00162 
00163    // get the upper and lower average limits
00164    bool GetSensitivity(Double_t& low, Double_t& high, Double_t pPrecision = 0.00001);
00165 
00166    // get the upper and lower limits for the outcome corresponding to
00167    // a given quantile.
00168    bool GetLimitsQuantile(Double_t& low, Double_t& high, Int_t& out_x, Double_t integral = 0.5);
00169 
00170    // get the upper and lower limits for the most likely outcome.
00171    bool GetLimitsML(Double_t& low, Double_t& high, Int_t& out_x);
00172 
00173    // get the value of x corresponding to rejection of the null hypothesis.
00174    bool GetCriticalNumber(Int_t& ncrit,Int_t maxtry=-1);
00175 
00176    /* Get the bounding mode flag. True activates bounded mode. Read
00177       TRolke.cxx and the references therein for details. */
00178    bool GetBounding() const {
00179       return fBounding;
00180    }
00181 
00182    /* Get the bounding mode flag. True activates bounded mode. Read
00183       TRolke.cxx and the references therein for details. */
00184    void SetBounding(const bool bnd) {
00185       fBounding = bnd;
00186    }
00187 
00188    /* Deprecated name for SetBounding. */
00189    void SetSwitch(bool bnd) ;
00190 
00191    /* Dump internals. Option is not used */
00192    void Print(Option_t*) const;
00193 
00194    ClassDef(TRolke, 2)
00195 };
00196 
00197 //calculate confidence limits using the Rolke method
00198 #endif
00199 

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