forked from elaird/hcalraw
/
oneRun.py
executable file
·94 lines (74 loc) · 2.89 KB
/
oneRun.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
#!/usr/bin/env python
import analyze
import printer
import graphs
import sys
from configuration import sw, matching
from options import opts
def subset(options, l, process=False, invert=False):
assert not (process and invert)
out = {}
for item in l:
value = getattr(options, item)
if process:
out[item] = sw.fedList(value)
elif invert:
# "noFoo": True --> "foo": False
out[item[2].lower() + item[3:]] = not value
else:
out[item] = value
return out
def check_and_adjust(options):
if not all([options.file1, options.feds1]):
sys.exit("--file1 and --feds1 are required (see './oneRun.py --help').")
if not options.outputFile.endswith(".root"):
sys.exit("--output-file must end with .root (%s)" % options.outputFile)
if 0 <= options.sparseLoop:
if options.file2:
sys.exit("--sparse-loop does not work with --file2")
if options.nEventsSkip:
sys.exit("--sparse-loop does not work with --nevents-skip")
if options.feds2 and (not options.file2) and (not options.noLoop):
# print "INFO: using --file1 also for --file2; also using identity map"
options.file2 = options.file1
options.identityMap = True
if options.patterns:
printer.info("setting nEvents=1 (--patterns was passed)")
options.nEvents = 1
def go(options):
kargs = subset(options, ["feds1", "feds2"], process=True)
kargs.update(subset(options, ["nEvents", "nEventsSkip", "outputFile", "noUnpack", "patterns", "sparseLoop"]))
kargs["compareOptions"] = subset(options, ["anyEmap", "printEmap"])
kargs["mapOptions"] = subset(options, ["printEventMap", "identityMap"])
kargs["printOptions"] = subset(options, ["dump", "progress"])
kargs["printOptions"].update(subset(options, ["noWarnUnpack", "noWarnQuality"], invert=True))
kargs["printOptions"]["crateslots"] = sw.fedList(options.crateslots)
for iFile in [1, 2]:
value = getattr(options, "file%d" % iFile)
if value:
kargs["files%d" % iFile] = value.split(",")
return analyze.oneRun(**kargs)
def main(options):
check_and_adjust(options)
matching.__okErrF = sw.fedList(options.okErrF)
matching.__utcaBcnDelta = options.utcaBcnDelta
matching.__utcaPipelineDelta = options.utcaPipelineDelta
if options.noColor:
printer.__color = False
if options.noLoop:
goCode = 0
else:
analyze.setup()
if options.profile:
import cProfile
cProfile.runctx("go(options)", globals(), locals(), sort="time")
goCode = 0 # FIXME
else:
goCode = go(options)
if options.feds2 and 0 <= options.dump:
analyze.printChannelSummary(options.outputFile)
if not options.noPlot:
graphs.main(options)
return goCode
if __name__ == "__main__":
main(opts()[0])