diff --git a/Trigger/TrigHypothesis/TrigEgammaHypo/python/TrigEgammaPrecisionElectronHypoTool.py b/Trigger/TrigHypothesis/TrigEgammaHypo/python/TrigEgammaPrecisionElectronHypoTool.py index b558510cd7fa8cfe8b317815f0cad104f3c78658..21663af19045b0f853837ad69ca2fe5221a64663 100644 --- a/Trigger/TrigHypothesis/TrigEgammaHypo/python/TrigEgammaPrecisionElectronHypoTool.py +++ b/Trigger/TrigHypothesis/TrigEgammaHypo/python/TrigEgammaPrecisionElectronHypoTool.py @@ -70,7 +70,7 @@ def _MultTool(name): def TrigEgammaPrecisionElectronHypoToolFromDict( d ): """ Use menu decoded chain dictionary to configure the tool """ cparts = [i for i in d['chainParts'] if ((i['signature']=='Electron') or (i['signature']=='Electron'))] - + def __mult(cpart): return int( cpart['multiplicity'] ) diff --git a/Trigger/TrigHypothesis/TrigEgammaHypo/python/TrigEgammaPrecisionPhotonHypoTool.py b/Trigger/TrigHypothesis/TrigEgammaHypo/python/TrigEgammaPrecisionPhotonHypoTool.py index dfea03594158b09b800f8afb3e8db2ed160517b4..82dd9ce56618a2e3bfa13579be8bc716515dadc1 100644 --- a/Trigger/TrigHypothesis/TrigEgammaHypo/python/TrigEgammaPrecisionPhotonHypoTool.py +++ b/Trigger/TrigHypothesis/TrigEgammaHypo/python/TrigEgammaPrecisionPhotonHypoTool.py @@ -51,7 +51,7 @@ def _MultTool(name): def TrigEgammaPrecisionPhotonHypoToolFromDict( d ): """ Use menu decoded chain dictionary to configure the tool """ cparts = [i for i in d['chainParts'] if ((i['signature']=='Electron') or (i['signature']=='Photon'))] - + def __mult(cpart): return int( cpart['multiplicity'] ) diff --git a/Trigger/TrigHypothesis/TrigEgammaHypo/python/TrigL2CaloHypoTool.py b/Trigger/TrigHypothesis/TrigEgammaHypo/python/TrigL2CaloHypoTool.py index f78b06881f629fba6d0e1bedb1d0aa6f1d02b2ee..14283124db828e9ceadf03212829f270f71081c5 100644 --- a/Trigger/TrigHypothesis/TrigEgammaHypo/python/TrigL2CaloHypoTool.py +++ b/Trigger/TrigHypothesis/TrigEgammaHypo/python/TrigL2CaloHypoTool.py @@ -108,7 +108,7 @@ def _MultTool(name): def TrigL2CaloHypoToolFromDict( d ): """ Use menu decoded chain dictionary to configure the tool """ cparts = [i for i in d['chainParts'] if ((i['signature']=='Electron') or (i['signature']=='Photon'))] - + def __mult(cpart): return int( cpart['multiplicity'] ) diff --git a/Trigger/TrigHypothesis/TrigEgammaHypo/python/TrigL2ElectronHypoTool.py b/Trigger/TrigHypothesis/TrigEgammaHypo/python/TrigL2ElectronHypoTool.py index ccddead7ace53260d8cd17e17c036b2e1d6dc919..a38f1bafdb4de80d10e3c46ee63c65da64376e85 100644 --- a/Trigger/TrigHypothesis/TrigEgammaHypo/python/TrigL2ElectronHypoTool.py +++ b/Trigger/TrigHypothesis/TrigEgammaHypo/python/TrigL2ElectronHypoTool.py @@ -11,6 +11,7 @@ log = logging.getLogger('TrigL2ElectronHypoTool') def TrigL2ElectronHypoToolFromDict( chainDict ): """ Use menu decoded chain dictionary to configure the tool """ cparts = [i for i in chainDict['chainParts'] if i['signature']=='Electron'] + thresholds = sum([ [cpart['threshold']]*int(cpart['multiplicity']) for cpart in cparts], []) name = chainDict['chainName'] diff --git a/Trigger/TrigValidation/TrigUpgradeTest/share/full_menu_cf.py b/Trigger/TrigValidation/TrigUpgradeTest/share/full_menu_cf.py index 33e60eecdb2e6b8e823ad658c7f871c95c400717..243636ae5a343d0138db832da7c7b2cb72d2db2f 100644 --- a/Trigger/TrigValidation/TrigUpgradeTest/share/full_menu_cf.py +++ b/Trigger/TrigValidation/TrigUpgradeTest/share/full_menu_cf.py @@ -231,7 +231,7 @@ if opt.doMETSlice == True: metCellStep = ChainStep("Step1_met_cell", [metCellSeq]) metClusterPufitStep = ChainStep("Step1_met_clusterpufit", [metClusterPufitSeq]) - comboStep_cell_clusterpufit = ChainStep("Step1_combo_cell_clusterpufit", [metCellSeq, metClusterPufitSeq], multiplicity=[2]) + comboStep_cell_clusterpufit = ChainStep("Step1_combo_cell_clusterpufit", [metCellSeq, metClusterPufitSeq], multiplicity=[1,1]) metChains = [ makeChain(name="HLT_xe65_L1XE50", L1Thresholds=["XE50"], ChainSteps=[metCellStep]), @@ -284,8 +284,8 @@ if opt.doCombinedSlice == True: from TriggerMenuMT.HLTMenuConfig.Muon.MuonSequenceSetup import muFastSequence - comboStep_et_mufast = ChainStep("Step1_et_mufast", [fastCaloSeq, muFastSequence()], multiplicity=[2]) - comboStep_mufast_etcut1_step1 = ChainStep("Step1_mufast_etcut1", [muFastSequence(), fastCaloSeq], multiplicity=[2]) + comboStep_et_mufast = ChainStep("Step1_et_mufast", [fastCaloSeq, muFastSequence()], multiplicity=[1,1]) + comboStep_mufast_etcut1_step1 = ChainStep("Step1_mufast_etcut1", [muFastSequence(), fastCaloSeq], multiplicity=[1,1]) comboChains = [ makeChain(name='HLT_e3_etcut_mu6_L1EM8I_MU10', L1Thresholds=["EM8I", "MU10"], ChainSteps=[comboStep_et_mufast ])] diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Bjet/BjetDef.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Bjet/BjetDef.py index 6ab58aeb44bab7e347c9967666bb7f4fe24ca8dc..e3725ef5ea9a37f9454afed1a556f2a281b7648b 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Bjet/BjetDef.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Bjet/BjetDef.py @@ -6,7 +6,6 @@ log = logging.getLogger("TriggerMenuMT.HLTMenuConfig.Bjet.BjetDef") from TriggerMenuMT.HLTMenuConfig.Menu.ChainConfigurationBase import ChainConfigurationBase -from TriggerMenuMT.HLTMenuConfig.Menu.MenuComponents import ChainStep, RecoFragmentsPool from TriggerMenuMT.HLTMenuConfig.Bjet.BjetSequenceSetup import getBJetSequence @@ -69,14 +68,13 @@ class BjetChainConfiguration(ChainConfigurationBase): stepName = "Step2_bjet" log.debug("Configuring step " + stepName) - bjetSeq = RecoFragmentsPool.retrieve( bjetSequenceCfg_j, None ) # the None will be used for flags in future - return ChainStep(stepName, [bjetSeq]) + return self.getStep(2, stepName, [bjetSequenceCfg_j]) def getBjetSequence_btag(self): stepName = "Step3_bjet" log.debug("Configuring step " + stepName) - bjetSeq = RecoFragmentsPool.retrieve( bjetSequenceCfg_btag, None ) # the None will be used for flags in future - return ChainStep(stepName, [bjetSeq]) + + return self.getStep(3, stepName, [bjetSequenceCfg_btag]) diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Bjet/GenerateBjetChainDefs.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Bjet/GenerateBjetChainDefs.py index 09a8483d741a7db2f3df452dd387a601f9d9f8c9..edf4d1391845cae97586d84570ca9cd1ce2f32ad 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Bjet/GenerateBjetChainDefs.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Bjet/GenerateBjetChainDefs.py @@ -18,11 +18,10 @@ def generateChainConfigs( chainDict ): listOfChainDicts = splitChainDict(chainDict) listOfChainDefs = [] - for subChainDict in listOfChainDicts: + jet = JetChainConfiguration(chainDict).assembleChain() - subChainDict['chainParts']['signature'] = 'Jet' + for subChainDict in listOfChainDicts: - jet = JetChainConfiguration(subChainDict).assembleChain() Bjet = BjetChainConfiguration(subChainDict).assembleChain() jet.steps = jet.steps + Bjet.steps diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Egamma/ElectronDef.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Egamma/ElectronDef.py index 42b9205088b4bd301a9626333f8f75bf073a7aa8..0ee48bae26cf6f904f7553d57c6db80144fb8082 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Egamma/ElectronDef.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Egamma/ElectronDef.py @@ -97,24 +97,24 @@ class ElectronChainConfiguration(ChainConfigurationBase): stepName = "Step1_FastCalo_electron" log.debug("Configuring step " + stepName) fastCalo = RecoFragmentsPool.retrieve( electronFastCaloCfg, None ) # the None will be used for flags in future - return ChainStep(stepName, [fastCalo], [self.mult]) + return ChainStep(stepName, [fastCalo], [self.mult], [self.dict]) def getFastElectron(self): stepName = "Step2_fast_electron" log.debug("Configuring step " + stepName) electronReco = RecoFragmentsPool.retrieve( fastElectronSequenceCfg, None ) - return ChainStep(stepName, [electronReco], [self.mult]) + return ChainStep(stepName, [electronReco], [self.mult], [self.dict]) def getPrecisionCaloElectron(self): stepName = "Step3_precisionCalo_electron" log.debug("Configuring step " + stepName) precisionReco = RecoFragmentsPool.retrieve( precisionCaloSequenceCfg, None ) - return ChainStep(stepName, [precisionReco], [self.mult]) + return ChainStep(stepName, [precisionReco], [self.mult], [self.dict]) def getPrecisionElectron(self): stepName = "Step4_precision_electron" log.debug("Configuring step " + stepName) precisionElectron = RecoFragmentsPool.retrieve( precisionElectronSequenceCfg, None ) - return ChainStep(stepName, [precisionElectron], [self.mult]) + return ChainStep(stepName, [precisionElectron], [self.mult], [self.dict]) diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Jet/GenerateJetChainDefs.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Jet/GenerateJetChainDefs.py index 79129bd54c1b60787237fcd7cf0c00764c813ec4..55faeed19aadb04732f2a05ee0c73f5f452a6c19 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Jet/GenerateJetChainDefs.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Jet/GenerateJetChainDefs.py @@ -1,6 +1,5 @@ # Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration -from TriggerMenuMT.HLTMenuConfig.Menu.ChainDictTools import splitChainDict from TriggerMenuMT.HLTMenuConfig.Jet.JetChainConfiguration import JetChainConfiguration @@ -14,29 +13,13 @@ def generateChainConfigs( chainDict ): import pprint pprint.pprint( chainDict ) - - listOfChainDicts = splitChainDict(chainDict) - listOfChainDefs = [] - - for subChainDict in listOfChainDicts: - - Jet = JetChainConfiguration(subChainDict).assembleChain() - - listOfChainDefs += [Jet] - log.debug('length of chaindefs %s', len(listOfChainDefs) ) - - # We should never use multiple reco definitions, as this - # cannot be handled by the hypos. - # FIXME: Check that all jet reco configs are identical - if len(listOfChainDefs)>1: - # Add reco consistency checking between all - log.warning("Multiple jet chainParts detected; reco consistency checks not yet implemented. Forcing chain to be single-object") - theChainDef = listOfChainDefs[0] #needs to be implemented properly - else: - theChainDef = listOfChainDefs[0] - - - return theChainDef + # Jet chain is assembled always from the full dictionary (multiple legs are handled internally by the jet reco / hypo) + theChainDef = JetChainConfiguration(chainDict) + + jetChain = theChainDef.assembleChain() + + + return jetChain diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Jet/JetChainConfiguration.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Jet/JetChainConfiguration.py index ea041a5f4697fcea5bd606996e06e5fd51ffebab..6808b79af94dcc8004fd5c6930fbae5bd2ea1d27 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Jet/JetChainConfiguration.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Jet/JetChainConfiguration.py @@ -1,23 +1,55 @@ -# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration from AthenaCommon.Logging import logging logging.getLogger().info("Importing %s",__name__) log = logging.getLogger("TriggerMenuMT.HLTMenuConfig.Jet.JetDef") - from TriggerMenuMT.HLTMenuConfig.Menu.ChainConfigurationBase import ChainConfigurationBase from TriggerMenuMT.HLTMenuConfig.Menu.MenuComponents import ChainStep, RecoFragmentsPool +import copy + +def jetChainParts(chainParts): + jChainParts = [] + for p in chainParts: + if p['trigType'] == 'j': + jChainParts.append(p) + return jChainParts + #---------------------------------------------------------------- # Class to configure chain #---------------------------------------------------------------- class JetChainConfiguration(ChainConfigurationBase): def __init__(self, chainDict): - ChainConfigurationBase.__init__(self,chainDict) + # we deliberately don't call base class constructore, since this assumes a single chain part + # which is not the case for jets + + self.dict = copy.deepcopy(chainDict) + + self.chainName = self.dict['chainName'] + self.chainL1Item = self.dict['L1item'] + + self.chainPart = self.dict['chainParts'] + self.L1Threshold = '' + self.mult = 1 # from the framework point of view I think the multiplicity is 1, internally the jet hypo has to figure out what to actually do + + # these properties are in the base class, but I don't think we need them for jets + #self.chainPartName = '' + #self.chainPartNameNoMult = '' + #self.chainPartNameNoMultwL1 = '' + + # expect that the L1 seed is the same for all jet parts, otherwise we have a problem + jChainParts = jetChainParts(self.chainPart) + for p in jChainParts: + l1th = p['L1threshold'] + if self.L1Threshold != '' and self.L1Threshold != l1th: + log.error('Cannot configure a jet chain with different L1 thresholds') + exit(1) + self.L1Threshold = l1th from TriggerMenuMT.HLTMenuConfig.Jet.JetRecoConfiguration import extractRecoDict - self.recoDict = extractRecoDict(self.dict["chainParts"]) + self.recoDict = extractRecoDict(jChainParts) # ---------------------- # Assemble the chain depending on information from chainName @@ -51,7 +83,8 @@ class JetChainConfiguration(ChainConfigurationBase): stepName = "Step1_jet_"+jetDefStr jetSeq1 = RecoFragmentsPool.retrieve( jetMenuSequence, None, **self.recoDict ) # the None will be used for flags in future - return ChainStep(stepName, [jetSeq1], multiplicity=[1]) + + return ChainStep(stepName, [jetSeq1], multiplicity=[1], chainDicts=[self.dict]) diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Jet/JetRecoConfiguration.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Jet/JetRecoConfiguration.py index ac1324802984f493aea8ad316c58705c8c3f4f8e..2610f2fa65c9896869b323749a55f70c8e5f8395 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Jet/JetRecoConfiguration.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Jet/JetRecoConfiguration.py @@ -8,13 +8,28 @@ # jet reco code. from JetRecConfig.JetDefinition import JetConstit, xAODType, JetDefinition +from AthenaCommon.Logging import logging +log = logging.getLogger("TriggerMenuMT.HLTMenuConfig.Jet.JetRecoConfiguration") # Extract the jet reco dict from the chainDict def extractRecoDict(chainParts): # interpret the reco configuration only # eventually should just be a subdict in the chainDict recoKeys = ['recoAlg','dataType','calib','jetCalib','trkopt','cleaning'] - return { key:chainParts[key] for key in recoKeys } + recoDict = {} + for p in chainParts: + for k in recoKeys: + # Look for our key in the chain part + if k in p.keys(): + # found the key, check for consistency with other chain parts of this chain + if k in recoDict.keys(): + if p[k] != recoDict[k]: + log.error('Inconsistent reco setting for' + k) + exit(1) + # copy this entry to the reco dictionary + recoDict[k] = p[k] + + return recoDict # Define the jet constituents to be interpreted by JetRecConfig # When actually specifying the reco, clustersKey should be diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/MET/METChainConfiguration.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/MET/METChainConfiguration.py index 046224426308ccaf000e783a52e85dc72094ab0e..e0382a387115b1e8982e52c171deb8e0b5553441 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/MET/METChainConfiguration.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/MET/METChainConfiguration.py @@ -20,7 +20,7 @@ class METChainConfiguration(ChainConfigurationBase): # Only some subset of keys in the METChainParts dictionary describe # reconstruction details - only these keys are passed down into the menu # sequence (the actual hypo tool is created later) - self.recoDict = extractMETRecoDict(self.dict["chainParts"]) + self.recoDict = extractMETRecoDict(self.chainPart) # ---------------------- # Assemble the chain depending on information from chainName @@ -39,4 +39,4 @@ class METChainConfiguration(ChainConfigurationBase): stepName = "Step1_met_{}".format(metRecoDictToString(self.recoDict) ) conf = AlgConfig.fromRecoDict(**self.recoDict) seq = conf.menuSequence - return ChainStep(stepName, [seq], multiplicity=[1]) + return ChainStep(stepName, [seq], multiplicity=[1], chainDicts=[self.dict]) diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/ChainConfigurationBase.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/ChainConfigurationBase.py index 97c90a6a1abf6d741490b8619841874e2e432135..68a1c24e67cbc9d87b66f5bfcce7b037bc2f0933 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/ChainConfigurationBase.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/ChainConfigurationBase.py @@ -24,7 +24,11 @@ class ChainConfigurationBase(object): self.chainName = self.dict['chainName'] self.chainL1Item = self.dict['L1item'] - self.chainPart = self.dict['chainParts'] + # check dictionary contains only one chain part + if len( self.dict['chainParts'] ) != 1: + raise RuntimeError( "Passed chain dictionary with %i chainParts to ChainConfigurationBase, but this constructor only supports chains with a single part" % len( self.dict['chainParts'] ) ) + + self.chainPart = self.dict['chainParts'][0] self.L1Threshold = self.chainPart['L1threshold'] # now threshold is always there self.mult = int(self.chainPart['multiplicity']) self.chainPartName = self.chainPart['chainPartName'] @@ -45,7 +49,7 @@ class ChainConfigurationBase(object): seqArray = [] for sequenceCfg in sequenceCfgArray: seqArray.append( RecoFragmentsPool.retrieve( sequenceCfg, None)) - return ChainStep(stepName, seqArray, [self.mult], comboToolConfs=comboTools) + return ChainStep(stepName, seqArray, [self.mult], [self.dict], comboToolConfs=comboTools) def buildChain(self, chainSteps): myChain = Chain(name = self.chainName, diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/ChainDictTools.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/ChainDictTools.py index d404a001734a7c8c1a5c37a7ddc24bc17e1e37b2..8edf28a5f766d69c99b63200be6b0fa84a613363 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/ChainDictTools.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/ChainDictTools.py @@ -91,7 +91,7 @@ def splitChainDict(chainDict): listOfChainDicts = [] for chainPart in chainDict['chainParts']: newChainDict = deepcopy(chainDict) - newChainDict['chainParts'] = chainPart + newChainDict['chainParts'] = [chainPart] listOfChainDicts += [newChainDict] return listOfChainDicts diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/ChainMerging.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/ChainMerging.py index f6380dae0c1d346a30496ac9a83f29bf1d60000a..f24e9e05ac3913cec9b1e987931c9b65da525300 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/ChainMerging.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/ChainMerging.py @@ -78,13 +78,18 @@ def mergeParallel(chainDefList, offset): def makeChainSteps(steps): + from copy import deepcopy + from TrigCompositeUtils.TrigCompositeUtils import legName stepName = '' stepSeq = [] stepMult = [] stepNumber = '' log.verbose(" steps %s ", steps) stepName = "merged" + stepDicts = [] + count = 0 comboHypoTools = [] + for step in steps: if step is None: continue @@ -110,10 +115,14 @@ def makeChainSteps(steps): # set the multiplicity of all the legs stepMult.append(sum(step.multiplicity)) comboHypoTools.extend(step.comboToolConfs) + # update the chain dict list for the combined step with the chain dict from this step + stepDicts += deepcopy(step.chainDicts) + # for merged steps, we need to update the name to add the leg name + stepDicts[-1]['chainName'] = legName(stepDicts[-1]['chainName'], count) + count = count + 1 - comboHypoTools = list(set(comboHypoTools)) - theChainStep = ChainStep(stepName, Sequences=stepSeq, multiplicity=stepMult, comboToolConfs=comboHypoTools) + theChainStep = ChainStep(stepName, Sequences=stepSeq, multiplicity=stepMult, chainDicts=stepDicts, comboToolConfs=comboHypoTools) log.debug("Merged step: \n %s", theChainStep) diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/MenuComponents.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/MenuComponents.py index 104813eaac1cd754a28f7bbd6afc5eae02afd944..e68b209822cb27fc41fa978c0fdbb474fab25b64 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/MenuComponents.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/MenuComponents.py @@ -526,14 +526,14 @@ class MenuSequence(object): if type(self._hypo) is list: hyponame=[] hypotool=[] - for hp, hptool in zip(self._hypo, self.hypoToolConf): + for hp, hptool in zip(self._hypo, self._hypoToolConf): hyponame.append( hp.Alg.name() ) hypotool.append( hptool.name ) return "MenuSequence::%s \n Hypo::%s \n Maker::%s \n Sequence::%s \n HypoTool::%s"\ %(self.name, hyponame, self._maker.Alg.name(), self.sequence.Alg.name(), hypotool) else: hyponame = self._hypo.Alg.name() - hypotool = self.hypoToolConf.name + hypotool = self._hypoToolConf.name return "MenuSequence::%s \n Hypo::%s \n Maker::%s \n Sequence::%s \n HypoTool::%s\n"\ %(self.name, hyponame, self._maker.Alg.name(), self.sequence.Alg.name(), hypotool) @@ -639,25 +639,43 @@ class Chain(object): """ This is extrapolating the hypotool configuration from the chain name""" log.debug("decodeHypoToolConfs for chain %s", self.name) from TriggerMenuMT.HLTMenuConfig.Menu.ChainDictTools import splitChainInDict + + # this spliting is only needed for chains which don't yet attach + # the dictionaries to the chain steps. It should be removed + # later once that migration is done. listOfChainDictsLegs = splitChainInDict(self.name) + for step in self.steps: if len(step.sequences) == 0: continue step_mult = [str(m) for m in step.multiplicity] - menu_mult = [part['chainParts'][0]['multiplicity'] for part in listOfChainDictsLegs ] - if step_mult != menu_mult: - # need to agree on the procedure: if the jet code changes the chainparts accordingly, this will never happen - log.warning("Got multiplicty %s from chain parts, but have %s legs. This is expected now for jets, so this tmp fix is added:", menu_mult, step_mult) - chainDict = listOfChainDictsLegs[0] - chainDict['chainName']= self.name # rename the chaindict to remove the leg name - for seq in step.sequences: - seq.createHypoTools( chainDict ) #this creates the HypoTools - continue - # add one hypotool per sequence and chain part - for seq, onePartChainDict in zip(step.sequences, listOfChainDictsLegs): - seq.createHypoTools( onePartChainDict )#this creates the HypoTools + if len(step.chainDicts) > 0: + # new way to configure hypo tools, works if the chain dictionaries have been attached to the steps + log.info('%s in new hypo tool creation method', self.name) + for seq, onePartChainDict in zip(step.sequences, step.chainDicts): + log.info(' onePartChainDict:') + log.info(' ' + str(onePartChainDict)) + seq.createHypoTools( onePartChainDict ) + + else: + # legacy way, to be removed once all signatures pass the chainDicts to the steps + log.info('%s in old hypo tool creation method', self.name) + menu_mult = [ part['chainParts'][0]['multiplicity'] for part in listOfChainDictsLegs ] + #print 'step, step_mult, menu_mult: ' + step.name + ' ' + str(step_mult) + ' ' + str(menu_mult) + if step_mult != menu_mult: + # Probably this shouldn't happen, but it currently does + log.warning("Got multiplicty %s from chain parts, but have %s legs. This is expected only for jet chains, but it has happened for %s, using the first chain dict", menu_mult, step_mult, self.name) + firstChainDict = listOfChainDictsLegs[0] + firstChainDict['chainName']= self.name # rename the chaindict to remove the leg name + for seq in step.sequences: + seq.createHypoTools( firstChainDict ) + + else: + # add one hypotool per sequence and chain part + for seq, onePartChainDict in zip(step.sequences, listOfChainDictsLegs): + seq.createHypoTools( onePartChainDict ) step.createComboHypoTools(self.name) @@ -756,7 +774,13 @@ class StepComponent(object): class ChainStep(object): """Class to describe one step of a chain; if multiplicity is greater than 1, the step is combo/combined. Set one multiplicity value per sequence""" - def __init__(self, name, Sequences=[], multiplicity=[1], comboToolConfs=[]): + def __init__(self, name, Sequences=[], multiplicity=[1], chainDicts=[], comboToolConfs=[]): + + # sanity check on inputs + if len(Sequences) != len(multiplicity): + # empty steps have one entry in multiplicity + if not (len(Sequences)==0 and len(multiplicity)==1): + raise RuntimeError("Tried to configure a ChainStep %s with %i Sequences and %i multiplicities. These lists must have the same size" % (name, len(Sequences), len(multiplicity)) ) self.name = name self.sequences=Sequences @@ -764,6 +788,7 @@ class ChainStep(object): self.comboToolConfs=comboToolConfs self.isCombo=sum(multiplicity)>1 self.combo=None + self.chainDicts = chainDicts if self.isCombo: self.makeCombo() diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Muon/generateMuon.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Muon/generateMuon.py index 1f7726c0f6d15cd4f6f2127f982daea14b614cc5..87998b2f4f376c37ab2083554b16bd00b3e43014 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Muon/generateMuon.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Muon/generateMuon.py @@ -6,12 +6,15 @@ from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator from TrigL2MuonSA.TrigL2MuonSAConfig_newJO import l2MuFastRecoCfg, l2MuFastHypoCfg from TrigMuonHypoMT.TrigMuonHypoMTConfig import TrigMufastHypoToolFromDict +from TriggerMenuMT.HLTMenuConfig.Menu.ChainDictTools import splitChainDict def fakeHypoAlgCfg(flags, name="FakeHypoForMuon"): from TrigUpgradeTest.TrigUpgradeTestConf import HLTTest__TestHypoAlg return HLTTest__TestHypoAlg( name, Input="" ) def generateChains( flags, chainDict ): + chainDict = splitChainDict(chainDict)[0] + stepName = getChainStepName('Muon', 1) stepReco, stepView = createStepView(stepName) @@ -84,6 +87,7 @@ def generateChains( flags, chainDict ): l1Thresholds=[] for part in chainDict['chainParts']: l1Thresholds.append(part['L1threshold']) + import pprint pprint.pprint(chainDict) chain = Chain( name=chainDict['chainName'], L1Thresholds=l1Thresholds, ChainSteps=[ l2muFastStep, efmuMSStep ] )