From 735b719a7cab209776632eaa9c9b6bf009e26b39 Mon Sep 17 00:00:00 2001 From: Mark Andrew Owen <mark.andrew.owen@cern.ch> Date: Tue, 12 May 2020 08:29:07 +0000 Subject: [PATCH] Changes to get parallel merging with chains that have sub-chains with different numbers of steps. Details of changes: - ChainMerging: makeChainSteps function now creates empty sequences when the input step is None. Also removed some commented code. - MenuComponents: check for consistent number of sequences and chain dicts per step when creating hypos. - LS2_v1: Add 3 emu chains. Two are primaries, the etcut1step chain is there to test merged chains with different numbers of steps. --- .../share/ref_RDOtoRDOTrig_mt1_build.ref | 12 +++ .../share/ref_data_v1Dev_build.ref | 12 +++ .../python/HLTMenuConfig/Egamma/PhotonDef.py | 3 - .../python/HLTMenuConfig/Menu/ChainMerging.py | 90 +++++++++++-------- .../python/HLTMenuConfig/Menu/LS2_v1.py | 12 ++- .../HLTMenuConfig/Menu/MenuComponents.py | 4 +- 6 files changed, 88 insertions(+), 45 deletions(-) diff --git a/Trigger/TrigValidation/TrigAnalysisTest/share/ref_RDOtoRDOTrig_mt1_build.ref b/Trigger/TrigValidation/TrigAnalysisTest/share/ref_RDOtoRDOTrig_mt1_build.ref index 7e6abdd7617..cd7e2cf9add 100644 --- a/Trigger/TrigValidation/TrigAnalysisTest/share/ref_RDOtoRDOTrig_mt1_build.ref +++ b/Trigger/TrigValidation/TrigAnalysisTest/share/ref_RDOtoRDOTrig_mt1_build.ref @@ -70,6 +70,9 @@ TrigSignatureMoniMT INFO -- #2512605388 Features TrigSignatureMoniMT INFO HLT_e140_lhloose_nod0_L1EM24VHI #2532156734 TrigSignatureMoniMT INFO -- #2532156734 Events 6 6 0 0 0 0 - - 0 TrigSignatureMoniMT INFO -- #2532156734 Features 0 0 0 0 - - +TrigSignatureMoniMT INFO HLT_e17_lhloose_mu14_L1EM15VH_MU10 #899946230 +TrigSignatureMoniMT INFO -- #899946230 Events 3 3 3 2 2 2 - - 2 +TrigSignatureMoniMT INFO -- #899946230 Features 3 46 4 2 - - TrigSignatureMoniMT INFO HLT_e26_etcut_L1EM22VHI #1703681121 TrigSignatureMoniMT INFO -- #1703681121 Events 6 6 6 6 6 - - - 6 TrigSignatureMoniMT INFO -- #1703681121 Features 7 134 7 - - - @@ -82,6 +85,9 @@ TrigSignatureMoniMT INFO -- #4227411116 Features TrigSignatureMoniMT INFO HLT_e300_etcut_L1EM24VHI #3481091923 TrigSignatureMoniMT INFO -- #3481091923 Events 6 6 0 0 0 - - - 0 TrigSignatureMoniMT INFO -- #3481091923 Features 0 0 0 - - - +TrigSignatureMoniMT INFO HLT_e3_etcut1step_mu26_L1EM8I_MU10 #2209076666 +TrigSignatureMoniMT INFO -- #2209076666 Events 5 5 5 2 2 2 - - 2 +TrigSignatureMoniMT INFO -- #2209076666 Features 5 2 2 2 - - TrigSignatureMoniMT INFO HLT_e3_etcut1step_mu6fast_L1EM8I_MU10 #2086577378 TrigSignatureMoniMT INFO -- #2086577378 Events 5 5 5 - - - - - 5 TrigSignatureMoniMT INFO -- #2086577378 Features 5 - - - - - @@ -109,6 +115,9 @@ TrigSignatureMoniMT INFO -- #756001976 Features TrigSignatureMoniMT INFO HLT_e7_etcut_L1EM3 #1959043579 TrigSignatureMoniMT INFO -- #1959043579 Events 20 20 20 20 20 - - - 20 TrigSignatureMoniMT INFO -- #1959043579 Features 89 1136 112 - - - +TrigSignatureMoniMT INFO HLT_e7_lhmedium_mu24_L1MU20 #2970063918 +TrigSignatureMoniMT INFO -- #2970063918 Events 8 8 7 5 5 1 - - 1 +TrigSignatureMoniMT INFO -- #2970063918 Features 9 72 14 1 - - TrigSignatureMoniMT INFO HLT_g140_etcut_L1EM24VHI #1045486446 TrigSignatureMoniMT INFO -- #1045486446 Events 6 6 0 0 0 - - - 0 TrigSignatureMoniMT INFO -- #1045486446 Features 0 0 0 - - - @@ -118,6 +127,9 @@ TrigSignatureMoniMT INFO -- #3534544568 Features TrigSignatureMoniMT INFO HLT_g20_etcut_LArPEB_L1EM15 #2706532790 TrigSignatureMoniMT INFO -- #2706532790 Events 14 14 14 14 12 12 - - 12 TrigSignatureMoniMT INFO -- #2706532790 Features 24 24 22 20 - - +TrigSignatureMoniMT INFO HLT_g25_medium_mu24_ivarmedium_L1MU20 #1007052793 +TrigSignatureMoniMT INFO -- #1007052793 Events 8 8 2 1 1 1 0 - 0 +TrigSignatureMoniMT INFO -- #1007052793 Features 2 1 3 1 0 - TrigSignatureMoniMT INFO HLT_g35_medium_g25_medium_L12EM20VH #1158879722 TrigSignatureMoniMT INFO -- #1158879722 Events 2 2 0 0 0 0 - - 0 TrigSignatureMoniMT INFO -- #1158879722 Features 0 0 0 0 - - diff --git a/Trigger/TrigValidation/TriggerTest/share/ref_data_v1Dev_build.ref b/Trigger/TrigValidation/TriggerTest/share/ref_data_v1Dev_build.ref index 6827578b85e..754c074b4ce 100644 --- a/Trigger/TrigValidation/TriggerTest/share/ref_data_v1Dev_build.ref +++ b/Trigger/TrigValidation/TriggerTest/share/ref_data_v1Dev_build.ref @@ -78,6 +78,9 @@ TrigSignatureMoniMT INFO -- #2512605388 Features TrigSignatureMoniMT INFO HLT_e140_lhloose_nod0_L1EM24VHI #2532156734 TrigSignatureMoniMT INFO -- #2532156734 Events 20 20 0 0 0 0 - - 0 TrigSignatureMoniMT INFO -- #2532156734 Features 0 0 0 0 - - +TrigSignatureMoniMT INFO HLT_e17_lhloose_mu14_L1EM15VH_MU10 #899946230 +TrigSignatureMoniMT INFO -- #899946230 Events 20 20 0 0 0 0 - - 0 +TrigSignatureMoniMT INFO -- #899946230 Features 0 0 0 0 - - TrigSignatureMoniMT INFO HLT_e26_etcut_L1EM22VHI #1703681121 TrigSignatureMoniMT INFO -- #1703681121 Events 20 20 1 1 0 - - - 0 TrigSignatureMoniMT INFO -- #1703681121 Features 1 3 0 - - - @@ -90,6 +93,9 @@ TrigSignatureMoniMT INFO -- #4227411116 Features TrigSignatureMoniMT INFO HLT_e300_etcut_L1EM24VHI #3481091923 TrigSignatureMoniMT INFO -- #3481091923 Events 20 20 0 0 0 - - - 0 TrigSignatureMoniMT INFO -- #3481091923 Features 0 0 0 - - - +TrigSignatureMoniMT INFO HLT_e3_etcut1step_mu26_L1EM8I_MU10 #2209076666 +TrigSignatureMoniMT INFO -- #2209076666 Events 20 20 0 0 0 0 - - 0 +TrigSignatureMoniMT INFO -- #2209076666 Features 0 0 0 0 - - TrigSignatureMoniMT INFO HLT_e3_etcut1step_mu6fast_L1EM8I_MU10 #2086577378 TrigSignatureMoniMT INFO -- #2086577378 Events 20 20 0 - - - - - 0 TrigSignatureMoniMT INFO -- #2086577378 Features 0 - - - - - @@ -117,6 +123,9 @@ TrigSignatureMoniMT INFO -- #756001976 Features TrigSignatureMoniMT INFO HLT_e7_etcut_L1EM3 #1959043579 TrigSignatureMoniMT INFO -- #1959043579 Events 20 20 13 13 11 - - - 11 TrigSignatureMoniMT INFO -- #1959043579 Features 26 90 20 - - - +TrigSignatureMoniMT INFO HLT_e7_lhmedium_mu24_L1MU20 #2970063918 +TrigSignatureMoniMT INFO -- #2970063918 Events 20 20 0 0 0 0 - - 0 +TrigSignatureMoniMT INFO -- #2970063918 Features 0 0 0 0 - - TrigSignatureMoniMT INFO HLT_g140_etcut_L1EM24VHI #1045486446 TrigSignatureMoniMT INFO -- #1045486446 Events 20 20 0 0 0 - - - 0 TrigSignatureMoniMT INFO -- #1045486446 Features 0 0 0 - - - @@ -126,6 +135,9 @@ TrigSignatureMoniMT INFO -- #3534544568 Features TrigSignatureMoniMT INFO HLT_g20_etcut_LArPEB_L1EM15 #2706532790 TrigSignatureMoniMT INFO -- #2706532790 Events 20 20 4 4 3 3 - - 3 TrigSignatureMoniMT INFO -- #2706532790 Features 5 5 4 4 - - +TrigSignatureMoniMT INFO HLT_g25_medium_mu24_ivarmedium_L1MU20 #1007052793 +TrigSignatureMoniMT INFO -- #1007052793 Events 20 20 0 0 0 0 0 - 0 +TrigSignatureMoniMT INFO -- #1007052793 Features 0 0 0 0 0 - TrigSignatureMoniMT INFO HLT_g35_medium_g25_medium_L12EM20VH #1158879722 TrigSignatureMoniMT INFO -- #1158879722 Events 20 20 0 0 0 0 - - 0 TrigSignatureMoniMT INFO -- #1158879722 Features 0 0 0 0 - - diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Egamma/PhotonDef.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Egamma/PhotonDef.py index f488412f316..3924b8bbb3f 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Egamma/PhotonDef.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Egamma/PhotonDef.py @@ -97,6 +97,3 @@ class PhotonChainConfiguration(ChainConfigurationBase): def getPrecisionPhoton(self): stepName = "PhotonPrecision" return self.getStep(4,stepName,[ precisionPhotonSequenceCfg]) - - - diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/ChainMerging.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/ChainMerging.py index 6bc773918f9..13976b6f52a 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/ChainMerging.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/ChainMerging.py @@ -50,30 +50,32 @@ def mergeParallel(chainDefList, offset): from itertools import zip_longest else: from itertools import izip_longest as zip_longest + # Use zip_longest so that we get None in case one chain has more steps than the other orderedSteps = list(zip_longest(*allSteps)) myOrderedSteps = deepcopy(orderedSteps) combChainSteps =[] - for step_index, steps in enumerate(myOrderedSteps): + log.debug("len(myOrderedSteps): %d", len(myOrderedSteps)) + for step_index, steps in enumerate(myOrderedSteps): mySteps = list(steps) - combStep = makeChainSteps(mySteps, step_index+1) + log.debug("step_index %d", step_index) + log.debug(mySteps) + combStep = makeChainSteps(mySteps, step_index+1, chainDefList) combChainSteps.append(combStep) - - # check if all chain parts have the same number of steps - sameNSteps = all(x==nSteps[0] for x in nSteps) - if sameNSteps is True: - log.debug("All chain parts have the same number of steps") - else: - log.debug("Have to deal with uneven number of chain steps, there might be none's appearing in sequence list => to be fixed") combinedChainDef = Chain(chainName, ChainSteps=combChainSteps, L1Thresholds=l1Thresholds) log.info("Parallel merged chain %s with these steps:", chainName) for step in combinedChainDef.steps: - log.debug(' %s', step) + log.info(' %s', step) return combinedChainDef +def getEmptySeqName(stepName, chain_index, step_number): + seqName = stepName + '_leg' + str(chain_index) + '_EmptySeqStep' + str(step_number) + #seqName = 'EmptySeq' + str(step_number) + return seqName + def serial_zip(allSteps, chainName): n_chains = len(allSteps) newsteps = [] @@ -90,7 +92,7 @@ def serial_zip(allSteps, chainName): # all other steps should contain an empty sequence for step_index2, emptyStep in enumerate(stepList): if emptyStep is None: - seqName = str(step.name) + '_leg' + str(chain_index) + '_EmptySeqStep' + str(step_index+1) + seqName = getEmptySeqName(step.name, chain_index, step_index+1) emptySeq = EmptyMenuSequence(seqName) stepList[step_index2] = ChainStep( seqName, Sequences=[emptySeq], chainDicts=step.chainDicts) @@ -124,7 +126,7 @@ def mergeSerial(chainDefList): combChainSteps =[] for step_index, steps in enumerate(mySerialSteps): mySteps = list(steps) - combStep = makeChainSteps(mySteps, step_index+1) + combStep = makeChainSteps(mySteps, step_index+1, chainDefList) combChainSteps.append(combStep) # check if all chain parts have the same number of steps @@ -143,7 +145,7 @@ def mergeSerial(chainDefList): return combinedChainDef -def makeChainSteps(steps, stepNumber): +def makeChainSteps(steps, stepNumber, chainDefList): from copy import deepcopy from TrigCompositeUtils.TrigCompositeUtils import legName stepName = 'merged_Step' + str(stepNumber) @@ -151,36 +153,46 @@ def makeChainSteps(steps, stepNumber): stepMult = [] log.verbose(" steps %s ", steps) stepDicts = [] - count = 0 comboHypoTools = [] - for step in steps: + # this function only makes sense if we are merging steps corresponding to the chains in the chainDefList + assert len(chainDefList)==len(steps), "makeChainSteps: Length of chain defs %d does not match length of steps to merge %d" % (len(chainDefList), len(steps)) + + for chain_index, step in enumerate(steps): if step is None: - continue - log.info(" step %s, multiplicity = %s", step.name, str(step.multiplicity)) - if len(step.sequences): - log.info(" with sequences = %s", ' '.join(map(str, [seq.name for seq in step.sequences]))) - - # this function only works if the input chains are single-object chains (one menu seuqnce) - if len(step.sequences) > 1: - log.error("More than one menu sequence found in combined chain!!") - - - currentStep = step.name - - # the step naming for combined chains needs to be revisted!! - stepName += '_' + currentStep - if len(step.sequences): - seq = step.sequences[0] - stepSeq.append(seq) - # set the multiplicity of all the legs - stepMult.append(sum(step.multiplicity)) - comboHypoTools.extend(step.comboToolConfs) - # update the chain dict list for the combined step with the chain dict from this step - stepDicts += deepcopy(step.chainDicts) + # this happens for merging chains with different numbers of steps, we need to "pad" out with empty sequences to propogate the decisions + seqName = getEmptySeqName(stepName, chain_index, stepNumber) + log.info(" creating empty sequence %s", seqName) + emptySeq = EmptyMenuSequence(seqName) + stepSeq.append(emptySeq) + stepMult.append(1) + # we need a chain dict here, use the one corresponding to this leg of the chain + stepDicts.append(deepcopy(chainDefList[chain_index].steps[-1].chainDicts[-1])) + else: + # Standard step, append it to the combined step + log.info(" step %s, multiplicity = %s", step.name, str(step.multiplicity)) + if len(step.sequences): + log.info(" with sequences = %s", ' '.join(map(str, [seq.name for seq in step.sequences]))) + + # this function only works if the input chains are single-object chains (one menu seuqnce) + if len(step.sequences) > 1: + log.error("More than one menu sequence found in combined chain!!") + + + currentStep = step.name + + # the step naming for combined chains needs to be revisted!! + stepName += '_' + currentStep + if len(step.sequences): + seq = step.sequences[0] + stepSeq.append(seq) + # set the multiplicity of all the legs + stepMult.append(sum(step.multiplicity)) + comboHypoTools.extend(step.comboToolConfs) + # update the chain dict list for the combined step with the chain dict from this step + stepDicts += deepcopy(step.chainDicts) # for merged steps, we need to update the name to add the leg name - stepDicts[-1]['chainName'] = legName(stepDicts[-1]['chainName'], count) - count = count + 1 + stepDicts[-1]['chainName'] = legName(stepDicts[-1]['chainName'], chain_index) comboHypoTools = list(set(comboHypoTools)) theChainStep = ChainStep(stepName, Sequences=stepSeq, multiplicity=stepMult, chainDicts=stepDicts, comboToolConfs=comboHypoTools) diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/LS2_v1.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/LS2_v1.py index 62bdac3838a..f06d0a0b9a9 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/LS2_v1.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/LS2_v1.py @@ -37,7 +37,6 @@ def setupMenu(): ChainProp(name='HLT_mu24_idperf_L1MU20', groups=SingleMuonGroup), ChainProp(name='HLT_mu6_mu6noL1_L1MU6', l1SeedThresholds=['MU6','FSNOSEED'], mergingStrategy='serial', groups=MultiMuonGroup), - #ATR-20049 ChainProp(name='HLT_mu6fast_L1MU6', groups=SingleMuonGroup), ChainProp(name='HLT_mu6Comb_L1MU6', groups=SingleMuonGroup), @@ -47,7 +46,7 @@ def setupMenu(): ChainProp(name='HLT_mu6_ivarmedium_L1MU6', groups=SingleMuonGroup), # commented because it is conflict with dimuon noL1 serial chain - # ChainProp(name='HLT_mu6noL1_L1MU6', l1SeedThresholds=['FSNOSEED'], groups=SingleMuonGroup), + # ChainProp(name='HLT_mu6noL1_L1MU6', l1SeedThresholds=['FSNOSEED'], groups=SingleMuonGroup), ChainProp(name='HLT_mu6_msonly_L1MU6', groups=SingleMuonGroup), @@ -212,6 +211,15 @@ def setupMenu(): # ChainProp(name='HLT_2mu4_bDimu_L12MU4', groups=BphysicsGroup), ] TriggerFlags.CombinedSlice.signatures = TriggerFlags.CombinedSlice.signatures() + [ + # groups need to be properly assigned here later + + # Test chain that is using parallel merging with different number of steps + ChainProp(name='HLT_e3_etcut1step_mu26_L1EM8I_MU10', l1SeedThresholds=['EM8I', 'MU10'], stream=[PhysicsStream], groups=MultiElectronGroup), + # Primary e-mu chains + ChainProp(name='HLT_e17_lhloose_mu14_L1EM15VH_MU10', l1SeedThresholds=['EM15VH','MU10'], stream=[PhysicsStream], groups=MultiElectronGroup), + ChainProp(name='HLT_e7_lhmedium_mu24_L1MU20',l1SeedThresholds=['EM3','MU20'], stream=[PhysicsStream], groups=MultiElectronGroup), + # Test photon-muon chain (isolation is there to have different number of steps) + ChainProp(name='HLT_g25_medium_mu24_ivarmedium_L1MU20',l1SeedThresholds=['EM15VH','MU20'], stream=[PhysicsStream], groups=MultiElectronGroup), ] TriggerFlags.HeavyIonSlice.signatures = TriggerFlags.HeavyIonSlice.signatures() + [] TriggerFlags.BeamspotSlice.signatures = TriggerFlags.BeamspotSlice.signatures() + [] diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/MenuComponents.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/MenuComponents.py index d9a556085df..e052d7f34e4 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/MenuComponents.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/MenuComponents.py @@ -718,8 +718,10 @@ class Chain(object): if len(step.chainDicts) > 0: # new way to configure hypo tools, works if the chain dictionaries have been attached to the steps log.info('%s in new hypo tool creation method, step mult= %d, isCombo=%d', self.name, sum(step.multiplicity), step.isCombo) + log.info("N(seq)=%d, N(chainDicts)=%d", len(step.sequences), len(step.chainDicts)) + assert len(step.sequences)==len(step.chainDicts), "createHypoTools only makes sense if number of sequences == number of chain dicts" for seq, onePartChainDict in zip(step.sequences, step.chainDicts): - log.info(' onePartChainDict:') + log.info(' seq: %s, onePartChainDict:', seq.name) log.info(' ' + str(onePartChainDict)) seq.createHypoTools( onePartChainDict ) -- GitLab