예제 #1
0
    def configure(self):
        from AthenaCommon.AlgSequence import AlgSequence
        topSequence = AlgSequence()

        #schedule xAOD conversions here
        from TrigBSExtraction.TrigBSExtractionConf import TrigHLTtoxAODConversion
        xaodconverter = TrigHLTtoxAODConversion()

        from TrigNavigation.TrigNavigationConfig import HLTNavigationOffline
        xaodconverter.Navigation = HLTNavigationOffline()

        from TrigEDMConfig.TriggerEDM import getPreregistrationList
        from TrigEDMConfig.TriggerEDM import getEFRun1BSList, getEFRun2EquivalentList, getL2Run1BSList, getL2Run2EquivalentList
        xaodconverter.Navigation.ClassesToPreregister = getPreregistrationList(
            TriggerFlags.EDMDecodingVersion())
        ## if TriggerFlags.EDMDecodingVersion() == 2:
        ##     #        if TriggerFlags.doMergedHLTResult():
        ##     #if EDMDecodingVersion() =='Run2': #FPP
        ##     xaodconverter.Navigation.ClassesToPreregister = getHLTPreregistrationList()
        ## else:
        ##     xaodconverter.Navigation.ClassesToPreregister = list(set(getL2PreregistrationList()+getEFPreregistrationList()+getHLTPreregistrationList()))

        #we attempt to convert the entire old navigation (L2+EF)
        #xaodconverter.BStoxAOD.ContainersToConvert = list(set(getL2PreregistrationList()+getEFPreregistrationList()))
        # we want only containers from Run 1 with the BS tag
        xaodconverter.BStoxAOD.ContainersToConvert = getL2Run1BSList(
        ) + getEFRun1BSList()
        xaodconverter.BStoxAOD.NewContainers = getL2Run2EquivalentList(
        ) + getEFRun2EquivalentList()

        xaodconverter.HLTResultKey = "HLTResult_EF"
        topSequence += xaodconverter

        # define list of HLT xAOD containers to be written to the output root file
        # (previously this was defined in HLTTriggerResultGetter def configure)
        from TrigEDMConfig.TriggerEDM import getTriggerEDMList
        self.xaodlist = {}
        self.xaodlist.update(getTriggerEDMList(TriggerFlags.ESDEDMSet(), 2))

        return True
예제 #2
0
    topSequence.TrigDecMaker.doHLT=False
elif TriggerFlags.dataTakingConditions()=='HltOnly':
    from AthenaCommon.AlgSequence import AlgSequence
    topSequence.TrigDecMaker.doL1=False
# Decide based on the run number whether to assume a merged, or a
# split HLT:
if not TriggerFlags.doMergedHLTResult():
    topSequence.TrigDecMaker.doHLT = False
else:
    topSequence.TrigDecMaker.doL2 = False
    topSequence.TrigDecMaker.doEF = False

_TriggerESDList = {}
_TriggerAODList = {}
from TrigEDMConfig.TriggerEDM import getTriggerEDMList
_TriggerESDList.update( getTriggerEDMList(TriggerFlags.ESDEDMSet(),  TriggerFlags.EDMDecodingVersion()) )
_TriggerAODList.update( getTriggerEDMList(TriggerFlags.AODEDMSet(),  TriggerFlags.EDMDecodingVersion()) )

def preplist(input):
   triglist = []
   for k,val in input.iteritems():
      for j in val:
         triglist.append(k + "#" + j)
   return triglist

StreamRDO.ItemList += ["HLT::HLTResult#HLTResult_HLT"]
StreamRDO.ItemList += ["TrigDec::TrigDecision#TrigDecision"]
StreamRDO.ItemList += ["TrigInDetTrackTruthMap#*"]
StreamRDO.ItemList += preplist(_TriggerESDList)
StreamRDO.ItemList += preplist(_TriggerAODList)
from TrigEDMConfig.TriggerEDM import getLvl1ESDList
예제 #3
0
#====================================================================
# AUGMENTATION TOOLS 
#====================================================================
# CREATE THE DERIVATION KERNEL ALGORITHM AND PASS THE ABOVE TOOLS  
#====================================================================
# The name of the kernel (TRIG2 in this case) must be unique to this 
# derivation
from DerivationFrameworkCore.DerivationFrameworkCoreConf import DerivationFramework__DerivationKernel
DerivationFrameworkJob += CfgMgr.DerivationFramework__DerivationKernel("TRIG4Kernel")

# First define the content list from TriggerEDM

# Configure collection list via TriggerEDM.py
from TrigEDMConfig.TriggerEDM import getTriggerEDMList
edmlist=[]
for item in getTriggerEDMList('AODSUPERSLIM',2):
    edmlist.extend(getTriggerEDMList('AODSUPERSLIM',2)[item])
edmlist.remove('TrigNavigation')
edmlist.remove('TrigConfKeys')
#from DerivationFrameworkCore.CompulsoryContent import *
#edmlist(set(CompulsoryTriggerNavigation))
#edmlist(set())
#====================================================================
# SET UP STREAM   
#====================================================================
# SKIMMING
# The base name (DAOD_TRIG4 here) must match the string in 
# DerivationFrameworkProdFlags (in DerivationFrameworkCore) 
streamName = derivationFlags.WriteDAOD_TRIG4Stream.StreamName
fileName   = buildFileName( derivationFlags.WriteDAOD_TRIG4Stream )
TRIG4Stream = MSMgr.NewPoolRootStream( streamName, fileName )
예제 #4
0
    def configure(self):

        log = logging.getLogger("HLTTriggerResultGetter.py")
        from RecExConfig.ObjKeyStore import objKeyStore

        # set EDMDecodingVersion
        EDMDecodingVersion()

        # Set AODFULL for data unless it was set explicitly already
        if TriggerFlags.AODEDMSet.isDefault() and globalflags.DataSource(
        ) == 'data':
            TriggerFlags.AODEDMSet = 'AODFULL'

        from AthenaCommon.AlgSequence import AlgSequence
        topSequence = AlgSequence()
        log.info("BS unpacking (TF.readBS): %d", TriggerFlags.readBS())
        if TriggerFlags.readBS():
            if TriggerFlags.EDMDecodingVersion() <= 2:
                bs = ByteStreamUnpackGetterRun2()  # noqa: F841
            else:
                bs = ByteStreamUnpackGetter()  # noqa: F841

        xAODContainers = {}
        #        if not recAlgs.doTrigger():      #only convert when running on old data
        if TriggerFlags.EDMDecodingVersion() == 1:
            xaodcnvrt = xAODConversionGetter()
            xAODContainers = xaodcnvrt.xaodlist

        if recAlgs.doTrigger() or TriggerFlags.doTriggerConfigOnly():
            if TriggerFlags.EDMDecodingVersion() <= 2:
                tdt = TrigDecisionGetterRun2()  # noqa: F841
            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")
            objKeyStore.addStreamESD("JetMomentMap", "TrigJetRecMomentMap")

        if rec.doWriteAOD():
            objKeyStore.addStreamAOD("JetKeyDescriptor", "JetKeyMap")
            objKeyStore.addStreamAOD("JetMomentMap", "TrigJetRecMomentMap")

        # ID truth
        if not rec.readESD() and (not rec.readAOD()) and TriggerFlags.doID() \
                and rec.doTruth():
            try:
                from TrigInDetTruthAlgs.TrigInDetTruthAlgsConfig import \
                    TrigIDTruthMaker
                topSequence += TrigIDTruthMaker()
            except Exception:
                log.warning("Couldn't set up the trigger ID truth maker")
                pass

        if rec.doESD() or rec.doAOD():
            from TrigEDMConfig.TriggerEDM import getTrigIDTruthList
            objKeyStore.addManyTypesStreamESD(
                getTrigIDTruthList(TriggerFlags.ESDEDMSet()))
            objKeyStore.addManyTypesStreamAOD(
                getTrigIDTruthList(TriggerFlags.AODEDMSet()))

        if (rec.doESD() or rec.doAOD()) and TriggerFlags.writeL1TopoValData():
            objKeyStore.addManyTypesStreamESD([
                'xAOD::TrigCompositeContainer#HLT_xAOD__TrigCompositeContainer_L1TopoValData',
                'xAOD::TrigCompositeAuxContainer#HLT_xAOD__TrigCompositeContainer_L1TopoValDataAux.'
            ])
            objKeyStore.addManyTypesStreamAOD([
                'xAOD::TrigCompositeContainer#HLT_xAOD__TrigCompositeContainer_L1TopoValData',
                'xAOD::TrigCompositeAuxContainer#HLT_xAOD__TrigCompositeContainer_L1TopoValDataAux.'
            ])
            log.debug(
                "HLT_xAOD__TrigCompositeContainer_L1TopoValData(Aux.) for L1Topo validation added to the data."
            )

        if rec.doAOD() or rec.doWriteAOD():
            # schedule the RoiDescriptorStore conversion
            # log.warning( "HLTTriggerResultGetter - setting up RoiWriter" )
            roiWriter = RoiWriter()
            # Add fictional input to ensure data dependency in AthenaMT
            roiWriter.ExtraInputs += [("TrigBSExtractionOutput",
                                       "StoreGateSvc+TrigBSExtractionOutput")]
            topSequence += roiWriter
            # write out the RoiDescriptorStores
            from TrigEDMConfig.TriggerEDMRun2 import TriggerRoiList
            objKeyStore.addManyTypesStreamAOD(TriggerRoiList)

        #Are we adding operational info objects in ESD?
        added = self._AddOPIToESD()
        if added:
            log.debug(
                "Operational Info object HLT_EXPRESS_OPI_HLT with extra information about express stream prescaling added to the data."
            )

        # ESD objects definitions
        _TriggerESDList = {}

        from TrigEDMConfig.TriggerEDM import getTriggerEDMList
        # we have to store xAOD containers in the root file, NOT AOD,
        # if the xAOD container list is not empty
        if (xAODContainers):
            _TriggerESDList.update(xAODContainers)
        else:
            _TriggerESDList.update(
                getTriggerEDMList(TriggerFlags.ESDEDMSet(),
                                  TriggerFlags.EDMDecodingVersion()))

        log.info(
            "ESD content set according to the ESDEDMSet flag: %s and EDM version %d",
            TriggerFlags.ESDEDMSet(), TriggerFlags.EDMDecodingVersion())

        # AOD objects choice
        _TriggerAODList = {}

        #from TrigEDMConfig.TriggerEDM import getAODList
        _TriggerAODList.update(
            getTriggerEDMList(TriggerFlags.AODEDMSet(),
                              TriggerFlags.EDMDecodingVersion()))

        log.info(
            "AOD content set according to the AODEDMSet flag: %s and EDM version %d",
            TriggerFlags.AODEDMSet(), TriggerFlags.EDMDecodingVersion())

        log.debug("ESD EDM list: %s", _TriggerESDList)
        log.debug("AOD EDM list: %s", _TriggerAODList)

        # Highlight what is in AOD list but not in ESD list, as this can cause
        # the "different number of entries in branch" problem, when it is in the
        # AOD list but the empty container per event is not created
        # Just compares keys of dicts, which are the class names, not their string keys in StoreGate
        not_in = [
            element for element in _TriggerAODList
            if element not in _TriggerESDList
        ]
        if (len(not_in) > 0):
            log.warning("In AOD list but not in ESD list: ")
            log.warning(not_in)
        else:
            log.info("AOD list is subset of ESD list - good.")

        def _addSlimming(stream, edm):
            from TrigNavTools.TrigNavToolsConfig import navigationThinningSvc

            edmlist = list(y.split('-')[0] for x in edm.values()
                           for y in x)  #flatten names

            svc = navigationThinningSvc({
                'name': 'HLTNav_%s' % stream,
                'mode': 'cleanup',
                'result': 'HLTResult_HLT',
                'features': edmlist
            })

            from OutputStreamAthenaPool.CreateOutputStreams import registerTrigNavThinningSvc
            registerTrigNavThinningSvc(stream, svc)

            log.info("Configured slimming of HLT for %s", stream)
            print(svc)  # noqa: ATL901
            del edmlist

        if TriggerFlags.doNavigationSlimming() and rec.readRDO(
        ) and rec.doWriteAOD():
            _addSlimming('StreamAOD',
                         _TriggerESDList)  #Use ESD item list also for AOD!
            log.info("configured navigation slimming for AOD output")

        if TriggerFlags.doNavigationSlimming() and rec.readRDO(
        ) and rec.doWriteESD():
            _addSlimming('StreamESD', _TriggerESDList)
            log.info("configured navigation slimming for ESD output")

        objKeyStore.addManyTypesStreamESD(_TriggerESDList)
        objKeyStore.addManyTypesStreamAOD(_TriggerAODList)

        return True
예제 #5
0
# AUGMENTATION TOOLS
#====================================================================
# CREATE THE DERIVATION KERNEL ALGORITHM AND PASS THE ABOVE TOOLS
#====================================================================
# The name of the kernel (TRIG2 in this case) must be unique to this
# derivation
from DerivationFrameworkCore.DerivationFrameworkCoreConf import DerivationFramework__DerivationKernel
DerivationFrameworkJob += CfgMgr.DerivationFramework__DerivationKernel(
    "TRIG2Kernel")

# First define the content list from TriggerEDM

# Configure collection list via TriggerEDM.py
from TrigEDMConfig.TriggerEDM import getTriggerEDMList
edmlist = []
for item in getTriggerEDMList('AODFULL', 2):
    edmlist.extend(getTriggerEDMList('AODFULL', 2)[item])
edmlist.remove('TrigNavigation')
edmlist.remove('TrigConfKeys')
#from DerivationFrameworkCore.CompulsoryContent import *
#edmlist(set(CompulsoryTriggerNavigation))
#edmlist(set())
#====================================================================
# SET UP STREAM
#====================================================================
# SKIMMING
# The base name (DAOD_TRIG2 here) must match the string in
# DerivationFrameworkProdFlags (in DerivationFrameworkCore)
streamName = derivationFlags.WriteDAOD_TRIG2Stream.StreamName
fileName = buildFileName(derivationFlags.WriteDAOD_TRIG2Stream)
TRIG2Stream = MSMgr.NewPoolRootStream(streamName, fileName)
예제 #6
0
    from xAODTriggerCnv.xAODTriggerCnvConf import xAODMaker__TrigDecisionCnvAlg
    alg = xAODMaker__TrigDecisionCnvAlg()
    alg.AODKey = "TrigDecision"
    alg.xAODKey = "xTrigDecision"
    topSequence.insert(idx + 1, alg)
    from xAODTriggerCnv.xAODTriggerCnvConf import xAODMaker__TrigNavigationCnvAlg
    trigNavCnv = xAODMaker__TrigNavigationCnvAlg()
    trigNavCnv.doL2 = False
    trigNavCnv.doEF = False
    trigNavCnv.doHLT = True
    topSequence.insert(idx + 2, trigNavCnv)
    _TriggerESDList = {}
    _TriggerAODList = {}
    from TrigEDMConfig.TriggerEDM import getTriggerEDMList
    _TriggerESDList.update(
        getTriggerEDMList(TriggerFlags.ESDEDMSet(),
                          TriggerFlags.EDMDecodingVersion()))
    _TriggerAODList.update(
        getTriggerEDMList(TriggerFlags.AODEDMSet(),
                          TriggerFlags.EDMDecodingVersion()))

    _streamRDO.ItemList += ["HLT::HLTResult#HLTResult_HLT"]
    _streamRDO.ItemList += ["TrigDec::TrigDecision#TrigDecision"]
    _streamRDO.ItemList += ["TrigInDetTrackTruthMap#*"]
    _streamRDO.ItemList += preplist(_TriggerESDList)
    _streamRDO.ItemList += preplist(_TriggerAODList)
    from TrigEDMConfig.TriggerEDM import getLvl1ESDList
    _streamRDO.ItemList += preplist(getLvl1ESDList())
    from TrigEDMConfig.TriggerEDM import getLvl1AODList
    _streamRDO.ItemList += preplist(getLvl1AODList())
    _streamRDO.MetadataItemList += [
        "xAOD::TriggerMenuContainer#*", "xAOD::TriggerMenuAuxContainer#*"
예제 #7
0
def triggerPOOLOutputCfg(flags, decObj, decObjHypoOut, edmSet):
    # Get the list of output collections from TriggerEDM
    from TrigEDMConfig.TriggerEDM import getTriggerEDMList
    edmList = getTriggerEDMList(edmSet, flags.Trigger.EDMDecodingVersion)

    # Build the output ItemList
    itemsToRecord = []
    for edmType, edmKeys in six.iteritems (edmList):
        itemsToRecord.extend([edmType+'#'+collKey for collKey in edmKeys])

    # Add decision containers (navigation)
    for item in decObj:
        dynamic = '.-' # Exclude dynamic
        if item in decObjHypoOut:
            dynamic = '.' # Include dynamic
        itemsToRecord.append('xAOD::TrigCompositeContainer#{:s}'.format(item))
        itemsToRecord.append('xAOD::TrigCompositeAuxContainer#{:s}Aux{:s}'.format(item, dynamic))

    # Add EventInfo
    itemsToRecord.append('xAOD::EventInfo#EventInfo')
    itemsToRecord.append('xAOD::EventAuxInfo#EventInfoAux.')

    # Create OutputStream
    outputType = ''
    if flags.Output.doWriteRDO:
        outputType = 'RDO'
    if flags.Output.doWriteESD:
        outputType = 'ESD'
    if flags.Output.doWriteAOD:
        outputType = 'AOD'
    from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
    acc = OutputStreamCfg(flags, outputType, ItemList=itemsToRecord, disableEventTag=True)
    streamAlg = acc.getEventAlgo("OutputStream"+outputType)

    # Keep input RDO objects in the output RDO_TRIG file
    if flags.Output.doWriteRDO:
        streamAlg.TakeItemsFromInput = True

    # Produce trigger bits
    bitsmaker = CompFactory.TriggerBitsMakerTool()
    decmaker = CompFactory.getComp("TrigDec::TrigDecisionMakerMT")("TrigDecMakerMT", BitsMakerTool = bitsmaker)
    acc.addEventAlgo( decmaker )

    # Produce trigger metadata
    menuwriter = CompFactory.getComp("TrigConf::xAODMenuWriterMT")()
    menuwriter.IsHLTJSONConfig = True
    menuwriter.IsL1JSONConfig = True
    acc.addEventAlgo( menuwriter )

    # Add metadata to the output stream
    streamAlg.MetadataItemList += [ "xAOD::TriggerMenuContainer#*", "xAOD::TriggerMenuAuxContainer#*" ]

    # Ensure OutputStream runs after TrigDecisionMakerMT and xAODMenuWriterMT
    streamAlg.ExtraInputs += [
        ("xAOD::TrigDecision", decmaker.TrigDecisionKey),
        ("xAOD::TrigConfKeys", menuwriter.EventObjectName)]

    # Produce xAOD L1 RoIs from RoIBResult
    from AnalysisTriggerAlgs.AnalysisTriggerAlgsCAConfig import RoIBResultToxAODCfg
    xRoIBResultAcc, xRoIBResultOutputs = RoIBResultToxAODCfg(flags, acc.getSequence().name)
    acc.merge(xRoIBResultAcc)
    # Ensure outputs are produced before streamAlg runs
    streamAlg.ExtraInputs += xRoIBResultOutputs

    return acc
예제 #8
0
    def configure(self):

        log = logging.getLogger("HLTTriggerResultGetter.py")
        from RecExConfig.ObjKeyStore import objKeyStore

        # set EDMDecodingVersion
        EDMDecodingVersion()

        # Set AODFULL for data unless it was set explicitly already
        if TriggerFlags.AODEDMSet.isDefault() and globalflags.DataSource()=='data':
            TriggerFlags.AODEDMSet = 'AODFULL'
            
        from AthenaCommon.AlgSequence import AlgSequence
        topSequence = AlgSequence()
        log.info("BS unpacking (TF.readBS): %d" % TriggerFlags.readBS() )
        if TriggerFlags.readBS():
            bs = ByteStreamUnpackGetter()

        xAODContainers = {}
#        if not recAlgs.doTrigger():      #only convert when running on old data
        if TriggerFlags.EDMDecodingVersion()==1:
            xaodcnvrt = xAODConversionGetter()
            xAODContainers = xaodcnvrt.xaodlist

        if recAlgs.doTrigger() or TriggerFlags.doTriggerConfigOnly():
            tdt = TrigDecisionGetter()

        # TrigJetRec additions
        if rec.doWriteESD():
            objKeyStore.addStreamESD("JetKeyDescriptor","JetKeyMap")
            objKeyStore.addStreamESD("JetMomentMap","TrigJetRecMomentMap")

        if rec.doWriteAOD():
            objKeyStore.addStreamAOD("JetKeyDescriptor","JetKeyMap")
            objKeyStore.addStreamAOD("JetMomentMap","TrigJetRecMomentMap")
                    
        # ID truth
        if not rec.readESD() and (not rec.readAOD()) and TriggerFlags.doID() \
                and rec.doTruth():
            try:
                from TrigInDetTruthAlgs.TrigInDetTruthAlgsConfig import \
                    TrigIDTruthMaker
                topSequence += TrigIDTruthMaker()
            except Exception:
                log.warning( "Couldn't set up the trigger ID truth maker" )
                pass

        if rec.doESD() or rec.doAOD():
            from TrigEDMConfig.TriggerEDM import getTrigIDTruthList
            objKeyStore.addManyTypesStreamESD(getTrigIDTruthList(TriggerFlags.ESDEDMSet()))
            objKeyStore.addManyTypesStreamAOD(getTrigIDTruthList(TriggerFlags.AODEDMSet()))

        if (rec.doESD() or rec.doAOD()) and TriggerFlags.writeL1TopoValData():
            objKeyStore.addManyTypesStreamESD(['xAOD::TrigCompositeContainer#HLT_xAOD__TrigCompositeContainer_L1TopoValData',
                                               'xAOD::TrigCompositeAuxContainer#HLT_xAOD__TrigCompositeContainer_L1TopoValDataAux.'])
            objKeyStore.addManyTypesStreamAOD(['xAOD::TrigCompositeContainer#HLT_xAOD__TrigCompositeContainer_L1TopoValData',
                                               'xAOD::TrigCompositeAuxContainer#HLT_xAOD__TrigCompositeContainer_L1TopoValDataAux.'])
            log.debug("HLT_xAOD__TrigCompositeContainer_L1TopoValData(Aux.) for L1Topo validation added to the data.")

        if rec.doAOD() or rec.doWriteAOD():
            # schedule the RoiDescriptorStore conversion
            # log.warning( "HLTTriggerResultGetter - setting up RoiWriter" )
            topSequence += RoiWriter()
            # write out the RoiDescriptorStores
            from TrigEDMConfig.TriggerEDM import TriggerRoiList
            objKeyStore.addManyTypesStreamAOD( TriggerRoiList )

        #Are we adding operational info objects in ESD?
        added=self._AddOPIToESD()
        if added:
            log.debug("Operational Info object HLT_EXPRESS_OPI_HLT with extra information about express stream prescaling added to the data.")
        


        # ESD objects definitions
        _TriggerESDList = {}

        from TrigEDMConfig.TriggerEDM import getTriggerEDMList 
        # we have to store xAOD containers in the root file, NOT AOD,
        # if the xAOD container list is not empty
        if(xAODContainers):
            _TriggerESDList.update( xAODContainers )
        else:
            _TriggerESDList.update( getTriggerEDMList(TriggerFlags.ESDEDMSet(),  TriggerFlags.EDMDecodingVersion()) ) 
        
        log.info("ESD content set according to the ESDEDMSet flag: %s and EDM version %d" % (TriggerFlags.ESDEDMSet() ,TriggerFlags.EDMDecodingVersion()) )

        # AOD objects choice
        _TriggerAODList = {}
        
        #from TrigEDMConfig.TriggerEDM import getAODList    
        _TriggerAODList.update( getTriggerEDMList(TriggerFlags.AODEDMSet(),  TriggerFlags.EDMDecodingVersion()) ) 

        log.info("AOD content set according to the AODEDMSet flag: %s and EDM version %d" % (TriggerFlags.AODEDMSet(),TriggerFlags.EDMDecodingVersion()) )

        log.debug("ESD EDM list: %s", _TriggerESDList)
        log.debug("AOD EDM list: %s", _TriggerAODList)
        
        # Highlight what is in AOD list but not in ESD list, as this can cause
        # the "different number of entries in branch" problem, when it is in the
        # AOD list but the empty container per event is not created
        # Just compares keys of dicts, which are the class names, not their string keys in StoreGate
        not_in = [ element for element in  _TriggerAODList if element not in _TriggerESDList ]
        if (len(not_in)>0):
            log.warning("In AOD list but not in ESD list: ")
            log.warning(not_in)
        else:
            log.info("AOD list is subset of ESD list - good.")


        def _addSlimming(stream, thinningSvc, edm):
            from AthenaCommon.AlgSequence import AlgSequence 
            topSequence = AlgSequence()
            from TrigNavTools.TrigNavToolsConf import HLT__StreamTrigNavSlimming, HLT__TrigNavigationSlimming
            from TrigNavTools.TrigNavToolsConfig import navigationSlimming

            edmlist = list(y.split('-')[0] for x in edm.values() for y in x) #flatten names
          
            # from HLT result drop unrecorded features
            # slimmerHLT = HLT__StreamTrigNavSlimming('HLTNavSlimmer_%s'%stream)
            slimmerHLT = HLT__TrigNavigationSlimming('TrigNavigationSlimmer_%s'%stream)
            tHLT = navigationSlimming({'name':'HLTNav_%s'%stream, 'mode':'cleanup', 
                                                          'ThinningSvc':thinningSvc, 'result':'HLTResult_HLT',
                                                          'features':edmlist})
            #tHLT.SlimmingTool.OutputLevel=DEBUG
            tHLT.ActInPlace=True
            slimmerHLT.ThinningTool = tHLT
            print slimmerHLT.ThinningTool
            topSequence += slimmerHLT
            log.info("Configured slimming of HLT")
            del edmlist


        from AthenaCommon.AppMgr import ServiceMgr as svcMgr
        from AthenaServices.Configurables import ThinningSvc, createThinningSvc
        
        _doSlimming = True
        if _doSlimming and rec.readRDO() and rec.doWriteAOD():
            if not hasattr(svcMgr, 'ThinningSvc'): # if the default is there it is configured for AODs
                svcMgr += ThinningSvc(name='ThinningSvc', Streams=['StreamAOD'])             
            _addSlimming('StreamAOD', svcMgr.ThinningSvc, _TriggerESDList ) #Use ESD item list also for AOD!
            log.info("configured navigation slimming for AOD output")
            
        if _doSlimming and rec.readRDO() and rec.doWriteESD(): #rec.doWriteESD() and not rec.readESD(): 
            if not  hasattr(svcMgr, 'ESDThinningSvc'):
                svcMgr += ThinningSvc(name='ESDThinningSvc', Streams=['StreamESD']) # the default is configured for AODs
            _addSlimming('StreamESD', svcMgr.ESDThinningSvc, _TriggerESDList )                
            log.info("configured navigation slimming for ESD output")              
            



        objKeyStore.addManyTypesStreamESD( _TriggerESDList )                        
        objKeyStore.addManyTypesStreamAOD( _TriggerAODList )        
            
        return True