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