ATLAS Offline Software
Loading...
Searching...
No Matches
MenuComponents.Chain Class Reference
Inheritance diagram for MenuComponents.Chain:
Collaboration diagram for MenuComponents.Chain:

Public Member Functions

 __init__ (self, name, ChainSteps, L1decisions, nSteps=None, alignmentGroups=None, topoMap=None)
 append_bjet_steps (self, new_steps)
 append_step_to_jet (self, new_steps)
 numberAllSteps (self)
 insertEmptySteps (self, empty_step_name, n_new_steps, start_position)
 checkNumberOfLegs (self)
 addTopo (self, topoPair, step="last")
 __str__ (self)
 __repr__ (self)

Public Attributes

 name = name
 steps = ChainSteps
list nSteps = nSteps
 alignmentGroups = alignmentGroups
dict topoMap = {}
 L1decisions = L1decisions

Static Private Attributes

str __slots__ = 'name','steps','nSteps','alignmentGroups','L1decisions', 'topoMap'

Detailed Description

Basic class to define the trigger menu 

Definition at line 424 of file MenuComponents.py.

Constructor & Destructor Documentation

◆ __init__()

MenuComponents.Chain.__init__ ( self,
name,
ChainSteps,
L1decisions,
nSteps = None,
alignmentGroups = None,
topoMap = None )
Construct the Chain from the steps
Out of all arguments the ChainSteps & L1Thresholds are most relevant, the chain name is used in debug messages

Definition at line 427 of file MenuComponents.py.

427 def __init__(self, name, ChainSteps, L1decisions, nSteps = None, alignmentGroups = None, topoMap=None):
428
429 """
430 Construct the Chain from the steps
431 Out of all arguments the ChainSteps & L1Thresholds are most relevant, the chain name is used in debug messages
432 """
433
434 # default mutable values must be initialized to None
435 if nSteps is None: nSteps = []
436 if alignmentGroups is None: alignmentGroups = []
437
438 self.name = name
439 self.steps = ChainSteps
440 self.nSteps = nSteps
441 self.alignmentGroups = alignmentGroups
442
443
444 # The chain holds a map of topo ComboHypoTool configurators
445 # This is needed to allow placement of the ComboHypoTool in the right position
446 # for multi-leg chains (defaults to last step)
447 # Format is {"[step name]" : ([topo config function], [topo descriptor string]), ...}
448 # Here, the topo descriptor string would usually be the chain name expression that
449 # configures the topo
450 self.topoMap = {}
451 if topoMap:
452 self.topoMap.update(topoMap)
453
454 # L1decisions are used to set the seed type (EM, MU,JET), removing the actual threshold
455 # in practice it is the HLTSeeding Decision output
456 self.L1decisions = L1decisions
457 log.debug("[Chain.__init__] Made Chain %s with seeds: %s ", name, self.L1decisions)
458

Member Function Documentation

◆ __repr__()

MenuComponents.Chain.__repr__ ( self)

Definition at line 576 of file MenuComponents.py.

576 def __repr__(self):
577 return "\n-*- Chain %s -*- \n + Seeds: %s, Steps: %s, AlignmentGroups: %s \n + Steps: \n %s \n"%(\
578 self.name, ' '.join(map(str, self.L1decisions)), self.nSteps, self.alignmentGroups, '\n '.join(map(str, self.steps)))
579
580
581
STL class.

◆ __str__()

MenuComponents.Chain.__str__ ( self)

Definition at line 572 of file MenuComponents.py.

572 def __str__(self):
573 return "\n-*- Chain %s -*- \n + Seeds: %s, Steps: %s, AlignmentGroups: %s "%(\
574 self.name, ' '.join(map(str, self.L1decisions)), self.nSteps, self.alignmentGroups)
575

◆ addTopo()

MenuComponents.Chain.addTopo ( self,
topoPair,
step = "last" )

Definition at line 567 of file MenuComponents.py.

567 def addTopo(self,topoPair,step="last"):
568 stepname = "last step" if step=="last" else step.name
569 log.debug("Adding topo configurator %s for %s to %s", topoPair[0].__qualname__, topoPair[1], "step " + stepname)
570 self.topoMap[step] = topoPair
571

◆ append_bjet_steps()

MenuComponents.Chain.append_bjet_steps ( self,
new_steps )

Definition at line 459 of file MenuComponents.py.

459 def append_bjet_steps(self,new_steps):
460 assert len(self.nSteps) == 1, "[Chain.append_bjet_steps] appending already-merged step lists - chain object will be broken. This should only be used to append Bjets to jets!"
461 self.steps = self.steps + new_steps
462 self.nSteps = [len(self.steps)]
463

◆ append_step_to_jet()

MenuComponents.Chain.append_step_to_jet ( self,
new_steps )

Definition at line 464 of file MenuComponents.py.

464 def append_step_to_jet(self,new_steps):
465 assert len(self.nSteps) == 1, "[Chain.append_step_to_jet] appending already-merged step lists - chain object will be broken. This is used either for appending Beamspot algorithms to jets!"
466 self.steps = self.steps + new_steps
467 self.nSteps = [len(self.steps)]
468
469

◆ checkNumberOfLegs()

MenuComponents.Chain.checkNumberOfLegs ( self)
return 0 if the chain has unexpected number of step legs 

Definition at line 540 of file MenuComponents.py.

540 def checkNumberOfLegs(self):
541 """ return 0 if the chain has unexpected number of step legs """
542 if len(self.steps) == 0: # skip if it's noAlg chains
543 return 1
544
545 mult=[step.nLegs for step in self.steps] # one nLegs per step
546 not_empty_mult = [m for m in mult if m!=0]
547 # cannot accept chains with all empty steps
548 if len(not_empty_mult) == 0:
549 log.error("checkNumberOfLegs: Chain %s has all steps with nLegs =0: what to do?", self.name)
550 return 0
551
552 # cannot accept chains with steps with different number of legs
553 if not_empty_mult.count(not_empty_mult[0]) != len(not_empty_mult):
554 log.error("checkNumberOfLegs: Chain %s has steps with differnt number of legs: %s", self.name, ' '.join(mult))
555 return 0
556
557 # check that the chain number of legs is the same as the number of L1 seeds
558 if not_empty_mult[0] != len(self.L1decisions):
559 log.error("checkNumberOfLegs: Chain %s has %i legs per step, and %d L1Decisions", self.name, mult, len(self.L1decisions))
560 return 0
561 return not_empty_mult[0]
562
563

◆ insertEmptySteps()

MenuComponents.Chain.insertEmptySteps ( self,
empty_step_name,
n_new_steps,
start_position )

Definition at line 493 of file MenuComponents.py.

493 def insertEmptySteps(self, empty_step_name, n_new_steps, start_position):
494 #start position indexed from 0. if start position is 3 and length is 2, it works like:
495 # [old1,old2,old3,old4,old5,old6] ==> [old1,old2,old3,empty1,empty2,old4,old5,old6]
496
497 if len(self.steps) == 0 :
498 log.error("I can't insert empty steps because the chain doesn't have any steps yet!")
499
500 if len(self.steps) < start_position :
501 log.error("I can't insert empty steps at step %d because the chain doesn't have that many steps!", start_position)
502
503
504 chain_steps_pre_split = self.steps[:start_position]
505 chain_steps_post_split = self.steps[start_position:]
506
507 next_step_name = ''
508 prev_step_name = ''
509 # copy the same dictionary as the last step, which else?
510 prev_chain_dict = []
511 if start_position == 0:
512 next_step_name = chain_steps_post_split[0].name
513 if re.search('^Step[0-9]_',next_step_name):
514 next_step_name = next_step_name[6:]
515 elif re.search('^Step[0-9]{2}_', next_step_name):
516 next_step_name = next_step_name[7:]
517
518 prev_step_name = 'empty_'+str(len(self.L1decisions))+'L1in'
519 prev_chain_dict = chain_steps_post_split[0].stepDicts
520 else:
521 if len(chain_steps_post_split) == 0:
522 log.error("Adding empty steps to the end of a chain (%s)- why would you do this?",self.name)
523 else:
524 prev_step_name = chain_steps_pre_split[-1].name
525 next_step_name = chain_steps_post_split[0].name
526 prev_chain_dict = chain_steps_pre_split[-1].stepDicts
527
528
529 steps_to_add = []
530 for stepID in range(1,n_new_steps+1):
531 new_step_name = prev_step_name+'_'+empty_step_name+'%d_'%stepID+next_step_name
532
533 log.debug("Adding empty step %s", new_step_name)
534 steps_to_add += [ChainStep(new_step_name, chainDicts=prev_chain_dict, isEmpty=True)]
535
536 self.steps = chain_steps_pre_split + steps_to_add + chain_steps_post_split
537
538 return
539

◆ numberAllSteps()

MenuComponents.Chain.numberAllSteps ( self)

Definition at line 470 of file MenuComponents.py.

470 def numberAllSteps(self):
471 if len(self.steps)==0:
472 return
473 else:
474 for stepID,step in enumerate(self.steps):
475 step_name = step.name
476 if re.search('^Step[0-9]_',step_name):
477 step_name = step_name[6:]
478 elif re.search('^Step[0-9]{2}_', step_name):
479 step_name = step_name[7:]
480 step.name = 'Step%d_'%(stepID+1)+step_name
481 # also modify the empty sequence names to follow the step name change
482 for iseq, seq in enumerate(step.sequenceGens):
483 if isEmptySequenceCfg(seq):
484 name = seq.func.__name__
485 if re.search('Seq[0-9]_',name):
486 newname = re.sub('Seq[0-9]_', 'Seq%d_'%(stepID+1), name)
487 #replace the empty sequence
488 thisEmpty = createEmptyMenuSequenceCfg(flags=None, name=newname)
489 step.sequenceGens[iseq]=functools.partial(thisEmpty, flags=None, name=newname)
490 return
491
492

Member Data Documentation

◆ __slots__

str MenuComponents.Chain.__slots__ = 'name','steps','nSteps','alignmentGroups','L1decisions', 'topoMap'
staticprivate

Definition at line 426 of file MenuComponents.py.

◆ alignmentGroups

MenuComponents.Chain.alignmentGroups = alignmentGroups

Definition at line 441 of file MenuComponents.py.

◆ L1decisions

MenuComponents.Chain.L1decisions = L1decisions

Definition at line 456 of file MenuComponents.py.

◆ name

MenuComponents.Chain.name = name

Definition at line 438 of file MenuComponents.py.

◆ nSteps

MenuComponents.Chain.nSteps = nSteps

Definition at line 440 of file MenuComponents.py.

◆ steps

MenuComponents.Chain.steps = ChainSteps

Definition at line 439 of file MenuComponents.py.

◆ topoMap

dict MenuComponents.Chain.topoMap = {}

Definition at line 450 of file MenuComponents.py.


The documentation for this class was generated from the following file: