3 """Define methods to construct configured Tile sample noise tool and conditions algorithm"""
5 from AthenaConfiguration.ComponentAccumulator
import ComponentAccumulator
6 from AthenaConfiguration.ComponentFactory
import CompFactory
9 """Return component accumulator with configured Tile sample noise conditions algorithm
12 flags -- Athena configuration flags
14 Source -- source of Tile sample noise conditions (COOL, FILE). Defaults to COOL.
15 ForceOnline -- flag to use online sample noise in offline. Defaults to False.
16 TileSampleNoise -- name of Tile sample noise conditions object.
17 Defaults to TileOnlineSampleNoise if ForceOnline else TileSampleNoise.
22 source = kwargs.get(
'Source',
'COOL')
23 sampleNoise = kwargs.get(
'TileSampleNoise',
'TileSampleNoise')
24 forceOnline = kwargs.get(
'ForceOnline',
False)
26 name = sampleNoise +
'CondAlg'
31 from TileConditions.TileFolders
import TileFolders
32 folders = TileFolders(isMC = flags.Input.isMC, isOnline = flags.Common.isOnline)
34 if flags.IOVDb.DatabaseInstance ==
'CONDBR2':
35 onlineSampleNoiseFolder =
'/TILE/ONL01/NOISE/SAMPLE'
37 onlineSampleNoiseFolder =
'/TILE/OFL01/NOISE/SAMPLE'
40 sampleNoiseFolder = folders.add(onlineSampleNoiseFolder,
'TILE')
42 sampleNoiseFolder = folders.addSplitOnline(onlineSampleNoiseFolder,
'/TILE/OFL02/NOISE/SAMPLE')
44 TileCondProxyCoolFlt=CompFactory.getComp(
"TileCondProxyCool<TileCalibDrawerFlt>")
45 sampleNoiseProxy =
TileCondProxyCoolFlt(
'TileCondProxyCool_NoiseSample', Source = sampleNoiseFolder)
47 from IOVDbSvc.IOVDbSvcConfig
import addFolderList
50 elif source ==
'FILE':
52 TileCondProxyFileFlt=CompFactory.getComp(
"TileCondProxyFile<TileCalibDrawerFlt>")
53 sampleNoiseProxy =
TileCondProxyFileFlt(
'TileCondProxyFile_NoiseSample', Source =
'TileDefault.ped')
56 raise(Exception(
"Invalid source: %s" % source))
58 TileSampleNoiseCondAlg = CompFactory.getComp(
"TileCondAlg<TileSampleNoise,TileCalibDrawerFlt>")
60 ConditionsProxy = sampleNoiseProxy,
61 TileCondData = sampleNoise)
63 acc.addCondAlgo(sampleNoiseCondAlg)
70 """Return component accumulator with configured private Tile sample noise tool
72 flags -- Athena configuration flags
74 Source -- source of Tile sample noise conditions (COOL, FILE). Defaults to COOL.
75 TileSampleNoise -- name of Tile sample noise conditions object. Defaults to TileSampleNoise.
76 TileOnlineSampleNoise -- name of Tile online sample noise conditions object. If it is not empty
77 online sample noise will be accessible in offline also and that allows
78 to get difference between pedestal used in online and corrected one
79 in offline. Proposed name: TileOnlineSampleNoise. Defaults to empty.
82 from AthenaCommon.Logging
import logging
83 msg = logging.getLogger(
'TileCondToolNoiseSample')
87 kwargs.setdefault(
'Source',
'COOL')
88 kwargs.setdefault(
'TileSampleNoise',
'TileSampleNoise')
90 sampleNoise = kwargs[
'TileSampleNoise']
91 onlineSampleNoise = kwargs.pop(
'TileOnlineSampleNoise',
'')
93 name =
'TileCondToolNoiseSample'
95 from TileConditions.TileEMScaleConfig
import TileEMScaleCondAlgCfg
100 if onlineSampleNoise:
101 if flags.Common.isOnline:
102 msg.warning(
'Not necessary to configure online sample noise in online especially')
103 onlineSampleNoise = sampleNoise
105 kwargs[
'TileSampleNoise'] = onlineSampleNoise
108 TileCondToolNoiseSample=CompFactory.TileCondToolNoiseSample
110 TileOnlineSampleNoise = onlineSampleNoise) )
115 if __name__ ==
"__main__":
117 from AthenaConfiguration.AllConfigFlags
import initConfigFlags
118 from AthenaConfiguration.TestDefaults
import defaultTestFiles
119 from AthenaCommon.Logging
import log
126 flags.Input.Files = defaultTestFiles.RAW_RUN2
127 flags.Common.isOnline =
True
133 print(sampleNoiseTool)
136 TileSampleNoise =
'TileSampleNoise',
137 TileOnlineSampleNoise =
'TileOnlineSampleNoise')
139 sampleNoiseTool = acc.popToolsAndMerge( accOnlSampleNoise )
140 print(sampleNoiseTool)
142 acc.printConfig(withDetails =
True, summariseProps =
True)
143 print(acc.getService(
'IOVDbSvc'))
144 acc.store(
open(
'TileSampleNoise.pkl',
'wb') )