ATLAS Offline Software
TileMonitoringCfgHelper.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 @file TileMonitoringHelper.py
6 @brief Helper functions for Run 3 Tile monitoring algorithm configuration
7 '''
8 
9 from TileCalibBlobObjs.Classes import TileCalibUtils as Tile
10 _cellNameEB = ['E3', 'E4', 'D4', 'D4', 'C10', 'C10', 'A12', 'A12', 'B11', 'B11', 'A13', 'A13',
11  'E1', 'E2', 'B12', 'B12', 'D5', 'D5', 'E3*', 'E4*', 'A14', 'A14', 'B13', 'B13',
12  '', '', '', '', '', '', 'B14', 'A15', 'A15', '', '', 'B14',
13  'B15', 'D6', 'D6', 'B15', 'A16', 'A16', '', '', '', '', '', '']
14 
15 
16 _cellNameLB = ['D0', 'A1', 'B1', 'B1', 'A1', 'A2', 'B2', 'B2', 'A2', 'A3', 'A3', 'B3',
17  'B3', 'D1', 'D1', 'A4', 'B4', 'B4', 'A4', 'A5', 'A5', 'B5', 'B5', 'A6',
18  'D2', 'D2', 'A6', 'B6', 'B6', 'A7', '', '', 'A7', 'B7', 'B7', 'A8',
19  'A9', 'A9', 'A8', 'B8', 'B8', 'D3', 'B9', '', 'D3', 'A10', 'A10', 'B9']
20 
21 
22 _partitionName = {0: 'AUX', 1 : 'LBA', 2 : 'LBC', 3 : 'EBA', 4 : 'EBC', 5 : 'AllPart'}
23 _gainName = {0 : 'LG', 1 : 'HG'}
24 _sampleName = {0 : 'SampA', 1 : 'SampB', 2 : 'SampD', 3 : 'SampE', 4 : 'AllSamp'}
25 
26 _cellNameTMDB_LB = ["D0", "D1L", "D1R", "D2R", "D2L", "D3L", "D3R", ""]
27 _cellNameTMDB_EB = ["D5L", "D5R", "D6L", "D6R"]
28 
29 def getCellName(partition, channel):
30  '''
31  This function returns name of Tile cell for given partition and channel.
32 
33  Arguments:
34  partition -- Tile partition name (LBA, LBC, EBA, EBC)
35  channel -- Tile channel number ([0..47])
36  '''
37  return _cellNameLB[channel] if partition.startswith('L') else _cellNameEB[channel]
38 
39 
41  '''
42  This function returns name of Tile partition for given ROS.
43 
44  Arguments:
45  ros -- Tile ROS ([0..5])
46  '''
47  return _partitionName[ros]
48 
49 
50 def getGainName(gain):
51  '''
52  This function returns name of Tile gain name
53 
54  Arguments:
55  gain -- Tile gain ([0,1])
56  '''
57  return _gainName[int(gain)]
58 
59 
60 def getSampleName(sample):
61  '''
62  This function returns name of Tile sample name
63 
64  Arguments:
65  sample -- Tile sample ([0..4])
66  '''
67  return _sampleName[int(sample)]
68 
69 
70 def getTileHistogramName(name, separator = '_', **kwargs):
71  '''
72  This function returns name of Tile histogram.
73 
74  Arguments:
75  name -- Name of histogram, actual name is constructed dynamicaly like:
76  name [+ partition] [+ sample] [+gain] [+ trigger]
77  separator -- Separtor between name, partition, sample, gain, and trigger
78  '''
79 
80  partition = kwargs.get('partition', '')
81  trigger = kwargs.get('trigger', '')
82  sample = kwargs.get('sample', '')
83  gain = kwargs.get('gain', '')
84 
85  fullName = name
86  fullName += separator + partition if partition else ''
87  fullName += separator + sample if sample else ''
88  fullName += separator + gain if gain else ''
89  fullName += separator + trigger if trigger else ''
90 
91  return fullName
92 
93 
94 def getTileHistogramTitle(title, **kwargs):
95  '''
96  This function returns title of Tile histogram.
97 
98  Arguments:
99  title -- Title of histogram, actual title is constructed dynamicaly like:
100  [run +] [trigger +] [partion +] [sample +] [gain +] title
101  '''
102 
103  partition = kwargs.get('partition', '')
104  trigger = kwargs.get('trigger', '')
105  sample = kwargs.get('sample', '')
106  gain = kwargs.get('gain', '')
107  run = kwargs.get('run', '')
108 
109  fullTitle = 'Partition ' + partition if partition else ''
110  fullTitle += ' Tile Cell ' + sample + ' ' if sample else ''
111  fullTitle += ' ' + gain if gain else ''
112  fullTitle += ': ' + title
113 
114  fullTitle = 'Trigger ' + trigger + ' ' + fullTitle if trigger else fullTitle
115  fullTitle = 'Run ' + run + ' ' + fullTitle if run else fullTitle
116 
117  return fullTitle
118 
119 
120 def getTileHistogramPath(path, **kwargs):
121  '''
122  This function returns path of Tile histogram.
123 
124  Arguments:
125  path -- Path of histogram, actual path is constructed dynamicaly like:
126  path [+ trigger] [+ partition]
127  '''
128 
129  partition = kwargs.get('partition', '')
130  trigger = kwargs.get('trigger', '')
131  subDirectory = kwargs.get('subDirectory', False)
132 
133  fullPath = path + '/' + trigger if trigger else path
134  fullPath += '/' + partition if partition and subDirectory else ''
135 
136  return fullPath
137 
138 
139 
140 def getModuleLabels(partition):
141  '''
142  This function returns list of Tile module names for given partition.
143 
144  Arguments:
145  partition -- Tile partition name (LBA, LBC, EBA, EBC)
146  '''
147 
148  if partition == 'AllPart':
149  labels = [str(module) for module in range(1, Tile.MAX_DRAWER + 1)]
150  else:
151  ros = {'LBA' : 1, 'LBC' : 2, 'EBA' : 3, 'EBC' : 4}
152  labels = [Tile.getDrawerString(ros[partition], module) for module in range(0, Tile.MAX_DRAWER)]
153 
154  return labels
155 
156 
157 def getCellChannelLabels(partition):
158  '''
159  This function returns list of Tile cell names with channes for given partition.
160 
161  Arguments:
162  partition -- Tile partition name (LBA, LBC, EBA, EBC)
163  '''
164 
165  labels = []
166  for channel in range(0, Tile.MAX_CHAN):
167  cellName = getCellName(partition, channel)
168  label = cellName + '_' + 'ch' + str(channel) if cellName else 'ch' + str(channel)
169  labels.append(label)
170  return labels
171 
172 
173 def getLabels(labels, partition = ''):
174  '''
175  This function returns list of labels for Tile histograms.
176 
177  This function returns list of Tile module or channel names for given partition
178  in the case of input labels is modules or channels. Otherwise it returns given labels.
179 
180  Arguments:
181  labels -- List of labels, "modules" and "channels" have special meaning,
182  in this case corresponding labels will be generated dynamicaly
183  partition -- Tile partition name (LBA, LBC, EBA, EBC)
184  '''
185 
186  if 'modules' in labels:
187  labels = getModuleLabels(partition)
188  elif 'channels' in labels:
189  labels = getCellChannelLabels(partition)
190 
191  return labels
192 
193 
194 def getCellNameTMDB(partition, channel):
195  return _cellNameTMDB_LB[channel] if partition.startswith('L') else _cellNameTMDB_EB[channel]
196 
198  return _cellNameTMDB_LB if partition.startswith('L') else _cellNameTMDB_EB
199 
200 
201 def getLegacyChannelForDemonstrator(useDemoCabling, partition, drawer, channel):
202  ''' Function to get legacy channel number from Tile Demonatrator '''
203 
204  legacyChannel = channel
205  if (useDemoCabling == 2015 and partition == 'EBC' and drawer == 1):
206  demo2legacy = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
207  26, 25, 24, 29, 31, 32, 27, 28, 30, 35, 34, 33, 38, 37, 43, 44, 41, 40, 39, 36, 42, 47, 46, 45]
208  legacyChannel = demo2legacy[channel]
209  elif useDemoCabling >= 2016 and useDemoCabling <= 2019 and partition == 'LBC' and (drawer == 1 or drawer > 2):
210  demo2legacy = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
211  26, 25, 24, 29, 28, 27, 32, 31, 30, 35, 34, 33, 38, 37, 36, 41, 40, 39, 44, 43, 42, 47, 46, 45]
212  legacyChannel = demo2legacy[channel]
213  elif useDemoCabling >= 2018 and partition == 'EBC' and drawer >= 2:
214  demo2legacyEB = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
215  31, 32, 30, 35, 33, 34, 38, 37, 41, 40, 39, 36, 26, 25, 24, 29, 28, 27, 44, 43, 42, 47, 46, 45]
216  legacyChannel = demo2legacyEB[channel]
217 
218  return legacyChannel
219 
220 
221 def addValueVsModuleAndChannelMaps(group, name, title, path, subDirectory = False, type = 'TH2D', value = '', trigger = '', run = ''):
222  '''
223  This function configures 2D histograms (maps) with Tile monitored value vs module and channel per partion.
224 
225  Arguments:
226  group -- Group (technically, a GenericMonitoringTool instance)
227  name -- Name of histogram (actual name is constructed dynamicaly like: name + partition + trigger)
228  title -- Title of histogram (actual title is constructed dynamicaly like: run + trigger + partion + title)
229  path -- Path in file for histogram (relative to the path of given group)
230  subDirectory -- Put the configured histograms into sub directory named like partion (True, False)
231  type -- Type of histogram (TH2D, TProfile2D)
232  value -- Name of monitored value (needed for TProfile2D)
233  trigger -- Name of trigger (given it will be put into title and name of histogram)
234  run -- Run number (given it will be put into the title)
235  '''
236 
237  for ros in range(1, Tile.MAX_ROS):
238  partition = getPartitionName(ros)
239  xlabels = []
240  ylabels = []
241  for module in range(1, Tile.MAX_DRAWER + 1): # modules start from 1
242  label = partition + '0' + str(module) if module < 10 else partition + str(module)
243  xlabels.append(label)
244 
245  for channel in range(0, Tile.MAX_CHAN):
246  cellName = getCellName(partition, channel)
247  label = cellName + '_' + 'ch' + str(channel) if cellName else 'ch' + str(channel)
248  ylabels.append(label)
249 
250  fullName = 'module' + partition + ',channel' + partition
251  if 'Profile' in type:
252  fullName += (',' + value + partition)
253  fullName += ';' + name + partition + trigger
254 
255  fullPath = path + '/' + partition if subDirectory else path
256 
257  fullTitle = 'Partition ' + partition + ': ' + title
258  if trigger:
259  fullTitle = 'Trigger ' + trigger + ' ' + fullTitle
260  if run:
261  fullTitle = 'Run ' + run + ' ' + fullTitle
262 
263  group.defineHistogram( fullName, path = fullPath, type = type, title = fullTitle,
264  xbins = 64, xmin = 0.5, xmax = 64.5, ybins = 48, ymin = -0.5, ymax = 47.5,
265  xlabels = xlabels, ylabels = ylabels )
266 
267 
268 def _getDimensions(triggers = [], perPartition = False, perSample = False, perGain = False, allPartitions = False):
269 
270  dimensions = []
271  if perPartition:
272  dimensions += [int(Tile.MAX_ROS)] if allPartitions else [int(Tile.MAX_ROS - 1)]
273  if perSample:
274  dimensions += [len(_sampleName)]
275  if perGain:
276  dimensions += [int(Tile.MAX_GAIN)]
277  if triggers:
278  dimensions += [len(triggers)]
279 
280  return dimensions
281 
282 
283 def _parsePostfix(postfix, triggers = [], perPartition = False, perSample = False, perGain = False):
284 
285  kwargs = {}
286  elements = postfix.split('_')
287 
288  if triggers:
289  kwargs['trigger'] = triggers[int(elements.pop())]
290  if perGain:
291  kwargs['gain'] = getGainName(elements.pop())
292  if perSample:
293  kwargs['sample'] = getSampleName(elements.pop())
294  if perPartition:
295  kwargs['ros'] = int(elements.pop()) + 1
296  kwargs['partition'] = getPartitionName(kwargs['ros'])
297 
298  return kwargs
299 
300 def addTile2DHistogramsArray(helper, algorithm, name = '', xvalue = '', yvalue = '', value = '',
301  title = '', path = '', weight = '', xbins = 0, xmin = 0., xmax = 0.,
302  ybins = 0, ymin = 0., ymax = 0., type = 'TH2D', run = '', triggers = [],
303  xlabels = (), ylabels = (), opt = '', subDirectory = False, perPartition = False,
304  perSample = False, perGain = False, allPartitions = False, separator = '_', merge = None ):
305  '''
306  This function configures 2D histograms with Tile monitored value per L1 trigger, partition, sample, gain.
307 
308  Arguments:
309  helper -- Helper
310  algorithm -- Monitoring algorithm
311  name -- Name of histogram, actual name is constructed dynamicaly like:
312  name + partition + sample + gain + trigger
313  xvalue -- Name of monitored value for x axis
314  yvalue -- Name of monitored value for y axis
315  value -- Name of monitored value for profile (needed for TProfile2D)
316  title -- Title of histogram, actual title is constructed dynamicaly like:
317  run + trigger + partion + sample + title
318  path -- Path in file for histogram (relative to the path of given group)
319  subDirectory -- Put the configured histograms into sub directory named like partion (True, False)
320  type -- Type of histogram (TH2D, TProfile2D)
321  run -- Run number (given it will be put into the title)
322  triggers -- Name of triggers (given it will be put into title and name of histogram)
323  xlabels -- List of bin labels for x axis, "modules" and "channels" have special meaning,
324  in this case corresponding labels will be generated dynamicaly
325  ylabels -- List of bin labels for y axis, "modules" and "channels" have special meaning,
326  in this case corresponding labels will be generated dynamicaly
327  perPartition -- Configure histograms per partition (if True partition name will be put into the title)
328  perSample -- Configure histograms per sample (if True sample name will be put into the title)
329  perGain -- Configure histograms per gain (if True gain name will be put into the title)
330  allPartitions -- Configure additional histogram with information from all partitions
331  separator -- Given it will be used as separtor between name and trigger
332  merge -- Whether to use a different histogram merging algorithm (must be "merge" for opt=kAddBinsDynamically)
333  '''
334 
335  import builtins
336 
337  dimensions = _getDimensions(triggers = triggers, perPartition = perPartition, perSample = perSample,
338  perGain = perGain, allPartitions = allPartitions)
339 
340  array = helper.addArray(dimensions, algorithm, name, topPath = path)
341  for postfix, tool in array.Tools.items():
342 
343  kwargs = _parsePostfix(postfix, triggers = triggers, perPartition = perPartition,
344  perSample = perSample, perGain = perGain)
345 
346  partition = kwargs['partition'] if 'partition' in kwargs else ''
347 
348  nxlabels = getLabels(xlabels, partition)
349  nylabels = getLabels(ylabels, partition)
350 
351  fullName = xvalue + ',' + yvalue + (',' + value if 'Profile' in type else '') + ';'
352  fullName += getTileHistogramName(name = name,separator = separator, **kwargs)
353 
354  subPath = getTileHistogramPath(path = '', subDirectory = subDirectory, **kwargs)
355 
356  gain = kwargs.get('gain', None)
357  gainTitle = title.get(gain, title) if gain and builtins.type(title) is dict else title
358  partitionTitle = gainTitle[partition] if builtins.type(gainTitle) is dict else gainTitle
359  fullTitle = getTileHistogramTitle(title = partitionTitle, run = run, **kwargs)
360 
361  tool.defineHistogram( fullName, path = subPath, type = type, title = fullTitle,
362  xlabels = nxlabels, ylabels = nylabels,
363  xbins = xbins, xmin = xmin, xmax = xmax,
364  ybins = ybins, ymin = ymin, ymax = ymax,
365  weight = weight, opt = opt, merge = merge)
366 
367  return array
368 
369 
370 def addTileModuleChannelMapsArray(helper, algorithm, name, title, path, weight = '',
371  subDirectory = False, type = 'TH2D', value = '',
372  run = '', triggers = [], perGain = False, separator = '_'):
373  '''
374  This function configures 2D histograms (maps) with Tile monitored value vs module and channel per partition.
375 
376  Arguments:
377  helper -- Helper
378  algorithm -- Monitoring algorithm
379  name -- Name of histogram, actual name is constructed dynamicaly like:
380  name + partition + gain + trigger
381  title -- Title of histogram, actual title is constructed dynamicaly like:
382  run + trigger + partion + gain + title
383  path -- Path in file for histogram (relative to the path of given group)
384  subDirectory -- Put the configured histograms into sub directory named like partion (True, False)
385  type -- Type of histogram (TH2D, TProfile2D)
386  value -- Name of monitored value (needed for TProfile2D)
387  run -- Run number (given it will be put into the title)
388  triggers -- Name of triggers (given it will be put into title and name of histogram)
389  perGain -- Configure histograms per gain (if True gain name will be put into the title)
390  separator -- Given it will be used as separtor between name, gain, and trigger
391  '''
392 
393  return addTile2DHistogramsArray(helper, algorithm, name = name, title = title, path = path, weight = weight,
394  xvalue = 'module', yvalue = 'channel', value = value, type = type,
395  xbins = Tile.MAX_DRAWER, xmin = -0.5, xmax = Tile.MAX_DRAWER - 0.5,
396  ybins = Tile.MAX_CHAN, ymin = -0.5, ymax = Tile.MAX_CHAN - 0.5,
397  run = run, xlabels = ('modules'), ylabels = ('channels'),
398  triggers = triggers, subDirectory = subDirectory, perGain = perGain,
399  perPartition = True, separator = separator)
400 
401 
402 def addTileModuleCorrelionMapsArray(helper, algorithm, name, title, path, weight = '',
403  subDirectory = False, type = 'TH2D', value = '', run = '',
404  triggers = [], perGain = False, allPartitions = False, separator = '_'):
405  '''
406  This function configures 2D histograms (maps) with Tile monitored value vs module and channel per partition.
407 
408  Arguments:
409  helper -- Helper
410  algorithm -- Monitoring algorithm
411  name -- Name of histogram, actual name is constructed dynamicaly like:
412  name + partition + gain + trigger
413  title -- Title of histogram, actual title is constructed dynamicaly like:
414  run + trigger + partion + gain + title
415  path -- Path in file for histogram (relative to the path of given group)
416  subDirectory -- Put the configured histograms into sub directory named like partion (True, False)
417  type -- Type of histogram (TH2D, TProfile2D)
418  value -- Name of monitored value (needed for TProfile2D)
419  run -- Run number (given it will be put into the title)
420  triggers -- Name of triggers (given it will be put into title and name of histogram)
421  perGain -- Configure histograms per gain (if True gain name will be put into the title)
422  allPartitions -- Configure additional histogram with information from all partitions
423  separator -- Given it will be used as separtor between name, gain, and trigger
424  '''
425 
426  return addTile2DHistogramsArray(helper, algorithm, name = name, title = title, path = path, weight = weight,
427  xvalue = 'firstModule', yvalue = 'secondModule', value = value,
428  xbins = Tile.MAX_DRAWER, xmin = -0.5, xmax = Tile.MAX_DRAWER - 0.5,
429  ybins = Tile.MAX_DRAWER, ymin = -0.5, ymax = Tile.MAX_DRAWER - 0.5,
430  run = run, xlabels = ('modules'), ylabels = ('modules'), type = type,
431  triggers = triggers, subDirectory = subDirectory, perGain = perGain,
432  perPartition = True, allPartitions = allPartitions, separator = separator)
433 
434 
435 
436 def addTileModulePartitionMapsArray(helper, algorithm, name, title, path, weight = '',
437  type = 'TH2D', value = '', run = '', triggers = [],
438  perGain = False, separator = '_'):
439  '''
440  This function configures 2D histograms (maps) with Tile monitored value vs module and partition.
441 
442  Arguments:
443  helper -- Helper
444  algorithm -- Monitoring algorithm
445  name -- Name of histogram, actual name is constructed dynamicaly like:
446  name + partition + gain + trigger
447  title -- Title of histogram, actual title is constructed dynamicaly like:
448  run + trigger + partion + gain + title
449  path -- Path in file for histogram (relative to the path of given group)
450  type -- Type of histogram (TH2D, TProfile2D)
451  value -- Name of monitored value (needed for TProfile2D)
452  run -- Run number (given it will be put into the title)
453  triggers -- Name of triggers (given it will be put into title and name of histogram)
454  perGain -- Configure histograms per gain (if True gain name will be put into the title)
455  separator -- Given it will be used as separtor between name, gain, and trigger
456  '''
457 
458  return addTile2DHistogramsArray(helper, algorithm, name = name, title = title + ';Module;Partition',
459  path = path, weight = weight, run = run, type = type,
460  xvalue = 'module', yvalue = 'partition', value = value,
461  xbins = Tile.MAX_DRAWER, xmin = -0.5, xmax = Tile.MAX_DRAWER - 0.5,
462  ybins = Tile.MAX_ROS - 1, ymin = -0.5, ymax = Tile.MAX_ROS - 1.5,
463  xlabels = [str(module) for module in range(1, Tile.MAX_DRAWER + 1)],
464  ylabels = [getPartitionName(ros) for ros in range(1, Tile.MAX_ROS)],
465  triggers = triggers, perGain = perGain, separator = separator)
466 
467 
468 
469 def addTileModuleDigitizerMapsArray(helper, algorithm, name, title, path, weight = '',
470  subDirectory = False, type = 'TH2D', value = '',
471  run = '', triggers = [], perGain = False, separator = '_'):
472  '''
473  This function configures 2D histograms (maps) with Tile monitored value vs module and digitizer per partition.
474 
475  Arguments:
476  helper -- Helper
477  algorithm -- Monitoring algorithm
478  name -- Name of histogram, actual name is constructed dynamicaly like:
479  name + partition + gain + trigger
480  title -- Title of histogram, actual title is constructed dynamicaly like:
481  run + trigger + partion + gain + title
482  path -- Path in file for histogram (relative to the path of given group)
483  subDirectory -- Put the configured histograms into sub directory named like partion (True, False)
484  type -- Type of histogram (TH2D, TProfile2D)
485  value -- Name of monitored value (needed for TProfile2D)
486  run -- Run number (given it will be put into the title)
487  triggers -- Name of triggers (given it will be put into title and name of histogram)
488  perGain -- Configure histograms per gain (if True gain name will be put into the title)
489  separator -- Given it will be used as separtor between name, gain, and trigger
490  '''
491 
492  return addTile2DHistogramsArray(helper, algorithm, name = name, title = title + ';;Digitizer', path = path,
493  weight = weight, xvalue = 'module', yvalue = 'digitizer', value = value,
494  xbins = Tile.MAX_DRAWER, xmin = -0.5, xmax = Tile.MAX_DRAWER - 0.5,
495  ybins = 8, ymin = 0.5, ymax = 8.5, run = run, xlabels = ('modules'),
496  ylabels = (), triggers = triggers, type = type,subDirectory = subDirectory,
497  perGain = perGain, perPartition = True, separator = separator)
498 
499 
500 
501 def addTileEtaPhiMapsArray(helper, algorithm, name, title, path, weight = '', type = 'TH2D', value = '',
502  run = '', triggers = [], perSample = True, perGain = False, separator = '_',
503  etaTitle= '#eta', etabins = 21, etamin = -2.025, etamax = 2.025,
504  phiTitle = '#phi', phibins = Tile.MAX_DRAWER, phimin = -3.15, phimax = 3.15):
505  '''
506  This function configures 2D histograms (maps) with Tile monitored value vs eta and phi.
507 
508  Arguments:
509  helper -- Helper
510  algorithm -- Monitoring algorithm
511  name -- Name of histogram, actual name is constructed dynamicaly like:
512  name + sample + gain + trigger
513  title -- Title of histogram, actual title is constructed dynamicaly like:
514  run + trigger + sample + gain + title
515  path -- Path in file for histogram (relative to the path of given group)
516  type -- Type of histogram (TH2D, TProfile2D)
517  value -- Name of monitored value (needed for TProfile2D)
518  run -- Run number (given it will be put into the title)
519  triggers -- Name of trigger (given it will be put into title and name of histogram)
520  perSample -- Configure histograms per sample (if True sample name will be put into the title)
521  perGain -- Configure histograms per gain (if True gain name will be put into the title)
522  separator -- Given it will be used as separtor between name, gain, and trigger
523  '''
524 
525  return addTile2DHistogramsArray(helper, algorithm, name = name,
526  title = title + ';' + etaTitle + ';' + phiTitle,
527  path = path, weight = weight, type = type,
528  xvalue = 'eta', yvalue = 'phi', value = value,
529  xbins = etabins, xmin = etamin, xmax = etamax,
530  ybins = phibins, ymin = phimin, ymax = phimax,
531  run = run, triggers = triggers, perGain = perGain,
532  perSample = perSample, separator = separator)
533 
534 
535 
536 def addTile1DHistogramsArray(helper, algorithm, name = '', xvalue = '', value = '', title = '', path = '',
537  weight = '', xbins = 0, xmin = 0., xmax = 0., type = 'TH1D', run = '', triggers = [],
538  subDirectory = False, perPartition = True, perSample = False, opt = '',
539  perGain = False, xlabels = (), allPartitions = False, separator = '_', merge = None ):
540  '''
541  This function configures 1D histograms with Tile monitored value per L1 trigger, partition, sample, gain.
542 
543  Arguments:
544  helper -- Helper
545  algorithm -- Monitoring algorithm
546  name -- Name of histogram, actual name is constructed dynamicaly like:
547  name + partition + sample + trigger
548  xvalue -- Name of monitored value for x axis
549  value -- Name of monitored value (needed for TProfile)
550  title -- Title of histogram, actual title is constructed dynamicaly like:
551  run + trigger + partion + sample + title
552  path -- Path in file for histogram (relative to the path of given group)
553  subDirectory -- Put the configured histograms into sub directory named like partion (True, False)
554  type -- Type of histogram (TH1D, TProfile)
555  run -- Run number (given it will be put into the title)
556  triggers -- Name of triggers (given it will be put into title and name of histogram)
557  perPartition -- Configure histograms per partition (if True partition name will be put into the title)
558  perSample -- Configure histograms per sample (if True sample name will be put into the title)
559  perGain -- Configure histograms per gain (if True gain name will be put into the title)
560  xlabels -- List of bin labels
561  allPartitions -- Configure additional histogram with information from all partitions
562  separator -- Given it will be used as separtor between name and trigger
563  merge -- Whether to use a different histogram merging algorithm (must be "merge" for opt=kAddBinsDynamically)
564  '''
565 
566  dimensions = _getDimensions(triggers = triggers, perPartition = perPartition, perSample = perSample,
567  perGain = perGain, allPartitions = allPartitions)
568 
569  array = helper.addArray(dimensions, algorithm, name, topPath = path)
570  for postfix, tool in array.Tools.items():
571 
572  kwargs = _parsePostfix(postfix, triggers = triggers, perPartition = perPartition,
573  perSample = perSample, perGain = perGain)
574 
575  partition = kwargs['partition'] if 'partition' in kwargs else ''
576  nxlabels = getLabels(xlabels, partition)
577 
578  fullName = xvalue + (',' + value if 'Profile' in type else '') + ';'
579  fullName += getTileHistogramName(name = name,separator = separator, **kwargs)
580 
581  subPath = getTileHistogramPath(path = '', subDirectory = subDirectory, **kwargs)
582  fullTitle = getTileHistogramTitle(title = title, run = run, **kwargs)
583 
584  tool.defineHistogram( fullName, path = subPath, weight = weight, type = type, title = fullTitle,
585  xlabels = nxlabels, xbins = xbins, xmin = xmin, xmax = xmax, opt = opt, merge = merge)
586 
587  return array
588 
589 
590 
591 
592 def addTileModuleArray(helper, algorithm, name, title, path,
593  type = 'TH1D', value = '', subDirectory = False,
594  triggers = [], run = '', separator = '_'):
595  '''
596  This function configures 1D histograms with Tile monitored value vs module per partition.
597 
598  Arguments:
599  helper -- Helper
600  algorithm -- Monitoring algorithm
601  name -- Name of histogram, actual name is constructed dynamicaly like:
602  name + partition + trigger
603  title -- Title of histogram, actual title is constructed dynamicaly like:
604  run + trigger + partion + title
605  path -- Path in file for histogram (relative to the path of given group)
606  type -- Type of histogram (TH1D, TProfile)
607  value -- Name of monitored value (needed for TProfile)
608  subDirectory -- Put the configured histograms into sub directory named like partion (True, False)
609  run -- Run number (given it will be put into the title)
610  separator -- Given it will be used as separtor between name and trigger
611  '''
612 
613  return addTile1DHistogramsArray(helper = helper, algorithm = algorithm, name = name, type = type,
614  xvalue = 'module', value = value, title = title, path = path,
615  xbins = Tile.MAX_DRAWER, xmin = -0.5, xmax = Tile.MAX_DRAWER - 0.5,
616  run = run, triggers = triggers, subDirectory = subDirectory,
617  xlabels = ('modules'), perPartition = True, separator = separator )
618 
619 
620 def addTileTMDB2DScatterHistogramsArray(helper, algorithm, name = '', xvalue = '', yvalue = '',
621  xbins = 0, xmin = 0, xmax = 0,
622  title = '', path = '', type = 'TH2D', run = ''):
623  for ros in range(1, Tile.MAX_ROS):
624  partition = getPartitionName(ros)
625  baseName = "{}_{}".format(name, partition)
626  nChannels = len(_cellNameTMDB_LB) if partition.startswith('L') else len(_cellNameTMDB_EB)
627 
628  dimensions = [int(Tile.MAX_DRAWER), nChannels, nChannels]
629  array = helper.addArray(dimensions, algorithm, baseName, topPath = path)
630  for postfix, tool in array.Tools.items():
631  elements = postfix.split('_')
632 
633  channel1 = int(elements.pop())
634  channel2 = int(elements.pop())
635  cell1 = getCellNameTMDB(partition, channel1)
636  cell2 = getCellNameTMDB(partition, channel2)
637 
638  module = '{}'.format(int(elements.pop()) + 1).rjust(2,'0')
639 
640  fullName = '{},{};{}{}_{}_{}'.format(xvalue, yvalue,
641  baseName, module, cell1, cell2)
642  hist_path = partition + module
643 
644  moduleOrPartition = 'Module ' + partition + module + partition
645  fullTitle = 'Run {} {} TMDB {}x{}: {};{};{}'.format(run, moduleOrPartition, cell1, cell2, title, cell1, cell2)
646 
647  tool.defineHistogram(fullName, path = hist_path, type = type, title = fullTitle,
648  xbins = xbins, xmin = xmin, xmax = xmax,
649  ybins = xbins, ymin = xmin, ymax = xmax)
650 
651 
652 def addTileTMDB_2DHistogramsArray(helper, algorithm, name = '', value = '',
653  title = '', path = '', type = 'TH2D', run = ''):
654  array = helper.addArray([int(Tile.MAX_ROS - 1)], algorithm, name, topPath = path)
655  for postfix, tool in array.Tools.items():
656  ros = int(postfix.split('_').pop()) + 1
657 
658  partition = getPartitionName(ros)
659  nxlabels = getModuleLabels(partition)
660  nylabels = getCellChannelTMDB_Labels(partition)
661  ybins = len(nylabels)
662 
663  fullName = 'module,channel' + (',' + value if 'Profile' in type else '') + ';'
664  fullName += getTileHistogramName(name, partition = partition)
665 
666  fullTitle = getTileHistogramTitle(title, run = run, partition = partition)
667 
668  tool.defineHistogram( fullName, path = '', type = type, title = fullTitle,
669  xlabels = nxlabels, ylabels = nylabels,
670  xbins = Tile.MAX_DRAWER, xmin = -0.5, xmax = Tile.MAX_DRAWER - 0.5,
671  ybins = ybins, ymin = -0.5, ymax = ybins - 0.5)
672 
673 def addTileTMDB_1DHistogramsArray(helper, algorithm, name = '', xvalue = '', value = '', title = '',
674  path = '', xbins = 0, xmin = 0., xmax = 0., type = 'TH1D', run = '',
675  perModule = False, isCorr=False):
676 
677  for ros in range(1, Tile.MAX_ROS):
678  partition = getPartitionName(ros)
679  baseName = "{}_{}".format(name, partition)
680  nChannels = len(_cellNameTMDB_LB) if partition.startswith('L') else len(_cellNameTMDB_EB)
681  if not isCorr:
682  dimensions = [int(Tile.MAX_DRAWER), nChannels] if perModule else [nChannels]
683  else:
684  dimensions = [int(Tile.MAX_DRAWER), nChannels, nChannels]
685 
686  array = helper.addArray(dimensions, algorithm, baseName, topPath = path)
687  for postfix, tool in array.Tools.items():
688  elements = postfix.split('_')
689  if not isCorr:
690  channel = int(elements.pop())
691  cell = getCellNameTMDB(partition, channel)
692  module = '{}'.format(int(elements.pop()) + 1).rjust(2,'0') if perModule else ''
693 
694  fullName = '{}{};{}{}_{}'.format(xvalue, (',' + value if 'Profile' in type else ''),
695  baseName, (module if perModule else ''), cell)
696 
697  moduleOrPartition = 'Module ' + partition + module if perModule else 'Partition ' + partition
698  fullTitle = 'Run {} {} TMDB {}: {}'.format(run, moduleOrPartition, cell, title)
699  else:
700  channel1 = int(elements.pop())
701  channel2 = int(elements.pop())
702  cell1 = getCellNameTMDB(partition, channel1)
703  cell2 = getCellNameTMDB(partition, channel2)
704 
705  module = '{}'.format(int(elements.pop()) + 1).rjust(2,'0') if perModule else ''
706 
707  fullName = '{}{};{}{}_{}_{}'.format(xvalue, (',' + value if 'Profile' in type else ''),
708  baseName, (module if perModule else ''), cell1, cell2)
709 
710  moduleOrPartition = 'Module ' + partition + module if perModule else 'Partition ' + partition
711  fullTitle = 'Run {} {} TMDB {}x{}: {}'.format(run, moduleOrPartition, cell1, cell2, title)
712 
713  tool.defineHistogram(fullName, path = '', type = type, title = fullTitle,
714  xbins = xbins, xmin = xmin, xmax = xmax)
715 
716 
717 def addTileChannelHistogramsArray(helper, algorithm, name, title, path,
718  xvalue, xbins, xmin, xmax, type='TH1D',
719  yvalue=None, ybins=None, ymin=None, ymax=None,
720  run='', value='', aliasSuffix=''):
721  '''
722  This function configures 1D histograms with Tile monitored value per module, channel, gain.
723 
724  Arguments:
725  helper -- Helper
726  algorithm -- Monitoring algorithm
727  name -- Name of histogram, actual name is constructed dynamicaly like:
728  name + mudule + channel + gain
729  title -- Title of histogram, actual title is constructed dynamicaly like:
730  run + module + channel + gain + title
731  path -- Path in file for histogram (relative to the path of given group)
732  xvalue -- Name of monitored value for x axis
733  yvalue -- Name of monitored value for y axis
734  type -- Type of histogram (TH1D, TProfile, TH2D)
735  value -- Name of monitored value (needed for TProfile)
736  run -- Run number (given it will be put into the title)
737  xlabels -- List of bin labels
738  '''
739 
740  import builtins
741  dimensions = [int(Tile.MAX_ROS) - 1, int(Tile.MAX_DRAWER)]
742  array = helper.addArray(dimensions, algorithm, name, topPath = path)
743 
744  for postfix, tool in array.Tools.items():
745  ros, module = [int(x) for x in postfix.split('_')[1:]]
746  moduleName = Tile.getDrawerString(ros + 1, module)
747  fullPath = moduleName
748 
749  for channel in range(0, int(Tile.MAX_CHAN)):
750  channelName = f'0{channel}' if channel < 10 else str(channel)
751  for gain in range(0, Tile.MAX_GAIN):
752  gainName = {0 : 'low', 1 : 'high'}[gain]
753  nameSuffix = aliasSuffix if aliasSuffix else xvalue
754  fullName = f'{xvalue}_{channel}_{gain}'
755  fullName += f',{yvalue}_{channel}_{gain}' if yvalue else ""
756  fullName += f',{value}_{channel}_{gain};' if 'Profile' in type else ';'
757  fullName += f'{moduleName}_ch_{channelName}_{gainName[:2]}_{nameSuffix}'
758  fullTitle = f'Run {run} {moduleName} Channel {channelName} {gainName} gain: {title}'
759 
760  xbinsInGain = xbins[gain] if builtins.type(xbins) is list else xbins
761  xminInGain = xmin[gain] if builtins.type(xmin) is list else xmin
762  xmaxInGain = xmax[gain] if builtins.type(xmax) is list else xmax
763 
764  ybinsInGain = ybins[gain] if builtins.type(ybins) is list else ybins
765  yminInGain = ymin[gain] if builtins.type(ymin) is list else ymin
766  ymaxInGain = ymax[gain] if builtins.type(ymax) is list else ymax
767 
768  tool.defineHistogram(fullName, title = fullTitle, path = fullPath, type = type,
769  xbins = xbinsInGain, xmin = xminInGain, xmax = xmaxInGain,
770  ybins = ybinsInGain, ymin = yminInGain, ymax = ymaxInGain)
TileMonitoringCfgHelper.addValueVsModuleAndChannelMaps
def addValueVsModuleAndChannelMaps(group, name, title, path, subDirectory=False, type='TH2D', value='', trigger='', run='')
Definition: TileMonitoringCfgHelper.py:221
TileMonitoringCfgHelper.addTileModuleChannelMapsArray
def addTileModuleChannelMapsArray(helper, algorithm, name, title, path, weight='', subDirectory=False, type='TH2D', value='', run='', triggers=[], perGain=False, separator='_')
Definition: TileMonitoringCfgHelper.py:370
vtune_athena.format
format
Definition: vtune_athena.py:14
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
TileMonitoringCfgHelper.getCellChannelLabels
def getCellChannelLabels(partition)
Definition: TileMonitoringCfgHelper.py:157
TileMonitoringCfgHelper.addTileModuleDigitizerMapsArray
def addTileModuleDigitizerMapsArray(helper, algorithm, name, title, path, weight='', subDirectory=False, type='TH2D', value='', run='', triggers=[], perGain=False, separator='_')
Definition: TileMonitoringCfgHelper.py:469
TileMonitoringCfgHelper.addTile2DHistogramsArray
def addTile2DHistogramsArray(helper, algorithm, name='', xvalue='', yvalue='', value='', title='', path='', weight='', xbins=0, xmin=0., xmax=0., ybins=0, ymin=0., ymax=0., type='TH2D', run='', triggers=[], xlabels=(), ylabels=(), opt='', subDirectory=False, perPartition=False, perSample=False, perGain=False, allPartitions=False, separator='_', merge=None)
Definition: TileMonitoringCfgHelper.py:300
TileMonitoringCfgHelper.getSampleName
def getSampleName(sample)
Definition: TileMonitoringCfgHelper.py:60
TileMonitoringCfgHelper._getDimensions
def _getDimensions(triggers=[], perPartition=False, perSample=False, perGain=False, allPartitions=False)
Definition: TileMonitoringCfgHelper.py:268
TileMonitoringCfgHelper.getLegacyChannelForDemonstrator
def getLegacyChannelForDemonstrator(useDemoCabling, partition, drawer, channel)
Definition: TileMonitoringCfgHelper.py:201
TileMonitoringCfgHelper.getTileHistogramPath
def getTileHistogramPath(path, **kwargs)
Definition: TileMonitoringCfgHelper.py:120
TileMonitoringCfgHelper._parsePostfix
def _parsePostfix(postfix, triggers=[], perPartition=False, perSample=False, perGain=False)
Definition: TileMonitoringCfgHelper.py:283
TileMonitoringCfgHelper.getTileHistogramName
def getTileHistogramName(name, separator='_', **kwargs)
Definition: TileMonitoringCfgHelper.py:70
TileMonitoringCfgHelper.addTile1DHistogramsArray
def addTile1DHistogramsArray(helper, algorithm, name='', xvalue='', value='', title='', path='', weight='', xbins=0, xmin=0., xmax=0., type='TH1D', run='', triggers=[], subDirectory=False, perPartition=True, perSample=False, opt='', perGain=False, xlabels=(), allPartitions=False, separator='_', merge=None)
Definition: TileMonitoringCfgHelper.py:536
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
TileMonitoringCfgHelper.addTileEtaPhiMapsArray
def addTileEtaPhiMapsArray(helper, algorithm, name, title, path, weight='', type='TH2D', value='', run='', triggers=[], perSample=True, perGain=False, separator='_', etaTitle='#eta', etabins=21, etamin=-2.025, etamax=2.025, phiTitle='#phi', phibins=Tile.MAX_DRAWER, phimin=-3.15, phimax=3.15)
Definition: TileMonitoringCfgHelper.py:501
TileMonitoringCfgHelper.addTileModuleCorrelionMapsArray
def addTileModuleCorrelionMapsArray(helper, algorithm, name, title, path, weight='', subDirectory=False, type='TH2D', value='', run='', triggers=[], perGain=False, allPartitions=False, separator='_')
Definition: TileMonitoringCfgHelper.py:402
TileMonitoringCfgHelper.getPartitionName
def getPartitionName(ros)
Definition: TileMonitoringCfgHelper.py:40
TileMonitoringCfgHelper.getTileHistogramTitle
def getTileHistogramTitle(title, **kwargs)
Definition: TileMonitoringCfgHelper.py:94
TileMonitoringCfgHelper.getModuleLabels
def getModuleLabels(partition)
Definition: TileMonitoringCfgHelper.py:140
TileMonitoringCfgHelper.addTileTMDB_1DHistogramsArray
def addTileTMDB_1DHistogramsArray(helper, algorithm, name='', xvalue='', value='', title='', path='', xbins=0, xmin=0., xmax=0., type='TH1D', run='', perModule=False, isCorr=False)
Definition: TileMonitoringCfgHelper.py:673
TileMonitoringCfgHelper.addTileTMDB2DScatterHistogramsArray
def addTileTMDB2DScatterHistogramsArray(helper, algorithm, name='', xvalue='', yvalue='', xbins=0, xmin=0, xmax=0, title='', path='', type='TH2D', run='')
Definition: TileMonitoringCfgHelper.py:620
TileMonitoringCfgHelper.getCellChannelTMDB_Labels
def getCellChannelTMDB_Labels(partition)
Definition: TileMonitoringCfgHelper.py:197
TileMonitoringCfgHelper.addTileChannelHistogramsArray
def addTileChannelHistogramsArray(helper, algorithm, name, title, path, xvalue, xbins, xmin, xmax, type='TH1D', yvalue=None, ybins=None, ymin=None, ymax=None, run='', value='', aliasSuffix='')
Definition: TileMonitoringCfgHelper.py:717
TileMonitoringCfgHelper.getGainName
def getGainName(gain)
Definition: TileMonitoringCfgHelper.py:50
TileMonitoringCfgHelper.getCellName
def getCellName(partition, channel)
Definition: TileMonitoringCfgHelper.py:29
TileMonitoringCfgHelper.addTileModulePartitionMapsArray
def addTileModulePartitionMapsArray(helper, algorithm, name, title, path, weight='', type='TH2D', value='', run='', triggers=[], perGain=False, separator='_')
Definition: TileMonitoringCfgHelper.py:436
str
Definition: BTagTrackIpAccessor.cxx:11
TileMonitoringCfgHelper.addTileTMDB_2DHistogramsArray
def addTileTMDB_2DHistogramsArray(helper, algorithm, name='', value='', title='', path='', type='TH2D', run='')
Definition: TileMonitoringCfgHelper.py:652
TileMonitoringCfgHelper.getCellNameTMDB
def getCellNameTMDB(partition, channel)
Definition: TileMonitoringCfgHelper.py:194
TileMonitoringCfgHelper.getLabels
def getLabels(labels, partition='')
Definition: TileMonitoringCfgHelper.py:173
TileMonitoringCfgHelper.addTileModuleArray
def addTileModuleArray(helper, algorithm, name, title, path, type='TH1D', value='', subDirectory=False, triggers=[], run='', separator='_')
Definition: TileMonitoringCfgHelper.py:592