CMS 3D CMS Logo

Functions | Variables
TkAlMapDesign_phase1_cfg Namespace Reference

Functions

def read_TPLfile (file_name)
 
def test_draw (w, h)
 

Variables

int M_T = .2
 
int M_X = 1.
 
float M_Y = 2.5
 
int PIX_D_W = 10.
 
int PIX_L_H = 10.
 
int PIX_L_W = 20.
 
int STR_D_W = 10.
 
int STR_L_H = 12.
 
int STR_L_W = 24.
 
float STR_TID_D_W = 5.5
 
dictionary TkMap_GEO
 

Function Documentation

◆ read_TPLfile()

def TkAlMapDesign_phase1_cfg.read_TPLfile (   file_name)

Definition at line 419 of file TkAlMapDesign_phase1_cfg.py.

References dqmMemoryStats.float, createfilelist.int, and submitPVValidationJobs.split().

Referenced by test_draw().

419 def read_TPLfile(file_name):
420  o_file = open(file_name, 'r')
421  lines = o_file.readlines()
422  o_file.close()
423 
424  TPL_dict = {}
425  for line in lines:
426  if '#' in line: continue
427  splt_line = line.replace('\n', '').split(' ')
428  det_id = int(splt_line[0])
429  x = []
430  y = []
431  for idx,coo in enumerate(splt_line[1:]):
432  #print(coo)
433  try:
434  val = float(coo)
435  if (idx%2) == 0:
436  y.append(val)
437  else:
438  x.append(val)
439  except ValueError:
440  continue
441  TPL_dict[det_id] = {}
442  TPL_dict[det_id]['x'] = x
443  TPL_dict[det_id]['y'] = y
444  return TPL_dict
445 
446 
447 

◆ test_draw()

def TkAlMapDesign_phase1_cfg.test_draw (   w,
  h 
)

Definition at line 454 of file TkAlMapDesign_phase1_cfg.py.

References mps_check.array, SiStripPI.max, SiStripPI.min, FastTimerService_cff.range, and read_TPLfile().

454  def test_draw(w, h):
455  canvas = ROOT.TCanvas('canvas', 'detector canvas', w, h)
456 
457  # Load all modules in absolute positions
458  # Find max x and y to rescale later for window
459  all_modules = {}
460  all_text = {}
461  x_max = -9999.
462  y_max = -9999.
463  x_min = 9999.
464  y_min = 9999.
465  for det in TkMap_GEO:
466  for sub in TkMap_GEO[det]:
467  for part in TkMap_GEO[det][sub]:
468  if part == 'latex':
469  all_text[det+'_'+sub] = TkMap_GEO[det][sub][part]
470  continue
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:
475  x_canv = []
476  y_canv = []
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)
487 
488  r_margin = 1
489  l_margin = 1
490  t_margin = 1
491  b_margin = 1
492 
493  x_max += r_margin
494  x_min -= l_margin
495  y_max += t_margin
496  y_min -= b_margin
497 
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.):
501  x_scale = x_range
502  y_scale = (h + 0.)/(w + 0.)*x_range
503  else:
504  y_scale = y_range
505  x_scale = (w + 0.)/(h + 0.)*y_range
506  TPL = {}
507  for module in all_modules:
508  x = array('d', [])
509  y = array('d', [])
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.))
513  # Begin point is end point
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.))
516  #print(x, y)
517  TPL[module] = ROOT.TPolyLine(len(x), x, y)
518  #TPL[module].SetFillColor(1)
519  TPL[module].SetLineColor(1)
520  TPL[module].Draw('f')
521  TPL[module].Draw()
522  TL = ROOT.TLatex()
523  TL.SetTextSize(0.025)
524  for key in all_text:
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'])
529  #TL.SetTextSize(0.025)
530  #TL.SetTextAlign(11)
531  #TL.DrawLatex(0.1, 0.1, 'bottom')
532  #TL.SetTextAlign(13)
533  #TL.DrawLatex(0.1, 0.1, 'top')
534  canvas.Update()
535  raw_input('exit')
536 

Variable Documentation

◆ M_T

int TkAlMapDesign_phase1_cfg.M_T = .2

Definition at line 4 of file TkAlMapDesign_phase1_cfg.py.

◆ M_X

int TkAlMapDesign_phase1_cfg.M_X = 1.

Definition at line 2 of file TkAlMapDesign_phase1_cfg.py.

◆ M_Y

float TkAlMapDesign_phase1_cfg.M_Y = 2.5

Definition at line 3 of file TkAlMapDesign_phase1_cfg.py.

◆ PIX_D_W

int TkAlMapDesign_phase1_cfg.PIX_D_W = 10.

Definition at line 6 of file TkAlMapDesign_phase1_cfg.py.

◆ PIX_L_H

int TkAlMapDesign_phase1_cfg.PIX_L_H = 10.

Definition at line 8 of file TkAlMapDesign_phase1_cfg.py.

◆ PIX_L_W

int TkAlMapDesign_phase1_cfg.PIX_L_W = 20.

Definition at line 7 of file TkAlMapDesign_phase1_cfg.py.

◆ STR_D_W

int TkAlMapDesign_phase1_cfg.STR_D_W = 10.

Definition at line 10 of file TkAlMapDesign_phase1_cfg.py.

◆ STR_L_H

int TkAlMapDesign_phase1_cfg.STR_L_H = 12.

Definition at line 13 of file TkAlMapDesign_phase1_cfg.py.

◆ STR_L_W

int TkAlMapDesign_phase1_cfg.STR_L_W = 24.

Definition at line 12 of file TkAlMapDesign_phase1_cfg.py.

◆ STR_TID_D_W

float TkAlMapDesign_phase1_cfg.STR_TID_D_W = 5.5

Definition at line 11 of file TkAlMapDesign_phase1_cfg.py.

◆ TkMap_GEO

dictionary TkAlMapDesign_phase1_cfg.TkMap_GEO

Definition at line 15 of file TkAlMapDesign_phase1_cfg.py.