Skip to content
Snippets Groups Projects
Commit d07d0705 authored by Vakhtang Tsulaia's avatar Vakhtang Tsulaia
Browse files

Merge branch 'TM-ATR21609' into 'master'

ATR-21609, adapting merging to allow for empty steps in parallel merging

See merge request !39439
parents fb5e4287 81b7defe
No related branches found
No related tags found
6 merge requests!58791DataQualityConfigurations: Modify L1Calo config for web display,!46784MuonCondInterface: Enable thread-safety checking.,!46776Updated LArMonitoring config file for WD to match new files produced using MT,!45405updated ART test cron job,!42417Draft: DIRE and VINCIA Base Fragments for Pythia 8.3,!39439ATR-21609, adapting merging to allow for empty steps in parallel merging
...@@ -6,6 +6,7 @@ log = logging.getLogger( __name__ ) ...@@ -6,6 +6,7 @@ log = logging.getLogger( __name__ )
from TriggerMenuMT.HLTMenuConfig.Menu.MenuComponents import Chain, ChainStep, EmptyMenuSequence, RecoFragmentsPool from TriggerMenuMT.HLTMenuConfig.Menu.MenuComponents import Chain, ChainStep, EmptyMenuSequence, RecoFragmentsPool
from TriggerMenuMT.HLTMenuConfig.Menu.MenuAlignmentTools import get_alignment_group_ordering as getAlignmentGroupOrdering from TriggerMenuMT.HLTMenuConfig.Menu.MenuAlignmentTools import get_alignment_group_ordering as getAlignmentGroupOrdering
from DecisionHandling.DecisionHandlingConfig import ComboHypoCfg
from collections import OrderedDict from collections import OrderedDict
from copy import deepcopy from copy import deepcopy
import re import re
...@@ -314,6 +315,15 @@ def mergeSerial(chainDefList): ...@@ -314,6 +315,15 @@ def mergeSerial(chainDefList):
return combinedChainDef return combinedChainDef
def checkStepContent(parallel_steps):
for step in parallel_steps:
if step is None:
continue
for seq in step.sequences:
if type(seq).__name__ != 'EmptyMenuSequence':
return True
return False
def makeCombinedStep(parallel_steps, stepNumber, chainDefList, allSteps = [], currentChainSteps = []): def makeCombinedStep(parallel_steps, stepNumber, chainDefList, allSteps = [], currentChainSteps = []):
from TrigCompositeUtils.TrigCompositeUtils import legName from TrigCompositeUtils.TrigCompositeUtils import legName
...@@ -329,17 +339,61 @@ def makeCombinedStep(parallel_steps, stepNumber, chainDefList, allSteps = [], cu ...@@ -329,17 +339,61 @@ def makeCombinedStep(parallel_steps, stepNumber, chainDefList, allSteps = [], cu
assert len(chainDefList)==len(parallel_steps), "[makeCombinedStep] makeCombinedStep: Length of chain defs %d does not match length of steps to merge %d" % (len(chainDefList), len(allSteps)) assert len(chainDefList)==len(parallel_steps), "[makeCombinedStep] makeCombinedStep: Length of chain defs %d does not match length of steps to merge %d" % (len(chainDefList), len(allSteps))
leg_counter = 0 leg_counter = 0
currentStepName = ''
# if *all* the steps we're trying to merge are either empty sequences or empty steps
# we need to create a single empty step instead.
hasNonEmptyStep = checkStepContent(parallel_steps)
if not hasNonEmptyStep:
for chain_index, step in enumerate(parallel_steps):
# every step is empty but some might have empty sequences and some might not
if len(step.sequences) == 0:
new_stepDict = deepcopy(chainDefList[chain_index].steps[-1].stepDicts[-1])
currentStepName = 'Empty' + chainDefList[chain_index].alignmentGroups[0]+'Align'+str(stepNumber)+'_'+new_stepDict['chainParts'][0]['multiplicity']+new_stepDict['signature']
# we need a chain dict here, use the one corresponding to this leg of the chain
oldLegName = new_stepDict['chainName']
if re.search('^leg[0-9]{3}_',oldLegName):
oldLegName = oldLegName[7:]
new_stepDict['chainName'] = legName(oldLegName,leg_counter)
stepDicts.append(new_stepDict)
leg_counter += 1
else:
# Standard step with empty sequence(s)
currentStepName = step.name
#remove redundant instances of StepN_ and merged_ (happens when merging already merged chains)
if re.search('^Step[0-9]_',currentStepName):
currentStepName = currentStepName[6:]
if re.search('^merged_',currentStepName):
currentStepName = currentStepName[7:]
# update the chain dict list for the combined step with the chain dict from this step
log.debug('[makeCombinedStep] adding step dictionaries %s',step.stepDicts)
for new_stepDict in deepcopy(step.stepDicts):
oldLegName = new_stepDict['chainName']
if re.search('^leg[0-9]{3}_',oldLegName):
oldLegName = oldLegName[7:]
new_stepDict['chainName'] = legName(oldLegName,leg_counter)
log.debug("[makeCombinedStep] stepDict naming old: %s, new: %s", oldLegName, new_stepDict['chainName'])
stepDicts.append(new_stepDict)
leg_counter += 1
stepName += '_' + currentStepName
theChainStep = ChainStep(stepName, Sequences=[], multiplicity=[], chainDicts=stepDicts, comboHypoCfg=ComboHypoCfg)
log.info("[makeCombinedStep] Merged empty step: \n %s", theChainStep)
return theChainStep
for chain_index, step in enumerate(parallel_steps): #this is a horizontal merge! for chain_index, step in enumerate(parallel_steps): #this is a horizontal merge!
if step is None:
if step is None or (hasNonEmptyStep and len(step.sequences) == 0):
# this happens for merging chains with different numbers of steps, we need to "pad" out with empty sequences to propogate the decisions # this happens for merging chains with different numbers of steps, we need to "pad" out with empty sequences to propogate the decisions
# all other chain parts' steps should contain an empty sequence # all other chain parts' steps should contain an empty sequence
new_stepDict = deepcopy(chainDefList[chain_index].steps[-1].stepDicts[-1]) new_stepDict = deepcopy(chainDefList[chain_index].steps[-1].stepDicts[-1])
seqName = getEmptySeqName(new_stepDict['signature'], chain_index, stepNumber, chainDefList[0].alignmentGroups[0]) seqName = getEmptySeqName(new_stepDict['signature'], chain_index, stepNumber, chainDefList[0].alignmentGroups[0])
currentStepName = ''
if isFullScanRoI(chainDefList[chain_index].L1decisions[0]): if isFullScanRoI(chainDefList[chain_index].L1decisions[0]):
if noPrecedingStepsPostMerge(currentChainSteps, chain_index): if noPrecedingStepsPostMerge(currentChainSteps, chain_index):
stepSeq.append(RecoFragmentsPool.retrieve(getEmptyMenuSequence, flags=None, name=seqName+"FS", mergeUsingFeature = False)) stepSeq.append(RecoFragmentsPool.retrieve(getEmptyMenuSequence, flags=None, name=seqName+"FS", mergeUsingFeature = False))
...@@ -403,7 +457,7 @@ def makeCombinedStep(parallel_steps, stepNumber, chainDefList, allSteps = [], cu ...@@ -403,7 +457,7 @@ def makeCombinedStep(parallel_steps, stepNumber, chainDefList, allSteps = [], cu
stepName += '_' + currentStepName stepName += '_' + currentStepName
log.debug('[makeCombinedStep] current step name %s',stepName) log.debug('[makeCombinedStep] current step name %s',stepName)
# for merged steps, we need to update the name to add the leg name # for merged steps, we need to update the name to add the leg name
comboHypoTools = list(set(comboHypoTools)) comboHypoTools = list(set(comboHypoTools))
theChainStep = ChainStep(stepName, Sequences=stepSeq, multiplicity=stepMult, chainDicts=stepDicts, comboHypoCfg=comboHypo, comboToolConfs=comboHypoTools) theChainStep = ChainStep(stepName, Sequences=stepSeq, multiplicity=stepMult, chainDicts=stepDicts, comboHypoCfg=comboHypo, comboToolConfs=comboHypoTools)
log.info("[makeCombinedStep] Merged step: \n %s", theChainStep) log.info("[makeCombinedStep] Merged step: \n %s", theChainStep)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment