ATLAS Offline Software
mdt.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
2 
3 from pkg_resources import resource_string
4 
5 from ..lib import (DCSC_DefectTranslate_Subdetector,
6  DCSC_Variable_With_Mapping,
7  make_multi_mapping)
8 
9 MDTBA, MDTBC, MDTEA, MDTEC = 302, 303, 304, 305
10 
12  """
13  Creates dictionaries representing the mappings
14  for different systems onto the chamber name.
15  """
16  def fix_line(line):
17  if not line:
18  return None
19  hv, lv, jtag, name, output_channel = line.split()
20  return int(hv), int(lv), int(jtag), name, int(output_channel)
21 
22  mdtcodes = resource_string("DCSCalculator2.subdetectors.data", "mdt_codes.dat").decode().strip().split("\n")
23 
24 
25  lines = [line for line in [fix_line(raw_line) for raw_line in mdtcodes if raw_line] if line]
26 
27  name_to_output = make_multi_mapping((name, output_channel) for hv, lv, jtag, name, output_channel in lines)
28  hv_to_name = make_multi_mapping((hv, name) for hv, lv, jtag, name, output_channel in lines)
29  lv_to_name = make_multi_mapping((lv, name) for hv, lv, jtag, name, output_channel in lines)
30  jtag_to_name = make_multi_mapping((jtag, name) for hv, lv, jtag, name, output_channel in lines)
31  name_to_name = make_multi_mapping((name, name) for hv, lv, jtag, name, output_channel in lines)
32 
33  return name_to_output, hv_to_name, lv_to_name, jtag_to_name, name_to_name
34 
35 
36 def evaluator_HV(iov):
37  """
38  Some chambers dont have a second multilayer (ML2).
39  Dont flag these as bad.
40  """
41  if iov.channel in range(245, 253): #Lower voltage requirement for new BIS78 chambers
42  hv = (
43  (
44  iov.fsmCurrentState_ML1 in ["ON"] and iov.v1set_ML1 >= 2730 and
45  ((iov.fsmCurrentState_ML2 in ["ON"] and iov.v1set_ML2 >= 2730) or iov.fsmCurrentState_ML2 == "")
46  )
47 
48  or
49 
50  (
51  iov.fsmCurrentState_ML1 == "STANDBY" and iov.v0set_ML1 >= 2730 and
52  iov.fsmCurrentState_ML2 == "STANDBY" and iov.v0set_ML2 >= 2730
53  )
54  )
55  else: # Original Requirement
56  hv = (
57  (
58  iov.fsmCurrentState_ML1 in ["ON"] and iov.v1set_ML1 >= 3050 and
59  ((iov.fsmCurrentState_ML2 in ["ON"] and iov.v1set_ML2 >= 3050) or iov.fsmCurrentState_ML2 == "")
60  )
61 
62  or
63 
64  (
65  iov.fsmCurrentState_ML1 == "STANDBY" and iov.v0set_ML1 >= 3050 and
66  iov.fsmCurrentState_ML2 == "STANDBY" and iov.v0set_ML2 >= 3050
67  )
68  )
69 
70  # uncomment me for debugging
71  # if not hv and "2016-05-17 01:3" in str(iov.since):
72  # try:
73  # name_to_output, hv_to_name, lv_to_name, jtag_to_name, name_to_name = generate_mdt_mappings()
74  # print "%25s %12s %12s %10.3f %10.3f | %s - %s" % (hv_to_name[iov.channel],
75  # iov.fsmCurrentState_ML1, iov.fsmCurrentState_ML2,
76  # iov.iMon_ML1, iov.iMon_ML2,
77  # iov.since, iov.until)
78  # except:
79  # pass
80 
81  return hv
82 
83 def evaluator_LV(iov):
84  return iov.fsmCurrentState_LV == "ON"
85 
86 def evaluator_JTAG(iov):
87  return iov.fsmCurrentState_JTAG == "INITIALIZED"
88 
90  """
91  The MDTs require a channel mapping to map channelids from different folders
92  onto a consistent numbering scheme. Here we use the chamber name (e.g., BIS2C08)
93  as the "master" channel. Everything else is mapped on to this.
94  """
95  folder_base = "/MDT/DCS"
96 
97  def __init__(self, *args, **kwargs):
98  """
99  Initialize mappings.
100  """
101  super(MDT, self).__init__(*args, **kwargs)
102 
103  mappings = generate_mdt_mappings()
104  name_to_output, hv_to_name, lv_to_name, jtag_to_name, name_to_name = mappings
105 
106  # save the reverse mapping, too
107  self.input_to_output_map = name_to_output
108  self.mapping = {}
109  for key, value in self.input_to_output_map.items():
110  self.mapping.setdefault(value, []).append(key)
111 
112  self.set_input_mapping("HV", hv_to_name)
113  self.set_input_mapping("LV", lv_to_name)
114  self.set_input_mapping("JTAG", jtag_to_name)
115 
116  self.translators = [MDT.color_to_defect_translator(flag, defect) for flag, defect in ((MDTBA, 'MS_MDT_BA_STANDBY_HV'),
117  (MDTBC, 'MS_MDT_BC_STANDBY_HV'),
118  (MDTEA, 'MS_MDT_EA_STANDBY_HV'),
119  (MDTEC, 'MS_MDT_EC_STANDBY_HV'),
120  )]
121 
122  variables = [DCSC_Variable_With_Mapping("HV", evaluator_HV),
123  DCSC_Variable_With_Mapping("LV", evaluator_LV),
124  DCSC_Variable_With_Mapping("JTAG", evaluator_JTAG),
125  ]
126 
127  # If you change this please consult with the Muon groups.
128  # It was decided to make it the same across CSC, MDT, RPC and TGC.
129  dead_fraction_caution = None
130  dead_fraction_bad = 0.1
131 
AtlasMcWeight::decode
double decode(number_type binnedWeight)
Convert weight from unsigned to double.
Definition: AtlasMcWeight.cxx:32
python.subdetectors.mdt.evaluator_HV
def evaluator_HV(iov)
Definition: mdt.py:36
python.subdetectors.mdt.generate_mdt_mappings
def generate_mdt_mappings()
Definition: mdt.py:11
python.subdetectors.mdt.MDT
Definition: mdt.py:89
python.subdetectors.mdt.evaluator_LV
def evaluator_LV(iov)
Definition: mdt.py:83
python.libcore.make_multi_mapping
def make_multi_mapping(iterable)
Definition: libcore.py:17
python.subdetector.DCSC_DefectTranslate_Subdetector.translators
translators
Definition: subdetector.py:540
dumpHVPathFromNtuple.append
bool append
Definition: dumpHVPathFromNtuple.py:91
python.subdetector.DCSC_DefectTranslate_Subdetector
Definition: subdetector.py:531
python.subdetectors.mdt.evaluator_JTAG
def evaluator_JTAG(iov)
Definition: mdt.py:86
python.subdetectors.mdt.MDT.mapping
mapping
Definition: mdt.py:108
python.subdetector.DCSC_Subdetector.set_input_mapping
def set_input_mapping(self, what, mapping)
Definition: subdetector.py:51
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:194
python.subdetectors.mdt.MDT.__init__
def __init__(self, *args, **kwargs)
Definition: mdt.py:97
python.subdetector.DCSC_Subdetector.input_to_output_map
input_to_output_map
Definition: subdetector.py:36
TrigJetMonitorAlgorithm.items
items
Definition: TrigJetMonitorAlgorithm.py:71
python.CaloAddPedShiftConfig.int
int
Definition: CaloAddPedShiftConfig.py:45
python.variable.DCSC_Variable_With_Mapping
Definition: variable.py:224
Trk::split
@ split
Definition: LayerMaterialProperties.h:38