21 'file':
'Relative_TPolyLine_Pixel_BPIX_L1.txt',
22 'x_off': -PIX_L_W - M_X - M_X,
23 'y_off': -PIX_L_H - M_Y - PIX_L_H/2. + M_Y/2.,
28 'file':
'Relative_TPolyLine_Pixel_BPIX_L2.txt',
29 'x_off': -PIX_L_W - M_X - M_X,
30 'y_off': -PIX_L_H/2. + M_Y/2.,
35 'file':
'Relative_TPolyLine_Pixel_BPIX_L3.txt',
36 'x_off': -PIX_L_W - M_X - M_X,
37 'y_off': PIX_L_H/2. + M_Y + M_Y/2.,
44 'file':
'Relative_TPolyLine_Pixel_FPIX_-1.txt',
45 'x_off': -PIX_L_W - M_X - M_X,
47 'y_off': -PIX_L_H - M_Y - PIX_L_H/2. + M_Y/2. - M_Y - PIX_D_W,
53 'file':
'Relative_TPolyLine_Pixel_FPIX_-2.txt',
54 'x_off': -PIX_D_W - M_X - M_X,
56 'y_off': -PIX_L_H - M_Y - PIX_L_H/2. + M_Y/2. - M_Y - PIX_D_W,
64 'file':
'Relative_TPolyLine_Pixel_FPIX_+1.txt',
65 'x_off': -PIX_L_W - M_X - M_X,
67 'y_off': PIX_L_H/2. + M_Y + M_Y/2. + PIX_L_H + M_Y,
73 'file':
'Relative_TPolyLine_Pixel_FPIX_+2.txt',
74 'x_off': -PIX_D_W - M_X - M_X,
76 'y_off': PIX_L_H/2. + M_Y + M_Y/2. + PIX_L_H + M_Y,
86 'file':
'Relative_TPolyLine_Strips_TIB_L1.txt',
93 'file':
'Relative_TPolyLine_Strips_TIB_L2.txt',
94 'x_off': 2*M_X + STR_L_W,
100 'file':
'Relative_TPolyLine_Strips_TIB_L3.txt',
107 'file':
'Relative_TPolyLine_Strips_TIB_L4.txt',
108 'x_off': 2*M_X + STR_L_W,
116 'file':
'Relative_TPolyLine_Strips_TOB_L1.txt',
117 'x_off': 3*M_X + 2*STR_L_W,
118 'y_off': -STR_L_H - M_Y - STR_L_H/2. + M_Y/2.,
123 'file':
'Relative_TPolyLine_Strips_TOB_L2.txt',
124 'x_off': 4*M_X + 3*STR_L_W,
125 'y_off': -STR_L_H - M_Y - STR_L_H/2. + M_Y/2.,
130 'file':
'Relative_TPolyLine_Strips_TOB_L3.txt',
131 'x_off': 3*M_X + 2*STR_L_W,
132 'y_off': - STR_L_H/2. + M_Y/2.,
137 'file':
'Relative_TPolyLine_Strips_TOB_L4.txt',
138 'x_off': 4*M_X + 3*STR_L_W,
139 'y_off': - STR_L_H/2. + M_Y/2.,
144 'file':
'Relative_TPolyLine_Strips_TOB_L5.txt',
145 'x_off': 3*M_X + 2*STR_L_W,
146 'y_off': STR_L_H/2. + M_Y + M_Y/2.,
151 'file':
'Relative_TPolyLine_Strips_TOB_L6.txt',
152 'x_off': 4*M_X + 3*STR_L_W,
153 'y_off': STR_L_H/2. + M_Y + M_Y/2.,
160 'file':
'Relative_TPolyLine_Strips_TID_-1.txt',
161 'x_off': M_X + (STR_L_W + M_X)/2.,
162 'y_off': - STR_L_H - M_Y - STR_TID_D_W,
163 'x_scale': STR_TID_D_W,
164 'y_scale': STR_TID_D_W,
167 'file':
'Relative_TPolyLine_Strips_TID_-2.txt',
168 'x_off': M_X + STR_L_W/2. - STR_TID_D_W/2. + (STR_L_W + M_X)/2.,
169 'y_off': - STR_L_H - M_Y - STR_TID_D_W,
170 'x_scale': STR_TID_D_W,
171 'y_scale': STR_TID_D_W,
174 'file':
'Relative_TPolyLine_Strips_TID_-3.txt',
175 'x_off': M_X + STR_L_W - STR_TID_D_W + (STR_L_W + M_X)/2.,
176 'y_off': - STR_L_H - M_Y - STR_TID_D_W,
177 'x_scale': STR_TID_D_W,
178 'y_scale': STR_TID_D_W,
183 'file':
'Relative_TPolyLine_Strips_TID_+1.txt',
184 'x_off': M_X + (STR_L_W + M_X)/2.,
185 'y_off': STR_L_H +2*M_Y,
186 'x_scale': STR_TID_D_W,
187 'y_scale': STR_TID_D_W,
190 'file':
'Relative_TPolyLine_Strips_TID_+2.txt',
191 'x_off': M_X + STR_L_W/2. - STR_TID_D_W/2. + (STR_L_W + M_X)/2.,
192 'y_off': STR_L_H +2*M_Y,
193 'x_scale': STR_TID_D_W,
194 'y_scale': STR_TID_D_W,
197 'file':
'Relative_TPolyLine_Strips_TID_+3.txt',
198 'x_off': M_X + STR_L_W - STR_TID_D_W + (STR_L_W + M_X)/2.,
199 'y_off': STR_L_H +2*M_Y,
200 'x_scale': STR_TID_D_W,
201 'y_scale': STR_TID_D_W,
206 'file':
'Relative_TPolyLine_Strips_TEC_-1.txt',
208 'y_off': -STR_L_H - M_Y - STR_L_H/2. + M_Y/2. - M_Y - STR_D_W,
213 'file':
'Relative_TPolyLine_Strips_TEC_-2.txt',
214 'x_off': M_X +((4*STR_L_W + 3*M_X - 9*STR_D_W)/8. + STR_D_W),
215 'y_off': -STR_L_H - M_Y - STR_L_H/2. + M_Y/2. - M_Y - STR_D_W,
220 'file':
'Relative_TPolyLine_Strips_TEC_-3.txt',
221 'x_off': M_X + 2*((4*STR_L_W + 3*M_X - 9*STR_D_W)/8. + STR_D_W),
222 'y_off': -STR_L_H - M_Y - STR_L_H/2. + M_Y/2. - M_Y - STR_D_W,
227 'file':
'Relative_TPolyLine_Strips_TEC_-4.txt',
228 'x_off': M_X + 3*((4*STR_L_W + 3*M_X - 9*STR_D_W)/8. + STR_D_W),
229 'y_off': -STR_L_H - M_Y - STR_L_H/2. + M_Y/2. - M_Y - STR_D_W,
234 'file':
'Relative_TPolyLine_Strips_TEC_-5.txt',
235 'x_off': M_X + 4*((4*STR_L_W + 3*M_X - 9*STR_D_W)/8. + STR_D_W),
236 'y_off': -STR_L_H - M_Y - STR_L_H/2. + M_Y/2. - M_Y - STR_D_W,
241 'file':
'Relative_TPolyLine_Strips_TEC_-6.txt',
242 'x_off': M_X + 5*((4*STR_L_W + 3*M_X - 9*STR_D_W)/8. + STR_D_W),
243 'y_off': -STR_L_H - M_Y - STR_L_H/2. + M_Y/2. - M_Y - STR_D_W,
248 'file':
'Relative_TPolyLine_Strips_TEC_-7.txt',
249 'x_off': M_X + 6*((4*STR_L_W + 3*M_X - 9*STR_D_W)/8. + STR_D_W),
250 'y_off': -STR_L_H - M_Y - STR_L_H/2. + M_Y/2. - M_Y - STR_D_W,
255 'file':
'Relative_TPolyLine_Strips_TEC_-8.txt',
256 'x_off': M_X + 7*((4*STR_L_W + 3*M_X - 9*STR_D_W)/8. + STR_D_W),
257 'y_off': -STR_L_H - M_Y - STR_L_H/2. + M_Y/2. - M_Y - STR_D_W,
262 'file':
'Relative_TPolyLine_Strips_TEC_-9.txt',
263 'x_off': M_X + 8*((4*STR_L_W + 3*M_X - 9*STR_D_W)/8. + STR_D_W),
264 'y_off': -STR_L_H - M_Y - STR_L_H/2. + M_Y/2. - M_Y - STR_D_W,
271 'file':
'Relative_TPolyLine_Strips_TEC_+1.txt',
273 'y_off': STR_L_H + STR_L_H/2. + M_Y/2. + 2*M_Y,
278 'file':
'Relative_TPolyLine_Strips_TEC_+2.txt',
279 'x_off': M_X + ((4*STR_L_W + 3*M_X - 9*STR_D_W)/8. + STR_D_W),
280 'y_off': STR_L_H + STR_L_H/2. + M_Y/2. + 2*M_Y,
285 'file':
'Relative_TPolyLine_Strips_TEC_+3.txt',
286 'x_off': M_X + 2*((4*STR_L_W + 3*M_X - 9*STR_D_W)/8. + STR_D_W),
287 'y_off': STR_L_H + STR_L_H/2. + M_Y/2. + 2*M_Y,
292 'file':
'Relative_TPolyLine_Strips_TEC_+4.txt',
293 'x_off': M_X + 3*((4*STR_L_W + 3*M_X - 9*STR_D_W)/8. + STR_D_W),
294 'y_off': STR_L_H + STR_L_H/2. + M_Y/2. + 2*M_Y,
299 'file':
'Relative_TPolyLine_Strips_TEC_+5.txt',
300 'x_off': M_X + 4*((4*STR_L_W + 3*M_X - 9*STR_D_W)/8. + STR_D_W),
301 'y_off': STR_L_H + STR_L_H/2. + M_Y/2. + 2*M_Y,
306 'file':
'Relative_TPolyLine_Strips_TEC_+6.txt',
307 'x_off': M_X + 5*((4*STR_L_W + 3*M_X - 9*STR_D_W)/8. + STR_D_W),
308 'y_off': STR_L_H + STR_L_H/2. + M_Y/2. + 2*M_Y,
313 'file':
'Relative_TPolyLine_Strips_TEC_+7.txt',
314 'x_off': M_X + 6*((4*STR_L_W + 3*M_X - 9*STR_D_W)/8. + STR_D_W),
315 'y_off': STR_L_H + STR_L_H/2. + M_Y/2. + 2*M_Y,
320 'file':
'Relative_TPolyLine_Strips_TEC_+8.txt',
321 'x_off': M_X + 7*((4*STR_L_W + 3*M_X - 9*STR_D_W)/8. + STR_D_W),
322 'y_off': STR_L_H + STR_L_H/2. + M_Y/2. + 2*M_Y,
327 'file':
'Relative_TPolyLine_Strips_TEC_+9.txt',
328 'x_off': M_X + 8*((4*STR_L_W + 3*M_X - 9*STR_D_W)/8. + STR_D_W),
329 'y_off': STR_L_H + STR_L_H/2. + M_Y/2. + 2*M_Y,
338 for layer
in TkMap_GEO[
'pixel'][
'BPIX']:
339 TkMap_GEO[
'pixel'][
'BPIX'][layer][
'latex'] = {
340 'text':
'BPIX '+layer,
341 'x': TkMap_GEO[
'pixel'][
'BPIX'][layer][
'x_off'],
342 'y': TkMap_GEO[
'pixel'][
'BPIX'][layer][
'y_off'] + PIX_L_H + M_T,
347 TkMap_GEO[
'pixel'][
'FPIX'+z][
'latex'] = {
349 'x': TkMap_GEO[
'pixel'][
'FPIX'+z][z+
'1'][
'x_off'],
350 'y': TkMap_GEO[
'pixel'][
'FPIX'+z][z+
'1'][
'y_off'] + PIX_D_W + M_T,
353 for disc
in TkMap_GEO[
'pixel'][
'FPIX'+z]:
354 if disc ==
'latex':
continue 355 TkMap_GEO[
'pixel'][
'FPIX'+z][disc][
'latex'] = {
357 'x': TkMap_GEO[
'pixel'][
'FPIX'+z][disc][
'x_off'] + PIX_D_W,
358 'y': TkMap_GEO[
'pixel'][
'FPIX'+z][disc][
'y_off'] + PIX_D_W,
362 for det
in [
'TIB',
'TOB']:
363 for layer
in TkMap_GEO[
'strips'][det]:
364 TkMap_GEO[
'strips'][det][layer][
'latex'] = {
365 'text': det+
' '+layer,
366 'x': TkMap_GEO[
'strips'][det][layer][
'x_off'],
367 'y': TkMap_GEO[
'strips'][det][layer][
'y_off'] + STR_L_H + M_T,
372 TkMap_GEO[
'strips'][
'TEC'+z][
'latex'] = {
374 'x': TkMap_GEO[
'strips'][
'TEC'+z][z+
'1'][
'x_off'],
375 'y': TkMap_GEO[
'strips'][
'TEC'+z][z+
'1'][
'y_off'] + STR_D_W + M_T,
378 for disc
in TkMap_GEO[
'strips'][
'TEC'+z]:
379 if disc ==
'latex':
continue 380 TkMap_GEO[
'strips'][
'TEC'+z][disc][
'latex'] = {
382 'x': TkMap_GEO[
'strips'][
'TEC'+z][disc][
'x_off'] + STR_D_W,
383 'y': TkMap_GEO[
'strips'][
'TEC'+z][disc][
'y_off'] + STR_D_W,
390 TkMap_GEO[
'strips'][
'TID'+z][
'latex'] = {
393 'x': TkMap_GEO[
'strips'][
'TID'+z][z+
'1'][
'x_off'] - 2*M_T,
395 'y': TkMap_GEO[
'strips'][
'TID'+z][z+
'1'][
'y_off'] + STR_TID_D_W/2.,
399 for disc
in TkMap_GEO[
'strips'][
'TID'+z]:
400 if disc ==
'latex':
continue 401 TkMap_GEO[
'strips'][
'TID'+z][disc][
'latex'] = {
403 'x': TkMap_GEO[
'strips'][
'TID'+z][disc][
'x_off'] + STR_TID_D_W,
404 'y': TkMap_GEO[
'strips'][
'TID'+z][disc][
'y_off'] + STR_TID_D_W,
409 o_file = open(file_name,
'r') 410 lines = o_file.readlines() 415 if '#' in line:
continue 416 splt_line = line.replace(
'\n',
'').
split(
' ')
417 det_id =
int(splt_line[0])
420 for idx,coo
in enumerate(splt_line[1:]):
430 TPL_dict[det_id] = {}
431 TPL_dict[det_id][
'x'] = x
432 TPL_dict[det_id][
'y'] = y
437 if __name__ ==
'__main__':
439 from array
import array
444 canvas = ROOT.TCanvas(
'canvas',
'detector canvas', w, h)
454 for det
in TkMap_GEO:
455 for sub
in TkMap_GEO[det]:
456 for part
in TkMap_GEO[det][sub]:
458 all_text[det+
'_'+sub] = TkMap_GEO[det][sub][part]
460 if 'latex' in TkMap_GEO[det][sub][part]:
461 all_text[det+
'_'+sub+
'_'+part] = TkMap_GEO[det][sub][part][
'latex']
462 TPL_dict =
read_TPLfile(TkMap_GEO[det][sub][part][
'file'])
463 for module
in TPL_dict:
466 for idx
in range(len(TPL_dict[module][
'x'])):
467 x_canv.append(TPL_dict[module][
'x'][idx]*TkMap_GEO[det][sub][part][
'x_scale'] + TkMap_GEO[det][sub][part][
'x_off'])
468 y_canv.append(TPL_dict[module][
'y'][idx]*TkMap_GEO[det][sub][part][
'y_scale'] + TkMap_GEO[det][sub][part][
'y_off'])
469 if max(x_canv) > x_max: x_max =
max(x_canv)
470 if max(y_canv) > y_max: y_max =
max(y_canv)
471 if min(x_canv) < x_min: x_min =
min(x_canv)
472 if min(y_canv) < y_min: y_min =
min(y_canv)
473 TPL_dict[module][
'x'] = x_canv
474 TPL_dict[module][
'y'] = y_canv
475 all_modules.update(TPL_dict)
487 x_range = x_max - x_min
488 y_range = y_max - y_min
489 if (x_range + 0.)/(w + 0.) > (y_range + 0.)/(h + 0.):
491 y_scale = (h + 0.)/(w + 0.)*x_range
494 x_scale = (w + 0.)/(h + 0.)*y_range
496 for module
in all_modules:
499 for idx
in range(len(all_modules[module][
'x'])):
500 x.append((all_modules[module][
'x'][idx] - x_min + 0.)/(x_scale + 0.))
501 y.append((all_modules[module][
'y'][idx] - y_min + 0.)/(y_scale + 0.))
503 x.append((all_modules[module][
'x'][0] - x_min + 0.)/(x_scale + 0.))
504 y.append((all_modules[module][
'y'][0] - y_min + 0.)/(y_scale + 0.))
506 TPL[module] = ROOT.TPolyLine(len(x), x, y)
508 TPL[module].SetLineColor(1)
509 TPL[module].Draw(
'f')
512 TL.SetTextSize(0.025)
514 x = (all_text[key][
'x'] - x_min + 0.)/(x_scale + 0.)
515 y = (all_text[key][
'y'] - y_min + 0.)/(y_scale + 0.)
516 TL.SetTextAlign(all_text[key][
'alignment'])
517 TL.DrawLatex(x, y, all_text[key][
'text'])
def read_TPLfile(file_name)