21 parser = OptionParser(usage=
"usage: %prog [options] smk")
23 parser.add_option(
"-v",
"--verbose",
24 action =
"store_true",
27 help=
"verbose output [default: %default]")
29 actions = OptionGroup(parser,
"actions")
31 actions.add_option(
"",
36 help =
"Level 1 prescale key PSK for L1 prescale set to convert" )
38 actions.add_option(
"",
44 help =
"HLT prescale key PSK for HLT prescale set to convert" )
46 actions.add_option(
"",
49 action =
"store_true",
51 help =
"only prints prescale keys attached to SMK [default: %default]" )
53 parser.add_option_group(actions)
55 parser.add_option(
"",
58 default =
"TRIGGERDB",
59 help =
"database alias TRIGGERDB|TRIGGERDBREPR|TRIGGERDBMC [default: %default]" )
62 (options, args) = parser.parse_args()
65 parser.error(
"Please specify the SMK")
70 parser.error(
"SMK must be an integer")
73 if not (options.l1psk
or options.hltpsk
or options.showpsk):
75 parser.error(
"Please specify one of the actions")
78 with Silence(options.verbose):
79 from TrigConfigSvc.TrigConfigSvcUtils
import getHLTPrescalesFromSMK
81 print(
"Trigger keys connected to SM %i are %r" % (smk, [
int(k[0])
for k
in hltpsk]))
85 with Silence(options.verbose):
86 from TrigConfigSvc.TrigConfigSvcUtils
import queryHLTPrescaleTableRun2
89 from collections
import defaultdict, OrderedDict
90 d = defaultdict(
lambda :
list())
93 d[(
int(e[1]),e[0])] += [ (e[2],e[4]) ]
97 for (chainID, chainName),prescales
in sorted(d.items()):
99 entry[
'chainId'] = chainID
100 entry[
'chainName'] =chainName
101 entry.update(prescales)
102 prescaleSet.append( entry )
106 filename =
"HLTPrescales_smk%i_psk%i.json" % (smk, options.hltpsk)
107 FH =
open(filename,
"w")
108 json.dump(prescaleSet, FH, indent=4, separators=(
',',
': '))
110 print(
"Wrote file %s" % filename)
113 with Silence(options.verbose):
114 from TrigConfigSvc.TrigConfigSvcUtils
import queryHLTPrescaleTableRun2
117 from collections
import defaultdict, OrderedDict
118 d = defaultdict(
lambda :
list())
121 d[(
int(e[1]),e[0])] += [ (e[2],e[4]) ]
125 for (chainID, chainName),prescales
in sorted(d.items()):
126 entry = OrderedDict()
127 entry[
'chainId'] = chainID
128 entry[
'chainName'] =chainName
129 entry.update(prescales)
130 prescaleSet.append( entry )
134 filename =
"HLTPrescales_smk%i_psk%i.json" % (smk, options.hltpsk)
135 FH =
open(filename,
"w")
136 json.dump(prescaleSet, FH, indent=4, separators=(
',',
': '))
138 print(
"Wrote file %s" % filename)