ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
DataQuality
DCSCalculator2
share
generate_mdt_mapping.py
Go to the documentation of this file.
1
#! /usr/bin/env python
2
"""
3
generate_mdt_mapping.py -- a script to generate the MDT channel mapping for HV, LV, JTAG from the COOL database.
4
5
from:
6
BEE1A02__HV <=> X
7
BEE1A02__LV <=> Y
8
BEE1A02__JTAG <=> Z
9
10
to:
11
X Y Z BEE1A02 302
12
13
https://svnweb.cern.ch/trac/atlasoff/browser/DataQuality/DQUtils/tags/DQUtils-00-01-04/python/db.py
14
https://svnweb.cern.ch/trac/atlasoff/browser/DataQuality/DQUtils/tags/DQUtils-00-01-04/python/channel_mapping.py
15
16
Run like:
17
18
[afs] asetup 20.1.4.7,here
19
[afs] python generate_mdt_mapping.py > mdt_codes.dat
20
21
Two exceptions, thanks to George Iakovidis and Stephanie Zimmerman:
22
* BOG0B12, BOG0B14 are associated to BOG0A12, BOG0A14 because they are located at z=0.
23
* BME5A13, BME5C13 share the same HV, LV with BME4A13, BME4C13 respectively (bigger chambers with 2xCSM)
24
25
Alex Tuna <tuna@cern>
26
"""
27
28
from
DQUtils
import
Databases
29
from
DQUtils.channel_mapping
import
get_channel_ids_names
30
31
database =
"COOLOFL_DCS/CONDBR2"
32
33
MDTBA, MDTBC, MDTEA, MDTEC = 302, 303, 304, 305
34
35
def
detector_region
(key):
36
""" e.g., translate BOF7C12 to MDTBC """
37
38
if
key[0] ==
"B"
and
key[4] ==
"A"
:
return
MDTBA
39
if
key[0] ==
"B"
and
key[4] ==
"B"
:
return
MDTBA
# exception
40
if
key[0] ==
"B"
and
key[4] ==
"C"
:
return
MDTBC
41
if
key[0] ==
"E"
and
key[4] ==
"A"
:
return
MDTEA
42
if
key[0] ==
"E"
and
key[4] ==
"C"
:
return
MDTEC
43
44
def
main
():
45
46
_, _, hv = get_channel_ids_names(Databases.get_folder(
"/MDT/DCS/HV"
, database))
47
_, _, lv = get_channel_ids_names(Databases.get_folder(
"/MDT/DCS/LV"
, database))
48
_, _, jt = get_channel_ids_names(Databases.get_folder(
"/MDT/DCS/JTAG"
, database))
49
50
all_keys = hv.keys() + lv.keys() + jt.keys()
51
string_keys = filter(
lambda
key: isinstance(key, str), all_keys)
52
region_keys =
set
()
53
54
for
key
in
string_keys:
55
56
region, folder = key.split(
"__"
)
57
region_keys.add(region)
58
59
for
key
in
sorted(region_keys):
60
line =
"%-6s %-6s %-6s %-8s %3s"
% (hv.get(key+
"__HV"
, 0),
61
lv.get(key+
"__LV"
, 0),
62
jt.get(key+
"__JTAG"
, 0),
63
key,
64
detector_region
(key),
65
)
66
67
# exceptions
68
if
key ==
"BOG0A12"
and
"BOG0B12"
in
region_keys:
continue
69
if
key ==
"BOG0A14"
and
"BOG0B14"
in
region_keys:
continue
70
if
key ==
"BOG0B12"
: line = line.replace(
"%-6s BOG0B12"
% (0),
"%-6s BOG0A12"
% (jt[
"BOG0A12__JTAG"
]))
71
if
key ==
"BOG0B14"
: line = line.replace(
"%-6s BOG0B14"
% (0),
"%-6s BOG0A14"
% (jt[
"BOG0A14__JTAG"
]))
72
if
key ==
"BME5A13"
: line = line.replace(
"%-6s %-6s"
% (0, 0),
"%-6s %-6s"
% (hv[
"BME4A13__HV"
], lv[
"BME4A13__LV"
]))
73
if
key ==
"BME5C13"
: line = line.replace(
"%-6s %-6s"
% (0, 0),
"%-6s %-6s"
% (hv[
"BME4C13__HV"
], lv[
"BME4C13__LV"
]))
74
75
if
line:
76
print
line
77
78
79
if
__name__ ==
"__main__"
:
80
main
()
set
STL class.
generate_mdt_mapping.main
main()
Definition
generate_mdt_mapping.py:44
generate_mdt_mapping.detector_region
detector_region(key)
Definition
generate_mdt_mapping.py:35
Generated on
for ATLAS Offline Software by
1.17.0