Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-11-27 03:17:55

0001 
0002 etaLUT0=[8.946,7.508,6.279,6.399]
0003 etaLUT1=[-0.159,-0.116,-0.088,-0.128]
0004 
0005 
0006 #fine eta
0007 
0008 
0009 
0010 for wheel in [-2,-1,0,1,2]:
0011     for station  in [1,2,3]:
0012         lut=[]
0013         for i in range(0,7):
0014             p=0
0015             if wheel==0:
0016                 if i==3:
0017                     p=0
0018                 else:
0019                     p=i-3
0020                     p=int(round(etaLUT0[station-1]*p+etaLUT1[station-1]*p*p*p/abs(p)))
0021             elif (wheel>0):
0022                 p=4+(abs(wheel)-1)*7+6-i
0023                 p=int(round(etaLUT0[station-1]*p+etaLUT1[station-1]*p*p*p/abs(p)))
0024             else:    
0025                 p=-(4+(abs(wheel)-1)*7+6-i)
0026                 p=int(round(etaLUT0[station-1]*p+etaLUT1[station-1]*p*p*p/abs(p)))
0027             lut.append(str(p))
0028         if wheel>0:
0029             print('etaLUT_plus_{wheel}_{station} = cms.vint32('.format(wheel=wheel,station=station)+','.join(lut)+')\n')
0030         if wheel<0:
0031             print('etaLUT_minus_{wheel}_{station} = cms.vint32('.format(wheel=abs(wheel),station=station)+','.join(lut)+')\n')
0032         if wheel==0:
0033             print('etaLUT_0_{station} = cms.vint32('.format(station=station)+','.join(lut)+')\n')
0034  
0035         #wite HLS LUT    
0036         HLSINFO={}
0037         #first the singles
0038     
0039 
0040         for k in range(0,7):
0041             tag=pow(2,k) 
0042             HLSINFO[tag]={'e1':lut[k],'e2':lut[k],'q':1}
0043         for k in range(0,6):
0044             for l in range(k+1,7):
0045                 tag=pow(2,k)+pow(2,l)
0046                 HLSINFO[tag]={'e1':lut[k],'e2':lut[l],'q':1}
0047         keys=sorted(HLSINFO.keys())
0048         d1=[]
0049         d2=[]
0050         d3=[]
0051 
0052         for N in range(0,pow(2,7)):
0053             if not (N in keys):
0054                 d1.append('0')
0055                 d2.append('0')
0056                 d3.append('0')
0057             else:
0058                 d1.append(str(HLSINFO[N]['e1']))
0059                 d2.append(str(HLSINFO[N]['e2']))
0060                 d3.append(str(HLSINFO[N]['q']))
0061                 
0062 
0063         if wheel>0:
0064             etaTag='plus_'+str(abs(wheel))
0065         elif wheel<0:
0066             etaTag='minus_'+str(abs(wheel))
0067         else:
0068             etaTag='0'
0069     
0070         print('const ap_int<8> etaLUT0_'+etaTag+"_"+str(station)+'[128]={'+','.join(d1)+'};\n')
0071         print('const ap_int<8> etaLUT1_'+etaTag+"_"+str(station)+'[128]={'+','.join(d2)+'};\n')
0072         print('const ap_uint<1> etaLUTQ_'+etaTag+"_"+str(station)+'[128]={'+','.join(d3)+'};\n')
0073         
0074 
0075             
0076                 
0077                 
0078 
0079 #coarse eta
0080 for wheel,p in zip([-2,-1,0,1,2],[-13,-6,0,6,13]):
0081     lut=[]
0082     for station  in [1,2,3,4]:
0083         if p==0:
0084             lut.append('0')
0085         else:
0086             u=int(round(etaLUT0[station-1]*p+etaLUT1[station-1]*p*p*p/abs(p)))
0087             lut.append(str(u))    
0088 
0089 
0090     if wheel>0:
0091         print('etaCoarseLUT_plus_{wheel}= cms.vint32('.format(wheel=wheel)+','.join(lut)+')\n')
0092     if wheel<0:
0093         print('etaCoarseLUT_minus_{wheel} = cms.vint32('.format(wheel=abs(wheel))+','.join(lut)+')\n')
0094     if wheel==0:
0095         print('etaCoarseLUT_0 = cms.vint32('+','.join(lut)+')\n')