558def triggerEDMGapFillerCfg( flags, edmSet, decObj=[], decObjHypoOut=[], extraInputs=[], extraOutputs=[] ):
559 """Configure the EDM gap filler"""
560
561 from TrigEDMConfig.TriggerEDMDefs import Alias
562 from TrigEDMConfig.TriggerEDM import getRawTriggerEDMList
563
564 # Ignore the following collections in the GapFiller. List of regular expressions
565 # that are fully matched against the EDM entry ("type#key").
566 ignore = [
567 # GapFiller always creates Aux stores unless it doesn't end in a ., then there are extra decorations that need declaring
568 ".*AuxContainer#.*", ".*AuxInfo#.*",
569 ]
570 if flags.Trigger.doHLT:
571 # Online, these collections will be created after the EDMCreator runs
572 ignore += ["xAOD::TrigCompositeContainer#HLTNav_Summary_OnlineSlimmed",
573 "xAOD::TrigCompositeContainer#HLT_RuntimeMetadata"]
574
575 acc = ComponentAccumulator()
576 tool = CompFactory.HLTEDMCreator(f"GapFiller{'' if edmSet==['BS'] else '_'+'_'.join(edmSet)}")
577 alg = CompFactory.HLTEDMCreatorAlg("EDMCreatorAlg",
578 OutputTools = [tool])
579 alg.ExtraInputs = set(extraInputs)
580 alg.ExtraOutputs = set(extraOutputs)
581 alg.ExtraOutputs.add(("xAOD::TrigConfKeys","TrigConfKeysOnline")) # declare keys which are always produced
582
583 # adding the following extra outputs, which can come out of old data but need to eliminate
584 # remaining dependencies on them (e.g. FwdAFPHLTPFlowJetMonitoringAlg)
585 # TODO: Remove dependent algs on these non-existent objects
586 alg.ExtraOutputs.add(('xAOD::JetContainer','HLT_AntiKt4EMTopoJets_subjesIS' ))
587 alg.ExtraOutputs.add(('xAOD::JetContainer','HLT_AntiKt4EMTopoJets_subjesgscIS_ftf' ))
588 alg.ExtraOutputs.add(('xAOD::JetContainer','HLT_AntiKt4EMTopoJets_subresjesgscIS_ftf' ))
589 alg.ExtraOutputs.add(('xAOD::JetContainer','HLT_AntiKt4EMTopoJets_subjesIS_fastftag'))
590 alg.ExtraOutputs.add(('xAOD::JetContainer','HLT_AntiKt4EMPFlowJets_subjesgscIS_ftf' ))
591 alg.ExtraOutputs.add(('xAOD::JetContainer','HLT_AntiKt4EMPFlowJets_subjesIS_ftf'))
592 alg.ExtraOutputs.add(('xAOD::JetContainer','HLT_AntiKt4EMPFlowJets_subresjesgscIS_ftf' ))
593 alg.ExtraOutputs.add(('xAOD::JetContainer','HLT_AntiKt10LCTopoJets_subjes'))
594 alg.ExtraOutputs.add(('xAOD::CaloClusterContainer','HLT_TopoCaloClustersLCFS'))
595
596
597 tool.RenounceOutputs = flags.Trigger.doHLT # if running trigger in HLT then renounce outputs to prevent dependencies on this tool/alg
598
599 if len(edmSet) != 0:
600 groupedByType = defaultdict( list )
601 re_ignore = [re.compile(x) for x in ignore]
602
603 # scan the EDM
604 for el in getRawTriggerEDMList(flags):
605 if not any([ outputType in el[1].split() for outputType in edmSet ]):
606 continue
607 if any(ign.fullmatch(el[0]) for ign in re_ignore):
608 # aux container or aux info .. need to see if we have decorations to declare
609 collType, collName = el[0].split("#")
610 if collName[-1] != ".":
611 collType = collType.replace("AuxInfo","Info").replace("AuxContainer","Container")
612 __log.debug("GapFiller will create EDM decorations on type '%s' of '%s'", collType, collName)
613 collNameList = collName.split(".") # first will be the collection name with Aux. added
614 collName = (collNameList[0] + ".").replace("Aux.",".")
615 for decorName in collNameList[1:]:
616 alg.ExtraOutputs.add((collType,"StoreGateSvc+"+collName+decorName))
617 continue
618 collType, collName = el[0].split("#")
619 if len(el) >= 4: # see if there is an alias
620 aliases = [ str(a) for a in el[3] if isinstance(a, Alias) ]
621 if len(aliases) == 1:
622 __log.debug("GapFiller configuration found an aliased type '%s' for '%s'", aliases[0], collType)
623 collType = aliases[0]
624 elif len(aliases) > 1:
625 __log.error("GapFiller configuration found inconsistent '%s' (too many aliases?)", aliases)
626
627 groupedByType[collType].append( collName )
628
629 for collType, collNameList in groupedByType.items():
630 propName = collType.split(":")[-1]
631 if hasattr( tool, propName ):
632 setattr( tool, propName, collNameList )
633 __log.debug("GapFiller will create EDM collection type '%s' for '%s'", collType, collNameList)
634 else:
635 __log.debug("EDM collections of type %s are not going to be added to StoreGate, if not created by the HLT", collType )
636
637 if decObj or decObjHypoOut:
638 __log.debug("GapFiller is ensuring the creation of all the decision object collections")
639 __log.debug("'%s'", decObj)
640 # Gap filler is also used to perform re-mapping of the HypoAlg outputs which is a sub-set of decObj
641 tool.FixLinks = list(decObjHypoOut)
642 # Append and hence confirm all TrigComposite collections
643 tool.TrigCompositeContainer += list(decObj)
644
645 acc.addEventAlgo(alg, primary=True)
646 return acc
647
648