diff --git a/TileCalorimeter/TileConditions/python/TileAutoCorrelationConfig.py b/TileCalorimeter/TileConditions/python/TileAutoCorrelationConfig.py new file mode 100644 index 0000000000000000000000000000000000000000..76a68c4bc82b74d82b5929c4b9742b0ee96f52ae --- /dev/null +++ b/TileCalorimeter/TileConditions/python/TileAutoCorrelationConfig.py @@ -0,0 +1,112 @@ +# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + +"""Define methods to construct configured Tile auto correlation tool and conditions algorithm""" + +from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator + +def TileAutoCorrelationCondAlgCfg(flags, **kwargs): + """Return component accumulator with configured Tile auto correlation conditions algorithm + + Arguments: + flags -- Athena configuration flags (ConfigFlags) + Keyword arguments: + Source -- source of Tile auto correlation conditions (COOL, FILE). Defaults to COOL. + TileAutoCorrelation -- name of Tile auto correlation conditions object. Defaults to TileAutoCorrelaton. + """ + + acc = ComponentAccumulator() + + source = kwargs.get('Source', 'COOL') + autoCorrelation = kwargs.get('TileAutoCorrelation', 'TileAutoCorrelation') + + name = autoCorrelation + 'CondAlg' + + if source == 'COOL': + # Connect COOL Tile conditions proxies to the algorithm (default) + + from TileConditions.TileFolders import TileFolders + folders = TileFolders(isMC = flags.Input.isMC, isOnline = flags.Common.isOnline) + + if flags.IOVDb.DatabaseInstance == 'CONDBR2': + if not flags.Common.isOnline: + autoCorrelationFolder = folders.add('/TILE/OFL02/NOISE/AUTOCR', 'TILE_OFL') + else: + raise(Exception("No online auto correlation folder in CONDBR2 DB")) + else: + autoCorrelationFolder = folders.addSplitOnline('/TILE/OFL01/NOISE/AUTOCR', '/TILE/OFL02/NOISE/AUTOCR') + + from TileConditions.TileConditionsConf import TileCondProxyCool_TileCalibDrawerFlt_ as TileCondProxyCoolFlt + autoCorrelationProxy = TileCondProxyCoolFlt('TileCondProxyCool_NoiseAutoCr', Source = autoCorrelationFolder) + + from IOVDbSvc.IOVDbSvcConfig import addFolderList + acc.merge( addFolderList(flags, folders.get()) ) + + elif source == 'FILE': + # Connect FILE Tile conditions proxies to the algorithm + from TileConditions.TileConditionsConf import TileCondProxyFile_TileCalibDrawerFlt_ as TileCondProxyFileFlt + autoCorrelationProxy = TileCondProxyFileFlt('TileCondProxyFile_NoiseAutoCr', Source = 'TileDefault.acr') + + else: + raise(Exception("Invalid source: %s" % source)) + + from TileConditions.TileConditionsConf import TileCalibCondAlg_TileCalibDrawerFlt_ as TileCalibFltCondAlg + autoCorrelationCondAlg = TileCalibFltCondAlg( name = name, + ConditionsProxy = autoCorrelationProxy, + TileCalibData = autoCorrelation) + + acc.addCondAlgo(autoCorrelationCondAlg) + + return acc + + +def TileCondToolAutoCrCfg(flags, **kwargs): + """Return component accumulator with configured private Tile auto correlation tool + Arguments: + flags -- Athena configuration flags (ConfigFlags) + Keyword arguments: + Source -- source of Tile auto correlation conditions (COOL, FILE). Defaults to COOL. + TileAutoCorrelation -- name of Tile auto correlation conditions object. Defaults to TileAutoCorrelaton. + """ + + acc = ComponentAccumulator() + + kwargs.setdefault('Source', 'COOL') + kwargs.setdefault('TileAutoCorrelation', 'TileAutoCorrelation') + + autoCorrelation = kwargs['TileAutoCorrelation'] + name = 'TileCondToolAutoCr' + + acc.merge( TileAutoCorrelationCondAlgCfg(flags, **kwargs) ) + + from TileConditions.TileConditionsConf import TileCondToolAutoCr + acc.setPrivateTools( TileCondToolAutoCr(name, TileAutoCorrelation = autoCorrelation) ) + + return acc + + +if __name__ == "__main__": + + from AthenaCommon.Configurable import Configurable + Configurable.configurableRun3Behavior = 1 + from AthenaConfiguration.AllConfigFlags import ConfigFlags + from AthenaConfiguration.TestDefaults import defaultTestFiles + from AthenaCommon.Logging import log + from AthenaCommon.Constants import DEBUG + + # Test setup + log.setLevel(DEBUG) + + ConfigFlags.Input.Files = defaultTestFiles.RAW + ConfigFlags.lock() + + acc = ComponentAccumulator() + + autoCorrelationTool = acc.popToolsAndMerge( TileCondToolAutoCrCfg(ConfigFlags) ) + print(autoCorrelationTool) + + acc.printConfig(withDetails = True, summariseProps = True) + print(acc.getService('IOVDbSvc')) + acc.store( open('TileAutoCorrelation.pkl','w') ) + + print('All OK') + diff --git a/TileCalorimeter/TileConditions/python/TileCondToolsTestConfig.py b/TileCalorimeter/TileConditions/python/TileCondToolsTestConfig.py index e98c5c1d197b8b791cf2b5100e36661fc5496d74..1d31507d507f41f0c3cbc8603cb9fe4324a72915 100644 --- a/TileCalorimeter/TileConditions/python/TileCondToolsTestConfig.py +++ b/TileCalorimeter/TileConditions/python/TileCondToolsTestConfig.py @@ -40,6 +40,10 @@ def TileCondToolsTestCfg(flags): onlineTimingTool = acc.popToolsAndMerge( TileCondToolOnlineTimingCfg(flags) ) msg.info(onlineTimingTool) + from TileOFCConfig import TileCondToolOfcCoolCfg + ofcCoolTool = acc.popToolsAndMerge( TileCondToolOfcCoolCfg(flags) ) + msg.info(ofcCoolTool) + if flags.IOVDb.DatabaseInstance == 'CONDBR2': from TileTMDBConfig import TileCondToolTMDBCfg tmdbTool = acc.popToolsAndMerge( TileCondToolTMDBCfg(flags) ) @@ -54,6 +58,15 @@ def TileCondToolsTestCfg(flags): pulseShapeTool = acc.popToolsAndMerge( TileCondToolPulseShapeCfg(flags) ) msg.info(pulseShapeTool) + from TileAutoCorrelationConfig import TileCondToolAutoCrCfg + autoCorrelationTool = acc.popToolsAndMerge( TileCondToolAutoCrCfg(flags) ) + msg.info(autoCorrelationTool) + + from TileOFCConfig import TileCondToolOfcCfg + ofcTool = acc.popToolsAndMerge( TileCondToolOfcCfg(flags) ) + msg.info(ofcTool) + + if not (flags.Input.isMC or flags.Common.isOnline): from TileConditions.TileDCSConfig import TileDCSToolCfg dcsTool = acc.popToolsAndMerge( TileDCSToolCfg(flags) ) diff --git a/TileCalorimeter/TileConditions/python/TileOFCConfig.py b/TileCalorimeter/TileConditions/python/TileOFCConfig.py new file mode 100644 index 0000000000000000000000000000000000000000..0a0639f2966e04736670ef58695cd86b82671468 --- /dev/null +++ b/TileCalorimeter/TileConditions/python/TileOFCConfig.py @@ -0,0 +1,160 @@ +# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + +"""Define methods to construct configured Tile OFC conditions tool and algorithm""" + +from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator + +def TileOFCCondAlgCfg(flags, **kwargs): + """Return component accumulator with configured Tile OFC conditions algorithm + + Arguments: + flags -- Athena configuration flags (ConfigFlags) + Keyword arguments: + Source -- source of Tile OFC conditions (COOL, FILE). Defaults to COOL. + TileOfc -- name of Tile OFC conditions object starts with. Defaults to TileOfc. + OfcType -- type of Tile OFC. Defaults to OF2. Possible OFC types: OF1, OF2. + """ + + acc = ComponentAccumulator() + + runType = flags.Tile.RunType + runType = runType.upper() + if runType not in ['PHY', 'PED', 'CIS', 'MONOCIS', 'LAS', 'BILAS']: + raise(Exception("Invalid Tile run type: %s" % runType)) + + actualRunType = {'PHY' : 'PHY', 'PED' : 'PHY', + 'LAS' : 'LAS', 'BILAS' : 'LAS', + 'CIS' : 'CIS', 'MONOCIS' : 'CIS'} + + runType = actualRunType.get(runType, runType) + + source = kwargs.get('Source', 'COOL') + ofc = kwargs.get('TileOfc', 'TileOfc') + ofcType = kwargs.get('OfcType', 'OF2') + + ofcType = ofcType.upper() + if ofcType not in ['OF1', 'OF2']: + raise(Exception("Invalid Tile OFC type: %s" % ofcType)) + + name = ofc + 'CondAlg' + + if source == 'COOL': + # Connect COOL Tile conditions proxies to the algorithm (default) + + from TileConditions.TileFolders import TileFolders + folders = TileFolders(isMC = flags.Input.isMC, isOnline = flags.Common.isOnline) + + ofcType = ofcType + '/' + runType + + runNumber = flags.Input.RunNumber[0] + runSplitOnline = 314449 #Use OFC stored in online folder for all runs before 2017 + if flags.IOVDb.DatabaseInstance == 'CONDBR2' and runType == 'PHY' and runNumber > runSplitOnline: + ofcFolder = folders.addSplitOnline('/TILE/ONL01/FILTER/' + ofcType, '/TILE/OFL02/FILTER/' + ofcType) + else: + ofcFolder = folders.addSplitMC('/TILE/ONL01/FILTER/' + ofcType, '/TILE/OFL02/FILTER/' + ofcType) + + from TileConditions.TileConditionsConf import TileCondProxyCool_TileCalibDrawerOfc_ as TileCondProxyCoolOfc + ofcProxy = TileCondProxyCoolOfc('TileCondProxyCool_Ofc', Source = ofcFolder) + + from IOVDbSvc.IOVDbSvcConfig import addFolderList + acc.merge( addFolderList(flags, folders.get()) ) + + else: + raise(Exception("Invalid source: %s" % source)) + + from TileConditions.TileConditionsConf import TileCalibCondAlg_TileCalibDrawerOfc_ as TileCalibOfcCondAlg + ofcCondAlg = TileCalibOfcCondAlg( name = name, ConditionsProxy = ofcProxy, TileCalibData = ofc) + + acc.addCondAlgo(ofcCondAlg) + + return acc + + +def TileCondToolOfcCoolCfg(flags, **kwargs): + """Return component accumulator with configured Tile OFC conditions algorithm + + Arguments: + flags -- Athena configuration flags (ConfigFlags) + Keyword arguments: + Source -- source of Tile OFC conditions (COOL, FILE). Defaults to COOL. + TileOfc -- name of Tile OFC conditions. Defaults to TileOfc + OfcType (capitalized). + OfcType -- type of Tile OFC. Defaults to OF2. Possible OFC types: OF1, OF2. + """ + + acc = ComponentAccumulator() + + kwargs.setdefault('Source', 'COOL') + kwargs.setdefault('OfcType', 'OF2') + + ofcType = kwargs['OfcType'] + ofc = 'TileOfc' + ofcType.capitalize() + + kwargs.setdefault('TileOfc', ofc) + + ofc = kwargs['TileOfc'] + name = 'TileCondToolOfcCool' + + acc.merge( TileOFCCondAlgCfg(flags, **kwargs) ) + + from TileConditions.TileConditionsConf import TileCondToolOfcCool + acc.setPrivateTools( TileCondToolOfcCool(name, TileOfc = ofc) ) + + return acc + + +def TileCondToolOfcCfg(flags, **kwargs): + """Return component accumulator with configured Tile OFC conditions algorithm + + Arguments: + flags -- Athena configuration flags (ConfigFlags) + Keyword arguments: + OfcType -- type of Tile OFC. Defaults to OF2. Possible OFC types: OF1, OF2. + """ + + acc = ComponentAccumulator() + + from TileConditions.TilePulseShapeConfig import TileCondToolPulseShapeCfg + pulseShapeTool = acc.popToolsAndMerge( TileCondToolPulseShapeCfg(flags) ) + + from TileConditions.TileAutoCorrelationConfig import TileCondToolAutoCrCfg + autoCorrelationTool = acc.popToolsAndMerge( TileCondToolAutoCrCfg(flags) ) + + name = 'TileCondToolOfc' + from TileConditions.TileConditionsConf import TileCondToolOfc + acc.setPrivateTools( TileCondToolOfc(name, TileCondToolPulseShape = pulseShapeTool, + TileCondToolAutoCr = autoCorrelationTool) ) + + return acc + + + +if __name__ == "__main__": + + from AthenaCommon.Configurable import Configurable + Configurable.configurableRun3Behavior = 1 + from AthenaConfiguration.AllConfigFlags import ConfigFlags + from AthenaConfiguration.TestDefaults import defaultTestFiles + from AthenaCommon.Logging import log + from AthenaCommon.Constants import DEBUG + + # Test setup + log.setLevel(DEBUG) + + ConfigFlags.Input.Files = defaultTestFiles.RAW + ConfigFlags.Tile.RunType = 'PHY' + ConfigFlags.lock() + + acc = ComponentAccumulator() + + ofcCoolTool = acc.popToolsAndMerge( TileCondToolOfcCoolCfg(ConfigFlags) ) + print(ofcCoolTool) + + ofcTool = acc.popToolsAndMerge( TileCondToolOfcCfg(ConfigFlags) ) + print(ofcTool) + + acc.printConfig(withDetails = True, summariseProps = True) + print(acc.getService('IOVDbSvc')) + acc.store( open('TileOFC.pkl','w') ) + + print('All OK') +