SND@LHC Software
Loading...
Searching...
No Matches
boardMappingParser.py
Go to the documentation of this file.
1
#!/usr/bin/env python3
2
3
import
json
4
5
def
getBoardMapping
(jsonString):
6
boardMapsNew = {
'Scifi'
: {},
'MuFilter'
: {}}
7
8
# converts the JSON string into a dictionary
9
j = json.loads(jsonString)
10
11
# the mapping is structured as: {<subsystem>: {<plane>: {<settings>...}, ...}, ...}
12
# subsystem is veto, scifi, us, ds
13
# plane depends on subsystem (e.g. '1x', '1y'... for Scifi)
14
# settings depends on sybsystem as well
15
# more info here: https://gitlab.cern.ch/snd-scifi/software/-/wikis/Board-Mapping
16
17
# loops over the subsystems
18
for
subsys, planes
in
j.items():
19
# each subsystem is treated separately
20
if
subsys ==
'scifi'
:
21
# loops over the planes in the subsystem
22
for
plane, conf
in
planes.items():
23
# sanity check that the settings are correct
24
if
conf[
'class'
] !=
'multiboard'
or
conf[
'type'
] !=
'snd_scifi'
:
25
raise
RuntimeError(
'wrong class/type: '
+ conf[
'class'
] +
'/'
+ conf[
'type'
])
26
27
# loops over the boards (for SciFi)
28
for
i, bid
in
enumerate(conf[
'boards'
]):
29
boardMapsNew[
'Scifi'
][f
'board_{bid}'
] = [f
'M{plane}'
.upper(), i]
30
31
elif
subsys ==
'veto'
:
32
for
plane, conf
in
planes.items():
33
if
conf[
'class'
] !=
'multislot'
or
conf[
'type'
] !=
'snd_veto'
:
34
raise
RuntimeError(
'wrong class/type: '
+ conf[
'class'
] +
'/'
+ conf[
'type'
])
35
36
# adds the 'board_XX' entry in the dictionary of not already there
37
bString = f
'board_{conf["board"]}'
38
if
bString
not
in
boardMapsNew[
'MuFilter'
]:
39
boardMapsNew[
'MuFilter'
][bString] = {}
40
41
# loops over the slots (the first is always left, the second always right)
42
for
i
in
range(2):
43
if
int(plane) <3:
44
boardMapsNew[
'MuFilter'
][bString][conf[
'slots'
][i]] = f
'Veto_{plane}{"Left" if i == 0 else "Right"}'
45
# The vertical Veto plane has one slot only
46
if
int(plane) ==3
and
i == 0:
47
boardMapsNew[
'MuFilter'
][bString][conf[
'slots'
][i]] = f
'Veto_{plane[i]}Vert'
48
49
elif
subsys ==
'us'
:
50
for
plane, conf
in
planes.items():
51
if
conf[
'class'
] !=
'multislot'
or
conf[
'type'
] !=
'snd_us'
:
52
raise
RuntimeError(
'wrong class/type: '
+ conf[
'class'
] +
'/'
+ conf[
'type'
])
53
54
bString = f
'board_{conf["board"]}'
55
if
bString
not
in
boardMapsNew[
'MuFilter'
]:
56
boardMapsNew[
'MuFilter'
][bString] = {}
57
58
for
i
in
range(2):
59
boardMapsNew[
'MuFilter'
][bString][conf[
'slots'
][i]] = f
'US_{plane}{"Left" if i == 0 else "Right"}'
60
61
elif
subsys ==
'ds'
:
62
for
plane, conf
in
planes.items():
63
if
conf[
'class'
] !=
'multislot'
or
(conf[
'type'
] !=
'snd_dsh'
and
conf[
'type'
] !=
'snd_dsv'
):
64
raise
RuntimeError(
'wrong class/type: '
+ conf[
'class'
] +
'/'
+ conf[
'type'
])
65
66
bString = f
'board_{conf["board"]}'
67
if
bString
not
in
boardMapsNew[
'MuFilter'
]:
68
boardMapsNew[
'MuFilter'
][bString] = {}
69
70
# for DS we have the additional complication of vertival planes, but they are two different plane types (snd_dsh and snd_dsv)
71
if
conf[
'type'
] ==
'snd_dsh'
:
72
for
i
in
range(2):
73
boardMapsNew[
'MuFilter'
][bString][conf[
'slots'
][i]] = f
'DS_{plane[0]}{"Left" if i == 0 else "Right"}'
74
else
:
75
# vertical planes use one slot only
76
boardMapsNew[
'MuFilter'
][bString][conf[
'slots'
][0]] = f
'DS_{plane[0]}Vert'
77
78
else
:
79
raise
RuntimeError(
'unknown subsystem: '
+ subsys)
80
81
return
boardMapsNew
82
83
def
oldMapping
(path):
84
# station mapping for SciFi
85
stations = {}
86
stations[
'M1Y'
] = {0:29, 1:3, 2:30}
# three fibre mats per plane
87
stations[
'M1X'
] = {0:11, 1:17, 2:28}
88
stations[
'M2Y'
] = {0:16, 1:14, 2:18}
89
stations[
'M2X'
] = {0:1, 1:2, 2:25}
90
stations[
'M3Y'
] = {0:15, 1:9, 2:5}
91
stations[
'M3X'
] = {0:22, 1:27, 2:4}
92
if
path.find(
"commissioning-h6"
)>0: stations[
'M4Y'
] = {0:46, 1:40, 2:20}
# board 40 replaces 23
93
else
: stations[
'M4Y'
] = {0:46, 1:23, 2:20}
94
stations[
'M4X'
] = {0:8, 1:50, 2:49}
95
stations[
'M5Y'
] = {0:19, 1:13, 2:36}
96
stations[
'M5X'
] = {0:21, 1:10, 2:6}
97
98
# board mapping for Scifi
99
boardMaps = {}
100
boardMaps[
'Scifi'
] = {}
101
for
station
in
stations:
102
for
mat
in
stations[station]:
103
board =
'board_'
+str(stations[station][mat])
104
boardMaps[
'Scifi'
][board]=[station,mat]
105
106
boardMaps[
'MuFilter'
] = {}
107
# hopefully final mapping of TI18
108
boardMaps[
'MuFilter'
][
'board_52'
] = {
'B'
:
'Veto_1Left'
,
'C'
:
'Veto_1Right'
,
'A'
:
'Veto_2Left'
,
'D'
:
'Veto_2Right'
}
109
boardMaps[
'MuFilter'
][
'board_43'
] = {
'D'
:
'US_1Left'
,
'A'
:
'US_1Right'
,
'C'
:
'US_2Left'
,
'B'
:
'US_2Right'
}
110
boardMaps[
'MuFilter'
][
'board_60'
] = {
'D'
:
'US_3Left'
,
'A'
:
'US_3Right'
,
'C'
:
'US_4Left'
,
'B'
:
'US_4Right'
}
111
boardMaps[
'MuFilter'
][
'board_41'
] = {
'D'
:
'US_5Left'
,
'A'
:
'US_5Right'
,
'C'
:
'DS_1Left'
,
'B'
:
'DS_1Right'
}
112
boardMaps[
'MuFilter'
][
'board_42'
] = {
'D'
:
'DS_2Left'
,
'A'
:
'DS_2Right'
,
'B'
:
'DS_1Vert'
,
'C'
:
'DS_2Vert'
}
113
boardMaps[
'MuFilter'
][
'board_55'
] = {
'D'
:
'DS_3Left'
,
'A'
:
'DS_3Right'
,
'B'
:
'DS_3Vert'
,
'C'
:
'DS_4Vert'
}
114
115
if
path.find(
"commissioning-h6"
)>0
or
path.find(
"TB_data_commissioning"
)>0 :
116
# H6 / H8
117
boardMaps[
'MuFilter'
][
'board_43'
] = {
'A'
:
'US_1Left'
,
'B'
:
'US_2Left'
,
'C'
:
'US_2Right'
,
'D'
:
'US_1Right'
}
118
boardMaps[
'MuFilter'
][
'board_60'
] = {
'A'
:
'US_3Left'
,
'B'
:
'US_4Left'
,
'C'
:
'US_4Right'
,
'D'
:
'US_3Right'
}
119
boardMaps[
'MuFilter'
][
'board_41'
] = {
'A'
:
'US_5Left'
,
'B'
:
'DS_1Left'
,
'C'
:
'DS_1Right'
,
'D'
:
'US_5Right'
}
120
if
path.find(
"commissioning-h6"
)>0: boardMaps[
'MuFilter'
][
'board_59'
] = {
'A'
:
'DS_2Right'
,
'B'
:
'DS_2Vert'
,
'C'
:
'DS_1Vert'
,
'D'
:
'DS_2Left'
}
121
else
: boardMaps[
'MuFilter'
][
'board_59'
] = {
'A'
:
'DS_2Left'
,
'B'
:
'DS_1Vert'
,
'C'
:
'DS_2Vert'
,
'D'
:
'DS_2Right'
}
122
boardMaps[
'MuFilter'
][
'board_42'
] = {
'A'
:
'DS_3Left'
,
'B'
:
'DS_4Vert'
,
'C'
:
'DS_3Vert'
,
'D'
:
'DS_3Right'
}
123
boardMaps[
'MuFilter'
][
'board_52'
] = {
'A'
:
'Veto_2Left'
,
'B'
:
'Veto_1Left'
,
'C'
:
'Veto_1Right'
,
'D'
:
'Veto_2Right'
}
124
if
path.find(
"data_commissioning_dune"
)>0:
# does not work
125
boardMaps[
'MuFilter'
][
'board_43'
] = {
'A'
:
'US_1Left'
,
'B'
:
'US_2Left'
,
'C'
:
'US_2Right'
,
'D'
:
'US_1Right'
}
126
boardMaps[
'MuFilter'
][
'board_60'
] = {
'A'
:
'US_3Left'
,
'B'
:
'US_4Left'
,
'C'
:
'US_4Right'
,
'D'
:
'US_3Right'
}
127
boardMaps[
'MuFilter'
][
'board_41'
] = {
'A'
:
'US_5Left'
,
'B'
:
'DS_1Left'
,
'C'
:
'DS_1Right'
,
'D'
:
'US_5Right'
}
128
boardMaps[
'MuFilter'
][
'board_59'
] = {
'A'
:
'DS_2Left'
,
'B'
:
'DS_1Vert'
,
'C'
:
'DS_2Vert'
,
'D'
:
'DS_2Right'
}
129
boardMaps[
'MuFilter'
][
'board_42'
] = {
'A'
:
'DS_3Left'
,
'B'
:
'DS_3Vert'
,
'C'
:
'notconnected'
,
'D'
:
'notconnected'
}
130
boardMaps[
'MuFilter'
][
'board_52'
] = {
'A'
:
'DS_3Right'
,
'B'
:
'notconnected'
,
'C'
:
'notconnected'
,
'D'
:
'notconnected'
}
131
return
boardMaps
132
133
import
os
134
path =
"/eos/experiment/sndlhc/testbeam/commissioning-h6/run_000010/"
135
136
def
main
():
137
# open the file as a normal text file and read it
138
if
path.find(
'eos'
)<0
or
os.path.isdir(path):
139
f = open(path+
"/board_mapping.json"
)
140
jsonStr = f.read()
141
else
:
142
from
XRootD
import
client
143
server = os.environ[
'EOSSHIP'
]
144
with
client.File()
as
f:
145
f.open(server+path+
"/board_mapping.json"
)
146
status, jsonStr = f.read()
147
148
# pass the read string to getBoardMapping()
149
return
getBoardMapping
(jsonStr)
150
151
152
if
__name__ ==
'__main__'
:
153
main
()
boardMappingParser.main
main()
Definition
boardMappingParser.py:136
boardMappingParser.getBoardMapping
getBoardMapping(jsonString)
Definition
boardMappingParser.py:5
boardMappingParser.oldMapping
oldMapping(path)
Definition
boardMappingParser.py:83
shipLHC
rawData
boardMappingParser.py
Generated by
1.9.8