8 from TriggerMenuMT.L1.Base.BunchGroupSet
import BunchGroupSet
9 from TriggerMenuMT.L1.Base.L1MenuFlags
import L1MenuFlags
10 from AthenaCommon.Logging
import logging
11 log = logging.getLogger(
"generateBunchGroupSetFromOldKey")
13 L1MenuFlags.CTPVersion = 4
14 L1MenuFlags.BunchGroupPartitioning = [1, 15, 15]
16 default_bgsname =
"generateBunchGroupSetFromOldKey"
24 "UnpairedNonisolated",
38 newbgs = BunchGroupSet(bgsname)
39 for idx,bg
in enumerate(oldbgs):
40 newbg = BunchGroupSet.BunchGroup(name = bgnames[idx], internalNumber = idx)
44 newbgs.addBunchGroup(newbg)
50 print(
"Please run\n%s <old-style.json>\n" % sys.argv[0].
split(
'/')[-1])
51 print(
"The old-style json file can be downloaded from the web using https://atlas-trigconf.cern.ch/bunchgroups?key=<key>&type=json")
56 with open(inputFN)
as fn:
57 inputJson = json.load(fn)
59 oldBGS = inputJson[0][
'code']
61 if 'name' in inputJson[0]:
62 bgsname = inputJson[0][
'name'] +
" from Run2 key "
63 if 'bgkey' in inputJson[0]:
64 bgsname +=
str(inputJson[0][
'bgkey'])
66 bgsname = default_bgsname
68 if 'bgnames' in inputJson[0]:
69 bgnames = inputJson[0][
'bgnames']
71 for i
in range(len(bgnames)):
72 if bgnames[i].
find(
" - "):
73 bgnames[i] = bgnames[i].
split(
" - ", 1)[1]
75 bgnames = default_bgnames
79 outputFN = inputFN.replace(
".json",
".newstyle.json")
80 newBGS.writeJSON(outputFN)
84 if __name__ ==
"__main__":