From 93b9046998a4731ef63456f591a9684c31be76f2 Mon Sep 17 00:00:00 2001 From: Tomasz Bold <tomasz.bold@gmail.com> Date: Wed, 2 Sep 2020 17:31:33 +0100 Subject: [PATCH] Simplified construction of sequences for combined chains --- .../Electron/generateElectron.py | 6 +-- .../python/HLTMenuConfig/Jet/generateJet.py | 4 +- .../HLTMenuConfig/Menu/HLTCFConfig_newJO.py | 48 ++++++++----------- .../python/HLTMenuConfig/Menu/LS2_v1_newJO.py | 6 ++- .../python/HLTMenuConfig/Muon/generateMuon.py | 6 +-- .../HLTMenuConfig/Photon/generatePhoton.py | 6 +-- 6 files changed, 36 insertions(+), 40 deletions(-) diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Electron/generateElectron.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Electron/generateElectron.py index afd53e4600dd..0a1f385d957f 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Electron/generateElectron.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Electron/generateElectron.py @@ -2,7 +2,7 @@ from TriggerMenuMT.HLTMenuConfig.Electron.ElectronRecoSequences import l2CaloRecoCfg, l2CaloHypoCfg from TriggerMenuMT.HLTMenuConfig.Menu.MenuComponents import CAMenuSequence, \ - ChainStep, Chain, getChainStepName, createStepView + ChainStep, Chain, createStepView from TrigEgammaHypo.TrigEgammaFastCaloHypoTool import TrigEgammaFastCaloHypoToolFromDict from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator @@ -18,7 +18,7 @@ def generateChains( flags, chainDict ): import pprint pprint.pprint( chainDict ) - firstStepName = getChainStepName('Electron', 1) + firstStepName = 'FastCaloElectron' stepReco, stepView = createStepView(firstStepName) accCalo = ComponentAccumulator() @@ -48,7 +48,7 @@ def generateChains( flags, chainDict ): fastCaloStep = ChainStep(name=firstStepName, Sequences=[fastCaloSequence], chainDicts=[chainDict]) - secondStepName = getChainStepName('Electron', 2) + secondStepName = 'ElectronFTF' stepReco, stepView = createStepView(secondStepName) accTrk = ComponentAccumulator() diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Jet/generateJet.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Jet/generateJet.py index bfd4ab99895c..183e5aa9f0c8 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Jet/generateJet.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Jet/generateJet.py @@ -1,6 +1,6 @@ # Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration -from TriggerMenuMT.HLTMenuConfig.Menu.MenuComponents import CAMenuSequence, ChainStep, Chain, InEventReco, getChainStepName, createStepView +from TriggerMenuMT.HLTMenuConfig.Menu.MenuComponents import CAMenuSequence, ChainStep, Chain, InEventReco, createStepView from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator from AthenaConfiguration.ComponentFactory import CompFactory import pprint @@ -24,7 +24,7 @@ def HLTCaloCellMakerCfg( cellsname, cdaSvc ): def generateChains( flags, chainDict ): - stepName = getChainStepName('Jet', 1) + stepName = 'Jet' stepReco, stepView = createStepView(stepName) acc = ComponentAccumulator() diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/HLTCFConfig_newJO.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/HLTCFConfig_newJO.py index 4a8fa7f68983..3353d4bfd39a 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/HLTCFConfig_newJO.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/HLTCFConfig_newJO.py @@ -65,6 +65,18 @@ def generateDecisionTree(chains): acc.addSequence(seq, parentName = allRecoSeqName ) return seq + @memoize + def getComboSequences( stepNumber, stepName ): + """ + """ + singleMenuSeqName = getSingleMenuSeq( stepNumber, stepName ).name + + stepComboName = "Combo{}{}".format(stepNumber,stepName) + acc.addSequence( seqAND(stepComboName), parentName=singleMenuSeqName ) + + stepComboRecoName ="ComboReco{}{}".format(stepNumber, stepName) + acc.addSequence( parOR(stepComboRecoName), parentName=stepComboName ) + return acc.getSequence(stepComboName), acc.getSequence(stepComboRecoName) @memoize def getFilterAlg( stepNumber, stepName ): @@ -161,39 +173,19 @@ def generateDecisionTree(chains): for chain in chains: for stepCounter, step in enumerate( chain.steps, 1 ): getFilterAlg( stepCounter, step.name ) - recoSeqName = getSingleMenuSeq( stepCounter, step.name ).name - + menuSeqName = getSingleMenuSeq( stepCounter, step.name ).name if step.isCombo: - # add merged reco sequence - stepRecoName = step.name + CFNaming.RECO_POSTFIX - stepViewName = step.name + CFNaming.VIEW_POSTFIX - - acc.addSequence( seqAND(stepViewName), parentName=recoSeqName ) - acc.addSequence( parOR(stepRecoName), parentName=stepViewName ) + # add sequences that allows reconstructions to be run in parallel, followed (in sequence) by the combo hypo + comboSeq, comboRecoSeq = getComboSequences( stepCounter, step.name ) for sequence in step.sequences: - for stepView in sequence.ca.getSequence().Members: - for viewMember in stepView.Members: - if isHypoBase(viewMember): - # add hypo alg to view sequence - acc.addEventAlgo( viewMember, sequenceName=stepViewName ) - else: - # add reco sequence to merged _reco - for recoAlg in viewMember.Members: - acc.addSequence( recoAlg, parentName=stepRecoName ) - - # elements from ca were moved above to the appropriate sequences - # so sequence and algorithms are considered as merged - sequence.ca._algorithms = {} - sequence.ca._sequence.Members = [] - acc.merge(sequence.ca, sequenceName=recoSeqName) - - # create combo hypo - comboHypo = CompFactory.ComboHypo( step.combo.Alg.getName() ) - acc.addEventAlgo( comboHypo, sequenceName=stepViewName ) + acc.merge( sequence.ca, sequenceName=comboRecoSeq.name) + comboHypo = CompFactory.ComboHypo( "CH"+step.name ) + acc.addEventAlgo( comboHypo, sequenceName=comboSeq.name ) + pass else: - acc.merge( step.sequences[0].ca, sequenceName=recoSeqName ) + acc.merge( step.sequences[0].ca, sequenceName=menuSeqName ) # cleanup settings made by Chain & related objects (can be removed in the future) diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/LS2_v1_newJO.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/LS2_v1_newJO.py index 24f9c763c64d..c60345206465 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/LS2_v1_newJO.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/LS2_v1_newJO.py @@ -61,7 +61,8 @@ def setupMenu(flags): ] flags.Trigger.menu.combined = [ - ChainProp(name='HLT_e7_mu10_L1EM7_MU10', groups=SingleElectronGroup) + ChainProp(name='HLT_e7_mu10_L1EM7_MU10', groups=SingleElectronGroup), + ChainProp(name='HLT_e7_mu12_L1EM7_MU10', groups=SingleElectronGroup) ] if __name__ == "__main__": @@ -93,6 +94,9 @@ if __name__ == "__main__": menu = generateMenu( ConfigFlags ) acc.merge(menu) + + acc.printConfig() + # print all hypo algs and their hypo tools for debugging from AthenaCommon.CFElements import flatAlgorithmSequences fs = flatAlgorithmSequences( menu.getSequence('HLTAllSteps') ) diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Muon/generateMuon.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Muon/generateMuon.py index 9fd51580390e..2f4d994c7334 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Muon/generateMuon.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Muon/generateMuon.py @@ -1,6 +1,6 @@ # Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration -from TriggerMenuMT.HLTMenuConfig.Menu.MenuComponents import CAMenuSequence, ChainStep, Chain, getChainStepName, createStepView +from TriggerMenuMT.HLTMenuConfig.Menu.MenuComponents import CAMenuSequence, ChainStep, Chain, createStepView from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator from TrigL2MuonSA.TrigL2MuonSAConfig_newJO import l2MuFastAlgCfg, l2MuFastHypoCfg @@ -115,7 +115,7 @@ def generateChains( flags, chainDict ): chainDict = splitChainDict(chainDict)[0] # Step 1 (L2MuonSA) - stepName = getChainStepName('Muon', 1) + stepName = 'L2MuonSA' stepReco, stepView = createStepView(stepName) acc = ComponentAccumulator() @@ -215,7 +215,7 @@ def generateChains( flags, chainDict ): # Please set up L2muComb step here #EF MS only - stepEFMSName = getChainStepName('EFMSMuon', 2) + stepEFMSName = 'EFMSMuon' stepEFMSReco, stepEFMSView = createStepView(stepEFMSName) #Clone and replace offline flags so we can set muon trigger specific values diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Photon/generatePhoton.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Photon/generatePhoton.py index cc0af567ee5c..c5bd2be44605 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Photon/generatePhoton.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Photon/generatePhoton.py @@ -3,7 +3,7 @@ from TriggerMenuMT.HLTMenuConfig.Electron.ElectronRecoSequences import l2CaloRecoCfg, l2CaloHypoCfg from TriggerMenuMT.HLTMenuConfig.Photon.PhotonRecoSequences import l2PhotonRecoCfg, l2PhotonHypoCfg from TriggerMenuMT.HLTMenuConfig.Menu.MenuComponents import CAMenuSequence, \ - ChainStep, Chain, getChainStepName, createStepView + ChainStep, Chain, createStepView from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator from TrigEgammaHypo.TrigEgammaFastCaloHypoTool import TrigEgammaFastCaloHypoToolFromDict @@ -16,7 +16,7 @@ log = logging.getLogger( 'TriggerMenuMT.HLTMenuConfig.Photon.generatePhoton' ) def generateChains(flags, chainDict): - firstStepName = getChainStepName('Photon', 1) + firstStepName = 'FastCaloPhoton' stepReco, stepView = createStepView(firstStepName) accCalo = ComponentAccumulator() @@ -44,7 +44,7 @@ def generateChains(flags, chainDict): fastCaloStep = ChainStep(firstStepName, [fastCaloSequence]) - secondStepName = getChainStepName('Photon', 2) + secondStepName = 'FastPhoton' stepReco, stepView = createStepView(secondStepName) accPhoton = ComponentAccumulator() -- GitLab