ATLAS Offline Software
TileDQFragMonitorAlgorithm.py
Go to the documentation of this file.
1 #
2 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 #
4 
5 '''
6 @file TileDQFragMonitorAlgorithm.py
7 @brief Python configuration of TileDQFragMonitorAlgorithm algorithm for the Run III
8 '''
9 
10 def TileDQFragMonitoringConfig(flags, **kwargs):
11 
12  ''' Function to configure TileDQFragMonitorAlgorithm algorithm in the monitoring system.'''
13 
14  from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
15  result = ComponentAccumulator()
16 
17  from DetDescrCnvSvc.DetDescrCnvSvcConfig import DetDescrCnvSvcCfg
18  result.merge(DetDescrCnvSvcCfg(flags))
19 
20  from TileConditions.TileCablingSvcConfig import TileCablingSvcCfg
21  result.merge( TileCablingSvcCfg(flags) )
22 
23  from TileRecUtils.TileDQstatusConfig import TileDQstatusAlgCfg
24  result.merge( TileDQstatusAlgCfg(flags) )
25 
26  from TileConditions.TileInfoLoaderConfig import TileInfoLoaderCfg
27  result.merge( TileInfoLoaderCfg(flags) )
28 
29  from TileConditions.TileEMScaleConfig import TileEMScaleCondAlgCfg
30  result.merge( TileEMScaleCondAlgCfg(flags) )
31 
32  from TileConditions.TileBadChannelsConfig import TileBadChannelsCondAlgCfg
33  result.merge( TileBadChannelsCondAlgCfg(flags) )
34 
35  kwargs.setdefault('CheckDCS', flags.Tile.useDCS)
36  if kwargs['CheckDCS']:
37  from TileConditions.TileDCSConfig import TileDCSCondAlgCfg
38  result.merge( TileDCSCondAlgCfg(flags) )
39 
40  rawChannelContainer = flags.Tile.RawChannelContainer
41 
42  from AthenaConfiguration.Enums import Format
43  if flags.Input.Format is Format.POOL:
44  kwargs.setdefault('TileDigitsContainer', 'TileDigitsFlt')
45  if rawChannelContainer not in flags.Input.Collections:
46  rawChannelContainer = ''
47 
48  kwargs.setdefault('TileRawChannelContainer', rawChannelContainer)
49 
50  from AthenaCommon.SystemOfUnits import GeV
51  kwargs.setdefault('MinEnergyChan', -5.0 * GeV)
52  kwargs.setdefault('MinEnergyGap', -10.0 * GeV)
53  kwargs.setdefault('fillDigiErrorsHistogramsPerLB', flags.Common.isOnline)
54  fillDigiErrorsHistogramsPerLB = kwargs['fillDigiErrorsHistogramsPerLB']
55 
56  runNumber = flags.Input.RunNumbers[0]
57  run = str(runNumber)
58 
59  # The following class will make a sequence, configure algorithms, and link
60  # them to GenericMonitoringTools
61  from AthenaMonitoring import AthMonitorCfgHelper
62  helper = AthMonitorCfgHelper(flags, 'TileDQFragMonAlgCfg')
63 
64  from AthenaConfiguration.ComponentFactory import CompFactory
65  tileDQFragMonAlg = helper.addAlgorithm(CompFactory.TileDQFragMonitorAlgorithm, 'TileDQFragMonAlg')
66 
67  for k, v in kwargs.items():
68  setattr(tileDQFragMonAlg, k, v)
69 
70  # 1) Configure histogram with TileDQFragMonAlg algorithm execution time
71  executeTimeGroup = helper.addGroup(tileDQFragMonAlg, 'TileDQFragMonExecuteTime', 'Tile/')
72  executeTimeGroup.defineHistogram('TIME_execute', path = 'DMUErrors', type='TH1F',
73  title = 'Time for execute TileDQFragMonAlg algorithm;time [#mus]',
74  xbins = 300, xmin = 0, xmax = 300000)
75 
76  # 2) Configure histogram with Tile error state in EventInfo vs lumi block
77  errorStateGroup = helper.addGroup(tileDQFragMonAlg, 'TileEventsWithErrEventInfoLB', 'Tile/DMUErrors')
78  errorStateGroup.defineHistogram('lumiBlock;TileEventsWithErrEventInfo', path = 'BadDrawers', type='TH1F',
79  title = 'Run ' + run + ': # events with Tile error state in EventInfo;LumiBlock;# events with error',
80  xbins = 1000, xmin = -0.5, xmax = 999.5, opt = 'kAddBinsDynamically', merge = 'merge')
81 
82  # 3) Configure histogram with number of consecutive bad Tile modules
83  consecutiveBadGroup = helper.addGroup(tileDQFragMonAlg, 'TileConsecutiveBadModules', 'Tile/DMUErrors')
84  consecutiveBadGroup.defineHistogram('TileConsecutiveBad', path = 'BadDrawers', type='TH1F',
85  title = 'Run ' + run + ': Max # Tile consecutive bad modules;# consecutive bad modules;N',
86  xbins = 17, xmin = -0.5, xmax = 16.5)
87 
88  # 4) Configure histogram with number of consecutive bad Tile modules per lumi block
89  consecutiveBadLBGroup = helper.addGroup(tileDQFragMonAlg, 'TileConsecutiveBadModulesLB', 'Tile/DMUErrors')
90  consecutiveBadLBGroup.defineHistogram('lumiBlock,TileConsecutiveBad;TileConsecutiveBadLB', path = 'BadDrawers', type='TH2F',
91  title = 'Run ' + run + ': Max # Tile consecutive bad modules;LumiBlock;# consecutive bad modules',
92  xbins = 1000, xmin = -0.5, xmax = 999.5, ybins = 17, ymin = -0.5, ymax = 16.5,
93  opt = 'kAddBinsDynamically', merge = 'merge')
94 
95 
96  from TileMonitoring.TileMonitoringCfgHelper import getPartitionName
97  from TileCalibBlobObjs.Classes import TileCalibUtils as Tile
98 
99  # 5) Configure histogram with mismatched L1 trigger type of Tile module
100  moduleLabels = [str(module) for module in range(1, Tile.MAX_DRAWER + 1)]
101  partitionLabels = [getPartitionName(ros) for ros in range(1, Tile.MAX_ROS)]
102 
103  mismatchedLVL1Group = helper.addGroup(tileDQFragMonAlg, 'TileMismatchedL1TriggerType', 'Tile/')
104  mismatchedLVL1Group.defineHistogram('module,ROS;TileMismatchedL1TriggerType', path = 'DMUErrors',
105  title = 'Run ' + run + ': Tile mismatched L1 Trigger Type;Module;Partition',
106  type = 'TH2F', xlabels = moduleLabels, ylabels = partitionLabels,
107  xbins = Tile.MAX_DRAWER, xmin = -0.5, xmax = Tile.MAX_DRAWER - 0.5,
108  ybins = Tile.MAX_ROS - 1, ymin = 1.0, ymax = Tile.MAX_ROS)
109 
110  # 6) Configure histogram with no all Tile digits in the case of Trigger Type = 0x82
111  noAllDigitsGroup = helper.addGroup(tileDQFragMonAlg, 'TileNoAllDigits', 'Tile/')
112  noAllDigitsGroup.defineHistogram('module,ROS;TileNoalldigits', path = 'DMUErrors', type = 'TH2F',
113  title = 'Run ' + run + ': No All Tile digits in event with Trigger Type = 0x82;Module;Partition',
114  xlabels = moduleLabels, ylabels = partitionLabels,
115  xbins = Tile.MAX_DRAWER, xmin = -0.5, xmax = Tile.MAX_DRAWER - 0.5,
116  ybins = Tile.MAX_ROS - 1, ymin = 1.0, ymax = Tile.MAX_ROS)
117 
118  # ) Configure histogram with global CRC errors vs module and partition
119  globalCRCGroup = helper.addGroup(tileDQFragMonAlg, 'TileBadGlobalCRC', 'Tile/')
120  globalCRCGroup.defineHistogram('module,ROS;TileBadGlobalCRC', path = 'DMUErrors', type = 'TH2F',
121  title = 'Run ' + run + ': Global CRC errors;Module;Partition',
122  xlabels = moduleLabels, ylabels = partitionLabels,
123  xbins = Tile.MAX_DRAWER, xmin = -0.5, xmax = Tile.MAX_DRAWER - 0.5,
124  ybins = Tile.MAX_ROS - 1, ymin = 1.0, ymax = Tile.MAX_ROS)
125 
126  # 7) Configure histograms with Tile DMU errors
127  maxDMUs = 16
128  dmuLabels = [str(dmu) for dmu in range(0, maxDMUs)]
129 
130  dmuErrorLabels = ['OK', 'HEADER_FORM', 'HEADER_PAR', 'MEMO_PAR', 'FE_CRC', 'ROD_CRC', 'BCID']
131  dmuErrorLabels += ['SAMPLE_FORM', 'SAMPLE_PAR', 'DOUBLE_STB', 'SINGLE_STB', 'GLOBAL_CRC']
132  dmuErrorLabels += ['DUMMY_FRAG', 'NO_RECO_FRAG', 'MASKED', 'ALL_M_BAD_DCS', 'ANY_CH_BAD_HV']
133 
134  dmuErrorLabels += ['0 -> 1023', 'Zeros', 'Two 1023 + ped', 'Jump 2 levels', 'Single Up + ped']
135  dmuErrorLabels += ['Single Dn + ped', 'Single Up + sig', 'Single Dn + sig', 'Ped > 200 LG']
136  dmuErrorLabels += ['Single Dn LG_s0', 'Single Dn LG_s6', 'Up LG_s0_s6 or Gap', 'Dn LG_s0_s6 or Gap']
137  dmuErrorLabels += ['Bad quality', 'Big negative ene']
138 
139  maxErrors = len(dmuErrorLabels)
140 
141  errorsArray = helper.addArray([int(Tile.MAX_ROS - 1), int(Tile.MAX_DRAWER)],
142  tileDQFragMonAlg, 'TileDigiErrors', topPath = 'Tile/')
143  for postfix, tool in errorsArray.Tools.items():
144  ros, module = [int(x) for x in postfix.split('_')[1:]]
145 
146  moduleName = Tile.getDrawerString(ros + 1, module)
147  title = 'Run ' + run + ': ' + moduleName + ' Channel and DMU Header Errors;DMU'
148  name = 'DMU,Error;TileDigiErrors' + moduleName
149 
150  tool.defineHistogram(name, title = title, type = 'TH2F', path = 'DMUErrors',
151  xlabels = dmuLabels, ylabels = dmuErrorLabels,
152  xbins = maxDMUs, xmin = 0.0, xmax = maxDMUs,
153  ybins = maxErrors, ymin = 0.0, ymax = maxErrors)
154 
155 
156  if fillDigiErrorsHistogramsPerLB:
157  kLBNHistoryDepth = 2
158  errorsInLBArray = helper.addArray([int(Tile.MAX_ROS - 1), int(Tile.MAX_DRAWER)],
159  tileDQFragMonAlg, 'TileDigiErrorsInLB', topPath = 'Tile/')
160  for postfix, tool in errorsInLBArray.Tools.items():
161  ros, module = [int(x) for x in postfix.split('_')[1:]]
162 
163  moduleName = Tile.getDrawerString(ros + 1, module)
164  title = 'Run ' + run + ': ' + moduleName + f' Channel and DMU Header Errors (reset every {kLBNHistoryDepth} LBs);DMU'
165  name = 'DMU,Error;TileDigiErrors' + moduleName
166 
167  tool.defineHistogram(name, title = title, type = 'TH2F', path = 'DMUErrors/LB',
168  opt = f'kLBNHistoryDepth={kLBNHistoryDepth}', xlabels = dmuLabels, ylabels = dmuErrorLabels,
169  xbins = maxDMUs, xmin = 0.0, xmax = maxDMUs,
170  ybins = maxErrors, ymin = 0.0, ymax = maxErrors)
171 
172 
173  # 8) Configure histograms with fraction of events/DMUs Tile DMU errors vs lumi blocks
174  errorsVsLBArray = helper.addArray([int(Tile.MAX_ROS - 1), int(Tile.MAX_DRAWER)],
175  tileDQFragMonAlg, 'FracTileDigiErrors', topPath = 'Tile/')
176  for postfix, tool in errorsVsLBArray.Tools.items():
177  ros, module = [int(x) for x in postfix.split('_')[1:]]
178 
179  moduleName = Tile.getDrawerString(ros + 1, module)
180  title = 'Run ' + run + ': ' + moduleName + ' (#total_events - #ok_events)/(#total_events)'
181  title += ';LumiBlock;Fraction of Digital errors'
182  name = 'lumiBlock,fractionOfBadDMUs;FracTileDigiErrors' + moduleName
183 
184  tool.defineHistogram(name, title = title, path = 'DMUErrors', type = 'TProfile',
185  xbins = 1000, xmin = -0.5, xmax = 999.5, opt = 'kAddBinsDynamically', merge = 'merge')
186 
187 
188 
189  from TileMonitoring.TileMonitoringCfgHelper import addTileModuleChannelMapsArray
190 
191  # 9) Configure histograms with # of jumps errors per Tile partition
192  addTileModuleChannelMapsArray(helper, tileDQFragMonAlg, path = 'Tile/DMUErrors/BadDrawers',
193  name = 'TileBadChannelsJumpMap', title = '# Jump errors',
194  run = run)
195 
196  # 10) Configure histograms with # of not masked jumps errors per Tile partition
197  addTileModuleChannelMapsArray(helper, tileDQFragMonAlg, path = 'Tile/DMUErrors/BadDrawers',
198  name = 'TileBadChannelsJumpNotMaskMap', title = '# Not masked Jump errors',
199  run = run)
200 
201 
202  # 11) Configure histograms with Tile bad pulse shape
203  addTileModuleChannelMapsArray(helper, tileDQFragMonAlg, path = 'Tile/DMUErrors/BadDrawers',
204  name = 'TileBadPulseQualityMap', run = run,
205  title = 'Bad pulse shape or #chi^{2} from Optimal Filtering algirithm')
206 
207  # 12) Configure histograms with Tile channel negative amplitudes below threshold
208  addTileModuleChannelMapsArray(helper, tileDQFragMonAlg, path = 'Tile/DMUErrors/BadDrawers',
209  name = 'TileBadChannelsNegMap', title = '# Negative amplitude',
210  run = run)
211 
212  # 13) Configure histograms with not masked Tile channel negative amplitudes below threshold
213  addTileModuleChannelMapsArray(helper, tileDQFragMonAlg, path = 'Tile/DMUErrors/BadDrawers',
214  name = 'TileBadChannelsNegNotMaskMap', run = run,
215  title = '# Not masked negative amplitude')
216 
217 
218  # 14) Configure histograms with Tile with negative energy below threshold
219  negEneMapTitle = f"# Negative energy below {kwargs['MinEnergyChan']/GeV} ({kwargs['MinEnergyGap']/GeV} for E cels) GeV"
220  addTileModuleChannelMapsArray(helper, tileDQFragMonAlg, path = 'Tile/DMUErrors/BadDrawers',
221  name = 'TileNegativeEnergyMap', run = run, title = negEneMapTitle)
222 
223  accumalator = helper.result()
224  result.merge(accumalator)
225  return result
226 
227 
228 if __name__=='__main__':
229 
230  # Setup logs
231  from AthenaCommon.Logging import log
232  from AthenaCommon.Constants import INFO
233  log.setLevel(INFO)
234 
235  # Set the Athena configuration flags
236  from AthenaConfiguration.AllConfigFlags import initConfigFlags
237  from AthenaConfiguration.TestDefaults import defaultConditionsTags, defaultGeometryTags, defaultTestFiles
238  flags = initConfigFlags()
239  flags.Input.Files = defaultTestFiles.RAW_RUN2
240  flags.GeoModel.AtlasVersion = defaultGeometryTags.RUN2
241  flags.IOVDb.GlobalTag = defaultConditionsTags.RUN2_DATA
242  flags.Output.HISTFileName = 'TileDQFragMonitorOutput.root'
243  flags.DQ.useTrigger = False
244  flags.DQ.enableLumiAccess = False
245  flags.Tile.doOptATLAS = True
246  flags.Exec.MaxEvents = 3
247  flags.fillFromArgs()
248  flags.lock()
249 
250  # Initialize configuration object, add accumulator, merge, and run.
251  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
252  cfg = MainServicesCfg(flags)
253 
254  from TileByteStream.TileByteStreamConfig import TileRawDataReadingCfg
255  cfg.merge( TileRawDataReadingCfg(flags, readMuRcv=False) )
256 
257  from TileRecUtils.TileRawChannelMakerConfig import TileRawChannelMakerCfg
258  cfg.merge( TileRawChannelMakerCfg(flags) )
259 
260  cfg.merge( TileDQFragMonitoringConfig(flags) )
261 
262  cfg.printConfig(withDetails = True, summariseProps = True)
263 
264  cfg.store( open('TileDQFragMonitorAlgorithm.pkl','wb') )
265 
266  sc = cfg.run()
267 
268  import sys
269  # Success should be 0
270  sys.exit(not sc.isSuccess())
SystemOfUnits
TileMonitoringCfgHelper.addTileModuleChannelMapsArray
def addTileModuleChannelMapsArray(helper, algorithm, name, title, path, weight='', subDirectory=False, type='TH2D', value='', run='', triggers=[], perGain=False, separator='_')
Definition: TileMonitoringCfgHelper.py:370
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
python.TileInfoLoaderConfig.TileInfoLoaderCfg
def TileInfoLoaderCfg(flags, **kwargs)
Definition: TileInfoLoaderConfig.py:12
python.DetDescrCnvSvcConfig.DetDescrCnvSvcCfg
def DetDescrCnvSvcCfg(flags, **kwargs)
Definition: DetDescrCnvSvcConfig.py:6
TileDQstatusConfig.TileDQstatusAlgCfg
def TileDQstatusAlgCfg(flags, **kwargs)
Definition: TileDQstatusConfig.py:31
python.TileBadChannelsConfig.TileBadChannelsCondAlgCfg
def TileBadChannelsCondAlgCfg(flags, **kwargs)
Definition: TileBadChannelsConfig.py:10
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:260
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
Constants
some useful constants -------------------------------------------------—
TileMonitoringCfgHelper.getPartitionName
def getPartitionName(ros)
Definition: TileMonitoringCfgHelper.py:40
python.TileEMScaleConfig.TileEMScaleCondAlgCfg
def TileEMScaleCondAlgCfg(flags, **kwargs)
Definition: TileEMScaleConfig.py:10
python.TileDCSConfig.TileDCSCondAlgCfg
def TileDCSCondAlgCfg(flags, **kwargs)
Definition: TileDCSConfig.py:8
Trk::open
@ open
Definition: BinningType.h:40
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
TileDQFragMonitorAlgorithm.TileDQFragMonitoringConfig
def TileDQFragMonitoringConfig(flags, **kwargs)
Definition: TileDQFragMonitorAlgorithm.py:10
TileByteStreamConfig.TileRawDataReadingCfg
def TileRawDataReadingCfg(flags, readDigits=True, readRawChannel=True, readMuRcv=None, readMuRcvDigits=False, readMuRcvRawCh=False, readBeamElem=None, readLaserObj=None, readDigitsFlx=False, readL2=False, stateless=False, **kwargs)
Definition: TileByteStreamConfig.py:87
TileRawChannelMakerConfig.TileRawChannelMakerCfg
def TileRawChannelMakerCfg(flags, **kwargs)
Definition: TileRawChannelMakerConfig.py:10
str
Definition: BTagTrackIpAccessor.cxx:11
python.TileCablingSvcConfig.TileCablingSvcCfg
def TileCablingSvcCfg(flags)
Definition: TileCablingSvcConfig.py:11