23 parser = OptionParser(usage=
"usage: %prog [options] smk")
25 parser.add_option(
"-v",
"--verbose",
26 action =
"store_true",
29 help=
"verbose output [default: %default]")
31 actions = OptionGroup(parser,
"actions")
33 actions.add_option(
"",
38 help =
"Level 1 prescale key PSK for L1 prescale set to convert" )
40 actions.add_option(
"",
46 help =
"HLT prescale key PSK for HLT prescale set to convert" )
48 actions.add_option(
"",
51 action =
"store_true",
53 help =
"only prints prescale keys attached to SMK [default: %default]" )
55 parser.add_option_group(actions)
57 parser.add_option(
"",
60 default =
"TRIGGERDB",
61 help =
"database alias TRIGGERDB|TRIGGERDBREPR|TRIGGERDBMC [default: %default]" )
64 (options, args) = parser.parse_args()
67 parser.error(
"Please specify the SMK")
72 parser.error(
"SMK must be an integer")
75 if not (options.l1psk
or options.hltpsk
or options.showpsk):
77 parser.error(
"Please specify one of the actions")
80 with Silence(options.verbose):
81 from TrigConfigSvc.TrigConfigSvcUtils
import getHLTPrescalesFromSMK
83 print(
"Trigger keys connected to SM %i are %r" % (smk, [
int(k[0])
for k
in hltpsk]))
87 with Silence(options.verbose):
88 from TrigConfigSvc.TrigConfigSvcUtils
import queryHLTPrescaleTableRun2
91 from collections
import defaultdict
92 d = defaultdict(
lambda :
list())
95 d[(
int(e[1]),e[0])] += [ (e[2],e[4]) ]
99 for (chainID, chainName),prescales
in sorted(d.items()):
101 entry[
'chainId'] = chainID
102 entry[
'chainName'] =chainName
103 entry.update(prescales)
104 prescaleSet.append( entry )
107 filename =
"HLTPrescales_smk%i_psk%i.json" % (smk, options.hltpsk)
108 FH =
open(filename,
"w")
109 json.dump(prescaleSet, FH, indent=4, separators=(
',',
': '))
111 print(
"Wrote file %s" % filename)
114 with Silence(options.verbose):
115 from TrigConfigSvc.TrigConfigSvcUtils
import queryHLTPrescaleTableRun2
118 from collections
import defaultdict
119 d = defaultdict(
lambda :
list())
122 d[(
int(e[1]),e[0])] += [ (e[2],e[4]) ]
126 for (chainID, chainName),prescales
in sorted(d.items()):
128 entry[
'chainId'] = chainID
129 entry[
'chainName'] =chainName
130 entry.update(prescales)
131 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)