5 from AthenaConfiguration.ComponentAccumulator 
import ComponentAccumulator
 
    6 from AthenaConfiguration.ComponentFactory 
import CompFactory
 
    7 from AthenaCommon.Logging 
import logging
 
    8 from TrigEDMConfig.TriggerEDM 
import recordable
 
   12 log = logging.getLogger(
'HLTSeedingConfig')
 
   14 _mapL1ThresholdToDecisionCollection = {
 
   16     "FSNOSEED": 
"HLTNav_L1FSNOSEED",
 
   19     "PROBEMU"  : 
"HLTNav_L1PROBEMU",
 
   21     "eEM": 
"HLTNav_L1eEM",
 
   22     "eTAU": 
"HLTNav_L1eTAU",
 
   23     "jEM": 
"HLTNav_L1jEM",
 
   24     "jTAU": 
"HLTNav_L1jTAU",
 
   25     "cTAU": 
"HLTNav_L1cTAU",
 
   27     "jLJ": 
"HLTNav_L1jLJ",
 
   29     "gLJ": 
"HLTNav_L1gLJ",
 
   30     "PROBEeEM" : 
"HLTNav_L1PROBEeEM",
 
   31     "PROBEjEM" : 
"HLTNav_L1PROBEjEM",
 
   32     "PROBEeTAU" : 
"HLTNav_L1PROBEeTAU",
 
   33     "PROBEjTAU" : 
"HLTNav_L1PROBEjTAU",
 
   34     "PROBEcTAU" : 
"HLTNav_L1PROBEcTAU",
 
   38     "TAU": 
"HLTNav_L1TAU",
 
   39     "XE" : 
"HLTNav_L1MET",
 
   40     "XS" : 
"HLTNav_L1MET",
 
   41     "TE" : 
"HLTNav_L1MET",
 
   42     "PROBEEM"  : 
"HLTNav_L1PROBEEM",
 
   43     "PROBETAU" : 
"HLTNav_L1PROBETAU",
 
   46 _mapL1ThresholdToRoICollection = {
 
   48     "FSNOSEED": 
"HLT_FSRoI",
 
   51     "PROBEMU"  : 
"HLT_MURoIs",
 
   54     "eTAU": 
"HLT_eTAURoIs",
 
   56     "jTAU": 
"HLT_jTAURoIs",
 
   57     "cTAU": 
"HLT_cTAURoIs",
 
   62     "PROBEeEM" : 
"HLT_eEMRoIs",
 
   63     "PROBEeTAU": 
"HLT_eTAURoIs",
 
   64     "PROBEjEM": 
"HLT_jEMRoIs",
 
   65     "PROBEjTAU": 
"HLT_jTAURoIs",
 
   66     "PROBEcTAU": 
"HLT_cTAURoIs",
 
   74     "PROBEEM"  : 
"HLT_EMRoIs",
 
   75     "PROBETAU" : 
"HLT_TAURoI",
 
   81     Translates L1 threshold  name of the DecisionsContainer name in the HLTSeeding unpacking tools 
   84     for (thresholdType, l1Collection) 
in _mapL1ThresholdToDecisionCollection.items():
 
   85         if threshold.startswith( thresholdType ):
 
   88     log.error(
"Threshold \""+ threshold + 
"\" not mapped to any Decision collection! Available are: " + 
str(_mapL1ThresholdToDecisionCollection.values()))
 
   93     Translates L1 threshold  name of the RoIDescriptor name in the HLTSeeding unpacking tools 
   96     for (thresholdType, l1Collection) 
in _mapL1ThresholdToRoICollection.items():
 
   97         if threshold.startswith( thresholdType ):
 
  100     log.error(
"Threshold \""+ threshold + 
"\" not mapped to any ROI collection! Available are: " + 
str(_mapL1ThresholdToRoICollection.values()))
 
  104     from HLTSeeding.HLTSeedingMonitoring 
import RoIsUnpackingMonitoring
 
  108                                                  MonTool = 
RoIsUnpackingMonitoring( flags, prefix=
"EM", maxCount=30, etaOffset=0.05, phiOffset=math.pi/64., maxEta=2.5 ))
 
  117     tauUnpacker.MonTool = 
RoIsUnpackingMonitoring( flags, prefix=
"TAU", maxCount=30, etaOffset=0.05, phiOffset=math.pi/64., maxEta=2.5  )
 
  124     return [emUnpacker, metUnpacker, tauUnpacker, jUnpacker ]
 
  127     from HLTSeeding.HLTSeedingMonitoring 
import RoIsUnpackingMonitoring
 
  130     if flags.Trigger.L1.doeFex:
 
  131         maxRoICount_eFex = 150  
 
  132         eFexEMUnpacker = CompFactory.eFexEMRoIsUnpackingTool(
 
  136             RoIHalfWidthEta = 0.2,
 
  137             RoIHalfWidthPhi = 0.2,
 
  139         eFexTauUnpacker = CompFactory.eFexTauRoIsUnpackingTool(
 
  143             RoIHalfWidthEta = 0.4,
 
  144             RoIHalfWidthPhi = math.pi/8,
 
  146         tools += [eFexEMUnpacker, eFexTauUnpacker]
 
  148     if flags.Trigger.L1.dojFex:
 
  149         maxRoICount_jFex = 200  
 
  150         jFexEMUnpacker = CompFactory.jFexFwdElRoIsUnpackingTool(
 
  154             RoIHalfWidthEta = 0.4,
 
  155             RoIHalfWidthPhi = math.pi/8,
 
  157         jFexTauUnpacker = CompFactory.jFexTauRoIsUnpackingTool(
 
  161             RoIHalfWidthEta = 0.4,
 
  162             RoIHalfWidthPhi = math.pi/8,
 
  164         jFexSRJetUnpacker = CompFactory.jFexSRJetRoIsUnpackingTool(
 
  167             RoIHalfWidthEta = 0.1,
 
  168             RoIHalfWidthPhi = 0.1,
 
  170         jFexLRJetUnpacker = CompFactory.jFexLRJetRoIsUnpackingTool(
 
  173             RoIHalfWidthEta = 0.1,
 
  174             RoIHalfWidthPhi = 0.1,
 
  176         tools += [jFexEMUnpacker, jFexTauUnpacker, jFexSRJetUnpacker, jFexLRJetUnpacker]
 
  178     if flags.Trigger.L1.dogFex:
 
  179         maxRoICount_gFex = 100  
 
  180         gFexSRJetUnpacker = CompFactory.gFexSRJetRoIsUnpackingTool(
 
  183             RoIHalfWidthEta = 0.1,
 
  184             RoIHalfWidthPhi = 0.1,
 
  186         gFexLRJetUnpacker = CompFactory.gFexLRJetRoIsUnpackingTool(
 
  189             RoIHalfWidthEta = 0.1,
 
  190             RoIHalfWidthPhi = 0.1,
 
  192         tools += [gFexSRJetUnpacker, gFexLRJetUnpacker]
 
  195     if flags.Trigger.L1.doeFex 
and flags.Trigger.L1.dojFex:
 
  196         maxRoICount_eFex = 150  
 
  197         cTauUnpacker = CompFactory.cTauRoIsUnpackingTool(
 
  201             RoIHalfWidthEta = 0.4,
 
  202             RoIHalfWidthPhi = math.pi/8,
 
  204         tools += [cTauUnpacker]
 
  209     from HLTSeeding.HLTSeedingMonitoring 
import RoIsUnpackingMonitoring
 
  210     muUnpacker = CompFactory.MURoIsUnpackingTool(
 
  219     from HLTSeeding.HLTSeedingMonitoring 
import RoIsUnpackingMonitoring
 
  220     muUnpacker = CompFactory.MuonRoIsUnpackingTool(
 
  224         RoIHalfWidthEta = 0.1,
 
  225         RoIHalfWidthPhi = 0.1,
 
  230     from HLTSeeding.HLTSeedingMonitoring 
import PrescalingMonitoring
 
  236     keyWriter = CompFactory.getComp(
'TrigConf::KeyWriterTool')(
'KeyWriterToolOnline')
 
  237     keyWriter.ConfKeys = 
'TrigConfKeysOnline' 
  238     keyWriter.IncludeL1PrescaleKey = 
False 
  239     keyWriter.IncludeBunchgroupKey = 
False 
  246     l1trMaker = CompFactory.L1TriggerResultMaker(
 
  250         jFexFwdElRoIKey = 
"",
 
  252         jFexSRJetRoIKey = 
"",
 
  253         jFexLRJetRoIKey = 
"",
 
  254         gFexSRJetRoIKey = 
"",
 
  255         gFexLRJetRoIKey = 
"",
 
  258         ThresholdPatternTools = [] )
 
  261     if flags.Trigger.L1.doMuon 
and flags.Trigger.enableL1MuonPhase1:
 
  262         l1trMaker.MuRoIKey = 
"LVL1MuonRoIs" 
  263         from TrigT1MuctpiPhase1.TrigT1MuctpiPhase1Config 
import TrigThresholdDecisionToolCfg
 
  265     elif flags.Trigger.L1.doMuon 
and flags.Trigger.enableL0Muon:   
 
  266         l1trMaker.MuRoIKey = 
"LVL1MuonRoIs" 
  267         l1trMaker.ThresholdPatternTools += [CompFactory.MURoIThresholdsTool()]
 
  270     if flags.Trigger.L1.doCalo 
and flags.Trigger.enableL1CaloPhase1:
 
  271         if flags.Trigger.L1.doeFex:
 
  272             l1trMaker.eFexEMRoIKey = 
"L1_eEMRoI" 
  273             l1trMaker.eFexTauRoIKey = 
"L1_eTauRoI" 
  274             l1trMaker.ThresholdPatternTools += [
 
  275                 CompFactory.eFexEMRoIThresholdsTool(),
 
  276                 CompFactory.eFexTauRoIThresholdsTool(),
 
  278         if flags.Trigger.L1.dojFex:
 
  279             l1trMaker.jFexFwdElRoIKey = 
"L1_jFexFwdElRoI" 
  280             l1trMaker.jFexTauRoIKey = 
"L1_jFexTauRoI" 
  281             l1trMaker.jFexSRJetRoIKey = 
"L1_jFexSRJetRoI" 
  282             l1trMaker.jFexLRJetRoIKey = 
"L1_jFexLRJetRoI" 
  283             l1trMaker.ThresholdPatternTools += [
 
  284                 CompFactory.jFexFwdElRoIThresholdsTool(),
 
  285                 CompFactory.jFexTauRoIThresholdsTool(),
 
  286                 CompFactory.jFexSRJetRoIThresholdsTool(),
 
  287                 CompFactory.jFexLRJetRoIThresholdsTool(),
 
  289         if flags.Trigger.L1.dogFex:
 
  290             l1trMaker.gFexSRJetRoIKey = 
"L1_gFexSRJetRoI" 
  291             l1trMaker.gFexLRJetRoIKey = 
"L1_gFexLRJetRoI" 
  292             l1trMaker.ThresholdPatternTools += [
 
  293                 CompFactory.gFexSRJetRoIThresholdsTool(),
 
  294                 CompFactory.gFexLRJetRoIThresholdsTool(),
 
  297         if flags.Trigger.L1.doeFex 
and flags.Trigger.L1.dojFex:
 
  298             l1trMaker.cTauRoIKey = 
"L1_cTauRoI"   
  299             l1trMaker.cjTauLinkKey = 
"L1_cTauRoI.jTauLink"   
  300             l1trMaker.ThresholdPatternTools += [
 
  301                 CompFactory.cTauRoIThresholdsTool(),
 
  308     acc.addEventAlgo(l1trMaker, primary=
True)
 
  314         from AthenaCommon.CFElements 
import parOR
 
  319     from HLTSeeding.HLTSeedingMonitoring 
import CTPUnpackingMonitoring, L1DataConsistencyMonitoring
 
  320     decoderAlg = CompFactory.HLTSeeding(
 
  321         RoIBResult = 
"RoIBResult", 
 
  322         L1TriggerResult = 
"L1TriggerResult" if flags.Trigger.enableL1MuonPhase1 
or flags.Trigger.enableL1CaloPhase1 
else "",
 
  323         HLTSeedingSummaryKey = 
"HLTSeedingSummary", 
 
  324         ctpUnpacker = CompFactory.CTPUnpackingTool( ForceEnableAllChains = flags.Trigger.forceEnableAllChains,
 
  326                                                     UseEDMxAOD = flags.Trigger.CTP.UseEDMxAOD )
 
  330     if not (flags.Trigger.forceEnableAllChains 
or flags.Trigger.disableL1ConsistencyChecker):
 
  331         def checkConsistency(thrName):
 
  332             '''Filter out threshold types for which HLT doesn't read TOBs from L1 readout''' 
  333             return thrName 
not in [
'FSNOSEED',
'TE',
'XE',
'XS'] 
and not thrName.startswith(
'PROBE')
 
  335         decoderAlg.L1DataConsistencyChecker = CompFactory.L1DataConsistencyChecker(
 
  336             ThresholdToDecisionMap = dict([(k,v) 
for k,v 
in _mapL1ThresholdToDecisionCollection.items() 
if checkConsistency(k)]),
 
  338             ErrorOnMissingTOB = flags.Trigger.L1.errorOnMissingTOB )
 
  341     from AthenaConfiguration.Enums 
import Format
 
  342     if flags.Input.Format 
is Format.POOL:
 
  343         transTypeKey = (
"TransientBSOutType",
"StoreGateSvc+TransientBSOutKey")
 
  344         decoderAlg.ExtraInputs.add(transTypeKey)
 
  346     decoderAlg.RoIBRoIUnpackers += [
 
  350     if flags.Trigger.L1.doCalo:
 
  351         if flags.Trigger.enableL1CaloPhase1:
 
  353         if flags.Trigger.enableL1CaloLegacy:
 
  356     if flags.Trigger.L1.doMuon:
 
  357         if flags.Trigger.enableL1MuonPhase1:
 
  364     decoderAlg.DoCostMonitoring = flags.Trigger.CostMonitoring.doCostMonitoring
 
  365     decoderAlg.CostMonitoringChain = flags.Trigger.CostMonitoring.chain
 
  366     decoderAlg.RoiZedWidthDefault = flags.Trigger.InDetTracking.RoiZedWidthDefault
 
  368     if flags.Input.Format 
is Format.BS 
and not flags.Trigger.doLVL1:
 
  370         from TrigT1ResultByteStream.TrigT1ResultByteStreamConfig 
import L1TriggerByteStreamDecoderCfg
 
  374     if flags.Trigger.enableL1MuonPhase1 
or flags.Trigger.enableL1CaloPhase1:
 
  377     acc.addEventAlgo( decoderAlg, sequenceName = seqName )
 
  379     from TrigConfigSvc.TrigConfigSvcCfg 
import TrigConfigSvcCfg, HLTPrescaleCondAlgCfg
 
  384     from TriggerJobOpts.TriggerConfigFlags 
import ROBPrefetching
 
  385     if ROBPrefetching.InitialRoI 
in flags.Trigger.ROBPrefetchingOptions:
 
  386         allDecisionsSet = 
set()
 
  387         for roiUnpacker 
in decoderAlg.RoIBRoIUnpackers + decoderAlg.xAODRoIUnpackers:
 
  388             dec = 
str(roiUnpacker.Decisions)
 
  390                 allDecisionsSet.add(dec)
 
  392         from TrigGenericAlgs.TrigGenericAlgsConfig 
import ROBPrefetchingAlgCfg_Si, ROBPrefetchingAlgCfg_Calo, ROBPrefetchingAlgCfg_Muon
 
  393         acc.merge(
ROBPrefetchingAlgCfg_Si(flags, 
"initialRoI", RoILinkName=
"initialRoI", ROBPrefetchingInputDecisions=allDecisions), sequenceName=seqName)
 
  394         acc.merge(
ROBPrefetchingAlgCfg_Calo(flags,
"initialRoI", RoILinkName=
"initialRoI", ROBPrefetchingInputDecisions=allDecisions), sequenceName=seqName)
 
  395         acc.merge(
ROBPrefetchingAlgCfg_Muon(flags,
"initialRoI", RoILinkName=
"initialRoI", ROBPrefetchingInputDecisions=allDecisions), sequenceName=seqName)
 
  400 if __name__ == 
"__main__":
 
  401     from AthenaConfiguration.AllConfigFlags 
import initConfigFlags
 
  402     from AthenaConfiguration.TestDefaults 
import defaultTestFiles, defaultGeometryTags
 
  405     flags.Trigger.forceEnableAllChains= 
True 
  406     flags.Input.Files = defaultTestFiles.RAW_RUN2
 
  407     flags.GeoModel.AtlasVersion = defaultGeometryTags.RUN2