NumberCountingUtils.cxx

Go to the documentation of this file.
00001 // @(#)root/roostats:$Id: NumberCountingUtils.cxx 29179 2009-06-23 18:39:27Z brun $
00002 // Author: Kyle Cranmer   28/07/2008
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2008, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 
00013 #ifndef RooStats_NumberCountingUtils
00014 #include "RooStats/NumberCountingUtils.h"
00015 #endif
00016 
00017 #ifndef RooStats_RooStatsUtils
00018 #include "RooStats/RooStatsUtils.h"
00019 #endif
00020 
00021 // // Without this macro the THtml doc  can not be generated
00022 // #if !defined(R__ALPHA) && !defined(R__SOLARIS) && !defined(R__ACC) && !defined(R__FBSD)
00023 // NamespaceImp(RooStats)
00024 // //NamespaceImp(NumberCountingUtils)
00025 // #endif
00026 
00027 //using namespace RooStats;
00028 
00029 Double_t RooStats::NumberCountingUtils::BinomialExpP(Double_t signalExp, Double_t backgroundExp, Double_t relativeBkgUncert){
00030   // Expected P-value for s=0 in a ratio of Poisson means.  
00031   // Here the background and its uncertainty are provided directly and 
00032   // assumed to be from the double Poisson counting setup described in the 
00033   // BinomialWithTau functions.  
00034   // Normally one would know tau directly, but here it is determiend from
00035   // the background uncertainty.  This is not strictly correct, but a useful 
00036   // approximation.
00037 
00038 
00039   //SIDE BAND EXAMPLE
00040   //See Eqn. (19) of Cranmer and pp. 36-37 of Linnemann.
00041   //150 total events in signalExp region, 100 in sideband of equal size
00042   Double_t mainInf = signalExp+backgroundExp;  //Given
00043   Double_t tau = 1./backgroundExp/(relativeBkgUncert*relativeBkgUncert);
00044   Double_t auxiliaryInf = backgroundExp*tau;  //Given
00045   
00046   Double_t P_Bi = TMath::BetaIncomplete(1./(1.+tau),mainInf,auxiliaryInf+1);
00047   return P_Bi;
00048   
00049 /*
00050 Now, if instead the mean background level b in the signal region is
00051 specified, along with Gaussian rms sigb, then one can fake a Poisson
00052 sideband (see Linnemann, p. 35, converted to Cranmer's notation) by
00053 letting tau = b/(sigb*sigb) and y = b*tau.  Thus, for example, if one
00054 has x=150 and b = 100 +/- 10, one then derives tau and y.  Then one
00055 has the same two lines of ROOT calling BetaIncomplete and ErfInverse.
00056 Since I chose these numbers to revert to the previous example, we get
00057 the same answer:
00058 */
00059 /*
00060 //GAUSSIAN FAKED AS POISSON EXAMPLE
00061 x = 150.    //Given
00062 b = 100.    //Given
00063 sigb = 10.  //Given
00064 tau = b/(sigb*sigb)
00065 y = tau*b   
00066 Z_Bi = TMath::BetaIncomplete(1./(1.+tau),x,y+1)    
00067 S = sqrt(2)*TMath::ErfInverse(1 - 2*Z_Bi)     
00068 
00069 */
00070 
00071 }
00072 
00073 
00074 Double_t RooStats::NumberCountingUtils::BinomialWithTauExpP(Double_t signalExp, Double_t backgroundExp, Double_t tau){
00075   // Expected P-value for s=0 in a ratio of Poisson means.  
00076   // Based on two expectations, a main measurement that might have signal
00077   // and an auxiliarly measurement for the background that is signal free.
00078   // The expected background in the auxiliary measurement is a factor
00079   // tau larger than in the main measurement.
00080 
00081   Double_t mainInf = signalExp+backgroundExp;  //Given
00082   Double_t auxiliaryInf = backgroundExp*tau;  //Given
00083   
00084   Double_t P_Bi = TMath::BetaIncomplete(1./(1.+tau),mainInf,auxiliaryInf+1);
00085   
00086   return P_Bi;
00087   
00088 }
00089 
00090 Double_t RooStats::NumberCountingUtils::BinomialObsP(Double_t mainObs, Double_t backgroundObs, Double_t relativeBkgUncert){
00091   // P-value for s=0 in a ratio of Poisson means.  
00092   // Here the background and its uncertainty are provided directly and 
00093   // assumed to be from the double Poisson counting setup.  
00094   // Normally one would know tau directly, but here it is determiend from
00095   // the background uncertainty.  This is not strictly correct, but a useful 
00096   // approximation.
00097   
00098   Double_t tau = 1./backgroundObs/(relativeBkgUncert*relativeBkgUncert);
00099   Double_t auxiliaryInf = backgroundObs*tau;  //Given
00100   
00101     
00102   //SIDE BAND EXAMPLE
00103   //See Eqn. (19) of Cranmer and pp. 36-37 of Linnemann.
00104   Double_t P_Bi = TMath::BetaIncomplete(1./(1.+tau),mainObs,auxiliaryInf+1);
00105   
00106   return P_Bi;
00107 
00108 }
00109 
00110 
00111 Double_t RooStats::NumberCountingUtils::BinomialWithTauObsP(Double_t mainObs, Double_t auxiliaryObs, Double_t tau){
00112   // P-value for s=0 in a ratio of Poisson means.  
00113   // Based on two observations, a main measurement that might have signal
00114   // and an auxiliarly measurement for the background that is signal free.
00115   // The expected background in the auxiliary measurement is a factor
00116   // tau larger than in the main measurement.
00117 
00118   //SIDE BAND EXAMPLE
00119   //See Eqn. (19) of Cranmer and pp. 36-37 of Linnemann.
00120   Double_t P_Bi = TMath::BetaIncomplete(1./(1.+tau),mainObs,auxiliaryObs+1);
00121   
00122   return P_Bi;
00123   
00124 }
00125 
00126 Double_t RooStats::NumberCountingUtils::BinomialExpZ(Double_t signalExp, Double_t backgroundExp, Double_t relativeBkgUncert) {    
00127   // See BinomialExpP
00128   return RooStats::PValueToSignificance( BinomialExpP(signalExp,backgroundExp,relativeBkgUncert) ) ;
00129   }
00130 
00131 Double_t RooStats::NumberCountingUtils::BinomialWithTauExpZ(Double_t signalExp, Double_t backgroundExp, Double_t tau){
00132   // See BinomialWithTauExpP
00133   return RooStats::PValueToSignificance( BinomialWithTauExpP(signalExp,backgroundExp,tau) ) ;
00134 }
00135 
00136 
00137 Double_t RooStats::NumberCountingUtils::BinomialObsZ(Double_t mainObs, Double_t backgroundObs, Double_t relativeBkgUncert){
00138   // See BinomialObsP
00139   return RooStats::PValueToSignificance( BinomialObsP(mainObs,backgroundObs,relativeBkgUncert) ) ;
00140 }
00141 
00142 Double_t RooStats::NumberCountingUtils::BinomialWithTauObsZ(Double_t mainObs, Double_t auxiliaryObs, Double_t tau){
00143   // See BinomialWithTauObsP
00144   return RooStats::PValueToSignificance( BinomialWithTauObsP(mainObs,auxiliaryObs,tau) ) ;  
00145 }

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