Exemple #1
0
def createOutputStream( streamName, fileName = "", asAlg = False ):
   writingTool = AthenaPoolOutputStreamTool( streamName + "Tool" )
   writingTool.DataHeaderSatellites = [ "basic/:EventInfo#*" ]
   outputStream = AthenaOutputStream(
      streamName,
      WritingTool = writingTool,
      ItemList    = [ "EventInfo#*" ]
      )
   outputStream.MetadataStore = svcMgr.MetaDataStore
   outputStream.MetadataItemList = [ "EventStreamInfo#" + streamName, "IOVMetaDataContainer#*" ]
   if asAlg:
      from AthenaCommon.AlgSequence import AlgSequence
      topSequence = AlgSequence()
      topSequence += outputStream
   else:
      theApp.OutStreamType = "AthenaOutputStream"
      theApp.addOutputStream( outputStream )

   if fileName != "":
      outputStream.OutputFile = fileName
      from OutputStreamAthenaPoolConf import MakeEventStreamInfo 
      streamInfoTool = MakeEventStreamInfo( streamName + "_MakeEventStreamInfo" )
      streamInfoTool.Key = streamName
      outputStream.HelperTools = [ streamInfoTool ]
   return outputStream
Exemple #2
0
def createOutputStream(streamName,
                       fileName="",
                       asAlg=False,
                       noTag=False,
                       eventInfoKey="EventInfo",
                       decisionFilter="",
                       trigNavThinningSvc=None):
    if trigNavThinningSvc is None:
        trigNavThinningSvc = _trigNavThinningSvcs.get(streamName, None)

    # define athena output stream
    writingTool = AthenaOutputStreamTool(streamName + "Tool")
    outputStream = AthenaOutputStream(streamName,
                                      WritingTool=writingTool,
                                      ItemList=["EventInfo#*"])
    #outputStream.ItemList += [ "xAOD::EventInfo#*" ]
    outputStream.MetadataStore = svcMgr.MetaDataStore
    outputStream.MetadataItemList = [
        "EventStreamInfo#" + streamName, "IOVMetaDataContainer#*"
    ]

    ## get a handle on the default top-level algorithm sequence
    from AthenaCommon.AlgSequence import AlgSequence
    topSequence = AlgSequence()
    from AthenaCommon.AlgSequence import AthSequencer
    outSequence = AthSequencer("AthOutSeq")

    doTag = not noTag
    if doTag:
        if ('EventInfoTagBuilder/EventInfoTagBuilder'
                not in topSequence.getProperties()['Members']):
            key = "SimpleTag"
            # Tell tool to pick it up
            outputStream.WritingTool.AttributeListKey = key
            # build eventinfo attribute list
            from .OutputStreamAthenaPoolConf import EventInfoAttListTool, EventInfoTagBuilder
            EventInfoTagBuilder = EventInfoTagBuilder(
                AttributeList=key,
                EventInfoKey=eventInfoKey,
                FilterString=decisionFilter)
            from AthenaCommon.GlobalFlags import globalflags
            if globalflags.InputFormat() == 'bytestream':
                #No event-tag input in bytestream
                EventInfoTagBuilder.PropagateInput = False
            topSequence += EventInfoTagBuilder

    # decide where to put outputstream in sequencing
    if asAlg:
        outSequence += outputStream
    else:
        outSequence += outputStream

    if fileName != "":
        outputStream.OutputFile = fileName
        from .OutputStreamAthenaPoolConf import MakeEventStreamInfo
        streamInfoTool = MakeEventStreamInfo(streamName +
                                             "_MakeEventStreamInfo")
        streamInfoTool.Key = streamName
        streamInfoTool.EventInfoKey = eventInfoKey
        outputStream.HelperTools = [streamInfoTool]

    # Support for MT thinning.
    from AthenaServices.AthenaServicesConf import Athena__ThinningCacheTool
    tct = Athena__ThinningCacheTool('ThinningCacheTool_' + streamName,
                                    StreamName=streamName)
    if trigNavThinningSvc is not None:
        tct.TrigNavigationThinningSvc = trigNavThinningSvc
    outputStream.HelperTools += [tct]

    # Set the list of transient items based on what we know is in the transient
    # store.  The output algorithm will then declare input dependencies
    # for objects which are both listed here and in the ItemList.
    # (We do it like this because ItemList is typically configured to include
    # everything which might possibly be output.  If this gets cleaned up,
    # then we can remove this.)
    # Some builds don't include RecExConfig, so don't crash in that case.
    # FIXME: Rather than using ObjKeyStore, we could scan all algorithms
    # and look for write handles.
    try:
        tlist = []
        from RecExConfig.ObjKeyStore import objKeyStore
        for typ, klist in objKeyStore['transient'].getProperties().items():
            for k in klist:
                tlist.append(typ + '#' + k)
        outputStream.TransientItems += tlist
    except ImportError:
        pass

    return outputStream