ATLAS Offline Software
Loading...
Searching...
No Matches
TileRawChannelCorrectionConfig.py
Go to the documentation of this file.
1# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2
3"""Define method to construct configured Tile correction tools and algorithm"""
4
5from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
6from AthenaConfiguration.ComponentFactory import CompFactory
7from TileConfiguration.TileConfigFlags import TileRunType
8
9def TileRawChannelOF1CorrectorCfg(flags, **kwargs):
10 """Return component accumulator with configured private Tile OF1 raw channel correction tool
11
12 Arguments:
13 flags -- Athena configuration flags
14 """
15
16 acc = ComponentAccumulator()
17
18 kwargs.setdefault('CorrectPedestalDifference', flags.Tile.correctPedestalDifference)
19 kwargs.setdefault('ZeroAmplitudeWithoutDigits', flags.Tile.zeroAmplitudeWithoutDigits)
20 kwargs.setdefault('TileDigitsContainer', 'TileDigitsCnt')
21
22 if kwargs['CorrectPedestalDifference']:
23 from TileConditions.TileSampleNoiseConfig import TileSampleNoiseCondAlgCfg
24 acc.merge( TileSampleNoiseCondAlgCfg(flags, TileSampleNoise="TileSampleNoise") )
25 acc.merge( TileSampleNoiseCondAlgCfg(flags, ForceOnline=True, TileSampleNoise="TileOnlineSampleNoise") )
26
27 if 'TileCondToolTiming' not in kwargs:
28 from TileConditions.TileTimingConfig import TileCondToolOnlineTimingCfg
29 kwargs['TileCondToolTiming'] = acc.popToolsAndMerge( TileCondToolOnlineTimingCfg(flags) )
30
31 if 'TileCondToolOfc' not in kwargs:
32 from TileConditions.TileOFCConfig import TileCondToolOfcCoolCfg
33 kwargs['TileCondToolOfc'] = acc.popToolsAndMerge( TileCondToolOfcCoolCfg(flags, OfcType = 'OF1') )
34
35 if kwargs['ZeroAmplitudeWithoutDigits']:
36
37 if 'TileCondToolDspThreshold' not in kwargs:
38 from TileConditions.TileDSPThresholdConfig import TileCondToolDspThresholdCfg
39 kwargs['TileCondToolDspThreshold'] = acc.popToolsAndMerge( TileCondToolDspThresholdCfg(flags) )
40
41 if kwargs['CorrectPedestalDifference'] or kwargs['ZeroAmplitudeWithoutDigits']:
42 from TileConditions.TileEMScaleConfig import TileEMScaleCondAlgCfg
43 acc.merge( TileEMScaleCondAlgCfg(flags) )
44
45 TileRawChannelOF1Corrector=CompFactory.TileRawChannelOF1Corrector
46 acc.setPrivateTools( TileRawChannelOF1Corrector(**kwargs) )
47
48 return acc
49
50
51
52def TileRawChannelNoiseFilterCfg(flags, **kwargs):
53 """Return component accumulator with configured private Tile raw channel noise filter tool
54
55 Arguments:
56 flags -- Athena configuration flags (ConfigFlags)
57 """
58
59 acc = ComponentAccumulator()
60
61 from TileRecUtils.TileDQstatusConfig import TileDQstatusAlgCfg
62 acc.merge( TileDQstatusAlgCfg(flags) )
63
64 from TileConditions.TileInfoLoaderConfig import TileInfoLoaderCfg
65 acc.merge( TileInfoLoaderCfg(flags) )
66
67 from TileConditions.TileEMScaleConfig import TileEMScaleCondAlgCfg
68 acc.merge( TileEMScaleCondAlgCfg(flags) )
69
70 from TileConditions.TileSampleNoiseConfig import TileSampleNoiseCondAlgCfg
71 acc.merge( TileSampleNoiseCondAlgCfg(flags) )
72
73 from TileConditions.TileBadChannelsConfig import TileBadChannelsCondAlgCfg
74 acc.merge( TileBadChannelsCondAlgCfg(flags) )
75
76 TileRawChannelNoiseFilter=CompFactory.TileRawChannelNoiseFilter
77 acc.setPrivateTools( TileRawChannelNoiseFilter(**kwargs) )
78
79 return acc
80
81
82
83def TileTimeBCOffsetFilterCfg(flags, **kwargs):
84 """Return component accumulator with configured private Tile raw channel timing jump correction tool
85
86 Arguments:
87 flags -- Athena configuration flags (ConfigFlags)
88 EneThreshold3 - energy threshold on 3 channels in one DMU (in MeV)
89 EneThreshold1 - energy threshold on 1 channel (in MeV)
90 TimeThreshold - threshold on time difference (in ns)
91 """
92
93 acc = ComponentAccumulator()
94 kwargs.setdefault('CheckDCS', flags.Tile.useDCS)
95 kwargs.setdefault('EneThreshold3', 1000)
96 kwargs.setdefault('EneThreshold1', 3000)
97 kwargs.setdefault('TimeThreshold', 15)
98 kwargs.setdefault('AverTimeEneThreshold', 500)
99 kwargs.setdefault('RefTimeThreshold', 10)
100 kwargs.setdefault('SampleDiffMaxMin_HG', 15)
101 kwargs.setdefault('SampleDiffMaxMin_LG', -1)
102
103 from TileRecUtils.TileDQstatusConfig import TileDQstatusAlgCfg
104 acc.merge( TileDQstatusAlgCfg(flags) )
105
106 from TileConditions.TileCablingSvcConfig import TileCablingSvcCfg
107 acc.merge(TileCablingSvcCfg(flags))
108
109 from TileConditions.TileEMScaleConfig import TileEMScaleCondAlgCfg
110 acc.merge( TileEMScaleCondAlgCfg(flags) )
111
112 from TileConditions.TileBadChannelsConfig import TileBadChannelsCondAlgCfg
113 acc.merge( TileBadChannelsCondAlgCfg(flags) )
114
115 if kwargs['CheckDCS']:
116 from TileConditions.TileDCSConfig import TileDCSCondAlgCfg
117 acc.merge( TileDCSCondAlgCfg(flags) )
118
119 TileTimeBCOffsetFilter=CompFactory.TileTimeBCOffsetFilter
120 acc.setPrivateTools( TileTimeBCOffsetFilter(**kwargs) )
121
122 return acc
123
124
125
127 """Return component accumulator with configured private Tile raw channel correction tools
128
129 Arguments:
130 flags -- Athena configuration flags (ConfigFlags)
131 """
132
133 acc = ComponentAccumulator()
134
135 noiseFilterTools = []
136
137 if flags.Tile.correctPedestalDifference or flags.Tile.zeroAmplitudeWithoutDigits:
138 noiseFilterTools += [ acc.popToolsAndMerge( TileRawChannelOF1CorrectorCfg(flags) ) ]
139
140 if flags.Tile.NoiseFilter == 1:
141 noiseFilterTools += [ acc.popToolsAndMerge( TileRawChannelNoiseFilterCfg(flags) ) ]
142
143 if flags.Tile.correctTimeJumps:
144 noiseFilterTools += [ acc.popToolsAndMerge( TileTimeBCOffsetFilterCfg(flags) ) ]
145
146 acc.setPrivateTools( noiseFilterTools )
147
148 return acc
149
150
152 """Return component accumulator with configured Tile raw channel correction algorithm
153
154 Arguments:
155 flags -- Athena configuration flags (ConfigFlags)
156
157 Keyword arguments:
158 InputRawChannelContainer -- input Tile raw channel container. Defaults to TileRawChannelCnt.
159 OutputRawChannelContainer -- output Tile raw channel container. Defaults to TileRawChannelCntCorrected.
160 """
161
162 acc = ComponentAccumulator()
163
164 kwargs.setdefault('InputRawChannelContainer', 'TileRawChannelCnt')
165 kwargs.setdefault('OutputRawChannelContainer', 'TileRawChannelCntCorrected')
166
167 if 'NoiseFilterTools' not in kwargs:
168 kwargs['NoiseFilterTools'] = acc.popToolsAndMerge( TileRawChannelCorrectionToolsCfg(flags) )
169
170 TileRawChannelCorrectionAlg=CompFactory.TileRawChannelCorrectionAlg
171 acc.addEventAlgo(TileRawChannelCorrectionAlg(**kwargs), primary = True)
172
173 return acc
174
175
176
177if __name__ == "__main__":
178
179 from AthenaConfiguration.AllConfigFlags import initConfigFlags
180 from AthenaConfiguration.TestDefaults import defaultConditionsTags, defaultGeometryTags, defaultTestFiles
181 from AthenaCommon.Logging import log
182 from AthenaCommon.Constants import DEBUG
183
184 # Test setup
185 log.setLevel(DEBUG)
186
187 flags = initConfigFlags()
188 flags.Input.Files = defaultTestFiles.RAW_RUN2
189 flags.GeoModel.AtlasVersion = defaultGeometryTags.RUN2
190 flags.IOVDb.GlobalTag = defaultConditionsTags.RUN2_DATA
191 flags.Tile.RunType = TileRunType.PHY
192 flags.Tile.correctPedestalDifference = True
193 flags.Tile.zeroAmplitudeWithoutDigits = True
194 flags.lock()
195
196 from AthenaConfiguration.MainServicesConfig import MainServicesCfg
197 acc = MainServicesCfg(flags)
198
199 from TileByteStream.TileByteStreamConfig import TileRawDataReadingCfg
200 acc.merge( TileRawDataReadingCfg(flags, readMuRcv=False) )
201
202 acc.merge( TileRawChannelCorrectionAlgCfg(flags) )
203
204 flags.dump()
205 acc.printConfig(withDetails = True, summariseProps = True)
206 acc.store( open('TileRawChannelCorrection.pkl','wb') )
207
208 sc = acc.run(maxEvents = 3)
209
210 import sys
211 # Success should be 0
212 sys.exit(not sc.isSuccess())
213
This algorithm applies noise filter tools to input Tile raw channel container.
This tool subtracts common-mode noise from all TileRawChannels in one container.
This tool correct TileRawChannels amplitudes which came from OF1 DSP if pedestal changed.
This tool sets bad status for channels with 25ns or 50ns timing jump.