rs_numbercountingutils.C

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////
00002 //
00003 // 'Number Counting Utils' RooStats tutorial 
00004 // author: Kyle Cranmer
00005 // date June. 2009 
00006 //
00007 // This tutorial shows an example of the RooStats standalone 
00008 // utilities that calculate the p-value or Z value (eg. significance in
00009 // 1-sided Gaussian standard deviations) for a number counting experiment.
00010 // This is a hypothesis test between background only and signal-plus-background.
00011 // The background estimate has uncertainty derived from an auxiliary or sideband
00012 // measurement.
00013 //
00014 // Documentation for these utilities can be found here:
00015 // http://root.cern.ch/root/html/RooStats__NumberCountingUtils.html
00016 //
00017 //
00018 // This problem is often called a proto-type problem for high energy physics.
00019 // In some references it is referred to as the on/off problem.
00020 //
00021 // The problem is treated in a fully frequentist fashion by 
00022 // interpreting the relative background uncertainty as
00023 // being due to an auxiliary or sideband observation 
00024 // that is also Poisson distributed with only background.
00025 // Finally, one considers the test as a ratio of Poisson means
00026 // where an interval is well known based on the conditioning on the total
00027 // number of events and the binomial distribution.
00028 // For more on this, see
00029 //  http://arxiv.org/abs/0905.3831
00030 //  http://arxiv.org/abs/physics/physics/0702156
00031 //  http://arxiv.org/abs/physics/0511028
00032 //
00033 /////////////////////////////////////////////////////////////////////////
00034 
00035 
00036 #ifndef __CINT__
00037 // you need to include this for compiled macro.
00038 // But for CINT, it needs to be in this ifndef/endif condition
00039 #include "RooStats/NumberCountingUtils.h"
00040 #include "RooGlobalFunc.h"
00041 #endif
00042 
00043 #include "RooStats/RooStatsUtils.h"
00044 
00045 #include <iostream>
00046 
00047 using namespace RooFit;
00048 using namespace RooStats ; // the utilities are in the RooStats namespace
00049 using namespace std ;
00050 
00051 void rs_numbercountingutils()
00052 {
00053   
00054   // From the root prompt, you can see the full list of functions by using tab-completion
00055   
00056   // root [0] RooStats::NumberCountingUtils::  <tab>
00057   // BinomialExpZ
00058   // BinomialWithTauExpZ
00059   // BinomialObsZ
00060   // BinomialWithTauObsZ
00061   // BinomialExpP
00062   // BinomialWithTauExpP
00063   // BinomialObsP
00064   // BinomialWithTauObsP
00065 
00066   // For each of the utilities you can inspect the arguments by tab completion
00067 
00068   //root [1] NumberCountingUtils::BinomialExpZ( <tab>
00069   //Double_t BinomialExpZ(Double_t sExp, Double_t bExp, Double_t fractionalBUncertainty)
00070 
00071   /////////////////////////////////////////////////////
00072   // Here we see common usages where the experimenter
00073   // has a relative background uncertainty, without
00074   // explicit reference to the auxiliary or sideband
00075   // measurement
00076 
00077   /////////////////////////////////////////////////////
00078   // Expected p-values and significance with background uncertainty
00079   ////////////////////////////////////////////////////
00080   double sExpected = 50;
00081   double bExpected = 100;
00082   double relativeBkgUncert = 0.1;
00083 
00084   double pExp = NumberCountingUtils::BinomialExpP(sExpected, bExpected, relativeBkgUncert);
00085   double zExp = NumberCountingUtils::BinomialExpZ(sExpected, bExpected, relativeBkgUncert);
00086   cout << "expected p-value ="<< pExp << "  Z value (Gaussian sigma) = "<< zExp << endl;
00087 
00088   /////////////////////////////////////////////////////
00089   // Expected p-values and significance with background uncertainty
00090   ////////////////////////////////////////////////////
00091   double observed = 150;
00092   double pObs = NumberCountingUtils::BinomialObsP(observed, bExpected, relativeBkgUncert);
00093   double zObs = NumberCountingUtils::BinomialObsZ(observed, bExpected, relativeBkgUncert);
00094   cout << "observed p-value ="<< pObs << "  Z value (Gaussian sigma) = "<< zObs << endl;
00095 
00096 
00097   /////////////////////////////////////////////////////
00098   // Here we see usages where the experimenter has knowledge
00099   // about the properties of the auxiliary or sideband
00100   // measurement.  In particular, the ratio tau of background
00101   // in the auxiliary measurement to the main measurement.
00102   // Large values of tau mean small background uncertainty
00103   // because the sideband is very constraining.
00104   
00105   // Usage:
00106   // root [0] RooStats::NumberCountingUtils::BinomialWithTauExpP( 
00107   // Double_t BinomialWithTauExpP(Double_t sExp, Double_t bExp, Double_t tau)
00108 
00109 
00110   /////////////////////////////////////////////////////
00111   // Expected p-values and significance with background uncertainty
00112   ////////////////////////////////////////////////////
00113   double tau = 1;
00114 
00115   double pExpWithTau = NumberCountingUtils::BinomialWithTauExpP(sExpected, bExpected, tau);
00116   double zExpWithTau = NumberCountingUtils::BinomialWithTauExpZ(sExpected, bExpected, tau);
00117   cout << "expected p-value ="<< pExpWithTau << "  Z value (Gaussian sigma) = "<< zExpWithTau << endl;
00118 
00119   /////////////////////////////////////////////////////
00120   // Expected p-values and significance with background uncertainty
00121   ////////////////////////////////////////////////////
00122   double pObsWithTau = NumberCountingUtils::BinomialWithTauObsP(observed, bExpected, tau);
00123   double zObsWithTau = NumberCountingUtils::BinomialWithTauObsZ(observed, bExpected, tau);
00124   cout << "observed p-value ="<< pObsWithTau << "  Z value (Gaussian sigma) = "<< zObsWithTau << endl;
00125 
00126 }

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