# Project CMSSW displayed by LXR

File indexing completed on 2024-04-06 12:20:53

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