From 6fbc5245e99d477032dede671ba82e48679b75c8 Mon Sep 17 00:00:00 2001 From: Francesca Pastore <francesca.pastore@cern.ch> Date: Thu, 8 Dec 2022 16:44:08 +0100 Subject: [PATCH 01/15] fix conflict --- .../python/runHLT_standalone_newJO.py | 5 +- .../python/CFtest/test_menu_cf_newJO.py | 2 +- .../HLT/Config/ChainConfigurationBase.py | 2 +- .../HLT/Config/ControlFlow/HLTCFComponents.py | 132 ++++++- .../HLT/Config/ControlFlow/HLTCFConfig.py | 60 +-- .../HLT/Config/ControlFlow/HLTCFConfig_CA.py | 343 ++++++++++++++++++ .../Config/ControlFlow/HLTCFConfig_newJO.py | 8 +- .../python/HLT/Config/GenerateMenuMT.py | 1 + .../python/HLT/Config/GenerateMenuMT_newJO.py | 23 +- .../python/HLT/Config/MenuComponents.py | 103 ++++-- .../Electron/TrigEMBremCollectionBuilder.py | 8 +- .../python/HLT/Menu/Dev_pp_run3_v1.py | 3 +- .../python/HLT/Menu/Dev_pp_run3_v1_newJO.py | 8 +- .../python/HLT/Muon/MuonChainConfiguration.py | 4 +- .../python/HLT/Muon/generateMuon.py | 10 + 15 files changed, 621 insertions(+), 91 deletions(-) create mode 100644 Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFConfig_CA.py mode change 100644 => 100755 Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/GenerateMenuMT_newJO.py diff --git a/Trigger/TriggerCommon/TriggerJobOpts/python/runHLT_standalone_newJO.py b/Trigger/TriggerCommon/TriggerJobOpts/python/runHLT_standalone_newJO.py index 470e40dab969..f1a6ffba0c22 100755 --- a/Trigger/TriggerCommon/TriggerJobOpts/python/runHLT_standalone_newJO.py +++ b/Trigger/TriggerCommon/TriggerJobOpts/python/runHLT_standalone_newJO.py @@ -3,7 +3,6 @@ # # Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration # - from AthenaCommon.Logging import logging log = logging.getLogger('runHLT_standalone_newJO') @@ -57,7 +56,9 @@ flags.addFlag("Trigger.selectChains",[]) flags.addFlag("Trigger.disableChains",[]) -flags.Trigger.enabledSignatures = ['Muon', 'Photon','Electron'] +flags.Trigger.enabledSignatures = ['Muon'] #, 'Photon','Electron'] +flags.Trigger.selectChains = ['HLT_mu4_L1MU3V','HLT_mu8_L1MU5VF','HLT_2mu6_L12MU5VF', 'HLT_mu4_mu6_L12MU3V'] + #flags.Trigger.disableChains=["HLT_2mu4_l2io_invmDimu_L1BPH-2M9-0DR15-2MU3VF", "HLT_2mu4_l2io_invmDimu_L1BPH-2M9-0DR15-2MU3V", "HLT_2mu6_l2io_invmDimu_L1BPH-2M9-2DR15-2MU5VF"] # exclude jets for now, since their MenuSeuqnece Structure needs more work to migrate diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/CFtest/test_menu_cf_newJO.py b/Trigger/TriggerCommon/TriggerMenuMT/python/CFtest/test_menu_cf_newJO.py index bc775a776b3c..de06371a9726 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/CFtest/test_menu_cf_newJO.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/CFtest/test_menu_cf_newJO.py @@ -98,7 +98,7 @@ def generateEmuMenu(ConfigFlags): import TriggerMenuMT.HLT.Config.ControlFlow.HLTCFConfig_newJO # set DEBUG flag on the control-flow builder (before building) TriggerMenuMT.HLT.Config.ControlFlow.HLTCFConfig_newJO.log.setLevel(DEBUG) - menuAcc = generateDecisionTree(ConfigFlags, HLTMenuConfig.configsList()) + menuAcc = generateDecisionTree(ConfigFlags, HLTMenuConfig) menuAcc.wasMerged() menuAcc.printConfig() diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ChainConfigurationBase.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ChainConfigurationBase.py index 49f43d0209e9..4ee8c0b8b449 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ChainConfigurationBase.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ChainConfigurationBase.py @@ -3,7 +3,7 @@ from AthenaCommon.Logging import logging log = logging.getLogger(__name__) - +log.setLevel(logging.DEBUG) import abc from TriggerMenuMT.HLT.Config.MenuComponents import Chain, ChainStep, RecoFragmentsPool diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFComponents.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFComponents.py index 07c62d358778..ba33f2d109b2 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFComponents.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFComponents.py @@ -2,11 +2,14 @@ from TriggerMenuMT.HLT.Config.MenuComponents import AlgNode from TriggerMenuMT.HLT.Config.ControlFlow.MenuComponentsNaming import CFNaming +from TriggerMenuMT.HLT.Config.Utility.HLTMenuConfig import HLTMenuConfig from AthenaCommon.CFElements import compName +from functools import lru_cache from AthenaCommon.Logging import logging log = logging.getLogger( __name__ ) +log.setLevel(logging.DEBUG) from AthenaConfiguration.ComponentFactory import CompFactory RoRSeqFilter = CompFactory.RoRSeqFilter @@ -50,11 +53,17 @@ class SequenceFilterNode(AlgNode): def __repr__(self): return "SequenceFilter::%s [%s] -> [%s], chains=%s"%(compName(self.Alg),' '.join(map(str, self.getInputList())),' '.join(map(str, self.getOutputList())), self.getChains()) - +from AthenaConfiguration.ComponentFactory import isRun3Cfg class RoRSequenceFilterNode(SequenceFilterNode): - def __init__(self, name): + def __init__(self, name): Alg= RoRSeqFilter(name) + #if isRun3Cfg(): + # self.acc=ComponentAccumulator() + # self.acc.addEventAlgo(Alg) + SequenceFilterNode.__init__(self, Alg, 'Input', 'Output') + self.resetInput() + self.resetOutput() ## why do we need this in CA mode?? def addChain(self, name, input_name): input_index = self.readInputList().index(input_name) @@ -78,12 +87,27 @@ class RoRSequenceFilterNode(SequenceFilterNode): from AthenaCommon.AlgSequence import AthSequencer +from GaudiKernel.DataHandle import DataHandle class PassFilterNode(SequenceFilterNode): """ PassFilter is a Filter node without inputs/outputs, so OutputProp=InputProp=empty""" def __init__(self, name): - Alg=AthSequencer( "PassSequence" ) + Alg=CompFactory.AthSequencer( "PassSequence" ) Alg.IgnoreFilterPassed=True # always pass SequenceFilterNode.__init__(self, Alg, '', '') + + def addOutput(self, name): + self.outputs.append(str(name) if isinstance(name, DataHandle) else name) + + def addInput(self, name): + self.inputs.append(str(name) if isinstance(name, DataHandle) else name) + + def getOutputList(self): + return self.outputs + + def getInputList(self): + return self.inputs + + ######################################################### @@ -96,18 +120,20 @@ class CFSequence(object): def __init__(self, ChainStep, FilterAlg): self.filter = FilterAlg self.step = ChainStep + self.combo = self.step.combo #copy this instance self.connectCombo() self.setDecisions() + log.debug("CFSequence.__init: created %s ",self) def setDecisions(self): """ Set the output decision of this CFSequence as the hypo outputdecision; In case of combo, takes the Combo outputs""" self.decisions=[] # empty steps: - if self.step.combo is None: + if self.combo is None: self.decisions.extend(self.filter.getOutputList()) else: - self.decisions.extend(self.step.combo.getOutputList()) + self.decisions.extend(self.combo.getOutputList()) log.debug("CFSequence: set out decisions: %s", self.decisions) @@ -141,24 +167,104 @@ class CFSequence(object): def connectCombo(self): """ connect Combo to Hypos""" - if self.step.combo is None: + if self.combo is None: return for seq in self.step.sequences: combo_input=seq.getOutputList()[0] - self.step.combo.addInput(combo_input) - inputs = self.step.combo.readInputList() + self.combo.addInput(combo_input) + inputs = self.combo.readInputList() legindex = inputs.index(combo_input) - log.debug("CFSequence.connectCombo: adding input to %s: %s", self.step.combo.Alg.getName(), combo_input) + log.debug("CFSequence.connectCombo: adding input to %s: %s", self.combo.Alg.getName(), combo_input) # inputs are the output decisions of the hypos of the sequences - combo_output=CFNaming.comboHypoOutputName (self.step.combo.Alg.getName(), legindex) - self.step.combo.addOutput(combo_output) - log.debug("CFSequence.connectCombo: adding output to %s: %s", self.step.combo.Alg.getName(), combo_output) + combo_output=CFNaming.comboHypoOutputName (self.combo.Alg.getName(), legindex) + self.combo.addOutput(combo_output) + log.debug("CFSequence.connectCombo: adding output to %s: %s", self.combo.Alg.getName(), combo_output) + + + def createHypoTools(self, chain,stepDicts): + """ stolen from Chain class""" + if self.step.combo is None: + return + log.debug("createHypoTools for Step %s", self.step.name) + log.debug('%s in new hypo tool creation method, step mult= %d', chain, sum(self.step.multiplicity)) + log.debug("N(seq)=%d, N(chainDicts)=%d", len(self.step.sequences), len(stepDicts)) + for seq, onePartChainDict in zip(self.step.sequences, stepDicts): + log.debug(' seq: %s, onePartChainDict:', seq.name) + log.debug(' %s', onePartChainDict) + seq.createHypoTools( onePartChainDict ) + + chainDict = HLTMenuConfig.getChainDictFromChainName(chain) + self.combo.createComboHypoTools(chainDict, self.step.comboToolConfs) + + #return self.step.createComboHypoTools(chain) + + def __repr__(self): return "--- CFSequence ---\n + Filter: %s \n + decisions: %s\n + %s \n"%(\ - self.filter.Alg.getName(), self.decisions, self.step) + compName(self.filter.Alg), self.decisions, self.step) +from AthenaCommon.CFElements import parOR, seqAND +from AthenaCommon.AlgSequence import AlgSequence +from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator +from TriggerMenuMT.HLT.Config.ControlFlow.HLTCFTools import isComboHypoAlg +from AthenaCommon.CFElements import findAllAlgorithms, getSequenceChildren, isSequence +from AthenaConfiguration.ComponentAccumulator import printProperties + +class CFSequenceCA(CFSequence): + """Class to describe the flow of decisions through ChainStep + filter with their connections (input, output) + A Filter can have more than one input/output if used in different chains, so this class stores and manages all of them (when doing the connect) + """ + def __init__(self, ChainStep, FilterAlg): + log.debug(" *** Create CFSequence %s with Filter %s", ChainStep.name, FilterAlg.Alg.name) + self.ca = ComponentAccumulator() + self.empty= ChainStep.isEmpty + #empty step: add the PassSequence, one instance only is appended to the tree + if self.empty: + seqAndWithFilter = FilterAlg.Alg + else: + seqAndWithFilter = seqAND(ChainStep.name) + + self.ca.addSequence(seqAndWithFilter) + self.seq=seqAndWithFilter + + if not self.empty: + self.ca.addEventAlgo(FilterAlg.Alg, sequenceName=seqAndWithFilter.name) + stepReco = parOR(ChainStep.name + CFNaming.RECO_POSTFIX) # all reco algorithms from all the sequences in a parallel sequence + self.ca.addSequence(stepReco, parentName=seqAndWithFilter.name) + log.info("created parOR %s inside seqAND %s ", stepReco.name, seqAndWithFilter.name) + + for menuseq in ChainStep.sequences: + self.ca.merge(menuseq.ca, sequenceName=stepReco.name) + + CFSequence.__init__(self, ChainStep,FilterAlg) + if self.combo is not None: + self.ca.addEventAlgo(self.step.combo.Alg, sequenceName=seqAndWithFilter.name) + + #printProperties(log,self.combo.Alg) + #log.debug(self.seq.Members) + + #@property + #def combo(self): + # self.step.combo.Alg= self.findComboHypoAlg() #self.ca.getEventAlgo(self.step.combo.Alg.name) + # return self.combo + + + + @lru_cache(None) + def findComboHypoAlg(self): + log.debug(self.seq.Members) + for alg in getSequenceChildren(self.seq): + log.debug("found %s",alg.name) + if not isSequence(alg): + if compName(alg) == self.step.combo.Alg.name: + #RecursionError: maximum recursion depth exceeded in comparison + #for alg in findAllAlgorithms( self.seq , self.step.combo.Alg.name): + if isComboHypoAlg( alg ): + return alg + + return None \ No newline at end of file diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFConfig.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFConfig.py index f215b2a7b415..4a44ac81ff39 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFConfig.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFConfig.py @@ -47,13 +47,13 @@ from collections import OrderedDict, defaultdict import re log = logging.getLogger( __name__ ) - +log.setLevel(logging.DEBUG) #### Functions to create the CF tree from CF configuration objects def makeSummary(name, flatDecisions): """ Returns a TriggerSummaryAlg connected to given decisions""" - summary = TriggerSummaryAlg( CFNaming.stepSummaryName(name) ) + summary = CompFactory.TriggerSummaryAlg( CFNaming.stepSummaryName(name) ) summary.InputDecision = "HLTSeedingSummary" summary.FinalDecisions = list(OrderedDict.fromkeys(flatDecisions)) return summary @@ -79,7 +79,7 @@ def createStepFilterNode(name, seq_list, dump=False): filter_list=[] for seq in seq_list: filterAlg = seq.filter.Alg - log.debug("createStepFilterNode: Add %s to filter node %s", filterAlg.name(), name) + log.debug("createStepFilterNode: Add %s to filter node %s", filterAlg.name, name) if filterAlg not in filter_list: filter_list.append(filterAlg) @@ -108,8 +108,8 @@ def createCFTree(CFseq): for menuseq in CFseq.step.sequences: menuseq.addToSequencer(recoSeqSet,hypoSet) - stepReco += sorted(list(recoSeqSet), key=lambda t: t.name()) - seqAndWithFilter += sorted(list(hypoSet), key=lambda t: t.name()) + stepReco += sorted(list(recoSeqSet), key=lambda t: t.name) + seqAndWithFilter += sorted(list(hypoSet), key=lambda t: t.name) if CFseq.step.combo is not None: seqAndWithFilter += CFseq.step.combo.Alg @@ -289,7 +289,7 @@ def matrixDisplay( allCFSeq ): if seq.name == "Empty": mx[stepNumber, "Empty"].extend(chains) else: - mx[stepNumber, seq.sequence.Alg.name()].extend(chains) + mx[stepNumber, seq.sequence.Alg.name].extend(chains) # sort dictionary by fist key=step sorted_mx = OrderedDict(sorted( list(mx.items()), key= lambda k: k[0])) @@ -329,7 +329,7 @@ def sequenceScanner( HLTNode ): if isSequence(c): # Detect whether this is the view sequence pointed to # by the EV creator alg, or if it is in such a sequence - inView = c.name()==inViewSequence or childInView + inView = c.name==inViewSequence or childInView stepIndex = _mapSequencesInSteps(c, stepIndex, childInView=inView) _seqMapInStep[compName(c)].add((stepIndex,inView)) log.verbose("sequenceScanner: Child %s of sequence %s is in view? %s --> '%s'", compName(c), name, inView, inViewSequence) @@ -365,8 +365,8 @@ def sequenceScanner( HLTNode ): def decisionTreeFromChains(flags, HLTNode, chains, allDicts, newJO): """ Creates the decision tree, given the starting node and the chains containing the sequences """ - log.info("[decisionTreeFromChains] Run decisionTreeFromChains on %s", HLTNode.name()) - HLTNodeName= HLTNode.name() + log.info("[decisionTreeFromChains] Run decisionTreeFromChains on %s", HLTNode.name) + HLTNodeName= HLTNode.name if len(chains) == 0: log.info("[decisionTreeFromChains] Configuring empty decisionTree") return [] @@ -432,6 +432,7 @@ def createDataFlow(chains, allDicts): # make one filter per step: sequenceFilter= None + comboHypo=None filterName = CFNaming.filterName(chainStep.name) if chainStep.isEmpty: filterOutput= filterInput @@ -447,34 +448,36 @@ def createDataFlow(chains, allDicts): CFseqList[nstep].append(CFseq) lastDecisions=CFseq.decisions lastCFseq=CFseq - else: + else: if len(foundCFSeq) > 1: - log.error("Found more than one sequence containing filter %s", filterName) + log.error("Found more than one sequence containing filter %s", filterName) + lastCFseq=foundCFSeq[0] sequenceFilter=lastCFseq.filter - [ sequenceFilter.addInput(inputName) for inputName in filterInput ] - [ sequenceFilter.addOutput(outputName) for outputName in filterOutput ] - lastCFseq.connect(filterOutput) + if len(list(set(sequenceFilter.getInputList()).intersection(filterInput))) == 0: + [ sequenceFilter.addInput(inputName) for inputName in filterInput ] + [ sequenceFilter.addOutput(outputName) for outputName in filterOutput ] + lastCFseq.connect(filterOutput) if chainStep.isEmpty: lastDecisions=filterOutput else: lastDecisions=lastCFseq.decisions - + print("lastDecisions are ",lastDecisions) # add chains to the filter: chainLegs = chainStep.getChainLegs() if len(chainLegs) != len(filterInput): log.error("[createDataFlow] lengths of chainlegs = %s differ from inputs=%s", str(chainLegs), str(filterInput)) raise Exception("[createDataFlow] Cannot proceed, exiting.") for finput, leg in zip(filterInput, chainLegs): + log.debug("Adding chain %s to input %s of %s", leg, finput,compName(sequenceFilter.Alg)) sequenceFilter.addChain(leg, finput) - log.debug("Adding chain %s to input %s of %s", leg, finput,sequenceFilter.Alg.name()) - + log.debug("Now Filter has chains: %s", sequenceFilter.getChains()) log.debug("Now Filter has chains/input: %s", sequenceFilter.getChainsPerInput()) - if chainStep.combo is not None: - chainStep.combo.addChain( [d for d in allDicts if d['chainName'] == chain.name ][0]) - log.debug("Added chains to ComboHypo: %s",chainStep.combo.getChains()) + if lastCFseq.combo is not None: + lastCFseq.combo.addChain( [d for d in allDicts if d['chainName'] == chain.name ][0]) + log.debug("Added chains to ComboHypo: %s",lastCFseq.combo.getChains()) else: log.debug("Combo not implemented if it's empty step") @@ -485,7 +488,7 @@ def createDataFlow(chains, allDicts): log.debug(dec) #end of loop over steps - log.debug("\n Built CF for chain %s with %d steps: \n - %s ", chain.name,len(chain.steps),'\n - '.join(map(str, [{step.name:step.multiplicity} for step in chain.steps]))) + log.debug("\n Built CD for chain %s with %d steps: \n - %s ", chain.name,len(chain.steps),'\n - '.join(map(str, [{step.name:step.multiplicity} for step in chain.steps]))) #end of loop over chains @@ -496,7 +499,7 @@ def createDataFlow(chains, allDicts): def createControlFlow(flags, HLTNode, CFseqList): """ Creates Control Flow Tree starting from the CFSequences""" - HLTNodeName= HLTNode.name() + HLTNodeName= HLTNode.name log.debug("createControlFlow on node %s",HLTNodeName) for nstep in range(len(CFseqList)): @@ -523,7 +526,7 @@ def createControlFlow(flags, HLTNode, CFseqList): if flags.Trigger.generateMenuDiagnostics: log.debug("Now Draw...") - stepCF_DataFlow_to_dot(stepRecoNode.name(), CFseqList[nstep]) + stepCF_DataFlow_to_dot(stepRecoNode.name, CFseqList[nstep]) stepCF_ControlFlow_to_dot(stepRecoNode) log.debug("************* End of step %d, %s", nstep+1, stepSequenceName) @@ -535,7 +538,7 @@ def findCFSequences(filter_name, cfseqList): """ Searches for a filter, with given name, in the CF sequence list of this step """ - foundFilters = [cfseq for cfseq in cfseqList if filter_name == cfseq.filter.Alg.name()] + foundFilters = [cfseq for cfseq in cfseqList if filter_name == compName(cfseq.filter.Alg)] return foundFilters @@ -548,18 +551,25 @@ def buildFilter(filter_name, filter_input, empty): one filter per previous sequence: 1 input/previous seq, 1 output/next seq """ if empty: + log.debug("Calling PassFilterNode %s", filter_name) sfilter = PassFilterNode(name=filter_name) for i in filter_input: sfilter.addInput(i) sfilter.addOutput(i) else: sfilter = RoRSequenceFilterNode(name=filter_name) + print(sfilter.Alg) + print(sfilter.readInputList()) + print('Adding ', filter_input) for i in filter_input: sfilter.addInput(i) sfilter.addOutput(CFNaming.filterOutName(filter_name, i)) log.debug("Added inputs to filter: %s", sfilter.getInputList()) log.debug("Added outputs to filter: %s", sfilter.getOutputList()) - log.debug("Filter Done: %s", sfilter.Alg.name()) + log.debug("Filter Done: %s", compName(sfilter.Alg)) + return (sfilter) + + diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFConfig_CA.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFConfig_CA.py new file mode 100644 index 000000000000..cf00a8a30b51 --- /dev/null +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFConfig_CA.py @@ -0,0 +1,343 @@ +# Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration +from functools import lru_cache +from AthenaCommon.CFElements import findAllAlgorithms, parOR, seqOR, seqAND, isSequence +from AthenaCommon.Logging import logging +import GaudiConfig2 +from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator +from AthenaConfiguration.ComponentFactory import CompFactory +from TriggerMenuMT.HLT.Config.Utility.ChainDictTools import splitChainInLegs +from TriggerMenuMT.HLT.Config.ControlFlow.HLTCFTools import (isComboHypoAlg, + isFilterAlg, + isHypoAlg, + isInputMakerBase) +from TriggerMenuMT.HLT.Config.ControlFlow.MenuComponentsNaming import CFNaming +from TriggerMenuMT.HLT.Config.MenuComponents import EmptyMenuSequence + + +log = logging.getLogger( __name__ ) +log.setLevel(logging.DEBUG) + + + + +def generateDecisionTree(flags, HLTMenuConfig): + """Creates CF algorithms + + The implementation relies of functions that build a small element of it. + Each function generates whatever is needed in the decision tree before (potentially in a recursive way). + All functions are cached, so each element is created only once. + + The functions check the global boolean theCFisFixed - and if set to True no CF algorithms are further constructed (assertion error is generated). + """ + chains=HLTMenuConfig.configsList() + allDicts=HLTMenuConfig.dictsList() + # HLTNode=seqAND("HLTAllSteps") + acc = ComponentAccumulator() + mainSequence = seqOR('HLTAllSteps') + acc.addSequence( mainSequence ) + theCFisFixed = False + + + + ######################################################################################################### + # FPnew + def constructControlFlow(CFseqList): + #flags, HLTNode, CFseqList + from .HLTCFConfig import createStepFilterNode, createStepRecoNode,makeSummary + """ Creates Control Flow Tree starting from the CFSequences""" + + HLTNodeName= mainSequence.name + HLTNode=mainSequence + log.debug("createControlFlow on node %s",HLTNodeName) + + for nstep in range(len(CFseqList)): + stepSequenceName = CFNaming.stepName(nstep) + log.debug("\n******** Create CF Tree %s with AthSequencers", stepSequenceName) + + #first make the filter step + + #stepFilterNode = createStepFilterNode(stepSequenceName, CFseqList[nstep], dump=False) + #acc.merge(stepFilterNode, sequenceName=HLTNodeName ) + #HLTNode.Members += [stepFilterNode] + + log.debug("Create filter step %s with %d filters", stepSequenceName, len(CFseqList[nstep])) + stepCFFilter = parOR(stepSequenceName + CFNaming.FILTER_POSTFIX) + acc.addSequence(stepCFFilter, parentName=HLTNodeName) + + stepCF = parOR(stepSequenceName + CFNaming.RECO_POSTFIX) + acc.addSequence(stepCF, parentName=HLTNodeName) + + filter_list=[] + for cseq in CFseqList[nstep]: + filterAlg = cseq.filter.Alg + + if filterAlg.name not in filter_list: + log.debug("createStepFilterNode: Add %s to filter node %s", filterAlg.name, stepSequenceName) + filter_list.append(filterAlg.name) + #acc.addEventAlgo(filterAlg, sequenceName=stepCF.name) + stepCFFilter.Members +=[filterAlg] + acc.merge( cseq.ca, sequenceName=stepCF.name) + #stepCF.Members += [cseq.seq] + #acc.merge( seq.ca, sequenceName=stepCF.name) + + + + #stepRecoNode = createStepRecoNode(stepSequenceName, CFseqList[nstep], dump=False) + #acc.addSequence(stepRecoNode, parentName=HLTNodeName ) + ##HLTNode.Members.append(stepCF) + #acc.merge( CFseq.ca, sequenceName=mainSequence.name) + + # then the monitor summary + stepDecisions = [] + for CFseq in CFseqList[nstep]: + stepDecisions.extend(CFseq.decisions) + + summary=makeSummary( stepSequenceName, stepDecisions ) + + #HLTNode += summary + + #if flags.Trigger.generateMenuDiagnostics: + # log.debug("Now Draw...") + # stepCF_DataFlow_to_dot(stepRecoNode.name, CFseqList[nstep]) + # stepCF_ControlFlow_to_dot(stepRecoNode) + + log.debug("************* End of step %d, %s", nstep+1, stepSequenceName) + + return + + + + ###################### + # FPnew + def constructDataFlow(): + from HLTSeeding.HLTSeedingConfig import mapThresholdToL1DecisionCollection + from .HLTCFComponents import CFSequenceCA, RoRSequenceFilterNode + from AthenaConfiguration.ComponentFactory import isRun3Cfg + + #def createDataFlow(chains, allDicts): + """ Creates the filters and connect them to the menu sequences""" + + # find tot nsteps + chainWithMaxSteps = max(chains, key=lambda chain: len(chain.steps)) + NSTEPS = len(chainWithMaxSteps.steps) + + log.info("[createDataFlow] creating DF for %d chains and total %d steps", len(chains), NSTEPS) + + # initialize arrays for monitor + finalDecisions = [ [] for n in range(NSTEPS) ] + CFseqList = [ [] for n in range(NSTEPS) ] + + # loop over chains + for chain in chains: + log.debug("\n Configuring chain %s with %d steps: \n - %s ", chain.name,len(chain.steps),'\n - '.join(map(str, [{step.name:step.multiplicity} for step in chain.steps]))) + + lastCFseq = None + lastDecisions = [] + for nstep, chainStep in enumerate( chain.steps ): + log.debug("\n************* Start connecting step %d %s for chain %s", nstep+1, chainStep.name, chain.name) + if nstep == 0: + if chainStep.stepDicts: + filterInput = [ mapThresholdToL1DecisionCollection(p["chainParts"][0]["L1threshold"]) for p in chainStep.stepDicts] + else: + filterInput = chain.L1decisions + else: + filterInput = lastDecisions + if len(filterInput) == 0 : + log.error("[createDataFlow] Filter for step %s has %d inputs! At least one is expected", chainStep.name, len(filterInput)) + raise Exception("[createDataFlow] Cannot proceed, exiting.") + + log.debug("Set Filter input: %s while setting the chain: %s", filterInput, chain.name) + + # make one filter per step: + sequenceFilter= None + filterName = CFNaming.filterName(chainStep.name) + if chainStep.isEmpty: + filterOutput= filterInput + else: + filterOutput =[ CFNaming.filterOutName(filterName, inputName) for inputName in filterInput ] + + foundCFSeq = [cfseq for cfseq in CFseqList[nstep] if filterName == cfseq.filter.Alg.name] + #foundCFSeq = findCFSequences(filterName, CFseqList[nstep]) + log.debug("Found %d CF sequences with filter name %s", len(foundCFSeq), filterName) + if not foundCFSeq: + + from .HLTCFConfig import buildFilter + sequenceFilter = buildFilter(filterName, filterInput, chainStep.isEmpty) + #addFilterAlg( nstep+1, chainStep.name, isEmpty(chainStep)) + #cacca + CFseq = CFSequenceCA( ChainStep=chainStep, FilterAlg=sequenceFilter) + log.info("merging CA ste %d %s to %s", nstep, sequenceFilter.name, mainSequence.name) + #CFseq.ca.printConfig() + #acc.merge( CFseq.ca, sequenceName=mainSequence.name) + #acc.addSequence( CFseq.seq, parentName = mainSequence.name ) + CFseq.connect(filterOutput) + CFseqList[nstep].append(CFseq) + lastDecisions=CFseq.decisions + lastCFseq=CFseq + else: + if len(foundCFSeq) > 1: + log.error("Found more than one sequence containing filter %s", filterName) + lastCFseq=foundCFSeq[0] + sequenceFilter=lastCFseq.filter + [ sequenceFilter.addInput(inputName) for inputName in filterInput ] + [ sequenceFilter.addOutput(outputName) for outputName in filterOutput ] + lastCFseq.connect(filterOutput) + if chainStep.isEmpty: + lastDecisions=filterOutput + else: + lastDecisions=lastCFseq.decisions + + + + # add chains to the filter: + chainLegs = chainStep.getChainLegs() + if len(chainLegs) != len(filterInput): + log.error("[createDataFlow] lengths of chainlegs = %s differ from inputs=%s", str(chainLegs), str(filterInput)) + raise Exception("[createDataFlow] Cannot proceed, exiting.") + for finput, leg in zip(filterInput, chainLegs): + log.debug("Adding chain %s to input %s of %s", leg, finput,sequenceFilter.Alg.name) + sequenceFilter.addChain(leg, finput) + + log.debug("Now Filter has chains: %s", sequenceFilter.getChains()) + log.debug("Now Filter has chains/input: %s", sequenceFilter.getChainsPerInput()) + + if lastCFseq.combo is not None: + lastCFseq.combo.addChain( [d for d in allDicts if d['chainName'] == chain.name ][0]) + log.debug("Added chain to ComboHypo: %s",lastCFseq.combo.getChains()) + else: + log.debug("Combo not implemented if it's empty step") + + # add HypoTools + lastCFseq.createHypoTools(chain.name,chainStep.stepDicts) + + if len(chain.steps) == nstep+1: + log.debug("Adding finalDecisions for chain %s at step %d:", chain.name, nstep+1) + for dec in lastDecisions: + finalDecisions[nstep].append(dec) + log.debug(dec) + #acc.printConfig(withDetails=True, summariseProps=True) + #end of loop over steps + log.debug("\n Built CF for chain %s with %d steps: \n - %s ", chain.name,len(chain.steps),'\n - '.join(map(str, [{step.name:step.multiplicity} for step in chain.steps]))) + #end of loop over chains + + + log.debug("End of createDataFlow for %d chains and total %d steps", len(chains), NSTEPS) + for nstep in range(NSTEPS): + log.debug("step %d: built %d sequences", nstep, len(CFseqList[nstep])) + return (finalDecisions, CFseqList) +###################### + + + (finalDecisions, CFseq_list) = constructDataFlow() + constructControlFlow(CFseq_list) + + + + log.debug("finalDecisions: %s", finalDecisions) + + theCFisFixed=True + log.debug("CF constructed") + #resetDataFlow(acc) + + log.debug("DF connected") + #setupHypoTools() + log.debug("Configured (Combo) Hypos") + acc.printConfig(withDetails=True, summariseProps=True) + + #FP validateDataFlowConnections() + + #if log.getEffectiveLevel() <= logging.DEBUG: + # printChainsConfig() + return acc + + +if __name__ == "__main__": + # Test of DF collections traversal + # build hypothetical structure of DF to test back traversing + # make it resemble the combined chain with one arm that is hollow/empty + # naming convention: H* - hypo, IM* - InputMaker, CH* - combo hypo, F* - filter + # last digit is step + # small letter a/b branch of the selection + acc = ComponentAccumulator() + # step 1 + acc.addEventAlgo(CompFactory.RoRSeqFilter("Fmerged1", Input=["Fa1_I","Fb1_I"], Output=["Fa1merged_O", "Fb1merged_O"])) + acc.addEventAlgo(CompFactory.RoRSeqFilter("Fa1", Input=["Fa1_I"], Output=["Fa1_O"])) + acc.addEventAlgo(CompFactory.RoRSeqFilter("Fb1", Input=["Fb1_I"], Output=["FOb1"])) + acc.addEventAlgo(CompFactory.EventViewCreatorAlgorithm("IMa1", InputMakerInputDecisions=["Fa1_O", "Fa1merged_O"], InputMakerOutputDecisions="IMa1_O")) + acc.addEventAlgo(CompFactory.EventViewCreatorAlgorithm("IMb1", InputMakerInputDecisions=["FOb1", "Fb1merged_O"], InputMakerOutputDecisions="IMb1_O")) + acc.addEventAlgo(CompFactory.HLTTest.TestHypoAlg("Ha1", HypoInputDecisions="IMa1_O", HypoOutputDecisions="Ha1_O")) + acc.addEventAlgo(CompFactory.HLTTest.TestHypoAlg("Hb1", HypoInputDecisions="IMb1_O", HypoOutputDecisions="Hb1_O")) + acc.addEventAlgo(CompFactory.ComboHypo("CHmerged1", HypoInputDecisions=["Ha1_O","Hb1_O"], HypoOutputDecisions=["CHa1merged_O", "CHb1merged_O"])) + acc.addEventAlgo(CompFactory.ComboHypo("CHa1", HypoInputDecisions=["Ha1_O"], HypoOutputDecisions=["CHa1_O"])) + acc.addEventAlgo(CompFactory.ComboHypo("CHb1", HypoInputDecisions=["Hb1_O"], HypoOutputDecisions=["CHb1_O"])) + + # step 2 with alternative merged sequences, when one is empty + acc.addEventAlgo(CompFactory.RoRSeqFilter("Fmerged2", Input=["CHa1merged_O","CHb1merged_O"], Output=["Fa2merged_O", "Fb2merged_O"])) #FOb2maerged dangling/unused + acc.addEventAlgo(CompFactory.RoRSeqFilter("Faltmerged2", Input=["CHa1merged_O"], Output=["Fa2altmerged_O"])) # + acc.addEventAlgo(CompFactory.RoRSeqFilter("Fa2", Input=["CHa1_O"], Output=["Fa2_O"])) + acc.addEventAlgo(CompFactory.RoRSeqFilter("Fb2", Input=["CHb1_O"], Output=["Fb2_O"])) + acc.addEventAlgo(CompFactory.EventViewCreatorAlgorithm("IMa2", InputMakerInputDecisions=["Fa2_O", "Fa2merged_O", "Fa2altmerged_O"], InputMakerOutputDecisions="IMa2_O")) + acc.addEventAlgo(CompFactory.EventViewCreatorAlgorithm("IMb2", InputMakerInputDecisions=["Fb2_O", "Fb2merged_O"], InputMakerOutputDecisions="IMb2_O")) + acc.addEventAlgo(CompFactory.HLTTest.TestHypoAlg("Ha2", HypoInputDecisions="IMa2_O", HypoOutputDecisions="Ha2_O")) + acc.addEventAlgo(CompFactory.HLTTest.TestHypoAlg("Hb2", HypoInputDecisions="IMb2_O", HypoOutputDecisions="Hb2_O")) + acc.addEventAlgo(CompFactory.ComboHypo("CHmerged2", HypoInputDecisions=["Ha2_O","Hb2_O"], HypoOutputDecisions=["CHa2merged_O", "CHb2merged_O"])) # assymetry here, see Hb1_O + acc.addEventAlgo(CompFactory.ComboHypo("CHaltmerged2", HypoInputDecisions=["Ha2_O","Hb1_O"], HypoOutputDecisions=["CHa2altmerged_O", "CHb2altmerged_O"])) # assymetry here, see Hb1_O + acc.addEventAlgo(CompFactory.ComboHypo("CHa2", HypoInputDecisions=["Ha2_O"], HypoOutputDecisions=["CHa2_O"])) + acc.addEventAlgo(CompFactory.ComboHypo("CHb2", HypoInputDecisions=["Hb2_O"], HypoOutputDecisions=["CHb2_O"])) + + # step 3 (wiht missing branch b) + acc.addEventAlgo(CompFactory.RoRSeqFilter("Fmerged3", Input=["CHa2merged_O","CHb2merged_O", "CHa2altmerged_O", "CHb2altmerged_O"], Output=["Fa3merged_O", "Fb3merged_O"], IOMapping=[[0,2],[1,3]])) + acc.addEventAlgo(CompFactory.RoRSeqFilter("Fa3", Input=["CHa2_O"], Output=["Fa3_O"])) + acc.addEventAlgo(CompFactory.RoRSeqFilter("Fb3", Input=["CHb2_O", "CHb1_O"], Output=["Fb3_O"], IOMapping=[[0,1]])) # reach to step 1, one output + acc.addEventAlgo(CompFactory.EventViewCreatorAlgorithm("IMa3", InputMakerInputDecisions=["Fa3_O", "Fa3merged_O"], InputMakerOutputDecisions="IMa3_O")) + acc.addEventAlgo(CompFactory.EventViewCreatorAlgorithm("IMb3", InputMakerInputDecisions=["Fb3_O", "Fb3merged_O"], InputMakerOutputDecisions="IMb3_O")) + acc.addEventAlgo(CompFactory.HLTTest.TestHypoAlg("Ha3", HypoInputDecisions="IMa3_O", HypoOutputDecisions="Ha3_O")) + acc.addEventAlgo(CompFactory.HLTTest.TestHypoAlg("Hb3", HypoInputDecisions="IMb3_O", HypoOutputDecisions="Hb3_O")) + acc.addEventAlgo(CompFactory.ComboHypo("CHmerged3", HypoInputDecisions=["Ha3_O","Hb3_O"], HypoOutputDecisions=["CHOa3merged", "CHOb3merged"])) + acc.addEventAlgo(CompFactory.ComboHypo("CHa3", HypoInputDecisions=["Ha3_O"], HypoOutputDecisions=["CHa3_O"])) + acc.addEventAlgo(CompFactory.ComboHypo("CHb3", HypoInputDecisions=["Hb3_O"], HypoOutputDecisions=["CHb3_O"])) + + acc.printConfig() + acc.wasMerged() + + # test traversing and collection of info (example hypo) + colls = [] + def hypoInOut(outCol, alg): + if isHypoAlg(alg): + colls.append(alg.HypoInputDecisions.Path) + colls.append(alg.HypoOutputDecisions.Path) + + traverseDataFlow(acc, "CHa2_O", hypoInOut) # start from ComboHypo output + log.info(colls) + assert set(colls) == set(['Ha2_O', 'IMa2_O', 'Ha1_O', 'IMa1_O']), "Traversing could not find hypo outpus & outputs for branch 'a'" + + colls = [] + traverseDataFlow(acc, "Fb3_O", hypoInOut) # start from ComboHypo output + log.info(colls) + assert set(colls) == set(['Hb1_O', 'IMb1_O', 'Hb2_O', 'IMb2_O']), "Traversing could not find hypo output & input for branch 'b'" + + colls = [] + traverseDataFlow(acc, "CHa2altmerged_O", hypoInOut) # start from ComboHypo output + log.info(colls) + assert 'Ha1_O' in colls + assert 'Hb2_0' not in colls, "This is another arm of selection 'b'" + + colls = [] + traverseDataFlow(acc, "CHb2altmerged_O", hypoInOut) # start from ComboHypo output from where 2nd setup hypo is not reachable + log.info(colls) + assert 'Hb1_O' in colls + assert 'Hb2_0' not in colls, "Due to empty step, this should nto be reachable" + + + colls = [] + def collectFilterInputs( outColl, alg ): + if isFilterAlg(alg): + idx = alg.Output.index(outColl) + colls.append(alg.Input[idx]) + + traverseDataFlow(acc, "CHa2_O", collectFilterInputs) + assert set(colls) == set(["CHa1_O", "CHa1merged_O", "Fa1_I"]) + colls = [] + traverseDataFlow(acc, "CHb2merged_O", collectFilterInputs) + assert set(colls) == set(["CHb1_O", "CHb1merged_O", "Fb1_I"]) + log.info("All ok") diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFConfig_newJO.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFConfig_newJO.py index 235e1aea55fd..b26b9b22c9f3 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFConfig_newJO.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFConfig_newJO.py @@ -143,7 +143,7 @@ def commonWithOtherOutput(acc, newInputColl, filterAlg ): return None -def generateDecisionTree(flags, chains): +def generateDecisionTree(flags, HLTMenuConfig): """Creates CF algorithms The implementation relies of functions that build a small element of it. @@ -152,6 +152,7 @@ def generateDecisionTree(flags, chains): The functions check the global boolean theCFisFixed - and if set to True no CF algorithms are further constructed (assertion error is generated). """ + chains=HLTMenuConfig.configsList() acc = ComponentAccumulator() mainSequence = seqOR('HLTAllSteps') acc.addSequence( mainSequence ) @@ -423,8 +424,8 @@ def generateDecisionTree(flags, chains): needCombo = False for sequenceCounter, sequence in enumerate(step.sequences): + #log.debug("Sequence %d: IM=%s, Hypo=%s", sequenceCounter, sequence.ca.inputMaker().name, sequence.ca.hypo().name) if not isinstance(sequence, EmptyMenuSequence): # not an empty sequence - log.debug("Sequence %d: IM=%s, Hypo=%s, comboReco=%s", sequenceCounter, sequence.ca.inputMaker().name, sequence.ca.hypo().name, comboRecoSeq.name) connectIMAndHypo(sequence.ca.inputMaker(), sequence.ca.hypo()) # setup basic CF acc.merge( sequence.ca, sequenceName=comboRecoSeq.name) log.debug("MERGE: sequence %s, sequenceName=%s", sequence, comboRecoSeq.name) @@ -567,8 +568,7 @@ def generateDecisionTree(flags, chains): validateDataFlowConnections() - if log.getEffectiveLevel() <= logging.DEBUG: - printChainsConfig() + printChainsConfig() return acc diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/GenerateMenuMT.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/GenerateMenuMT.py index 1413e8c31f5f..256b30fcf426 100755 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/GenerateMenuMT.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/GenerateMenuMT.py @@ -9,6 +9,7 @@ from TriggerMenuMT.HLT.Config.ControlFlow.HLTCFTools import NoCAmigration from AthenaCommon.Logging import logging log = logging.getLogger(__name__) +log.setLevel(logging.DEBUG) class Singleton(type): _instances = {} diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/GenerateMenuMT_newJO.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/GenerateMenuMT_newJO.py old mode 100644 new mode 100755 index 5db63b79ea2d..d0b060694b62 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/GenerateMenuMT_newJO.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/GenerateMenuMT_newJO.py @@ -2,7 +2,11 @@ import itertools from TriggerMenuMT.HLT.Config.Utility.DictFromChainName import dictFromChainName -from TriggerMenuMT.HLT.Config.ControlFlow.HLTCFConfig_newJO import generateDecisionTree + +if 0: + from TriggerMenuMT.HLT.Config.ControlFlow.HLTCFConfig_newJO import generateDecisionTree +else: + from TriggerMenuMT.HLT.Config.ControlFlow.HLTCFConfig_CA import generateDecisionTree from TriggerMenuMT.HLT.Config.Utility.HLTMenuConfig import HLTMenuConfig from TriggerMenuMT.HLT.Config.Utility.ChainMerging import mergeChainDefs from TriggerMenuMT.HLT.Config.Utility.ChainDictTools import splitInterSignatureChainDict @@ -12,6 +16,7 @@ import importlib from AthenaCommon.Logging import logging log = logging.getLogger(__name__) +log.setLevel(logging.DEBUG) def getChainsOfMenu(flags): """ @@ -179,15 +184,14 @@ class FilterChainsToGenerate(object): def generateMenuMT(flags): """ Interface between CA and MenuMT using ChainConfigurationBase - """ - - + """ # Generate the menu, stolen from HLT_standalone from TriggerMenuMT.HLT.Config.GenerateMenuMT import GenerateMenuMT menu = GenerateMenuMT() - - chainsToGenerate = FilterChainsToGenerate(flags) + + chainsToGenerate = FilterChainsToGenerate(flags) + log.debug("Filtering chains ") menu.setChainFilter(chainsToGenerate) finalListOfChainConfigs = menu.generateAllChainConfigs(flags) @@ -226,8 +230,9 @@ def generateMenuAcc(flags): """ Generate appropriate Control Flow Graph wiht all HLT algorithms """ - - menuAcc = generateDecisionTree(flags, HLTMenuConfig.configsList()) + #steps=[] # neeeded? + #menuAcc = generateDecisionTree(flags, steps, HLTMenuConfig.configsList(), HLTMenuConfig.dictsList(), newJO=False) + menuAcc = generateDecisionTree(flags, HLTMenuConfig) menuAcc.wasMerged() if log.getEffectiveLevel() <= logging.DEBUG: menuAcc.printConfig() @@ -263,3 +268,5 @@ if __name__ == "__main__": ca.printConfig() ca.wasMerged() log.info("All ok") + + diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/MenuComponents.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/MenuComponents.py index 6b93d02821c4..97c16e6cb3ce 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/MenuComponents.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/MenuComponents.py @@ -16,6 +16,13 @@ from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator from AthenaConfiguration.ComponentFactory import CompFactory from AthenaConfiguration.AccumulatorCache import AccumulatorCache from DecisionHandling.DecisionHandlingConfig import ComboHypoCfg +from AthenaConfiguration.ComponentFactory import isRun3Cfg +from AthenaConfiguration.ComponentAccumulator import printProperties +import GaudiConfig2 +#if isRun3Cfg(): + +#else: +# from DecisionHandling.DecisionHandlingConfig import ComboHypoCfg from GaudiKernel.DataHandle import DataHandle from HLTSeeding.HLTSeedingConfig import mapThresholdToL1DecisionCollection from TrigCompositeUtils.TrigCompositeUtils import legName @@ -29,10 +36,14 @@ import re from AthenaCommon.Logging import logging log = logging.getLogger( __name__ ) - +log.setLevel(logging.DEBUG) # Pool of mutable ComboHypo instances (as opposed to immutable cache of RecoFragmentsPool) _ComboHypoPool = dict() - +def ComboHypoCfg2( name ): + log.debug("Calling newjo ComboHypoCfg") + #from DecisionHandling.DecisionHandlingConf import ComboHypo + alg = CompFactory.ComboHypo( name ) + return alg class Node(object): """base class representing one Alg + inputs + outputs, to be used to Draw dot diagrams and connect objects""" @@ -88,7 +99,6 @@ class AlgNode(Node): def getPar(self, prop): return getProp(self.Alg, prop) - def resetOutput(self): self.resetPar(self.outputProp) @@ -97,7 +107,6 @@ class AlgNode(Node): def addOutput(self, name): outputs = self.readOutputList() - log.debug("Outputs: %s", outputs) if name in outputs: log.debug("Output DH not added in %s: %s already set!", self.Alg.getName(), name) else: @@ -178,6 +187,7 @@ class HypoAlgNode(AlgNode): def addHypoTool (self, hypoToolConf): log.debug("Adding HypoTool %s to %s", hypoToolConf.chainDict['chainName'], compName(self.Alg)) + print(len(self.Alg.HypoTools)) try: self.Alg.HypoTools = self.Alg.HypoTools + [hypoToolConf.create()] # see ATEAM-773 except NoHypoToolCreated as e: @@ -204,6 +214,8 @@ class InputMakerNode(AlgNode): def __init__(self, Alg): assert isInputMakerBase(Alg), "Error in creating InputMakerNode from Alg " + compName(Alg) AlgNode.__init__(self, Alg, 'InputMakerInputDecisions', 'InputMakerOutputDecisions') + self.resetInput() + self.resetOutput() ## why do we need this in CA mode?? input_maker_output = CFNaming.inputMakerOutName(compName(self.Alg)) self.addOutput(input_maker_output) @@ -216,10 +228,15 @@ class ComboMaker(AlgNode): Alg = self.create( name ) log.debug("ComboMaker init: Alg %s", name) AlgNode.__init__(self, Alg, 'HypoInputDecisions', 'HypoOutputDecisions') + self.resetInput() + self.resetOutput() ## why do we need this in CA mode?? def create (self, name): log.debug("ComboMaker.create %s",name) - return self.comboHypoCfg(name=name) + #tmp FP: + #return CompFactory.ComboHypo( name ) + + return self.comboHypoCfg(name=name) """ AlgNode automatically de-duplicates input ReadHandles upon repeated calls to addInput. @@ -242,9 +259,18 @@ class ComboMaker(AlgNode): return AlgNode.addInput(self, name) def addChain(self, chainDict): + print("Adding chains to ComboHypo ", compName(self.Alg), ": ",chainDict['chainName']) + #printProperties(log,self.Alg) chainName = chainDict['chainName'] chainMult = chainDict['chainMultiplicities'] - legsToInputCollections = self.mapRawInputsToInputsIndex() + print("inputs=",self.readInputList() ) + #legsToInputCollections = self.mapRawInputsToInputsIndex() + legsToInputCollections = self.readInputList() + # only to debug + cval1 = getProp(self.Alg, self.prop1) # check necessary to see if chain was added already? + cval2 = getProp(self.Alg, self.prop2) + print ("Already set Props:", cval1, cval2) + # if len(chainMult) != len(legsToInputCollections): log.error("ComboMaker for Alg:{} with addChain for:{} Chain multiplicity:{} Per leg input collection index:{}." @@ -254,9 +280,11 @@ class ComboMaker(AlgNode): log.error("Check why ComboMaker.addInput(...) was not called exactly once per leg.") raise Exception("[createDataFlow] Error in ComboMaker.addChain. Cannot proceed.") - cval1 = self.Alg.getProperties()[self.prop1] # check necessary to see if chain was added already? - cval2 = self.Alg.getProperties()[self.prop2] - if type(cval1) is dict: + cval1 = getProp(self.Alg, self.prop1) # check necessary to see if chain was added already? + cval2 = getProp(self.Alg, self.prop2) + print (cval1, cval2) + print (cval1.keys()) + if type(cval1) is dict or isinstance(cval1, GaudiConfig2.semantics._DictHelper): if chainName in cval1.keys(): log.error("ERROR in configuration: ComboAlg %s has already been configured for chain %s", compName(self.Alg), chainName) raise Exception("[createDataFlow] Error in ComboMaker.addChain. Cannot proceed.") @@ -269,9 +297,11 @@ class ComboMaker(AlgNode): setattr(self.Alg, self.prop1, cval1) setattr(self.Alg, self.prop2, cval2) + #printProperties(log,self.Alg) def getChains(self): - cval = self.Alg.getProperties()[self.prop1] + cval = getProp(self.Alg, self.prop1) + #cval = self.Alg.getProperties()[self.prop1] return cval.keys() @@ -367,8 +397,8 @@ class MenuSequence(object): _Hypo = Hypo _Maker = Maker _Sequence = Sequence - self._maker = InputMakerNode( Alg = _Maker ) - self._seed='' + self._maker = InputMakerNode( Alg = _Maker ) + self._seed ='' input_maker_output= self.maker.readOutputList()[0] # only one since it's merged # Connect InputMaker output to ROBPrefetchingAlg(s) if there are any (except for probe seq which is handled later) @@ -394,28 +424,28 @@ class MenuSequence(object): if IsProbe: def getProbeSequence(baseSeq,probeIM): # Add IM and sequence contents to duplicated sequence - probeSeq = baseSeq.clone(baseSeq.name()+"_probe") + probeSeq = baseSeq.clone(baseSeq.name+"_probe") probeSeq += probeIM if isinstance(probeIM,CompFactory.EventViewCreatorAlgorithm): for child in baseSeq.getChildren()[1:]: - probeChild = child.clone(child.name()+"_probe") + probeChild = child.clone(child.name+"_probe") if hasProp(child,'ROBPrefetchingInputDecisions') and (ROBPrefetching.StepRoI in ConfigFlags.Trigger.ROBPrefetchingOptions): # child is a ROB prefetching alg, map the probe IM decisions probeChild.ROBPrefetchingInputDecisions = [str(probeIM.InputMakerOutputDecisions)] - elif probeIM.ViewNodeName == child.name(): + elif probeIM.ViewNodeName == child.name: # child is the view alg sequence, map it to the probe sequence - probeIM.ViewNodeName = probeChild.name() + probeIM.ViewNodeName = probeChild.name for viewalg in child.getChildren(): probeChild += viewalg probeSeq += probeChild return probeSeq # Make sure nothing was lost _Sequence = getProbeSequence(baseSeq=Sequence,probeIM=_Maker) - assert len(_Sequence.getChildren()) == len(Sequence.getChildren()), f'Different number of children in sequence {_Sequence.name()} vs {Sequence.name()} ({len(_Sequence.getChildren())} vs {len(Sequence.getChildren())})' + assert len(_Sequence.getChildren()) == len(Sequence.getChildren()), f'Different number of children in sequence {_Sequence.name} vs {Sequence.name} ({len(_Sequence.getChildren())} vs {len(Sequence.getChildren())})' self._sequence = Node( Alg=_Sequence) - log.debug("MenuSequence.connect: connecting InputMaker and HypoAlg, adding: \n\ + log.debug("connecting InputMaker and HypoAlg, adding: \n\ InputMaker::%s.output=%s",\ compName(self.maker.Alg), input_maker_output) log.debug("HypoAlg::%s.HypoInputDecisions=%s, \n \ @@ -445,14 +475,14 @@ class MenuSequence(object): @staticmethod def getProbeHypo(flags,basehypo): '''Clone hypo & input maker''' - probehypo = basehypo.clone(basehypo.name()+"_probe") + probehypo = basehypo.clone(basehypo.name+"_probe") for p,v in basehypo.getValuedProperties().items(): setattr(probehypo,p,getattr(basehypo,p)) return probehypo @staticmethod def getProbeInputMaker(flags,baseIM): - probeIM = baseIM.clone(baseIM.name()+"_probe") + probeIM = baseIM.clone(baseIM.name+"_probe") for p,v in baseIM.getValuedProperties().items(): setattr(probeIM,p,getattr(baseIM,p)) @@ -481,9 +511,12 @@ class MenuSequence(object): outputlist.append(self._hypo.readOutputList()[0]) return outputlist + def connectToFilter(self, outfilter): """ Connect filter to the InputMaker""" - self._maker.addInput(outfilter) + log.debug("connecting %s to inputs of %s", outfilter,compName(self._maker.Alg)) + #printProperties(log,self._maker.Alg) + self._maker.addInput(outfilter) def connect(self, Hypo, HypoToolGen): """ Sets the input and output of the hypo, and links to the input maker """ @@ -512,8 +545,11 @@ class MenuSequence(object): hypo.addHypoTool(self._hypoToolConf) else: self._hypoToolConf.setConf( chainDict ) - self._hypo.addHypoTool(self._hypoToolConf) #this creates the HypoTools + self._hypo.addHypoTool(self._hypoToolConf) #this creates the HypoTools + def getHypoToolMap(self,chainDict) : + self._hypoToolConf.setConf( chainDict ) + return (self._hypo.Alg.name, self._hypoToolConf) def addToSequencer(self, recoSeq_list, hypo_list): recoSeq_list.add(self.sequence.Alg) @@ -553,10 +589,13 @@ class MenuSequenceCA(MenuSequence): inputMaker = [ a for a in allAlgs if isInputMakerBase(a)] assert len(inputMaker) == 1, "Wrong number of input makers in the component accumulator {}".format(len(inputMaker)) inputMaker = inputMaker[0] + #inputMaker.InputMakerInputDecisions=[] # why do we need this in CA mode?? hypoAlg = [ a for a in allAlgs if isHypoAlg(a)] assert len(hypoAlg) == 1, "Wrong number of hypo algs in the component accumulator {}".format(len(hypoAlg)) hypoAlg = hypoAlg[0] - MenuSequence.__init__(self, self.ca.getSequence(), inputMaker, hypoAlg, HypoToolGen) + print("creating MenuSequenceCA for Hypo ", hypoAlg.name) + self.ca.printConfig() + MenuSequence.__init__(self, self.ca.topSequence(), inputMaker, hypoAlg, HypoToolGen) @property def sequence(self): @@ -578,6 +617,8 @@ class MenuSequenceCA(MenuSequence): + + class Chain(object): """Basic class to define the trigger menu """ __slots__ ='name','steps','nSteps','alignmentGroups','vseeds','L1decisions', 'topoMap' @@ -861,7 +902,7 @@ class ChainStep(object): else: log.error("[getLegIds] chain %s has multiplicities %s but no legs? ",step_dict['chainName'], self.multiplicity) raise Exception("[getLegIds] cannot extract leg IDs, exiting.") - else: + leg_ids += [int(step_dict['chainName'][3:6])] return leg_ids @@ -872,13 +913,14 @@ class ChainStep(object): def makeCombo(self): self.combo=None if self.isEmpty or self.comboHypoCfg is None: - return + return comboName = CFNaming.comboHypoName(self.name) key = hash((comboName, self.comboHypoCfg)) if key not in _ComboHypoPool: + log.debug("makeCombo: creating new ComboHypo %s",comboName) _ComboHypoPool[key] = createComboAlg(None, name=comboName, comboHypoCfg=self.comboHypoCfg) self.combo = _ComboHypoPool[key] - + def createComboHypoTools(self, chainName): chainDict = HLTMenuConfig.getChainDictFromChainName(chainName) @@ -910,9 +952,9 @@ class ChainStep(object): ' '.join(map(str, [dic['chainName'] for dic in self.stepDicts])), ' '.join(map(str, [seq.name for seq in self.sequences]) )) if self.combo is not None: - repr_string += "\n+ ComboHypo = %s, ComboHypoTools = %s" %\ - (self.combo.Alg.name(), - ' '.join(map(str, [tool.__name__ for tool in self.comboToolConfs]))) + repr_string += "\n + ComboHypo = %s" %(compName(self.combo.Alg)) + if len(self.comboToolConfs)>0: + repr_string +=", ComboHypoTools = %s" %(' '.join(map(str, [tool.__name__ for tool in self.comboToolConfs]))) return repr_string @@ -1045,6 +1087,9 @@ class SelectionCA(ComponentAccumulator): assert im is not None, "No input maker in SeelectionCA {}".format(self.name) return im + def topSequence(self): + return self.stepViewSequence + # mainline/rec-ex-common and CA based JO compatibility layer (basically converters) def algorithmCAToGlobalWrapper(gen, flags, *args, **kwargs): """Merges CA with athena for all components except the algorithms. Those are converted to Run2 objects and returned. diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Electron/TrigEMBremCollectionBuilder.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Electron/TrigEMBremCollectionBuilder.py index 35970364d8c2..54c3d7d19924 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Electron/TrigEMBremCollectionBuilder.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Electron/TrigEMBremCollectionBuilder.py @@ -98,6 +98,12 @@ class TrigEgammaBremCollectionBuilder (egammaAlgsConf.EMBremCollectionBuilder): GSFBuildTrackSummaryHelperTool = TrackingCommon.getInDetSummaryHelper( name="GSFBuildTrackSummaryHelperTool", HoleSearch=None, +<<<<<<< Updated upstream +======= + TestPixelLayerTool=GSFBuildTestPixelLayerTool, + isHLT = True, + DoSharedHits=False, +>>>>>>> Stashed changes private=True) # @@ -119,8 +125,6 @@ class TrigEgammaBremCollectionBuilder (egammaAlgsConf.EMBremCollectionBuilder): name="GSFBuildInDetParticleCreatorTool", TRT_ElectronPidTool=GSFBuildTRT_ElectronPidTool, PixelToTPIDTool=GSFBuildPixelToTPIDTool, - TestPixelLayerTool=GSFBuildTestPixelLayerTool, - ComputeAdditionalInfo=True, KeepParameters=True, TrackSummaryTool=GSFBuildInDetTrigTrackSummaryTool) # diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Menu/Dev_pp_run3_v1.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Menu/Dev_pp_run3_v1.py index 42ca8e1aad25..d6e66eb793ad 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Menu/Dev_pp_run3_v1.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Menu/Dev_pp_run3_v1.py @@ -73,7 +73,8 @@ def setupMenu(): #ATR-21003 ChainProp(name='HLT_2mu14_l2io_L12MU8F', groups=DevGroup+MultiMuonGroup), ChainProp(name='HLT_2mu6_l2io_L12MU5VF', groups=DevGroup+MultiMuonGroup), - + ## FP add test for combo chains + ChainProp(name='HLT_mu4_mu6_L12MU3V', groups=DevGroup+MultiMuonGroup), # Test T&P dimuon ChainProp(name='HLT_mu24_mu6_L1MU14FCH', l1SeedThresholds=['MU14FCH','MU3V'], groups=DevGroup+MultiMuonGroup), ChainProp(name='HLT_mu24_mu6_probe_L1MU14FCH', l1SeedThresholds=['MU14FCH','PROBEMU3V'], groups=DevGroup+MultiMuonGroup), diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Menu/Dev_pp_run3_v1_newJO.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Menu/Dev_pp_run3_v1_newJO.py index eabec475e245..4185e38014fa 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Menu/Dev_pp_run3_v1_newJO.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Menu/Dev_pp_run3_v1_newJO.py @@ -113,10 +113,10 @@ if __name__ == "__main__": ConfigFlags.Trigger.generateMenuDiagnostics = True log.info(" Running Dev_pp_run3_newJO") - ConfigFlags.addFlag("Trigger.enabledSignatures",[]) - ConfigFlags.addFlag("Trigger.disabledSignatures",[]) - ConfigFlags.addFlag("Trigger.selectChains",[]) - ConfigFlags.addFlag("Trigger.disableChains",[]) + #ConfigFlags.addFlag("Trigger.enabledSignatures",[]) + #ConfigFlags.addFlag("Trigger.disabledSignatures",[]) + #ConfigFlags.addFlag("Trigger.selectChains",[]) + #ConfigFlags.addFlag("Trigger.disableChains",[]) from AthenaConfiguration.TestDefaults import defaultTestFiles diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Muon/MuonChainConfiguration.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Muon/MuonChainConfiguration.py index c92d79ab97e3..1e5beea937b0 100755 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Muon/MuonChainConfiguration.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Muon/MuonChainConfiguration.py @@ -13,7 +13,9 @@ from ..Config.ChainConfigurationBase import ChainConfigurationBase from AthenaConfiguration.ComponentFactory import isRun3Cfg if isRun3Cfg(): - from .generateMuon import muFastSequence, muEFSASequence, muCombSequence, muEFCBSequence + #from .generateMuon import muFastSequence, muCombSequence + from .generateMuon import muFastSequence, muEFSASequence, muCombSequence, muEFCBSequence, muCombOvlpRmSequence, muFastOvlpRmSequence + #muFastOvlpRmSequence, else: from .MuonMenuSequences import muFastSequence, muFastCalibSequence, muFastOvlpRmSequence, mul2mtSAOvlpRmSequence, muCombSequence, muCombLRTSequence, muCombOvlpRmSequence, mul2mtCBOvlpRmSequence, mul2IOOvlpRmSequence, muEFSASequence, muEFCBSequence, muEFCBIDperfSequence, muEFCBLRTSequence, muEFCBLRTIDperfSequence, muEFSAFSSequence, muEFCBFSSequence, muEFIsoSequence, muEFMSIsoSequence, efLateMuRoISequence, efLateMuSequence, muRoiClusterSequence, muEFIDtpSequence diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Muon/generateMuon.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Muon/generateMuon.py index 57f722aaf04b..604e49989136 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Muon/generateMuon.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Muon/generateMuon.py @@ -199,6 +199,11 @@ def muFastStep(flags, chainDict): return ChainStep( name=selAcc.name, Sequences=[l2muFastSequence], chainDicts=[chainDict] ) +## FP fake, just to run +def muFastOvlpRmSequence (flags, is_probe_leg=False): + log.warning("FAKE muFastOvlpRmSequence replaced by single muFast") + return muFastSequence(flags) + @AccumulatorCache def _muCombStepSeq(flags): ### Set muon step2 - L2muComb ### @@ -236,6 +241,11 @@ def muCombStep(flags, chainDict): return ChainStep( name=selAccL2CB.name, Sequences=[l2muCombSequence], chainDicts=[chainDict] ) +def muCombOvlpRmSequence(flags, is_probe_leg=False): + log.warning("FAKE muCombOvlpRmSequence replaced by single muCombSequence") + return muCombSequence(flags) + + @AccumulatorCache def _muEFSAStepSeq(flags, name='RoI'): #EF MS only -- GitLab From 70cc41b8a93aa5ba972b306fa6012292079e7610 Mon Sep 17 00:00:00 2001 From: Francesca Pastore <francesca.pastore@cern.ch> Date: Fri, 16 Dec 2022 15:37:13 +0100 Subject: [PATCH 02/15] ctest are fine --- .../python/DecisionHandlingConfig.py | 5 +- .../TriggerMenuMT/CMakeLists.txt | 5 ++ .../CommonSequences/EventBuildingSequences.py | 2 +- .../CommonSequences/TLABuildingSequences.py | 3 +- .../HLT/Config/ControlFlow/HLTCFComponents.py | 22 +++--- .../HLT/Config/ControlFlow/HLTCFConfig.py | 21 +++--- .../HLT/Config/ControlFlow/HLTCFConfig_CA.py | 11 ++- .../python/HLT/Config/MenuComponents.py | 75 ++++++++++--------- .../python/HLT/Config/Utility/ChainMerging.py | 9 ++- .../HLT/Config/Utility/ComboHypoHandling.py | 3 +- .../Electron/TrigEMBremCollectionBuilder.py | 6 -- 11 files changed, 87 insertions(+), 75 deletions(-) diff --git a/Trigger/TrigSteer/DecisionHandling/python/DecisionHandlingConfig.py b/Trigger/TrigSteer/DecisionHandling/python/DecisionHandlingConfig.py index 1162bcf5ad7f..0158022d9240 100644 --- a/Trigger/TrigSteer/DecisionHandling/python/DecisionHandlingConfig.py +++ b/Trigger/TrigSteer/DecisionHandling/python/DecisionHandlingConfig.py @@ -1,7 +1,7 @@ # # Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration # - +from AthenaConfiguration.ComponentFactory import CompFactory EnableFilterMonitoring = False # Can be changed in a precommand/preExec def setupFilterMonitoring( filterAlg ): @@ -33,5 +33,6 @@ def TriggerSummaryAlg( name ): def ComboHypoCfg( name ): from DecisionHandling.DecisionHandlingConf import ComboHypo - alg = ComboHypo( name ) + alg = CompFactory.ComboHypo( name ) return alg + diff --git a/Trigger/TriggerCommon/TriggerMenuMT/CMakeLists.txt b/Trigger/TriggerCommon/TriggerMenuMT/CMakeLists.txt index 0b94cb99cd71..97f87065e9bc 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/CMakeLists.txt +++ b/Trigger/TriggerCommon/TriggerMenuMT/CMakeLists.txt @@ -19,6 +19,7 @@ atlas_install_scripts( scripts/generateL1MenuRun3.py scripts/runTriggerAPIExample.py scripts/generateUnprescaledLists.py scripts/test_menu_dump.py + scripts/test_menu_CA.py POST_BUILD_CMD ${ATLAS_FLAKE8} ) # Shell scripts without flake8 checking: @@ -114,6 +115,10 @@ atlas_add_test(generateMenuMT_newJO PROPERTIES TIMEOUT 500 POST_EXEC_SCRIPT noerror.sh ) +atlas_add_test( test_menu_CA + SCRIPT test_menu_CA.py + POST_EXEC_SCRIPT noerror.sh ) + # test for menu name consistency atlas_add_test( test_menu_dump SCRIPT test_menu_dump.py -p diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/CommonSequences/EventBuildingSequences.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/CommonSequences/EventBuildingSequences.py index d4fa910016a6..eac117a424e5 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/CommonSequences/EventBuildingSequences.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/CommonSequences/EventBuildingSequences.py @@ -47,7 +47,7 @@ def addEventBuildingSequence(flags, chain, eventBuildType, chainDict): chainDicts=[chainDict]) else: # standard PEB chain - prevStep = chain.steps[-1] + prevStep = chain.steps[-1] step_name = 'Step_merged{:s}_PEBInfoWriter_{:s}'.format(prevStep.name, eventBuildType) step = ChainStep(name=step_name, Sequences=[seq for leg in prevStep.legIds], diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/CommonSequences/TLABuildingSequences.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/CommonSequences/TLABuildingSequences.py index e031581714fc..e98d63383d20 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/CommonSequences/TLABuildingSequences.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/CommonSequences/TLABuildingSequences.py @@ -10,7 +10,6 @@ from TriggerMenuMT.HLT.Config.ControlFlow.HLTCFTools import NoCAmigration log = logging.getLogger(__name__) - def addTLAStep(chain, chainDict): ''' Add one extra chain step for TLA Activities @@ -26,7 +25,7 @@ def addTLAStep(chain, chainDict): # call the sequence from their respective signatures tlaSequencesList.append(getTLASignatureSequence(ConfigFlags, chainDict=chainDict, chainPart=cPart)), #signature=cPart['signature'])), - log.debug("addTLAStep: About to add a step with: %d, parallel sequences.", len(tlaSequencesList)) + log.debug("addTLAStep: About to add a step with: %d parallel sequences.", len(tlaSequencesList)) # we add one step per TLA chain, with sequences matching the list of signatures # and multiplicities matching those of the previous step of the chain (already merged if combined) diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFComponents.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFComponents.py index ba33f2d109b2..fa99e09f5163 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFComponents.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFComponents.py @@ -57,9 +57,7 @@ from AthenaConfiguration.ComponentFactory import isRun3Cfg class RoRSequenceFilterNode(SequenceFilterNode): def __init__(self, name): Alg= RoRSeqFilter(name) - #if isRun3Cfg(): - # self.acc=ComponentAccumulator() - # self.acc.addEventAlgo(Alg) + SequenceFilterNode.__init__(self, Alg, 'Input', 'Output') self.resetInput() @@ -120,7 +118,7 @@ class CFSequence(object): def __init__(self, ChainStep, FilterAlg): self.filter = FilterAlg self.step = ChainStep - self.combo = self.step.combo #copy this instance + self.combo = ChainStep.combo #copy this instance self.connectCombo() self.setDecisions() @@ -219,7 +217,7 @@ class CFSequenceCA(CFSequence): """ def __init__(self, ChainStep, FilterAlg): - log.debug(" *** Create CFSequence %s with Filter %s", ChainStep.name, FilterAlg.Alg.name) + log.debug(" *** Create CFSequence %s with Filter %s", ChainStep.name, FilterAlg.Alg.getName()) self.ca = ComponentAccumulator() self.empty= ChainStep.isEmpty #empty step: add the PassSequence, one instance only is appended to the tree @@ -233,17 +231,17 @@ class CFSequenceCA(CFSequence): self.seq=seqAndWithFilter if not self.empty: - self.ca.addEventAlgo(FilterAlg.Alg, sequenceName=seqAndWithFilter.name) + self.ca.addEventAlgo(FilterAlg.Alg, sequenceName=seqAndWithFilter.getName()) stepReco = parOR(ChainStep.name + CFNaming.RECO_POSTFIX) # all reco algorithms from all the sequences in a parallel sequence - self.ca.addSequence(stepReco, parentName=seqAndWithFilter.name) - log.info("created parOR %s inside seqAND %s ", stepReco.name, seqAndWithFilter.name) + self.ca.addSequence(stepReco, parentName=seqAndWithFilter.getName()) + log.info("created parOR %s inside seqAND %s ", stepReco.getName(), seqAndWithFilter.getName()) for menuseq in ChainStep.sequences: - self.ca.merge(menuseq.ca, sequenceName=stepReco.name) + self.ca.merge(menuseq.ca, sequenceName=stepReco.getName()) CFSequence.__init__(self, ChainStep,FilterAlg) if self.combo is not None: - self.ca.addEventAlgo(self.step.combo.Alg, sequenceName=seqAndWithFilter.name) + self.ca.addEventAlgo(self.step.combo.Alg, sequenceName=seqAndWithFilter.getName()) #printProperties(log,self.combo.Alg) #log.debug(self.seq.Members) @@ -259,9 +257,9 @@ class CFSequenceCA(CFSequence): def findComboHypoAlg(self): log.debug(self.seq.Members) for alg in getSequenceChildren(self.seq): - log.debug("found %s",alg.name) + log.debug("found %s",alg.getName()) if not isSequence(alg): - if compName(alg) == self.step.combo.Alg.name: + if compName(alg) == self.step.combo.Alg.getName(): #RecursionError: maximum recursion depth exceeded in comparison #for alg in findAllAlgorithms( self.seq , self.step.combo.Alg.name): if isComboHypoAlg( alg ): diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFConfig.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFConfig.py index 4a44ac81ff39..49611e06f15e 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFConfig.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFConfig.py @@ -40,7 +40,7 @@ from TriggerJobOpts.TriggerConfig import collectHypos, collectFilters, collectVi triggerMonitoringCfg, triggerSummaryCfg, triggerMergeViewsAndAddMissingEDMCfg, collectHypoDecisionObjects from TrigNavSlimmingMT.TrigNavSlimmingMTConfig import getTrigNavSlimmingMTOnlineConfig from ViewAlgs.ViewAlgsConf import EventViewCreatorAlgorithm - +from AthenaConfiguration.ComponentFactory import CompFactory from builtins import map, range, str, zip from collections import OrderedDict, defaultdict @@ -108,8 +108,8 @@ def createCFTree(CFseq): for menuseq in CFseq.step.sequences: menuseq.addToSequencer(recoSeqSet,hypoSet) - stepReco += sorted(list(recoSeqSet), key=lambda t: t.name) - seqAndWithFilter += sorted(list(hypoSet), key=lambda t: t.name) + stepReco += sorted(list(recoSeqSet), key=lambda t: t.getName()) + seqAndWithFilter += sorted(list(hypoSet), key=lambda t: t.getName()) if CFseq.step.combo is not None: seqAndWithFilter += CFseq.step.combo.Alg @@ -366,7 +366,7 @@ def decisionTreeFromChains(flags, HLTNode, chains, allDicts, newJO): """ Creates the decision tree, given the starting node and the chains containing the sequences """ log.info("[decisionTreeFromChains] Run decisionTreeFromChains on %s", HLTNode.name) - HLTNodeName= HLTNode.name + HLTNodeName= HLTNode.getName() if len(chains) == 0: log.info("[decisionTreeFromChains] Configuring empty decisionTree") return [] @@ -431,8 +431,7 @@ def createDataFlow(chains, allDicts): log.debug("Set Filter input: %s while setting the chain: %s", filterInput, chain.name) # make one filter per step: - sequenceFilter= None - comboHypo=None + sequenceFilter= None filterName = CFNaming.filterName(chainStep.name) if chainStep.isEmpty: filterOutput= filterInput @@ -454,7 +453,7 @@ def createDataFlow(chains, allDicts): lastCFseq=foundCFSeq[0] sequenceFilter=lastCFseq.filter - if len(list(set(sequenceFilter.getInputList()).intersection(filterInput))) == 0: + if len(list(set(sequenceFilter.getInputList()).intersection(filterInput))) != len(list(set(filterInput))): [ sequenceFilter.addInput(inputName) for inputName in filterInput ] [ sequenceFilter.addOutput(outputName) for outputName in filterOutput ] lastCFseq.connect(filterOutput) @@ -475,9 +474,9 @@ def createDataFlow(chains, allDicts): log.debug("Now Filter has chains: %s", sequenceFilter.getChains()) log.debug("Now Filter has chains/input: %s", sequenceFilter.getChainsPerInput()) - if lastCFseq.combo is not None: - lastCFseq.combo.addChain( [d for d in allDicts if d['chainName'] == chain.name ][0]) - log.debug("Added chains to ComboHypo: %s",lastCFseq.combo.getChains()) + if lastCFseq.step.combo is not None: + lastCFseq.step.combo.addChain( [d for d in allDicts if d['chainName'] == chain.name ][0]) + log.debug("Added chains to ComboHypo: %s",lastCFseq.step.combo.getChains()) else: log.debug("Combo not implemented if it's empty step") @@ -526,7 +525,7 @@ def createControlFlow(flags, HLTNode, CFseqList): if flags.Trigger.generateMenuDiagnostics: log.debug("Now Draw...") - stepCF_DataFlow_to_dot(stepRecoNode.name, CFseqList[nstep]) + stepCF_DataFlow_to_dot(stepRecoNode.getName(), CFseqList[nstep]) stepCF_ControlFlow_to_dot(stepRecoNode) log.debug("************* End of step %d, %s", nstep+1, stepSequenceName) diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFConfig_CA.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFConfig_CA.py index cf00a8a30b51..39a486cb6f01 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFConfig_CA.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFConfig_CA.py @@ -164,7 +164,7 @@ def generateDecisionTree(flags, HLTMenuConfig): from .HLTCFConfig import buildFilter sequenceFilter = buildFilter(filterName, filterInput, chainStep.isEmpty) #addFilterAlg( nstep+1, chainStep.name, isEmpty(chainStep)) - #cacca + # cacca CFseq = CFSequenceCA( ChainStep=chainStep, FilterAlg=sequenceFilter) log.info("merging CA ste %d %s to %s", nstep, sequenceFilter.name, mainSequence.name) #CFseq.ca.printConfig() @@ -201,9 +201,9 @@ def generateDecisionTree(flags, HLTMenuConfig): log.debug("Now Filter has chains: %s", sequenceFilter.getChains()) log.debug("Now Filter has chains/input: %s", sequenceFilter.getChainsPerInput()) - if lastCFseq.combo is not None: - lastCFseq.combo.addChain( [d for d in allDicts if d['chainName'] == chain.name ][0]) - log.debug("Added chain to ComboHypo: %s",lastCFseq.combo.getChains()) + if lastCFseq.step.combo is not None: + lastCFseq.step.combo.addChain( [d for d in allDicts if d['chainName'] == chain.name ][0]) + log.debug("Added chain to ComboHypo: %s",lastCFseq.step.combo.getChains()) else: log.debug("Combo not implemented if it's empty step") @@ -227,6 +227,9 @@ def generateDecisionTree(flags, HLTMenuConfig): return (finalDecisions, CFseqList) ###################### + if len(chains) == 0: + log.info("[generateDecisionTree] Configuring empty decisionTree") + return acc (finalDecisions, CFseq_list) = constructDataFlow() constructControlFlow(CFseq_list) diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/MenuComponents.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/MenuComponents.py index 97c16e6cb3ce..04b071f37b25 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/MenuComponents.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/MenuComponents.py @@ -19,10 +19,6 @@ from DecisionHandling.DecisionHandlingConfig import ComboHypoCfg from AthenaConfiguration.ComponentFactory import isRun3Cfg from AthenaConfiguration.ComponentAccumulator import printProperties import GaudiConfig2 -#if isRun3Cfg(): - -#else: -# from DecisionHandling.DecisionHandlingConfig import ComboHypoCfg from GaudiKernel.DataHandle import DataHandle from HLTSeeding.HLTSeedingConfig import mapThresholdToL1DecisionCollection from TrigCompositeUtils.TrigCompositeUtils import legName @@ -39,16 +35,12 @@ log = logging.getLogger( __name__ ) log.setLevel(logging.DEBUG) # Pool of mutable ComboHypo instances (as opposed to immutable cache of RecoFragmentsPool) _ComboHypoPool = dict() -def ComboHypoCfg2( name ): - log.debug("Calling newjo ComboHypoCfg") - #from DecisionHandling.DecisionHandlingConf import ComboHypo - alg = CompFactory.ComboHypo( name ) - return alg + class Node(object): """base class representing one Alg + inputs + outputs, to be used to Draw dot diagrams and connect objects""" def __init__(self, Alg): - self.name = ("%sNode")%( Alg.name ) + self.name = ("%sNode")%( Alg.getName() ) self.Alg=Alg self.inputs=[] self.outputs=[] @@ -66,7 +58,7 @@ class Node(object): return self.inputs def __repr__(self): - return "Node::%s [%s] -> [%s]"%(self.Alg.name, ' '.join(map(str, self.getInputList())), ' '.join(map(str, self.getOutputList()))) + return "Node::%s [%s] -> [%s]"%(self.Alg.getName(), ' '.join(map(str, self.getInputList())), ' '.join(map(str, self.getOutputList()))) @@ -186,7 +178,7 @@ class HypoAlgNode(AlgNode): def addHypoTool (self, hypoToolConf): - log.debug("Adding HypoTool %s to %s", hypoToolConf.chainDict['chainName'], compName(self.Alg)) + log.debug("Adding HypoTool %s to %s", hypoToolConf.chainDict['chainName'], self.Alg.getName()) print(len(self.Alg.HypoTools)) try: self.Alg.HypoTools = self.Alg.HypoTools + [hypoToolConf.create()] # see ATEAM-773 @@ -230,6 +222,9 @@ class ComboMaker(AlgNode): AlgNode.__init__(self, Alg, 'HypoInputDecisions', 'HypoOutputDecisions') self.resetInput() self.resetOutput() ## why do we need this in CA mode?? + # reset the chains, why do we need to do it? + setattr(self.Alg, self.prop1, {}) + setattr(self.Alg, self.prop2, {}) def create (self, name): log.debug("ComboMaker.create %s",name) @@ -263,9 +258,9 @@ class ComboMaker(AlgNode): #printProperties(log,self.Alg) chainName = chainDict['chainName'] chainMult = chainDict['chainMultiplicities'] - print("inputs=",self.readInputList() ) - #legsToInputCollections = self.mapRawInputsToInputsIndex() - legsToInputCollections = self.readInputList() + print("inputs=",self.getInputList() ) + legsToInputCollections = self.mapRawInputsToInputsIndex() + #legsToInputCollections = self.getInputList() # only to debug cval1 = getProp(self.Alg, self.prop1) # check necessary to see if chain was added already? cval2 = getProp(self.Alg, self.prop2) @@ -320,6 +315,8 @@ class ComboMaker(AlgNode): # Now sequences and chains ########################################################## + + class EmptyMenuSequence(object): """ Class to emulate reco sequences with no Hypo""" """ By construction it has no Hypo;""" @@ -424,24 +421,24 @@ class MenuSequence(object): if IsProbe: def getProbeSequence(baseSeq,probeIM): # Add IM and sequence contents to duplicated sequence - probeSeq = baseSeq.clone(baseSeq.name+"_probe") + probeSeq = baseSeq.clone(baseSeq.getName()+"_probe") probeSeq += probeIM if isinstance(probeIM,CompFactory.EventViewCreatorAlgorithm): for child in baseSeq.getChildren()[1:]: - probeChild = child.clone(child.name+"_probe") + probeChild = child.clone(child.getName()+"_probe") if hasProp(child,'ROBPrefetchingInputDecisions') and (ROBPrefetching.StepRoI in ConfigFlags.Trigger.ROBPrefetchingOptions): # child is a ROB prefetching alg, map the probe IM decisions probeChild.ROBPrefetchingInputDecisions = [str(probeIM.InputMakerOutputDecisions)] - elif probeIM.ViewNodeName == child.name: + elif probeIM.ViewNodeName == child.getName(): # child is the view alg sequence, map it to the probe sequence - probeIM.ViewNodeName = probeChild.name + probeIM.ViewNodeName = probeChild.getName() for viewalg in child.getChildren(): probeChild += viewalg probeSeq += probeChild return probeSeq # Make sure nothing was lost _Sequence = getProbeSequence(baseSeq=Sequence,probeIM=_Maker) - assert len(_Sequence.getChildren()) == len(Sequence.getChildren()), f'Different number of children in sequence {_Sequence.name} vs {Sequence.name} ({len(_Sequence.getChildren())} vs {len(Sequence.getChildren())})' + assert len(_Sequence.getChildren()) == len(Sequence.getChildren()), f'Different number of children in sequence {_Sequence.getName()} vs {Sequence.getName()} ({len(_Sequence.getChildren())} vs {len(Sequence.getChildren())})' self._sequence = Node( Alg=_Sequence) @@ -475,14 +472,14 @@ class MenuSequence(object): @staticmethod def getProbeHypo(flags,basehypo): '''Clone hypo & input maker''' - probehypo = basehypo.clone(basehypo.name+"_probe") + probehypo = basehypo.clone(basehypo.getName()+"_probe") for p,v in basehypo.getValuedProperties().items(): setattr(probehypo,p,getattr(basehypo,p)) return probehypo @staticmethod def getProbeInputMaker(flags,baseIM): - probeIM = baseIM.clone(baseIM.name+"_probe") + probeIM = baseIM.clone(baseIM.getName()+"_probe") for p,v in baseIM.getValuedProperties().items(): setattr(probeIM,p,getattr(baseIM,p)) @@ -549,7 +546,7 @@ class MenuSequence(object): def getHypoToolMap(self,chainDict) : self._hypoToolConf.setConf( chainDict ) - return (self._hypo.Alg.name, self._hypoToolConf) + return (self._hypo.Alg.getName(), self._hypoToolConf) def addToSequencer(self, recoSeq_list, hypo_list): recoSeq_list.add(self.sequence.Alg) @@ -593,30 +590,40 @@ class MenuSequenceCA(MenuSequence): hypoAlg = [ a for a in allAlgs if isHypoAlg(a)] assert len(hypoAlg) == 1, "Wrong number of hypo algs in the component accumulator {}".format(len(hypoAlg)) hypoAlg = hypoAlg[0] - print("creating MenuSequenceCA for Hypo ", hypoAlg.name) + print("creating MenuSequenceCA for Hypo ", hypoAlg.getName()) self.ca.printConfig() MenuSequence.__init__(self, self.ca.topSequence(), inputMaker, hypoAlg, HypoToolGen) @property def sequence(self): - makerAlg = self.ca.getEventAlgo(self._maker.Alg.name) + makerAlg = self.ca.getEventAlgo(self._maker.Alg.getName()) self._maker.Alg = makerAlg return self._sequence @property def maker(self): - makerAlg = self.ca.getEventAlgo(self._maker.Alg.name) + makerAlg = self.ca.getEventAlgo(self._maker.Alg.getName()) self._maker.Alg = makerAlg return self._maker @property def hypo(self): - hypoAlg = self.ca.getEventAlgo(self._hypo.Alg.name) + hypoAlg = self.ca.getEventAlgo(self._hypo.Alg.getName()) self._hypo.Alg = hypoAlg return self._hypo +class EmptyMenuSequenceCA(EmptyMenuSequence): + def __init__(self, the_name): + self.ca=ComponentAccumulator() + EmptyMenuSequence.__init__(self,the_name ) + self.ca.addEventAlgo(self._maker.Alg) + @property + def maker(self): + makerAlg = self.ca.getEventAlgo(self._maker.Alg.getName()) + self._maker.Alg = makerAlg + return self._maker class Chain(object): @@ -902,7 +909,7 @@ class ChainStep(object): else: log.error("[getLegIds] chain %s has multiplicities %s but no legs? ",step_dict['chainName'], self.multiplicity) raise Exception("[getLegIds] cannot extract leg IDs, exiting.") - + else: leg_ids += [int(step_dict['chainName'][3:6])] return leg_ids @@ -917,7 +924,7 @@ class ChainStep(object): comboName = CFNaming.comboHypoName(self.name) key = hash((comboName, self.comboHypoCfg)) if key not in _ComboHypoPool: - log.debug("makeCombo: creating new ComboHypo %s",comboName) + log.debug("makeCombo: creating new ComboHypo %s with hash %s",comboName, key) _ComboHypoPool[key] = createComboAlg(None, name=comboName, comboHypoCfg=self.comboHypoCfg) self.combo = _ComboHypoPool[key] @@ -989,19 +996,19 @@ class InEventRecoCA( ComponentAccumulator ): args.update(**inputMakerArgs) self.inputMakerAlg = CompFactory.InputMakerForRoI(**args) - self.addEventAlgo( self.inputMakerAlg, self.mainSeq.name ) - self.recoSeq = parOR( "InputSeq_"+self.inputMakerAlg.name ) #FP: why is this needed? - self.addSequence( self.recoSeq, self.mainSeq.name ) + self.addEventAlgo( self.inputMakerAlg, self.mainSeq.getName() ) + self.recoSeq = parOR( "InputSeq_"+self.inputMakerAlg.getName() ) #FP: why is this needed? + self.addSequence( self.recoSeq, self.mainSeq.getName() ) pass def mergeReco( self, ca ): """ Merged CA moving reconstruction algorithms into the right sequence """ - return self.merge( ca, sequenceName=self.recoSeq.name ) + return self.merge( ca, sequenceName=self.recoSeq.getName() ) def addRecoAlgo( self, algo ): """ Place algorithm in the correct reconstruction sequence """ - return self.addEventAlgo( algo, sequenceName=self.recoSeq.name ) + return self.addEventAlgo( algo, sequenceName=self.recoSeq.getName() ) def inputMaker( self ): return self.inputMakerAlg diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/Utility/ChainMerging.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/Utility/ChainMerging.py index ff503070d118..de79f501750b 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/Utility/ChainMerging.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/Utility/ChainMerging.py @@ -1,7 +1,7 @@ # Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration from TriggerMenuMT.HLT.Config.Utility.MenuAlignmentTools import get_alignment_group_ordering as getAlignmentGroupOrdering -from TriggerMenuMT.HLT.Config.MenuComponents import Chain, ChainStep, EmptyMenuSequence, RecoFragmentsPool +from TriggerMenuMT.HLT.Config.MenuComponents import Chain, ChainStep, EmptyMenuSequence, RecoFragmentsPool, EmptyMenuSequenceCA from AthenaCommon.Logging import logging from AthenaConfiguration.AllConfigFlags import ConfigFlags @@ -155,7 +155,12 @@ def getEmptySeqName(stepName, chain_index, step_number, alignGroup): return seqName def EmptyMenuSequenceCfg(flags, name): - return EmptyMenuSequence(name) + # to clean up + if isRun3Cfg(): + return EmptyMenuSequenceCA(name) + else: + return EmptyMenuSequence(name) + def getEmptyMenuSequence(flags, name): if isRun3Cfg(): diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/Utility/ComboHypoHandling.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/Utility/ComboHypoHandling.py index 59a7cb6c8fb4..d184dac880c9 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/Utility/ComboHypoHandling.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/Utility/ComboHypoHandling.py @@ -10,6 +10,7 @@ logging.getLogger().info("Importing %s",__name__) import math import re from TrigConfHLTUtils.HLTUtils import string2hash +from AthenaConfiguration.ComponentFactory import CompFactory topoLegIndices = "ABCDEF" @@ -195,7 +196,7 @@ def TrigComboHypoToolFromDict(chainDict): # convert list of dicts into dict of lists toolProps = {k:[thedef[k] for thedef in topoDefs] for k in topoDefs[0]} - tool = TrigComboHypoTool(chainName, SkipLegCheck=skipLegCheck, **toolProps) + tool = CompFactory.TrigComboHypoTool(chainName, SkipLegCheck=skipLegCheck, **toolProps) return tool diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Electron/TrigEMBremCollectionBuilder.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Electron/TrigEMBremCollectionBuilder.py index 54c3d7d19924..a7508fc1e668 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Electron/TrigEMBremCollectionBuilder.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Electron/TrigEMBremCollectionBuilder.py @@ -98,12 +98,6 @@ class TrigEgammaBremCollectionBuilder (egammaAlgsConf.EMBremCollectionBuilder): GSFBuildTrackSummaryHelperTool = TrackingCommon.getInDetSummaryHelper( name="GSFBuildTrackSummaryHelperTool", HoleSearch=None, -<<<<<<< Updated upstream -======= - TestPixelLayerTool=GSFBuildTestPixelLayerTool, - isHLT = True, - DoSharedHits=False, ->>>>>>> Stashed changes private=True) # -- GitLab From e5a2e434877c623e6a793758abec2a57dad7aa32 Mon Sep 17 00:00:00 2001 From: Francesca Pastore <francesca.pastore@cern.ch> Date: Mon, 19 Dec 2022 20:42:43 +0100 Subject: [PATCH 03/15] first draft working --- .../TriggerJobOpts/python/TriggerConfig.py | 5 +- .../TriggerMenuMT/CMakeLists.txt | 6 +- .../HLT/Config/ChainConfigurationBase.py | 1 - .../HLT/Config/ControlFlow/HLTCFComponents.py | 19 +- .../HLT/Config/ControlFlow/HLTCFConfig.py | 161 +++++++-- .../HLT/Config/ControlFlow/HLTCFConfig_CA.py | 321 +----------------- .../python/HLT/Config/GenerateMenuMT.py | 1 - .../python/HLT/Config/GenerateMenuMT_newJO.py | 64 +++- .../python/HLT/Config/MenuComponents.py | 39 +-- .../HLT/Config/Utility/ComboHypoHandling.py | 1 - 10 files changed, 210 insertions(+), 408 deletions(-) diff --git a/Trigger/TriggerCommon/TriggerJobOpts/python/TriggerConfig.py b/Trigger/TriggerCommon/TriggerJobOpts/python/TriggerConfig.py index 7bca2ddb34b3..1b3477a23319 100644 --- a/Trigger/TriggerCommon/TriggerJobOpts/python/TriggerConfig.py +++ b/Trigger/TriggerCommon/TriggerJobOpts/python/TriggerConfig.py @@ -10,6 +10,7 @@ from AthenaCommon.Logging import logging from .TriggerRecoConfig import TriggerMetadataWriterCfg __log = logging.getLogger('TriggerConfig') + def __isCombo(alg): return hasProp( alg, "MultiplicitiesMap" ) @@ -40,7 +41,7 @@ def collectHypos( steps ): __log.debug( "collecting hypos from step %s", stepSeq.getName() ) # start = {} for seq,algs in flatAlgorithmSequences(stepSeq).items(): - for alg in sorted(algs, key=lambda t: str(t.name)): + for alg in sorted(algs, key=lambda t: str(t.getName())): if isSequence( alg ): continue # will replace by function once dependencies are sorted @@ -196,7 +197,7 @@ def triggerSummaryCfg(flags, hypos): hypoChains, hypoOutputKeys = __decisionsFromHypo( hypo ) for chain in hypoChains: if chain not in chainToCollectionInStep: - chainToCollectionInStep[chain] = hypoOutputKeys + chainToCollectionInStep[chain] = hypoOutputKeys chainToLastCollection.update( chainToCollectionInStep ) from TriggerMenuMT.HLT.Config.Utility.HLTMenuConfig import HLTMenuConfig diff --git a/Trigger/TriggerCommon/TriggerMenuMT/CMakeLists.txt b/Trigger/TriggerCommon/TriggerMenuMT/CMakeLists.txt index 97f87065e9bc..c448d4d9affe 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/CMakeLists.txt +++ b/Trigger/TriggerCommon/TriggerMenuMT/CMakeLists.txt @@ -117,7 +117,11 @@ atlas_add_test(generateMenuMT_newJO atlas_add_test( test_menu_CA SCRIPT test_menu_CA.py - POST_EXEC_SCRIPT noerror.sh ) + PRIVATE_WORKING_DIRECTORY + PROPERTIES TIMEOUT 500 + POST_EXEC_SCRIPT "check_log.py --errors --config checklogTriggerTest.conf ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/unitTestRun_test_menu_CA/test_menu_CA.log" + ) + # test for menu name consistency atlas_add_test( test_menu_dump diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ChainConfigurationBase.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ChainConfigurationBase.py index 4ee8c0b8b449..1a8f9b2c8bee 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ChainConfigurationBase.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ChainConfigurationBase.py @@ -3,7 +3,6 @@ from AthenaCommon.Logging import logging log = logging.getLogger(__name__) -log.setLevel(logging.DEBUG) import abc from TriggerMenuMT.HLT.Config.MenuComponents import Chain, ChainStep, RecoFragmentsPool diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFComponents.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFComponents.py index fa99e09f5163..2c29da7b9b12 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFComponents.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFComponents.py @@ -9,7 +9,6 @@ from functools import lru_cache from AthenaCommon.Logging import logging log = logging.getLogger( __name__ ) -log.setLevel(logging.DEBUG) from AthenaConfiguration.ComponentFactory import CompFactory RoRSeqFilter = CompFactory.RoRSeqFilter @@ -53,7 +52,6 @@ class SequenceFilterNode(AlgNode): def __repr__(self): return "SequenceFilter::%s [%s] -> [%s], chains=%s"%(compName(self.Alg),' '.join(map(str, self.getInputList())),' '.join(map(str, self.getOutputList())), self.getChains()) -from AthenaConfiguration.ComponentFactory import isRun3Cfg class RoRSequenceFilterNode(SequenceFilterNode): def __init__(self, name): Alg= RoRSeqFilter(name) @@ -84,7 +82,6 @@ class RoRSequenceFilterNode(SequenceFilterNode): return self.getPar("ChainsPerInput") -from AthenaCommon.AlgSequence import AthSequencer from GaudiKernel.DataHandle import DataHandle class PassFilterNode(SequenceFilterNode): """ PassFilter is a Filter node without inputs/outputs, so OutputProp=InputProp=empty""" @@ -194,9 +191,7 @@ class CFSequence(object): chainDict = HLTMenuConfig.getChainDictFromChainName(chain) self.combo.createComboHypoTools(chainDict, self.step.comboToolConfs) - - #return self.step.createComboHypoTools(chain) - + @@ -205,11 +200,9 @@ class CFSequence(object): compName(self.filter.Alg), self.decisions, self.step) from AthenaCommon.CFElements import parOR, seqAND -from AthenaCommon.AlgSequence import AlgSequence from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator from TriggerMenuMT.HLT.Config.ControlFlow.HLTCFTools import isComboHypoAlg -from AthenaCommon.CFElements import findAllAlgorithms, getSequenceChildren, isSequence -from AthenaConfiguration.ComponentAccumulator import printProperties +from AthenaCommon.CFElements import getSequenceChildren, isSequence class CFSequenceCA(CFSequence): """Class to describe the flow of decisions through ChainStep + filter with their connections (input, output) @@ -243,15 +236,7 @@ class CFSequenceCA(CFSequence): if self.combo is not None: self.ca.addEventAlgo(self.step.combo.Alg, sequenceName=seqAndWithFilter.getName()) - #printProperties(log,self.combo.Alg) - #log.debug(self.seq.Members) - - #@property - #def combo(self): - # self.step.combo.Alg= self.findComboHypoAlg() #self.ca.getEventAlgo(self.step.combo.Alg.name) - # return self.combo - @lru_cache(None) def findComboHypoAlg(self): diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFConfig.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFConfig.py index 49611e06f15e..b00b9f30ce0e 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFConfig.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFConfig.py @@ -23,7 +23,7 @@ """ from TriggerMenuMT.HLT.Config.ControlFlow.HLTCFDot import stepCF_DataFlow_to_dot, stepCF_ControlFlow_to_dot, all_DataFlow_to_dot -from TriggerMenuMT.HLT.Config.ControlFlow.HLTCFComponents import CFSequence, RoRSequenceFilterNode, PassFilterNode +from TriggerMenuMT.HLT.Config.ControlFlow.HLTCFComponents import CFSequence, RoRSequenceFilterNode, PassFilterNode, CFSequenceCA from TriggerMenuMT.HLT.Config.ControlFlow.MenuComponentsNaming import CFNaming from TriggerMenuMT.HLT.Config.Validation.CFValidation import testHLTTree @@ -34,20 +34,20 @@ from AthenaCommon.Logging import logging from AthenaConfiguration.ComponentAccumulator import conf2toConfigurable, appendCAtoAthena -from DecisionHandling.DecisionHandlingConfig import TriggerSummaryAlg from HLTSeeding.HLTSeedingConfig import mapThresholdToL1DecisionCollection from TriggerJobOpts.TriggerConfig import collectHypos, collectFilters, collectViewMakers, collectDecisionObjects, \ triggerMonitoringCfg, triggerSummaryCfg, triggerMergeViewsAndAddMissingEDMCfg, collectHypoDecisionObjects from TrigNavSlimmingMT.TrigNavSlimmingMTConfig import getTrigNavSlimmingMTOnlineConfig from ViewAlgs.ViewAlgsConf import EventViewCreatorAlgorithm from AthenaConfiguration.ComponentFactory import CompFactory +from AthenaConfiguration.ComponentFactory import isRun3Cfg +from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator from builtins import map, range, str, zip from collections import OrderedDict, defaultdict import re log = logging.getLogger( __name__ ) -log.setLevel(logging.DEBUG) #### Functions to create the CF tree from CF configuration objects def makeSummary(name, flatDecisions): @@ -76,10 +76,11 @@ def createStepFilterNode(name, seq_list, dump=False): """ Elementary HLT filter step: OR node containing all Filters of the sequences. The node gates execution of next reco step """ log.debug("Create filter step %s with %d filters", name, len(seq_list)) + stepCF = parOR(name + CFNaming.FILTER_POSTFIX) filter_list=[] for seq in seq_list: filterAlg = seq.filter.Alg - log.debug("createStepFilterNode: Add %s to filter node %s", filterAlg.name, name) + log.debug("createStepFilterNode: Add %s to filter node %s", filterAlg.getName(), name) if filterAlg not in filter_list: filter_list.append(filterAlg) @@ -146,7 +147,7 @@ def makeHLTTree(flags, newJO=False, hltMenuConfig = None): log.debug("[makeHLTTree] will now make the DF and CF tree from chains") # make DF and CF tree from chains - finalDecisions = decisionTreeFromChains(flags, steps, hltMenuConfig.configsList(), hltMenuConfig.dictsList(), newJO) + finalDecisions, acc = decisionTreeFromChains(flags, steps, hltMenuConfig.configsList(), hltMenuConfig.dictsList(), newJO) successful_scan = sequenceScanner( steps ) @@ -289,7 +290,7 @@ def matrixDisplay( allCFSeq ): if seq.name == "Empty": mx[stepNumber, "Empty"].extend(chains) else: - mx[stepNumber, seq.sequence.Alg.name].extend(chains) + mx[stepNumber, seq.sequence.Alg.getName()].extend(chains) # sort dictionary by fist key=step sorted_mx = OrderedDict(sorted( list(mx.items()), key= lambda k: k[0])) @@ -329,7 +330,7 @@ def sequenceScanner( HLTNode ): if isSequence(c): # Detect whether this is the view sequence pointed to # by the EV creator alg, or if it is in such a sequence - inView = c.name==inViewSequence or childInView + inView = c.getName()==inViewSequence or childInView stepIndex = _mapSequencesInSteps(c, stepIndex, childInView=inView) _seqMapInStep[compName(c)].add((stepIndex,inView)) log.verbose("sequenceScanner: Child %s of sequence %s is in view? %s --> '%s'", compName(c), name, inView, inViewSequence) @@ -365,35 +366,34 @@ def sequenceScanner( HLTNode ): def decisionTreeFromChains(flags, HLTNode, chains, allDicts, newJO): """ Creates the decision tree, given the starting node and the chains containing the sequences """ - log.info("[decisionTreeFromChains] Run decisionTreeFromChains on %s", HLTNode.name) + log.info("[decisionTreeFromChains] Run decisionTreeFromChains on %s", HLTNode.getName()) HLTNodeName= HLTNode.getName() if len(chains) == 0: log.info("[decisionTreeFromChains] Configuring empty decisionTree") - return [] + acc = ComponentAccumulator() + if isRun3Cfg(): + acc.addSequence(HLTNode) + return ([], acc) + (finalDecisions, CFseq_list) = createDataFlow(chains, allDicts) - if not newJO: - createControlFlow(flags, HLTNode, CFseq_list) - else: - raise RuntimeError('createControlFlowNewJO not implemented') - # createControlFlowNewJO(HLTNode, CFseq_list) - - - # decode and attach HypoTools: - for chain in chains: - chain.createHypoTools() + #createControlFlowOld(flags, HLTNode, CFseq_list) + acc=createControlFlow(flags, HLTNode, CFseq_list) # create dot graphs log.debug("finalDecisions: %s", finalDecisions) if flags.Trigger.generateMenuDiagnostics: all_DataFlow_to_dot(HLTNodeName, CFseq_list) + + if isRun3Cfg(): + acc.printConfig(withDetails=True, summariseProps=True) # matrix display # uncomment for serious debugging # matrixDisplay( CFseq_list ) - return finalDecisions + return (finalDecisions,acc) def createDataFlow(chains, allDicts): @@ -437,12 +437,16 @@ def createDataFlow(chains, allDicts): filterOutput= filterInput else: filterOutput =[ CFNaming.filterOutName(filterName, inputName) for inputName in filterInput ] - - foundCFSeq = findCFSequences(filterName, CFseqList[nstep]) + + foundCFSeq = [cfseq for cfseq in CFseqList[nstep] if filterName == cfseq.filter.Alg.getName()] + #foundCFSeq = findCFSequences(filterName, CFseqList[nstep]) log.debug("Found %d CF sequences with filter name %s", len(foundCFSeq), filterName) if not foundCFSeq: sequenceFilter = buildFilter(filterName, filterInput, chainStep.isEmpty) - CFseq = CFSequence( ChainStep=chainStep, FilterAlg=sequenceFilter) + if isRun3Cfg(): + CFseq = CFSequenceCA( ChainStep=chainStep, FilterAlg=sequenceFilter) + else: + CFseq = CFSequence( ChainStep=chainStep, FilterAlg=sequenceFilter) CFseq.connect(filterOutput) CFseqList[nstep].append(CFseq) lastDecisions=CFseq.decisions @@ -461,7 +465,7 @@ def createDataFlow(chains, allDicts): lastDecisions=filterOutput else: lastDecisions=lastCFseq.decisions - print("lastDecisions are ",lastDecisions) + # add chains to the filter: chainLegs = chainStep.getChainLegs() if len(chainLegs) != len(filterInput): @@ -480,6 +484,9 @@ def createDataFlow(chains, allDicts): else: log.debug("Combo not implemented if it's empty step") + # add HypoTools + lastCFseq.createHypoTools(chain.name,chainStep.stepDicts) + if len(chain.steps) == nstep+1: log.debug("Adding finalDecisions for chain %s at step %d:", chain.name, nstep+1) for dec in lastDecisions: @@ -498,7 +505,104 @@ def createDataFlow(chains, allDicts): def createControlFlow(flags, HLTNode, CFseqList): """ Creates Control Flow Tree starting from the CFSequences""" - HLTNodeName= HLTNode.name + HLTNodeName= HLTNode.getName() + log.debug("createControlFlow on node %s",HLTNodeName) + acc = ComponentAccumulator() + if isRun3Cfg(): + acc.addSequence(HLTNode) + + for nstep in range(len(CFseqList)): + stepSequenceName = CFNaming.stepName(nstep) + log.debug("\n******** Create CF Tree %s with AthSequencers", stepSequenceName) + + + # filter node + log.debug("Create filter step %s with %d filters", stepSequenceName, len(CFseqList[nstep])) + stepCFFilter = parOR(stepSequenceName + CFNaming.FILTER_POSTFIX) + if isRun3Cfg(): + acc.addSequence(stepCFFilter, parentName=HLTNodeName) + else: + HLTNode += stepCFFilter + + filter_list=[] + for cseq in CFseqList[nstep]: + filterAlg = cseq.filter.Alg + if filterAlg.getName() not in filter_list: + log.debug("createControlFlow: Add %s to filter node %s", filterAlg.getName(), stepSequenceName) + filter_list.append(filterAlg.getName()) + if isRun3Cfg(): + stepCFFilter.Members +=[filterAlg] + else: + stepCFFilter +=filterAlg + + + # reco step node + log.debug("Create reco step %s with %d sequences", stepSequenceName, len(CFseqList)) + stepCFReco = parOR(stepSequenceName + CFNaming.RECO_POSTFIX) + if isRun3Cfg(): + acc.addSequence(stepCFReco, parentName=HLTNodeName) + else: + HLTNode += stepCFReco + + for cseq in CFseqList[nstep]: + #createCFTree=Filter+Reco+Combo + log.debug(" *** Create CF Tree for CFSequence %s", cseq.step.name) + filterAlg = cseq.filter.Alg + stepReco = parOR(cseq.step.name + CFNaming.RECO_POSTFIX) + + if len(cseq.step.sequences)==0: + if isRun3Cfg(): + stepCFReco.Members +=[filterAlg] + else: + stepCFReco += filterAlg + else: + seqAndWithFilter = seqAND(cseq.step.name) + if isRun3Cfg(): + stepCFReco.Members +=[seqAndWithFilter] + seqAndWithFilter.Members +=[filterAlg, stepReco] + acc.merge( cseq.ca, sequenceName=stepReco.getName()) + else: + seqAndWithFilter +=[filterAlg, stepReco] + recoSeqSet=set() + hypoSet=set() + for menuseq in cseq.step.sequences: + menuseq.addToSequencer(recoSeqSet,hypoSet) + + stepReco += sorted(list(recoSeqSet), key=lambda t: t.getName()) + seqAndWithFilter += sorted(list(hypoSet), key=lambda t: t.getName()) + if cseq.step.combo is not None: + seqAndWithFilter += cseq.step.combo.Alg + + stepCFReco += seqAndWithFilter + + + # then the monitor summary + stepDecisions = [] + for CFseq in CFseqList[nstep]: + stepDecisions.extend(CFseq.decisions) + + summary=makeSummary( stepSequenceName, stepDecisions ) + if isRun3Cfg(): + HLTNode.Members += [summary] + else: + HLTNode += summary + + if flags.Trigger.generateMenuDiagnostics: + log.debug("Now Draw...") + stepCF_DataFlow_to_dot(stepReco.getName(), CFseqList[nstep]) + stepCF_ControlFlow_to_dot(stepReco) + + log.debug("************* End of step %d, %s", nstep+1, stepSequenceName) + + return acc + + + +######## obsolete, to remove +def createControlFlowOld(flags, HLTNode, CFseqList): + """ Creates Control Flow Tree starting from the CFSequences""" + + HLTNodeName= HLTNode.getName() log.debug("createControlFlow on node %s",HLTNodeName) for nstep in range(len(CFseqList)): @@ -532,7 +636,7 @@ def createControlFlow(flags, HLTNode, CFseqList): return - +# obsolete, to remove def findCFSequences(filter_name, cfseqList): """ Searches for a filter, with given name, in the CF sequence list of this step @@ -556,10 +660,7 @@ def buildFilter(filter_name, filter_input, empty): sfilter.addInput(i) sfilter.addOutput(i) else: - sfilter = RoRSequenceFilterNode(name=filter_name) - print(sfilter.Alg) - print(sfilter.readInputList()) - print('Adding ', filter_input) + sfilter = RoRSequenceFilterNode(name=filter_name) for i in filter_input: sfilter.addInput(i) sfilter.addOutput(CFNaming.filterOutName(filter_name, i)) diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFConfig_CA.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFConfig_CA.py index 39a486cb6f01..bb4a100a6e1b 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFConfig_CA.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFConfig_CA.py @@ -1,26 +1,11 @@ # Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration -from functools import lru_cache -from AthenaCommon.CFElements import findAllAlgorithms, parOR, seqOR, seqAND, isSequence +from AthenaCommon.CFElements import findAllAlgorithms, seqOR from AthenaCommon.Logging import logging -import GaudiConfig2 -from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator -from AthenaConfiguration.ComponentFactory import CompFactory -from TriggerMenuMT.HLT.Config.Utility.ChainDictTools import splitChainInLegs -from TriggerMenuMT.HLT.Config.ControlFlow.HLTCFTools import (isComboHypoAlg, - isFilterAlg, - isHypoAlg, - isInputMakerBase) -from TriggerMenuMT.HLT.Config.ControlFlow.MenuComponentsNaming import CFNaming -from TriggerMenuMT.HLT.Config.MenuComponents import EmptyMenuSequence - +from .HLTCFConfig import createDataFlow, createControlFlow log = logging.getLogger( __name__ ) -log.setLevel(logging.DEBUG) - - - -def generateDecisionTree(flags, HLTMenuConfig): +def decisionTreeFromChains(flags, HLTNode, chains, allDicts, newJO): """Creates CF algorithms The implementation relies of functions that build a small element of it. @@ -29,222 +14,16 @@ def generateDecisionTree(flags, HLTMenuConfig): The functions check the global boolean theCFisFixed - and if set to True no CF algorithms are further constructed (assertion error is generated). """ - chains=HLTMenuConfig.configsList() - allDicts=HLTMenuConfig.dictsList() - # HLTNode=seqAND("HLTAllSteps") - acc = ComponentAccumulator() - mainSequence = seqOR('HLTAllSteps') - acc.addSequence( mainSequence ) - theCFisFixed = False - - - - ######################################################################################################### - # FPnew - def constructControlFlow(CFseqList): - #flags, HLTNode, CFseqList - from .HLTCFConfig import createStepFilterNode, createStepRecoNode,makeSummary - """ Creates Control Flow Tree starting from the CFSequences""" - - HLTNodeName= mainSequence.name - HLTNode=mainSequence - log.debug("createControlFlow on node %s",HLTNodeName) - - for nstep in range(len(CFseqList)): - stepSequenceName = CFNaming.stepName(nstep) - log.debug("\n******** Create CF Tree %s with AthSequencers", stepSequenceName) - - #first make the filter step - - #stepFilterNode = createStepFilterNode(stepSequenceName, CFseqList[nstep], dump=False) - #acc.merge(stepFilterNode, sequenceName=HLTNodeName ) - #HLTNode.Members += [stepFilterNode] - - log.debug("Create filter step %s with %d filters", stepSequenceName, len(CFseqList[nstep])) - stepCFFilter = parOR(stepSequenceName + CFNaming.FILTER_POSTFIX) - acc.addSequence(stepCFFilter, parentName=HLTNodeName) - - stepCF = parOR(stepSequenceName + CFNaming.RECO_POSTFIX) - acc.addSequence(stepCF, parentName=HLTNodeName) - - filter_list=[] - for cseq in CFseqList[nstep]: - filterAlg = cseq.filter.Alg - - if filterAlg.name not in filter_list: - log.debug("createStepFilterNode: Add %s to filter node %s", filterAlg.name, stepSequenceName) - filter_list.append(filterAlg.name) - #acc.addEventAlgo(filterAlg, sequenceName=stepCF.name) - stepCFFilter.Members +=[filterAlg] - acc.merge( cseq.ca, sequenceName=stepCF.name) - #stepCF.Members += [cseq.seq] - #acc.merge( seq.ca, sequenceName=stepCF.name) - - - - #stepRecoNode = createStepRecoNode(stepSequenceName, CFseqList[nstep], dump=False) - #acc.addSequence(stepRecoNode, parentName=HLTNodeName ) - ##HLTNode.Members.append(stepCF) - #acc.merge( CFseq.ca, sequenceName=mainSequence.name) - - # then the monitor summary - stepDecisions = [] - for CFseq in CFseqList[nstep]: - stepDecisions.extend(CFseq.decisions) - summary=makeSummary( stepSequenceName, stepDecisions ) - - #HLTNode += summary - - #if flags.Trigger.generateMenuDiagnostics: - # log.debug("Now Draw...") - # stepCF_DataFlow_to_dot(stepRecoNode.name, CFseqList[nstep]) - # stepCF_ControlFlow_to_dot(stepRecoNode) - - log.debug("************* End of step %d, %s", nstep+1, stepSequenceName) - - return - - - - ###################### - # FPnew - def constructDataFlow(): - from HLTSeeding.HLTSeedingConfig import mapThresholdToL1DecisionCollection - from .HLTCFComponents import CFSequenceCA, RoRSequenceFilterNode - from AthenaConfiguration.ComponentFactory import isRun3Cfg - - #def createDataFlow(chains, allDicts): - """ Creates the filters and connect them to the menu sequences""" - # find tot nsteps - chainWithMaxSteps = max(chains, key=lambda chain: len(chain.steps)) - NSTEPS = len(chainWithMaxSteps.steps) - - log.info("[createDataFlow] creating DF for %d chains and total %d steps", len(chains), NSTEPS) - - # initialize arrays for monitor - finalDecisions = [ [] for n in range(NSTEPS) ] - CFseqList = [ [] for n in range(NSTEPS) ] - - # loop over chains - for chain in chains: - log.debug("\n Configuring chain %s with %d steps: \n - %s ", chain.name,len(chain.steps),'\n - '.join(map(str, [{step.name:step.multiplicity} for step in chain.steps]))) - - lastCFseq = None - lastDecisions = [] - for nstep, chainStep in enumerate( chain.steps ): - log.debug("\n************* Start connecting step %d %s for chain %s", nstep+1, chainStep.name, chain.name) - if nstep == 0: - if chainStep.stepDicts: - filterInput = [ mapThresholdToL1DecisionCollection(p["chainParts"][0]["L1threshold"]) for p in chainStep.stepDicts] - else: - filterInput = chain.L1decisions - else: - filterInput = lastDecisions - if len(filterInput) == 0 : - log.error("[createDataFlow] Filter for step %s has %d inputs! At least one is expected", chainStep.name, len(filterInput)) - raise Exception("[createDataFlow] Cannot proceed, exiting.") - - log.debug("Set Filter input: %s while setting the chain: %s", filterInput, chain.name) - - # make one filter per step: - sequenceFilter= None - filterName = CFNaming.filterName(chainStep.name) - if chainStep.isEmpty: - filterOutput= filterInput - else: - filterOutput =[ CFNaming.filterOutName(filterName, inputName) for inputName in filterInput ] - - foundCFSeq = [cfseq for cfseq in CFseqList[nstep] if filterName == cfseq.filter.Alg.name] - #foundCFSeq = findCFSequences(filterName, CFseqList[nstep]) - log.debug("Found %d CF sequences with filter name %s", len(foundCFSeq), filterName) - if not foundCFSeq: - - from .HLTCFConfig import buildFilter - sequenceFilter = buildFilter(filterName, filterInput, chainStep.isEmpty) - #addFilterAlg( nstep+1, chainStep.name, isEmpty(chainStep)) - # cacca - CFseq = CFSequenceCA( ChainStep=chainStep, FilterAlg=sequenceFilter) - log.info("merging CA ste %d %s to %s", nstep, sequenceFilter.name, mainSequence.name) - #CFseq.ca.printConfig() - #acc.merge( CFseq.ca, sequenceName=mainSequence.name) - #acc.addSequence( CFseq.seq, parentName = mainSequence.name ) - CFseq.connect(filterOutput) - CFseqList[nstep].append(CFseq) - lastDecisions=CFseq.decisions - lastCFseq=CFseq - else: - if len(foundCFSeq) > 1: - log.error("Found more than one sequence containing filter %s", filterName) - lastCFseq=foundCFSeq[0] - sequenceFilter=lastCFseq.filter - [ sequenceFilter.addInput(inputName) for inputName in filterInput ] - [ sequenceFilter.addOutput(outputName) for outputName in filterOutput ] - lastCFseq.connect(filterOutput) - if chainStep.isEmpty: - lastDecisions=filterOutput - else: - lastDecisions=lastCFseq.decisions - - - - # add chains to the filter: - chainLegs = chainStep.getChainLegs() - if len(chainLegs) != len(filterInput): - log.error("[createDataFlow] lengths of chainlegs = %s differ from inputs=%s", str(chainLegs), str(filterInput)) - raise Exception("[createDataFlow] Cannot proceed, exiting.") - for finput, leg in zip(filterInput, chainLegs): - log.debug("Adding chain %s to input %s of %s", leg, finput,sequenceFilter.Alg.name) - sequenceFilter.addChain(leg, finput) - - log.debug("Now Filter has chains: %s", sequenceFilter.getChains()) - log.debug("Now Filter has chains/input: %s", sequenceFilter.getChainsPerInput()) - - if lastCFseq.step.combo is not None: - lastCFseq.step.combo.addChain( [d for d in allDicts if d['chainName'] == chain.name ][0]) - log.debug("Added chain to ComboHypo: %s",lastCFseq.step.combo.getChains()) - else: - log.debug("Combo not implemented if it's empty step") - - # add HypoTools - lastCFseq.createHypoTools(chain.name,chainStep.stepDicts) - - if len(chain.steps) == nstep+1: - log.debug("Adding finalDecisions for chain %s at step %d:", chain.name, nstep+1) - for dec in lastDecisions: - finalDecisions[nstep].append(dec) - log.debug(dec) - #acc.printConfig(withDetails=True, summariseProps=True) - #end of loop over steps - log.debug("\n Built CF for chain %s with %d steps: \n - %s ", chain.name,len(chain.steps),'\n - '.join(map(str, [{step.name:step.multiplicity} for step in chain.steps]))) - #end of loop over chains - - - log.debug("End of createDataFlow for %d chains and total %d steps", len(chains), NSTEPS) - for nstep in range(NSTEPS): - log.debug("step %d: built %d sequences", nstep, len(CFseqList[nstep])) - return (finalDecisions, CFseqList) -###################### - if len(chains) == 0: log.info("[generateDecisionTree] Configuring empty decisionTree") return acc - (finalDecisions, CFseq_list) = constructDataFlow() - constructControlFlow(CFseq_list) - - - + (finalDecisions, CFseq_list) = createDataFlow(chains, allDicts) + createControlFlow(flags, HLTNode, CFseq_list, acc) log.debug("finalDecisions: %s", finalDecisions) - - theCFisFixed=True - log.debug("CF constructed") - #resetDataFlow(acc) - log.debug("DF connected") - #setupHypoTools() - log.debug("Configured (Combo) Hypos") acc.printConfig(withDetails=True, summariseProps=True) #FP validateDataFlowConnections() @@ -254,93 +33,3 @@ def generateDecisionTree(flags, HLTMenuConfig): return acc -if __name__ == "__main__": - # Test of DF collections traversal - # build hypothetical structure of DF to test back traversing - # make it resemble the combined chain with one arm that is hollow/empty - # naming convention: H* - hypo, IM* - InputMaker, CH* - combo hypo, F* - filter - # last digit is step - # small letter a/b branch of the selection - acc = ComponentAccumulator() - # step 1 - acc.addEventAlgo(CompFactory.RoRSeqFilter("Fmerged1", Input=["Fa1_I","Fb1_I"], Output=["Fa1merged_O", "Fb1merged_O"])) - acc.addEventAlgo(CompFactory.RoRSeqFilter("Fa1", Input=["Fa1_I"], Output=["Fa1_O"])) - acc.addEventAlgo(CompFactory.RoRSeqFilter("Fb1", Input=["Fb1_I"], Output=["FOb1"])) - acc.addEventAlgo(CompFactory.EventViewCreatorAlgorithm("IMa1", InputMakerInputDecisions=["Fa1_O", "Fa1merged_O"], InputMakerOutputDecisions="IMa1_O")) - acc.addEventAlgo(CompFactory.EventViewCreatorAlgorithm("IMb1", InputMakerInputDecisions=["FOb1", "Fb1merged_O"], InputMakerOutputDecisions="IMb1_O")) - acc.addEventAlgo(CompFactory.HLTTest.TestHypoAlg("Ha1", HypoInputDecisions="IMa1_O", HypoOutputDecisions="Ha1_O")) - acc.addEventAlgo(CompFactory.HLTTest.TestHypoAlg("Hb1", HypoInputDecisions="IMb1_O", HypoOutputDecisions="Hb1_O")) - acc.addEventAlgo(CompFactory.ComboHypo("CHmerged1", HypoInputDecisions=["Ha1_O","Hb1_O"], HypoOutputDecisions=["CHa1merged_O", "CHb1merged_O"])) - acc.addEventAlgo(CompFactory.ComboHypo("CHa1", HypoInputDecisions=["Ha1_O"], HypoOutputDecisions=["CHa1_O"])) - acc.addEventAlgo(CompFactory.ComboHypo("CHb1", HypoInputDecisions=["Hb1_O"], HypoOutputDecisions=["CHb1_O"])) - - # step 2 with alternative merged sequences, when one is empty - acc.addEventAlgo(CompFactory.RoRSeqFilter("Fmerged2", Input=["CHa1merged_O","CHb1merged_O"], Output=["Fa2merged_O", "Fb2merged_O"])) #FOb2maerged dangling/unused - acc.addEventAlgo(CompFactory.RoRSeqFilter("Faltmerged2", Input=["CHa1merged_O"], Output=["Fa2altmerged_O"])) # - acc.addEventAlgo(CompFactory.RoRSeqFilter("Fa2", Input=["CHa1_O"], Output=["Fa2_O"])) - acc.addEventAlgo(CompFactory.RoRSeqFilter("Fb2", Input=["CHb1_O"], Output=["Fb2_O"])) - acc.addEventAlgo(CompFactory.EventViewCreatorAlgorithm("IMa2", InputMakerInputDecisions=["Fa2_O", "Fa2merged_O", "Fa2altmerged_O"], InputMakerOutputDecisions="IMa2_O")) - acc.addEventAlgo(CompFactory.EventViewCreatorAlgorithm("IMb2", InputMakerInputDecisions=["Fb2_O", "Fb2merged_O"], InputMakerOutputDecisions="IMb2_O")) - acc.addEventAlgo(CompFactory.HLTTest.TestHypoAlg("Ha2", HypoInputDecisions="IMa2_O", HypoOutputDecisions="Ha2_O")) - acc.addEventAlgo(CompFactory.HLTTest.TestHypoAlg("Hb2", HypoInputDecisions="IMb2_O", HypoOutputDecisions="Hb2_O")) - acc.addEventAlgo(CompFactory.ComboHypo("CHmerged2", HypoInputDecisions=["Ha2_O","Hb2_O"], HypoOutputDecisions=["CHa2merged_O", "CHb2merged_O"])) # assymetry here, see Hb1_O - acc.addEventAlgo(CompFactory.ComboHypo("CHaltmerged2", HypoInputDecisions=["Ha2_O","Hb1_O"], HypoOutputDecisions=["CHa2altmerged_O", "CHb2altmerged_O"])) # assymetry here, see Hb1_O - acc.addEventAlgo(CompFactory.ComboHypo("CHa2", HypoInputDecisions=["Ha2_O"], HypoOutputDecisions=["CHa2_O"])) - acc.addEventAlgo(CompFactory.ComboHypo("CHb2", HypoInputDecisions=["Hb2_O"], HypoOutputDecisions=["CHb2_O"])) - - # step 3 (wiht missing branch b) - acc.addEventAlgo(CompFactory.RoRSeqFilter("Fmerged3", Input=["CHa2merged_O","CHb2merged_O", "CHa2altmerged_O", "CHb2altmerged_O"], Output=["Fa3merged_O", "Fb3merged_O"], IOMapping=[[0,2],[1,3]])) - acc.addEventAlgo(CompFactory.RoRSeqFilter("Fa3", Input=["CHa2_O"], Output=["Fa3_O"])) - acc.addEventAlgo(CompFactory.RoRSeqFilter("Fb3", Input=["CHb2_O", "CHb1_O"], Output=["Fb3_O"], IOMapping=[[0,1]])) # reach to step 1, one output - acc.addEventAlgo(CompFactory.EventViewCreatorAlgorithm("IMa3", InputMakerInputDecisions=["Fa3_O", "Fa3merged_O"], InputMakerOutputDecisions="IMa3_O")) - acc.addEventAlgo(CompFactory.EventViewCreatorAlgorithm("IMb3", InputMakerInputDecisions=["Fb3_O", "Fb3merged_O"], InputMakerOutputDecisions="IMb3_O")) - acc.addEventAlgo(CompFactory.HLTTest.TestHypoAlg("Ha3", HypoInputDecisions="IMa3_O", HypoOutputDecisions="Ha3_O")) - acc.addEventAlgo(CompFactory.HLTTest.TestHypoAlg("Hb3", HypoInputDecisions="IMb3_O", HypoOutputDecisions="Hb3_O")) - acc.addEventAlgo(CompFactory.ComboHypo("CHmerged3", HypoInputDecisions=["Ha3_O","Hb3_O"], HypoOutputDecisions=["CHOa3merged", "CHOb3merged"])) - acc.addEventAlgo(CompFactory.ComboHypo("CHa3", HypoInputDecisions=["Ha3_O"], HypoOutputDecisions=["CHa3_O"])) - acc.addEventAlgo(CompFactory.ComboHypo("CHb3", HypoInputDecisions=["Hb3_O"], HypoOutputDecisions=["CHb3_O"])) - - acc.printConfig() - acc.wasMerged() - - # test traversing and collection of info (example hypo) - colls = [] - def hypoInOut(outCol, alg): - if isHypoAlg(alg): - colls.append(alg.HypoInputDecisions.Path) - colls.append(alg.HypoOutputDecisions.Path) - - traverseDataFlow(acc, "CHa2_O", hypoInOut) # start from ComboHypo output - log.info(colls) - assert set(colls) == set(['Ha2_O', 'IMa2_O', 'Ha1_O', 'IMa1_O']), "Traversing could not find hypo outpus & outputs for branch 'a'" - - colls = [] - traverseDataFlow(acc, "Fb3_O", hypoInOut) # start from ComboHypo output - log.info(colls) - assert set(colls) == set(['Hb1_O', 'IMb1_O', 'Hb2_O', 'IMb2_O']), "Traversing could not find hypo output & input for branch 'b'" - - colls = [] - traverseDataFlow(acc, "CHa2altmerged_O", hypoInOut) # start from ComboHypo output - log.info(colls) - assert 'Ha1_O' in colls - assert 'Hb2_0' not in colls, "This is another arm of selection 'b'" - - colls = [] - traverseDataFlow(acc, "CHb2altmerged_O", hypoInOut) # start from ComboHypo output from where 2nd setup hypo is not reachable - log.info(colls) - assert 'Hb1_O' in colls - assert 'Hb2_0' not in colls, "Due to empty step, this should nto be reachable" - - - colls = [] - def collectFilterInputs( outColl, alg ): - if isFilterAlg(alg): - idx = alg.Output.index(outColl) - colls.append(alg.Input[idx]) - - traverseDataFlow(acc, "CHa2_O", collectFilterInputs) - assert set(colls) == set(["CHa1_O", "CHa1merged_O", "Fa1_I"]) - colls = [] - traverseDataFlow(acc, "CHb2merged_O", collectFilterInputs) - assert set(colls) == set(["CHb1_O", "CHb1merged_O", "Fb1_I"]) - log.info("All ok") diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/GenerateMenuMT.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/GenerateMenuMT.py index 256b30fcf426..1413e8c31f5f 100755 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/GenerateMenuMT.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/GenerateMenuMT.py @@ -9,7 +9,6 @@ from TriggerMenuMT.HLT.Config.ControlFlow.HLTCFTools import NoCAmigration from AthenaCommon.Logging import logging log = logging.getLogger(__name__) -log.setLevel(logging.DEBUG) class Singleton(type): _instances = {} diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/GenerateMenuMT_newJO.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/GenerateMenuMT_newJO.py index d0b060694b62..5a3919898d17 100755 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/GenerateMenuMT_newJO.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/GenerateMenuMT_newJO.py @@ -3,10 +3,12 @@ import itertools from TriggerMenuMT.HLT.Config.Utility.DictFromChainName import dictFromChainName -if 0: - from TriggerMenuMT.HLT.Config.ControlFlow.HLTCFConfig_newJO import generateDecisionTree -else: - from TriggerMenuMT.HLT.Config.ControlFlow.HLTCFConfig_CA import generateDecisionTree +#from TriggerMenuMT.HLT.Config.ControlFlow.HLTCFConfig_newJO import generateDecisionTree +#from TriggerMenuMT.HLT.Config.ControlFlow.HLTCFConfig_CA import decisionTreeFromChains +from TriggerMenuMT.HLT.Config.ControlFlow.HLTCFConfig import decisionTreeFromChains, sequenceScanner, makeSummary + +from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator +from AthenaCommon.CFElements import parOR, seqAND from TriggerMenuMT.HLT.Config.Utility.HLTMenuConfig import HLTMenuConfig from TriggerMenuMT.HLT.Config.Utility.ChainMerging import mergeChainDefs from TriggerMenuMT.HLT.Config.Utility.ChainDictTools import splitInterSignatureChainDict @@ -16,7 +18,6 @@ import importlib from AthenaCommon.Logging import logging log = logging.getLogger(__name__) -log.setLevel(logging.DEBUG) def getChainsOfMenu(flags): """ @@ -204,7 +205,7 @@ def generateMenuMT(flags): log.info("finalListOfChainConfig %s", finalListOfChainConfigs) log.info("Making the HLT configuration tree") - menuAcc=generateMenuAcc(flags) + menuAcc=makeHLTTree(flags) # generate L1 menu # This probably will go to TriggerConfig.triggerRunCfg @@ -218,7 +219,7 @@ def LoadAndGenerateMenu(flags): Load and generate Chain configurations, without ChainConfigurationBase """ loadChains(flags) - menuAcc= generateMenuAcc(flags) + menuAcc= makeHLTTree(flags) # The L1 presacles do not get created in the menu setup from TrigConfigSvc.TrigConfigSvcCfg import generateL1Menu, createL1PrescalesFileFromMenu generateL1Menu(flags) @@ -226,18 +227,61 @@ def LoadAndGenerateMenu(flags): return menuAcc -def generateMenuAcc(flags): +def makeHLTTree(flags): """ Generate appropriate Control Flow Graph wiht all HLT algorithms """ + log.info("newJO version of makeHLTTree") + from TriggerJobOpts.TriggerConfig import collectHypos, \ + triggerSummaryCfg #steps=[] # neeeded? #menuAcc = generateDecisionTree(flags, steps, HLTMenuConfig.configsList(), HLTMenuConfig.dictsList(), newJO=False) - menuAcc = generateDecisionTree(flags, HLTMenuConfig) + #this is old newJO menu + acc = ComponentAccumulator() + + steps = seqAND('HLTAllSteps') + finalDecisions, menuAcc = decisionTreeFromChains(flags, steps, HLTMenuConfig.configsList(), HLTMenuConfig.dictsList(), newJO=False) menuAcc.wasMerged() if log.getEffectiveLevel() <= logging.DEBUG: menuAcc.printConfig() - log.info('CF is built') + acc.merge(menuAcc) + successful_scan = sequenceScanner( steps ) + if not successful_scan: + raise Exception("[makeHLTTree] At least one sequence is expected in more than one step. Check error messages and fix!") + + flatDecisions=[] + for step in finalDecisions: + flatDecisions.extend (step) + + summary = makeSummary("Final", flatDecisions) + + hypos = collectHypos(steps) + #filters = collectFilters(steps) + viewMakers = collectViewMakers(steps) + + viewMakerMap = {vm.getName():vm for vm in viewMakers} + for vmname, vm in viewMakerMap.items(): + log.debug(f"{vmname} InputMakerOutputDecisions: {vm.InputMakerOutputDecisions}") + if vmname.endswith("_probe"): + try: + log.debug(f"Setting InputCachedViews on {vmname} to read decisions from tag leg {vmname[:-6]}: {vm.InputMakerOutputDecisions}") + vm.InputCachedViews = viewMakerMap[vmname[:-6]].InputMakerOutputDecisions + except KeyError: # We may be using a probe leg that has different reco from the tag + log.debug(f"Tag leg does not match probe: '{vmname[:-6]}', will not use cached views") + + + hltEndSeq = parOR("HLTEndSeq") + acc.addSequence(hltEndSeq, parentName="HLTAllSteps") + hltEndSeq.Members += [summary] + + + summaryAcc, summaryAlg = triggerSummaryCfg( flags, hypos ) + # Schedule the DecisionSummaryMakerAlg + acc.addSequence(seqAND("HLTFinalizeSeq"), parentName="HLTEndSeq") + acc.merge(summaryAcc, sequenceName="HLTFinalizeSeq") + + log.info("[makeHLTTree] created the final summary tree") # # generate JOSON representation of the config from TriggerMenuMT.HLT.Config.JSON.HLTMenuJSON import generateJSON_newJO diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/MenuComponents.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/MenuComponents.py index 04b071f37b25..6c713cd3a6d1 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/MenuComponents.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/MenuComponents.py @@ -16,7 +16,6 @@ from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator from AthenaConfiguration.ComponentFactory import CompFactory from AthenaConfiguration.AccumulatorCache import AccumulatorCache from DecisionHandling.DecisionHandlingConfig import ComboHypoCfg -from AthenaConfiguration.ComponentFactory import isRun3Cfg from AthenaConfiguration.ComponentAccumulator import printProperties import GaudiConfig2 from GaudiKernel.DataHandle import DataHandle @@ -32,7 +31,6 @@ import re from AthenaCommon.Logging import logging log = logging.getLogger( __name__ ) -log.setLevel(logging.DEBUG) # Pool of mutable ComboHypo instances (as opposed to immutable cache of RecoFragmentsPool) _ComboHypoPool = dict() @@ -178,8 +176,7 @@ class HypoAlgNode(AlgNode): def addHypoTool (self, hypoToolConf): - log.debug("Adding HypoTool %s to %s", hypoToolConf.chainDict['chainName'], self.Alg.getName()) - print(len(self.Alg.HypoTools)) + log.debug("Adding HypoTool %s to %s", hypoToolConf.chainDict['chainName'], self.Alg.getName()) try: self.Alg.HypoTools = self.Alg.HypoTools + [hypoToolConf.create()] # see ATEAM-773 except NoHypoToolCreated as e: @@ -253,20 +250,10 @@ class ComboMaker(AlgNode): def addInput(self, name): return AlgNode.addInput(self, name) - def addChain(self, chainDict): - print("Adding chains to ComboHypo ", compName(self.Alg), ": ",chainDict['chainName']) - #printProperties(log,self.Alg) + def addChain(self, chainDict): chainName = chainDict['chainName'] - chainMult = chainDict['chainMultiplicities'] - print("inputs=",self.getInputList() ) - legsToInputCollections = self.mapRawInputsToInputsIndex() - #legsToInputCollections = self.getInputList() - # only to debug - cval1 = getProp(self.Alg, self.prop1) # check necessary to see if chain was added already? - cval2 = getProp(self.Alg, self.prop2) - print ("Already set Props:", cval1, cval2) - # - + chainMult = chainDict['chainMultiplicities'] + legsToInputCollections = self.mapRawInputsToInputsIndex() if len(chainMult) != len(legsToInputCollections): log.error("ComboMaker for Alg:{} with addChain for:{} Chain multiplicity:{} Per leg input collection index:{}." .format(compName(self.Alg), chainName, tuple(chainMult), tuple(legsToInputCollections))) @@ -276,9 +263,7 @@ class ComboMaker(AlgNode): raise Exception("[createDataFlow] Error in ComboMaker.addChain. Cannot proceed.") cval1 = getProp(self.Alg, self.prop1) # check necessary to see if chain was added already? - cval2 = getProp(self.Alg, self.prop2) - print (cval1, cval2) - print (cval1.keys()) + cval2 = getProp(self.Alg, self.prop2) if type(cval1) is dict or isinstance(cval1, GaudiConfig2.semantics._DictHelper): if chainName in cval1.keys(): log.error("ERROR in configuration: ComboAlg %s has already been configured for chain %s", compName(self.Alg), chainName) @@ -292,11 +277,10 @@ class ComboMaker(AlgNode): setattr(self.Alg, self.prop1, cval1) setattr(self.Alg, self.prop2, cval2) - #printProperties(log,self.Alg) + def getChains(self): - cval = getProp(self.Alg, self.prop1) - #cval = self.Alg.getProperties()[self.prop1] + cval = getProp(self.Alg, self.prop1) return cval.keys() @@ -511,8 +495,7 @@ class MenuSequence(object): def connectToFilter(self, outfilter): """ Connect filter to the InputMaker""" - log.debug("connecting %s to inputs of %s", outfilter,compName(self._maker.Alg)) - #printProperties(log,self._maker.Alg) + log.debug("connecting %s to inputs of %s", outfilter,compName(self._maker.Alg)) self._maker.addInput(outfilter) def connect(self, Hypo, HypoToolGen): @@ -585,13 +568,11 @@ class MenuSequenceCA(MenuSequence): allAlgs = self.ca.getEventAlgos() inputMaker = [ a for a in allAlgs if isInputMakerBase(a)] assert len(inputMaker) == 1, "Wrong number of input makers in the component accumulator {}".format(len(inputMaker)) - inputMaker = inputMaker[0] - #inputMaker.InputMakerInputDecisions=[] # why do we need this in CA mode?? + inputMaker = inputMaker[0] hypoAlg = [ a for a in allAlgs if isHypoAlg(a)] assert len(hypoAlg) == 1, "Wrong number of hypo algs in the component accumulator {}".format(len(hypoAlg)) hypoAlg = hypoAlg[0] - print("creating MenuSequenceCA for Hypo ", hypoAlg.getName()) - self.ca.printConfig() + #self.ca.printConfig() MenuSequence.__init__(self, self.ca.topSequence(), inputMaker, hypoAlg, HypoToolGen) @property diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/Utility/ComboHypoHandling.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/Utility/ComboHypoHandling.py index d184dac880c9..66d33aef6255 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/Utility/ComboHypoHandling.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/Utility/ComboHypoHandling.py @@ -54,7 +54,6 @@ from TriggerMenuMT.HLT.MinBias.MinBiasChainConfiguration import TrigAFPDijetComb from TriggerMenuMT.HLT.Muon.MuonChainConfiguration import TrigMuonEFIdtpInvMassHypoToolCfg def TrigComboHypoToolFromDict(chainDict): - from TrigHypoCommonTools.TrigHypoCommonToolsConf import TrigComboHypoTool from AthenaMonitoringKernel.GenericMonitoringTool import GenericMonitoringTool, defineHistogram chainName = chainDict['chainName'] -- GitLab From c0584ad93c126079cbc92dce5072883fd93f03fc Mon Sep 17 00:00:00 2001 From: Francesca Pastore <francesca.pastore@cern.ch> Date: Tue, 20 Dec 2022 16:28:39 +0100 Subject: [PATCH 04/15] some cleanup --- .../python/DecisionHandlingConfig.py | 3 +- .../HLT/Config/ControlFlow/HLTCFConfig_CA.py | 35 ------------------- .../python/HLT/Config/GenerateMenuMT_newJO.py | 2 +- 3 files changed, 2 insertions(+), 38 deletions(-) delete mode 100644 Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFConfig_CA.py diff --git a/Trigger/TrigSteer/DecisionHandling/python/DecisionHandlingConfig.py b/Trigger/TrigSteer/DecisionHandling/python/DecisionHandlingConfig.py index 0158022d9240..74ec0b9b3cd8 100644 --- a/Trigger/TrigSteer/DecisionHandling/python/DecisionHandlingConfig.py +++ b/Trigger/TrigSteer/DecisionHandling/python/DecisionHandlingConfig.py @@ -31,8 +31,7 @@ def TriggerSummaryAlg( name ): alg.MonTool = monTool return alg -def ComboHypoCfg( name ): - from DecisionHandling.DecisionHandlingConf import ComboHypo +def ComboHypoCfg( name ): alg = CompFactory.ComboHypo( name ) return alg diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFConfig_CA.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFConfig_CA.py deleted file mode 100644 index bb4a100a6e1b..000000000000 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFConfig_CA.py +++ /dev/null @@ -1,35 +0,0 @@ -# Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration -from AthenaCommon.CFElements import findAllAlgorithms, seqOR -from AthenaCommon.Logging import logging -from .HLTCFConfig import createDataFlow, createControlFlow - -log = logging.getLogger( __name__ ) - -def decisionTreeFromChains(flags, HLTNode, chains, allDicts, newJO): - """Creates CF algorithms - - The implementation relies of functions that build a small element of it. - Each function generates whatever is needed in the decision tree before (potentially in a recursive way). - All functions are cached, so each element is created only once. - - The functions check the global boolean theCFisFixed - and if set to True no CF algorithms are further constructed (assertion error is generated). - """ - - - if len(chains) == 0: - log.info("[generateDecisionTree] Configuring empty decisionTree") - return acc - - (finalDecisions, CFseq_list) = createDataFlow(chains, allDicts) - createControlFlow(flags, HLTNode, CFseq_list, acc) - log.debug("finalDecisions: %s", finalDecisions) - - acc.printConfig(withDetails=True, summariseProps=True) - - #FP validateDataFlowConnections() - - #if log.getEffectiveLevel() <= logging.DEBUG: - # printChainsConfig() - return acc - - diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/GenerateMenuMT_newJO.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/GenerateMenuMT_newJO.py index 5a3919898d17..e9de39b339d4 100755 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/GenerateMenuMT_newJO.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/GenerateMenuMT_newJO.py @@ -232,7 +232,7 @@ def makeHLTTree(flags): Generate appropriate Control Flow Graph wiht all HLT algorithms """ log.info("newJO version of makeHLTTree") - from TriggerJobOpts.TriggerConfig import collectHypos, \ + from TriggerJobOpts.TriggerConfig import collectHypos, collectViewMakers, \ triggerSummaryCfg #steps=[] # neeeded? #menuAcc = generateDecisionTree(flags, steps, HLTMenuConfig.configsList(), HLTMenuConfig.dictsList(), newJO=False) -- GitLab From bb6a457638d5ee84d4fabd3b8e129c92c0e00592 Mon Sep 17 00:00:00 2001 From: Francesca Pastore <francesca.pastore@cern.ch> Date: Wed, 21 Dec 2022 19:13:45 +0100 Subject: [PATCH 05/15] some cleanup, ready without probe chains --- .../TriggerJobOpts/python/TriggerConfig.py | 4 + .../python/runHLT_standalone_newJO.py | 8 +- .../HLT/Config/ControlFlow/HLTCFConfig.py | 35 +++----- .../Config/ControlFlow/HLTCFConfig_newJO.py | 3 +- .../python/HLT/Config/GenerateMenuMT.py | 1 + .../python/HLT/Config/GenerateMenuMT_newJO.py | 5 +- .../python/HLT/Config/MenuComponents.py | 89 +++++++++++-------- .../Electron/TrigEMBremCollectionBuilder.py | 2 + .../python/HLT/Menu/Dev_pp_run3_v1.py | 3 +- .../python/HLT/Muon/generateMuon.py | 14 +-- 10 files changed, 85 insertions(+), 79 deletions(-) diff --git a/Trigger/TriggerCommon/TriggerJobOpts/python/TriggerConfig.py b/Trigger/TriggerCommon/TriggerJobOpts/python/TriggerConfig.py index 1b3477a23319..db5316190452 100644 --- a/Trigger/TriggerCommon/TriggerJobOpts/python/TriggerConfig.py +++ b/Trigger/TriggerCommon/TriggerJobOpts/python/TriggerConfig.py @@ -630,6 +630,10 @@ def triggerRunCfg( flags, menu=None ): acc.addSequence( parOR("HLTEndSeq"), parentName="HLTTop" ) acc.addSequence( seqAND("HLTFinalizeSeq"), parentName="HLTEndSeq" ) + nfilters = sum(len(v) for v in filters.values()) + nhypos = sum(len(v) for v in hypos.values()) + __log.info( "Algorithms counting: Number of Filter algorithms: %d - Number of Hypo algoirthms: %d", nfilters , nhypos) + summaryAcc, summaryAlg = triggerSummaryCfg( flags, hypos ) acc.merge( summaryAcc, sequenceName="HLTFinalizeSeq" ) acc.addEventAlgo( summaryAlg, sequenceName="HLTFinalizeSeq" ) diff --git a/Trigger/TriggerCommon/TriggerJobOpts/python/runHLT_standalone_newJO.py b/Trigger/TriggerCommon/TriggerJobOpts/python/runHLT_standalone_newJO.py index 2c55f8e2b6ec..718617d326fc 100755 --- a/Trigger/TriggerCommon/TriggerJobOpts/python/runHLT_standalone_newJO.py +++ b/Trigger/TriggerCommon/TriggerJobOpts/python/runHLT_standalone_newJO.py @@ -53,8 +53,8 @@ flags.addFlag("Trigger.selectChains",[]) flags.addFlag("Trigger.disableChains",[]) -flags.Trigger.enabledSignatures = ['Muon'] #, 'Photon','Electron'] -flags.Trigger.selectChains = ['HLT_mu4_L1MU3V','HLT_mu8_L1MU5VF','HLT_2mu6_L12MU5VF', 'HLT_mu4_mu6_L12MU3V'] +flags.Trigger.enabledSignatures = ['Muon', 'Photon','Electron'] +#flags.Trigger.selectChains = ['HLT_mu4_L1MU3V','HLT_mu8_L1MU5VF','HLT_2mu6_L12MU5VF', 'HLT_mu24_mu6_L1MU14FCH','HLT_mu24_mu6_probe_L1MU14FCH'] #, 'HLT_mu4_mu6_L12MU3V'] #flags.Trigger.disableChains=["HLT_2mu4_l2io_invmDimu_L1BPH-2M9-0DR15-2MU3VF", "HLT_2mu4_l2io_invmDimu_L1BPH-2M9-0DR15-2MU3V", "HLT_2mu6_l2io_invmDimu_L1BPH-2M9-2DR15-2MU5VF"] # exclude jets for now, since their MenuSeuqnece Structure needs more work to migrate @@ -94,10 +94,10 @@ flags.lock() flags.dump() # Enable when debugging deduplication issues # ComponentAccumulator.debugMode = "trackCA trackEventAlog ... and so on" - +from AthenaCommon.Logging import logging +logging.getLogger("TriggerMenuMT").setLevel(logging.DEBUG) acc = MainServicesCfg(flags) - acc.getService('AvalancheSchedulerSvc').VerboseSubSlots = True # this delcares to the scheduler that EventInfo object comes from the input diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFConfig.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFConfig.py index ed22c602f46c..00bca0fb6532 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFConfig.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFConfig.py @@ -438,8 +438,7 @@ def createDataFlow(chains, allDicts): else: filterOutput =[ CFNaming.filterOutName(filterName, inputName) for inputName in filterInput ] - foundCFSeq = [cfseq for cfseq in CFseqList[nstep] if filterName == cfseq.filter.Alg.getName()] - #foundCFSeq = findCFSequences(filterName, CFseqList[nstep]) + foundCFSeq = [cfseq for cfseq in CFseqList[nstep] if filterName == cfseq.filter.Alg.getName()] log.debug("Found %d CF sequences with filter name %s", len(foundCFSeq), filterName) if not foundCFSeq: sequenceFilter = buildFilter(filterName, filterInput, chainStep.isEmpty) @@ -547,21 +546,16 @@ def createControlFlow(flags, HLTNode, CFseqList): for cseq in CFseqList[nstep]: #createCFTree=Filter+Reco+Combo log.debug(" *** Create CF Tree for CFSequence %s", cseq.step.name) - filterAlg = cseq.filter.Alg - stepReco = parOR(cseq.step.name + CFNaming.RECO_POSTFIX) + if isRun3Cfg(): + acc.merge( cseq.ca, sequenceName=stepCFReco.getName()) - if len(cseq.step.sequences)==0: - if isRun3Cfg(): - stepCFReco.Members +=[filterAlg] - else: - stepCFReco += filterAlg else: - seqAndWithFilter = seqAND(cseq.step.name) - if isRun3Cfg(): - stepCFReco.Members +=[seqAndWithFilter] - seqAndWithFilter.Members +=[filterAlg, stepReco] - acc.merge( cseq.ca, sequenceName=stepReco.getName()) + filterAlg = cseq.filter.Alg + if len(cseq.step.sequences)==0: + stepCFReco += filterAlg else: + seqAndWithFilter = seqAND(cseq.step.name) + stepReco = parOR(cseq.step.name + CFNaming.RECO_POSTFIX) seqAndWithFilter +=[filterAlg, stepReco] recoSeqSet=set() hypoSet=set() @@ -589,8 +583,8 @@ def createControlFlow(flags, HLTNode, CFseqList): if flags.Trigger.generateMenuDiagnostics: log.debug("Now Draw...") - stepCF_DataFlow_to_dot(stepReco.getName(), CFseqList[nstep]) - stepCF_ControlFlow_to_dot(stepReco) + stepCF_DataFlow_to_dot(stepCFReco.getName(), CFseqList[nstep]) + stepCF_ControlFlow_to_dot(stepCFReco) log.debug("************* End of step %d, %s", nstep+1, stepSequenceName) @@ -636,15 +630,6 @@ def createControlFlowOld(flags, HLTNode, CFseqList): return -# obsolete, to remove -def findCFSequences(filter_name, cfseqList): - """ - Searches for a filter, with given name, in the CF sequence list of this step - """ - foundFilters = [cfseq for cfseq in cfseqList if filter_name == compName(cfseq.filter.Alg)] - - return foundFilters - def buildFilter(filter_name, filter_input, empty): """ diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFConfig_newJO.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFConfig_newJO.py index b26b9b22c9f3..325d4d0640d1 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFConfig_newJO.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFConfig_newJO.py @@ -568,7 +568,8 @@ def generateDecisionTree(flags, HLTMenuConfig): validateDataFlowConnections() - printChainsConfig() + if log.getEffectiveLevel() <= logging.DEBUG: + printChainsConfig() return acc diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/GenerateMenuMT.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/GenerateMenuMT.py index 1413e8c31f5f..268683c37e5b 100755 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/GenerateMenuMT.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/GenerateMenuMT.py @@ -10,6 +10,7 @@ from TriggerMenuMT.HLT.Config.ControlFlow.HLTCFTools import NoCAmigration from AthenaCommon.Logging import logging log = logging.getLogger(__name__) + class Singleton(type): _instances = {} def __call__(cls, *args, **kwargs): diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/GenerateMenuMT_newJO.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/GenerateMenuMT_newJO.py index e9de39b339d4..d5460c114da4 100755 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/GenerateMenuMT_newJO.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/GenerateMenuMT_newJO.py @@ -256,6 +256,7 @@ def makeHLTTree(flags): summary = makeSummary("Final", flatDecisions) + """ hypos = collectHypos(steps) #filters = collectFilters(steps) viewMakers = collectViewMakers(steps) @@ -282,7 +283,7 @@ def makeHLTTree(flags): acc.merge(summaryAcc, sequenceName="HLTFinalizeSeq") log.info("[makeHLTTree] created the final summary tree") - +""" # # generate JOSON representation of the config from TriggerMenuMT.HLT.Config.JSON.HLTMenuJSON import generateJSON_newJO generateJSON_newJO(flags, HLTMenuConfig.dictsList(), HLTMenuConfig.configsList(), menuAcc.getSequence("HLTAllSteps")) @@ -290,6 +291,8 @@ def makeHLTTree(flags): from TriggerMenuMT.HLT.Config.JSON.HLTPrescaleJSON import generateJSON_newJO as generatePrescaleJSON_newJO generatePrescaleJSON_newJO(flags, HLTMenuConfig.dictsList(), HLTMenuConfig.configsList()) + from AthenaCommon.CFElements import checkSequenceConsistency + checkSequenceConsistency(steps) return menuAcc diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/MenuComponents.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/MenuComponents.py index 8821c78c92b2..70baf4cb2cfd 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/MenuComponents.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/MenuComponents.py @@ -16,7 +16,6 @@ from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator from AthenaConfiguration.ComponentFactory import CompFactory from AthenaConfiguration.AccumulatorCache import AccumulatorCache from DecisionHandling.DecisionHandlingConfig import ComboHypoCfg -from AthenaConfiguration.ComponentAccumulator import printProperties import GaudiConfig2 from GaudiKernel.DataHandle import DataHandle from HLTSeeding.HLTSeedingConfig import mapThresholdToL1DecisionCollection @@ -225,9 +224,6 @@ class ComboMaker(AlgNode): def create (self, name): log.debug("ComboMaker.create %s",name) - #tmp FP: - #return CompFactory.ComboHypo( name ) - return self.comboHypoCfg(name=name) """ @@ -367,12 +363,18 @@ class MenuSequence(object): # For probe legs we need to substitute the inputmaker and hypo alg # so we will use temp variables for both - if IsProbe: - log.debug("MenuSequence: found a probe leg") - _Hypo = RecoFragmentsPool.retrieve(MenuSequence.getProbeHypo,ConfigFlags,basehypo=Hypo) - # Reset this so that HypoAlgNode.addOutput will actually do something - _Hypo.HypoOutputDecisions = "StoreGateSvc+UNSPECIFIED_OUTPUT" - _Maker = RecoFragmentsPool.retrieve(MenuSequence.getProbeInputMaker,ConfigFlags,baseIM=Maker) + if IsProbe: + from AthenaConfiguration.ComponentFactory import isRun3Cfg + if isRun3Cfg(): + #_Hypo = Hypo + #_Maker = Maker + #_Sequence = Sequence + log.info("MenuSequence in Run3Cfg: found a probe leg, don't know how to clone, exit") + else: + _Hypo = RecoFragmentsPool.retrieve(MenuSequence.getProbeHypo,ConfigFlags,basehypo=Hypo) + # Reset this so that HypoAlgNode.addOutput will actually do something + _Hypo.HypoOutputDecisions = "StoreGateSvc+UNSPECIFIED_OUTPUT" + _Maker = RecoFragmentsPool.retrieve(MenuSequence.getProbeInputMaker,ConfigFlags,baseIM=Maker) else: # For regular legs, just use the provided components _Hypo = Hypo @@ -404,21 +406,27 @@ class MenuSequence(object): if IsProbe: def getProbeSequence(baseSeq,probeIM): - # Add IM and sequence contents to duplicated sequence - probeSeq = baseSeq.clone(baseSeq.getName()+"_probe") - probeSeq += probeIM - if isinstance(probeIM,CompFactory.EventViewCreatorAlgorithm): - for child in baseSeq.getChildren()[1:]: - probeChild = child.clone(child.getName()+"_probe") - if hasProp(child,'ROBPrefetchingInputDecisions') and (ROBPrefetching.StepRoI in ConfigFlags.Trigger.ROBPrefetchingOptions): - # child is a ROB prefetching alg, map the probe IM decisions - probeChild.ROBPrefetchingInputDecisions = [str(probeIM.InputMakerOutputDecisions)] - elif probeIM.ViewNodeName == child.getName(): - # child is the view alg sequence, map it to the probe sequence - probeIM.ViewNodeName = probeChild.getName() - for viewalg in child.getChildren(): - probeChild += viewalg - probeSeq += probeChild + if isRun3Cfg(): + probeSeq = None #baseSeq + #probeSeq.name= baseSeq.getName()+"_probe" + log.info("to be completed") + + else: + # Add IM and sequence contents to duplicated sequence + probeSeq = baseSeq.clone(baseSeq.getName()+"_probe") + probeSeq += probeIM + if isinstance(probeIM,CompFactory.EventViewCreatorAlgorithm): + for child in baseSeq.getChildren()[1:]: + probeChild = child.clone(child.getName()+"_probe") + if hasProp(child,'ROBPrefetchingInputDecisions') and (ROBPrefetching.StepRoI in ConfigFlags.Trigger.ROBPrefetchingOptions): + # child is a ROB prefetching alg, map the probe IM decisions + probeChild.ROBPrefetchingInputDecisions = [str(probeIM.InputMakerOutputDecisions)] + elif probeIM.ViewNodeName == child.getName(): + # child is the view alg sequence, map it to the probe sequence + probeIM.ViewNodeName = probeChild.getName() + for viewalg in child.getChildren(): + probeChild += viewalg + probeSeq += probeChild return probeSeq # Make sure nothing was lost _Sequence = getProbeSequence(baseSeq=Sequence,probeIM=_Maker) @@ -563,7 +571,7 @@ class MenuSequence(object): class MenuSequenceCA(MenuSequence): ''' MenuSequence with Component Accumulator ''' - def __init__(self, selectionCA, HypoToolGen ): + def __init__(self, selectionCA, HypoToolGen, isProbe=False ): self.ca = selectionCA allAlgs = self.ca.getEventAlgos() inputMaker = [ a for a in allAlgs if isInputMakerBase(a)] @@ -571,9 +579,8 @@ class MenuSequenceCA(MenuSequence): inputMaker = inputMaker[0] hypoAlg = [ a for a in allAlgs if isHypoAlg(a)] assert len(hypoAlg) == 1, "Wrong number of hypo algs in the component accumulator {}".format(len(hypoAlg)) - hypoAlg = hypoAlg[0] - #self.ca.printConfig() - MenuSequence.__init__(self, self.ca.topSequence(), inputMaker, hypoAlg, HypoToolGen) + hypoAlg = hypoAlg[0] + MenuSequence.__init__(self, self.ca.topSequence(), inputMaker, hypoAlg, HypoToolGen, IsProbe=isProbe) @property def sequence(self): @@ -904,8 +911,7 @@ class ChainStep(object): return comboName = CFNaming.comboHypoName(self.name) key = hash((comboName, self.comboHypoCfg)) - if key not in _ComboHypoPool: - log.debug("makeCombo: creating new ComboHypo %s with hash %s",comboName, key) + if key not in _ComboHypoPool: _ComboHypoPool[key] = createComboAlg(None, name=comboName, comboHypoCfg=self.comboHypoCfg) self.combo = _ComboHypoPool[key] @@ -998,10 +1004,10 @@ class InEventRecoCA( ComponentAccumulator ): class InViewRecoCA(ComponentAccumulator): """ Class to handle in-view reco, sets up the View maker if not provided and exposes InputMaker so that more inputs to it can be added in the process of assembling the menu """ - def __init__(self, name, viewMaker=None, **viewMakerArgs): + def __init__(self, name, viewMaker=None, isProbe=False, **viewMakerArgs): super( InViewRecoCA, self ).__init__() - self.name = name - self.mainSeq = seqAND( name ) + self.name = name +"_probe" if isProbe else name + self.mainSeq = seqAND( self.name ) self.addSequence( self.mainSeq ) if len(viewMakerArgs) != 0: @@ -1043,13 +1049,14 @@ class InViewRecoCA(ComponentAccumulator): class SelectionCA(ComponentAccumulator): """ CA component for MenuSequenceCA sequence """ - def __init__(self, name): - self.name = name - + def __init__(self, name, isProbe=False): + self.name = name+"_probe" if isProbe else name + self.isProbe=isProbe super( SelectionCA, self ).__init__() - self.stepRecoSequence = parOR(CFNaming.stepRecoName(name)) - self.stepViewSequence = seqAND(CFNaming.stepContentName(name), [self.stepRecoSequence]) + # to do: remove content sequence, leave just one for the Hypo? + self.stepRecoSequence = parOR(CFNaming.stepRecoName(self.name)) + self.stepViewSequence = seqAND(CFNaming.stepContentName(self.name), [self.stepRecoSequence]) self.addSequence(self.stepViewSequence) def mergeReco(self, other): @@ -1061,6 +1068,10 @@ class SelectionCA(ComponentAccumulator): def addHypoAlgo(self, algo): """To be used when the hypo alg configuration does not require auxiliary tools/services""" + if self.isProbe: + newname = algo.getName()+'_probe' + algo.name=newname + #algo.name(algo.getName()+'_probe') self.addEventAlgo(algo, sequenceName=self.stepViewSequence.name) def hypo(self): diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Electron/TrigEMBremCollectionBuilder.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Electron/TrigEMBremCollectionBuilder.py index a7508fc1e668..35970364d8c2 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Electron/TrigEMBremCollectionBuilder.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Electron/TrigEMBremCollectionBuilder.py @@ -119,6 +119,8 @@ class TrigEgammaBremCollectionBuilder (egammaAlgsConf.EMBremCollectionBuilder): name="GSFBuildInDetParticleCreatorTool", TRT_ElectronPidTool=GSFBuildTRT_ElectronPidTool, PixelToTPIDTool=GSFBuildPixelToTPIDTool, + TestPixelLayerTool=GSFBuildTestPixelLayerTool, + ComputeAdditionalInfo=True, KeepParameters=True, TrackSummaryTool=GSFBuildInDetTrigTrackSummaryTool) # diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Menu/Dev_pp_run3_v1.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Menu/Dev_pp_run3_v1.py index 217d4f17906b..151f4979f3b5 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Menu/Dev_pp_run3_v1.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Menu/Dev_pp_run3_v1.py @@ -73,8 +73,7 @@ def setupMenu(): #ATR-21003 ChainProp(name='HLT_2mu14_l2io_L12MU8F', groups=DevGroup+MultiMuonGroup), ChainProp(name='HLT_2mu6_l2io_L12MU5VF', groups=DevGroup+MultiMuonGroup), - ## FP add test for combo chains - ChainProp(name='HLT_mu4_mu6_L12MU3V', groups=DevGroup+MultiMuonGroup), + # Test T&P dimuon ChainProp(name='HLT_mu24_mu6_L1MU14FCH', l1SeedThresholds=['MU14FCH','MU3V'], groups=DevGroup+MultiMuonGroup), ChainProp(name='HLT_mu24_mu6_probe_L1MU14FCH', l1SeedThresholds=['MU14FCH','PROBEMU3V'], groups=DevGroup+MultiMuonGroup), diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Muon/generateMuon.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Muon/generateMuon.py index 604e49989136..0417cb482148 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Muon/generateMuon.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Muon/generateMuon.py @@ -158,11 +158,11 @@ def efMuIsoHypoConf(flags, name="UNSPECIFIED", inputMuons="UNSPECIFIED"): return efHypo @AccumulatorCache -def _muFastStepSeq(flags): +def _muFastStepSeq(flags, is_probe_leg=False): # Step 1 (L2MuonSA) - selAcc = SelectionCA("L2MuFastReco") + selAcc = SelectionCA("L2MuFastReco", is_probe_leg) # Set EventViews for L2MuonSA step - reco = InViewRecoCA("L2MuFastReco") + reco = InViewRecoCA("L2MuFastReco", isProbe=is_probe_leg) #external data loading to view reco.mergeReco( MuFastViewDataVerifier(flags) ) @@ -183,13 +183,13 @@ def _muFastStepSeq(flags): selAcc.addHypoAlgo(l2muFastHypo) l2muFastSequence = MenuSequenceCA(selAcc, - HypoToolGen = TrigMufastHypoToolFromDict ) + HypoToolGen = TrigMufastHypoToolFromDict, isProbe=is_probe_leg ) return (selAcc , l2muFastSequence) def muFastSequence(flags, is_probe_leg=False): muonflags = flags.cloneAndReplace('Muon', 'Trigger.Offline.SA.Muon') - selAcc , l2muFastSequence = _muFastStepSeq(muonflags) + selAcc , l2muFastSequence = _muFastStepSeq(muonflags, is_probe_leg) return l2muFastSequence @@ -199,10 +199,10 @@ def muFastStep(flags, chainDict): return ChainStep( name=selAcc.name, Sequences=[l2muFastSequence], chainDicts=[chainDict] ) -## FP fake, just to run +## FP fake, just to test run def muFastOvlpRmSequence (flags, is_probe_leg=False): log.warning("FAKE muFastOvlpRmSequence replaced by single muFast") - return muFastSequence(flags) + return muFastSequence(flags, is_probe_leg) @AccumulatorCache def _muCombStepSeq(flags): -- GitLab From 6692366ce5b88173eae7805125df168565af668d Mon Sep 17 00:00:00 2001 From: Francesca Pastore <francesca.pastore@cern.ch> Date: Wed, 21 Dec 2022 19:16:25 +0100 Subject: [PATCH 06/15] added test_menu_CA --- .../TriggerMenuMT/scripts/test_menu_CA.py | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100755 Trigger/TriggerCommon/TriggerMenuMT/scripts/test_menu_CA.py diff --git a/Trigger/TriggerCommon/TriggerMenuMT/scripts/test_menu_CA.py b/Trigger/TriggerCommon/TriggerMenuMT/scripts/test_menu_CA.py new file mode 100755 index 000000000000..f83fb7a713be --- /dev/null +++ b/Trigger/TriggerCommon/TriggerMenuMT/scripts/test_menu_CA.py @@ -0,0 +1,52 @@ +#!/usr/bin/env python3 +# Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration + +""" +test of Dev menu with CA migrated menu code, reproducing runHLT_standalone_newJO +""" +from AthenaCommon.Logging import logging +log = logging.getLogger('runHLT_standalone_newJO') + +from AthenaConfiguration.AllConfigFlags import ConfigFlags +from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator +from AthenaConfiguration.AccumulatorCache import AccumulatorDecorator +from AthenaCommon.Configurable import Configurable +Configurable.configurableRun3Behavior = 1 + + + + +# select chains, as in runHLT_standalone +ConfigFlags.addFlag("Trigger.enabledSignatures",[]) +ConfigFlags.addFlag("Trigger.disabledSignatures",[]) +ConfigFlags.addFlag("Trigger.selectChains",[]) +ConfigFlags.addFlag("Trigger.disableChains",[]) +ConfigFlags.Trigger.enabledSignatures = ['Muon', 'Photon','Electron'] + +from AthenaConfiguration.AllConfigFlags import ConfigFlags +ConfigFlags.Trigger.generateMenuDiagnostics = True + +from AthenaConfiguration.TestDefaults import defaultTestFiles +ConfigFlags.Input.Files = defaultTestFiles.RAW +ConfigFlags.Trigger.triggerMenuSetup="Dev_pp_run3_v1" + +ConfigFlags.Trigger.EDMVersion=3 +ConfigFlags.lock() +ConfigFlags.dump() + + +acc = ComponentAccumulator() +from TrigConfigSvc.TrigConfigSvcCfg import L1ConfigSvcCfg +acc.merge(L1ConfigSvcCfg(ConfigFlags)) + +from TriggerMenuMT.HLT.Config.GenerateMenuMT_newJO import generateMenuMT +menu = generateMenuMT( ConfigFlags) +acc.merge(menu) + +#from TriggerJobOpts.TriggerConfig import triggerRunCfg +#menu = triggerRunCfg(flags, menu=generateHLTMenu) + +acc.printConfig() +AccumulatorDecorator.printStats() + + -- GitLab From 63f1e7fce1bd9095baaafdd69a7a38297ede8e6e Mon Sep 17 00:00:00 2001 From: Francesca Pastore <francesca.pastore@cern.ch> Date: Wed, 21 Dec 2022 19:34:32 +0100 Subject: [PATCH 07/15] more cleanup --- .../TriggerMenuMT/python/HLT/Menu/Dev_pp_run3_v1_newJO.py | 8 ++++---- .../python/HLT/Muon/MuonChainConfiguration.py | 2 -- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Menu/Dev_pp_run3_v1_newJO.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Menu/Dev_pp_run3_v1_newJO.py index 4185e38014fa..eabec475e245 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Menu/Dev_pp_run3_v1_newJO.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Menu/Dev_pp_run3_v1_newJO.py @@ -113,10 +113,10 @@ if __name__ == "__main__": ConfigFlags.Trigger.generateMenuDiagnostics = True log.info(" Running Dev_pp_run3_newJO") - #ConfigFlags.addFlag("Trigger.enabledSignatures",[]) - #ConfigFlags.addFlag("Trigger.disabledSignatures",[]) - #ConfigFlags.addFlag("Trigger.selectChains",[]) - #ConfigFlags.addFlag("Trigger.disableChains",[]) + ConfigFlags.addFlag("Trigger.enabledSignatures",[]) + ConfigFlags.addFlag("Trigger.disabledSignatures",[]) + ConfigFlags.addFlag("Trigger.selectChains",[]) + ConfigFlags.addFlag("Trigger.disableChains",[]) from AthenaConfiguration.TestDefaults import defaultTestFiles diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Muon/MuonChainConfiguration.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Muon/MuonChainConfiguration.py index 1e5beea937b0..cf00f5a11844 100755 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Muon/MuonChainConfiguration.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Muon/MuonChainConfiguration.py @@ -13,9 +13,7 @@ from ..Config.ChainConfigurationBase import ChainConfigurationBase from AthenaConfiguration.ComponentFactory import isRun3Cfg if isRun3Cfg(): - #from .generateMuon import muFastSequence, muCombSequence from .generateMuon import muFastSequence, muEFSASequence, muCombSequence, muEFCBSequence, muCombOvlpRmSequence, muFastOvlpRmSequence - #muFastOvlpRmSequence, else: from .MuonMenuSequences import muFastSequence, muFastCalibSequence, muFastOvlpRmSequence, mul2mtSAOvlpRmSequence, muCombSequence, muCombLRTSequence, muCombOvlpRmSequence, mul2mtCBOvlpRmSequence, mul2IOOvlpRmSequence, muEFSASequence, muEFCBSequence, muEFCBIDperfSequence, muEFCBLRTSequence, muEFCBLRTIDperfSequence, muEFSAFSSequence, muEFCBFSSequence, muEFIsoSequence, muEFMSIsoSequence, efLateMuRoISequence, efLateMuSequence, muRoiClusterSequence, muEFIDtpSequence -- GitLab From dd04bd60a58ace1ec3bb584853c0f48ff1912047 Mon Sep 17 00:00:00 2001 From: Francesca Pastore <francesca.pastore@cern.ch> Date: Thu, 22 Dec 2022 11:09:30 +0100 Subject: [PATCH 08/15] remove cmake warning --- .../python/HLT/Config/GenerateMenuMT_newJO.py | 38 +------------------ 1 file changed, 2 insertions(+), 36 deletions(-) diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/GenerateMenuMT_newJO.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/GenerateMenuMT_newJO.py index d5460c114da4..90d8cbe6118f 100755 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/GenerateMenuMT_newJO.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/GenerateMenuMT_newJO.py @@ -5,10 +5,10 @@ from TriggerMenuMT.HLT.Config.Utility.DictFromChainName import dictFromChainName #from TriggerMenuMT.HLT.Config.ControlFlow.HLTCFConfig_newJO import generateDecisionTree #from TriggerMenuMT.HLT.Config.ControlFlow.HLTCFConfig_CA import decisionTreeFromChains -from TriggerMenuMT.HLT.Config.ControlFlow.HLTCFConfig import decisionTreeFromChains, sequenceScanner, makeSummary +from TriggerMenuMT.HLT.Config.ControlFlow.HLTCFConfig import decisionTreeFromChains, sequenceScanner from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator -from AthenaCommon.CFElements import parOR, seqAND +from AthenaCommon.CFElements import seqAND from TriggerMenuMT.HLT.Config.Utility.HLTMenuConfig import HLTMenuConfig from TriggerMenuMT.HLT.Config.Utility.ChainMerging import mergeChainDefs from TriggerMenuMT.HLT.Config.Utility.ChainDictTools import splitInterSignatureChainDict @@ -232,11 +232,6 @@ def makeHLTTree(flags): Generate appropriate Control Flow Graph wiht all HLT algorithms """ log.info("newJO version of makeHLTTree") - from TriggerJobOpts.TriggerConfig import collectHypos, collectViewMakers, \ - triggerSummaryCfg - #steps=[] # neeeded? - #menuAcc = generateDecisionTree(flags, steps, HLTMenuConfig.configsList(), HLTMenuConfig.dictsList(), newJO=False) - #this is old newJO menu acc = ComponentAccumulator() steps = seqAND('HLTAllSteps') @@ -253,37 +248,8 @@ def makeHLTTree(flags): flatDecisions=[] for step in finalDecisions: flatDecisions.extend (step) - - summary = makeSummary("Final", flatDecisions) - """ - hypos = collectHypos(steps) - #filters = collectFilters(steps) - viewMakers = collectViewMakers(steps) - - viewMakerMap = {vm.getName():vm for vm in viewMakers} - for vmname, vm in viewMakerMap.items(): - log.debug(f"{vmname} InputMakerOutputDecisions: {vm.InputMakerOutputDecisions}") - if vmname.endswith("_probe"): - try: - log.debug(f"Setting InputCachedViews on {vmname} to read decisions from tag leg {vmname[:-6]}: {vm.InputMakerOutputDecisions}") - vm.InputCachedViews = viewMakerMap[vmname[:-6]].InputMakerOutputDecisions - except KeyError: # We may be using a probe leg that has different reco from the tag - log.debug(f"Tag leg does not match probe: '{vmname[:-6]}', will not use cached views") - - - hltEndSeq = parOR("HLTEndSeq") - acc.addSequence(hltEndSeq, parentName="HLTAllSteps") - hltEndSeq.Members += [summary] - - summaryAcc, summaryAlg = triggerSummaryCfg( flags, hypos ) - # Schedule the DecisionSummaryMakerAlg - acc.addSequence(seqAND("HLTFinalizeSeq"), parentName="HLTEndSeq") - acc.merge(summaryAcc, sequenceName="HLTFinalizeSeq") - - log.info("[makeHLTTree] created the final summary tree") -""" # # generate JOSON representation of the config from TriggerMenuMT.HLT.Config.JSON.HLTMenuJSON import generateJSON_newJO generateJSON_newJO(flags, HLTMenuConfig.dictsList(), HLTMenuConfig.configsList(), menuAcc.getSequence("HLTAllSteps")) -- GitLab From 4d404e1fd66f84cf00df1eaa4340948447c9942f Mon Sep 17 00:00:00 2001 From: Francesca Pastore <francesca.pastore@cern.ch> Date: Thu, 22 Dec 2022 19:58:22 +0100 Subject: [PATCH 09/15] fix of addHypoTool in both JO --- .../HLT/Config/ControlFlow/HLTCFComponents.py | 48 ++++++++----------- .../HLT/Config/ControlFlow/HLTCFConfig.py | 19 +++++--- .../python/HLT/Config/MenuComponents.py | 37 ++++++-------- 3 files changed, 46 insertions(+), 58 deletions(-) diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFComponents.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFComponents.py index 2c29da7b9b12..52b9c8dfe3af 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFComponents.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFComponents.py @@ -15,26 +15,6 @@ RoRSeqFilter = CompFactory.RoRSeqFilter PassFilter = CompFactory.PassFilter -class HypoToolConf(object): - """ Class to group info on hypotools for ChainDict""" - def __init__(self, hypoToolGen): - self.hypoToolGen = hypoToolGen - self.name=hypoToolGen.__name__ - - def setConf( self, chainDict): - if type(chainDict) is not dict: - raise RuntimeError("Configuring hypo with %s, not good anymore, use chainDict" % str(chainDict) ) - self.chainDict = chainDict - - def create(self): - """creates instance of the hypo tool""" - return self.hypoToolGen( self.chainDict ) - - def confAndCreate(self, chainDict): - """sets the configuration and creates instance of the hypo tool""" - self.setConf(chainDict) - return self.create() - class SequenceFilterNode(AlgNode): """Node for any kind of sequence filter""" def __init__(self, Alg, inputProp, outputProp): @@ -177,22 +157,32 @@ class CFSequence(object): log.debug("CFSequence.connectCombo: adding output to %s: %s", self.combo.Alg.getName(), combo_output) - def createHypoTools(self, chain,stepDicts): - """ stolen from Chain class""" + def createHypoTools(self, chain, newstep): + """ set and create HypoTools on the stored step from input step configuration + MenuSeuqnece with same algorithms can have different HypoTool classes + which are stored in the input step + """ + if self.step.combo is None: return - log.debug("createHypoTools for Step %s", self.step.name) - log.debug('%s in new hypo tool creation method, step mult= %d', chain, sum(self.step.multiplicity)) - log.debug("N(seq)=%d, N(chainDicts)=%d", len(self.step.sequences), len(stepDicts)) - for seq, onePartChainDict in zip(self.step.sequences, stepDicts): + log.debug("createHypoTools for Step %s", newstep.name) + log.debug('%s in new hypo tool creation method, step mult= %d', chain, sum(newstep.multiplicity)) + log.debug("N(seq)=%d, N(chainDicts)=%d", len(newstep.sequences), len(newstep.stepDicts)) + assert(len(newstep.sequences)==len(newstep.stepDicts) ) + assert(len(self.step.sequences)==len(newstep.stepDicts) ) + + for seq, myseq, onePartChainDict in zip(newstep.sequences, self.step.sequences, newstep.stepDicts): log.debug(' seq: %s, onePartChainDict:', seq.name) log.debug(' %s', onePartChainDict) - seq.createHypoTools( onePartChainDict ) + hypoToolConf=seq.getHypoToolConf() + if hypoToolConf is not None: # avoid empty sequences + hypoToolConf.setConf( onePartChainDict ) + myseq.hypo.addHypoTool(hypoToolConf) #this creates the HypoTools + #myseq.createHypoTools( onePartChainDict ) chainDict = HLTMenuConfig.getChainDictFromChainName(chain) - self.combo.createComboHypoTools(chainDict, self.step.comboToolConfs) + self.combo.createComboHypoTools(chainDict, newstep.comboToolConfs) - def __repr__(self): diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFConfig.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFConfig.py index 00bca0fb6532..2a5d3b8f3f15 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFConfig.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFConfig.py @@ -378,7 +378,12 @@ def decisionTreeFromChains(flags, HLTNode, chains, allDicts, newJO): (finalDecisions, CFseq_list) = createDataFlow(chains, allDicts) #createControlFlowOld(flags, HLTNode, CFseq_list) - acc=createControlFlow(flags, HLTNode, CFseq_list) + acc = createControlFlow(flags, HLTNode, CFseq_list) + + # decode and attach HypoTools: + ##FPP + #for chain in chains: + # chain.createHypoTools() # create dot graphs log.debug("finalDecisions: %s", finalDecisions) @@ -483,8 +488,8 @@ def createDataFlow(chains, allDicts): else: log.debug("Combo not implemented if it's empty step") - # add HypoTools - lastCFseq.createHypoTools(chain.name,chainStep.stepDicts) + # add HypoTools to this step (cumulating all same steps) + lastCFseq.createHypoTools(chain.name,chainStep) if len(chain.steps) == nstep+1: log.debug("Adding finalDecisions for chain %s at step %d:", chain.name, nstep+1) @@ -505,7 +510,7 @@ def createControlFlow(flags, HLTNode, CFseqList): """ Creates Control Flow Tree starting from the CFSequences""" HLTNodeName= HLTNode.getName() - log.debug("createControlFlow on node %s",HLTNodeName) + log.debug("[createControlFlow] on node %s",HLTNodeName) acc = ComponentAccumulator() if isRun3Cfg(): acc.addSequence(HLTNode) @@ -516,7 +521,7 @@ def createControlFlow(flags, HLTNode, CFseqList): # filter node - log.debug("Create filter step %s with %d filters", stepSequenceName, len(CFseqList[nstep])) + log.debug("[createControlFlow] Create filter step %s with %d filters", stepSequenceName, len(CFseqList[nstep])) stepCFFilter = parOR(stepSequenceName + CFNaming.FILTER_POSTFIX) if isRun3Cfg(): acc.addSequence(stepCFFilter, parentName=HLTNodeName) @@ -527,7 +532,7 @@ def createControlFlow(flags, HLTNode, CFseqList): for cseq in CFseqList[nstep]: filterAlg = cseq.filter.Alg if filterAlg.getName() not in filter_list: - log.debug("createControlFlow: Add %s to filter node %s", filterAlg.getName(), stepSequenceName) + log.debug("[createControlFlow] Add %s to filter node %s", filterAlg.getName(), stepSequenceName) filter_list.append(filterAlg.getName()) if isRun3Cfg(): stepCFFilter.Members +=[filterAlg] @@ -536,7 +541,7 @@ def createControlFlow(flags, HLTNode, CFseqList): # reco step node - log.debug("Create reco step %s with %d sequences", stepSequenceName, len(CFseqList)) + log.debug("[createControlFlow] Create reco step %s with %d sequences", stepSequenceName, len(CFseqList)) stepCFReco = parOR(stepSequenceName + CFNaming.RECO_POSTFIX) if isRun3Cfg(): acc.addSequence(stepCFReco, parentName=HLTNodeName) diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/MenuComponents.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/MenuComponents.py index 70baf4cb2cfd..50e2c8665b8a 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/MenuComponents.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/MenuComponents.py @@ -23,6 +23,7 @@ from TrigCompositeUtils.TrigCompositeUtils import legName from AthenaCommon.Configurable import ConfigurableCABehavior from AthenaConfiguration.ComponentAccumulator import appendCAtoAthena, conf2toConfigurable from TriggerJobOpts.TriggerConfigFlags import ROBPrefetching +from AthenaConfiguration.ComponentFactory import isRun3Cfg from collections.abc import MutableSequence import collections.abc @@ -175,9 +176,12 @@ class HypoAlgNode(AlgNode): def addHypoTool (self, hypoToolConf): - log.debug("Adding HypoTool %s to %s", hypoToolConf.chainDict['chainName'], self.Alg.getName()) + log.debug("Adding HypoTool %s for chain %s to %s", hypoToolConf.name, hypoToolConf.chainDict['chainName'], self.Alg.getName()) try: self.Alg.HypoTools = self.Alg.HypoTools + [hypoToolConf.create()] # see ATEAM-773 + if isRun3Cfg(): + assert isinstance(self.Alg.HypoTools[-1], GaudiConfig2._configurables.Configurable), "The Hypo Tool for {} is not Configurable2".format(hypoToolConf.chainDict['chainName']) + except NoHypoToolCreated as e: log.debug("%s returned empty tool: %s", hypoToolConf.name, e) @@ -287,6 +291,7 @@ class ComboMaker(AlgNode): confs = [ HypoToolConf( tool ) for tool in comboToolConfs ] log.debug("ComboMaker.createComboHypoTools for chain %s, Alg %s with %d tools", chainDict["chainName"],self.Alg.getName(), len(comboToolConfs)) for conf in confs: + log.debug("ComboMaker.createComboHypoTools adding %s", conf) tools = self.Alg.ComboHypoTools self.Alg.ComboHypoTools = tools + [ conf.confAndCreate( chainDict ) ] @@ -333,7 +338,10 @@ class EmptyMenuSequence(object): self._maker.addInput(outfilter) def createHypoTools(self, chainDict): - log.debug("This sequence is empty. No Hypo to conficure") + log.debug("This sequence is empty. No Hypo to configure") + + def getHypoToolConf(self): + return None def addToSequencer(self, recoSeq_list, hypo_list): recoSeq_list.add(self.sequence.Alg) @@ -505,26 +513,8 @@ class MenuSequence(object): """ Connect filter to the InputMaker""" log.debug("connecting %s to inputs of %s", outfilter,compName(self._maker.Alg)) self._maker.addInput(outfilter) - - def connect(self, Hypo, HypoToolGen): - """ Sets the input and output of the hypo, and links to the input maker """ - input_maker_output= self._maker.readOutputList()[0] # only one since it's merged - - #### Add input/output Decision to Hypo - self.name = CFNaming.menuSequenceName(compName(Hypo)) - self.hypoToolConf = HypoToolConf( HypoToolGen ) - self._hypo = HypoAlgNode( Alg = Hypo ) - hypo_output = CFNaming.hypoAlgOutName(compName(Hypo)) - self._hypo.addOutput(hypo_output) - self._hypo.setPreviousDecision( input_maker_output) - - log.debug("MenuSequence.connect: connecting InputMaker and HypoAlg and OverlapRemoverAlg, adding: \n\ - InputMaker::%s.output=%s",\ - compName(self._maker.Alg), input_maker_output) - log.debug("HypoAlg::%s.previousDecision=%s, \n HypoAlg::%s.output=%s",\ - compName(self._hypo.Alg), input_maker_output, compName(self._hypo.Alg), self._hypo.readOutputList()[0]) - - + + def createHypoTools(self, chainDict): if type(self._hypoToolConf) is list: log.warning ("This sequence %s has %d multiple HypoTools ",self.sequence.name, len(self.hypoToolConf)) @@ -534,6 +524,9 @@ class MenuSequence(object): else: self._hypoToolConf.setConf( chainDict ) self._hypo.addHypoTool(self._hypoToolConf) #this creates the HypoTools + + def getHypoToolConf(self) : + return self._hypoToolConf def getHypoToolMap(self,chainDict) : self._hypoToolConf.setConf( chainDict ) -- GitLab From 398e07fc5aeafc01f91fadc21867fa946b69d96d Mon Sep 17 00:00:00 2001 From: Francesca Pastore <francesca.pastore@cern.ch> Date: Mon, 16 Jan 2023 15:21:55 +0100 Subject: [PATCH 10/15] finalized review by Tomasz --- .../HLT/Config/ControlFlow/HLTCFComponents.py | 15 +++++++-------- .../HLT/Config/ControlFlow/HLTCFConfig.py | 18 +++++++----------- .../python/HLT/Config/MenuComponents.py | 9 +++++---- 3 files changed, 19 insertions(+), 23 deletions(-) diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFComponents.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFComponents.py index f81ae9d59bf4..1350c48bccd3 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFComponents.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFComponents.py @@ -4,7 +4,7 @@ from TriggerMenuMT.HLT.Config.MenuComponents import AlgNode from TriggerMenuMT.HLT.Config.ControlFlow.MenuComponentsNaming import CFNaming from TriggerMenuMT.HLT.Config.Utility.HLTMenuConfig import HLTMenuConfig -from AthenaCommon.CFElements import compName +from AthenaCommon.CFElements import compName, findAlgorithmByPredicate from functools import lru_cache from AthenaCommon.Logging import logging @@ -62,7 +62,7 @@ class RoRSequenceFilterNode(SequenceFilterNode): return self.getPar("ChainsPerInput") -from GaudiKernel.DataHandle import DataHandle +#from GaudiKernel.DataHandle import DataHandle class PassFilterNode(SequenceFilterNode): """ PassFilter is a Filter node without inputs/outputs, so OutputProp=InputProp=empty""" def __init__(self, name): @@ -71,10 +71,10 @@ class PassFilterNode(SequenceFilterNode): SequenceFilterNode.__init__(self, Alg, '', '') def addOutput(self, name): - self.outputs.append(str(name)) # if isinstance(name, DataHandle) else name) + self.outputs.append(str(name)) def addInput(self, name): - self.inputs.append(str(name)) # if isinstance(name, DataHandle) else name) + self.inputs.append(str(name)) def getOutputList(self): return self.outputs @@ -164,8 +164,8 @@ class CFSequence(object): if self.step.combo is None: return - assert len(newstep.sequences)==len(self.step.sequences), "Trying to add HypoTools from new step %s, which differ in number of sequences"%newstep.name" - assert len(self.step.sequences)==len(newstep.stepDicts), "The number of sequences of step %s (%d) differ from the number of dictionaries in the chain (%d)",%(self.step.name, len(self.step.sequences), len(newstep.stepDicts)) + assert len(newstep.sequences)==len(self.step.sequences), f'Trying to add HypoTools from new step {newstep.name}, which differ in number of sequences' + assert len(self.step.sequences)==len(newstep.stepDicts), f'The number of sequences of step {self.step.name} ({len(self.step.sequences)}) differ from the number of dictionaries in the chain {len(newstep.stepDicts)}' log.debug("createHypoTools for Step %s", newstep.name) log.debug('from chain %s with step mult= %d', chain, sum(newstep.multiplicity)) @@ -228,10 +228,9 @@ class CFSequenceCA(CFSequence): self.ca.addEventAlgo(self.step.combo.Alg, sequenceName=seqAndWithFilter.getName()) -from AthenaCommon.CFElements import findAlgorithmByPredicate @lru_cache(None) def findComboHypoAlg(self): - return findAlgorithmByPredicate(self.seq, lambda alg: compName(alg) == self.step.Alg.getName() and isComboHypo(alg)) + return findAlgorithmByPredicate(self.seq, lambda alg: compName(alg) == self.step.Alg.getName() and isComboHypoAlg(alg)) def findComboHypoAlg2(self): log.debug(self.seq.Members) diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFConfig.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFConfig.py index 7e27c65bb671..41d7cbb67f7a 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFConfig.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFConfig.py @@ -32,7 +32,7 @@ from AthenaCommon.AlgSequence import AlgSequence, dumpSequence from AthenaCommon.Configurable import ConfigurableCABehavior from AthenaCommon.Logging import logging -from AthenaConfiguration.ComponentAccumulator import conf2toConfigurable, appendCAtoAthena, addEventAlgo +from AthenaConfiguration.ComponentAccumulator import conf2toConfigurable, appendCAtoAthena from HLTSeeding.HLTSeedingConfig import mapThresholdToL1DecisionCollection from TriggerJobOpts.TriggerConfig import collectHypos, collectFilters, collectViewMakers, collectDecisionObjects, \ @@ -510,8 +510,7 @@ def createControlFlow(flags, HLTNode, CFseqList): if isComponentAccumulatorCfg(): acc.addSequence(HLTNode) - for nstep, sequences in enumerate(CFseqList): - #for nstep in range(len(CFseqList)): + for nstep, sequences in enumerate(CFseqList): stepSequenceName = CFNaming.stepName(nstep) log.debug("\n******** Create CF Tree %s with AthSequencers", stepSequenceName) @@ -526,14 +525,13 @@ def createControlFlow(flags, HLTNode, CFseqList): filter_list=[] # add the filter to the node - for cseq in sequences: #CFseqList[nstep]: + for cseq in sequences: filterAlg = cseq.filter.Alg if filterAlg.getName() not in filter_list: log.debug("[createControlFlow] Add %s to filter node %s", filterAlg.getName(), stepSequenceName) filter_list.append(filterAlg.getName()) - if isComponentAccumulatorCfg(): - addEventAlgo([filterAlg],sequenceName=stepCFFilter.getName()) - #stepCFFilter.Members +=[filterAlg] + if isComponentAccumulatorCfg(): + stepCFFilter.Members +=[filterAlg] else: stepCFFilter +=filterAlg @@ -547,8 +545,7 @@ def createControlFlow(flags, HLTNode, CFseqList): HLTNode += stepCFReco # add the sequences to the reco node - for cseq in sequences: #CFseqList[nstep]: - #createCFTree=Filter+Reco+Combo + for cseq in sequences: log.debug(" *** Create CF Tree for CFSequence %s", cseq.step.name) if isComponentAccumulatorCfg(): acc.merge( cseq.ca, sequenceName=stepCFReco.getName()) @@ -581,8 +578,7 @@ def createControlFlow(flags, HLTNode, CFseqList): summary=makeSummary( stepSequenceName, stepDecisions ) if isComponentAccumulatorCfg(): - addEventAlgo([summary],sequenceName=HLTNode.getName()) - #HLTNode.Members += [summary] + acc.addEventAlgo([summary],sequenceName=HLTNode.getName()) else: HLTNode += summary diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/MenuComponents.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/MenuComponents.py index 9063af3ba70b..6b43721f90c3 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/MenuComponents.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/MenuComponents.py @@ -44,10 +44,10 @@ class Node(object): self.outputs=[] def addOutput(self, name): - self.outputs.append(str(name))# if isinstance(name, DataHandle) else name) + self.outputs.append(str(name)) def addInput(self, name): - self.inputs.append(str(name)) # if isinstance(name, DataHandle) else name) + self.inputs.append(str(name)) def getOutputList(self): return self.outputs @@ -377,8 +377,9 @@ class MenuSequence(object): #_Hypo = Hypo #_Maker = Maker #_Sequence = Sequence - log.info("MenuSequence in isComponentAccumulatorCfg: found a probe leg, don't know how to clone, do nothing") - return + self._name = CFNaming.menuSequenceName(compName(_Hypo)) + log.info("MenuSequence in isComponentAccumulatorCfg: found a probe leg, don't know how to clone, create empty sequence") + return else: _Hypo = RecoFragmentsPool.retrieve(MenuSequence.getProbeHypo,ConfigFlags,basehypo=Hypo) # Reset this so that HypoAlgNode.addOutput will actually do something -- GitLab From b680861208c14a9becc86e1c16e374cfd8fdef62 Mon Sep 17 00:00:00 2001 From: Francesca Pastore <francesca.pastore@cern.ch> Date: Tue, 17 Jan 2023 11:16:48 +0100 Subject: [PATCH 11/15] removed make warning and added CAMigration flag --- .../TriggerMenuMT/python/HLT/Config/MenuComponents.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/MenuComponents.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/MenuComponents.py index 6b43721f90c3..ef1e4046e862 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/MenuComponents.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/MenuComponents.py @@ -3,6 +3,7 @@ from TriggerMenuMT.HLT.Config.Utility.HLTMenuConfig import HLTMenuConfig from TriggerMenuMT.HLT.Config.ControlFlow.MenuComponentsNaming import CFNaming from TriggerMenuMT.HLT.Config.ControlFlow.HLTCFTools import (NoHypoToolCreated, + NoCAmigration, algColor, isHypoBase, isComboHypoAlg, @@ -377,9 +378,7 @@ class MenuSequence(object): #_Hypo = Hypo #_Maker = Maker #_Sequence = Sequence - self._name = CFNaming.menuSequenceName(compName(_Hypo)) - log.info("MenuSequence in isComponentAccumulatorCfg: found a probe leg, don't know how to clone, create empty sequence") - return + log.warning(str(NoCAmigration('[MenuSequence] found a probe leg, dont know how to clone, no sequence {0}_probe created for CA components'.format(compName(Hypo))) )) else: _Hypo = RecoFragmentsPool.retrieve(MenuSequence.getProbeHypo,ConfigFlags,basehypo=Hypo) # Reset this so that HypoAlgNode.addOutput will actually do something @@ -419,8 +418,7 @@ class MenuSequence(object): if isComponentAccumulatorCfg(): probeSeq = None #baseSeq #probeSeq.name= baseSeq.getName()+"_probe" - log.info("to be completed") - + log.warning(str(NoCAmigration('[MenuSequence] found a probe leg, dont know how to clone, no sequence {0}_probe created for CA components'.format(compName(Hypo))) )) else: # Add IM and sequence contents to duplicated sequence probeSeq = baseSeq.clone(baseSeq.getName()+"_probe") -- GitLab From fcc06f60126a40cea4f9f5083b0504adf5c45501 Mon Sep 17 00:00:00 2001 From: Francesca Pastore <francesca.pastore@cern.ch> Date: Tue, 17 Jan 2023 17:10:27 +0100 Subject: [PATCH 12/15] some aestethics due to L1 review --- .../HLT/Config/ControlFlow/HLTCFComponents.py | 59 ++++----------- .../HLT/Config/ControlFlow/HLTCFConfig.py | 74 +++++++++---------- .../python/HLT/Config/GenerateMenuMT_newJO.py | 5 -- .../python/HLT/Config/MenuComponents.py | 58 ++++++--------- 4 files changed, 71 insertions(+), 125 deletions(-) diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFComponents.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFComponents.py index 1350c48bccd3..045b576e0c11 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFComponents.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFComponents.py @@ -3,14 +3,16 @@ from TriggerMenuMT.HLT.Config.MenuComponents import AlgNode from TriggerMenuMT.HLT.Config.ControlFlow.MenuComponentsNaming import CFNaming from TriggerMenuMT.HLT.Config.Utility.HLTMenuConfig import HLTMenuConfig - -from AthenaCommon.CFElements import compName, findAlgorithmByPredicate +from TriggerMenuMT.HLT.Config.ControlFlow.HLTCFTools import isComboHypoAlg +from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator +from AthenaConfiguration.ComponentFactory import CompFactory +from AthenaCommon.CFElements import compName, findAlgorithmByPredicate, parOR, seqAND from functools import lru_cache from AthenaCommon.Logging import logging log = logging.getLogger( __name__ ) -from AthenaConfiguration.ComponentFactory import CompFactory + RoRSeqFilter = CompFactory.RoRSeqFilter PassFilter = CompFactory.PassFilter @@ -34,9 +36,7 @@ class SequenceFilterNode(AlgNode): class RoRSequenceFilterNode(SequenceFilterNode): def __init__(self, name): - Alg= RoRSeqFilter(name) - - + Alg= RoRSeqFilter(name) SequenceFilterNode.__init__(self, Alg, 'Input', 'Output') self.resetInput() self.resetOutput() ## why do we need this in CA mode?? @@ -62,7 +62,7 @@ class RoRSequenceFilterNode(SequenceFilterNode): return self.getPar("ChainsPerInput") -#from GaudiKernel.DataHandle import DataHandle + class PassFilterNode(SequenceFilterNode): """ PassFilter is a Filter node without inputs/outputs, so OutputProp=InputProp=empty""" def __init__(self, name): @@ -97,8 +97,7 @@ class CFSequence(object): self.step = ChainStep self.combo = ChainStep.combo #copy this instance self.connectCombo() - self.setDecisions() - + self.setDecisions() log.debug("CFSequence.__init: created %s ",self) def setDecisions(self): @@ -109,7 +108,6 @@ class CFSequence(object): self.decisions.extend(self.filter.getOutputList()) else: self.decisions.extend(self.combo.getOutputList()) - log.debug("CFSequence: set out decisions: %s", self.decisions) @@ -160,66 +158,48 @@ class CFSequence(object): def createHypoTools(self, chain, newstep): """ set and create HypoTools accumulated on the self.step from an input step configuration """ - if self.step.combo is None: return - assert len(newstep.sequences)==len(self.step.sequences), f'Trying to add HypoTools from new step {newstep.name}, which differ in number of sequences' - assert len(self.step.sequences)==len(newstep.stepDicts), f'The number of sequences of step {self.step.name} ({len(self.step.sequences)}) differ from the number of dictionaries in the chain {len(newstep.stepDicts)}' + assert len(newstep.sequences) == len(self.step.sequences), f'Trying to add HypoTools from new step {newstep.name}, which differ in number of sequences' + assert len(self.step.sequences) == len(newstep.stepDicts), f'The number of sequences of step {self.step.name} ({len(self.step.sequences)}) differ from the number of dictionaries in the chain {len(newstep.stepDicts)}' log.debug("createHypoTools for Step %s", newstep.name) log.debug('from chain %s with step mult= %d', chain, sum(newstep.multiplicity)) log.debug("N(seq)=%d, N(chainDicts)=%d", len(newstep.sequences), len(newstep.stepDicts)) - for seq, myseq, onePartChainDict in zip(newstep.sequences, self.step.sequences, newstep.stepDicts): log.debug(' seq: %s, onePartChainDict:', seq.name) log.debug(' %s', onePartChainDict) hypoToolConf=seq.getHypoToolConf() if hypoToolConf is not None: # avoid empty sequences hypoToolConf.setConf( onePartChainDict ) - myseq.hypo.addHypoTool(hypoToolConf) #this creates the HypoTools - - + myseq.hypo.addHypoTool(hypoToolConf) #this creates the HypoTools chainDict = HLTMenuConfig.getChainDictFromChainName(chain) self.combo.createComboHypoTools(chainDict, newstep.comboToolConfs) - - def __repr__(self): return "--- CFSequence ---\n + Filter: %s \n + decisions: %s\n + %s \n"%(\ compName(self.filter.Alg), self.decisions, self.step) -from AthenaCommon.CFElements import parOR, seqAND -from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator -from TriggerMenuMT.HLT.Config.ControlFlow.HLTCFTools import isComboHypoAlg -from AthenaCommon.CFElements import getSequenceChildren, isSequence class CFSequenceCA(CFSequence): """Class to describe the flow of decisions through ChainStep + filter with their connections (input, output) A Filter can have more than one input/output if used in different chains, so this class stores and manages all of them (when doing the connect) """ def __init__(self, ChainStep, FilterAlg): - log.debug(" *** Create CFSequence %s with Filter %s", ChainStep.name, FilterAlg.Alg.getName()) self.ca = ComponentAccumulator() self.empty= ChainStep.isEmpty #empty step: add the PassSequence, one instance only is appended to the tree - if self.empty: - seqAndWithFilter = FilterAlg.Alg - else: - seqAndWithFilter = seqAND(ChainStep.name) - - + seqAndWithFilter = FilterAlg.Alg if self.empty else seqAND(ChainStep.name) self.ca.addSequence(seqAndWithFilter) - self.seq=seqAndWithFilter - + self.seq = seqAndWithFilter if not self.empty: self.ca.addEventAlgo(FilterAlg.Alg, sequenceName=seqAndWithFilter.getName()) stepReco = parOR(ChainStep.name + CFNaming.RECO_POSTFIX) # all reco algorithms from all the sequences in a parallel sequence self.ca.addSequence(stepReco, parentName=seqAndWithFilter.getName()) log.info("created parOR %s inside seqAND %s ", stepReco.getName(), seqAndWithFilter.getName()) - for menuseq in ChainStep.sequences: self.ca.merge(menuseq.ca, sequenceName=stepReco.getName()) @@ -232,15 +212,4 @@ class CFSequenceCA(CFSequence): def findComboHypoAlg(self): return findAlgorithmByPredicate(self.seq, lambda alg: compName(alg) == self.step.Alg.getName() and isComboHypoAlg(alg)) - def findComboHypoAlg2(self): - log.debug(self.seq.Members) - for alg in getSequenceChildren(self.seq): - log.debug("found %s",alg.getName()) - if not isSequence(alg): - if compName(alg) == self.step.combo.Alg.getName(): - #RecursionError: maximum recursion depth exceeded in comparison - #for alg in findAllAlgorithms( self.seq , self.step.combo.Alg.name): - if isComboHypoAlg( alg ): - return alg - - return None + \ No newline at end of file diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFConfig.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFConfig.py index 41d7cbb67f7a..4ca59ab0d26b 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFConfig.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFConfig.py @@ -367,7 +367,7 @@ def decisionTreeFromChains(flags, HLTNode, chains, allDicts, newJO): """ Creates the decision tree, given the starting node and the chains containing the sequences """ log.info("[decisionTreeFromChains] Run decisionTreeFromChains on %s", HLTNode.getName()) - HLTNodeName= HLTNode.getName() + HLTNodeName = HLTNode.getName() if len(chains) == 0: log.info("[decisionTreeFromChains] Configuring empty decisionTree") acc = ComponentAccumulator() @@ -387,7 +387,7 @@ def decisionTreeFromChains(flags, HLTNode, chains, allDicts, newJO): all_DataFlow_to_dot(HLTNodeName, CFseq_list) if isComponentAccumulatorCfg(): - acc.printConfig(withDetails=True, summariseProps=True) + acc.printConfig(withDetails = True, summariseProps = True) # matrix display # uncomment for serious debugging @@ -400,7 +400,7 @@ def createDataFlow(chains, allDicts): """ Creates the filters and connect them to the menu sequences""" # find tot nsteps - chainWithMaxSteps = max(chains, key=lambda chain: len(chain.steps)) + chainWithMaxSteps = max(chains, key = lambda chain: len(chain.steps)) NSTEPS = len(chainWithMaxSteps.steps) log.info("[createDataFlow] creating DF for %d chains and total %d steps", len(chains), NSTEPS) @@ -431,44 +431,42 @@ def createDataFlow(chains, allDicts): log.debug("Set Filter input: %s while setting the chain: %s", filterInput, chain.name) # make one filter per step: - sequenceFilter= None + sequenceFilter = None filterName = CFNaming.filterName(chainStep.name) if chainStep.isEmpty: - filterOutput= filterInput + filterOutput = filterInput else: - filterOutput =[ CFNaming.filterOutName(filterName, inputName) for inputName in filterInput ] + filterOutput = [CFNaming.filterOutName(filterName, inputName) for inputName in filterInput ] foundCFSeq = [cfseq for cfseq in CFseqList[nstep] if filterName == cfseq.filter.Alg.getName()] log.debug("Found %d CF sequences with filter name %s", len(foundCFSeq), filterName) if not foundCFSeq: sequenceFilter = buildFilter(filterName, filterInput, chainStep.isEmpty) if isComponentAccumulatorCfg(): - CFseq = CFSequenceCA( ChainStep=chainStep, FilterAlg=sequenceFilter) + CFseq = CFSequenceCA( ChainStep = chainStep, FilterAlg = sequenceFilter) else: - CFseq = CFSequence( ChainStep=chainStep, FilterAlg=sequenceFilter) + CFseq = CFSequence( ChainStep = chainStep, FilterAlg = sequenceFilter) CFseq.connect(filterOutput) CFseqList[nstep].append(CFseq) - lastDecisions=CFseq.decisions - lastCFseq=CFseq + lastDecisions = CFseq.decisions + lastCFseq = CFseq else: if len(foundCFSeq) > 1: log.error("Found more than one sequence containing filter %s", filterName) - lastCFseq=foundCFSeq[0] - sequenceFilter=lastCFseq.filter + lastCFseq = foundCFSeq[0] + sequenceFilter = lastCFseq.filter if len(list(set(sequenceFilter.getInputList()).intersection(filterInput))) != len(list(set(filterInput))): [ sequenceFilter.addInput(inputName) for inputName in filterInput ] [ sequenceFilter.addOutput(outputName) for outputName in filterOutput ] lastCFseq.connect(filterOutput) - if chainStep.isEmpty: - lastDecisions=filterOutput - else: - lastDecisions=lastCFseq.decisions - + + lastDecisions = filterOutput if chainStep.isEmpty else lastCFseq.decisions + # add chains to the filter: chainLegs = chainStep.getChainLegs() if len(chainLegs) != len(filterInput): - log.error("[createDataFlow] lengths of chainlegs = %s differ from inputs=%s", str(chainLegs), str(filterInput)) + log.error("[createDataFlow] lengths of chainlegs = %s differ from inputs = %s", str(chainLegs), str(filterInput)) raise Exception("[createDataFlow] Cannot proceed, exiting.") for finput, leg in zip(filterInput, chainLegs): log.debug("Adding chain %s to input %s of %s", leg, finput,compName(sequenceFilter.Alg)) @@ -496,7 +494,6 @@ def createDataFlow(chains, allDicts): log.debug("\n Built CD for chain %s with %d steps: \n - %s ", chain.name,len(chain.steps),'\n - '.join(map(str, [{step.name:step.multiplicity} for step in chain.steps]))) #end of loop over chains - log.debug("End of createDataFlow for %d chains and total %d steps", len(chains), NSTEPS) return (finalDecisions, CFseqList) @@ -504,7 +501,7 @@ def createDataFlow(chains, allDicts): def createControlFlow(flags, HLTNode, CFseqList): """ Creates Control Flow Tree starting from the CFSequences""" - HLTNodeName= HLTNode.getName() + HLTNodeName = HLTNode.getName() log.debug("[createControlFlow] on node %s",HLTNodeName) acc = ComponentAccumulator() if isComponentAccumulatorCfg(): @@ -523,7 +520,7 @@ def createControlFlow(flags, HLTNode, CFseqList): else: HLTNode += stepCFFilter - filter_list=[] + filter_list = [] # add the filter to the node for cseq in sequences: filterAlg = cseq.filter.Alg @@ -531,16 +528,16 @@ def createControlFlow(flags, HLTNode, CFseqList): log.debug("[createControlFlow] Add %s to filter node %s", filterAlg.getName(), stepSequenceName) filter_list.append(filterAlg.getName()) if isComponentAccumulatorCfg(): - stepCFFilter.Members +=[filterAlg] + stepCFFilter.Members += [filterAlg] else: - stepCFFilter +=filterAlg + stepCFFilter += filterAlg # create reco step node log.debug("[createControlFlow] Create reco step %s with %d sequences", stepSequenceName, len(CFseqList)) stepCFReco = parOR(stepSequenceName + CFNaming.RECO_POSTFIX) if isComponentAccumulatorCfg(): - acc.addSequence(stepCFReco, parentName=HLTNodeName) + acc.addSequence(stepCFReco, parentName = HLTNodeName) else: HLTNode += stepCFReco @@ -548,23 +545,22 @@ def createControlFlow(flags, HLTNode, CFseqList): for cseq in sequences: log.debug(" *** Create CF Tree for CFSequence %s", cseq.step.name) if isComponentAccumulatorCfg(): - acc.merge( cseq.ca, sequenceName=stepCFReco.getName()) - + acc.merge( cseq.ca, sequenceName = stepCFReco.getName()) else: filterAlg = cseq.filter.Alg - if len(cseq.step.sequences)==0: + if len(cseq.step.sequences) == 0: stepCFReco += filterAlg else: seqAndWithFilter = seqAND(cseq.step.name) stepReco = parOR(cseq.step.name + CFNaming.RECO_POSTFIX) - seqAndWithFilter +=[filterAlg, stepReco] - recoSeqSet=set() - hypoSet=set() + seqAndWithFilter += [filterAlg, stepReco] + recoSeqSet = set() + hypoSet = set() for menuseq in cseq.step.sequences: - menuseq.addToSequencer(recoSeqSet,hypoSet) + menuseq.addToSequencer(recoSeqSet, hypoSet) - stepReco += sorted(list(recoSeqSet), key=lambda t: t.getName()) - seqAndWithFilter += sorted(list(hypoSet), key=lambda t: t.getName()) + stepReco += sorted(list(recoSeqSet), key = lambda t: t.getName()) + seqAndWithFilter += sorted(list(hypoSet), key = lambda t: t.getName()) if cseq.step.combo is not None: seqAndWithFilter += cseq.step.combo.Alg @@ -576,16 +572,16 @@ def createControlFlow(flags, HLTNode, CFseqList): for CFseq in CFseqList[nstep]: stepDecisions.extend(CFseq.decisions) - summary=makeSummary( stepSequenceName, stepDecisions ) + summary = makeSummary( stepSequenceName, stepDecisions ) if isComponentAccumulatorCfg(): - acc.addEventAlgo([summary],sequenceName=HLTNode.getName()) + acc.addEventAlgo([summary],sequenceName = HLTNode.getName()) else: HLTNode += summary if flags.Trigger.generateMenuDiagnostics: log.debug("Now Draw Menu Diagnostic dot graphs...") - stepCF_DataFlow_to_dot(stepCFReco.getName(), CFseqList[nstep]) - stepCF_ControlFlow_to_dot(stepCFReco) + stepCF_DataFlow_to_dot( stepCFReco.getName(), CFseqList[nstep] ) + stepCF_ControlFlow_to_dot( stepCFReco ) log.debug("************* End of step %d, %s", nstep+1, stepSequenceName) @@ -604,12 +600,12 @@ def buildFilter(filter_name, filter_input, empty): """ if empty: log.debug("Calling PassFilterNode %s", filter_name) - sfilter = PassFilterNode(name=filter_name) + sfilter = PassFilterNode(name = filter_name) for i in filter_input: sfilter.addInput(i) sfilter.addOutput(i) else: - sfilter = RoRSequenceFilterNode(name=filter_name) + sfilter = RoRSequenceFilterNode(name = filter_name) for i in filter_input: sfilter.addInput(i) sfilter.addOutput(CFNaming.filterOutName(filter_name, i)) diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/GenerateMenuMT_newJO.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/GenerateMenuMT_newJO.py index 90d8cbe6118f..934a98ff2256 100755 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/GenerateMenuMT_newJO.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/GenerateMenuMT_newJO.py @@ -2,9 +2,6 @@ import itertools from TriggerMenuMT.HLT.Config.Utility.DictFromChainName import dictFromChainName - -#from TriggerMenuMT.HLT.Config.ControlFlow.HLTCFConfig_newJO import generateDecisionTree -#from TriggerMenuMT.HLT.Config.ControlFlow.HLTCFConfig_CA import decisionTreeFromChains from TriggerMenuMT.HLT.Config.ControlFlow.HLTCFConfig import decisionTreeFromChains, sequenceScanner from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator @@ -195,7 +192,6 @@ def generateMenuMT(flags): log.debug("Filtering chains ") menu.setChainFilter(chainsToGenerate) finalListOfChainConfigs = menu.generateAllChainConfigs(flags) - log.info("Length of FinalListofChainConfigs %s", len(finalListOfChainConfigs)) # make sure that we didn't generate any steps that are fully empty in all chains @@ -203,7 +199,6 @@ def generateMenuMT(flags): finalListOfChainConfigs = menu.resolveEmptySteps(finalListOfChainConfigs) log.info("finalListOfChainConfig %s", finalListOfChainConfigs) - log.info("Making the HLT configuration tree") menuAcc=makeHLTTree(flags) diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/MenuComponents.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/MenuComponents.py index ef1e4046e862..56969136cff0 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/MenuComponents.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/MenuComponents.py @@ -60,13 +60,12 @@ class Node(object): return "Node::%s [%s] -> [%s]"%(self.Alg.getName(), ' '.join(map(str, self.getInputList())), ' '.join(map(str, self.getOutputList()))) - class AlgNode(Node): """Node class that connects inputs and outputs to basic alg. properties """ def __init__(self, Alg, inputProp, outputProp): Node.__init__(self, Alg) - self.outputProp=outputProp - self.inputProp=inputProp + self.outputProp = outputProp + self.inputProp = inputProp def addDefaultOutput(self): if self.outputProp != '': @@ -139,18 +138,15 @@ class HypoToolConf(object): self.hypoToolGen = hypoToolGen self.name=hypoToolGen.__name__ - def setConf( self, chainDict): if type(chainDict) is not dict: raise RuntimeError("Configuring hypo with %s, not good anymore, use chainDict" % str(chainDict) ) self.chainDict = chainDict - def create(self): """creates instance of the hypo tool""" return self.hypoToolGen( self.chainDict ) - def confAndCreate(self, chainDict): """sets the configuration and creates instance of the hypo tool""" self.setConf(chainDict) @@ -215,8 +211,8 @@ class InputMakerNode(AlgNode): class ComboMaker(AlgNode): def __init__(self, name, comboHypoCfg): - self.prop1="MultiplicitiesMap" - self.prop2="LegToInputCollectionMap" + self.prop1 = "MultiplicitiesMap" + self.prop2 = "LegToInputCollectionMap" self.comboHypoCfg = comboHypoCfg Alg = self.create( name ) log.debug("ComboMaker init: Alg %s", name) @@ -270,8 +266,8 @@ class ComboMaker(AlgNode): log.error("ERROR in configuration: ComboAlg %s has already been configured for chain %s", compName(self.Alg), chainName) raise Exception("[createDataFlow] Error in ComboMaker.addChain. Cannot proceed.") else: - cval1[chainName]=chainMult - cval2[chainName]=legsToInputCollections + cval1[chainName] = chainMult + cval2[chainName] = legsToInputCollections else: cval1 = {chainName : chainMult} cval2 = {chainName : legsToInputCollections} @@ -315,7 +311,7 @@ class EmptyMenuSequence(object): Maker.isEmptyStep = True Maker.RoIsLink = 'initialRoI' #(this is the default property, just making it explicit) self._maker = InputMakerNode( Alg = Maker ) - self._seed='' + self._seed = '' self._sequence = Node( Alg = seqAND(the_name, [Maker])) log.debug("Made EmptySequence %s",the_name) @@ -350,10 +346,8 @@ class EmptyMenuSequence(object): def buildDFDot(self, cfseq_algs, all_hypos, last_step_hypo_nodes, file): cfseq_algs.append(self._maker) cfseq_algs.append(self.sequence ) - file.write(" %s[fillcolor=%s]\n"%(self._maker.Alg.getName(), algColor(self._maker.Alg))) file.write(" %s[fillcolor=%s]\n"%(self.sequence.Alg.getName(), algColor(self.sequence.Alg))) - return cfseq_algs, all_hypos, last_step_hypo_nodes def setSeed( self, seed ): @@ -536,21 +530,16 @@ class MenuSequence(object): recoSeq_list.add(self.sequence.Alg) hypo_list.add(self._hypo.Alg) - def buildDFDot(self, cfseq_algs, all_hypos, last_step_hypo_nodes, file): cfseq_algs.append(self._maker) cfseq_algs.append(self.sequence ) - file.write(" %s[fillcolor=%s]\n"%(self._maker.Alg.getName(), algColor(self._maker.Alg))) - file.write(" %s[fillcolor=%s]\n"%(self.sequence.Alg.getName(), algColor(self.sequence.Alg))) - + file.write(" %s[fillcolor=%s]\n"%(self.sequence.Alg.getName(), algColor(self.sequence.Alg))) cfseq_algs.append(self._hypo) file.write(" %s[color=%s]\n"%(self._hypo.Alg.getName(), algColor(self._hypo.Alg))) all_hypos.append(self._hypo) - return cfseq_algs, all_hypos, last_step_hypo_nodes - def setSeed( self, seed ): self._seed = seed @@ -615,11 +604,11 @@ class Chain(object): Construct the Chain from the steps Out of all arguments the ChainSteps & L1Thresholds are most relevant, the chain name is used in debug messages """ - self.name = name - self.steps=ChainSteps + self.name = name + self.steps = ChainSteps self.nSteps = nSteps self.alignmentGroups = alignmentGroups - self.vseeds=L1Thresholds + self.vseeds = L1Thresholds # The chain holds a map of topo ComboHypoTool configurators # This is needed to allow placement of the ComboHypoTool in the right position @@ -770,11 +759,11 @@ class Chain(object): # next: can we remove multiplicity array, if it can be retrieved from the ChainDict? 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], chainDicts=[], comboHypoCfg=ComboHypoCfg, comboToolConfs=[], isEmpty = False, createsGhostLegs = False): + def __init__(self, name, Sequences = [], multiplicity = [1], chainDicts = [], comboHypoCfg = ComboHypoCfg, comboToolConfs = [], isEmpty = False, createsGhostLegs = False): # TODO: remove parameter multiplicity, since this must be extracted from the ChainDict ATR-23928 # include cases of empty steps with multiplicity = [] or multiplicity=[0,0,0///] - if sum(multiplicity)==0: - multiplicity=[] + if sum(multiplicity) == 0: + multiplicity = [] else: log.debug("chain %s, step %s: len=%d multiplicty=%d", chainDicts[0]['chainName'], name, len(chainDicts), len(multiplicity)) # sanity check on inputs, excluding empty steps @@ -789,9 +778,9 @@ class ChainStep(object): log.error("[ChainStep] multiplicities: %s",multiplicity) 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 - self.onlyJets = False + self.name = name + self.sequences = Sequences + self.onlyJets = False sig_set = None if len(chainDicts) > 0 and 'signature' in chainDicts[0]: leg_signatures = [step['signature'] for step in chainDicts if step['signature'] != 'Bjet'] @@ -805,10 +794,10 @@ class ChainStep(object): self.onlyJets = True self.multiplicity = multiplicity - self.comboHypoCfg=comboHypoCfg + self.comboHypoCfg = comboHypoCfg self.comboToolConfs = list(comboToolConfs) self.stepDicts = chainDicts # one dict per leg - self.isEmpty=(sum(multiplicity)==0 or isEmpty) + self.isEmpty = (sum(multiplicity) == 0 or isEmpty) if not self.isEmpty: #self.relabelLegIdsForJets() self.setChainPartIndices() @@ -893,7 +882,7 @@ class ChainStep(object): self.comboToolConfs.append(tool) def makeCombo(self): - self.combo=None + self.combo = None if self.isEmpty or self.comboHypoCfg is None: return comboName = CFNaming.comboHypoName(self.name) @@ -908,7 +897,6 @@ class ChainStep(object): self.combo.createComboHypoTools(chainDict, self.comboToolConfs) def getChainLegs(self): - """ This is extrapolating the chain legs from the step dictionaries""" legs = [part['chainName'] for part in self.stepDicts] return legs @@ -1078,10 +1066,8 @@ class SelectionCA(ComponentAccumulator): # mainline/rec-ex-common and CA based JO compatibility layer (basically converters) def algorithmCAToGlobalWrapper(gen, flags, *args, **kwargs): - """Merges CA with athena for all components except the algorithms. Those are converted to Run2 objects and returned. - - If CA contains more than one algorithm, a list is returned, else a single algorithm is returned. - + """ Merges CA with athena for all components except the algorithms. Those are converted to Run2 objects and returned. + If CA contains more than one algorithm, a list is returned, else a single algorithm is returned. """ with ConfigurableCABehavior(): ca = gen(flags, *args, **kwargs) -- GitLab From 451bf2bc2ce4d86d9de40442a9ece8577b5f37ad Mon Sep 17 00:00:00 2001 From: Francesca Pastore <francesca.pastore@cern.ch> Date: Wed, 18 Jan 2023 15:56:20 +0100 Subject: [PATCH 13/15] fixes from Jason comments --- .../python/HLT/Config/ControlFlow/HLTCFConfig_newJO.py | 1 - .../TriggerCommon/TriggerMenuMT/scripts/test_menu_CA.py | 8 +------- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFConfig_newJO.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFConfig_newJO.py index 325d4d0640d1..ea7b1efed897 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFConfig_newJO.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFConfig_newJO.py @@ -424,7 +424,6 @@ def generateDecisionTree(flags, HLTMenuConfig): needCombo = False for sequenceCounter, sequence in enumerate(step.sequences): - #log.debug("Sequence %d: IM=%s, Hypo=%s", sequenceCounter, sequence.ca.inputMaker().name, sequence.ca.hypo().name) if not isinstance(sequence, EmptyMenuSequence): # not an empty sequence connectIMAndHypo(sequence.ca.inputMaker(), sequence.ca.hypo()) # setup basic CF acc.merge( sequence.ca, sequenceName=comboRecoSeq.name) diff --git a/Trigger/TriggerCommon/TriggerMenuMT/scripts/test_menu_CA.py b/Trigger/TriggerCommon/TriggerMenuMT/scripts/test_menu_CA.py index f83fb7a713be..f806cb1334a4 100755 --- a/Trigger/TriggerCommon/TriggerMenuMT/scripts/test_menu_CA.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/scripts/test_menu_CA.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -# Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration """ test of Dev menu with CA migrated menu code, reproducing runHLT_standalone_newJO @@ -14,8 +14,6 @@ from AthenaCommon.Configurable import Configurable Configurable.configurableRun3Behavior = 1 - - # select chains, as in runHLT_standalone ConfigFlags.addFlag("Trigger.enabledSignatures",[]) ConfigFlags.addFlag("Trigger.disabledSignatures",[]) @@ -42,10 +40,6 @@ acc.merge(L1ConfigSvcCfg(ConfigFlags)) from TriggerMenuMT.HLT.Config.GenerateMenuMT_newJO import generateMenuMT menu = generateMenuMT( ConfigFlags) acc.merge(menu) - -#from TriggerJobOpts.TriggerConfig import triggerRunCfg -#menu = triggerRunCfg(flags, menu=generateHLTMenu) - acc.printConfig() AccumulatorDecorator.printStats() -- GitLab From 0581dc0e3d4e162ce8b8b3be13cf2b7b2843d157 Mon Sep 17 00:00:00 2001 From: Francesca Pastore <francesca.pastore@cern.ch> Date: Fri, 20 Jan 2023 15:23:41 +0100 Subject: [PATCH 14/15] fix TriggerSummaryAlg --- .../TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFConfig.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFConfig.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFConfig.py index 4ca59ab0d26b..19f3463cbae3 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFConfig.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFConfig.py @@ -34,6 +34,7 @@ from AthenaCommon.Logging import logging from AthenaConfiguration.ComponentAccumulator import conf2toConfigurable, appendCAtoAthena +from DecisionHandling.DecisionHandlingConfig import TriggerSummaryAlg from HLTSeeding.HLTSeedingConfig import mapThresholdToL1DecisionCollection from TriggerJobOpts.TriggerConfig import collectHypos, collectFilters, collectViewMakers, collectDecisionObjects, \ triggerMonitoringCfg, triggerSummaryCfg, triggerMergeViewsAndAddMissingEDMCfg, collectHypoDecisionObjects @@ -53,7 +54,7 @@ log = logging.getLogger( __name__ ) def makeSummary(name, flatDecisions): """ Returns a TriggerSummaryAlg connected to given decisions""" - summary = CompFactory.TriggerSummaryAlg( CFNaming.stepSummaryName(name) ) + summary = TriggerSummaryAlg( CFNaming.stepSummaryName(name) ) summary.InputDecision = "HLTSeedingSummary" summary.FinalDecisions = list(OrderedDict.fromkeys(flatDecisions)) return summary -- GitLab From 4c28cbbd5d4a8d229dbc96a16b9b4129cc8b4dd6 Mon Sep 17 00:00:00 2001 From: Francesca Pastore <francesca.pastore@cern.ch> Date: Fri, 20 Jan 2023 15:42:46 +0100 Subject: [PATCH 15/15] leftover from merging --- .../TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFConfig.py | 3 +-- .../python/HLT/Config/Utility/ComboHypoHandling.py | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFConfig.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFConfig.py index 85787cf8d2de..17b89515d2d8 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFConfig.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/ControlFlow/HLTCFConfig.py @@ -40,7 +40,6 @@ from TriggerJobOpts.TriggerConfig import collectHypos, collectFilters, collectVi triggerMonitoringCfg, triggerSummaryCfg, triggerMergeViewsAndAddMissingEDMCfg, collectHypoDecisionObjects from TrigNavSlimmingMT.TrigNavSlimmingMTConfig import getTrigNavSlimmingMTOnlineConfig from ViewAlgs.ViewAlgsConf import EventViewCreatorAlgorithm -from AthenaConfiguration.ComponentFactory import CompFactory from AthenaConfiguration.ComponentFactory import isComponentAccumulatorCfg from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator @@ -573,7 +572,7 @@ def createControlFlow(flags, HLTNode, CFseqList): for CFseq in CFseqList[nstep]: stepDecisions.extend(CFseq.decisions) - summary = makeSummary( stepSequenceName, stepDecisions ) + summary = makeSummary( flags, stepSequenceName, stepDecisions ) if isComponentAccumulatorCfg(): acc.addEventAlgo([summary],sequenceName = HLTNode.getName()) else: diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/Utility/ComboHypoHandling.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/Utility/ComboHypoHandling.py index 728dfd79c982..d7ec6fec6eed 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/Utility/ComboHypoHandling.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Config/Utility/ComboHypoHandling.py @@ -54,7 +54,6 @@ from TriggerMenuMT.HLT.MinBias.MinBiasChainConfiguration import TrigAFPDijetComb from TriggerMenuMT.HLT.Muon.MuonChainConfiguration import TrigMuonEFIdtpInvMassHypoToolCfg def TrigComboHypoToolFromDict(chainDict): - # from TrigHypoCommonTools.TrigHypoCommonToolsConf import TrigComboHypoTool from AthenaMonitoringKernel.GenericMonitoringTool import GenericMonitoringTool chainName = chainDict['chainName'] -- GitLab