Commit 1cac5a43 authored by Rafal Bielski's avatar Rafal Bielski
Browse files

Further fixes for trigger setup in reco transforms

- Move trigger MT output hacks from reconstruction domain to trigger domain
- Fix python memory allocation error when peeking BS file for ROD version
- Make sure all navigation and metadata is propagated to AOD for all workflows (data and MC)
parent 5007b9b3
......@@ -49,51 +49,23 @@ if hasattr(runArgs,"outputAODFile"):
rec.doWriteAOD.set_Value_and_Lock( True )
athenaCommonFlags.PoolAODOutput.set_Value_and_Lock( runArgs.outputAODFile )
# Begin temporary trigger block
from RecExConfig.ObjKeyStore import objKeyStore
if TriggerFlags.doMT():
recoLog.info("Scheduling temporary ESDtoAOD propagation of Trigger MT EDM collections")
recoLog.info("AOD content set according to the AODEDMSet flag: %s and EDM version (default setting) %d (for doMT() currently hardcoded to 3)",
TriggerFlags.AODEDMSet(), TriggerFlags.EDMDecodingVersion())
trigEDMListESD = {}
trigEDMListAOD = {}
from TrigEDMConfig.TriggerEDM import getTriggerEDMList
# !!! this needs to be changed!! currently hardcoded to run version 3 corresponding to the Run 3
#trigEDMListESD.update(getTriggerEDMList(TriggerFlags.ESDEDMSet(), TriggerFlags.EDMDecodingVersion()) )
trigEDMListESD.update(getTriggerEDMList(TriggerFlags.ESDEDMSet(), 3) )
objKeyStore.addManyTypesStreamESD( trigEDMListESD )
# !!! this needs to be changed!! currently hardcoded to run version 3 corresponding to the Run 3
#trigEDMListAOD.update(getTriggerEDMList(TriggerFlags.AODEDMSet(), TriggerFlags.EDMDecodingVersion()) )
trigEDMListAOD.update(getTriggerEDMList(TriggerFlags.AODEDMSet(), 3) )
objKeyStore.addManyTypesStreamAOD( trigEDMListAOD )
notIncludedInAOD = [element for element in trigEDMListAOD if element not in trigEDMListESD]
if (len(notIncludedInAOD)>0):
recoLog.warning ("In AOD list but not in ESD list: ")
recoLog.warning(notIncludedInAOD)
else:
recoLog.info("AOD EDM list is a subset of ESD list - good")
# We also want to propagate the navigation to ESD and AOD. For now, unconditionally
# Note: Not every TrigComposite collection is navigation, there are other use cases too.
# So in future we should filter more heavily than this too.
from PyUtils.MetaReaderPeeker import convert_itemList
rawCollections = convert_itemList(layout='#join')
for item in rawCollections:
if item.startswith("xAOD::TrigComposite"):
objKeyStore.addManyTypesStreamESD( [item] )
objKeyStore.addManyTypesStreamAOD( [item] )
# Don't run any trigger - only pass the HLT contents from ESD to AOD
from RecExConfig.RecAlgsFlags import recAlgs
recAlgs.doTrigger.set_Value_and_Lock( False )
rec.doTrigger.set_Value_and_Lock( False )
# Add HLT output
from TriggerJobOpts.HLTTriggerResultGetter import HLTTriggerResultGetter
hltOutput = HLTTriggerResultGetter()
# Add Trigger menu metadata
if rec.doFileMetaData():
from RecExConfig.ObjKeyStore import objKeyStore
metadataItems = [ "xAOD::TriggerMenuContainer#TriggerMenu",
"xAOD::TriggerMenuAuxContainer#TriggerMenuAux." ]
objKeyStore.addManyTypesMetaData( metadataItems )
else: # not TriggerFlags.doMT()
pass # See TriggerJobOpts/python/TriggerGetter.py for Run 2. Called by RecExCommon
if hasattr(runArgs,"outputTAGFile"):
# should be used as outputTAGFile_e2a=myTAG.root so that it does not trigger AODtoTAG
# if writing TAG file, need AOD object in any case
......
......@@ -81,56 +81,16 @@ if hasattr(runArgs,"inputRDO_TRIGFile"):
DQMonFlags.doHLTMon = False
DQMonFlags.useTrigger = False
DQMonFlags.doLVL1CaloMon = False
# Auto-configure EDM decoding version
from TriggerJobOpts.HLTTriggerResultGetter import EDMDecodingVersion
EDMDecodingVersion()
from AthenaCommon.KeyStore import CfgItemList, CfgKeyStore
# Configure HLT output
from TriggerJobOpts.HLTTriggerResultGetter import HLTTriggerResultGetter
hltOutput = HLTTriggerResultGetter()
# Add Trigger menu metadata
from RecExConfig.ObjKeyStore import objKeyStore
if TriggerFlags.doMT():
recoLog.info("Scheduling temporary ESDtoAOD propagation of Trigger MT EDM collections")
recoLog.info("AOD content set according to the AODEDMSet flag: %s and EDM version %d (currently hardcoded to 3)", TriggerFlags.AODEDMSet(), TriggerFlags.EDMDecodingVersion())
edmset = TriggerFlags.AODEDMSet()
recoLog.info(edmset)
trigEDMListESD = {}
trigEDMListAOD = {}
from TrigEDMConfig.TriggerEDM import getTriggerEDMList
# !!! this needs to be changed!! currently hardcoded to run version 3 corresponding to the Run 3
#trigEDMListESD.update(getTriggerEDMList(TriggerFlags.ESDEDMSet(), TriggerFlags.EDMDecodingVersion()) )
trigEDMListESD.update(getTriggerEDMList(TriggerFlags.ESDEDMSet(), 3) )
objKeyStore.addManyTypesStreamESD( trigEDMListESD )
# !!! this needs to be changed!! currently hardcoded to run version 3 corresponding to the Run 3
#trigEDMListAOD.update(getTriggerEDMList(TriggerFlags.AODEDMSet(), TriggerFlags.EDMDecodingVersion()) )
trigEDMListAOD.update(getTriggerEDMList(TriggerFlags.AODEDMSet(), 3) )
objKeyStore.addManyTypesStreamAOD( trigEDMListAOD )
notIncludedInAOD = [element for element in trigEDMListAOD if element not in trigEDMListESD]
if (len(notIncludedInAOD)>0):
recoLog.warning ("In AOD list but not in ESD list: ")
recoLog.warning(notIncludedInAOD)
else:
recoLog.info("AOD EDM list is a subset of ESD list - good")
# We also want to propagate the navigation to ESD and AOD. For now, unconditionally
# Note: Not every TrigComposite collection is navigation, there are other use cases too.
# So in future we should filter more heavily than this too.
from PyUtils.MetaReaderPeeker import convert_itemList
rawCollections = convert_itemList(layout='#join')
for item in rawCollections:
if item.startswith("xAOD::TrigComposite"):
objKeyStore.addManyTypesStreamESD( [item] )
objKeyStore.addManyTypesStreamAOD( [item] )
else: # not TriggerFlags.doMT()
_TriggerESDList = {}
_TriggerAODList = {}
from TrigEDMConfig.TriggerEDM import getTriggerEDMList
_TriggerAODList.update( getTriggerEDMList(TriggerFlags.AODEDMSet(), TriggerFlags.EDMDecodingVersion()) )
_TriggerESDList.update( getTriggerEDMList(TriggerFlags.ESDEDMSet(), TriggerFlags.EDMDecodingVersion()) )
objKeyStore.addManyTypesStreamESD( _TriggerESDList )
objKeyStore.addManyTypesStreamAOD( _TriggerAODList )
if rec.doFileMetaData():
metadataItems = [ "xAOD::TriggerMenuContainer#TriggerMenu",
"xAOD::TriggerMenuAuxContainer#TriggerMenuAux." ]
objKeyStore.addManyTypesMetaData( metadataItems )
# Configure other outputs
from TrigEDMConfig.TriggerEDM import getLvl1ESDList
from TrigEDMConfig.TriggerEDM import getLvl1AODList
from TrigEDMConfig.TriggerEDM import getTrigIDTruthList
......@@ -138,10 +98,6 @@ if hasattr(runArgs,"inputRDO_TRIGFile"):
objKeyStore.addManyTypesStreamAOD(getTrigIDTruthList(TriggerFlags.AODEDMSet()))
objKeyStore.addManyTypesStreamESD(getLvl1ESDList())
objKeyStore.addManyTypesStreamAOD(getLvl1AODList())
if rec.doFileMetaData():
metadataItems = [ "xAOD::TriggerMenuContainer#TriggerMenu",
"xAOD::TriggerMenuAuxContainer#TriggerMenuAux." ]
objKeyStore.addManyTypesMetaData( metadataItems )
if hasattr(runArgs,"inputRDO_FILTFile"):
rec.readRDO.set_Value_and_Lock( True )
......
......@@ -26,17 +26,23 @@ def EDMDecodingVersion():
import eformat
from libpyeformat_helper import SubDetector
bs = eformat.istream(inputFileName)
hltRobs = [robf for robf in bs[0].robs()[0] if robf.rob_source_id().subdetector_id()==SubDetector.TDAQ_HLT]
rodVersionM = -1
rodVersionL = -1
if len(hltRobs) == 0:
# Do an empty loop over all robs to work around memory allocation problem ATR-20480
for robf in bs[0].robs()[0]:
pass
# Find the first HLT ROBFragment in the first event
for robf in bs[0].robs()[0]:
if robf.rob_source_id().subdetector_id()==SubDetector.TDAQ_HLT:
rodVersionM = robf.rod_minor_version() >> 8
rodVersionL = robf.rod_minor_version() & 0xFF
log.debug("HLT ROD minor version from input file is %d.%d", rodVersionM, rodVersionL)
break
if rodVersionM < 0 or rodVersionL < 0:
log.warning("Cannot determine HLT ROD version from input file, falling back to runNumber-based decision")
else:
rodVersionM = hltRobs[0].rod_minor_version() >> 8
rodVersionL = hltRobs[0].rod_minor_version() & 0xFF
log.debug("HLT ROD minor version from input file is %d.%d", rodVersionM, rodVersionL)
if rodVersionM >= 1:
elif rodVersionM >= 1:
TriggerFlags.EDMDecodingVersion = 3
log.info("Decoding version set to 3, because running on BS file with HLT ROD version %d.%d", rodVersionM, rodVersionL)
return
......@@ -71,15 +77,24 @@ def EDMDecodingVersion():
else:
# POOL files: decide based on HLT output type present in file
from RecExConfig.ObjKeyStore import cfgKeyStore
from PyUtils.MetaReaderPeeker import convert_itemList
cfgKeyStore.addManyTypesInputFile(convert_itemList(layout='#join'))
TriggerFlags.doMergedHLTResult = True
if cfgKeyStore.isInInputFile( "HLT::HLTResult", "HLTResult_EF" ):
TriggerFlags.EDMDecodingVersion = 1
TriggerFlags.doMergedHLTResult = False
log.info("Decoding version set to 1, because HLTResult_EF found in pool file")
log.info("Decoding version set to 1, because HLTResult_EF found in POOL file")
elif cfgKeyStore.isInInputFile( "HLT::HLTResult", "HLTResult_HLT"):
TriggerFlags.EDMDecodingVersion = 2
log.info("Decoding version set to 2, because HLTResult_HLT found in POOL file")
elif cfgKeyStore.isInInputFile( "xAOD::TrigCompositeContainer", "HLTNav_Summary"):
TriggerFlags.EDMDecodingVersion = 3
log.info("Decoding version set to 3, because HLTNav_Summary found in POOL file")
elif rec.readAOD() and cfgKeyStore.isInInputFile( "xAOD::TrigNavigation", "TrigNavigation"):
# If running on AOD input (e.g. for monitoring), there is not HLTResult, so check for TrigNavigation
TriggerFlags.EDMDecodingVersion = 2
log.info("Decoding version set to 2, because TrigNavigation found in POOL file")
elif rec.readRDO():
# If running Trigger on RDO input (without previous trigger result), choose Run-2 or Run-3 based on doMT
if TriggerFlags.doMT():
......@@ -91,7 +106,6 @@ def EDMDecodingVersion():
else:
log.warning("Cannot recognise HLT EDM format, leaving default TriggerFlags.EDMDecodingVersion=%d", TriggerFlags.EDMDecodingVersion())
log.info("EDMDecoding set to %s based on HLT output type in POOL file", TriggerFlags.EDMDecodingVersion )
class xAODConversionGetter(Configured):
def configure(self):
......@@ -384,6 +398,17 @@ class HLTTriggerResultGetter(Configured):
else:
tdt = TrigDecisionGetter() # noqa: F841
# Temporary hack to add Run-3 navigation to ESD and AOD
if (rec.doESD() or rec.doAOD()) and TriggerFlags.EDMDecodingVersion() == 3:
# The hack with wildcards is needed for BS->ESD because we don't know the exact keys
# of HLT navigation containers before unpacking them from the BS event.
objKeyStore._store['streamESD'].allowWildCard(True)
objKeyStore._store['streamAOD'].allowWildCard(True)
objKeyStore.addManyTypesStreamESD(['xAOD::TrigCompositeContainer#HLTNav*',
'xAOD::TrigCompositeAuxContainer#HLTNav*'])
objKeyStore.addManyTypesStreamAOD(['xAOD::TrigCompositeContainer#HLTNav*',
'xAOD::TrigCompositeAuxContainer#HLTNav*'])
# TrigJetRec additions
if rec.doWriteESD():
objKeyStore.addStreamESD("JetKeyDescriptor","JetKeyMap")
......
......@@ -47,8 +47,9 @@ class TriggerGetter(Configured):
log.info("Basic configuration flags RecAlgsFlag.doTrigger: %d RecFlags.doTrigger: %d TriggerFlags.doTriggerConfigOnly %d", recAlgs.doTrigger(), rec.doTrigger(), TF.doTriggerConfigOnly() )
log.info("TriggerFlags: doL1Topo: %s, doLVL1: %s, doLVL2: %s, doEF: %s, doHLT: %s, doMT: %s", TF.doL1Topo(), TF.doLVL1(), TF.doLVL2(), TF.doEF(), TF.doHLT(), TF.doMT() )
if TF.doMT():
log.info("configuring MT Trigger, actually nothing happens for now")
# RDOtoRDOTrigger MT temporarily coded in the transform skeleton, so skip here
if TF.doMT() and rec.readRDO() and rec.doWriteRDO():
log.info("Nothing happens in TriggerGetter for RDOtoRDOTrigger MT")
return True
willGenerateMenu = recAlgs.doTrigger() and (TF.doLVL1() or TF.doLVL2() or TF.doEF() or TF.doHLT()) and not TF.doTriggerConfigOnly()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment