Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 10:40:25

0001 
0002 M_X = 1.
0003 M_Y = 2.5
0004 M_T = .2
0005 
0006 PIX_D_W = 10.
0007 #PIX_L_W = 20.
0008 #PIX_L_H = 10.
0009 PIX_L_W = 24.
0010 PIX_L_H = 12.
0011 
0012 STR_D_W = 10.
0013 STR_TID_D_W = 5.5
0014 STR_L_W = 24.
0015 STR_L_H = 12.
0016 
0017 TkMap_GEO = {
0018     'pixel' : {
0019         'BPIX': {
0020             'L1': {
0021                 'file': 'Relative_TPolyLine_Pixel_BPIX_L1.txt',
0022                 'x_off': -PIX_L_W - M_X - M_X,
0023                 'y_off': -PIX_L_H - M_Y - PIX_L_H/2. + M_Y/2.,
0024                 'x_scale': PIX_L_W,
0025                 'y_scale': PIX_L_H,
0026             },
0027             'L2': {
0028                 'file': 'Relative_TPolyLine_Pixel_BPIX_L2.txt',
0029                 'x_off': -PIX_L_W - M_X - M_X,
0030                 'y_off': -PIX_L_H/2. + M_Y/2.,
0031                 'x_scale': PIX_L_W,
0032                 'y_scale': PIX_L_H,
0033             },
0034             'L3': {
0035                 'file': 'Relative_TPolyLine_Pixel_BPIX_L3.txt',
0036                 'x_off': -PIX_L_W - M_X - M_X,
0037                 'y_off': PIX_L_H/2. + M_Y + M_Y/2.,
0038                 'x_scale': PIX_L_W,
0039                 'y_scale': PIX_L_H,
0040             },
0041         },
0042         'FPIX-': {
0043             '-1': {
0044                 'file': 'Relative_TPolyLine_Pixel_FPIX_-1.txt',
0045                 'x_off': -PIX_L_W - M_X - M_X,
0046                 #'x_off': -2*PIX_L_W - 2*M_X,
0047                 'y_off': -PIX_L_H - M_Y - PIX_L_H/2. + M_Y/2. - M_Y - PIX_D_W,
0048                 #'y_off': -PIX_L_H - M_Y - PIX_D_W, 
0049                 'x_scale': PIX_D_W,
0050                 'y_scale': PIX_D_W,
0051             },
0052             '-2': {
0053                 'file': 'Relative_TPolyLine_Pixel_FPIX_-2.txt',
0054                 'x_off': -PIX_D_W - M_X - M_X,
0055                 #'x_off': -PIX_L_W - M_X - PIX_L_W/4. - M_X/2.,
0056                 'y_off': -PIX_L_H - M_Y - PIX_L_H/2. + M_Y/2. - M_Y - PIX_D_W,
0057                 #'y_off': -PIX_L_H - M_Y - PIX_D_W, 
0058                 'x_scale': PIX_D_W,
0059                 'y_scale': PIX_D_W,
0060             },
0061         },
0062         'FPIX+': {
0063             '+1': {
0064                 'file': 'Relative_TPolyLine_Pixel_FPIX_+1.txt',
0065                 'x_off': -PIX_L_W - M_X - M_X,
0066                 #'x_off': -2*PIX_L_W - 2*M_X,
0067                 'y_off': PIX_L_H/2. + M_Y + M_Y/2. + PIX_L_H + M_Y,
0068                 #'y_off': PIX_L_H + 2*M_Y, 
0069                 'x_scale': PIX_D_W,
0070                 'y_scale': PIX_D_W,
0071             },
0072             '+2': {
0073                 'file': 'Relative_TPolyLine_Pixel_FPIX_+2.txt',
0074                 'x_off': -PIX_D_W - M_X - M_X,
0075                 #'x_off': -PIX_L_W - M_X - PIX_L_W/4. - M_X/2.,
0076                 'y_off': PIX_L_H/2. + M_Y + M_Y/2. + PIX_L_H + M_Y,
0077                 #'y_off': PIX_L_H + 2*M_Y, 
0078                 'x_scale': PIX_D_W,
0079                 'y_scale': PIX_D_W,
0080             },
0081         }, 
0082     },
0083     'strips': {
0084         'TIB': {
0085             'L1': {
0086                 'file': 'Relative_TPolyLine_Strips_TIB_L1.txt',
0087                 'x_off': M_X,
0088                 'y_off': -STR_L_H,
0089                 'x_scale': STR_L_W,
0090                 'y_scale': STR_L_H,
0091             },
0092             'L2': {
0093                 'file': 'Relative_TPolyLine_Strips_TIB_L2.txt',
0094                 'x_off': 2*M_X + STR_L_W,
0095                 'y_off': -STR_L_H,
0096                 'x_scale': STR_L_W,
0097                 'y_scale': STR_L_H,
0098             },
0099             'L3': {
0100                 'file': 'Relative_TPolyLine_Strips_TIB_L3.txt',
0101                 'x_off': M_X,
0102                 'y_off': M_Y,
0103                 'x_scale': STR_L_W,
0104                 'y_scale': STR_L_H,
0105             },
0106             'L4': {
0107                 'file': 'Relative_TPolyLine_Strips_TIB_L4.txt',
0108                 'x_off': 2*M_X + STR_L_W,
0109                 'y_off': M_Y,
0110                 'x_scale': STR_L_W,
0111                 'y_scale': STR_L_H,
0112             },
0113         },
0114         'TOB': {
0115             'L1': {
0116                 'file': 'Relative_TPolyLine_Strips_TOB_L1.txt',
0117                 'x_off': 3*M_X + 2*STR_L_W,
0118                 'y_off': -STR_L_H - M_Y - STR_L_H/2. + M_Y/2.,
0119                 'x_scale': STR_L_W,
0120                 'y_scale': STR_L_H,
0121             },
0122             'L2': {
0123                 'file': 'Relative_TPolyLine_Strips_TOB_L2.txt',
0124                 'x_off': 4*M_X + 3*STR_L_W,
0125                 'y_off': -STR_L_H - M_Y - STR_L_H/2. + M_Y/2.,
0126                 'x_scale': STR_L_W,
0127                 'y_scale': STR_L_H,
0128             },
0129             'L3': {
0130                 'file': 'Relative_TPolyLine_Strips_TOB_L3.txt',
0131                 'x_off': 3*M_X + 2*STR_L_W,
0132                 'y_off': - STR_L_H/2. + M_Y/2.,
0133                 'x_scale': STR_L_W,
0134                 'y_scale': STR_L_H,
0135             },
0136             'L4': {
0137                 'file': 'Relative_TPolyLine_Strips_TOB_L4.txt',
0138                 'x_off': 4*M_X + 3*STR_L_W,
0139                 'y_off': - STR_L_H/2. + M_Y/2.,
0140                 'x_scale': STR_L_W,
0141                 'y_scale': STR_L_H,
0142             },
0143             'L5': {
0144                 'file': 'Relative_TPolyLine_Strips_TOB_L5.txt',
0145                 'x_off': 3*M_X + 2*STR_L_W,
0146                 'y_off': STR_L_H/2. + M_Y + M_Y/2.,
0147                 'x_scale': STR_L_W,
0148                 'y_scale': STR_L_H,
0149             },
0150             'L6': {
0151                 'file': 'Relative_TPolyLine_Strips_TOB_L6.txt',
0152                 'x_off': 4*M_X + 3*STR_L_W,
0153                 'y_off': STR_L_H/2. + M_Y + M_Y/2.,
0154                 'x_scale': STR_L_W,
0155                 'y_scale': STR_L_H,
0156             },
0157         },
0158         'TID-': {
0159             '-1': {
0160                 'file': 'Relative_TPolyLine_Strips_TID_-1.txt',
0161                 'x_off': M_X + (STR_L_W + M_X)/2.,
0162                 'y_off': - STR_L_H - M_Y - STR_TID_D_W,
0163                 'x_scale': STR_TID_D_W,
0164                 'y_scale': STR_TID_D_W,
0165             },
0166             '-2': {
0167                 'file': 'Relative_TPolyLine_Strips_TID_-2.txt',
0168                 'x_off': M_X + STR_L_W/2. - STR_TID_D_W/2. + (STR_L_W + M_X)/2.,
0169                 'y_off': - STR_L_H - M_Y - STR_TID_D_W,
0170                 'x_scale': STR_TID_D_W,
0171                 'y_scale': STR_TID_D_W,
0172             },
0173             '-3': {
0174                 'file': 'Relative_TPolyLine_Strips_TID_-3.txt',
0175                 'x_off': M_X + STR_L_W - STR_TID_D_W + (STR_L_W + M_X)/2.,
0176                 'y_off': - STR_L_H - M_Y - STR_TID_D_W,
0177                 'x_scale': STR_TID_D_W,
0178                 'y_scale': STR_TID_D_W,
0179             },
0180         },
0181         'TID+': {
0182             '+1': {
0183                 'file': 'Relative_TPolyLine_Strips_TID_+1.txt',
0184                 'x_off': M_X + (STR_L_W + M_X)/2.,
0185                 'y_off': STR_L_H +2*M_Y,
0186                 'x_scale': STR_TID_D_W,
0187                 'y_scale': STR_TID_D_W,
0188             },
0189             '+2': {
0190                 'file': 'Relative_TPolyLine_Strips_TID_+2.txt',
0191                 'x_off': M_X + STR_L_W/2. - STR_TID_D_W/2. + (STR_L_W + M_X)/2.,
0192                 'y_off': STR_L_H +2*M_Y,
0193                 'x_scale': STR_TID_D_W,
0194                 'y_scale': STR_TID_D_W,
0195             },
0196             '+3': {
0197                 'file': 'Relative_TPolyLine_Strips_TID_+3.txt',
0198                 'x_off': M_X + STR_L_W - STR_TID_D_W + (STR_L_W + M_X)/2.,
0199                 'y_off': STR_L_H +2*M_Y,
0200                 'x_scale': STR_TID_D_W,
0201                 'y_scale': STR_TID_D_W,
0202             },
0203         },
0204         'TEC-': {
0205             '-1': {
0206                 'file': 'Relative_TPolyLine_Strips_TEC_-1.txt',
0207                 'x_off': M_X,
0208                 'y_off': -STR_L_H - M_Y - STR_L_H/2. + M_Y/2. - M_Y - STR_D_W,
0209                 'x_scale': STR_D_W,
0210                 'y_scale': STR_D_W,
0211             },
0212             '-2': {
0213                 'file': 'Relative_TPolyLine_Strips_TEC_-2.txt',
0214                 'x_off': M_X +((4*STR_L_W + 3*M_X - 9*STR_D_W)/8. + STR_D_W),
0215                 'y_off': -STR_L_H - M_Y - STR_L_H/2. + M_Y/2. - M_Y - STR_D_W,
0216                 'x_scale': STR_D_W,
0217                 'y_scale': STR_D_W,
0218             },
0219             '-3': {
0220                 'file': 'Relative_TPolyLine_Strips_TEC_-3.txt',
0221                 'x_off': M_X + 2*((4*STR_L_W + 3*M_X - 9*STR_D_W)/8. + STR_D_W),
0222                 'y_off': -STR_L_H - M_Y - STR_L_H/2. + M_Y/2. - M_Y - STR_D_W,
0223                 'x_scale': STR_D_W,
0224                 'y_scale': STR_D_W,
0225             },
0226             '-4': {
0227                 'file': 'Relative_TPolyLine_Strips_TEC_-4.txt',
0228                 'x_off': M_X + 3*((4*STR_L_W + 3*M_X - 9*STR_D_W)/8. + STR_D_W),
0229                 'y_off': -STR_L_H - M_Y - STR_L_H/2. + M_Y/2. - M_Y - STR_D_W,
0230                 'x_scale': STR_D_W,
0231                 'y_scale': STR_D_W,
0232             },
0233             '-5': {
0234                 'file': 'Relative_TPolyLine_Strips_TEC_-5.txt',
0235                 'x_off': M_X + 4*((4*STR_L_W + 3*M_X - 9*STR_D_W)/8. + STR_D_W),
0236                 'y_off': -STR_L_H - M_Y - STR_L_H/2. + M_Y/2. - M_Y - STR_D_W,
0237                 'x_scale': STR_D_W,
0238                 'y_scale': STR_D_W,
0239             },
0240             '-6': {
0241                 'file': 'Relative_TPolyLine_Strips_TEC_-6.txt',
0242                 'x_off': M_X + 5*((4*STR_L_W + 3*M_X - 9*STR_D_W)/8. + STR_D_W),
0243                 'y_off': -STR_L_H - M_Y - STR_L_H/2. + M_Y/2. - M_Y - STR_D_W,
0244                 'x_scale': STR_D_W,
0245                 'y_scale': STR_D_W,
0246             },
0247             '-7': {
0248                 'file': 'Relative_TPolyLine_Strips_TEC_-7.txt',
0249                 'x_off': M_X + 6*((4*STR_L_W + 3*M_X - 9*STR_D_W)/8. + STR_D_W),
0250                 'y_off': -STR_L_H - M_Y - STR_L_H/2. + M_Y/2. - M_Y - STR_D_W,
0251                 'x_scale': STR_D_W,
0252                 'y_scale': STR_D_W,
0253             },
0254             '-8': {
0255                 'file': 'Relative_TPolyLine_Strips_TEC_-8.txt',
0256                 'x_off': M_X + 7*((4*STR_L_W + 3*M_X - 9*STR_D_W)/8. + STR_D_W),
0257                 'y_off': -STR_L_H - M_Y - STR_L_H/2. + M_Y/2. - M_Y - STR_D_W,
0258                 'x_scale': STR_D_W,
0259                 'y_scale': STR_D_W,
0260             },
0261             '-9': {
0262                 'file': 'Relative_TPolyLine_Strips_TEC_-9.txt',
0263                 'x_off': M_X + 8*((4*STR_L_W + 3*M_X - 9*STR_D_W)/8. + STR_D_W),
0264                 'y_off': -STR_L_H - M_Y - STR_L_H/2. + M_Y/2. - M_Y - STR_D_W,
0265                 'x_scale': STR_D_W,
0266                 'y_scale': STR_D_W,
0267             },
0268         },
0269         'TEC+': {
0270             '+1': {
0271                 'file': 'Relative_TPolyLine_Strips_TEC_+1.txt',
0272                 'x_off': M_X,
0273                 'y_off': STR_L_H + STR_L_H/2. + M_Y/2. + 2*M_Y,
0274                 'x_scale': STR_D_W,
0275                 'y_scale': STR_D_W,
0276             },
0277             '+2': {
0278                 'file': 'Relative_TPolyLine_Strips_TEC_+2.txt',
0279                 'x_off': M_X + ((4*STR_L_W + 3*M_X - 9*STR_D_W)/8. + STR_D_W),
0280                 'y_off': STR_L_H + STR_L_H/2. + M_Y/2. + 2*M_Y,
0281                 'x_scale': STR_D_W,
0282                 'y_scale': STR_D_W,
0283             },
0284             '+3': {
0285                 'file': 'Relative_TPolyLine_Strips_TEC_+3.txt',
0286                 'x_off': M_X + 2*((4*STR_L_W + 3*M_X - 9*STR_D_W)/8. + STR_D_W),
0287                 'y_off': STR_L_H + STR_L_H/2. + M_Y/2. + 2*M_Y,
0288                 'x_scale': STR_D_W,
0289                 'y_scale': STR_D_W,
0290             },
0291             '+4': {
0292                 'file': 'Relative_TPolyLine_Strips_TEC_+4.txt',
0293                 'x_off': M_X + 3*((4*STR_L_W + 3*M_X - 9*STR_D_W)/8. + STR_D_W),
0294                 'y_off': STR_L_H + STR_L_H/2. + M_Y/2. + 2*M_Y,
0295                 'x_scale': STR_D_W,
0296                 'y_scale': STR_D_W,
0297             },
0298             '+5': {
0299                 'file': 'Relative_TPolyLine_Strips_TEC_+5.txt',
0300                 'x_off': M_X + 4*((4*STR_L_W + 3*M_X - 9*STR_D_W)/8. + STR_D_W),
0301                 'y_off': STR_L_H + STR_L_H/2. + M_Y/2. + 2*M_Y,
0302                 'x_scale': STR_D_W,
0303                 'y_scale': STR_D_W,
0304             },
0305             '+6': {
0306                 'file': 'Relative_TPolyLine_Strips_TEC_+6.txt',
0307                 'x_off': M_X + 5*((4*STR_L_W + 3*M_X - 9*STR_D_W)/8. + STR_D_W),
0308                 'y_off': STR_L_H + STR_L_H/2. + M_Y/2. + 2*M_Y,
0309                 'x_scale': STR_D_W,
0310                 'y_scale': STR_D_W,
0311             },
0312             '+7': {
0313                 'file': 'Relative_TPolyLine_Strips_TEC_+7.txt',
0314                 'x_off': M_X + 6*((4*STR_L_W + 3*M_X - 9*STR_D_W)/8. + STR_D_W),
0315                 'y_off': STR_L_H + STR_L_H/2. + M_Y/2. + 2*M_Y,
0316                 'x_scale': STR_D_W,
0317                 'y_scale': STR_D_W,
0318             },
0319             '+8': {
0320                 'file': 'Relative_TPolyLine_Strips_TEC_+8.txt',
0321                 'x_off': M_X + 7*((4*STR_L_W + 3*M_X - 9*STR_D_W)/8. + STR_D_W),
0322                 'y_off': STR_L_H + STR_L_H/2. + M_Y/2. + 2*M_Y,
0323                 'x_scale': STR_D_W,
0324                 'y_scale': STR_D_W,
0325             },
0326             '+9': {
0327                 'file': 'Relative_TPolyLine_Strips_TEC_+9.txt',
0328                 'x_off': M_X + 8*((4*STR_L_W + 3*M_X - 9*STR_D_W)/8. + STR_D_W),
0329                 'y_off': STR_L_H + STR_L_H/2. + M_Y/2. + 2*M_Y,
0330                 'x_scale': STR_D_W,
0331                 'y_scale': STR_D_W,
0332             },
0333         },
0334     },
0335 }
0336 
0337 # Add text
0338 for layer in TkMap_GEO['pixel']['BPIX']:
0339     TkMap_GEO['pixel']['BPIX'][layer]['latex'] = {
0340         'text': 'BPIX '+layer,
0341         'x': TkMap_GEO['pixel']['BPIX'][layer]['x_off'],
0342         'y': TkMap_GEO['pixel']['BPIX'][layer]['y_off'] + PIX_L_H + M_T,
0343         'alignment': 11,
0344     }
0345 
0346 for z in ['-', '+']:
0347     TkMap_GEO['pixel']['FPIX'+z]['latex'] = {
0348         'text': 'FPIX',
0349         'x': TkMap_GEO['pixel']['FPIX'+z][z+'1']['x_off'],
0350         'y': TkMap_GEO['pixel']['FPIX'+z][z+'1']['y_off'] + PIX_D_W + M_T,
0351         'alignment': 11,
0352     }
0353     for disc in TkMap_GEO['pixel']['FPIX'+z]:
0354         if disc == 'latex': continue
0355         TkMap_GEO['pixel']['FPIX'+z][disc]['latex'] = {
0356             'text': disc,
0357             'x': TkMap_GEO['pixel']['FPIX'+z][disc]['x_off'] + PIX_D_W,
0358             'y': TkMap_GEO['pixel']['FPIX'+z][disc]['y_off'] + PIX_D_W,
0359             #'alignment': 33,
0360             'alignment': 23,
0361         }
0362 for det in ['TIB', 'TOB']:
0363     for layer in TkMap_GEO['strips'][det]:
0364         TkMap_GEO['strips'][det][layer]['latex'] = {
0365             'text': det+' '+layer,
0366             'x': TkMap_GEO['strips'][det][layer]['x_off'],
0367             'y': TkMap_GEO['strips'][det][layer]['y_off'] + STR_L_H + M_T,
0368             'alignment': 11,
0369         }
0370 
0371 for z in ['-', '+']:
0372     TkMap_GEO['strips']['TEC'+z]['latex'] = {
0373         'text': 'TEC',
0374         'x': TkMap_GEO['strips']['TEC'+z][z+'1']['x_off'],
0375         'y': TkMap_GEO['strips']['TEC'+z][z+'1']['y_off'] + STR_D_W + M_T,
0376         'alignment': 11,
0377     }
0378     for disc in TkMap_GEO['strips']['TEC'+z]:
0379         if disc == 'latex': continue
0380         TkMap_GEO['strips']['TEC'+z][disc]['latex'] = {
0381             'text': disc,
0382             'x': TkMap_GEO['strips']['TEC'+z][disc]['x_off'] + STR_D_W,
0383             'y': TkMap_GEO['strips']['TEC'+z][disc]['y_off'] + STR_D_W,
0384             #'alignment': 33,
0385             'alignment': 23,
0386         }
0387 
0388 # TID
0389 for z in ['-', '+']:
0390     TkMap_GEO['strips']['TID'+z]['latex'] = {
0391         'text': 'TID',
0392         #'x': TkMap_GEO['strips']['TID'+z][z+'1']['x_off'],
0393         'x': TkMap_GEO['strips']['TID'+z][z+'1']['x_off'] - 2*M_T,
0394         #'y': TkMap_GEO['strips']['TID'+z][z+'1']['y_off'] + STR_TID_D_W + M_T,
0395         'y': TkMap_GEO['strips']['TID'+z][z+'1']['y_off'] + STR_TID_D_W/2.,
0396         #'alignment': 11,
0397         'alignment': 32,
0398     }
0399     for disc in TkMap_GEO['strips']['TID'+z]:
0400         if disc == 'latex': continue
0401         TkMap_GEO['strips']['TID'+z][disc]['latex'] = {
0402             'text': disc,
0403             'x': TkMap_GEO['strips']['TID'+z][disc]['x_off'] + STR_TID_D_W,
0404             'y': TkMap_GEO['strips']['TID'+z][disc]['y_off'] + STR_TID_D_W,
0405             'alignment': 13,
0406         }
0407 
0408 def read_TPLfile(file_name):
0409     o_file = open(file_name, 'r')
0410     lines = o_file.readlines()
0411     o_file.close()
0412 
0413     TPL_dict = {}
0414     for line in lines:
0415         if '#' in line: continue
0416         splt_line = line.replace('\n', '').split(' ')
0417         det_id = int(splt_line[0])
0418         x = []
0419         y = []
0420         for idx,coo in enumerate(splt_line[1:]):
0421             #print(coo)
0422             try:
0423                 val = float(coo)
0424                 if (idx%2) == 0: 
0425                     y.append(val)
0426                 else: 
0427                     x.append(val)
0428             except ValueError:
0429                 continue
0430         TPL_dict[det_id] = {}
0431         TPL_dict[det_id]['x'] = x
0432         TPL_dict[det_id]['y'] = y
0433     return TPL_dict
0434         
0435     
0436 
0437 if __name__ == '__main__':
0438     import ROOT
0439     from array import array
0440     #TPL_dict = read_TPLfile('Relative_TPolyLine_Pixel_phase1_BPIX_L1.txt')
0441     #print(TPL_dict)
0442 
0443     def test_draw(w, h):
0444         canvas = ROOT.TCanvas('canvas', 'detector canvas', w, h)
0445         
0446         # Load all modules in absolute positions
0447         # Find max x and y to rescale later for window
0448         all_modules = {}
0449         all_text = {}
0450         x_max = -9999.
0451         y_max = -9999.
0452         x_min = 9999.
0453         y_min = 9999.
0454         for det in TkMap_GEO:
0455             for sub in TkMap_GEO[det]:
0456                 for part in TkMap_GEO[det][sub]:
0457                     if part == 'latex':
0458                         all_text[det+'_'+sub] = TkMap_GEO[det][sub][part]
0459                         continue
0460                     if 'latex' in TkMap_GEO[det][sub][part]:
0461                         all_text[det+'_'+sub+'_'+part] = TkMap_GEO[det][sub][part]['latex']
0462                     TPL_dict = read_TPLfile(TkMap_GEO[det][sub][part]['file'])
0463                     for module in TPL_dict:
0464                         x_canv = []
0465                         y_canv = []
0466                         for idx in range(len(TPL_dict[module]['x'])):
0467                             x_canv.append(TPL_dict[module]['x'][idx]*TkMap_GEO[det][sub][part]['x_scale'] + TkMap_GEO[det][sub][part]['x_off'])
0468                             y_canv.append(TPL_dict[module]['y'][idx]*TkMap_GEO[det][sub][part]['y_scale'] + TkMap_GEO[det][sub][part]['y_off'])
0469                         if max(x_canv) > x_max: x_max = max(x_canv)
0470                         if max(y_canv) > y_max: y_max = max(y_canv)
0471                         if min(x_canv) < x_min: x_min = min(x_canv)
0472                         if min(y_canv) < y_min: y_min = min(y_canv)
0473                         TPL_dict[module]['x'] = x_canv
0474                         TPL_dict[module]['y'] = y_canv
0475                     all_modules.update(TPL_dict)
0476 
0477         r_margin = 1
0478         l_margin = 1
0479         t_margin = 1
0480         b_margin = 1
0481 
0482         x_max += r_margin
0483         x_min -= l_margin
0484         y_max += t_margin
0485         y_min -= b_margin
0486 
0487         x_range = x_max - x_min
0488         y_range = y_max - y_min
0489         if (x_range + 0.)/(w + 0.) > (y_range + 0.)/(h + 0.):
0490             x_scale = x_range
0491             y_scale = (h + 0.)/(w + 0.)*x_range
0492         else:
0493             y_scale = y_range
0494             x_scale = (w + 0.)/(h + 0.)*y_range
0495         TPL = {} 
0496         for module in all_modules:
0497             x = array('d', [])
0498             y = array('d', [])
0499             for idx in range(len(all_modules[module]['x'])):
0500                 x.append((all_modules[module]['x'][idx] - x_min + 0.)/(x_scale + 0.))
0501                 y.append((all_modules[module]['y'][idx] - y_min + 0.)/(y_scale + 0.))
0502             # Begin point is end point
0503             x.append((all_modules[module]['x'][0] - x_min + 0.)/(x_scale + 0.))
0504             y.append((all_modules[module]['y'][0] - y_min + 0.)/(y_scale + 0.))
0505             #print(x, y)
0506             TPL[module] = ROOT.TPolyLine(len(x), x, y) 
0507             #TPL[module].SetFillColor(1)
0508             TPL[module].SetLineColor(1)
0509             TPL[module].Draw('f')
0510             TPL[module].Draw()
0511         TL = ROOT.TLatex()
0512         TL.SetTextSize(0.025)
0513         for key in all_text:
0514             x = (all_text[key]['x'] - x_min + 0.)/(x_scale + 0.)
0515             y = (all_text[key]['y'] - y_min + 0.)/(y_scale + 0.)
0516             TL.SetTextAlign(all_text[key]['alignment'])
0517             TL.DrawLatex(x, y, all_text[key]['text'])
0518         #TL.SetTextSize(0.025)
0519         #TL.SetTextAlign(11)
0520         #TL.DrawLatex(0.1, 0.1, 'bottom')
0521         #TL.SetTextAlign(13)
0522         #TL.DrawLatex(0.1, 0.1, 'top')
0523         canvas.Update() 
0524         raw_input('exit')
0525    
0526     test_draw(1500, 750)
0527     #test_draw(125, 500)
0528     #test_draw(500, 500)
0529     #raw_input('exit')
0530  
0531