18import matplotlib.pyplot
as plt
19import matplotlib.patches
as patches
21from ROOT
import Belle2
24 sys.exit(
"No input .root file specified!")
26inputroot = sys.argv[1]
27file = ROOT.TFile(inputroot,
"OPEN")
28vxd = file.Get(
"VXDAlignment")
30fileName = inputroot +
'.txt'
32text_file = open(fileName,
"w")
33text_file.write(
"layer ladder sensor param value\n")
34for entry
in vxd.getMap():
35 element_parameter = entry.first
37 element = element_parameter.first
38 param = element_parameter.second
40 layer = vxdid.getLayerNumber()
41 ladder = vxdid.getLadderNumber()
42 sensor = vxdid.getSensorNumber()
44 text_file.write(
"{} {} {} {} {}\n".format(layer, ladder, sensor, param, value))
47for parameter
in range(1, 7):
48 text_file.write(
"{} {} {} {} {}\n".format(1, 0, 1, parameter, vxd.get(int(
Belle2.VxdID(1, 0, 0, 1)), parameter)))
49 text_file.write(
"{} {} {} {} {}\n".format(1, 0, 2, parameter, vxd.get(int(
Belle2.VxdID(1, 0, 0, 2)), parameter)))
50 text_file.write(
"{} {} {} {} {}\n".format(3, 0, 1, parameter, vxd.get(int(
Belle2.VxdID(3, 0, 0, 1)), parameter)))
51 text_file.write(
"{} {} {} {} {}\n".format(3, 0, 2, parameter, vxd.get(int(
Belle2.VxdID(3, 0, 0, 2)), parameter)))
52 for layer
in range(1, 7):
53 text_file.write(
"{} {} {} {} {}\n".format(layer, 1, 0, parameter, vxd.get(int(
Belle2.VxdID(layer, 1, 0)), parameter)))
61 (4, 1, 1), (4, 1, 2), (4, 1, 3),
62 (5, 1, 1), (5, 1, 2), (5, 1, 3), (5, 1, 4),
63 (6, 1, 1), (6, 1, 2), (6, 1, 3), (6, 1, 4), (6, 1, 5)
81print(
'reading from file ' + fileName)
83dataframe = pd.read_table(
86 skipinitialspace=
True,
95scale = np.where(dataframe.parameter < 4, 1.0e4, 1.0e3)
96for colname
in [
'value']:
97 dataframe[colname] *= scale
99font = {
'family':
'normal',
'weight':
'bold',
'size': 22}
102 [0.20, 0.00, 0.60, 0.10],
103 [0.60, 0.00, 0.99, 0.10],
104 [0.20, 0.12, 0.60, 0.22],
105 [0.60, 0.12, 0.99, 0.22],
106 [0.20, 0.25, 0.60, 0.35],
107 [0.60, 0.25, 0.99, 0.35],
108 [0.00, 0.38, 0.30, 0.52],
109 [0.30, 0.38, 0.60, 0.52],
110 [0.60, 0.38, 0.90, 0.52],
111 [0.00, 0.58, 0.25, 0.72],
112 [0.25, 0.58, 0.50, 0.72],
113 [0.50, 0.58, 0.75, 0.72],
114 [0.75, 0.58, 0.99, 0.72],
115 [0.00, 0.78, 0.20, 0.92],
116 [0.20, 0.78, 0.40, 0.92],
117 [0.40, 0.78, 0.60, 0.92],
118 [0.60, 0.78, 0.80, 0.92],
119 [0.80, 0.78, 0.99, 0.92])
121excludedSensor = [
True,
True,
True,
True,
True,
True,
True,
True,
True,
True,
True,
True,
True,
True,
True,
True,
True,
True]
122excludedLadder = [
True,
True,
True,
True,
True,
True]
123excludedHalfShell = [
True,
True]
125quantity = [
r'NAN',
r'$u$ = ',
r'$v$ = ',
r'$w$ = ',
r'$\alpha$ = ',
r'$\beta$ = ',
r'$\gamma$ = ']
126unit = [
r'NAN',
' um',
' um',
' um',
' mrad',
' mrad',
' mrad']
127line = [
'NAN',
r'$u$ = NAN',
r'$v$ = NAN',
r'$w$ = NAN',
r'$\alpha$ = NAN',
r'$\beta$ = NAN',
r'$\gamma$ = NAN']
129fig = plt.figure(figsize=(8.27, 11.69))
130ax = fig.add_subplot(111)
132ax.text(0.00, 0.97,
'Experiment: 1002(Phase II), Run: XXXX, Date: 6/10/2017', color=
'black', size=
'14.5', weight=
'bold')
134ax.text(0.05, 0.03,
' layer 1 \nladder 1', color=
'black', size=
'12', weight=
'bold')
135ax.text(0.05, 0.15,
' layer 2 \nladder 1', color=
'black', size=
'12', weight=
'bold')
136ax.text(0.05, 0.28,
' layer 3 \nladder 1', color=
'black', size=
'12', weight=
'bold')
137ax.text(0.40, 0.53,
' layer 4 ladder 1', color=
'black', size=
'12', weight=
'bold')
138ax.text(0.40, 0.73,
' layer 5 ladder 1', color=
'black', size=
'12', weight=
'bold')
139ax.text(0.40, 0.93,
' layer 6 ladder 1', color=
'black', size=
'12', weight=
'bold')
143for i
in range(0, 18):
144 layer_id, ladder_id, sensor_id = beast2_sensors[i]
145 print(
'Sensor: ', layer_id,
'.', ladder_id,
'.', sensor_id)
146 for j
in [1, 2, 3, 4, 5, 6]:
147 number = float(dataframe[
'value'][dataframe[
'layer'] == layer_id][dataframe[
'ladder'] == ladder_id]
148 [dataframe[
'sensor'] == sensor_id][dataframe[
'parameter'] == j])
150 excludedSensor[i] =
False
151 line[j] = quantity[j] + str(round(number, 5)) + unit[j]
154 print(
'Non calculated ladder!!')
157 if excludedSensor[i]:
158 if (i == 6
or i == 9
or i == 13):
159 ax.add_patch(plt.Polygon([[sensorCoordinates[i][0],
160 sensorCoordinates[i][1] - 0.03],
161 [sensorCoordinates[i][2],
162 sensorCoordinates[i][1]],
163 [sensorCoordinates[i][2],
164 sensorCoordinates[i][3]],
165 [sensorCoordinates[i][0],
166 sensorCoordinates[i][3] + 0.03]],
170 ax.add_patch(plt.Polygon([[sensorCoordinates[i][0],
171 sensorCoordinates[i][1] - 0.03],
172 [sensorCoordinates[i][2],
173 sensorCoordinates[i][1]],
174 [sensorCoordinates[i][2],
175 sensorCoordinates[i][3]],
176 [sensorCoordinates[i][0],
177 sensorCoordinates[i][3] + 0.03]],
180 ax.add_patch(plt.Polygon([[sensorCoordinates[i][0], sensorCoordinates[i][1]],
181 [sensorCoordinates[i][2], sensorCoordinates[i][1]],
182 [sensorCoordinates[i][2], sensorCoordinates[i][3]],
183 [sensorCoordinates[i][0], sensorCoordinates[i][3]]],
184 facecolor=
'red', alpha=0.3, edgecolor=
'black'))
185 ax.add_patch(plt.Polygon([[sensorCoordinates[i][0], sensorCoordinates[i][1]],
186 [sensorCoordinates[i][2], sensorCoordinates[i][1]],
187 [sensorCoordinates[i][2], sensorCoordinates[i][3]],
188 [sensorCoordinates[i][0], sensorCoordinates[i][3]]], fill=
None))
191 if (i == 6
or i == 9
or i == 13):
192 ax.add_patch(plt.Polygon([[sensorCoordinates[i][0],
193 sensorCoordinates[i][1] - 0.03],
194 [sensorCoordinates[i][2],
195 sensorCoordinates[i][1]],
196 [sensorCoordinates[i][2],
197 sensorCoordinates[i][3]],
198 [sensorCoordinates[i][0],
199 sensorCoordinates[i][3] + 0.03]],
203 ax.add_patch(plt.Polygon([[sensorCoordinates[i][0],
204 sensorCoordinates[i][1] - 0.03],
205 [sensorCoordinates[i][2],
206 sensorCoordinates[i][1]],
207 [sensorCoordinates[i][2],
208 sensorCoordinates[i][3]],
209 [sensorCoordinates[i][0],
210 sensorCoordinates[i][3] + 0.03]],
213 ax.add_patch(plt.Polygon([[sensorCoordinates[i][0],
214 sensorCoordinates[i][1]],
215 [sensorCoordinates[i][2],
216 sensorCoordinates[i][1]],
217 [sensorCoordinates[i][2],
218 sensorCoordinates[i][3]],
219 [sensorCoordinates[i][0],
220 sensorCoordinates[i][3]]],
224 ax.add_patch(plt.Polygon([[sensorCoordinates[i][0], sensorCoordinates[i][1]],
225 [sensorCoordinates[i][2], sensorCoordinates[i][1]],
226 [sensorCoordinates[i][2], sensorCoordinates[i][3]],
227 [sensorCoordinates[i][0], sensorCoordinates[i][3]]], fill=
None))
231 sensorCoordinates[i][0] + 0.02,
232 sensorCoordinates[i][1] + 0.080,
239 boxstyle=
'round,pad=0.15'))
241 sensorCoordinates[i][0] + 0.02,
242 sensorCoordinates[i][1] + 0.045,
249 boxstyle=
'round,pad=0.15'))
251 sensorCoordinates[i][0] + 0.02,
252 sensorCoordinates[i][1] + 0.010,
259 boxstyle=
'round,pad=0.15'))
261 sensorCoordinates[i][0] + 0.20,
262 sensorCoordinates[i][1] + 0.078,
269 boxstyle=
'round,pad=0.15'))
271 sensorCoordinates[i][0] + 0.20,
272 sensorCoordinates[i][1] + 0.045,
279 boxstyle=
'round,pad=0.15'))
281 sensorCoordinates[i][0] + 0.20,
282 sensorCoordinates[i][1] + 0.012,
289 boxstyle=
'round,pad=0.15'))
291 ax.text(sensorCoordinates[i][0] + (sensorCoordinates[i][2] - sensorCoordinates[i][0]) / 4 - 0.024,
292 sensorCoordinates[i][1] + 0.121,
296 bbox=dict(facecolor=
'white',
298 boxstyle=
'round,pad=0.15'))
299 ax.text(sensorCoordinates[i][0] + (sensorCoordinates[i][2] - sensorCoordinates[i][0]) / 4 - 0.024,
300 sensorCoordinates[i][1] + 0.099,
304 bbox=dict(facecolor=
'white',
306 boxstyle=
'round,pad=0.15'))
307 ax.text(sensorCoordinates[i][0] + (sensorCoordinates[i][2] - sensorCoordinates[i][0]) / 4 - 0.024,
308 sensorCoordinates[i][1] + 0.077,
312 bbox=dict(facecolor=
'white',
314 boxstyle=
'round,pad=0.15'))
315 ax.text(sensorCoordinates[i][0] + (sensorCoordinates[i][2] - sensorCoordinates[i][0]) / 4 - 0.030,
316 sensorCoordinates[i][1] + 0.055,
320 bbox=dict(facecolor=
'white',
322 boxstyle=
'round,pad=0.15'))
323 ax.text(sensorCoordinates[i][0] + (sensorCoordinates[i][2] - sensorCoordinates[i][0]) / 4 - 0.030,
324 sensorCoordinates[i][1] + 0.033,
328 bbox=dict(facecolor=
'white',
330 boxstyle=
'round,pad=0.15'))
331 ax.text(sensorCoordinates[i][0] + (sensorCoordinates[i][2] - sensorCoordinates[i][0]) / 4 - 0.030,
332 sensorCoordinates[i][1] + 0.011,
336 bbox=dict(facecolor=
'white',
338 boxstyle=
'round,pad=0.15'))
340 line = [
'NAN',
r'$u$ = NAN',
r'$v$ = NAN',
r'$w$ = NAN',
r'$\alpha$ = NAN',
r'$\beta$ = NAN',
r'$\gamma$ = NAN']
343fig.savefig(
'outputSensors.png', dpi=300)
346fig = plt.figure(figsize=(8.27, 11.69))
347ax = fig.add_subplot(111)
351ax.text(0.00, 0.97,
'Experiment: 1002(Phase II), Run: XXXX, Date: 6/10/2017', color=
'black', size=
'14.5', weight=
'bold')
353ax.text(0.00, 0.325,
' layer 1 ladder 1', color=
'black', size=
'12', weight=
'bold')
354ax.text(0.00, 0.405,
' layer 2 ladder 1', color=
'black', size=
'12', weight=
'bold')
355ax.text(0.00, 0.485,
' layer 3 ladder 1', color=
'black', size=
'12', weight=
'bold')
356ax.text(0.00, 0.59,
' layer 4 ladder 1', color=
'black', size=
'12', weight=
'bold')
357ax.text(0.00, 0.73,
' layer 5 ladder 1', color=
'black', size=
'12', weight=
'bold')
358ax.text(0.00, 0.88,
' layer 6 ladder 1', color=
'black', size=
'12', weight=
'bold')
361 [0.20, 0.30, 0.60, 0.36],
362 [0.60, 0.30, 0.99, 0.36],
363 [0.20, 0.38, 0.60, 0.44],
364 [0.60, 0.38, 0.99, 0.44],
365 [0.20, 0.46, 0.60, 0.52],
366 [0.60, 0.46, 0.99, 0.52],
367 [0.00, 0.56, 0.30, 0.63],
368 [0.30, 0.56, 0.60, 0.63],
369 [0.60, 0.56, 0.90, 0.63],
370 [0.00, 0.70, 0.25, 0.78],
371 [0.25, 0.70, 0.50, 0.78],
372 [0.50, 0.70, 0.75, 0.78],
373 [0.75, 0.70, 0.99, 0.78],
374 [0.00, 0.85, 0.20, 0.92],
375 [0.20, 0.85, 0.40, 0.92],
376 [0.40, 0.85, 0.60, 0.92],
377 [0.60, 0.85, 0.80, 0.92],
378 [0.80, 0.85, 0.99, 0.92])
382 layer_id, ladder_id, sensor_id = beast2_ladders[i]
383 for j
in [1, 2, 3, 4, 5, 6]:
384 number = float(dataframe[
'value'][dataframe[
'layer'] == layer_id][dataframe[
'ladder'] == ladder_id]
385 [dataframe[
'sensor'] == sensor_id][dataframe[
'parameter'] == j])
387 excludedLadder[i] =
False
389for i
in range(0, 18):
390 excludedSensor[i] =
False
392 if excludedLadder[0]:
393 excludedSensor[i] =
True
395 if excludedLadder[1]:
396 excludedSensor[i] =
True
398 if excludedLadder[2]:
399 excludedSensor[i] =
True
401 if excludedLadder[3]:
402 excludedSensor[i] =
True
403 if i
in range(9, 13):
404 if excludedLadder[4]:
405 excludedSensor[i] =
True
406 if i
in range(13, 18):
407 if excludedLadder[5]:
408 excludedSensor[i] =
True
410 if excludedSensor[i]:
411 if (i == 6
or i == 9
or i == 13):
412 ax.add_patch(plt.Polygon([[sensorCoordinates[i][0],
413 sensorCoordinates[i][1] - 0.03],
414 [sensorCoordinates[i][2],
415 sensorCoordinates[i][1]],
416 [sensorCoordinates[i][2],
417 sensorCoordinates[i][3]],
418 [sensorCoordinates[i][0],
419 sensorCoordinates[i][3] + 0.03]],
423 ax.add_patch(plt.Polygon([[sensorCoordinates[i][0],
424 sensorCoordinates[i][1] - 0.03],
425 [sensorCoordinates[i][2],
426 sensorCoordinates[i][1]],
427 [sensorCoordinates[i][2],
428 sensorCoordinates[i][3]],
429 [sensorCoordinates[i][0],
430 sensorCoordinates[i][3] + 0.03]],
433 ax.add_patch(plt.Polygon([[sensorCoordinates[i][0], sensorCoordinates[i][1]],
434 [sensorCoordinates[i][2], sensorCoordinates[i][1]],
435 [sensorCoordinates[i][2], sensorCoordinates[i][3]],
436 [sensorCoordinates[i][0], sensorCoordinates[i][3]]],
437 facecolor=
'red', alpha=0.3, edgecolor=
'black'))
438 ax.add_patch(plt.Polygon([[sensorCoordinates[i][0], sensorCoordinates[i][1]],
439 [sensorCoordinates[i][2], sensorCoordinates[i][1]],
440 [sensorCoordinates[i][2], sensorCoordinates[i][3]],
441 [sensorCoordinates[i][0], sensorCoordinates[i][3]]], fill=
None))
444 if (i == 6
or i == 9
or i == 13):
445 ax.add_patch(plt.Polygon([[sensorCoordinates[i][0],
446 sensorCoordinates[i][1] - 0.03],
447 [sensorCoordinates[i][2],
448 sensorCoordinates[i][1]],
449 [sensorCoordinates[i][2],
450 sensorCoordinates[i][3]],
451 [sensorCoordinates[i][0],
452 sensorCoordinates[i][3] + 0.03]],
459 ax.add_patch(plt.Polygon([[sensorCoordinates[i][0],
460 sensorCoordinates[i][1]],
461 [sensorCoordinates[i][2],
462 sensorCoordinates[i][1]],
463 [sensorCoordinates[i][2],
464 sensorCoordinates[i][3]],
465 [sensorCoordinates[i][0],
466 sensorCoordinates[i][3]]],
482 layer_id, ladder_id, sensor_id = beast2_ladders[i]
483 print(
'Sensor: ', layer_id,
'.', ladder_id,
'.', sensor_id)
484 for j
in [1, 2, 3, 4, 5, 6]:
485 number = float(dataframe[
'value'][dataframe[
'layer'] == layer_id][dataframe[
'ladder'] == ladder_id]
486 [dataframe[
'sensor'] == sensor_id][dataframe[
'parameter'] == j])
488 line[j] = quantity[j] + str(round(number, 5)) + unit[j]
491 print(
'Non calculated ladder!!')
494 if not excludedLadder[i]:
496 ladderCoordinates[i][0] + 0.000,
497 ladderCoordinates[i][1] + 0.011,
504 boxstyle=
'round,pad=0.15'))
507 ladderCoordinates[i][0] + 0.200,
508 ladderCoordinates[i][1] + 0.011,
515 boxstyle=
'round,pad=0.15'))
517 ladderCoordinates[i][0] + 0.400,
518 ladderCoordinates[i][1] + 0.011,
525 boxstyle=
'round,pad=0.15'))
527 ladderCoordinates[i][0] + 0.000,
528 ladderCoordinates[i][1] - 0.011,
535 boxstyle=
'round,pad=0.15'))
537 ladderCoordinates[i][0] + 0.200,
538 ladderCoordinates[i][1] - 0.011,
545 boxstyle=
'round,pad=0.15'))
547 ladderCoordinates[i][0] + 0.400,
548 ladderCoordinates[i][1] - 0.011,
555 boxstyle=
'round,pad=0.15'))
556 line = [
'NAN',
r'$u$ = NAN',
r'$v$ = NAN',
r'$w$ = NAN',
r'$\alpha$ = NAN',
r'$\beta$ = NAN',
r'$\gamma$ = NAN']
558ax.text(0.10, 0.25,
' PXD half shell', color=
'black', size=
'12', weight=
'bold')
559ax.text(0.70, 0.25,
' SVD half shell', color=
'black', size=
'12', weight=
'bold')
563 layer_id, ladder_id, sensor_id = beast2_halfshells[i]
564 print(
'Sensor: ', layer_id,
'.', ladder_id,
'.', sensor_id)
565 for j
in [1, 2, 3, 4, 5, 6]:
566 number = float(dataframe[
'value'][dataframe[
'layer'] == layer_id][dataframe[
'ladder'] == ladder_id]
567 [dataframe[
'sensor'] == sensor_id][dataframe[
'parameter'] == j])
569 excludedHalfShell[i] =
False
570 line[j] = quantity[j] + str(round(number, 5)) + unit[j]
573 print(
'Non calculated ladder!!')
576 if excludedHalfShell[i]:
577 ax.add_patch(patches.Arc(xy=[0.45, 0.15], width=0.10, height=0.07, angle=.0,
578 theta1=-90.0, theta2=90.0, color=
'red', alpha=0.1, linewidth=35.0))
579 ax.add_patch(patches.Arc(xy=[0.45, 0.15], width=0.28, height=0.20, angle=.0,
580 theta1=-90.0, theta2=90.0, color=
'red', alpha=0.1, linewidth=40.0))
582 ax.add_patch(patches.Arc(xy=[0.45, 0.15], width=0.10, height=0.07, angle=.0,
583 theta1=-90.0, theta2=90.0, color=
'green', alpha=0.1, linewidth=35.0))
584 ax.add_patch(patches.Arc(xy=[0.45, 0.15], width=0.28, height=0.20, angle=.0,
585 theta1=-90.0, theta2=90.0, color=
'green', alpha=0.1, linewidth=40.0))
587 ax.text(0.12 + 0.6 * i, 0.22,
594 boxstyle=
'round,pad=0.15'))
596 ax.text(0.12 + 0.6 * i, 0.19,
603 boxstyle=
'round,pad=0.15'))
604 ax.text(0.12 + 0.6 * i, 0.16,
611 boxstyle=
'round,pad=0.15'))
612 ax.text(0.12 + 0.6 * i, 0.13,
619 boxstyle=
'round,pad=0.15'))
620 ax.text(0.12 + 0.6 * i, 0.10,
627 boxstyle=
'round,pad=0.15'))
628 ax.text(0.12 + 0.6 * i, 0.07,
635 boxstyle=
'round,pad=0.15'))
636 line = [
'NAN',
r'$u$ = NAN',
r'$v$ = NAN',
r'$w$ = NAN',
r'$\alpha$ = NAN',
r'$\beta$ = NAN',
r'$\gamma$ = NAN']
639fig.savefig(
'outputLadders.png', dpi=300)
Class to uniquely identify a any structure of the PXD and SVD.