ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
rs_numbercountingutils.C
Go to the documentation of this file.
1 /////////////////////////////////////////////////////////////////////////
2 //
3 // 'Number Counting Utils' RooStats tutorial
4 // author: Kyle Cranmer
5 // date June. 2009
6 //
7 // This tutorial shows an example of the RooStats standalone
8 // utilities that calculate the p-value or Z value (eg. significance in
9 // 1-sided Gaussian standard deviations) for a number counting experiment.
10 // This is a hypothesis test between background only and signal-plus-background.
11 // The background estimate has uncertainty derived from an auxiliary or sideband
12 // measurement.
13 //
14 // Documentation for these utilities can be found here:
15 // http://root.cern.ch/root/html/RooStats__NumberCountingUtils.html
16 //
17 //
18 // This problem is often called a proto-type problem for high energy physics.
19 // In some references it is referred to as the on/off problem.
20 //
21 // The problem is treated in a fully frequentist fashion by
22 // interpreting the relative background uncertainty as
23 // being due to an auxiliary or sideband observation
24 // that is also Poisson distributed with only background.
25 // Finally, one considers the test as a ratio of Poisson means
26 // where an interval is well known based on the conditioning on the total
27 // number of events and the binomial distribution.
28 // For more on this, see
29 // http://arxiv.org/abs/0905.3831
30 // http://arxiv.org/abs/physics/physics/0702156
31 // http://arxiv.org/abs/physics/0511028
32 //
33 /////////////////////////////////////////////////////////////////////////
34 
35 
36 #ifndef __CINT__
37 // you need to include this for compiled macro.
38 // But for CINT, it needs to be in this ifndef/endif condition
40 #include "RooGlobalFunc.h"
41 #endif
42 
43 #include "RooStats/RooStatsUtils.h"
44 
45 #include <iostream>
46 
47 using namespace RooFit;
48 using namespace RooStats ; // the utilities are in the RooStats namespace
49 using namespace std ;
50 
52 {
53 
54  // From the root prompt, you can see the full list of functions by using tab-completion
55 
56  // root [0] RooStats::NumberCountingUtils:: <tab>
57  // BinomialExpZ
58  // BinomialWithTauExpZ
59  // BinomialObsZ
60  // BinomialWithTauObsZ
61  // BinomialExpP
62  // BinomialWithTauExpP
63  // BinomialObsP
64  // BinomialWithTauObsP
65 
66  // For each of the utilities you can inspect the arguments by tab completion
67 
68  //root [1] NumberCountingUtils::BinomialExpZ( <tab>
69  //Double_t BinomialExpZ(Double_t sExp, Double_t bExp, Double_t fractionalBUncertainty)
70 
71  /////////////////////////////////////////////////////
72  // Here we see common usages where the experimenter
73  // has a relative background uncertainty, without
74  // explicit reference to the auxiliary or sideband
75  // measurement
76 
77  /////////////////////////////////////////////////////
78  // Expected p-values and significance with background uncertainty
79  ////////////////////////////////////////////////////
80  double sExpected = 50;
81  double bExpected = 100;
82  double relativeBkgUncert = 0.1;
83 
84  double pExp = NumberCountingUtils::BinomialExpP(sExpected, bExpected, relativeBkgUncert);
85  double zExp = NumberCountingUtils::BinomialExpZ(sExpected, bExpected, relativeBkgUncert);
86  cout << "expected p-value ="<< pExp << " Z value (Gaussian sigma) = "<< zExp << endl;
87 
88  /////////////////////////////////////////////////////
89  // Expected p-values and significance with background uncertainty
90  ////////////////////////////////////////////////////
91  double observed = 150;
92  double pObs = NumberCountingUtils::BinomialObsP(observed, bExpected, relativeBkgUncert);
93  double zObs = NumberCountingUtils::BinomialObsZ(observed, bExpected, relativeBkgUncert);
94  cout << "observed p-value ="<< pObs << " Z value (Gaussian sigma) = "<< zObs << endl;
95 
96 
97  /////////////////////////////////////////////////////
98  // Here we see usages where the experimenter has knowledge
99  // about the properties of the auxiliary or sideband
100  // measurement. In particular, the ratio tau of background
101  // in the auxiliary measurement to the main measurement.
102  // Large values of tau mean small background uncertainty
103  // because the sideband is very constraining.
104 
105  // Usage:
106  // root [0] RooStats::NumberCountingUtils::BinomialWithTauExpP(
107  // Double_t BinomialWithTauExpP(Double_t sExp, Double_t bExp, Double_t tau)
108 
109 
110  /////////////////////////////////////////////////////
111  // Expected p-values and significance with background uncertainty
112  ////////////////////////////////////////////////////
113  double tau = 1;
114 
115  double pExpWithTau = NumberCountingUtils::BinomialWithTauExpP(sExpected, bExpected, tau);
116  double zExpWithTau = NumberCountingUtils::BinomialWithTauExpZ(sExpected, bExpected, tau);
117  cout << "expected p-value ="<< pExpWithTau << " Z value (Gaussian sigma) = "<< zExpWithTau << endl;
118 
119  /////////////////////////////////////////////////////
120  // Expected p-values and significance with background uncertainty
121  ////////////////////////////////////////////////////
122  double pObsWithTau = NumberCountingUtils::BinomialWithTauObsP(observed, bExpected, tau);
123  double zObsWithTau = NumberCountingUtils::BinomialWithTauObsZ(observed, bExpected, tau);
124  cout << "observed p-value ="<< pObsWithTau << " Z value (Gaussian sigma) = "<< zObsWithTau << endl;
125 
126 }
Double_t BinomialWithTauObsP(Double_t nObs, Double_t bExp, Double_t tau)
Double_t BinomialObsP(Double_t nObs, Double_t, Double_t fractionalBUncertainty)
Double_t BinomialWithTauObsZ(Double_t nObs, Double_t bExp, Double_t tau)
Double_t BinomialExpZ(Double_t sExp, Double_t bExp, Double_t fractionalBUncertainty)
Double_t BinomialExpP(Double_t sExp, Double_t bExp, Double_t fractionalBUncertainty)
Double_t BinomialWithTauExpP(Double_t sExp, Double_t bExp, Double_t tau)
void rs_numbercountingutils()
Double_t BinomialObsZ(Double_t nObs, Double_t bExp, Double_t fractionalBUncertainty)
Double_t BinomialWithTauExpZ(Double_t sExp, Double_t bExp, Double_t tau)