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 _do_metadata(self):
        """
        Setup and add metadata to the HIT file.
        """
        import AtlasG4Eng
        AtlasG4Eng.G4Eng.log.verbose(
            'AtlasSimSkeleton._do_metadata :: starting')
        from G4AtlasApps.SimFlags import simFlags
        if not simFlags.ISFRun:
            AtlasG4Eng.G4Eng.log.debug(
                'AtlasSimSkeleton._do_metadata :: recording metadata')
            from G4AtlasApps.G4Atlas_Metadata import createSimulationParametersMetadata
            createSimulationParametersMetadata()
            from AthenaCommon.AthenaCommonFlags import athenaCommonFlags
            if not athenaCommonFlags.PoolHitsOutput.statusOn:
                AtlasG4Eng.G4Eng.log.info(
                    'AtlasSimSkeleton._do_metadata :: no output HITS file, so no metadata writing required.'
                )
            else:
                from AthenaServices.AthenaServicesConf import AthenaOutputStream
                stream1_SimMetaData = AthenaOutputStream(
                    "StreamHITS_SimMetaData")
                stream1_SimMetaData.ItemList += ["IOVMetaDataContainer#*"]

        AtlasG4Eng.G4Eng.log.verbose('AtlasSimSkeleton._do_metadata :: done')
Exemple #3
0
    def _do_metadata(self):
        """
        Setup and add metadata to the HIT file
        """
        import AtlasG4Eng
        AtlasG4Eng.G4Eng.log.verbose(
            'TBSimSkeleton :: _do_metadata :: starting')
        from G4AtlasApps.G4Atlas_Metadata import createTBSimulationParametersMetadata
        createTBSimulationParametersMetadata()

        from AthenaCommon.AthenaCommonFlags import athenaCommonFlags
        if (athenaCommonFlags.PoolHitsOutput.statusOn):
            AtlasG4Eng.G4Eng.log.info('SimCtbKernel : Recording Metadata')
            from AthenaServices.AthenaServicesConf import AthenaOutputStream
            stream1_SimMetaData = AthenaOutputStream("StreamHITS_SimMetaData")
            stream1_SimMetaData.ItemList += ["IOVMetaDataContainer#*"]
            AtlasG4Eng.G4Eng.log.info('SimSkeleton :: _do_metadata done')
        else:
            AtlasG4Eng.G4Eng.log.info(
                'SimSkeleton :: _do_metadata nothing done')
    def __init__(self, StreamName, FileName):
        AugmentedStreamBase.__init__(self, StreamName)

        #General setup
        from AthenaCommon.AppMgr import theApp
        svcMgr = theApp.serviceMgr()
        from AthenaCommon.AlgSequence import AlgSequence
        topSequence = AlgSequence()

        # BS OutputStream Tool
        from ByteStreamCnvSvc.ByteStreamCnvSvcConf import ByteStreamEventStorageOutputSvc, ByteStreamOutputStreamCopyTool
        self.bsCopyTool = ByteStreamOutputStreamCopyTool(
            "OutputStreamBSCopyTool")
        svcMgr.ToolSvc += self.bsCopyTool

        #default output directory
        import commands
        cmd = 'pwd'
        (statusCode, outDir) = commands.getstatusoutput(cmd)
        outDir += "/"

        # BS output Svc
        from ByteStreamCnvSvc.ByteStreamCnvSvcConf import ByteStreamEventStorageOutputSvc
        self.bsOutputSvc = ByteStreamEventStorageOutputSvc(
            "BSESOutputSvc" + StreamName,
            OutputDirectory=outDir,
            SimpleFileName=FileName)
        svcMgr += self.bsOutputSvc

        # Set BS OutputSvc/InputSvc to BS OutputStream Tool
        self.bsCopyTool.ByteStreamOutputSvc = self.bsOutputSvc
        self.bsCopyTool.ByteStreamInputSvc = svcMgr.ByteStreamInputSvc

        # create AthenaOutputStream for BS Copy and add it to topSequence
        from AthenaServices.AthenaServicesConf import AthenaOutputStream
        self.Stream = AthenaOutputStream(StreamName,
                                         WritingTool=self.bsCopyTool)

        #topSequence += self.Stream #<-- coherent with asAlg=False in OutputStreamAthenaPool.py
        theApp.addOutputStream(self.Stream)
        return
Exemple #5
0
def createOutputStream(streamName, fileName="", asAlg=False):
    from AthenaServices.AthenaServicesConf import AthenaOutputStream
    theApp.OutStreamType = "AthenaOutputStream"
    if asAlg:
        from AthenaCommon.AlgSequence import AlgSequence
        topSequence = AlgSequence()

    # Now do standard output stream
    writingTool1 = AthenaRootOutputStreamTool(streamName + "Tool")
    writingTool1.TreeName = "CollectionTree"
    outputStream = AthenaOutputStream(streamName,
                                      WritingTool=writingTool1,
                                      ItemList=["EventInfo#*"])
    if asAlg:
        from AthenaCommon.AlgSequence import AlgSequence
        topSequence += outputStream
    else:
        theApp.addOutputStream(outputStream)

    if fileName != "":
        outputStream.OutputFile = fileName

    return outputStream
    if i == 32: bsCopyTool.ByteStreamOutputSvc32 = bsOutputSvc
    if i == 33: bsCopyTool.ByteStreamOutputSvc33 = bsOutputSvc
    if i == 34: bsCopyTool.ByteStreamOutputSvc34 = bsOutputSvc
    if i == 35: bsCopyTool.ByteStreamOutputSvc35 = bsOutputSvc
    if i == 36: bsCopyTool.ByteStreamOutputSvc36 = bsOutputSvc
    if i == 37: bsCopyTool.ByteStreamOutputSvc37 = bsOutputSvc
    if i == 38: bsCopyTool.ByteStreamOutputSvc38 = bsOutputSvc
    if i == 39: bsCopyTool.ByteStreamOutputSvc39 = bsOutputSvc
    if i == 40: bsCopyTool.ByteStreamOutputSvc40 = bsOutputSvc
    if i == 41: bsCopyTool.ByteStreamOutputSvc41 = bsOutputSvc
    if i == 42: bsCopyTool.ByteStreamOutputSvc42 = bsOutputSvc
    if i == 43: bsCopyTool.ByteStreamOutputSvc43 = bsOutputSvc
    if i == 44: bsCopyTool.ByteStreamOutputSvc44 = bsOutputSvc
    if i == 45: bsCopyTool.ByteStreamOutputSvc45 = bsOutputSvc
    if i == 46: bsCopyTool.ByteStreamOutputSvc46 = bsOutputSvc
    if i == 47: bsCopyTool.ByteStreamOutputSvc47 = bsOutputSvc
    if i == 48: bsCopyTool.ByteStreamOutputSvc48 = bsOutputSvc
    if i == 49: bsCopyTool.ByteStreamOutputSvc49 = bsOutputSvc

# BS InputStream
bsCopyTool.ByteStreamInputSvc = svcMgr.ByteStreamInputSvc

# create AthenaOutputStream for BS Copy
from AthenaServices.AthenaServicesConf import AthenaOutputStream
OutputStreamBSCopy = AthenaOutputStream("OutputStreamBSCopy",
                                        WritingTool=bsCopyTool)
topSequence += OutputStreamBSCopy

# apply prescale to the OutputStream
OutputStreamBSCopy.AcceptAlgs = ["BSFilter"]
Exemple #7
0
    ServiceMgr += AGDD2Geo

## Add configured GeoModelSvc to service manager
ServiceMgr += gms

## AtlasSimSkeleton._do_metadata
from G4AtlasApps.SimFlags import simFlags
if not simFlags.ISFRun:
    from G4AtlasApps.G4Atlas_Metadata import createSimulationParametersMetadata
    createSimulationParametersMetadata()
    from AthenaCommon.AthenaCommonFlags import athenaCommonFlags
    if not athenaCommonFlags.PoolHitsOutput.statusOn:
        print 'AtlasSimSkeleton._do_metadata :: no output HITS file, so no metadata writing required.'
    else:
        from AthenaServices.AthenaServicesConf import AthenaOutputStream
        stream1_SimMetaData = AthenaOutputStream("StreamHITS_SimMetaData")
        stream1_SimMetaData.ItemList += ["IOVMetaDataContainer#*"]

if not simFlags.ISFRun:

    def hits_persistency():
        """ HITS POOL file persistency
        """
        from G4AtlasApps.SimFlags import simFlags
        from AthenaCommon.DetFlags import DetFlags
        from AthenaCommon.AthenaCommonFlags import athenaCommonFlags
        from AthenaPoolCnvSvc.WriteAthenaPool import AthenaPoolOutputStream

        ## Not yet understood, but need to treat StreamHITS as alg in Hive.
        ## Seems to also work fine outside of Hive, but to be extra safe I'm
        ## only changing it in Hive.
Exemple #8
0
include("InDetRecExample/InDetRecCabling.py")

if DetFlags.haveRIO.pixel_on():
    ByteStreamCnvSvc.InitCnvs += ["PixelRDO_Container"]
if DetFlags.haveRIO.SCT_on():
    ByteStreamCnvSvc.InitCnvs += ["SCT_RDO_Container"]
if DetFlags.haveRIO.TRT_on():
    ByteStreamCnvSvc.InitCnvs += ["TRT_RDO_Container"]
if DetFlags.haveRIO.BCM_on():
    ByteStreamCnvSvc.InitCnvs += ["BCM_RDO_Container"]
print(ByteStreamCnvSvc)

# OutputStream
from AthenaServices.AthenaServicesConf import AthenaOutputStream
oStream = AthenaOutputStream("StreamBS",
                             EvtConversionSvc="ByteStreamCnvSvc",
                             OutputFile="ByteStreamEventStorageOutputSvc")

if DetFlags.haveRIO.pixel_on():
    oStream.ItemList += ["PixelRDO_Container#*"]
if DetFlags.haveRIO.SCT_on():
    oStream.ItemList += ["SCT_RDO_Container#*"]
if DetFlags.haveRIO.TRT_on():
    oStream.ItemList += ["TRT_RDO_Container#*"]
if DetFlags.haveRIO.BCM_on():
    oStream.ItemList += ["BCM_RDO_Container#*"]
print(oStream)

# add stream
theApp.addOutputStream(oStream)
theApp.OutStreamType = "AthenaOutputStream"
Exemple #9
0
def getStream(type, name):
    # globals in this module
    global svcMgr
    global _streamMap

    # type check
    type = type.upper()
    if type not in ['EVENTSTORAGE', 'TRANSIENT']:
        raise RuntimeError("unsupported StreamType:%s" % type)

    # return existing stream
    if (type, name) in _streamMap:
        return _streamMap[(type, name)]

    # EventStorage
    if type == 'EVENTSTORAGE':
        # OutputSvc
        if not hasattr(svcMgr, "ByteStreamEventStorageOutputSvc"):
            from ByteStreamCnvSvc.ByteStreamCnvSvcConf import ByteStreamEventStorageOutputSvc
            svcMgr += ByteStreamEventStorageOutputSvc()

        # Properties
        ByteStreamCnvSvc = svcMgr.ByteStreamCnvSvc
        ByteStreamCnvSvc.ByteStreamOutputSvcList += [
            "ByteStreamEventStorageOutputSvc"
        ]

        # OutputStream
        from AthenaServices.AthenaServicesConf import AthenaOutputStream
        StreamBS = AthenaOutputStream(
            name,
            EvtConversionSvc="ByteStreamCnvSvc",
            OutputFile="ByteStreamEventStorageOutputSvc",
        )
        theApp.addOutputStream(StreamBS)
        theApp.OutStreamType = "AthenaOutputStream"

        # Define the output as follows:
        ByteStreamEventStorageOutputSvc = svcMgr.ByteStreamEventStorageOutputSvc

        ByteStreamEventStorageOutputSvc.MaxFileMB = 15000
        # maximum number of event (beyond which it creates a new file)
        ByteStreamEventStorageOutputSvc.MaxFileNE = 15000000
        ByteStreamEventStorageOutputSvc.OutputDirectory = "./"
        ByteStreamEventStorageOutputSvc.AppName = "Athena"
        # release variable depends the way the env is configured
        #svcMgr.ByteStreamEventStorageOutputSvc.FileTag = release
        svcMgr.ByteStreamEventStorageOutputSvc.RunNumber = 0
        # does not work
        if hasattr(svcMgr.EventSelector, 'RunNumber'):
            svcMgr.ByteStreamEventStorageOutputSvc.RunNumber = svcMgr.EventSelector.RunNumber

        # decode BSRDOOutput property and overwrite some OutputStream properties if things are there defined
        from AthenaCommon.AthenaCommonFlags import athenaCommonFlags
        props = athenaCommonFlags.BSRDOOutput().split(",")
        if len(props) > 1:
            for p in props:
                if "AppName" in p:
                    svcMgr.ByteStreamEventStorageOutputSvc.AppName = p.split(
                        "=")[1]
                if "OutputDirectory" in p:
                    svcMgr.ByteStreamEventStorageOutputSvc.OutputDirectory = p.split(
                        "=")[1]
                if "FileTag" in p:
                    svcMgr.ByteStreamEventStorageOutputSvc.FileTag = p.split(
                        "=")[1]
                if "Run" in p:
                    svcMgr.ByteStreamEventStorageOutputSvc.RunNumber = int(
                        p.split("=")[1])
        else:
            svcMgr.ByteStreamEventStorageOutputSvc.SimpleFileName = athenaCommonFlags.BSRDOOutput(
            )
        # append
        _streamMap[(type, name)] = StreamBS
        return StreamBS

    elif type == 'TRANSIENT':
        # OutputSvc
        if not hasattr(svcMgr, "ROBDataProviderSvc"):
            from ByteStreamCnvSvcBase.ByteStreamCnvSvcBaseConf import ROBDataProviderSvc
            svcMgr += ROBDataProviderSvc()
        if not hasattr(svcMgr, "ByteStreamRDP_OutputSvc"):
            from ByteStreamCnvSvc.ByteStreamCnvSvcConf import ByteStreamRDP_OutputSvc
            svcMgr += ByteStreamRDP_OutputSvc()

        # Properties
        ByteStreamCnvSvc = svcMgr.ByteStreamCnvSvc
        ByteStreamCnvSvc.ByteStreamOutputSvcList += ["ByteStreamRDP_OutputSvc"]

        # This output stream is created as a regular OutputStream
        from AthenaServices.AthenaServicesConf import AthenaOutputStream
        StreamBS = AthenaOutputStream(
            name,
            EvtConversionSvc="ByteStreamCnvSvc",
            OutputFile="ByteStreamRDP_OutputSvc",
        )
        from AthenaCommon.AlgSequence import AlgSequence
        topSequence = AlgSequence()
        topSequence += StreamBS

        # ByteStreamCnvSvc is an input CnvSvc now.
        EventPersistencySvc = svcMgr.EventPersistencySvc
        EventPersistencySvc.CnvServices += ["ByteStreamCnvSvc"]

        # append
        _streamMap[(type, name)] = StreamBS
        return StreamBS

    else:
        raise RuntimeError("unsupported StreamType:%s" % type)
# ----------- JobOptions fragments for sending ByteStream to ROBDataProvider
#

## get a handle to the default top-level algorithm sequence
from AthenaCommon.AlgSequence import AlgSequence
topSequence = AlgSequence()

# get a handle on the ServiceManager
svcMgr = theApp.serviceMgr()

# Conversion Service instance
from ByteStreamCnvSvc.ByteStreamCnvSvcConf import ByteStreamCnvSvc
svcMgr += ByteStreamCnvSvc()
# OutputSvc
from ByteStreamCnvSvcBase.ByteStreamCnvSvcBaseConf import ROBDataProviderSvc
svcMgr += ROBDataProviderSvc()
from ByteStreamCnvSvc.ByteStreamCnvSvcConf import ByteStreamRDP_OutputSvc
svcMgr += ByteStreamRDP_OutputSvc()
# Properties
ByteStreamCnvSvc = svcMgr.ByteStreamCnvSvc
ByteStreamCnvSvc.ByteStreamOutputSvc = "ByteStreamRDP_OutputSvc"
# This output stream is created as a regular OutputStream
# OutputStream
from AthenaServices.AthenaServicesConf import AthenaOutputStream
topSequence += AthenaOutputStream("StreamBS",
                                  EvtConversionSvc="ByteStreamCnvSvc",
                                  OutputFile="ByteStreamRDP_OutputSvc")
# ByteStreamCnvSvc is an input CnvSvc now.
EventPersistencySvc = svcMgr.EventPersistencySvc
EventPersistencySvc.CnvServices += ["ByteStreamCnvSvc"]
Exemple #11
0
    svcMgr += ByteStreamAddressProviderSvc()
svcMgr.ByteStreamAddressProviderSvc.TypeNames += [
    "ROIB::RoIBResult/RoIBResult", "MuCTPI_RDO/MUCTPI_RDO", "CTP_RDO/CTP_RDO",
    "MuCTPI_RIO/MUCTPI_RIO", "CTP_RIO/CTP_RIO"
]
from OverlayCommonAlgs.OverlayCommonAlgsConf import BSFilter
filAlg = BSFilter("BSFilter")
filAlg.TriggerBit = 63  # The trigger bit to select
topSequence += filAlg

# BS OutputStream Tool
OutStreamName = "OutputStreamBSCopy"
from ByteStreamCnvSvc.ByteStreamCnvSvcConf import ByteStreamEventStorageOutputSvc, ByteStreamOutputStreamCopyTool
bsCopyTool = ByteStreamOutputStreamCopyTool("OutputStreamBSCopyTool")
svcMgr.ToolSvc += bsCopyTool

# Service to write out BS events
bsOutputSvc = ByteStreamEventStorageOutputSvc(
    "BSESOutputSvc0",
    OutputDirectory="temp/",
    SimpleFileName="SelectedBSEvents")
svcMgr += bsOutputSvc
bsCopyTool.ByteStreamOutputSvc = bsOutputSvc
bsCopyTool.ByteStreamInputSvc = svcMgr.ByteStreamInputSvc

# create AthenaOutputStream for BS Copy
from AthenaServices.AthenaServicesConf import AthenaOutputStream
OutputStreamBSCopy = AthenaOutputStream(OutStreamName, WritingTool=bsCopyTool)
topSequence += OutputStreamBSCopy
OutputStreamBSCopy.AcceptAlgs = ["BSFilter"]
Exemple #12
0
    ## For upgrade geometries the TRT has been removed, so should be switched off.
    if not DetFlags.detdescr.TRT_on():
        try:
            McEventCollectionFilter.UseTRTHits = False
        except:
            filterHitLog.error('Trying to run on upgrade samples (no TRT) with an old tag of McEventCollectionFilter - job will fail.')
    topSequence += McEventCollectionFilter


if releaseIsOlderThan(17,6):
    #--------------------------------------------------------------
    # Copy InFile MetaData using MetaDataTools
    #-------------------------------------------------------------
    from AthenaServices.AthenaServicesConf import AthenaOutputStream
    Stream1_FH = AthenaOutputStream( "StreamHITS_FH" )
    Stream1_FH.ItemList += [ "IOVMetaDataContainer#*" ]

#--------------------------------------------------------------
# Set output level threshold (2=DEBUG, 3=INFO, 4=WARNING, 5=ERROR, 6=FATAL )
#-------------------------------------------------------------
ServiceMgr.MessageSvc.OutputLevel   = INFO
LArHitFilter.OutputLevel        = INFO

#--------------------------------------------------------------
# Ensure IOVDbSvc.GlobalTag is configured
# - protection against bad HITS file metadata
#--------------------------------------------------------------
if not hasattr(ServiceMgr,'IOVDbSvc'):
    from IOVDbSvc.IOVDbSvcConf import IOVDbSvc
    ServiceMgr += IOVDbSvc()
Exemple #13
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
Exemple #14
0
# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
#--------------------------------------------------------------
# Write to Transient BS
#--------------------------------------------------------------

from AthenaCommon.AppMgr import theApp, ServiceMgr
from AthenaCommon.Include import include
from AthenaServices.AthenaServicesConf import AthenaOutputStream
from TriggerJobOpts.TriggerFlags import TriggerFlags

include("ByteStreamCnvSvc/RDP_ByteStream_jobOptions.py")

# Configure Transient BS Output Stream. ExtraInputs make sure all data (e.g. conditions)
# needed for BS encoding are scheduled to be produced before StreamBS
StreamBS = AthenaOutputStream("StreamBS",
                              EvtConversionSvc="ByteStreamCnvSvc",
                              ExtraInputs=[('xAOD::EventInfo',
                                            'StoreGateSvc+EventInfo')])

#Ensure StreamBS runs before L1Decoder
transTypeKey = ("TransientBSOutType", "StoreGateSvc+TransientBSOutKey")
StreamBS.ExtraOutputs += [transTypeKey]

if not TriggerFlags.fakeLVL1():
    from TrigT1ResultByteStream.TrigT1ResultByteStreamConfig import L1ByteStreamEncodersRecExSetup
    L1ByteStreamEncodersRecExSetup()
    StreamBS.ItemList += ["ROIB::RoIBResult#*"]
    StreamBS.ExtraInputs += [('ROIB::RoIBResult', 'StoreGateSvc+RoIBResult')]

if TriggerFlags.doID():
    # TRT
    StreamBS.ItemList += ["TRT_RDO_Container#*"]
ByteStreamFileOutputSvc = ByteStreamFileOutputSvc("ByteStreamFileOutputSvc",
                                                  OutputFiles=["RawEvent.re"])
ServiceMgr += ByteStreamFileOutputSvc
print ByteStreamFileOutputSvc

# Conversion Service instance
from ByteStreamCnvSvc.ByteStreamCnvSvcConf import ByteStreamCnvSvc
ByteStreamCnvSvc = ByteStreamCnvSvc(
    "ByteStreamCnvSvc",
    IsSimulation=True,
    ByteStreamOutputSvc="ByteStreamFileOutputSvc")
ByteStreamCnvSvc.InitCnvs += ["PixelRDO_Container"]
#ByteStreamCnvSvc.InitCnvs += ["SCT_RDO_Container"]
#ByteStreamCnvSvc.InitCnvs += ["TRT_RDO_Container"]
ServiceMgr += ByteStreamCnvSvc
print ByteStreamCnvSvc

# OutputStream
from AthenaServices.AthenaServicesConf import AthenaOutputStream
StreamBS = AthenaOutputStream("StreamBS", EvtConversionSvc="ByteStreamCnvSvc")
# Force reading of output stream (ostream set externally)
StreamBS.ForceRead = TRUE
#StreamBS.ItemList += [ "TRT_RDO_Container#*" ]
#StreamBS.ItemList += [ "SCT_RDO_Container#*" ]
StreamBS.ItemList += ["PixelRDO_Container#*"]
print StreamBS

# add stream
theApp.addOutputStream(StreamBS)
theApp.OutStreamType = "AthenaOutputStream"
#--------------------------------------------------------------
# Converter
#--------------------------------------------------------------
include("EventAthenaPool/EventAthenaPool_joboptions.py")

#--------------------------------------------------------------
# Output streams
#--------------------------------------------------------------
theApp.OutStream = []

from AthenaServices.AthenaServicesConf import AthenaOutputStream

ToolSvc = Service("ToolSvc")

# Declare output streams:
Stream1 = AthenaOutputStream("Stream1")

# Tool for output stream:
Stream1.WritingTool = "AthenaPoolOutputStreamTool"

# Set processing stage name for <>_ref
try:
    Stream1.ProcessingTag = StageOutName
except:
    print "No processing tag set for stream1"

# Persistent data file name:
try:
    Stream1.OutputFile = OutFile
except:
    Stream1.OutputFile = "OutputData.root"
Exemple #17
0
class ISF_HITSStream:
    """
     Place to handle the persistency.
    """

    isfoplog.info("in ISF_HITSStream")

    from G4AtlasApps.SimFlags import simFlags
    from ISF_Config.ISF_jobProperties import ISF_Flags
    from AthenaCommon.AthenaCommonFlags import athenaCommonFlags
    if athenaCommonFlags.PoolHitsOutput.statusOn or (hasattr(simFlags, "WriteTR") and simFlags.WriteTR.statusOn) or (hasattr(simFlags,'StoppedParticleFile') and simFlags.StoppedParticleFile.statusOn):
        ## Write hits in POOL
        isfoplog.info("ISF_HITSStream starting")

        ## The following used to be in G4AtlasApps/HitAthenaPoolWriteOptions
        from AthenaCommon.Configurable import Configurable
        from AthenaPoolCnvSvc.WriteAthenaPool import AthenaPoolOutputStream

        ## Default setting for one output stream
        from AthenaCommon.AppMgr import ServiceMgr
        ServiceMgr.AthenaPoolCnvSvc.PoolAttributes += ["TREE_BRANCH_OFFSETTAB_LEN = '100'"]
        ServiceMgr.AthenaPoolCnvSvc.PoolAttributes += ["DEFAULT_BUFFERSIZE = '2048'"]

        ## Write geometry tag info
        import EventInfoMgt.EventInfoMgtInit

        ## Patch metadata if required
        from ISF_Example.ISF_Metadata import patch_mc_channel_numberMetadata
        patch_mc_channel_numberMetadata()

        ## Instantiate StreamHITS
        ## NB. Two-arg constructor is needed, since otherwise metadata writing fails!
        stream1 = None
        if athenaCommonFlags.PoolHitsOutput.statusOn:
            stream1 = AthenaPoolOutputStream("StreamHITS", athenaCommonFlags.PoolHitsOutput())
            stream1.ForceRead = True
            stream1.ItemList = getHITSStreamItemList()
            ## Make stream aware of aborted events
            stream1.AcceptAlgs = [ISF_Flags.Simulator.KernelName()]

        ## StreamEVGEN: needed for cosmic simulations and cavern BG
        ## Separate stream of track record (TR) info -- it does not apply to the CTB simulations.
        # TODO: Can this be merged into the cosmics sec above, or do the AthenaPool includes *need* to be in-between?
        layout = simFlags.SimLayout.get_Value()
        if "tb" not in layout:
            if hasattr(simFlags, "WriteTR") and simFlags.WriteTR.statusOn or\
               hasattr(simFlags,'StoppedParticleFile') and simFlags.StoppedParticleFile.statusOn:
                streamName = simFlags.WriteTR.get_Value() if simFlags.WriteTR.statusOn else simFlags.StoppedParticleFile.get_Value()
                stream2 = AthenaPoolOutputStream("StreamEVGEN", streamName)
                stream2.ItemList = getEVNTStreamItemList()
                ## Make stream aware of aborted events
                stream2.AcceptAlgs = [ISF_Flags.Simulator.KernelName()]
        #
        #  Setup and add metadata to the HITS file.
        #  ( heavily based on G4AtlasApps/python/SimAtlasKernel.py )
        #
        #  causes problems with cosmics currently:
        #    "IOVDbSvc ERROR Duplicate request for folder /Simulation/Parameters associated to already"
        from AthenaServices.AthenaServicesConf import AthenaOutputStream
        stream1_SimMetaData = AthenaOutputStream("StreamHITS_SimMetaData")
        stream1_SimMetaData.ItemList += [ "IOVMetaDataContainer#*" ]

        isfoplog.info("ISF_HITSStream done")
    else:
        isfoplog.info("ISF_HITSStream nothing done")