# Project CMSSW displayed by LXR

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

```0001 from __future__ import print_function
0002 import FWCore.ParameterSet.Config as cms
0003
0004
0005 from L1Trigger.L1TMuonBarrel.simKBmtfDigis_cfi import bmtfKalmanTrackingSettings as settings
0006
0007 initialK = settings.initialK
0008 initialK2 = settings.initialK2
0009
0010 def bits(number, size_in_bits):
0011     """
0012     The bin() function is *REALLY* unhelpful when working with negative numbers.
0013     It outputs the binary representation of the positive version of that number
0014     with a '-' at the beginning. Woop-di-do. Here's how to derive the two's-
0015     complement binary of a negative number:
0016
0017         complement(bin(+n - 1))
0018
0019     `complement` is a function that flips each bit. `+n` is the negative number
0021
0022     """
0023     if number < 0:
0024         return compliment(bin(abs(number) - 1)[2:]).rjust(size_in_bits, '1')
0025     else:
0026         return bin(number)[2:].rjust(size_in_bits, '0')
0027
0028 def compliment(value):
0029     return ''.join(COMPLEMENT[x] for x in value)
0030
0031 COMPLEMENT = {'1': '0', '0': '1'}
0032
0033
0034
0035 for i in range(0,4):
0036     arr = []
0037     for k in range(0,1024):
0038         arr.append(0)
0039     for phiB in range(-512,512):
0041         factor=phiB
0042         if i in [2,3]:
0043             if abs(phiB)>63:
0044                 factor = 63*phiB/abs(phiB)
0045         if i in [1,0]:
0046             if abs(phiB)>127:
0047                 factor = 127*phiB/abs(phiB)
0048         if factor!=0:
0049             charge= phiB/abs(phiB)
0050         else:
0051             charge=0;
0052
0053         K = int(initialK[i]*8*factor/(1+initialK2[i]*8*charge*factor))
0054         if K>8191:
0055             K=8191
0056         if K<-8191:
0057             K=-8191