Skip to content
Snippets Groups Projects
Commit 6161aa0d authored by Tomasz Bold's avatar Tomasz Bold Committed by Adam Edward Barton
Browse files

Add simple part of json generation

parent 12e23aec
No related branches found
No related tags found
No related merge requests found
...@@ -8,7 +8,7 @@ from AthenaCommon.CFElements import parOR, seqOR, seqAND, stepSeq, findAlgorithm ...@@ -8,7 +8,7 @@ from AthenaCommon.CFElements import parOR, seqOR, seqAND, stepSeq, findAlgorithm
from AthenaCommon.AlgSequence import dumpMasterSequence from AthenaCommon.AlgSequence import dumpMasterSequence
from AthenaCommon.AppMgr import theApp from AthenaCommon.AppMgr import theApp
from TriggerMenuMT.HLTMenuConfig.Menu.LS2_v1_newJO import setupMenu
from AthenaCommon.Configurable import Configurable from AthenaCommon.Configurable import Configurable
Configurable.configurableRun3Behavior=1 Configurable.configurableRun3Behavior=1
...@@ -24,7 +24,7 @@ flags.Detector.GeometryCSC = True ...@@ -24,7 +24,7 @@ flags.Detector.GeometryCSC = True
flags.Detector.GeometryRPC = True flags.Detector.GeometryRPC = True
flags.Trigger.writeBS=True # switches on HLTResultMT creation flags.Trigger.writeBS=True # switches on HLTResultMT creation
exec("from TriggerMenuMT.HLTMenuConfig.Menu."+flags.Trigger.triggerMenuSetup +" import setupMenu")
flags.needFlagsCategory('Trigger') flags.needFlagsCategory('Trigger')
setupMenu(flags) setupMenu(flags)
......
...@@ -80,7 +80,7 @@ def createTriggerFlags(): ...@@ -80,7 +80,7 @@ def createTriggerFlags():
flags.addFlag('Trigger.triggerConfig', 'MCRECO:DEFAULT') flags.addFlag('Trigger.triggerConfig', 'MCRECO:DEFAULT')
# name of the trigger menu # name of the trigger menu
flags.addFlag('Trigger.triggerMenuSetup', 'Physics_pp_v7_primaries') flags.addFlag('Trigger.triggerMenuSetup', 'LS2_v1_newJO')
# version of the menu # version of the menu
from AthenaCommon.AppMgr import release_metadata from AthenaCommon.AppMgr import release_metadata
......
...@@ -167,7 +167,6 @@ class GenerateMenuMT(object): ...@@ -167,7 +167,6 @@ class GenerateMenuMT(object):
log.debug("Finished with retrieving chain configuration for chain %s", chain) log.debug("Finished with retrieving chain configuration for chain %s", chain)
self.triggerConfigHLT.allChainConfigs.append(chainConfig) self.triggerConfigHLT.allChainConfigs.append(chainConfig)
return self.triggerConfigHLT.allChainConfigs return self.triggerConfigHLT.allChainConfigs
...@@ -338,5 +337,9 @@ class GenerateMenuMT(object): ...@@ -338,5 +337,9 @@ class GenerateMenuMT(object):
makeHLTTree(HLTChains=finalListOfChainConfigs, newJO=False, triggerConfigHLT = self.triggerConfigHLT) makeHLTTree(HLTChains=finalListOfChainConfigs, newJO=False, triggerConfigHLT = self.triggerConfigHLT)
# the return values used for debugging, might be removed later # the return values used for debugging, might be removed later
from TriggerMenuMT.HLTMenuConfig.Menu.HLTMenuJSON import generateJSON
generateJSON( None )
return finalListOfChainConfigs return finalListOfChainConfigs
...@@ -94,6 +94,11 @@ def generateMenu( flags ): ...@@ -94,6 +94,11 @@ def generateMenu( flags ):
_log.info('CF is built') _log.info('CF is built')
# # generate JOSON representation of the config
from TriggerMenuMT.HLTMenuConfig.Menu.HLTMenuJSON import generateJSON_newJO
generateJSON_newJO( None )
return menuAcc return menuAcc
# 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 )
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment