From 4d2713e837abfc2f3c72e790a89a5816f68c881c Mon Sep 17 00:00:00 2001 From: Frank Berghaus <frank.berghaus@cern.ch> Date: Tue, 14 Jul 2020 15:00:01 +0200 Subject: [PATCH] Clean up component accumulator config for bytestream reading Refactor the read configuration for bytestream in component accumulator style. Looking at code from the athena configuration team it seems that we use camelCase for functions and methods. Since that changes the interface it requires a update to the clients. --- Calorimeter/CaloRec/python/CaloRecoConfig.py | 2 +- .../python/ByteStreamConfig.py | 169 +++++++++--------- .../python/TileDQFragMonitorAlgorithm.py | 2 +- .../python/TileDigiNoiseMonitorAlgorithm.py | 2 +- .../TileRawChannelNoiseMonitorAlgorithm.py | 2 +- .../TileRawChannelTimeMonitorAlgorithm.py | 2 +- .../python/TileDigitsFilterConfig.py | 2 +- .../python/TileDigitsMakerConfig.py | 2 +- 8 files changed, 95 insertions(+), 88 deletions(-) diff --git a/Calorimeter/CaloRec/python/CaloRecoConfig.py b/Calorimeter/CaloRec/python/CaloRecoConfig.py index 2776fb87aa8..36365c7e2a5 100644 --- a/Calorimeter/CaloRec/python/CaloRecoConfig.py +++ b/Calorimeter/CaloRec/python/CaloRecoConfig.py @@ -13,7 +13,7 @@ def CaloRecoCfg(configFlags): from ByteStreamCnvSvc.ByteStreamConfig import ByteStreamReadCfg - result.merge( ByteStreamReadCfg(configFlags,typeNames=['TileDigitsContainer/TileDigitsCnt','TileRawChannelContainer/TileRawChannelCnt'])) + result.merge( ByteStreamReadCfg(configFlags,type_names=['TileDigitsContainer/TileDigitsCnt','TileRawChannelContainer/TileRawChannelCnt'])) from LArROD.LArRawChannelBuilderAlgConfig import LArRawChannelBuilderAlgCfg diff --git a/Event/ByteStreamCnvSvc/python/ByteStreamConfig.py b/Event/ByteStreamCnvSvc/python/ByteStreamConfig.py index de44b7f9143..ccda176c396 100644 --- a/Event/ByteStreamCnvSvc/python/ByteStreamConfig.py +++ b/Event/ByteStreamCnvSvc/python/ByteStreamConfig.py @@ -1,71 +1,76 @@ -# -# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -# - +#!/usr/bin/env python +# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration +"""module docstring +""" from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator from AthenaConfiguration.ComponentFactory import CompFactory +from AthenaConfiguration.AllConfigFlags import ConfigFlags +from AthenaConfiguration.TestDefaults import defaultTestFiles +from AthenaCommon.Configurable import Configurable +from AthenaServices.MetaDataSvcConfig import MetaDataSvcCfg -def ByteStreamReadCfg( inputFlags, typeNames=[] ): - """ - Creates accumulator for BS reading +def ByteStreamReadCfg(flags, type_names=None): + """Creates resultumulator for BS reading """ - - acc = ComponentAccumulator() - - ByteStreamCnvSvc, ByteStreamEventStorageInputSvc, EventSelectorByteStream=CompFactory.getComps("ByteStreamCnvSvc","ByteStreamEventStorageInputSvc","EventSelectorByteStream",) - - if inputFlags.Input.SecondaryFiles: - filenames = inputFlags.Input.SecondaryFiles - eventSelector = EventSelectorByteStream("SecondaryEventSelector", IsSecondary=True) - eventSelector.Input = filenames - acc.addService( eventSelector ) + result = ComponentAccumulator() + bytestream_conversion = CompFactory.ByteStreamCnvSvc() + result.addService(bytestream_conversion) + + bytestream_input = CompFactory.ByteStreamEventStorageInputSvc( + name="ByteStreamInputSvc", + EventInfoKey="{}EventInfo".format( + flags.Overlay.BkgPrefix if flags.Overlay.DataOverlay else "" + ), + ) + result.addService(bytestream_input) + + if flags.Input.SecondaryFiles: + event_selector = CompFactory.EventSelectorByteStream( + name="SecondaryEventSelector", + IsSecondary=True, + Input=flags.Input.SecondaryFiles, + ByteStreamInputSvc=bytestream_input.name, + ) + result.addService(event_selector) else: - filenames = inputFlags.Input.Files - xAODMaker__EventInfoSelectorTool = CompFactory.xAODMaker.EventInfoSelectorTool - xconv = xAODMaker__EventInfoSelectorTool() - eventSelector = EventSelectorByteStream("EventSelector") - eventSelector.Input = filenames - eventSelector.HelperTools += [xconv] - eventSelector.SkipEvents=inputFlags.Exec.SkipEvents - acc.addService( eventSelector ) - acc.setAppProperty( "EvtSel", eventSelector.name ) - - bsInputSvc = ByteStreamEventStorageInputSvc( "ByteStreamInputSvc" ) - if inputFlags.Overlay.DataOverlay: - bsInputSvc.EventInfoKey = inputFlags.Overlay.BkgPrefix + "EventInfo" - acc.addService( bsInputSvc ) - - EvtPersistencySvc=CompFactory.EvtPersistencySvc - eventPersistencySvc = EvtPersistencySvc( "EventPersistencySvc" ) - acc.addService( eventPersistencySvc ) - - bsCnvSvc = ByteStreamCnvSvc() - eventSelector.ByteStreamInputSvc = bsInputSvc.name - eventPersistencySvc.CnvServices = [ bsCnvSvc.name ] - acc.addService( bsCnvSvc ) - - ROBDataProviderSvc=CompFactory.ROBDataProviderSvc - robDPSvc = ROBDataProviderSvc() - acc.addService( robDPSvc ) - - ByteStreamAddressProviderSvc=CompFactory.ByteStreamAddressProviderSvc - bsAddressProviderSvc = ByteStreamAddressProviderSvc(TypeNames=typeNames) - acc.addService( bsAddressProviderSvc ) - - ProxyProviderSvc=CompFactory.ProxyProviderSvc - - from AthenaServices.MetaDataSvcConfig import MetaDataSvcCfg - acc.merge(MetaDataSvcCfg(inputFlags, ["IOVDbMetaDataTool", "ByteStreamMetadataTool"])) - - proxy = ProxyProviderSvc() - proxy.ProviderNames += [ bsAddressProviderSvc.name ] - acc.addService( proxy ) - - return acc - -def ByteStreamWriteCfg( flags, typeNames=[] ): - acc = ComponentAccumulator("AthOutSeq") + event_selector = CompFactory.EventSelectorByteStream( + name="EventSelector", + Input=flags.Input.Files, + SkipEvents=flags.Exec.SkipEvents, + ByteStreamInputSvc=bytestream_input.name, + ) + event_selector.HelperTools += [ + CompFactory.xAODMaker.EventInfoSelectorTool() + ] + result.addService(event_selector) + result.setAppProperty("EvtSel", event_selector.name) + + event_persistency = CompFactory.EvtPersistencySvc( + name="EventPersistencySvc", CnvServices=[bytestream_conversion.name] + ) + result.addService(event_persistency) + + result.addService(CompFactory.ROBDataProviderSvc()) + + address_provider = CompFactory.ByteStreamAddressProviderSvc( + TypeNames=type_names if type_names else list(), + ) + result.addService(address_provider) + + result.merge( + MetaDataSvcCfg(flags, ["IOVDbMetaDataTool", "ByteStreamMetadataTool"]) + ) + + proxy = CompFactory.ProxyProviderSvc() + proxy.ProviderNames += [address_provider.name] + result.addService(proxy) + + return result + + +def ByteStreamWriteCfg(flags, type_names=[]): + result = ComponentAccumulator("AthOutSeq") outputSvc = CompFactory.ByteStreamEventStorageOutputSvc() outputSvc.MaxFileMB = 15000 # event (beyond which it creates a new file) @@ -73,34 +78,36 @@ def ByteStreamWriteCfg( flags, typeNames=[] ): outputSvc.OutputDirectory = "./" outputSvc.AppName = "Athena" # release variable depends the way the env is configured - #FileTag = release + # FileTag = release allRuns = set(flags.Input.RunNumber) - assert len(allRuns) == 1, "The input is from multiple runs, do not know which one to use {}".format(allRuns) + assert ( + len(allRuns) == 1 + ), "The input is from multiple runs, do not know which one to use {}".format( + allRuns + ) outputSvc.RunNumber = allRuns.pop() - bsCnvSvc = CompFactory.ByteStreamCnvSvc("ByteStreamCnvSvc") - - bsCnvSvc.ByteStreamOutputSvcList = [ outputSvc.getName() ] - streamAlg = CompFactory.AthenaOutputStream( "BSOutputStreamAlg", - EvtConversionSvc = bsCnvSvc.getName(), - OutputFile = "ByteStreamEventStorageOutputSvc", - ItemList = typeNames ) + bytestream_conversion = CompFactory.ByteStreamCnvSvc("ByteStreamCnvSvc") - acc.addService( outputSvc ) - acc.addService( bsCnvSvc ) - acc.addEventAlgo( streamAlg, primary = True ) - return acc + bytestream_conversion.ByteStreamOutputSvcList = [outputSvc.getName()] + streamAlg = CompFactory.AthenaOutputStream( + "BSOutputStreamAlg", + EvtConversionSvc=bytestream_conversion.getName(), + OutputFile="ByteStreamEventStorageOutputSvc", + ItemList=type_names, + ) + result.addService(outputSvc) + result.addService(bytestream_conversion) + result.addEventAlgo(streamAlg, primary=True) + return result if __name__ == "__main__": - from AthenaConfiguration.AllConfigFlags import ConfigFlags - from AthenaConfiguration.TestDefaults import defaultTestFiles - from AthenaCommon.Configurable import Configurable - Configurable.configurableRun3Behavior=True + Configurable.configurableRun3Behavior = True ConfigFlags.Input.Files = defaultTestFiles.RAW - acc = ByteStreamReadCfg( ConfigFlags ) - acc.store( open( "test.pkl", "wb" ) ) + acc = ByteStreamReadCfg(ConfigFlags) + acc.store(open("test.pkl", "wb")) print("All OK") diff --git a/TileCalorimeter/TileMonitoring/python/TileDQFragMonitorAlgorithm.py b/TileCalorimeter/TileMonitoring/python/TileDQFragMonitorAlgorithm.py index f331a2014c1..ec65125a570 100644 --- a/TileCalorimeter/TileMonitoring/python/TileDQFragMonitorAlgorithm.py +++ b/TileCalorimeter/TileMonitoring/python/TileDQFragMonitorAlgorithm.py @@ -254,7 +254,7 @@ if __name__=='__main__': from ByteStreamCnvSvc.ByteStreamConfig import ByteStreamReadCfg tileTypeNames = ['TileRawChannelContainer/TileRawChannelCnt', 'TileDigitsContainer/TileDigitsCnt'] - cfg.merge( ByteStreamReadCfg(ConfigFlags, typeNames = tileTypeNames) ) + cfg.merge( ByteStreamReadCfg(ConfigFlags, type_names = tileTypeNames) ) from TileRecUtils.TileRawChannelMakerConfig import TileRawChannelMakerCfg cfg.merge( TileRawChannelMakerCfg(ConfigFlags) ) diff --git a/TileCalorimeter/TileMonitoring/python/TileDigiNoiseMonitorAlgorithm.py b/TileCalorimeter/TileMonitoring/python/TileDigiNoiseMonitorAlgorithm.py index 3e750d187f6..ac987ea3044 100644 --- a/TileCalorimeter/TileMonitoring/python/TileDigiNoiseMonitorAlgorithm.py +++ b/TileCalorimeter/TileMonitoring/python/TileDigiNoiseMonitorAlgorithm.py @@ -108,7 +108,7 @@ if __name__=='__main__': from ByteStreamCnvSvc.ByteStreamConfig import ByteStreamReadCfg tileTypeNames = ['TileRawChannelContainer/TileRawChannelCnt', 'TileDigitsContainer/TileDigitsCnt'] - cfg.merge( ByteStreamReadCfg(ConfigFlags, typeNames = tileTypeNames) ) + cfg.merge( ByteStreamReadCfg(ConfigFlags, type_names = tileTypeNames) ) cfg.merge( TileDigiNoiseMonitoringConfig(ConfigFlags, TriggerChain = '') ) diff --git a/TileCalorimeter/TileMonitoring/python/TileRawChannelNoiseMonitorAlgorithm.py b/TileCalorimeter/TileMonitoring/python/TileRawChannelNoiseMonitorAlgorithm.py index ae75099c21e..0626765535c 100644 --- a/TileCalorimeter/TileMonitoring/python/TileRawChannelNoiseMonitorAlgorithm.py +++ b/TileCalorimeter/TileMonitoring/python/TileRawChannelNoiseMonitorAlgorithm.py @@ -121,7 +121,7 @@ if __name__=='__main__': from ByteStreamCnvSvc.ByteStreamConfig import ByteStreamReadCfg tileTypeNames = ['TileRawChannelContainer/TileRawChannelCnt', 'TileDigitsContainer/TileDigitsCnt'] - cfg.merge( ByteStreamReadCfg(ConfigFlags, typeNames = tileTypeNames) ) + cfg.merge( ByteStreamReadCfg(ConfigFlags, type_names = tileTypeNames) ) from TileRecUtils.TileRawChannelMakerConfig import TileRawChannelMakerCfg cfg.merge( TileRawChannelMakerCfg(ConfigFlags) ) diff --git a/TileCalorimeter/TileMonitoring/python/TileRawChannelTimeMonitorAlgorithm.py b/TileCalorimeter/TileMonitoring/python/TileRawChannelTimeMonitorAlgorithm.py index e0cb1adf8e7..3f662248fbf 100644 --- a/TileCalorimeter/TileMonitoring/python/TileRawChannelTimeMonitorAlgorithm.py +++ b/TileCalorimeter/TileMonitoring/python/TileRawChannelTimeMonitorAlgorithm.py @@ -155,7 +155,7 @@ if __name__=='__main__': tileTypeNames = ['TileRawChannelContainer/TileRawChannelCnt', 'TileDigitsContainer/TileDigitsCnt', 'TileBeamElemContainer/TileBeamElemCnt'] - cfg.merge( ByteStreamReadCfg(ConfigFlags, typeNames = tileTypeNames) ) + cfg.merge( ByteStreamReadCfg(ConfigFlags, type_names = tileTypeNames) ) from TileRecUtils.TileRawChannelMakerConfig import TileRawChannelMakerCfg cfg.merge( TileRawChannelMakerCfg(ConfigFlags) ) diff --git a/TileCalorimeter/TileRecAlgs/python/TileDigitsFilterConfig.py b/TileCalorimeter/TileRecAlgs/python/TileDigitsFilterConfig.py index 97e1fd31c06..0542192fb22 100644 --- a/TileCalorimeter/TileRecAlgs/python/TileDigitsFilterConfig.py +++ b/TileCalorimeter/TileRecAlgs/python/TileDigitsFilterConfig.py @@ -78,7 +78,7 @@ if __name__ == "__main__": from ByteStreamCnvSvc.ByteStreamConfig import ByteStreamReadCfg tileTypeNames = ['TileRawChannelContainer/TileRawChannelCnt', 'TileDigitsContainer/TileDigitsCnt'] - acc.merge( ByteStreamReadCfg(ConfigFlags, typeNames = tileTypeNames) ) + acc.merge( ByteStreamReadCfg(ConfigFlags, type_names = tileTypeNames) ) acc.merge( TileDigitsFilterOutputCfg(ConfigFlags) ) diff --git a/TileCalorimeter/TileSimAlgs/python/TileDigitsMakerConfig.py b/TileCalorimeter/TileSimAlgs/python/TileDigitsMakerConfig.py index bf7398360eb..06070f59d8c 100644 --- a/TileCalorimeter/TileSimAlgs/python/TileDigitsMakerConfig.py +++ b/TileCalorimeter/TileSimAlgs/python/TileDigitsMakerConfig.py @@ -60,7 +60,7 @@ def TileDigitsMakerCfg(flags, **kwargs): if flags.Overlay.DataOverlay: from ByteStreamCnvSvc.ByteStreamConfig import ByteStreamReadCfg - acc.merge(ByteStreamReadCfg(flags, typeNames=[ + acc.merge(ByteStreamReadCfg(flags, type_names=[ 'TileDigitsContainer/' + flags.Overlay.BkgPrefix + 'TileDigitsCnt', 'TileRawChannelContainer/' + flags.Overlay.BkgPrefix + 'TileRawChannelCnt'] )) -- GitLab