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