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