diff --git a/Trigger/TrigValidation/TrigUpgradeTest/python/EmuStepProcessingConfig.py b/Trigger/TrigValidation/TrigUpgradeTest/python/EmuStepProcessingConfig.py index 086a72ccaf2479513ec5dd4d097c3bf36f78c0da..4ea9e7347d17907e22f9a165e73896e4f5eec4ef 100644 --- a/Trigger/TrigValidation/TrigUpgradeTest/python/EmuStepProcessingConfig.py +++ b/Trigger/TrigValidation/TrigUpgradeTest/python/EmuStepProcessingConfig.py @@ -74,10 +74,10 @@ def generateL1DecoderAndChains(): - from TrigUpgradeTest.TestUtils import writeEmulationFiles + from TrigUpgradeTest.TestUtils import writeEmulationFiles, makeChain writeEmulationFiles(data) - from TriggerMenuMT.HLTMenuConfig.Menu.MenuComponents import Chain, ChainStep + from TriggerMenuMT.HLTMenuConfig.Menu.MenuComponents import ChainStep doMuon=True @@ -115,11 +115,11 @@ def generateL1DecoderAndChains(): MuChains = [ - Chain(name='HLT_mu8_1step_L1MU6', L1Thresholds=["MU6"], ChainSteps=[step_mu11]), - Chain(name='HLT_mu20_L1MU10', L1Thresholds=["MU10"], ChainSteps=[step_mu11 , step_mu21 , step_mu31] ), - Chain(name='HLT_mu10_L1MU10', L1Thresholds=["MU10"], ChainSteps=[step_mu11 , step_mu22 , step_mu31] ), - Chain(name='HLT_mu8_L1MU10', L1Thresholds=["MU10"], ChainSteps=[step_mu11 , step_mu21 , step_mu32, step_mu41] ), - Chain(name='HLT_mu6_L1MU6', L1Thresholds=["MU6"], ChainSteps=[step_mu11 , step_empy , step_mu32, step_mu41] ), + makeChain(name='HLT_mu8_1step_L1MU6', L1Thresholds=["MU6"], ChainSteps=[step_mu11]), + makeChain(name='HLT_mu20_L1MU10', L1Thresholds=["MU10"], ChainSteps=[step_mu11 , step_mu21 , step_mu31] ), + makeChain(name='HLT_mu10_L1MU10', L1Thresholds=["MU10"], ChainSteps=[step_mu11 , step_mu22 , step_mu31] ), + makeChain(name='HLT_mu8_L1MU10', L1Thresholds=["MU10"], ChainSteps=[step_mu11 , step_mu21 , step_mu32, step_mu41] ), + makeChain(name='HLT_mu6_L1MU6', L1Thresholds=["MU6"], ChainSteps=[step_mu11 , step_empy , step_mu32, step_mu41] ), # Chain(name='HLT_mu6_1step_L1MU6', L1Item="L1_MU6", ChainSteps=[step_mu11 , step_empy , step_mu31]), # Chain(name='HLT_2mu6_L12MU6', L1Item="L1_2MU6", ChainSteps=[ChainStep("Step_2muSA", [muSA,muSA]) ] ) ] @@ -142,11 +142,11 @@ def generateL1DecoderAndChains(): ElChains = [ - Chain(name='HLT_e5_L1EM7' , L1Thresholds=["EM7"], ChainSteps=[ ChainStep("Step_em11", [el11]), ChainStep("Step_em21", [el21]) ] ), - Chain(name='HLT_e5_v2_L1EM7', L1Thresholds=["EM7"], ChainSteps=[ ChainStep("Step_em11", [el11]), ChainStep("Step_em22", [el22]) ] ), - Chain(name='HLT_e5_v3_L1EM7', L1Thresholds=["EM7"], ChainSteps=[ ChainStep("Step_em11", [el11]), ChainStep("Step_em23", [el23]) ] ), - Chain(name='HLT_e8_L1EM7' , L1Thresholds=["EM7"], ChainSteps=[ ChainStep("Step_em11", [el11]), ChainStep("Step_em21", [el21]), ChainStep("Step_em31", [el31]) ] ), - Chain(name='HLT_g5_L1EM7' , L1Thresholds=["EM7"], ChainSteps=[ ChainStep("Step_gam11", [gamm11]) ] ) + makeChain(name='HLT_e5_L1EM7' , L1Thresholds=["EM7"], ChainSteps=[ ChainStep("Step_em11", [el11]), ChainStep("Step_em21", [el21]) ] ), + makeChain(name='HLT_e5_v2_L1EM7', L1Thresholds=["EM7"], ChainSteps=[ ChainStep("Step_em11", [el11]), ChainStep("Step_em22", [el22]) ] ), + makeChain(name='HLT_e5_v3_L1EM7', L1Thresholds=["EM7"], ChainSteps=[ ChainStep("Step_em11", [el11]), ChainStep("Step_em23", [el23]) ] ), + makeChain(name='HLT_e8_L1EM7' , L1Thresholds=["EM7"], ChainSteps=[ ChainStep("Step_em11", [el11]), ChainStep("Step_em21", [el21]), ChainStep("Step_em31", [el31]) ] ), + makeChain(name='HLT_g5_L1EM7' , L1Thresholds=["EM7"], ChainSteps=[ ChainStep("Step_gam11", [gamm11]) ] ) ] HLTChains += ElChains @@ -184,15 +184,15 @@ def generateL1DecoderAndChains(): # in symmetric chains, multiplicity=2 but only one sequence is used CombChains =[ - Chain(name='HLT_mu8_e8_L1MU6_EM7', L1Thresholds=["MU6","EM7"], ChainSteps=[ ChainStep("Step1_mu_em", [mu11, el11], multiplicity=2), + makeChain(name='HLT_mu8_e8_L1MU6_EM7', L1Thresholds=["MU6","EM7"], ChainSteps=[ ChainStep("Step1_mu_em", [mu11, el11], multiplicity=2), ChainStep("Step2_mu_em", [mu21, el21], multiplicity=2)] ), - Chain(name='HLT_e5_e8_L1EM3_EM5', L1Thresholds=["EM3","EM5"], ChainSteps=[ ChainStep("Step1_2em", [el11, el11], multiplicity=2), + makeChain(name='HLT_e5_e8_L1EM3_EM5', L1Thresholds=["EM3","EM5"], ChainSteps=[ ChainStep("Step1_2em", [el11, el11], multiplicity=2), ChainStep("Step2_2em", [el21, el21], multiplicity=2) ]), - Chain(name='HLT_2mu6_L12MU6', L1Thresholds=["MU6"], ChainSteps=[ ChainStep("Step1_2mu", [mu11], multiplicity=2), + makeChain(name='HLT_2mu6_L12MU6', L1Thresholds=["MU6"], ChainSteps=[ ChainStep("Step1_2mu", [mu11], multiplicity=2), ChainStep("Step2_2mu", [mu21], multiplicity=2) ]), - Chain(name='HLT_2mu6Comb_L12MU6', L1Thresholds=["MU6"], ChainSteps=[ ChainStep("Step1_2mu_empty", multiplicity=2), + makeChain(name='HLT_2mu6Comb_L12MU6', L1Thresholds=["MU6"], ChainSteps=[ ChainStep("Step1_2mu_empty", multiplicity=2), ChainStep("Step2_2mu", [mu21], multiplicity=2) ]), - Chain(name='HLT_2mu4_bDimu_L12MU4', L1Thresholds=["MU4"], ChainSteps=[ ChainStep("Step1_2mu", [mu11], multiplicity=2), + makeChain(name='HLT_2mu4_bDimu_L12MU4', L1Thresholds=["MU4"], ChainSteps=[ ChainStep("Step1_2mu", [mu11], multiplicity=2), step_mu22, ChainStep("Step3_2mu", [mu31], multiplicity=2)] ) ] diff --git a/Trigger/TrigValidation/TrigUpgradeTest/python/TestUtils.py b/Trigger/TrigValidation/TrigUpgradeTest/python/TestUtils.py index 9fb177fbb5a78a69bff576d1c64779f2fc8b99ed..f4a79cccb81d29de77ce29eb530f180c664645d2 100644 --- a/Trigger/TrigValidation/TrigUpgradeTest/python/TestUtils.py +++ b/Trigger/TrigValidation/TrigUpgradeTest/python/TestUtils.py @@ -99,8 +99,8 @@ class L1EmulationTest(L1Decoder): self.L1DecoderSummaryKey = "L1DecoderSummary" -from TriggerMenuMT.HLTMenuConfig.Menu.TriggerConfigHLT import TriggerConfigHLT -chainsConfig = TriggerConfigHLT( ) + + chainsCounter = 0 @@ -112,17 +112,20 @@ def makeChain( name, L1Thresholds, ChainSteps, Streams="physics:Main", Groups=[] from TriggerMenuMT.HLTMenuConfig.Menu.ChainDefInMenu import ChainProp prop = ChainProp( name=name, l1SeedThresholds=L1Thresholds, groups=Groups ) + from TriggerMenuMT.HLTMenuConfig.Menu.TriggerConfigHLT import TriggerConfigHLT + from TriggerMenuMT.HLTMenuConfig.Menu.DictFromChainName import DictFromChainName decoder = DictFromChainName() chainDict = decoder.getChainDict( prop ) global chainsCounter chainDict["chainCounter"] = chainsCounter chainsCounter += 1 - TriggerConfigHLT.currentTriggerConfig().allChainDicts.append( chainDict ) from TriggerMenuMT.HLTMenuConfig.Menu.MenuComponents import Chain chainConfig = Chain( name=name, L1Thresholds=L1Thresholds, ChainSteps=ChainSteps ) - TriggerConfigHLT.currentTriggerConfig().allChainConfigs.append( chainConfig ) + + TriggerConfigHLT.registerChain( chainDict, chainConfig ) + return chainConfig if __name__ == "__main__": diff --git a/Trigger/TrigValidation/TrigUpgradeTest/python/pebMenuDefs.py b/Trigger/TrigValidation/TrigUpgradeTest/python/pebMenuDefs.py index be7d68604c5e431d4106dc4cbcb492892669b90b..36fa9c061e733ad5600177e2fcccef55954fa7be 100644 --- a/Trigger/TrigValidation/TrigUpgradeTest/python/pebMenuDefs.py +++ b/Trigger/TrigValidation/TrigUpgradeTest/python/pebMenuDefs.py @@ -16,7 +16,7 @@ log = logging.getLogger('pebMenuDefs') # PEB Info Writer step ################################################################## def pebInputMaker(name): - maker = InputMakerForRoI("pebInputMaker_"+name, mergeOutputs=False) + maker = InputMakerForRoI("IMpeb_"+name, mergeOutputs=False) maker.RoIs="pebInputRoI_"+name return maker diff --git a/Trigger/TrigValidation/TrigUpgradeTest/share/EmuScalingCFTest.py b/Trigger/TrigValidation/TrigUpgradeTest/share/EmuScalingCFTest.py index 28d486f000a2891640e3d1d1d9b49ba3280e76bf..dec8d2727113751cc42b12b9f86e8d8c49217901 100644 --- a/Trigger/TrigValidation/TrigUpgradeTest/share/EmuScalingCFTest.py +++ b/Trigger/TrigValidation/TrigUpgradeTest/share/EmuScalingCFTest.py @@ -4,7 +4,8 @@ from L1Decoder.L1DecoderConf import CTPUnpackingEmulationTool, RoIsUnpackingEmul from AthenaCommon.AlgScheduler import AlgScheduler from AthenaCommon.CFElements import parOR from AthenaCommon.Logging import logging -from TriggerMenuMT.HLTMenuConfig.Menu.MenuComponents import Chain, ChainStep +from TriggerMenuMT.HLTMenuConfig.Menu.MenuComponents import ChainStep +from TrigUpgradeTest.TestUtils import writeEmulationFiles, makeChain log = logging.getLogger('EmuScalingCFTest') @@ -60,8 +61,7 @@ def generateChains(chain_names): step = ChainStep(seq.name, [seq]) chainSteps.append(step) - # el21 = elMenuSequence(step="2",reconame="v1", hyponame="v1") - chainObj=Chain(name=chain ,L1Thresholds=[seed], ChainSteps=chainSteps ) + chainObj=makeChain(name=chain ,L1Thresholds=[seed], ChainSteps=chainSteps ) log.debug("adding chain %s",chainObj) chains.append(chainObj) # Chain(name='HLT_e5' , L1Item="L1_EM7", ChainSteps=[ ChainStep("Step_em11", [el11]), ChainStep("Step_em21", [el21]) ] ), @@ -89,7 +89,7 @@ def process(): HLTChains=generateChains(chain_names) - from TrigUpgradeTest.TestUtils import writeEmulationFiles + writeEmulationFiles(data) # this is a temporary hack to include new test chains @@ -127,7 +127,8 @@ def process(): topSequence = AlgSequence() topSequence += l1Decoder ##### Make all HLT ####### - makeHLTTree(HLTChains) + from TriggerMenuMT.HLTMenuConfig.Menu.TriggerConfigHLT import TriggerConfigHLT + makeHLTTree( triggerConfigHLT=TriggerConfigHLT ) print "EmuScalingCF: dump top Sequence after CF/DF Tree build" from AthenaCommon.AlgSequence import dumpMasterSequence, dumpSequence diff --git a/Trigger/TrigValidation/TrigUpgradeTest/share/EmuStepProcessingTest.py b/Trigger/TrigValidation/TrigUpgradeTest/share/EmuStepProcessingTest.py index 45329dcba83259e2fbdb1bc80e04e4ad8dd97e45..7dea98b229682fc53a176f7b5c970bcc313aa497 100644 --- a/Trigger/TrigValidation/TrigUpgradeTest/share/EmuStepProcessingTest.py +++ b/Trigger/TrigValidation/TrigUpgradeTest/share/EmuStepProcessingTest.py @@ -30,7 +30,8 @@ topSequence = AlgSequence() l1Decoder, HLTChains = generateL1DecoderAndChains() topSequence += l1Decoder ##### Make all HLT ####### -makeHLTTree(HLTChains) +from TriggerMenuMT.HLTMenuConfig.Menu.TriggerConfigHLT import TriggerConfigHLT +makeHLTTree( triggerConfigHLT=TriggerConfigHLT ) print "EmuStepProcessing: dump top Sequence after CF/DF Tree build" from AthenaCommon.AlgSequence import dumpMasterSequence, dumpSequence diff --git a/Trigger/TrigValidation/TrigUpgradeTest/share/full_menu.py b/Trigger/TrigValidation/TrigUpgradeTest/share/full_menu.py index cebe2431c40428d9625eb909e9fc0937d01db6dc..88288235775c3120ac7c85886ba2a3dda5a6e05b 100644 --- a/Trigger/TrigValidation/TrigUpgradeTest/share/full_menu.py +++ b/Trigger/TrigValidation/TrigUpgradeTest/share/full_menu.py @@ -130,3 +130,9 @@ if configureBSResult: from AthenaCommon.AppMgr import ServiceMgr as svcMgr hltResultMaker = svcMgr.HltEventLoopMgr.ResultMaker hltResultMaker.MakerTools = [stmaker, serialiser] # TODO: add bits maker + +m = findAlgorithm(topSequence,'TrigSignatureMoniMT') +print m +m.OutputLevel=DEBUG + + diff --git a/Trigger/TrigValidation/TrigUpgradeTest/share/full_menu_cf.py b/Trigger/TrigValidation/TrigUpgradeTest/share/full_menu_cf.py index 17d0c3aebb4ff65674260191caa0e9da48d36c08..489ae3e09e08ffd105558b60f81aa7eaf83765b7 100644 --- a/Trigger/TrigValidation/TrigUpgradeTest/share/full_menu_cf.py +++ b/Trigger/TrigValidation/TrigUpgradeTest/share/full_menu_cf.py @@ -291,7 +291,7 @@ if opt.doCombinedSlice == True: ##### Make all HLT ####### from TriggerMenuMT.HLTMenuConfig.Menu.HLTCFConfig import makeHLTTree from TriggerMenuMT.HLTMenuConfig.Menu.TriggerConfigHLT import TriggerConfigHLT -makeHLTTree( None, triggerConfigHLT=TriggerConfigHLT.currentTriggerConfig() ) +makeHLTTree( triggerConfigHLT=TriggerConfigHLT ) ########################################## diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/GenerateMenuMT.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/GenerateMenuMT.py index 6f41ce7703560c8e317da69628aaec40fac0d5a2..1cb223b566bd273bfc45af7a4afe5c2ae5ac15c1 100755 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/GenerateMenuMT.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/GenerateMenuMT.py @@ -36,7 +36,6 @@ class GenerateMenuMT(object): def __init__(self): - self.triggerConfigHLT = None self.chains = [] self.chainDefs = [] self.listOfErrorChainDefs = [] @@ -77,9 +76,6 @@ class GenerateMenuMT(object): == Setup of TriggerConfigHLT, menu and prescale names """ (HLTPrescales) = self.setupMenu() - self.triggerConfigHLT = TriggerConfigHLT(TriggerFlags.outputHLTconfigFile(), self.signaturesOverwritten) - self.triggerConfigHLT.menuName = TriggerFlags.triggerMenuSetup() - log.debug("Working with menu: %s", self.triggerConfigHLT.menuName) log.debug(" and prescales : %s", HLTPrescales) @@ -90,7 +86,7 @@ class GenerateMenuMT(object): # go over the slices and put together big list of signatures requested #(L1Prescales, HLTPrescales, streamConfig) = MenuPrescaleConfig(self.triggerPythonConfig) # that does not seem to work - (self.L1Prescales, self.HLTPrescales) = MenuPrescaleConfig(self.triggerConfigHLT) + (self.L1Prescales, self.HLTPrescales) = MenuPrescaleConfig(TriggerConfigHLT) global _func_to_modify_signatures if _func_to_modify_signatures is not None: log.info('setupMenu: Modifying trigger signatures in TriggerFlags with %s', @@ -157,7 +153,6 @@ class GenerateMenuMT(object): for chain in chainsInMenu: log.debug("Currently processing chain: %s ", chain) chainDict = decodeChainName.getChainDict(chain) - self.triggerConfigHLT.allChainDicts.append(chainDict) chainCounter += 1 chainDict['chainCounter'] = chainCounter @@ -166,10 +161,10 @@ class GenerateMenuMT(object): chainConfig= self.generateChainConfig(chainDict) log.debug("Finished with retrieving chain configuration for chain %s", chain) - self.triggerConfigHLT.allChainConfigs.append(chainConfig) + TriggerConfigHLT.registerChain( chainDict, chainConfig ) - return self.triggerConfigHLT.allChainConfigs + return TriggerConfigHLT.configsList() def getChainsFromMenu(self): """ @@ -335,7 +330,7 @@ class GenerateMenuMT(object): for step in cc.steps: log.debug(step) - makeHLTTree(None, newJO=False, triggerConfigHLT = self.triggerConfigHLT) + makeHLTTree(newJO=False, triggerConfigHLT = TriggerConfigHLT) # the return values used for debugging, might be removed later from TriggerMenuMT.HLTMenuConfig.Menu.HLTMenuJSON import generateJSON diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/HLTCFConfig.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/HLTCFConfig.py index 0d7165bcf197de5269bc03f113a05f24848cc611..bab796cbb25b015264e1f99a4a77ea2366eaa5e8 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/HLTCFConfig.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/HLTCFConfig.py @@ -119,32 +119,12 @@ def createCFTree(CFseq): ## CORE of Decision Handling ####################################### -def makeHLTTree(HLTChains, newJO=False, triggerConfigHLT = None): +def makeHLTTree(newJO=False, triggerConfigHLT = None): """ creates the full HLT tree""" # Check if triggerConfigHLT exits, if yes, derive information from this # this will be in use once TrigUpgrade test has migrated to TriggerMenuMT completely - if triggerConfigHLT: - assert len(triggerConfigHLT.allChainConfigs) != 0, "Chain configurations passed, but list of configurations it is empty" - assert len(triggerConfigHLT.allChainDicts) != 0, "Chain configurations passed, but list of chain dicts it is empty" - assert HLTChains is None, "Both triggerConfigHLT and HLTChains list passed to CF building, either one or the other shoudl be used" - allChainConfigs = triggerConfigHLT.allChainConfigs - allChainDicts = triggerConfigHLT.allChainDicts - else: - log.info("No triggerConfigHLT was passed, only relying on HLTChains now, in this mode complex chains can not be handled") - log.info("Creating necessary chainDict info now") - - allChainConfigs = HLTChains - allChainDicts = [] - from TriggerMenuMT.HLTMenuConfig.Menu import DictFromChainName - decodeChainName = DictFromChainName.DictFromChainName() - for chain in allChainConfigs: - chainDict = decodeChainName.getChainDict(chain.name) - allChainDicts.append(chainDict) - from TriggerMenuMT.HLTMenuConfig.Menu.TriggerConfigHLT import TriggerConfigHLT - TriggerConfigHLT.currentTriggerConfig().allChainDicts = allChainDicts # need to fill it because HypoTool creation needs it - # lock flags from AthenaConfiguration.AllConfigFlags import ConfigFlags ConfigFlags.lock() @@ -165,7 +145,7 @@ def makeHLTTree(HLTChains, newJO=False, triggerConfigHLT = None): topSequence.remove( l1decoder ) # set CTP chains before creating the full tree (and the monitor) - EnabledChainNamesToCTP = dict([ (c["chainName"], c["L1item"]) for c in allChainDicts]) + EnabledChainNamesToCTP = dict([ (c["chainName"], c["L1item"]) for c in triggerConfigHLT.dictsList()]) l1decoder[0].ChainToCTPMapping = EnabledChainNamesToCTP # main HLT top sequence @@ -179,7 +159,7 @@ def makeHLTTree(HLTChains, newJO=False, triggerConfigHLT = None): hltTop += steps # make DF and CF tree from chains - finalDecisions = decisionTree_From_Chains(steps, allChainConfigs, allChainDicts, newJO) + finalDecisions = decisionTree_From_Chains(steps, triggerConfigHLT.configsList(), triggerConfigHLT.dictsList(), newJO) flatDecisions=[] for step in finalDecisions: diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/HLTMenuJSON.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/HLTMenuJSON.py index 2fc2084b16b0b203d8df034de6f4ea33f8e14bf7..0fb3768c1bba74c0dc4d812081737496b3953965 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/HLTMenuJSON.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/HLTMenuJSON.py @@ -67,9 +67,9 @@ def generateJSON(): __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, triggerConfigHLT.allChainConfigs, TriggerFlags.triggerMenuSetup() ) + + return __generateJSON( TriggerConfigHLT.dictsList(), TriggerConfigHLT.configsList(), TriggerFlags.triggerMenuSetup() ) def generateJSON_newJO( chainDicts, chainConfigs ): __log.info("Generating HLT JSON config in the new JO") diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/MenuComponents.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/MenuComponents.py index 9dd9775a39ccc1f9764be84739fb2198ecf0cc0e..526ee22276ba4a749cf067322566b07ca5daa3bb 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/MenuComponents.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/MenuComponents.py @@ -461,8 +461,8 @@ class Chain(object): def decodeHypoToolConfs(self, allChainDicts): """ This is extrapolating the hypotool configuration from the (combined) chain name""" import copy - from TriggerMenuMT.HLTMenuConfig.Menu.TriggerConfigHLT import getChainDictFromChainName - chainDict = getChainDictFromChainName(self.name, allChainDicts) + from TriggerMenuMT.HLTMenuConfig.Menu.TriggerConfigHLT import TriggerConfigHLT + chainDict = TriggerConfigHLT.getChainDictFromChainName(self.name) for step in self.steps: if len(step.sequences) == 0: diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/TriggerConfigHLT.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/TriggerConfigHLT.py index 5012ee6d8024c9f382938ce1fb3631670f9be842..39579771af98058070ab558d4c126f2461638b5b 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/TriggerConfigHLT.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/TriggerConfigHLT.py @@ -7,63 +7,54 @@ ######################################################################################### import sys +from six import itervalues from AthenaCommon.Logging import logging log = logging.getLogger( 'TriggerConfigHLT' ) class TriggerConfigHLT(object): - - sCurrentTriggerConfig = None - def currentTriggerConfig(): - return TriggerConfigHLT.sCurrentTriggerConfig - currentTriggerConfig = staticmethod(currentTriggerConfig) - - def __init__(self, hltfile=None, signaturesOverwritten=False): - self.menuName = 'TestMenu' - self.__HLTFile = hltfile + """ + Repository of all configured chains. Contains chain dictionaries and Menu Chain objects + """ + from collections import OrderedDict + __allChainConfigs = OrderedDict() + __allChainDicts = OrderedDict() + + @classmethod + def registerChain(cls, chainDict, chainConfig): + """ + Register chain for future use - self.allChainConfigs = [] - self.allChainDicts = [] - - self.allThresholds = {} - self.allItems = {} - self.allChains = {} - self.allChainSteps = {} + Name reuse and inconsistency is reported + """ + assert chainDict['chainName'] not in cls.__allChainDicts, 'Chain dictionary {} already registered'.format(chainDict['chainName']) + assert chainConfig.name not in cls.__allChainConfigs, 'Chain configuration {} already registered'.format(chainConfig.name) + assert chainDict['chainName'] == chainConfig.name, 'Registering chain dictionary and config that have differnet names: in dictionary {}, in config {}'.format(chainDict['chainName'], chainConfig.name) - self.theHLTChains = [] - self.theSeqLists = [] - self.theSeqDict = {} # dict by Seq output TE + cls.__allChainConfigs[chainConfig.name] = chainConfig + cls.__allChainDicts[chainDict['chainName']] = chainDict + log.debug("Registered chain ", chainConfig.name ) - if type(signaturesOverwritten)!=bool: - log.error('Wrong type for signaturesOverwritten. Received %s but expected bool', type(signaturesOverwritten)) - self.signaturesOverwritten = signaturesOverwritten + @classmethod + def dicts(cls): + return cls.__allChainDicts - TriggerConfigHLT.sCurrentTriggerConfig = self + @classmethod + def dictsList(cls): + return list(itervalues(cls.__allChainDicts)) - def registerHLTChain(self, chainName, chainConfig): - """ Adds chain to the set of self.allChains which are registered for further use """ - if chainName in self.allChains: - self.allChains[chainName].append( chainConfig ) - else: - self.allChains[chainName] = [ chainConfig ] - - def getHLTConfigFile(self): - return self.__HLTFile + @classmethod + def configsList(cls): + return list(itervalues(cls.__allChainConfigs)) + @classmethod + def getChainDictFromChainName(cls, chainName): + assert chainName in cls.__allChainDicts, "Chain of name {} not registered, all registered {}".format(chainName, cls.__allChainDicts.keys()) + return cls.__allChainDicts[chainName] - def writeHLTConfigFile(self,smkPskName): - """ Writes HLT config file""" - if self.__HLTFile is None: - return - log.info("Writing of config files needs to be implemented") -#__chainsDict = {} -def getChainDictFromChainName(chainName, allChainDicts = None): - found = [ c for c in TriggerConfigHLT.currentTriggerConfig().allChainDicts if c['chainName'] == chainName ] - assert len(found) == 1, "Problem finding a unique dict for the chain {}, found that many: {} ".format(chainName, len(found)) - return found[0] ############################## # this function was supposed to be part of the class but doesn't work for now @@ -100,3 +91,23 @@ def getConfFromChainName(chainName, allChainDicts = None): log.info("TriggerConfigHLT.getConfFromChainName: Called chain %s and hypoTool conf %s", chainName, chainPartNames) return chainPartNames + + +if __name__ == "__main__": # selftest + log.info('Self testing') + class ChainClassGoodForThisTest: + def __init__(self, n): + self.name = n + + TriggerConfigHLT.registerChain({'chainName':'HLT_bla1'}, ChainClassGoodForThisTest('HLT_bla1')) + TriggerConfigHLT.registerChain({'chainName':'HLT_bla2'}, ChainClassGoodForThisTest('HLT_bla2')) + TriggerConfigHLT.getChainDictFromChainName('HLT_bla1') # if missing will assert + TriggerConfigHLT.getChainDictFromChainName('HLT_bla2') # if missing will assert + log.info("ok, registration works") + try: + TriggerConfigHLT.getChainDictFromChainName('HLT_blabla') + except Exception as e: + if isinstance(e, AssertionError): + log.info("ok, unregistered chain handling works") + else: + log.error("unhandled missing chain")