ATLAS Offline Software
afp.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
2 
3 import os
4 pbeastDefaultServer = 'https://pc-atlas-www.cern.ch' if os.getenv('PBEAST_SERVER_HTTPS_PROXY', '').startswith('atlasgw') else 'https://atlasop.cern.ch'
5 pbeastServer = os.getenv('PBEAST_SERVER', pbeastDefaultServer)
6 
7 import libpbeastpy; pbeast = libpbeastpy.ServerProxy(pbeastServer)
8 import logging; log = logging.getLogger("DCSCalculator2.variable")
9 
10 from itertools import chain, combinations
11 
12 from DQUtils.events import process_iovs
13 from DQUtils.general import timer
14 from DQUtils.sugar import IOVSet, RANGEIOV_VAL, RunLumi, TimestampType, define_iov_type, make_iov_type
15 
16 from DCSCalculator2 import config
17 from DCSCalculator2.consts import RED, YELLOW
18 from DCSCalculator2.libcore import map_channels
19 from DCSCalculator2.subdetector import DCSC_DefectTranslate_Subdetector
20 from DCSCalculator2.variable import DefectIOV, GoodIOV, DCSC_Variable
21 
22 class DCSC_Variable_With_Mapping(DCSC_Variable):
23  def __init__(self, folder, evaluator, *, mapping=None, **kwargs):
24  super().__init__(folder, evaluator, **kwargs)
25  self.mapping = mapping
26 
27  def read(self, query_range, folder_base, folder_name):
28  result = super().read(query_range, folder_base, folder_name)
29  if self.mapping is not None:
30  result = map_channels(result, self.mapping, folder_name)
31  return result
32 
33 class DCSC_Merged_Variable(DCSC_Variable):
34  def __init__(self, folders, evaluator, *, mapping={}, **kwargs):
35  folder_merge = ','.join(folders)
36 
37  super().__init__(folder_merge, evaluator, **kwargs)
38  self.folder_names = folders
39  self.mapping = mapping
40 
41  def get_variable(self, name):
42  for var in self.variables:
43  if var.folder_name == name:
44  return var
45  raise RuntimeError("Folder '%s' not found" % name)
46 
47  def read(self, query_range, folder_base, folder_names):
48  var_iovs = []
49  folders = folder_names.split(',')
50 
51  for folder in folders:
52  iovs = super().read(query_range, folder_base, folder)
53  if folder in self.mapping:
54  iovs = map_channels(iovs, self.mapping[folder], folder)
55  var_iovs.append(iovs)
56 
57  iovs = self.merge_input_variables(*var_iovs)
58 
59  if config.opts.check_input_time:
60  self.print_time_info(iovs)
61 
62  if log.isEnabledFor(logging.INFO):
63  input_hash = hash(iovs)
64  self.input_hashes.append(input_hash)
65  #log.info(" -> Input hash: % 09x (len=%i)", input_hash, len(iovs))
66 
67  return iovs
68 
69  def merge_input_variables(self, *inputs):
70  type_bases = [iovs.iov_type for iovs in inputs]
71  base_names = [base.__name__[:-4] for base in type_bases]
72  attributes = [base.lower() for base in base_names]
73  clazz = make_iov_type('MERGER_OF_' + '_AND_'.join(base_names), tuple(['channel'] + attributes))
74 
75  inputs_by_channel = [iovs.by_channel for iovs in inputs]
76  all_channels = sorted(set(y for x in inputs_by_channel for y in x.keys()))
77 
78  result = []
79  for channel in all_channels:
80  c_inputs = [x[channel] for x in inputs_by_channel]
81  result.extend(iov for iov in self.merge_inputs(clazz, channel, *c_inputs))
82 
83  return IOVSet(result, iov_type=clazz, origin=self.folder_names)
84 
85  def merge_inputs(self, clazz, channel, *inputs):
86  result = [clazz(since, until, channel, *states) for since, until, states in process_iovs(*inputs)]
87  return IOVSet(result, iov_type=clazz, origin=self.folder_names)
88 
89 @define_iov_type
90 def PBeastIOV(channel, value):
91  "Stores the value of an object's attribute queried from pBeast"
92 
93 class TDAQC_Variable(DCSC_Variable):
94  """
95  A variable which reads data from pBeast.
96  """
97  TIME_RATIO = 1e3
98 
99  @staticmethod
100  def timeCOOL2PBeast(timestamp):
101  return int(timestamp/TDAQC_Variable.TIME_RATIO)
102 
103  @staticmethod
104  def timePBeast2COOL(timestamp):
105  return TimestampType(timestamp*TDAQC_Variable.TIME_RATIO)
106 
107  def __init__(self, query, evaluator, *, regex=False, mapping=dict(), force_mapping=False, empty_value=None):
108  super().__init__(query, evaluator)
109  self.regex = regex
110  self.mapping = mapping
111  self.force_mapping = force_mapping
112  self.empty_value = empty_value
113  self.query = query
114  self.partition, self.className, self.attribute, self.path = query.split('.', 3)
115  self.input_hashes = []
116 
117  def __repr__(self):
118  return f"<TDAQCVariable {self.query}>"
119 
120  def read(self, query_range, query, *, regex=False):
121  """
122  Read the relevant data from pBeast for this variable, and convert them to COOL-like format
123  """
124  partition, className, attribute, path = query.split('.', 3)
125 
126  log.info(f"Querying pBeast object{'s using regex' if regex else ''} {query}")
127 
128  since, until = query_range
129  since, until = TDAQC_Variable.timeCOOL2PBeast(since), TDAQC_Variable.timeCOOL2PBeast(until)
130 
131  query_data = pbeast.get_data(partition, className, attribute, path, regex, since, until)
132  data = dict.fromkeys(self.mapping.keys()) if self.force_mapping else dict()
133  if query_data:
134  data.update(query_data[0].data)
135 
136  def instantiate(since, until, channel, value):
137  if isinstance(value, list):
138  value = tuple(value)
139  return PBeastIOV(TDAQC_Variable.timePBeast2COOL(since), TDAQC_Variable.timePBeast2COOL(until), channel, value)
140 
141  iovs = []
142  for channel, entries in data.items():
143  if not entries:
144  iovs.append(PBeastIOV(*query_range, channel, self.empty_value))
145  continue
146  first = entries[0]
147  since = first.ts
148  value = first.value
149  for point in entries:
150  if point.value == value:
151  continue
152  iovs.append(instantiate(since, point.ts, channel, value))
153  since = point.ts
154  value = point.value
155  last = entries[-1]
156  iovs.append(instantiate(since, last.ts, channel, value))
157  iovs = IOVSet(iovs, iov_type=PBeastIOV, origin=query)
158 
159  if log.isEnabledFor(logging.INFO):
160  input_hash = hash(iovs)
161  self.input_hashes.append(input_hash)
162  log.info(" -> Input hash: % 09x (len=%i)", input_hash, len(iovs))
163 
164  return iovs
165 
166  def calculate_good_iovs(self, lbtime, subdetector):
167  """
168  Calculate LB-wise "good" states
169  """
170 
171  self.subdetector = subdetector
172 
173  since, until = lbtime.first, lbtime.last
174  if self.timewise_folder:
175  query_range = RANGEIOV_VAL(since.since, until.until)
176  else:
177  query_range = RANGEIOV_VAL(RunLumi(since.Run, since.LumiBlock),
178  RunLumi(until.Run, until.LumiBlock))
179 
180  # Read the database
181  iovs = self.read(query_range, self.query, regex=self.regex)
182  # Decide the states of the input iovs
183  iovs = self.make_good_iovs(iovs)
184  # Apply a mapping for input channels if necessary
185  iovs = self.map_input_channels(iovs)
186 
187  if self.timewise_folder and not config.opts.timewise:
188  # we might already know the defect mapping
189  with timer("Quantize %s (%i iovs over %i lbs)" %
190  (self.query, len(iovs), len(lbtime))):
191  # Quantize to luminosity block
192  iovs = self.quantize(lbtime, iovs)
193 
194  self.iovs = iovs
195  return self
196 
197  def make_good_iov(self, iov):
198  """
199  Determine if one input iov is good.
200  """
201  giov = GoodIOV(iov.since, iov.until, self.mapping.get(iov.channel, iov.channel), self.evaluator(iov))
202  giov._orig_iov = iov
203  return giov
204 
206  def make_good_iov(self, iov):
207  """
208  Determine if channels in one input iov are good.
209  """
210  giov = []
211  for channel, goodness in self.evaluator(iov):
212  current = GoodIOV(iov.since, iov.until, channel, goodness)
213  current._orig_iov = iov
214  giov.append(current)
215  return giov
216 
217  def make_good_iovs(self, iovs):
218  """
219  Determine whether each iov signifies a good or bad state.
220  """
221  results = []
222  for iov in iovs:
223  results.append(self.make_good_iov(iov))
224  return IOVSet(sum(zip(*results), ())) # Sort by channel first
225 
227  def make_good_iov(self, iov):
228  """
229  Determine if channels in one input iov are good.
230  """
231  giov = []
232  for bit, channel in self.mapping.get(iov.channel, dict()).items():
233  iov_value = (((iov.value >> bit) & 1) == 1) if iov.value is not None else None
234  test_iov = PBeastIOV(iov.since, iov.until, channel, iov_value)
235  current = GoodIOV(iov.since, iov.until, channel, self.evaluator(test_iov))
236  current._orig_iov = iov
237  giov.append(current)
238  return giov
239 
241  def make_good_iov(self, iov):
242  """
243  Determine if channels in one input iov are good.
244  """
245  giov = []
246  for index, channel in self.mapping.get(iov.channel, dict()).items():
247  iov_value = iov.value[index] if iov.value is not None else None
248  test_iov = PBeastIOV(iov.since, iov.until, channel, iov_value)
249  current = GoodIOV(iov.since, iov.until, channel, self.evaluator(test_iov))
250  current._orig_iov = iov
251  giov.append(current)
252  return giov
253 
254 # DCS channels
255 A_FAR_GARAGE, A_NEAR_GARAGE, C_FAR_GARAGE, C_NEAR_GARAGE = 101, 105, 109, 113
256 A_FAR_SIT_HV, A_NEAR_SIT_HV, C_FAR_SIT_HV, C_NEAR_SIT_HV = 1, 5, 9, 13
257 A_FAR_SIT_LV, A_NEAR_SIT_LV, C_FAR_SIT_LV, C_NEAR_SIT_LV = 21, 25, 29, 33
258 A_FAR_TOF_HV, C_FAR_TOF_HV = 51, 59
259 A_FAR_TOF_LV, C_FAR_TOF_LV = 71, 79
260 
261 # TDAQ channels
262 TTC_RESTART = 1000
263 STOPLESSLY_REMOVED = 5000
264 
265 A_FAR_SIT_DISABLED, A_NEAR_SIT_DISABLED, C_FAR_SIT_DISABLED, C_NEAR_SIT_DISABLED = 1001, 1005, 1009, 1013
266 A_FAR_TOF_DISABLED, C_FAR_TOF_DISABLED = 1051, 1059
267 
268 # Channel groups
269 GARAGE = [A_FAR_GARAGE, A_NEAR_GARAGE, C_FAR_GARAGE, C_NEAR_GARAGE]
270 SIT_HV = [A_FAR_SIT_HV, A_NEAR_SIT_HV, C_FAR_SIT_HV, C_NEAR_SIT_HV]
271 SIT_LV = [A_FAR_SIT_LV, A_NEAR_SIT_LV, C_FAR_SIT_LV, C_NEAR_SIT_LV]
272 TOF_HV = [A_FAR_TOF_HV, C_FAR_TOF_HV]
273 TOF_LV = [A_FAR_TOF_LV, C_FAR_TOF_LV]
274 
275 SIT_DISABLED = [A_FAR_SIT_DISABLED, A_NEAR_SIT_DISABLED, C_FAR_SIT_DISABLED, C_NEAR_SIT_DISABLED]
276 TOF_DISABLED = [A_FAR_TOF_DISABLED, C_FAR_TOF_DISABLED]
277 
278 # Thresholds
279 SIT_HV_DEAD_BAND = 0.05
280 TOF_HV_DEAD_BAND = 0.90
281 
282 SIT_LV_CURRENT_LOW, SIT_LV_CURRENT_HIGH = 0.4, 0.6
283 TOF_HV_CURRENT_LOW = 600
284 TOF_LV_CURRENT_LOW = 1
285 
286 def mapChannels(*mapseqArgs):
287  return dict(chain(*[zip(channels, range(defectChannel, defectChannel + len(channels))) for channels, defectChannel in mapseqArgs]))
288 
289 def mapTranslatorCounts(countMap):
290  return {channel: range(channel, channel + count) for count, channels in countMap.items() for channel in channels}
291 
292 def remove_None(value, default):
293  return value if value is not None else default
294 
295 class AFP(DCSC_DefectTranslate_Subdetector):
296  folder_base = '/AFP/DCS'
297  variables = [
298 
301 
302  # AFP_(A|C)_(FAR|NEAR)_IN_GARAGE
304  'STATION',
305  lambda iov: iov.inphysics is True,
306  mapping = {1: C_FAR_GARAGE, 2: C_NEAR_GARAGE, 3: A_FAR_GARAGE, 4: A_NEAR_GARAGE}
307  ),
308 
309  # AFP_(A|C)_(FAR|NEAR)_SIT_(PARTIALLY|NOT)_OPERATIONAL_LV
311  'SIT/LV',
312  lambda iov: SIT_LV_CURRENT_LOW <= remove_None(iov.current, 0) <= SIT_LV_CURRENT_HIGH,
313  mapping = mapChannels(
314  ([ 9, 10, 11, 12], A_FAR_SIT_LV ),
315  ([13, 14, 15, 16], A_NEAR_SIT_LV),
316  ([ 1, 2, 3, 4], C_FAR_SIT_LV ),
317  ([ 5, 6, 7, 8], C_NEAR_SIT_LV)
318  )
319  ),
320 
321  # AFP_(A|C)_(FAR|NEAR)_SIT_(PARTIALLY|NOT)_OPERATIONAL_HV
323  ['SIT/HV', 'SIT/HV_VOLTAGE_SET'],
324  lambda iov: -remove_None(iov.hv.voltage, 0) > iov.hv_voltage_set.voltageSet - SIT_HV_DEAD_BAND,
325  mapping = {
326  'SIT/HV': mapChannels(
327  ([ 6, 7, 1, 2], A_FAR_SIT_HV ),
328  ([ 8, 3, 4, 9], A_NEAR_SIT_HV),
329  ([10, 11, 12, 5], C_FAR_SIT_HV ),
330  ([13, 14, 15, 16], C_NEAR_SIT_HV)),
331  'SIT/HV_VOLTAGE_SET': mapChannels(
332  ([ 1, 2, 3, 4], A_FAR_SIT_HV ),
333  ([ 5, 6, 7, 8], A_NEAR_SIT_HV),
334  ([ 9, 10, 11, 12], C_FAR_SIT_HV ),
335  ([13, 14, 15, 16], C_NEAR_SIT_HV))
336  }
337  ),
338 
339  # AFP_(A|C)_FAR_TOF_NOT_OPERATIONAL_LV
341  'TOF_TDC_CURRENT',
342  lambda iov: TOF_LV_CURRENT_LOW <= remove_None(iov.hptdc1_current, 0) and TOF_LV_CURRENT_LOW <= remove_None(iov.hptdc2_current, 0),
343  mapping = {1: A_FAR_TOF_LV, 2: C_FAR_TOF_LV}
344  ),
345 
346  # AFP_(A|C)_FAR_TOF_NOT_OPERATIONAL_HV
348  ['TOF', 'TOF_PMT_VOLTAGE_SET'],
349  lambda iov: -remove_None(iov.tof.pmt_voltage, 0) > iov.tof_pmt_voltage_set.pmt_voltageSet - TOF_HV_DEAD_BAND and -remove_None(iov.tof.pmt_current, 0) > TOF_HV_CURRENT_LOW,
350  mapping = {
351  'TOF': {1: A_FAR_TOF_HV, 2: C_FAR_TOF_HV},
352  'TOF_PMT_VOLTAGE_SET': {1: A_FAR_TOF_HV, 2: C_FAR_TOF_HV},
353  }
354  ),
355 
356 
359 
360  # AFP_TTC_RESTART
362  'ATLAS.RCStateInfo.state.RunCtrl.AFP',
363  lambda iov: iov.value == 'RUNNING',
364  mapping = {'RunCtrl.AFP': TTC_RESTART}
365  ),
366 
367  # AFP_STOPLESSLY_REMOVED
369  'ATLAS.RODBusyIS.BusyEnabled.Monitoring.afp_rodBusy-VLDB/RODBusy',
370  lambda iov: iov.value is not False,
371  mapping = {'Monitoring.afp_rodBusy-VLDB/RODBusy': {6: STOPLESSLY_REMOVED}}
372  ),
373 
374  # AFP_(A|C)_(FAR|NEAR)_(PARTIALLY|NOT)_OPERATIONAL_TDAQ
376  'ATLAS.RceMonitoring.DisabledPerm.Monitoring.RceMonitoring_RCE[34]',
377  lambda iov: iov.value is not True,
378  regex = True,
379  mapping = {
380  'Monitoring.RceMonitoring_RCE3': mapChannels(([0, 2, 4, 6], A_NEAR_SIT_DISABLED), ([8, 10, 12, 14], A_FAR_SIT_DISABLED), ([9, 11], A_FAR_TOF_DISABLED)),
381  'Monitoring.RceMonitoring_RCE4': mapChannels(([0, 2, 4, 6], C_NEAR_SIT_DISABLED), ([8, 10, 12, 14], C_FAR_SIT_DISABLED), ([9, 11], C_FAR_TOF_DISABLED)),
382  }
383  ),
384  ]
385 
386  equality_breaker = 0.0001
387 
388  dead_fraction_caution = 0 + equality_breaker
389  dead_fraction_bad = 0.25 + equality_breaker
390 
392  1: [*GARAGE, TTC_RESTART, STOPLESSLY_REMOVED, *TOF_LV, *TOF_HV],
393  2: TOF_DISABLED,
394  4: [*SIT_DISABLED, *SIT_LV, *SIT_HV],
395  })
396 
397  def merge_variable_states(self, states):
398  """
399  Merge input channel states across variables, taking the worst.
400 
401  Ignore configuration variables and variables without channel.
402  """
403 
404  # Remove variables without channel
405  states = [state for state in states if state and state.channel is not None]
406 
407  # More simplistic way of doing the above, but cannot handle config vars:
408  return min(state.good for state in states) if len(states) > 0 else None
409 
410  @staticmethod
411  def color_to_defect_translator(channel, defect_name, color, comment):
412  def translator_core(iovs):
413  return [DefectIOV(iov.since, iov.until, defect_name, True,
414  comment=comment(iov))
415  for iov in iovs if iov.channel == channel
416  and iov.Code == color]
417  return translator_core
418 
419  @staticmethod
420  def defect_combinator(channels, defect_name, code, comment):
421  def combinator_core(iovs):
422  result = []
423  channel_diffs = [channels[0] - channel for channel in channels]
424  channel_iovs = iovs.by_channel
425  defect_iovs = [channel_iovs.get(channel) for channel in channels]
426  for since, until, states in process_iovs(*defect_iovs):
427  matched = [state for state in states if state.Code == code]
428  if len(matched) < 2: continue # We need at least two defects
429  matched_diffs = [diff for state,diff in zip(states, channel_diffs) if state.Code == code]
430  bad_channels = [{iov.channel + diff for iov in state._orig_iovs if not iov.good} for state,diff in zip(matched,matched_diffs)]
431  if all(a.issubset(b) or a.issuperset(b) for a,b in combinations(bad_channels, 2)): continue # We need that the defects have different origin
432  result.append(DefectIOV(since, until, defect_name, True, comment=comment()))
433  return result
434  return combinator_core
435 
436  def __init__(self, *args, **kwargs):
437  super(AFP, self).__init__(*args, **kwargs)
438  self.translators = [
439  AFP.color_to_defect_translator(*cdcc)
440  for cdcc in [
441 
444  (A_FAR_GARAGE, 'AFP_A_FAR_IN_GARAGE', RED, AFP.comment_GARAGE),
445  (A_NEAR_GARAGE, 'AFP_A_NEAR_IN_GARAGE', RED, AFP.comment_GARAGE),
446  (C_FAR_GARAGE, 'AFP_C_FAR_IN_GARAGE', RED, AFP.comment_GARAGE),
447  (C_NEAR_GARAGE, 'AFP_C_NEAR_IN_GARAGE', RED, AFP.comment_GARAGE),
448 
449  (A_FAR_SIT_HV, 'AFP_A_FAR_SIT_PARTIALLY_OPERATIONAL_HV', YELLOW, AFP.comment_SIT_HV),
450  (A_FAR_SIT_HV, 'AFP_A_FAR_SIT_NOT_OPERATIONAL_HV', RED, AFP.comment_SIT_HV),
451  (A_NEAR_SIT_HV, 'AFP_A_NEAR_SIT_PARTIALLY_OPERATIONAL_HV', YELLOW, AFP.comment_SIT_HV),
452  (A_NEAR_SIT_HV, 'AFP_A_NEAR_SIT_NOT_OPERATIONAL_HV', RED, AFP.comment_SIT_HV),
453  (C_FAR_SIT_HV, 'AFP_C_FAR_SIT_PARTIALLY_OPERATIONAL_HV', YELLOW, AFP.comment_SIT_HV),
454  (C_FAR_SIT_HV, 'AFP_C_FAR_SIT_NOT_OPERATIONAL_HV', RED, AFP.comment_SIT_HV),
455  (C_NEAR_SIT_HV, 'AFP_C_NEAR_SIT_PARTIALLY_OPERATIONAL_HV', YELLOW, AFP.comment_SIT_HV),
456  (C_NEAR_SIT_HV, 'AFP_C_NEAR_SIT_NOT_OPERATIONAL_HV', RED, AFP.comment_SIT_HV),
457 
458  (A_FAR_SIT_LV, 'AFP_A_FAR_SIT_PARTIALLY_OPERATIONAL_LV', YELLOW, AFP.comment_SIT_LV),
459  (A_FAR_SIT_LV, 'AFP_A_FAR_SIT_NOT_OPERATIONAL_LV', RED, AFP.comment_SIT_LV),
460  (A_NEAR_SIT_LV, 'AFP_A_NEAR_SIT_PARTIALLY_OPERATIONAL_LV', YELLOW, AFP.comment_SIT_LV),
461  (A_NEAR_SIT_LV, 'AFP_A_NEAR_SIT_NOT_OPERATIONAL_LV', RED, AFP.comment_SIT_LV),
462  (C_FAR_SIT_LV, 'AFP_C_FAR_SIT_PARTIALLY_OPERATIONAL_LV', YELLOW, AFP.comment_SIT_LV),
463  (C_FAR_SIT_LV, 'AFP_C_FAR_SIT_NOT_OPERATIONAL_LV', RED, AFP.comment_SIT_LV),
464  (C_NEAR_SIT_LV, 'AFP_C_NEAR_SIT_PARTIALLY_OPERATIONAL_LV', YELLOW, AFP.comment_SIT_LV),
465  (C_NEAR_SIT_LV, 'AFP_C_NEAR_SIT_NOT_OPERATIONAL_LV', RED, AFP.comment_SIT_LV),
466 
467  (A_FAR_TOF_LV, 'AFP_A_FAR_TOF_NOT_OPERATIONAL_LV', RED, AFP.comment_TOF_LV),
468  (C_FAR_TOF_LV, 'AFP_C_FAR_TOF_NOT_OPERATIONAL_LV', RED, AFP.comment_TOF_LV),
469 
470  (A_FAR_TOF_HV, 'AFP_A_FAR_TOF_NOT_OPERATIONAL_HV', RED, AFP.comment_TOF_HV),
471  (C_FAR_TOF_HV, 'AFP_C_FAR_TOF_NOT_OPERATIONAL_HV', RED, AFP.comment_TOF_HV),
472 
473 
476  (TTC_RESTART, 'AFP_TTC_RESTART', RED, AFP.comment_TTC_RESTART),
477  (STOPLESSLY_REMOVED, 'AFP_STOPLESSLY_REMOVED', RED, AFP.comment_STOPLESSLY_REMOVED),
478 
479  (A_FAR_SIT_DISABLED, 'AFP_A_FAR_SIT_PARTIALLY_OPERATIONAL_TDAQ', YELLOW, AFP.comment_SIT_DISABLED),
480  (A_FAR_SIT_DISABLED, 'AFP_A_FAR_SIT_NOT_OPERATIONAL_TDAQ', RED, AFP.comment_SIT_DISABLED),
481  (A_NEAR_SIT_DISABLED, 'AFP_A_NEAR_SIT_PARTIALLY_OPERATIONAL_TDAQ', YELLOW, AFP.comment_SIT_DISABLED),
482  (A_NEAR_SIT_DISABLED, 'AFP_A_NEAR_SIT_NOT_OPERATIONAL_TDAQ', RED, AFP.comment_SIT_DISABLED),
483  (C_FAR_SIT_DISABLED, 'AFP_C_FAR_SIT_PARTIALLY_OPERATIONAL_TDAQ', YELLOW, AFP.comment_SIT_DISABLED),
484  (C_FAR_SIT_DISABLED, 'AFP_C_FAR_SIT_NOT_OPERATIONAL_TDAQ', RED, AFP.comment_SIT_DISABLED),
485  (C_NEAR_SIT_DISABLED, 'AFP_C_NEAR_SIT_PARTIALLY_OPERATIONAL_TDAQ', YELLOW, AFP.comment_SIT_DISABLED),
486  (C_NEAR_SIT_DISABLED, 'AFP_C_NEAR_SIT_NOT_OPERATIONAL_TDAQ', RED, AFP.comment_SIT_DISABLED),
487 
488  (A_FAR_TOF_DISABLED, 'AFP_A_FAR_TOF_NOT_OPERATIONAL_TDAQ', RED, AFP.comment_TOF_DISABLED),
489  (C_FAR_TOF_DISABLED, 'AFP_C_FAR_TOF_NOT_OPERATIONAL_TDAQ', RED, AFP.comment_TOF_DISABLED),
490  ]
491  ] + [
492  AFP.defect_combinator(*cdcc)
493  for cdcc in [
494  ([A_FAR_SIT_LV, A_FAR_SIT_DISABLED], 'AFP_A_FAR_SIT_NOT_OPERATIONAL', YELLOW, AFP.comment_SIT_COMBINATION),
495  ([A_NEAR_SIT_LV, A_NEAR_SIT_DISABLED], 'AFP_A_NEAR_SIT_NOT_OPERATIONAL', YELLOW, AFP.comment_SIT_COMBINATION),
496  ([C_FAR_SIT_LV, C_FAR_SIT_DISABLED], 'AFP_C_FAR_SIT_NOT_OPERATIONAL', YELLOW, AFP.comment_SIT_COMBINATION),
497  ([C_NEAR_SIT_LV, C_NEAR_SIT_DISABLED], 'AFP_C_NEAR_SIT_NOT_OPERATIONAL', YELLOW, AFP.comment_SIT_COMBINATION),
498  ]
499  ]
500 
501 
504 
505  @staticmethod
506  def comment_GARAGE(iov):
507  return 'Station not in physics'
508 
509  @staticmethod
510  def comment_SIT_LV(iov):
511  return AFP.comment_planes(iov, 'with too low current')
512 
513  @staticmethod
514  def comment_SIT_HV(iov):
515  return AFP.comment_planes(iov, 'out of nominal voltage')
516 
517  @staticmethod
518  def comment_TOF_LV(iov):
519  return 'ToF TDC with too low current'
520 
521  @staticmethod
522  def comment_TOF_HV(iov):
523  return 'ToF PMT out of nominal voltage'
524 
525 
528 
529  @staticmethod
531  return 'AFP not in the RUNNING state'
532 
533  @staticmethod
535  return 'AFP stoplessly removed from the run'
536 
537  @staticmethod
539  return AFP.comment_planes(iov, 'removed from readout')
540 
541  @staticmethod
543  return AFP.comment_device(iov, 'ToF TDC', 'removed from readout')
544 
545 
548 
549  @staticmethod
551  return "Combination of 'partially operational' defects"
552 
553 
556 
557  @staticmethod
558  def comment_planes(iov, message):
559  return AFP.comment_device(iov, 'SiT plane', message)
560 
561  @staticmethod
562  def comment_device(iov, device, message):
563  count = iov.NConfig - iov.NWorking
564  if count != 1:
565  device += 's'
566  return f"{count} {device} {message}"
python.subdetectors.afp.AFP
Definition: afp.py:295
python.libcore.map_channels
def map_channels(iovs, mapping, folder)
Definition: libcore.py:39
python.subdetectors.afp.TDAQC_Variable.calculate_good_iovs
def calculate_good_iovs(self, lbtime, subdetector)
Definition: afp.py:166
python.subdetectors.afp.DCSC_Merged_Variable
Definition: afp.py:33
runLayerRecalibration.chain
chain
Definition: runLayerRecalibration.py:175
python.subdetectors.afp.AFP.comment_SIT_HV
def comment_SIT_HV(iov)
Definition: afp.py:514
python.subdetectors.afp.AFP.comment_STOPLESSLY_REMOVED
def comment_STOPLESSLY_REMOVED(iov)
Definition: afp.py:534
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
python.subdetectors.afp.AFP.comment_TTC_RESTART
def comment_TTC_RESTART(iov)
TDAQ defects.
Definition: afp.py:530
python.subdetectors.afp.TDAQC_Array_Variable.make_good_iov
def make_good_iov(self, iov)
Definition: afp.py:241
python.subdetectors.afp.DCSC_Merged_Variable.get_variable
def get_variable(self, name)
Definition: afp.py:41
python.sugar.iovtype.RANGEIOV_VAL
def RANGEIOV_VAL()
Definition: iovtype.py:153
python.subdetectors.afp.DCSC_Merged_Variable.merge_input_variables
def merge_input_variables(self, *inputs)
Definition: afp.py:69
python.subdetectors.afp.mapChannels
def mapChannels(*mapseqArgs)
Definition: afp.py:286
python.subdetectors.afp.TDAQC_Variable.iovs
iovs
Definition: afp.py:194
python.subdetectors.afp.TDAQC_Variable
Definition: afp.py:93
python.subdetectors.afp.TDAQC_Variable.path
path
Definition: afp.py:114
python.subdetectors.afp.AFP.defect_combinator
def defect_combinator(channels, defect_name, code, comment)
Definition: afp.py:420
python.subdetectors.afp.TDAQC_Variable.input_hashes
input_hashes
Definition: afp.py:115
python.variable.DefectIOV
def DefectIOV(channel, present, comment)
Definition: variable.py:26
python.subdetectors.afp.AFP.translators
translators
Definition: afp.py:438
python.subdetectors.afp.TDAQC_Variable.read
def read(self, query_range, query, *regex=False)
Definition: afp.py:120
python.subdetectors.afp.AFP.comment_TOF_LV
def comment_TOF_LV(iov)
Definition: afp.py:518
python.subdetectors.afp.TDAQC_Variable.timePBeast2COOL
def timePBeast2COOL(timestamp)
Definition: afp.py:104
python.subdetectors.afp.TDAQC_Variable.empty_value
empty_value
Definition: afp.py:112
dumpHVPathFromNtuple.append
bool append
Definition: dumpHVPathFromNtuple.py:91
python.subdetectors.afp.TDAQC_Multi_Channel_Variable
Definition: afp.py:205
python.utils.AtlRunQueryTimer.timer
def timer(name, disabled=False)
Definition: AtlRunQueryTimer.py:86
python.subdetectors.afp.TDAQC_Array_Variable
Definition: afp.py:240
python.variable.GoodIOV
def GoodIOV(channel, good)
Definition: variable.py:18
python.sugar.runlumi.RunLumi
RunLumi
Definition: runlumi.py:131
python.subdetectors.afp.DCSC_Merged_Variable.__init__
def __init__(self, folders, evaluator, *mapping={}, **kwargs)
Definition: afp.py:34
python.subdetectors.afp.TDAQC_Variable.__init__
def __init__(self, query, evaluator, *regex=False, mapping=dict(), force_mapping=False, empty_value=None)
Definition: afp.py:107
python.subdetectors.afp.TDAQC_Variable.make_good_iov
def make_good_iov(self, iov)
Definition: afp.py:197
python.subdetectors.afp.TDAQC_Multi_Channel_Variable.make_good_iovs
def make_good_iovs(self, iovs)
Definition: afp.py:217
convertTimingResiduals.sum
sum
Definition: convertTimingResiduals.py:55
python.subdetectors.afp.DCSC_Merged_Variable.folder_names
folder_names
Definition: afp.py:38
python.subdetectors.afp.AFP.comment_TOF_DISABLED
def comment_TOF_DISABLED(iov)
Definition: afp.py:542
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
python.subdetectors.afp.DCSC_Merged_Variable.read
def read(self, query_range, folder_base, folder_names)
Definition: afp.py:47
python.subdetectors.afp.TDAQC_Variable.subdetector
subdetector
Definition: afp.py:171
python.subdetectors.afp.AFP.__init__
def __init__(self, *args, **kwargs)
Definition: afp.py:436
python.subdetectors.afp.mapTranslatorCounts
def mapTranslatorCounts(countMap)
Definition: afp.py:289
python.subdetectors.afp.TDAQC_Variable.__repr__
def __repr__(self)
Definition: afp.py:117
python.subdetectors.afp.PBeastIOV
def PBeastIOV(channel, value)
Definition: afp.py:90
python.events.process_iovs
def process_iovs(*iovsets)
Definition: events.py:30
python.subdetectors.afp.AFP.comment_SIT_DISABLED
def comment_SIT_DISABLED(iov)
Definition: afp.py:538
DerivationFramework::TriggerMatchingUtils::sorted
std::vector< typename T::value_type > sorted(T begin, T end)
Helper function to create a sorted vector from an unsorted one.
CxxUtils::set
constexpr std::enable_if_t< is_bitmask_v< E >, E & > set(E &lhs, E rhs)
Convenience function to set bits in a class enum bitmask.
Definition: bitmask.h:224
min
#define min(a, b)
Definition: cfImp.cxx:40
CaloCondBlobAlgs_fillNoiseFromASCII.comment
string comment
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:27
python.subdetectors.afp.AFP.comment_SIT_COMBINATION
def comment_SIT_COMBINATION()
Combination defects.
Definition: afp.py:550
python.subdetectors.afp.TDAQC_Variable.query
query
Definition: afp.py:113
TCS::join
std::string join(const std::vector< std::string > &v, const char c=',')
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/Root/StringUtils.cxx:10
python.subdetectors.afp.AFP.color_to_defect_translator
def color_to_defect_translator(channel, defect_name, color, comment)
Definition: afp.py:411
python.subdetectors.afp.AFP.comment_TOF_HV
def comment_TOF_HV(iov)
Definition: afp.py:522
python.subdetectors.afp.AFP.comment_planes
def comment_planes(iov, message)
Comment templates.
Definition: afp.py:558
python.subdetectors.afp.DCSC_Merged_Variable.mapping
mapping
Definition: afp.py:39
python.subdetectors.afp.AFP.comment_device
def comment_device(iov, device, message)
Definition: afp.py:562
TrigJetMonitorAlgorithm.items
items
Definition: TrigJetMonitorAlgorithm.py:79
python.subdetectors.afp.DCSC_Variable_With_Mapping.mapping
mapping
Definition: afp.py:25
python.subdetectors.afp.DCSC_Variable_With_Mapping
Definition: afp.py:22
python.combo.combinations
def combinations(items, n)
Definition: combo.py:85
python.subdetectors.afp.TDAQC_Variable.mapping
mapping
Definition: afp.py:110
Cut::all
@ all
Definition: SUSYToolsAlg.cxx:64
python.subdetectors.afp.TDAQC_Variable.timeCOOL2PBeast
def timeCOOL2PBeast(timestamp)
Definition: afp.py:100
python.subdetectors.afp.AFP.comment_SIT_LV
def comment_SIT_LV(iov)
Definition: afp.py:510
python.subdetectors.afp.DCSC_Variable_With_Mapping.__init__
def __init__(self, folder, evaluator, *mapping=None, **kwargs)
Definition: afp.py:23
CaloCondBlobAlgs_fillNoiseFromASCII.hash
dictionary hash
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:109
python.subdetectors.afp.DCSC_Variable_With_Mapping.read
def read(self, query_range, folder_base, folder_name)
Definition: afp.py:27
get
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition: hcg.cxx:127
python.subdetectors.afp.TDAQC_Bit_Flag_Variable
Definition: afp.py:226
python.sugar.iovtype.make_iov_type
def make_iov_type(name, variables, bases=(IOVType,), _memoized={})
Definition: iovtype.py:114
python.subdetectors.afp.TDAQC_Multi_Channel_Variable.make_good_iov
def make_good_iov(self, iov)
Definition: afp.py:206
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:790
python.subdetectors.afp.TDAQC_Variable.force_mapping
force_mapping
Definition: afp.py:111
python.subdetectors.afp.AFP.comment_GARAGE
def comment_GARAGE(iov)
DCS defects.
Definition: afp.py:506
python.subdetectors.afp.TDAQC_Variable.regex
regex
Definition: afp.py:109
python.subdetectors.afp.remove_None
def remove_None(value, default)
Definition: afp.py:292
python.subdetectors.afp.TDAQC_Bit_Flag_Variable.make_good_iov
def make_good_iov(self, iov)
Definition: afp.py:227
python.subdetectors.afp.DCSC_Merged_Variable.merge_inputs
def merge_inputs(self, clazz, channel, *inputs)
Definition: afp.py:85
python.subdetectors.afp.AFP.merge_variable_states
def merge_variable_states(self, states)
Definition: afp.py:397