diff --git a/Trigger/TrigValidation/TrigUpgradeTest/share/newJOtest.py b/Trigger/TrigValidation/TrigUpgradeTest/share/newJOtest.py index 653314d3dd471bd35f402152b32a56ac8b812902..259180c9f4eb104ec5eb57138426f13a81a38901 100644 --- a/Trigger/TrigValidation/TrigUpgradeTest/share/newJOtest.py +++ b/Trigger/TrigValidation/TrigUpgradeTest/share/newJOtest.py @@ -8,7 +8,7 @@ from AthenaCommon.CFElements import parOR, seqOR, seqAND, stepSeq, findAlgorithm from AthenaCommon.AlgSequence import dumpMasterSequence from AthenaCommon.AppMgr import theApp -from TriggerMenuMT.HLTMenuConfig.Menu.LS2_v1_newJO import setupMenu + from AthenaCommon.Configurable import Configurable Configurable.configurableRun3Behavior=1 @@ -24,7 +24,7 @@ flags.Detector.GeometryCSC = True flags.Detector.GeometryRPC = True flags.Trigger.writeBS=True # switches on HLTResultMT creation - +exec("from TriggerMenuMT.HLTMenuConfig.Menu."+flags.Trigger.triggerMenuSetup +" import setupMenu") flags.needFlagsCategory('Trigger') setupMenu(flags) diff --git a/Trigger/TriggerCommon/TriggerJobOpts/python/TriggerConfigFlags.py b/Trigger/TriggerCommon/TriggerJobOpts/python/TriggerConfigFlags.py index 39fb028a92470576ff756ef32fab1ad23da86362..ef313a5785797dc6fc01ca1f4a99998a42928143 100644 --- a/Trigger/TriggerCommon/TriggerJobOpts/python/TriggerConfigFlags.py +++ b/Trigger/TriggerCommon/TriggerJobOpts/python/TriggerConfigFlags.py @@ -80,7 +80,7 @@ def createTriggerFlags(): flags.addFlag('Trigger.triggerConfig', 'MCRECO:DEFAULT') # name of the trigger menu - flags.addFlag('Trigger.triggerMenuSetup', 'Physics_pp_v7_primaries') + flags.addFlag('Trigger.triggerMenuSetup', 'LS2_v1_newJO') # version of the menu from AthenaCommon.AppMgr import release_metadata diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/GenerateMenuMT.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/GenerateMenuMT.py index 2f1a19e8d45f315934ade6ecb2354989058a223f..565e64e4ba010f46141ebe44f2466e8fd89edf9f 100755 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/GenerateMenuMT.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/GenerateMenuMT.py @@ -167,7 +167,6 @@ class GenerateMenuMT(object): log.debug("Finished with retrieving chain configuration for chain %s", chain) self.triggerConfigHLT.allChainConfigs.append(chainConfig) - return self.triggerConfigHLT.allChainConfigs @@ -338,5 +337,9 @@ class GenerateMenuMT(object): makeHLTTree(HLTChains=finalListOfChainConfigs, newJO=False, triggerConfigHLT = self.triggerConfigHLT) # the return values used for debugging, might be removed later + + from TriggerMenuMT.HLTMenuConfig.Menu.HLTMenuJSON import generateJSON + generateJSON( None ) + return finalListOfChainConfigs diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/GenerateMenuMT_newJO.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/GenerateMenuMT_newJO.py index 197ecd8d873ae1a261411979f5652529beea848a..455d71bcbed9e5ea5f9a59ae0e5d846646d53722 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/GenerateMenuMT_newJO.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/GenerateMenuMT_newJO.py @@ -94,6 +94,11 @@ def generateMenu( flags ): _log.info('CF is built') + + # # generate JOSON representation of the config + from TriggerMenuMT.HLTMenuConfig.Menu.HLTMenuJSON import generateJSON_newJO + generateJSON_newJO( None ) + return menuAcc diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/HLTMenuJSON.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/HLTMenuJSON.py new file mode 100644 index 0000000000000000000000000000000000000000..c39a189056f72d309f8614c129979e66b9dd1fc0 --- /dev/null +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/HLTMenuJSON.py @@ -0,0 +1,60 @@ +# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + +from AthenaCommon.Logging import logging +__log = logging.getLogger( 'HLTMenuJSON.py' ) + + +def __generateJSON( chainDicts, sequences, menuName ): + """ Generates JSON given the ChainProps and sequences + """ + menuDict = { "name":menuName , "chains":[] } + counter = 0 + + for chain in chainDicts: + + streamDicts = [ { "obeyLB": "yes", "prescale":"1", "name":sn, "type":"physics" } + for sn in chain["stream"]] + + # l1 threshold require a bit of parsing for now, TODO revisit once L1 thresholds available in the chainDicts + # the logic is: break the item name into pieces by "_", removing the prefix L1, then remove any multiplicity that is in front of each fragment + l1Thresholds = [ t.lstrip( '23456789') for t in chain["L1item"].split("_", 1)[-1].split("_")] + + chainDict = { "counter": counter, + "name": chain["chainName"], + "l1item": chain["L1item"], + "l1thresholds": l1Thresholds, + "groups": chain["groups"], + "streams": streamDicts } + menuDict["chains"].append( chainDict ) + counter += 1 + + __log.info( "Menu name:" + menuName ) + with open( menuName+'.json', 'w' ) as fp: + import json + json.dump( menuDict, fp, indent=4, sort_keys=True ) + + +def generateJSON( allStepsSequence ): + __log.info("Generating HLT JSON config in the rec-ex-common job") + from TriggerJobOpts.TriggerFlags import TriggerFlags + from TriggerMenuMT.HLTMenuConfig.Menu.TriggerConfigHLT import TriggerConfigHLT + triggerConfigHLT = TriggerConfigHLT.currentTriggerConfig() + return __generateJSON( triggerConfigHLT.allChainDicts, None, TriggerFlags.outputHLTconfigFile().replace( '.xml', '' ) ) + +def generateJSON_newJO( allStepsSequence ): + __log.info("Generating HLT JSON config in the new JO") + from AthenaConfiguration.AllConfigFlags import ConfigFlags + from TriggerMenuMT.HLTMenuConfig.Menu import DictFromChainName + + + decoder = DictFromChainName.DictFromChainName() + chainDicts = [] + #TODO, once we move to New JO, it is likely there will be a repository with all chains + #we shoudl switch to use it then + for name, cfgFlag in list( ConfigFlags._flagdict.iteritems() ): + if 'Trigger.menu.' in name: + for chain in ConfigFlags._get( name ): + chainDicts.append( decoder.getChainDict( chain ) ) + + import os + return __generateJSON( chainDicts, None, "HLTconfig_"+os.getenv( "AtlasVersion" ) + "." + ConfigFlags.Trigger.triggerMenuSetup )