forked from boundino/omstools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hltrunsummary.py
57 lines (50 loc) · 2.28 KB
/
hltrunsummary.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
import json
import argparse
import sys
import util.oms as o
import util.utility as u
if __name__ == "__main__":
parser = argparse.ArgumentParser(description = 'Print HLT summary of a given run')
parser.add_argument('--run', required = True, help = 'one run number')
parser.add_argument('--outcsv', required = False, help = 'Optional csv output file')
args = parser.parse_args()
run = args.run
rundetails = o.get_run_info(run, verbose = True)
if not rundetails: sys.exit()
hltconfig = o.get_hltconfig_info(rundetails["attributes"]["hlt_key"])
if not hltconfig: sys.exit()
q = o.omsapi.query("hltpathinfo")
q.paginate(per_page = 1000)
q.set_verbose(False)
q.filter("run_number", run)
data = q.data().json()["data"]
outputfile = u.setoutput(args.outcsv, 'outcsv/hltrunsummary.csv')
results = []
maxlen = 0
with open(outputfile, 'w') as f:
print("HLT Path, L1 seed, Rate (Hz), L1 Pass, PS Pass, Accepted", file = f)
for d in data:
attr = d["attributes"]
# if "HLT_" not in attr["path_name"]:
# continue
config = o.get_item_data(hltconfig, "path_name", attr["path_name"])
ele = { "path" : attr["path_name"],
"l1_prerequisite" : config["attributes"]["l1_prerequisite"],
"rate" : str(attr["rate"]),
"l1_pass" : str(attr["l1_pass"]),
"ps_pass" : str(attr["ps_pass"]),
"accepted" : str(attr["accepted"]),
}
if len(ele["path"]) > maxlen: maxlen = len(ele["path"])
for e in ele:
print(u.mystr(ele[e]) + ", ", end = "", file = f)
print("", file = f)
results.append(ele)
nl = 115 + maxlen
print('-' * nl)
print('| {:<{width}} |{:>15} |{:>15} |{:>10} |{:>10} | {:<50} |'.format("HLT Path", "Rate (Hz)", "L1 Pass", "PS Pass", "Accepted", "L1 seed", width = maxlen))
print('-' * nl)
for rr in results:
print('| {:<{width}} |{:>15} |{:>15} |{:>10} |{:>10} | {:<50} |'.format(u.mystr(rr["path"]), u.mystr(rr["rate"]), u.mystr(rr["l1_pass"]), u.mystr(rr["ps_pass"]), u.mystr(rr["accepted"]), u.mystr(rr["l1_prerequisite"]), width = maxlen))
print('-' * nl)
print()