Skip to content

Commit

Permalink
Update datacards and scripts for tutorial
Browse files Browse the repository at this point in the history
  • Loading branch information
kcormi committed Jun 24, 2024
1 parent cfe5f5e commit 33f4d1c
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
imax 1 # number of channels
jmax 1 # number of backgrounds
kmax 3 # number of nuisance parameters
-------
shapes * * FAKE
------
bin bin1
observation 0
-----
bin bin1 bin1
process ggH WW
process 0 1
rate 2.3 1
-------
lumi lnN 1.01 1.01 # luminosity uncertainty
xs_ggH lnN 1.10 - # gg->H cross section + signal efficiency + other minor ones
xs_WW lnN - 1.16 # WW cross section + signal efficiency + other minor ones
17 changes: 17 additions & 0 deletions data/tutorials/statistical_routines_tutorial/datacard_obs12.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
imax 1 # number of channels
jmax 1 # number of backgrounds
kmax 3 # number of nuisance parameters
-------
shapes * * FAKE
------
bin bin1
observation 12
-----
bin bin1 bin1
process ggH WW
process 0 1
rate 2.3 5.4
-------
lumi lnN 1.01 1.01 # luminosity uncertainty
xs_ggH lnN 1.10 - # gg->H cross section + signal efficiency + other minor ones
xs_WW lnN - 1.16 # WW cross section + signal efficiency + other minor ones
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
imax 1 # number of channels
jmax 1 # number of backgrounds
kmax 3 # number of nuisance parameters
-------
shapes * * FAKE
------
bin bin1
observation 13
-----
bin bin1 bin1
process ggH WW
process 0 1
rate 2.3 23.4
-------
lumi lnN 1.01 1.01 # luminosity uncertainty
xs_ggH lnN 1.10 - # gg->H cross section + signal efficiency + other minor ones
xs_WW lnN - 1.16 # WW cross section + signal efficiency + other minor ones
41 changes: 41 additions & 0 deletions data/tutorials/statistical_routines_tutorial/get_quantile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
from ROOT import TFile
import numpy as np
import scipy.stats as st

from argparse import ArgumentParser

parser = ArgumentParser()
parser.add_argument('--input', default="higgsCombineTest.MultiDimFit.mH120.123456.root", help='input root file with toy results from MultiDimFit')
parser.add_argument('--q0', action='store_true', help='use the q_0 test statistic rather than the profile likelihood ratio.')
args = parser.parse_args()

n_sigma = 1
quantile_val = 2*st.norm().cdf(-n_sigma) #Get the quantile corresponding to the N sigma interval



f = TFile(args.input,"READ")
limit = f.Get("limit")
n_entries = limit.GetEntries()

m2nll_vals = []
r_vals = []
last_toy_num = -1
for i in range(n_entries):
limit.GetEntry(i)
if limit.quantileExpected < 0:
if args.q0:
r_vals.append(limit.r)
continue

m2nll_vals.append(2*limit.deltaNLL)


test_stat_vals = m2nll_vals
if args.q0:
test_stat_vals = np.where( np.array(r_vals) > 0, test_stat_vals, 0 )

test_stat_cutoff = np.quantile( test_stat_vals, 1-quantile_val)
t_stat_name = 'q0' if args.q0 else '-2*deltaNLL'
print(f'This point is rejected at the {n_sigma} sigma level if the test stat {t_stat_name} > {test_stat_cutoff}')

0 comments on commit 33f4d1c

Please sign in to comment.