forked from TaiSakuma/xi-roc-cafe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tbl_roc.py
executable file
·139 lines (108 loc) · 3.95 KB
/
tbl_roc.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#!/usr/bin/env python
# Tai Sakuma <[email protected]>
import os, sys
import argparse
import pandas as pd
import aggregate as ag
##__________________________________________________________________||
pd.set_option('display.max_columns', None)
pd.set_option('display.max_colwidth', 4096)
pd.set_option('display.max_rows', 65536)
pd.set_option('display.width', 1000)
##__________________________________________________________________||
parser = argparse.ArgumentParser()
parser.add_argument('--dir', default = 'tbl_002', help = 'path to the tbl dir')
args = parser.parse_args()
##__________________________________________________________________||
tbldir = args.dir
#
# load data frames
#
tbl_qcd_minOmegaTilde = ag.custom_pd_read_table(
os.path.join(tbldir, 'QCD', 'tbl_n_component.htbin.njetbin.mhtbin.minOmegaTilde.txt'),
dtype = dict(n = float, nvar = float)
)
# print tbl_qcd_minOmegaTilde.head()
# print tbl_qcd_minOmegaTilde.describe()
# print tbl_qcd_minOmegaTilde.dtypes
# print tbl_qcd_minOmegaTilde.component.cat.categories
tbl_qcd_xi = ag.custom_pd_read_table(
os.path.join(tbldir, 'QCD', 'tbl_n_component.htbin.njetbin.mhtbin.xi.txt'),
dtype = dict(n = float, nvar = float)
)
tbl_t1tttt_minOmegaTilde = ag.custom_pd_read_table(
os.path.join(tbldir, 'T1tttt', 'tbl_n_component.smsmass1.smsmass2.htbin.njetbin.mhtbin.minOmegaTilde.txt'),
dtype = dict(n = float, nvar = float)
)
tbl_t1tttt_xi = ag.custom_pd_read_table(
os.path.join(tbldir, 'T1tttt', 'tbl_n_component.smsmass1.smsmass2.htbin.njetbin.mhtbin.xi.txt'),
dtype = dict(n = float, nvar = float)
)
tbl_qcd_xsec = ag.custom_pd_read_table(
os.path.join(tbldir, 'QCD', 'tbl_xsec.txt'),
dtype = dict(xsec = float)
)
tbl_qcd_nevt = ag.custom_pd_read_table(
os.path.join(tbldir, 'QCD', 'tbl_nevt.txt'),
dtype = dict(nevt = float, nevt_sumw = float)
)
tbl_sm_component_process = ag.custom_pd_read_table(
os.path.join(tbldir, 'QCD', 'tbl_cfg_component_phasespace_process.txt')
)
#
# merge or split components (data sets) to processes
#
tbl_qcd_minOmegaTilde = ag.combine_mc_components(
tbl_qcd_minOmegaTilde, tbl_sm_component_process, tbl_qcd_nevt, tbl_qcd_xsec
)
tbl_qcd_xi = ag.combine_mc_components(
tbl_qcd_xi, tbl_sm_component_process, tbl_qcd_nevt, tbl_qcd_xsec
)
tbl_t1tttt_minOmegaTilde = ag.split_component_for_smsmass(tbl_t1tttt_minOmegaTilde)
tbl_t1tttt_xi = ag.split_component_for_smsmass(tbl_t1tttt_xi)
#
# sum over MHT bins
#
tbl_qcd_minOmegaTilde = ag.sum_over_categories(
tbl_qcd_minOmegaTilde, categories = ['mhtbin'], variables = ['n', 'nvar']
)
tbl_qcd_xi = ag.sum_over_categories(
tbl_qcd_xi, categories = ['mhtbin'], variables = ['n', 'nvar']
)
tbl_t1tttt_minOmegaTilde = ag.sum_over_categories(
tbl_t1tttt_minOmegaTilde, categories = ['mhtbin'], variables = ['n', 'nvar']
)
tbl_t1tttt_xi = ag.sum_over_categories(
tbl_t1tttt_xi, categories = ['mhtbin'], variables = ['n', 'nvar']
)
#
# calculate cumulative distributions and selection efficiencies
#
tbl_qcd_minOmegaTilde = ag.calculate_efficiency(
tbl_qcd_minOmegaTilde, varname = 'minOmegaTilde'
)
tbl_qcd_xi = ag.calculate_efficiency(
tbl_qcd_xi, varname = 'xi'
)
tbl_t1tttt_minOmegaTilde = ag.calculate_efficiency(
tbl_t1tttt_minOmegaTilde, varname = 'minOmegaTilde'
)
tbl_t1tttt_xi = ag.calculate_efficiency(
tbl_t1tttt_xi, varname = 'xi'
)
#
# create ROCs
#
tbl_minOmegaTilde = ag.rbind_tbls([tbl_qcd_minOmegaTilde, tbl_t1tttt_minOmegaTilde])
tbl_minOmegaTilde = ag.create_roc(tbl_minOmegaTilde, process1 = ['QCD'], varname = 'minOmegaTilde')
tbl_xi = ag.rbind_tbls([tbl_qcd_xi, tbl_t1tttt_xi])
tbl_xi = ag.create_roc(tbl_xi, process1 = ['QCD'], varname = 'xi')
#
# bind into one table
#
tbl_minOmegaTilde = ag.gather_var(tbl_minOmegaTilde, varname = 'minOmegaTilde')
tbl_xi = ag.gather_var(tbl_xi, varname = 'xi')
tbl_roc = ag.rbind_tbls([tbl_minOmegaTilde, tbl_xi])
#
print tbl_roc.to_string(index = False)
##__________________________________________________________________||