-
Notifications
You must be signed in to change notification settings - Fork 1
/
spearmint_cuts.py
69 lines (55 loc) · 2.06 KB
/
spearmint_cuts.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# from analysis.mass_fitting import run_spearmint_fit, run_spearmint_sweights
from k3pi_utilities.helpers import quiet_mode
from analysis.bdt_studies import get_bdt_discriminant
from analysis import selection
from k3pi_config.modes import MODE
import numpy as np
def run_it(params):
quiet_mode(True)
# pid_cuts = ['min_pi_nnpi', 'max_pi_nnk', 'min_k_nnk', 'max_k_nnpi']
spi_cuts = ['min_spi_nnpi', 'max_spi_nnk', 'max_spi_nnghost', 'max_spi_nnp']
# pid_cut_values = {
# n: params[n][0] for n in pid_cuts
# }
spi_cut_values = {
n: params[n][0] for n in spi_cuts
}
# Get the signal stuff
with MODE('MagBoth', 1516, 'RS'):
signal = selection.mass_signal_region()
bdt = get_bdt_discriminant()
bdt_sel = bdt['comb_bkg_bdt'] > params['BDT_CUT'][0]
bdt_sel &= bdt['rand_spi_bdt'] > params['BDT_CUT2'][0]
spi = selection._apply_slow_pion_cut(**spi_cut_values)
sel = selection.full_selection()
supersel = bdt_sel & spi & sel
sig0 = float(signal[sel].sum())/300.
sig = float(signal[supersel].sum())/300.
# Get the Background stuff
with MODE('MagBoth', 1516, 'WS'):
background = selection.mass_sideband_region()
bdt = get_bdt_discriminant()
bdt_sel = bdt['comb_bkg_bdt'] > params['BDT_CUT'][0]
bdt_sel &= bdt['rand_spi_bdt'] > params['BDT_CUT2'][0]
spi = selection._apply_slow_pion_cut(**spi_cut_values)
sel = selection.full_selection()
supersel = bdt_sel & spi & sel
bkg = float(background[supersel].sum())/15.4
print 'sig0 =', sig0
print 'sig =', sig
print 'bkg =', bkg
ret = -(sig/sig0)/(0.5 + np.sqrt(bkg))
return ret
# return run_spearmint_fit(bdt & pid & spi)
def main(job_id, params):
return run_it(params)
if __name__ == '__main__':
params = {
'max_spi_nnp': [0.5],
'min_spi_nnpi': [0.300000],
'max_spi_nnghost': [0.050000],
'max_spi_nnk': [0.50000],
'BDT_CUT': [0.2000],
'BDT_CUT2': [0.4000],
}
print main(1, params)