def __getChainSequencers(stepsData, chainName): """ Finds the Filter which is responsible for this Chain in each Step. Return a list of the per-Step name() of the Sequencer which is unlocked by the Chain's Filter in the Step. """ sequencers = [] counter = 0 from DecisionHandling.TrigCompositeUtils import chainNameFromLegName for step in stepsData: counter += 1 mySequencer = None endOfChain = False for sequencer in step: sequencerFilter = getSequenceChildren( sequencer )[0] # Always the first child in the step if any(chainName in chainNameFromLegName(fChain) for fChain in sequencerFilter.Chains): if mySequencer is not None: __log.error( "Multiple Filters found (corresponding Sequencers %s, %s) for %s in Step %i!", mySequencer.getName(), sequencer.getName(), chainName, counter) mySequencer = sequencer if mySequencer is None: endOfChain = True if counter == 1 and 'noalg' not in chainName: __log.warn("No Filter found for %s in Step 1", chainName) else: if endOfChain is True: __log.error( "Found another Step, (Step %i) for chain %s " "which looked like it had already finished after %i Steps!", counter, chainName, sequencers.len()) sequencers.append(mySequencer.getName()) return sequencers
def collectHypos( steps ): """ Method iterating over the CF and picking all the Hypothesis algorithms Returned is a map with the step name and list of all instances of hypos in that step. Input is top HLT sequencer. """ __log.info("Collecting hypos from steps") from collections import defaultdict hypos = defaultdict( list ) for stepSeq in getSequenceChildren( steps ): if not isSequence( stepSeq ): continue if "filter" in stepSeq.getName(): __log.debug("Skipping filtering steps " +stepSeq.getName() ) continue __log.debug( "collecting hypos from step " + stepSeq.getName() ) # start = {} for seq,algs in six.iteritems (flatAlgorithmSequences( stepSeq )): for alg in algs: if isSequence( alg ): continue # will replace by function once dependencies are sorted if hasProp( alg, 'HypoInputDecisions'): __log.debug( "found hypo " + alg.getName() + " in " +stepSeq.getName() ) if __isCombo( alg ) and len(alg.ComboHypoTools): __log.debug( " with %d comboHypoTools: %s", len(alg.ComboHypoTools), ' '.join(map(str, [tool.getName() for tool in alg.ComboHypoTools]))) hypos[stepSeq.getName()].append( alg ) else: __log.verbose("Not a hypo" + alg.getName()) return hypos
def collectFilters( steps ): """ Similarly to collectHypos but works for filter algorithms The logic is simpler as all filters are grouped in step filter sequences Returns map: step name -> list of all filters of that step """ __log.info("Collecting filters") from collections import defaultdict filters = defaultdict( list ) for stepSeq in getSequenceChildren( steps ): if "filter" in stepSeq.getName(): filters[stepSeq.getName()] = getSequenceChildren( stepSeq ) __log.debug("Found Filters in Step {} : {}".format(stepSeq.getName(), getSequenceChildren( stepSeq ))) return filters
def __getStepsDataFromAlgSequence(HLTAllSteps): """ Generates a list where the index corresponds to a Step number and the stored object is a list of Sequencers making up the Step """ stepsData = [] if HLTAllSteps is not None: for HLTStep in getSequenceChildren( HLTAllSteps ): if "_reco" not in HLTStep.getName(): # Avoid the pre-step Filter execution # Look for newJO reco for Step in getChildrenIfSequence( HLTStep ): for View in getChildrenIfSequence( Step ): for Reco in getChildrenIfSequence( View ): if "_reco" in Reco.getName() and HLTStep.getName() not in stepsData: stepsData.append( getSequenceChildren( HLTStep ) ) break continue stepsData.append( getSequenceChildren( HLTStep ) ) else: __log.warn( "No HLTAllSteps sequencer, will not export per-Step data for chains.") return stepsData
def _dump(seq, indent): o = list() if isSequence(seq): for c in getSequenceChildren(seq): if isSequence(c): o.append(( "%s[color=%s, shape=circle, width=.5, fixedsize=true ,style=filled]\n" % (compName(c), _seqColor(c)), indent)) else: o.append(("%s[fillcolor=%s,style=filled]\n" % (compName(c), algColor(c)), indent)) o.append(("%s -> %s\n" % (compName(seq), compName(c)), indent)) o.extend(_dump(c, indent + 1)) return o
def getValuesProperties(node): Excluded = ["StoreGateSvc/DetectorStore", "StoreGateSvc"] values = [] algs = [] if isinstance(node.Alg, AthSequencer): seq = node.Alg algs = getSequenceChildren(seq) algs.pop(0) # remove InputMaker else: algs.append(node.Alg) for alg in algs: for k, cval in alg.getValuedProperties().items(): if type(cval) is list: for val in cval: if val == '': # CAT type(val) is None ?? if val not in Excluded: values.append(val) elif cval == '': # CAT type(val) is None ?? if cval not in Excluded: values.append(cval) else: continue return set(values)
def getChildrenIfSequence( s ): return getSequenceChildren( s ) if isSequence( s ) else []
def __getSequenceChildrenIfIsSequence( s ): if isSequence( s ): return getSequenceChildren( s ) return []