diff --git a/Trigger/TriggerCommon/TriggerMenuMT/CMakeLists.txt b/Trigger/TriggerCommon/TriggerMenuMT/CMakeLists.txt index 30eb25f176178ce758b0f84b881158719e49ad0c..4ce4f91ce383c7c194ab6a7c0ad8d12337d9c84a 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/CMakeLists.txt +++ b/Trigger/TriggerCommon/TriggerMenuMT/CMakeLists.txt @@ -113,7 +113,8 @@ atlas_install_scripts( scripts/generateMenuMT.py scripts/trigCompareOldandNewL1Menus.py scripts/trigL1MenuMigrationCheck.sh scripts/verify_menu_config.py - scripts/test_full_menu_cf.py ) + scripts/test_full_menu_cf.py + scripts/generateBunchGroupSetFromOldKey.py ) atlas_install_joboptions( share/*.py ) atlas_install_xmls( data/*.dtd data/*.xml ) diff --git a/Trigger/TriggerCommon/TriggerMenuMT/scripts/generateBunchGroupSetFromOldKey.py b/Trigger/TriggerCommon/TriggerMenuMT/scripts/generateBunchGroupSetFromOldKey.py new file mode 100755 index 0000000000000000000000000000000000000000..eeb1ed0ec6f7a9d047f8212cc5c06dcee8a20a12 --- /dev/null +++ b/Trigger/TriggerCommon/TriggerMenuMT/scripts/generateBunchGroupSetFromOldKey.py @@ -0,0 +1,69 @@ +#!/usr/bin/env python + +# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + +import sys +import json + +from TriggerMenuMT.L1.Base.BunchGroupSet import BunchGroupSet +from TriggerMenuMT.L1.Base.L1MenuFlags import L1MenuFlags +from AthenaCommon.Logging import logging +log = logging.getLogger("generateBunchGroupSetFromOldKey") + +L1MenuFlags.CTPVersion = 4 +L1MenuFlags.BunchGroupPartitioning = [1, 15, 15] + +bgsname = "All_FilledEmpty_expCalreq" + +bgnames = [ + "BCRVETO", + "Filled", + "Calreq", + "Empty", + "UnpairedIsolated", + "UnpairedNonisolated", + "EmptyAfterFilled", + "Unpaired", + "NotUsed", + "NotUsed", + "NotUsed", + "NotUsed", + "NotUsed", + "NotUsed", + "NotUsed", + "NotUsed" +] + +def transform2(oldbgs): + newbgs = BunchGroupSet(bgsname) + for idx,bg in enumerate(oldbgs): + newbg = BunchGroupSet.BunchGroup(name = bgnames[idx], internalNumber = idx) + for b in bg: + newbg.addBunch(b) + newbg.normalize() + newbgs.addBunchGroup(newbg) + return newbgs + +def main(): + + if len(sys.argv)<2: + print("Please run\n%s <old-style.json>\n" % sys.argv[0].split('/')[-1]) # noqa: ATL901 + print("The old-style json file can be downloaded from the web using https://atlas-trigconf.cern.ch/bunchgroups?key=<key>&type=json") # noqa: ATL901 + return 1 + + inputFN = sys.argv[1] + + with open(inputFN) as fp: + oldBGS = json.load(fp)[0]['code'] + newBGS = transform2(oldBGS) + + outputFN = inputFN.replace(".json",".newstyle.json") + newBGS.writeJSON(outputFN) + + + +if __name__ == "__main__": + sys.exit(main()) + + +