ATLAS Offline Software
Loading...
Searching...
No Matches
TileDigitsMonitorAlgorithm.py
Go to the documentation of this file.
2# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3#
4
5from TileConfiguration.TileConfigFlags import TileRunType
6
7'''
8@file TileDigitsMonitorAlgorithm.py
9@brief Python configuration of TileDigitsMonitorAlgorithm algorithm for the Run III
10'''
11def TileDigitsMonitoringConfig(flags, **kwargs):
12
13 ''' Function to configure TileDigitsMonitorAlgorithm algorithm in the monitoring system.'''
14
15 # Define one top-level monitoring algorithm. The new configuration
16 # framework uses a component accumulator.
17 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
18 result = ComponentAccumulator()
19
20 from TileRecUtils.TileDQstatusConfig import TileDQstatusAlgCfg
21 result.merge( TileDQstatusAlgCfg(flags) )
22
23 from TileGeoModel.TileGMConfig import TileGMCfg
24 result.merge(TileGMCfg(flags))
25
26 from TileConditions.TileCablingSvcConfig import TileCablingSvcCfg
27 result.merge(TileCablingSvcCfg(flags))
28
29 from TileConditions.TileInfoLoaderConfig import TileInfoLoaderCfg
30 result.merge(TileInfoLoaderCfg(flags))
31
32 runType = flags.Tile.RunType
33
34 kwargs.setdefault('name', 'TileDigitsMonAlg')
35 kwargs.setdefault('RunType', runType.getIntValue())
36
37 kwargs.setdefault('fillErrorsHistograms', True)
38 kwargs.setdefault('fillHighFrequencyNoiseHistograms', True)
39 kwargs.setdefault('fillEventModule32Histograms', True)
40 kwargs.setdefault('fillSamplesHistograms', True)
41 kwargs.setdefault('fillProfileHistograms', True)
42 kwargs.setdefault('fillPedestalHistograms', True)
43 kwargs.setdefault('fillCorrelationsHistograms', runType is TileRunType.PED)
44 kwargs.setdefault('TileRawChannelContainer', 'TileRawChannelCnt')
45
46 kwargs.setdefault('fillPedestalDifference', True)
47 if kwargs['fillPedestalDifference'] and 'TileCondToolNoiseSample' not in kwargs:
48 from TileConditions.TileSampleNoiseConfig import TileCondToolNoiseSampleCfg
49 sampleNoiseTool = result.popToolsAndMerge( TileCondToolNoiseSampleCfg(flags) )
50 kwargs['TileCondToolNoiseSample'] = sampleNoiseTool
51
52 # The following class will make a sequence, configure algorithms, and link
53 # them to GenericMonitoringTools
54 from AthenaMonitoring import AthMonitorCfgHelper
55 helper = AthMonitorCfgHelper(flags,'TileDigitsMonitoring')
56
57 # Adding an TileCellMonitorAlgorithm algorithm to the helper
58 from AthenaConfiguration.ComponentFactory import CompFactory
59 tileDigitsMonAlg = helper.addAlgorithm(CompFactory.TileDigitsMonitorAlgorithm, kwargs['name'])
60
61 for k, v in kwargs.items():
62 setattr(tileDigitsMonAlg, k, v)
63
64 run = str(flags.Input.RunNumbers[0])
65
66 # 1) Configure histogram with TileDigiNoiseMonAlg algorithm execution time
67 executeTimeGroup = helper.addGroup(tileDigitsMonAlg, 'TileDigitsMonExecuteTime', 'Tile/')
68 executeTimeGroup.defineHistogram('TIME_execute', path = 'Digits', type='TH1F',
69 title = 'Time for execute TileDigitsMonAlg algorithm;time [#mus]',
70 xbins = 200, xmin = 0, xmax = 200000)
71
72
73 from TileCalibBlobObjs.Classes import TileCalibUtils as Tile
74 from TileMonitoring.TileMonitoringCfgHelper import addTileChannelHistogramsArray
75
76 if kwargs['fillErrorsHistograms']:
77
78 # Configure histogram with overflows in high gain
79 overflowGroup = helper.addGroup(tileDigitsMonAlg, 'TileDigitsOverflow', 'Tile/')
80 overflowGroup.defineHistogram('charge;OverflowInHighGain', path = 'Digits/Summary', type='TH1D',
81 title = f'Run {run}: Injected charge with overflow in high gain;charge [pC]',
82 xbins = 10010, xmin = -0.5, xmax = 1000.5)
83
84
85 # Configure histograms with all Tile DMU Global CRC errors
86 crcGlobalDimensions = [int(Tile.MAX_ROS) - 1, int(Tile.MAX_DRAWER)]
87 crcGlobalArray = helper.addArray(crcGlobalDimensions, tileDigitsMonAlg, 'TileDigitsGlobalCRC', topPath = 'Tile/Digits')
88
89 for postfix, tool in crcGlobalArray.Tools.items():
90 ros, module = [int(x) for x in postfix.split('_')[1:]]
91 moduleName = Tile.getDrawerString(ros + 1, module)
92
93 fullName = f'CRC_global;{moduleName}_CRC_global'
94 fullTitle = f'Run {run} {moduleName}: Global CRC errors'
95
96 tool.defineHistogram(fullName, title = fullTitle, path = 'Summary', type = 'TH1I',
97 xbins = 3, xmin = -0.5, xmax = 2.5)
98
99
100 # Configure histograms with Tile DMU errors
101 maxDMUs = 16
102 dmuLabels = [str(dmu) for dmu in range(0, maxDMUs)]
103
104 dmuErrorLabels = ['OK', 'Format', 'Parity', 'Memory', 'SingleStrobe', 'DoubleStrobe', 'DummyFrag', 'NoDataFrag']
105 maxErrors = len(dmuErrorLabels)
106
107 errorsArray = helper.addArray([int(Tile.MAX_ROS - 1), int(Tile.MAX_DRAWER), int(Tile.MAX_GAIN)],
108 tileDigitsMonAlg, 'TileDigitsErrors', topPath = 'Tile/')
109 for postfix, tool in errorsArray.Tools.items():
110 ros, module, gain = [int(x) for x in postfix.split('_')[1:]]
111 gainName = {0 : 'low', 1 : 'high'}.get(gain)
112 moduleName = Tile.getDrawerString(ros + 1, module)
113
114 fullTitle = f'Run {run} {moduleName}: DMU Header {gainName} gain errors;DMU'
115 fullName = f'DMU,Error;{moduleName}_DMU_head__{gainName[:2]}_err'
116 fullPath = f'Digits/{moduleName}'
117
118 tool.defineHistogram(fullName, title = fullTitle, type = 'TH2F', path = fullPath,
119 xlabels = dmuLabels, ylabels = dmuErrorLabels,
120 xbins = maxDMUs, xmin = 0.0, xmax = maxDMUs,
121 ybins = maxErrors, ymin = 0.0, ymax = maxErrors)
122
123
124 # Configure histograms with all Tile DMU CRC errors
125 crcErrDimensions = [int(Tile.MAX_ROS) - 1, int(Tile.MAX_DRAWER)]
126 crcErrArray = helper.addArray(crcErrDimensions, tileDigitsMonAlg, 'TileDigitsCRCErrors', topPath = 'Tile/Digits')
127
128 for postfix, tool in crcErrArray.Tools.items():
129 ros, module = [int(x) for x in postfix.split('_')[1:]]
130 moduleName = Tile.getDrawerString(ros + 1, module)
131 fullPath = moduleName
132
133 for dmu in range(0, maxDMUs):
134 dmuName = f'0{dmu}' if dmu < 10 else str(dmu)
135 fullName = f'CRC_err_{dmu};{moduleName}_dmu_{dmuName}_CRC_err'
136 fullTitle = f'Run {run} {moduleName} DMU {dmuName}: CRC errors'
137
138 tool.defineHistogram(fullName, title = fullTitle, path = fullPath, type = 'TH1I',
139 xbins = 5, xmin = -0.5, xmax = 4.5)
140
141
142 # Configure histograms with all Tile DMU BCID
143 bcidDimensions = [int(Tile.MAX_ROS) - 1, int(Tile.MAX_DRAWER), int(Tile.MAX_GAIN)]
144 bcidArray = helper.addArray(bcidDimensions, tileDigitsMonAlg, 'TileDigitsBCID', topPath = 'Tile/Digits')
145
146 for postfix, tool in bcidArray.Tools.items():
147 ros, module, gain = [int(x) for x in postfix.split('_')[1:]]
148 moduleName = Tile.getDrawerString(ros + 1, module)
149 gainName = {0 : 'low', 1 : 'high'}.get(gain)
150 fullPath = moduleName
151
152 for dmu in range(0,maxDMUs):
153 dmuName = f'0{dmu}' if dmu < 10 else str(dmu)
154 fullName = f'BCID_{dmu};{moduleName}_dmu_{dmuName}_{gainName[:2]}_BCID'
155 fullTitle = f'Run {run} {moduleName} DMU {dmuName} {gainName} gain: BCID'
156
157 tool.defineHistogram(fullName, title = fullTitle, path = fullPath, type = 'TH1I',
158 xbins = 100, xmin = 2050.5, xmax = 2150.5)
159
160
161 # Configure histograms with all Tile DMU BCID Errors
162 bcidErrDimensions = [int(Tile.MAX_ROS) - 1, int(Tile.MAX_DRAWER), int(Tile.MAX_GAIN)]
163 bcidErrArray = helper.addArray(bcidErrDimensions, tileDigitsMonAlg, 'TileDigitsBCIDErrors', topPath = 'Tile/Digits')
164
165 for postfix, tool in bcidErrArray.Tools.items():
166 ros, module, gain = [int(x) for x in postfix.split('_')[1:]]
167 moduleName = Tile.getDrawerString(ros + 1, module)
168 gainName = {0 : 'low', 1 : 'high'}.get(gain)
169 fullPath = moduleName
170
171 for dmu in range(0, maxDMUs):
172 dmuName = f'0{dmu}' if dmu < 10 else str(dmu)
173 fullName = f'BCID_err_{dmu};{moduleName}_dmu_{dmuName}_{gainName[:2]}_BCID_err'
174 fullTitle = f'Run {run} {moduleName} DMU {dmuName} {gainName} gain: BCID errors'
175
176 tool.defineHistogram(fullName, title = fullTitle, path = fullPath, type = 'TH1I',
177 xbins = 3, xmin = -0.5, xmax = 2.5)
178
179
180 if kwargs['fillCorrelationsHistograms']:
181 # Configure histograms with average sample in Tile channels per module and gain
182 meanSampleArray = helper.addArray([2], tileDigitsMonAlg, 'TileDigitsMeanSample', topPath = 'Tile/Digits')
183 for postfix, tool in meanSampleArray.Tools.items():
184 gain = int(postfix.split('_').pop())
185 gainName = {0 : 'low', 1 : 'high'}.get(gain)
186 for ros in range(1, Tile.MAX_ROS):
187 for module in range(0, Tile.MAX_DRAWER):
188 moduleName = Tile.getDrawerString(ros, module)
189
190 fullName = f'channel_{moduleName},meanSample_{moduleName};{moduleName}_{gainName[:2]}_mean_sample'
191 fullTitle = f'Run {run} {moduleName} {gainName} gain: Average sample'
192
193 tool.defineHistogram(fullName, title = fullTitle, path = moduleName, type = 'TProfile',
194 xbins = Tile.MAX_CHAN, xmin = -0.5, xmax = Tile.MAX_CHAN - 0.5)
195
196 # Configure histograms with average sum of samples in Tile channels per module and gain
197 meanSampleProdArray = helper.addArray([2], tileDigitsMonAlg, 'TileDigitsMeanSampleProd', topPath = 'Tile/Digits')
198 for postfix, tool in meanSampleProdArray.Tools.items():
199 gain = int(postfix.split('_').pop())
200 gainName = {0 : 'low', 1 : 'high'}.get(gain)
201 for ros in range(1, Tile.MAX_ROS):
202 for module in range(0, Tile.MAX_DRAWER):
203 moduleName = Tile.getDrawerString(ros, module)
204
205 fullName = f'channel1_{moduleName},channel2_{moduleName},meanSampleProd_{moduleName};'
206 fullName += f'{moduleName}_{gainName[:2]}_mean_sample_prod'
207 fullTitle = f'Run {run} {moduleName} {gainName} gain: Average samples product'
208
209 tool.defineHistogram(fullName, title = fullTitle, path = moduleName, type = 'TProfile2D',
210 xbins = Tile.MAX_CHAN, xmin = -0.5, xmax = Tile.MAX_CHAN - 0.5,
211 ybins = Tile.MAX_CHAN, ymin = -0.5, ymax = Tile.MAX_CHAN - 0.5)
212
213
214 if kwargs['fillPedestalHistograms']:
215 # Configure histograms with Tile channel pedestals per module, channel and gain
216 addTileChannelHistogramsArray(helper, tileDigitsMonAlg, name = 'TileDigitsSample0',
217 title = 'Pedestal, sample[0]', path = 'Tile/Digits', type = 'TH1I',
218 xvalue = 'sample0', xbins = 151, xmin = -0.5, xmax = 150.5, run = run)
219
220 if kwargs['fillHighFrequencyNoiseHistograms']:
221 # Configure histograms with Tile channel HFN per module, channel and gain
222 addTileChannelHistogramsArray(helper, tileDigitsMonAlg, name = 'TileDigitsMeanRMS',
223 title = 'Mean RMS in event', path = 'Tile/Digits', type = 'TH1F',
224 xvalue = 'meanRMS', xbins = 101, xmin = -0.05, xmax = 10.5, run = run)
225
226 if kwargs['fillSamplesHistograms']:
227 # Configure histograms with all Tile channel samples per module, channel and gain
228 addTileChannelHistogramsArray(helper, tileDigitsMonAlg, name = 'TileDigitsSamples',
229 title = 'All samples', path = 'Tile/Digits', type = 'TH1I',
230 xvalue = 'samples', xbins = 1025, xmin = -0.5, xmax = 1024.5, run = run)
231
232 if kwargs['fillProfileHistograms']:
233 # Configure histograms with Tile channel average profile per module, channel and gain
234 addTileChannelHistogramsArray(helper, tileDigitsMonAlg, name = 'TileDigitsProfile',
235 title = 'Average profile', path = 'Tile/Digits', type = 'TProfile',
236 xvalue = 'sampleNumbers', xbins = 7, xmin = -0.5, xmax = 6.5,
237 run = run, value = 'samples', aliasSuffix = 'prof')
238
239 if kwargs['fillEventModule32Histograms']:
240 # Configure histograms with all Tile channel samples per module, channel and gain
241 addTileChannelHistogramsArray(helper, tileDigitsMonAlg, name = 'TileDigitsEvtMod32',
242 title = 'Event number % 32', path = 'Tile/Digits', type = 'TH1I',
243 xvalue = 'evtn_mod32', xbins = 32, xmin = -0.5, xmax = 31.5, run = run)
244
245 accumalator = helper.result()
246 result.merge(accumalator)
247 return result
248
249if __name__=='__main__':
250
251 # Setup logs
252 from AthenaCommon.Logging import log
253 from AthenaCommon.Constants import INFO
254 log.setLevel(INFO)
255
256 # Set the Athena configuration flags
257 from AthenaConfiguration.AllConfigFlags import initConfigFlags
258 from AthenaConfiguration.TestDefaults import defaultConditionsTags, defaultGeometryTags, defaultTestFiles
259 flags = initConfigFlags()
260 flags.Input.Files = defaultTestFiles.RAW_RUN2
261 flags.GeoModel.AtlasVersion = defaultGeometryTags.RUN2
262 flags.IOVDb.GlobalTag = defaultConditionsTags.RUN2_DATA
263 flags.Output.HISTFileName = 'TileDigitsMonitorOutput2.root'
264 flags.DQ.useTrigger = False
265 flags.DQ.enableLumiAccess = False
266 flags.Exec.MaxEvents = 3
267 flags.fillFromArgs()
268 flags.lock()
269
270 # Initialize configuration object, add accumulator, merge, and run.
271 from AthenaConfiguration.MainServicesConfig import MainServicesCfg
272 cfg = MainServicesCfg(flags)
273
274 from TileByteStream.TileByteStreamConfig import TileRawDataReadingCfg
275 cfg.merge( TileRawDataReadingCfg(flags, readMuRcv=False, readBeamElem=True) )
276
277 cfg.merge( TileDigitsMonitoringConfig(flags, name = 'TileDigitsMonAlg',
278 fillPedestalDifference = False) )
279
280 cfg.printConfig(withDetails = True, summariseProps = True)
281 flags.dump()
282
283 cfg.store( open('TileDigitsMonitorAlgorithm.pkl','wb') )
284
285 sc = cfg.run()
286
287 import sys
288 # Success should be 0
289 sys.exit(not sc.isSuccess())
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition hcg.cxx:130