3 from TriggerMenuMT.HLT.Config.Utility.MenuAlignmentTools
import get_alignment_group_ordering
as getAlignmentGroupOrdering
4 from TriggerMenuMT.HLT.Config.MenuComponents
import Chain, ChainStep, EmptyMenuSequenceCfg, isEmptySequenceCfg
6 from AthenaCommon.Logging
import logging
7 from DecisionHandling.DecisionHandlingConfig
import ComboHypoCfg
8 from TrigCompositeUtils.TrigCompositeUtils
import legName
10 from copy
import deepcopy
13 log = logging.getLogger( __name__ )
15 def mergeChainDefs(listOfChainDefs, chainDict, perSig_lengthOfChainConfigs = None):
19 strategy = chainDict[
"mergingStrategy"]
20 offset = chainDict[
"mergingOffset"]
21 log.debug(
"[mergeChainDefs] %s: Combine by using %s merging", chainDict[
'chainName'], strategy)
25 if 'Bjet' in chainDict[
'signatures']
and 'Jet' in chainDict[
'signatures']:
26 leg_numbering = [it
for it,s
in enumerate(chainDict[
'signatures'])]
28 if strategy==
"parallel":
30 elif strategy==
"serial":
33 elif strategy==
"auto":
34 ordering = getAlignmentGroupOrdering()
36 for ich,cConfig
in enumerate(listOfChainDefs):
37 chain_ag = cConfig.alignmentGroups[0]
38 if chain_ag
not in ordering:
39 log.error(
"[mergeChainDefs] Alignment group %s can't be auto-merged because it's not in the grouping list!",chain_ag)
40 if chain_ag
in merging_dict:
41 merging_dict[chain_ag] += [ich]
43 merging_dict[chain_ag] = [ich]
46 tmp_merged_ordering = []
47 for ag
in merging_dict:
48 if len(merging_dict[ag]) > 1:
49 log.debug(
"[mergeChainDefs] parallel merging")
50 new_chain_defs, perSig_lengthOfChainConfigs =
mergeParallel(
list( listOfChainDefs[i]
for i
in merging_dict[ag] ), offset, leg_numbering, perSig_lengthOfChainConfigs)
51 tmp_merged += [new_chain_defs]
52 tmp_merged_ordering += [ordering.index(ag)]
54 log.debug(
"[mergeChainDefs] don't need to parallel merge")
55 tmp_merged += [listOfChainDefs[merging_dict[ag][0]]]
56 tmp_merged_ordering += [ordering.index(ag)]
59 merged_ordering = [-1]*len(tmp_merged_ordering)
60 copy_ordering = tmp_merged_ordering.copy()
62 while len(copy_ordering) > 0:
63 min_index = tmp_merged_ordering.index(
min(copy_ordering))
64 copy_ordering.pop(copy_ordering.index(
min(copy_ordering)))
65 merged_ordering[min_index] = tmp_val
69 if len(tmp_merged) == 1:
70 if perSig_lengthOfChainConfigs
is None:
71 log.debug(
"[mergeChainDefs] tmp merged has length 1, returning 0th element")
74 log.debug(
"[mergeChainDefs] tmp merged has length 1, returning 0th element and perSig list")
75 return tmp_merged[0], perSig_lengthOfChainConfigs
77 if perSig_lengthOfChainConfigs
is None:
78 log.debug(
"[mergeChainDefs] serial merging first")
81 log.debug(
"[mergeChainDefs] returning mergeSerial result and perSig_lengthOfChainConfigs %s",perSig_lengthOfChainConfigs)
82 return mergeSerial(tmp_merged, merged_ordering), perSig_lengthOfChainConfigs
85 log.error(
"[mergeChainDefs] Merging failed for %s. Merging strategy '%s' not known.", (listOfChainDefs, strategy))
91 if not perSig_lengthOfChainConfigs:
94 for leg_lengths, leg_grps
in perSig_lengthOfChainConfigs:
95 for grp, length
in zip(leg_grps,leg_lengths):
96 if grp
in leg_length_dict:
97 leg_length_dict[grp] += [length]
99 leg_length_dict[grp] = [length]
100 found_mismatch =
False
103 log.debug(
"[check_leg_lengths] leg lengths: %s",leg_length_dict)
104 for grp,lengths
in leg_length_dict.items():
105 if len(
set(lengths)) > 1:
106 log.debug(
"[check_leg_lengths] found mismatch for %s given %s", grp, lengths)
108 log.error(
"[check_leg_lengths] Second mismatch in the same chain! I don't know how to deal with this, please resolve. Chain leg lengths: %s",perSig_lengthOfChainConfigs)
109 log.error(
"[check_leg_lengths] Second mismatch in the same chain! lengths,grp: %s,%s",lengths, grp)
110 raise Exception(
"[are_lengths_mismatched] Cannot merge chain, exiting.")
111 found_mismatch =
True
112 max_length =
max(lengths)
115 return mismatched_ag, max_length
118 def mergeParallel(chainDefList, offset, leg_numbering = [], perSig_lengthOfChainConfigs = None):
121 log.error(
"[mergeParallel] Offset for parallel merging not implemented.")
122 raise Exception(
"[mergeParallel] Cannot merge this chain, exiting.")
130 vertical_alignment_groups = []
132 for iConfig, cConfig
in enumerate(chainDefList):
134 chainName = cConfig.name
135 elif chainName != cConfig.name:
136 log.error(
"[mergeParallel] Something is wrong with the combined chain name: cConfig.name = %s while chainName = %s", cConfig.name, chainName)
137 raise Exception(
"[mergeParallel] Cannot merge this chain, exiting.")
139 if len(
set(cConfig.alignmentGroups)) == 1:
140 alignmentGroups.append(cConfig.alignmentGroups[0])
141 elif len(cConfig.alignmentGroups) > 1:
142 log.debug(
"[mergeParallel] Parallel merging an already merged chain with different alignment groups? This is odd! %s",cConfig.alignmentGroups)
143 log.debug(
"...let's look at the config: %s", perSig_lengthOfChainConfigs)
147 align_grp_to_lengthen, max_length =
check_leg_lengths(perSig_lengthOfChainConfigs)
149 current_leg_ag_length = -1
150 index_modified_leg = -1
151 leg_lengths, leg_ags = perSig_lengthOfChainConfigs[iConfig]
152 for ileg, (length, ag)
in enumerate(zip(leg_lengths, leg_ags)):
153 if ag == align_grp_to_lengthen:
154 current_leg_ag_length = length
155 index_modified_leg = ileg
156 log.debug(
"[mergeParallel] ileg %s, length %s, ag %s: ",ileg, length, ag)
161 n_new_steps = max_length - current_leg_ag_length
163 previous_step_dicts = cConfig.steps[current_leg_ag_length-1].stepDicts
164 for i
in range(1,n_new_steps+1):
168 for ileg,stepDict
in enumerate(previous_step_dicts):
169 is_fs_string =
'FS' if isFullScanRoI(cConfig.L1decisions[ileg])
else ''
170 sigNames += [stepDict[
'chainParts'][0][
'signature'] + is_fs_string]
172 seqMultName =
'_'.
join([sigName
for sigName
in sigNames])
173 seqStepName =
'Empty' + align_grp_to_lengthen +
'Align' +
str(current_leg_ag_length+i) +
'_' + seqMultName
174 seqNames = [
getEmptySeqName(previous_step_dicts[iSeq][
'signature'], current_leg_ag_length+i, align_grp_to_lengthen)
for iSeq
in range(len(sigNames))]
176 emptySequences =
build_empty_sequences(previous_step_dicts, step_mult,
'mergeParallel', cConfig.L1decisions, seqNames, chainName)
178 cConfig.steps.insert(current_leg_ag_length + i - 1,
179 ChainStep( seqStepName, Sequences=emptySequences,
180 multiplicity = step_mult, chainDicts=previous_step_dicts,
186 perSig_lengthOfChainConfigs[iConfig][0][index_modified_leg] = max_length
188 log.debug(
"[mergeParallel] Alignment groups are empty for this combined chain")
190 allSteps.append(cConfig.steps)
191 allStepsMult.append(len(cConfig.steps[0].multiplicity))
192 nSteps.append(len(cConfig.steps))
193 l1Decisions.extend(cConfig.L1decisions)
198 if perSig_lengthOfChainConfigs
is not None and len(perSig_lengthOfChainConfigs) > 0:
199 in_chain_ag_lengths = {}
200 ag_ordering = getAlignmentGroupOrdering()
201 for ag
in ag_ordering:
202 for ag_lengths,sig_ags
in perSig_lengthOfChainConfigs:
203 for ag_length, sig_ag
in zip(ag_lengths, sig_ags):
204 if (sig_ag
in in_chain_ag_lengths
and in_chain_ag_lengths[sig_ag] < ag_length)
or sig_ag
not in in_chain_ag_lengths:
205 in_chain_ag_lengths[sig_ag] = ag_length
206 for ag, ag_length
in in_chain_ag_lengths.items():
207 vertical_alignment_groups += [ag]*ag_length
210 vertical_alignment_groups = [alignmentGroups[0]]*len(orderedSteps)
213 log.debug(
"[mergeParallel] alignment groups horizontal: %s", alignmentGroups)
214 log.debug(
"[mergeParallel] alignment groups vertical: %s", vertical_alignment_groups)
217 log.debug(
"[mergeParallel] len(orderedSteps): %d", len(orderedSteps))
218 for chain_index
in range(len(chainDefList)):
219 log.debug(
'[mergeParallel] Chain object to merge (i.e. chainDef) %s', chainDefList[chain_index])
221 for step_index, (steps, step_ag)
in enumerate(zip(orderedSteps,vertical_alignment_groups)):
222 mySteps =
list(steps)
223 log.debug(
"[mergeParallel] Merging step counter %d", step_index+1)
225 combStep =
makeCombinedStep(mySteps, step_index+1, chainDefList, orderedSteps, combChainSteps, leg_numbering, step_ag)
226 combChainSteps.append(combStep)
228 combinedChainDef = Chain(chainName, ChainSteps=combChainSteps, L1decisions=l1Decisions,
229 nSteps = nSteps, alignmentGroups = alignmentGroups)
231 log.debug(
"[mergeParallel] Parallel merged chain %s with these steps:", chainName)
232 for step
in combinedChainDef.steps:
233 log.debug(
'\n %s', step)
235 return combinedChainDef, perSig_lengthOfChainConfigs
240 if re.search(
'^Step[0-9]_',stepName):
241 stepName = stepName[6:]
242 elif re.search(
'^Step[0-9]{2}_', stepName):
243 stepName = stepName[7:]
245 seqName =
'Empty'+ alignGroup +
'Seq'+
str(step_number)+
'_'+ stepName
251 fsRoIList = [
'HLTNav_L1FSNOSEED',
'HLTNav_L1MET',
'HLTNav_L1J']
252 if inputL1Nav
in fsRoIList:
260 for iseq,seq
in enumerate(chainStep.sequenceFunctions):
268 if len(
set(cp[
'alignmentGroup']
for cp
in chainStep.stepDicts[iseq][
'chainParts'])) > 1:
269 log.error(
"[getCurrentAG] The leg has more than one chainPart (%s). Either the alignmentGroup property is bad or this is an unimplemented situation.",chainStep.stepDicts[iseq][
'chainParts'])
270 raise Exception(
"[getCurrentAG] Not sure what is happening here, but I don't know what to do.")
271 filled_seq_ag += [chainStep.stepDicts[iseq][
'chainParts'][0][
'alignmentGroup']]
273 if len(filled_seq_ag) == 0:
274 log.error(
"[getCurrentAG] No non-empty sequences were found in %s", chainStep.sequenceFunctions)
275 log.error(
"[getCurrentAG] The chainstep is %s", chainStep)
276 raise Exception(
"[getCurrentAG] Cannot find the current alignment group for this chain")
277 elif len(
set(filled_seq_ag)) > 1:
278 log.error(
"[getCurrentAG] Found more than one alignment group for this step %s", filled_seq_ag)
279 raise Exception(
"[getCurrentAG] Cannot find the current alignment group for this chain")
281 return filled_seq_ag[0]
283 def serial_zip(allSteps, chainName, chainDefList, legOrdering):
289 legs_per_part = [len(chainDefList[stepPlacement].steps[0].multiplicity)
for stepPlacement
in legOrdering]
290 n_parts = len(allSteps)
291 log.debug(
'[serial_zip] configuring chain with %d parts with multiplicities %s', n_parts, legs_per_part)
292 log.debug(
'[serial_zip] and leg ordering %s', legOrdering)
299 for chain_index, (chainSteps, stepPlacement)
in enumerate(zip(allSteps, legOrdering)):
301 for step_index, step
in enumerate(chainSteps):
303 prev_ag_step_index = step_index
305 log.debug(
'[serial_zip] chain_index: %s step_index: %s, alignment group: %s', chain_index, step_index, previousAG)
307 stepList = [
None]*n_parts
310 stepList[stepPlacement] = step
311 log.debug(
'[serial_zip] Put step: %s', step.name)
314 for chain_index2, (nLegs, stepPlacement2)
in enumerate(zip(legs_per_part, legOrdering)):
315 emptyStep = stepList[stepPlacement2]
316 if emptyStep
is None:
317 if chain_index2 == chain_index:
318 log.error(
"chain_index2 = chain_index, but the stepList still has none!")
319 raise Exception(
"[serial_zip] duplicating existing leg, why has this happened??")
324 if chain_index2 < chain_index:
325 emptyChainDicts = allSteps[chain_index2][-1].stepDicts
327 emptyChainDicts = allSteps[chain_index2][0].stepDicts
329 log.debug(
"[serial_zip] nLegs: %s, len(emptyChainDicts): %s, len(L1decisions): %s", nLegs, len(emptyChainDicts), len(chainDefList[stepPlacement2].L1decisions))
331 for ileg,(emptyChainDict,_)
in enumerate(zip(emptyChainDicts,chainDefList[stepPlacement2].L1decisions)):
332 if isFullScanRoI(chainDefList[stepPlacement2].L1decisions[ileg]):
333 sigNames +=[emptyChainDict[
'chainParts'][0][
'signature']+
'FS']
335 sigNames +=[emptyChainDict[
'chainParts'][0][
'signature']]
337 seqMultName =
'_'.
join([sigName
for sigName
in sigNames])
341 if len(
set(chainDefList[stepPlacement].alignmentGroups)) == 1:
342 currentAG = chainDefList[stepPlacement].alignmentGroups[0]
343 ag_step_index = step_index+1
347 if currentAG == previousAG:
348 ag_step_index = prev_ag_step_index + 1
349 prev_ag_step_index = ag_step_index
352 previousAG = currentAG
353 prev_ag_step_index = 1
355 seqStepName =
'Empty' + currentAG +
'Align'+
str(ag_step_index)+
'_'+seqMultName
357 seqNames = [
getEmptySeqName(emptyChainDicts[iSeq][
'signature'], ag_step_index, currentAG)
for iSeq
in range(nLegs)]
359 log.verbose(
"[serial_zip] step name for this leg: %s", seqStepName)
360 log.verbose(
"[serial_zip] created empty sequence(s): %s", seqNames)
361 log.verbose(
"[serial_zip] L1decisions %s ", chainDefList[stepPlacement2].L1decisions)
363 emptySequences =
build_empty_sequences(emptyChainDicts, step_mult,
'serial_zip', chainDefList[stepPlacement2].L1decisions, seqNames, chainName)
365 stepList[stepPlacement2] = ChainStep( seqStepName, Sequences=emptySequences,
366 multiplicity = step_mult, chainDicts=emptyChainDicts,
369 newsteps.append(stepList)
370 log.debug(
'After serial_zip')
372 log.debug(
', '.
join(map(str, [step.name
for step
in s]) ) )
383 log.debug(
'[mergeSerial] Merge chainDefList:')
384 log.debug(chainDefList)
385 log.debug(
'[mergeSerial] wth ordering %s:',chainDefListOrdering)
387 for ic,cOrder
in enumerate(chainDefListOrdering):
390 cConfig = chainDefList[chainDefListOrdering.index(ic)]
391 leg_order = chainDefListOrdering.index(ic)
394 chainName = cConfig.name
395 elif chainName != cConfig.name:
396 log.error(
"[mergeSerial] Something is wrong with the combined chain name: cConfig.name = %s while chainName = %s", cConfig.name, chainName)
397 raise Exception(
"[mergeSerial] Cannot merge this chain, exiting.")
400 allSteps.append(cConfig.steps)
401 legOrdering.append(leg_order)
402 nSteps.extend(cConfig.nSteps)
403 l1Decisions.extend(chainDefList[ic].L1decisions)
404 alignmentGroups.extend(cConfig.alignmentGroups)
406 serialSteps =
serial_zip(allSteps, chainName, chainDefList, legOrdering)
408 for chain_index
in range(len(chainDefList)):
409 log.debug(
'[mergeSerial] Chain object to merge (i.e. chainDef) %s', chainDefList[chain_index])
410 for step_index, steps
in enumerate(serialSteps):
411 mySteps =
list(steps)
413 combChainSteps.append(combStep)
415 combinedChainDef = Chain(chainName, ChainSteps=combChainSteps, L1decisions=l1Decisions,
416 nSteps = nSteps, alignmentGroups = alignmentGroups)
418 log.debug(
"[mergeSerial] Serial merged chain %s with number of steps/leg %s with these steps:", chainName, combinedChainDef.nSteps)
419 for step
in combinedChainDef.steps:
420 log.debug(
' %s', step)
422 return combinedChainDef
426 return True if any step contains a real Sequence
428 for step
in parallel_steps:
429 if step
is None or step.isEmpty:
431 for seq
in step.sequenceFunctions:
436 def makeCombinedStep(parallel_steps, stepNumber, chainDefList, allSteps = [], currentChainSteps = [], leg_numbering = [], alignment_group = ""):
440 log.verbose(
"[makeCombinedStep] steps %s ", parallel_steps)
451 if not hasNonEmptyStep:
453 if len(parallel_steps)>=len(chainDefList)
and all(step
is None for step
in parallel_steps[len(chainDefList):]):
457 parallel_steps=parallel_steps[:len(chainDefList)]
458 log.debug(
"[makeCombinedStep] removing empty steps exceeding chainDefList size. The new steps are now %s ", parallel_steps)
460 for chain_index, step
in enumerate(parallel_steps):
462 if step
is None or len(step.sequenceFunctions) == 0:
464 new_stepDicts = deepcopy(chainDefList[chain_index].steps[-1].stepDicts)
465 currentStepName =
'Empty' + chainDefList[chain_index].alignmentGroups[0]+
'Align'+
str(stepNumber)+
'_'+new_stepDicts[0][
'chainParts'][0][
'multiplicity']+new_stepDicts[0][
'signature']
466 log.debug(
'[makeCombinedStep] step has no sequences, making empty step %s', currentStepName)
469 for new_stepDict
in new_stepDicts:
470 oldLegName = new_stepDict[
'chainName']
471 if re.search(
'^leg[0-9]{3}_',oldLegName):
472 oldLegName = oldLegName[7:]
473 new_stepDict[
'chainName'] =
legName(oldLegName,leg_counter)
474 log.debug(
"[makeCombinedStep] stepDict naming old: %s, new: %s", oldLegName, new_stepDict[
'chainName'])
475 stepDicts.append(new_stepDict)
480 currentStepName = step.name
483 if currentStepName.startswith(
'merged_'):
484 currentStepName = currentStepName[7:]
487 log.debug(
'[makeCombinedStep] adding step dictionaries %s',step.stepDicts)
489 for new_stepDict
in deepcopy(step.stepDicts):
490 oldLegName = new_stepDict[
'chainName']
491 if re.search(
'^leg[0-9]{3}_',oldLegName):
492 oldLegName = oldLegName[7:]
493 if len(leg_numbering) > 0:
494 leg_counter = leg_numbering[chain_index]
495 new_stepDict[
'chainName'] =
legName(oldLegName,leg_counter)
496 log.debug(
"[makeCombinedStep] stepDict naming old: %s, new: %s", oldLegName, new_stepDict[
'chainName'])
497 stepDicts.append(new_stepDict)
500 stepName +=
'_' + currentStepName
502 theChainStep = ChainStep(stepName, Sequences=[], multiplicity=[], chainDicts=stepDicts, comboHypoCfg=ComboHypoCfg)
503 log.debug(
"[makeCombinedStep] Merged empty step: \n %s", theChainStep)
506 for chain_index, step
in enumerate(parallel_steps):
508 if step
is None or (hasNonEmptyStep
and len(step.sequenceFunctions) == 0):
512 if chain_index+1 > len(chainDefList):
513 chain_index-=chain_index
515 if alignment_group ==
"":
516 alignment_group = chainDefList[0].alignmentGroups[0]
518 new_stepDict = deepcopy(chainDefList[chain_index].steps[-1].stepDicts[-1])
519 seqName =
getEmptySeqName(new_stepDict[
'signature'], stepNumber, alignment_group)
522 stepSeq.append(functools.partial(EmptyMenuSequenceCfg,
None, name=seqName+
"FS"))
523 currentStepName =
'Empty' + alignment_group +
'Align'+
str(stepNumber)+
'_'+new_stepDict[
'chainParts'][0][
'multiplicity']+new_stepDict[
'signature']+
'FS'
525 stepSeq.append(functools.partial(EmptyMenuSequenceCfg,
None, name=seqName))
526 currentStepName =
'Empty' + alignment_group +
'Align'+
str(stepNumber)+
'_'+new_stepDict[
'chainParts'][0][
'multiplicity']+new_stepDict[
'signature']
528 log.debug(
"[makeCombinedStep] chain_index: %s, step name: %s, empty sequence name: %s", chain_index, currentStepName, seqName)
532 if stepNumber > 1
and len(currentChainSteps[stepNumber-2].multiplicity) >0:
533 prev_step_mult =
int(currentChainSteps[stepNumber-2].multiplicity[chain_index])
536 prev_step_mult =
int(new_stepDict[
'chainParts'][0][
'multiplicity'])
537 stepMult.append(prev_step_mult)
539 oldLegName = new_stepDict[
'chainName']
540 if re.search(
'^leg[0-9]{3}_',oldLegName):
541 oldLegName = oldLegName[7:]
542 new_stepDict[
'chainName'] =
legName(oldLegName,leg_counter)
543 stepDicts.append(new_stepDict)
547 log.debug(
"[makeCombinedStep] step %s, multiplicity = %s", step.name,
str(step.multiplicity))
548 if len(step.sequenceFunctions):
549 log.debug(
"[makeCombinedStep] with sequences = %s",
' '.
join(map(str, [seq.func.__name__
for seq
in step.sequenceFunctions])))
552 if len(step.sequenceFunctions) > 1:
553 log.debug(
"[makeCombinedStep] combining in an already combined chain")
555 if ( comboHypo
is None or
556 (hasattr(step.comboHypoCfg,
'__name__')
and step.comboHypoCfg.__name__ !=
"ComboHypoCfg") ):
557 comboHypo = step.comboHypoCfg
558 currentStepName = step.name
560 if currentStepName.startswith(
'merged_'):
561 currentStepName = currentStepName[7:]
562 stepSeq.extend(step.sequenceFunctions)
564 if len(step.multiplicity) == 0:
567 stepMult.extend(step.multiplicity)
568 comboHypoTools.extend(step.comboToolConfs)
570 log.debug(
'[makeCombinedStep] adding step dictionaries %s',step.stepDicts)
571 log.debug(
'[makeCombinedStep] my leg_numbering is: %s, for chain_index %s',leg_numbering, chain_index)
572 for new_stepDict
in deepcopy(step.stepDicts):
573 oldLegName = new_stepDict[
'chainName']
574 if re.search(
'^leg[0-9]{3}_',oldLegName):
575 oldLegName = oldLegName[7:]
576 if len(leg_numbering) > 0:
577 leg_counter = leg_numbering[chain_index]
578 new_stepDict[
'chainName'] =
legName(oldLegName,leg_counter)
579 log.debug(
"[makeCombinedStep] stepDict naming old: %s, new: %s", oldLegName, new_stepDict[
'chainName'])
580 stepDicts.append(new_stepDict)
585 stepName +=
'_' + currentStepName
586 log.debug(
'[makeCombinedStep] current step name %s',stepName)
589 comboHypoTools =
list(
set(comboHypoTools))
590 theChainStep = ChainStep(stepName, Sequences=stepSeq, multiplicity=stepMult, chainDicts=stepDicts, comboHypoCfg=comboHypo, comboToolConfs=comboHypoTools)
591 log.debug(
"[makeCombinedStep] Merged step: \n %s", theChainStep)
598 from itertools
import repeat
600 iterators = [iter(it)
for it
in AllSteps]
602 if len(iterators)==0:
606 for i, it
in enumerate(iterators):
609 except StopIteration:
610 if i
not in inactives:
613 if len(inactives)>=len(iterators):
616 iterators[i] = repeat(fillvalue,
int(multiplicity[i]))
619 if int(multiplicity[i]) > 1
and value == fillvalue:
620 values.extend([fillvalue]*
int(multiplicity[i]-1))
627 for ileg
in range(len(L1decisions)):
629 log.debug(
"[%s] adding FS empty sequence", caller)
630 emptySequences += [functools.partial(EmptyMenuSequenceCfg,
None, name=seqNames[ileg]+
"FS")]
632 log.debug(
"[%s] adding non-FS empty sequence", caller)
633 emptySequences += [functools.partial(EmptyMenuSequenceCfg,
None, name=seqNames[ileg])]
635 log.verbose(
"[%s] emptyChainDicts %s", caller, emptyChainDicts)
636 log.debug(
"[%s] %s has number of empty sequences %d and empty legs in stepDicts %d",
637 caller, chainName, len(emptySequences), len(emptyChainDicts))
638 if len(emptySequences) != len(emptyChainDicts):
639 log.error(
"[%s] %s has a different number of empty sequences/legs %d than stepDicts %d",
640 caller, chainName, len(emptySequences), len(emptyChainDicts))
642 raise Exception(f
"[{caller}] Cannot create this chain step, exiting.")
644 for sd
in emptyChainDicts:
645 if sd[
'signature'] ==
'Jet' or sd[
'signature'] ==
'Bjet':
647 elif len(sd[
'chainParts']) != 1:
648 log.error(
"[%s] %s has chainParts has length != 1 within a leg! chain dictionary for this step: \n %s",
649 caller, chainName, sd)
650 raise Exception(f
"[{caller}] Cannot create this chain step, exiting.")
652 step_mult += [
int(sd[
'chainParts'][0][
'multiplicity'])]
654 if len(emptySequences) != len(step_mult):
655 log.error(
"[%s] %s has a different number of empty sequences/legs %d than multiplicities %d",
656 caller, chainName, len(emptySequences), len(step_mult))
657 raise Exception(f
"[{caller}] Cannot create this chain step, exiting.")
659 log.verbose(
'[%s] step multiplicity %s',caller, step_mult)
662 return emptySequences