19 'file':
'Relative_TPolyLine_Pixel_phase1_BPIX_L1.txt',
20 'x_off': -2*PIX_L_W - 2*M_X,
26 'file':
'Relative_TPolyLine_Pixel_phase1_BPIX_L2.txt',
27 'x_off': -PIX_L_W - M_X,
33 'file':
'Relative_TPolyLine_Pixel_phase1_BPIX_L3.txt',
34 'x_off': -2*PIX_L_W - 2*M_X,
40 'file':
'Relative_TPolyLine_Pixel_phase1_BPIX_L4.txt',
41 'x_off': -PIX_L_W - M_X,
49 'file':
'Relative_TPolyLine_Pixel_phase1_FPIX_-1.txt',
50 'x_off': -2*PIX_L_W - 2*M_X,
51 'y_off': -PIX_L_H - M_Y - PIX_D_W,
56 'file':
'Relative_TPolyLine_Pixel_phase1_FPIX_-2.txt',
57 'x_off': -PIX_L_W - M_X - PIX_L_W/4. - M_X/2.,
58 'y_off': -PIX_L_H - M_Y - PIX_D_W,
63 'file':
'Relative_TPolyLine_Pixel_phase1_FPIX_-3.txt',
64 'x_off': -PIX_D_W - M_X,
65 'y_off': -PIX_L_H - M_Y - PIX_D_W,
72 'file':
'Relative_TPolyLine_Pixel_phase1_FPIX_+1.txt',
73 'x_off': -2*PIX_L_W - 2*M_X,
74 'y_off': PIX_L_H + 2*M_Y,
79 'file':
'Relative_TPolyLine_Pixel_phase1_FPIX_+2.txt',
80 'x_off': -PIX_L_W - M_X - PIX_L_W/4. - M_X/2.,
81 'y_off': PIX_L_H + 2*M_Y,
86 'file':
'Relative_TPolyLine_Pixel_phase1_FPIX_+3.txt',
87 'x_off': -PIX_D_W- M_X,
88 'y_off': PIX_L_H + 2*M_Y,
97 'file':
'Relative_TPolyLine_Strips_TIB_L1.txt',
104 'file':
'Relative_TPolyLine_Strips_TIB_L2.txt',
105 'x_off': 2*M_X + STR_L_W,
111 'file':
'Relative_TPolyLine_Strips_TIB_L3.txt',
118 'file':
'Relative_TPolyLine_Strips_TIB_L4.txt',
119 'x_off': 2*M_X + STR_L_W,
127 'file':
'Relative_TPolyLine_Strips_TOB_L1.txt',
128 'x_off': 3*M_X + 2*STR_L_W,
129 'y_off': -STR_L_H - M_Y - STR_L_H/2. + M_Y/2.,
134 'file':
'Relative_TPolyLine_Strips_TOB_L2.txt',
135 'x_off': 4*M_X + 3*STR_L_W,
136 'y_off': -STR_L_H - M_Y - STR_L_H/2. + M_Y/2.,
141 'file':
'Relative_TPolyLine_Strips_TOB_L3.txt',
142 'x_off': 3*M_X + 2*STR_L_W,
143 'y_off': - STR_L_H/2. + M_Y/2.,
148 'file':
'Relative_TPolyLine_Strips_TOB_L4.txt',
149 'x_off': 4*M_X + 3*STR_L_W,
150 'y_off': - STR_L_H/2. + M_Y/2.,
155 'file':
'Relative_TPolyLine_Strips_TOB_L5.txt',
156 'x_off': 3*M_X + 2*STR_L_W,
157 'y_off': STR_L_H/2. + M_Y + M_Y/2.,
162 'file':
'Relative_TPolyLine_Strips_TOB_L6.txt',
163 'x_off': 4*M_X + 3*STR_L_W,
164 'y_off': STR_L_H/2. + M_Y + M_Y/2.,
171 'file':
'Relative_TPolyLine_Strips_TID_-1.txt',
172 'x_off': M_X + (STR_L_W + M_X)/2.,
173 'y_off': - STR_L_H - M_Y - STR_TID_D_W,
174 'x_scale': STR_TID_D_W,
175 'y_scale': STR_TID_D_W,
178 'file':
'Relative_TPolyLine_Strips_TID_-2.txt',
179 'x_off': M_X + STR_L_W/2. - STR_TID_D_W/2. + (STR_L_W + M_X)/2.,
180 'y_off': - STR_L_H - M_Y - STR_TID_D_W,
181 'x_scale': STR_TID_D_W,
182 'y_scale': STR_TID_D_W,
185 'file':
'Relative_TPolyLine_Strips_TID_-3.txt',
186 'x_off': M_X + STR_L_W - STR_TID_D_W + (STR_L_W + M_X)/2.,
187 'y_off': - STR_L_H - M_Y - STR_TID_D_W,
188 'x_scale': STR_TID_D_W,
189 'y_scale': STR_TID_D_W,
194 'file':
'Relative_TPolyLine_Strips_TID_+1.txt',
195 'x_off': M_X + (STR_L_W + M_X)/2.,
196 'y_off': STR_L_H +2*M_Y,
197 'x_scale': STR_TID_D_W,
198 'y_scale': STR_TID_D_W,
201 'file':
'Relative_TPolyLine_Strips_TID_+2.txt',
202 'x_off': M_X + STR_L_W/2. - STR_TID_D_W/2. + (STR_L_W + M_X)/2.,
203 'y_off': STR_L_H +2*M_Y,
204 'x_scale': STR_TID_D_W,
205 'y_scale': STR_TID_D_W,
208 'file':
'Relative_TPolyLine_Strips_TID_+3.txt',
209 'x_off': M_X + STR_L_W - STR_TID_D_W + (STR_L_W + M_X)/2.,
210 'y_off': STR_L_H +2*M_Y,
211 'x_scale': STR_TID_D_W,
212 'y_scale': STR_TID_D_W,
217 'file':
'Relative_TPolyLine_Strips_TEC_-1.txt',
219 'y_off': -STR_L_H - M_Y - STR_L_H/2. + M_Y/2. - M_Y - STR_D_W,
224 'file':
'Relative_TPolyLine_Strips_TEC_-2.txt',
225 'x_off': M_X +((4*STR_L_W + 3*M_X - 9*STR_D_W)/8. + STR_D_W),
226 'y_off': -STR_L_H - M_Y - STR_L_H/2. + M_Y/2. - M_Y - STR_D_W,
231 'file':
'Relative_TPolyLine_Strips_TEC_-3.txt',
232 'x_off': M_X + 2*((4*STR_L_W + 3*M_X - 9*STR_D_W)/8. + STR_D_W),
233 'y_off': -STR_L_H - M_Y - STR_L_H/2. + M_Y/2. - M_Y - STR_D_W,
238 'file':
'Relative_TPolyLine_Strips_TEC_-4.txt',
239 'x_off': M_X + 3*((4*STR_L_W + 3*M_X - 9*STR_D_W)/8. + STR_D_W),
240 'y_off': -STR_L_H - M_Y - STR_L_H/2. + M_Y/2. - M_Y - STR_D_W,
245 'file':
'Relative_TPolyLine_Strips_TEC_-5.txt',
246 'x_off': M_X + 4*((4*STR_L_W + 3*M_X - 9*STR_D_W)/8. + STR_D_W),
247 'y_off': -STR_L_H - M_Y - STR_L_H/2. + M_Y/2. - M_Y - STR_D_W,
252 'file':
'Relative_TPolyLine_Strips_TEC_-6.txt',
253 'x_off': M_X + 5*((4*STR_L_W + 3*M_X - 9*STR_D_W)/8. + STR_D_W),
254 'y_off': -STR_L_H - M_Y - STR_L_H/2. + M_Y/2. - M_Y - STR_D_W,
259 'file':
'Relative_TPolyLine_Strips_TEC_-7.txt',
260 'x_off': M_X + 6*((4*STR_L_W + 3*M_X - 9*STR_D_W)/8. + STR_D_W),
261 'y_off': -STR_L_H - M_Y - STR_L_H/2. + M_Y/2. - M_Y - STR_D_W,
266 'file':
'Relative_TPolyLine_Strips_TEC_-8.txt',
267 'x_off': M_X + 7*((4*STR_L_W + 3*M_X - 9*STR_D_W)/8. + STR_D_W),
268 'y_off': -STR_L_H - M_Y - STR_L_H/2. + M_Y/2. - M_Y - STR_D_W,
273 'file':
'Relative_TPolyLine_Strips_TEC_-9.txt',
274 'x_off': M_X + 8*((4*STR_L_W + 3*M_X - 9*STR_D_W)/8. + STR_D_W),
275 'y_off': -STR_L_H - M_Y - STR_L_H/2. + M_Y/2. - M_Y - STR_D_W,
282 'file':
'Relative_TPolyLine_Strips_TEC_+1.txt',
284 'y_off': STR_L_H + STR_L_H/2. + M_Y/2. + 2*M_Y,
289 'file':
'Relative_TPolyLine_Strips_TEC_+2.txt',
290 'x_off': M_X + ((4*STR_L_W + 3*M_X - 9*STR_D_W)/8. + STR_D_W),
291 'y_off': STR_L_H + STR_L_H/2. + M_Y/2. + 2*M_Y,
296 'file':
'Relative_TPolyLine_Strips_TEC_+3.txt',
297 'x_off': M_X + 2*((4*STR_L_W + 3*M_X - 9*STR_D_W)/8. + STR_D_W),
298 'y_off': STR_L_H + STR_L_H/2. + M_Y/2. + 2*M_Y,
303 'file':
'Relative_TPolyLine_Strips_TEC_+4.txt',
304 'x_off': M_X + 3*((4*STR_L_W + 3*M_X - 9*STR_D_W)/8. + STR_D_W),
305 'y_off': STR_L_H + STR_L_H/2. + M_Y/2. + 2*M_Y,
310 'file':
'Relative_TPolyLine_Strips_TEC_+5.txt',
311 'x_off': M_X + 4*((4*STR_L_W + 3*M_X - 9*STR_D_W)/8. + STR_D_W),
312 'y_off': STR_L_H + STR_L_H/2. + M_Y/2. + 2*M_Y,
317 'file':
'Relative_TPolyLine_Strips_TEC_+6.txt',
318 'x_off': M_X + 5*((4*STR_L_W + 3*M_X - 9*STR_D_W)/8. + STR_D_W),
319 'y_off': STR_L_H + STR_L_H/2. + M_Y/2. + 2*M_Y,
324 'file':
'Relative_TPolyLine_Strips_TEC_+7.txt',
325 'x_off': M_X + 6*((4*STR_L_W + 3*M_X - 9*STR_D_W)/8. + STR_D_W),
326 'y_off': STR_L_H + STR_L_H/2. + M_Y/2. + 2*M_Y,
331 'file':
'Relative_TPolyLine_Strips_TEC_+8.txt',
332 'x_off': M_X + 7*((4*STR_L_W + 3*M_X - 9*STR_D_W)/8. + STR_D_W),
333 'y_off': STR_L_H + STR_L_H/2. + M_Y/2. + 2*M_Y,
338 'file':
'Relative_TPolyLine_Strips_TEC_+9.txt',
339 'x_off': M_X + 8*((4*STR_L_W + 3*M_X - 9*STR_D_W)/8. + STR_D_W),
340 'y_off': STR_L_H + STR_L_H/2. + M_Y/2. + 2*M_Y,
349 for layer
in TkMap_GEO[
'pixel'][
'BPIX']:
350 TkMap_GEO[
'pixel'][
'BPIX'][layer][
'latex'] = {
351 'text':
'BPIX '+layer,
352 'x': TkMap_GEO[
'pixel'][
'BPIX'][layer][
'x_off'],
353 'y': TkMap_GEO[
'pixel'][
'BPIX'][layer][
'y_off'] + PIX_L_H + M_T,
358 TkMap_GEO[
'pixel'][
'FPIX'+z][
'latex'] = {
360 'x': TkMap_GEO[
'pixel'][
'FPIX'+z][z+
'1'][
'x_off'],
361 'y': TkMap_GEO[
'pixel'][
'FPIX'+z][z+
'1'][
'y_off'] + PIX_D_W + M_T,
364 for disc
in TkMap_GEO[
'pixel'][
'FPIX'+z]:
365 if disc ==
'latex':
continue 366 TkMap_GEO[
'pixel'][
'FPIX'+z][disc][
'latex'] = {
368 'x': TkMap_GEO[
'pixel'][
'FPIX'+z][disc][
'x_off'] + PIX_D_W,
369 'y': TkMap_GEO[
'pixel'][
'FPIX'+z][disc][
'y_off'] + PIX_D_W,
373 for det
in [
'TIB',
'TOB']:
374 for layer
in TkMap_GEO[
'strips'][det]:
375 TkMap_GEO[
'strips'][det][layer][
'latex'] = {
376 'text': det+
' '+layer,
377 'x': TkMap_GEO[
'strips'][det][layer][
'x_off'],
378 'y': TkMap_GEO[
'strips'][det][layer][
'y_off'] + STR_L_H + M_T,
383 TkMap_GEO[
'strips'][
'TEC'+z][
'latex'] = {
385 'x': TkMap_GEO[
'strips'][
'TEC'+z][z+
'1'][
'x_off'],
386 'y': TkMap_GEO[
'strips'][
'TEC'+z][z+
'1'][
'y_off'] + STR_D_W + M_T,
389 for disc
in TkMap_GEO[
'strips'][
'TEC'+z]:
390 if disc ==
'latex':
continue 391 TkMap_GEO[
'strips'][
'TEC'+z][disc][
'latex'] = {
393 'x': TkMap_GEO[
'strips'][
'TEC'+z][disc][
'x_off'] + STR_D_W,
394 'y': TkMap_GEO[
'strips'][
'TEC'+z][disc][
'y_off'] + STR_D_W,
401 TkMap_GEO[
'strips'][
'TID'+z][
'latex'] = {
404 'x': TkMap_GEO[
'strips'][
'TID'+z][z+
'1'][
'x_off'] - 2*M_T,
406 'y': TkMap_GEO[
'strips'][
'TID'+z][z+
'1'][
'y_off'] + STR_TID_D_W/2.,
410 for disc
in TkMap_GEO[
'strips'][
'TID'+z]:
411 if disc ==
'latex':
continue 412 TkMap_GEO[
'strips'][
'TID'+z][disc][
'latex'] = {
414 'x': TkMap_GEO[
'strips'][
'TID'+z][disc][
'x_off'] + STR_TID_D_W,
415 'y': TkMap_GEO[
'strips'][
'TID'+z][disc][
'y_off'] + STR_TID_D_W,
420 o_file = open(file_name,
'r') 421 lines = o_file.readlines() 426 if '#' in line:
continue 427 splt_line = line.replace(
'\n',
'').
split(
' ')
428 det_id =
int(splt_line[0])
431 for idx,coo
in enumerate(splt_line[1:]):
441 TPL_dict[det_id] = {}
442 TPL_dict[det_id][
'x'] = x
443 TPL_dict[det_id][
'y'] = y
448 if __name__ ==
'__main__':
450 from array
import array
455 canvas = ROOT.TCanvas(
'canvas',
'detector canvas', w, h)
465 for det
in TkMap_GEO:
466 for sub
in TkMap_GEO[det]:
467 for part
in TkMap_GEO[det][sub]:
469 all_text[det+
'_'+sub] = TkMap_GEO[det][sub][part]
471 if 'latex' in TkMap_GEO[det][sub][part]:
472 all_text[det+
'_'+sub+
'_'+part] = TkMap_GEO[det][sub][part][
'latex']
473 TPL_dict =
read_TPLfile(TkMap_GEO[det][sub][part][
'file'])
474 for module
in TPL_dict:
477 for idx
in range(len(TPL_dict[module][
'x'])):
478 x_canv.append(TPL_dict[module][
'x'][idx]*TkMap_GEO[det][sub][part][
'x_scale'] + TkMap_GEO[det][sub][part][
'x_off'])
479 y_canv.append(TPL_dict[module][
'y'][idx]*TkMap_GEO[det][sub][part][
'y_scale'] + TkMap_GEO[det][sub][part][
'y_off'])
480 if max(x_canv) > x_max: x_max =
max(x_canv)
481 if max(y_canv) > y_max: y_max =
max(y_canv)
482 if min(x_canv) < x_min: x_min =
min(x_canv)
483 if min(y_canv) < y_min: y_min =
min(y_canv)
484 TPL_dict[module][
'x'] = x_canv
485 TPL_dict[module][
'y'] = y_canv
486 all_modules.update(TPL_dict)
498 x_range = x_max - x_min
499 y_range = y_max - y_min
500 if (x_range + 0.)/(w + 0.) > (y_range + 0.)/(h + 0.):
502 y_scale = (h + 0.)/(w + 0.)*x_range
505 x_scale = (w + 0.)/(h + 0.)*y_range
507 for module
in all_modules:
510 for idx
in range(len(all_modules[module][
'x'])):
511 x.append((all_modules[module][
'x'][idx] - x_min + 0.)/(x_scale + 0.))
512 y.append((all_modules[module][
'y'][idx] - y_min + 0.)/(y_scale + 0.))
514 x.append((all_modules[module][
'x'][0] - x_min + 0.)/(x_scale + 0.))
515 y.append((all_modules[module][
'y'][0] - y_min + 0.)/(y_scale + 0.))
517 TPL[module] = ROOT.TPolyLine(len(x), x, y)
519 TPL[module].SetLineColor(1)
520 TPL[module].Draw(
'f')
523 TL.SetTextSize(0.025)
525 x = (all_text[key][
'x'] - x_min + 0.)/(x_scale + 0.)
526 y = (all_text[key][
'y'] - y_min + 0.)/(y_scale + 0.)
527 TL.SetTextAlign(all_text[key][
'alignment'])
528 TL.DrawLatex(x, y, all_text[key][
'text'])
def read_TPLfile(file_name)