File indexing completed on 2024-04-06 12:20:23
0001
0002
0003 from __future__ import print_function
0004 import os
0005 import sys
0006 import math
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024 if not os.path.isdir(os.environ['LOCALRT'] + "/src/L1Trigger/L1TCalorimeter/data"):
0025 print(os.environ['LOCALRT'] + "/src/L1Trigger/L1TCalorimeter/data/ directory does not exist.\n"
0026 "Creating directory now.\n"
0027 "Remember to do 'git add " + os.environ['LOCALRT'] + "L1Trigger/L1TCalorimeter/data' when committing the new LUT!")
0028 os.makedirs(os.environ['LOCALRT'] + "/src/L1Trigger/L1TCalorimeter/data")
0029
0030 print("Creating tower Et threshold LUT with filename " + os.environ['LOCALRT'] + "/src/L1Trigger/L1TCalorimeter/data/lut_towEtThresh_2017v4_excl30.txt'")
0031 towEtThreshLUTFile = open(os.environ['LOCALRT']+"/src/L1Trigger/L1TCalorimeter/data/lut_towEtThresh_2017v4_excl30.txt", "w")
0032
0033
0034
0035 towEtThreshLUTFile.write(
0036 "# address to et sum tower Et threshold LUT\n"
0037 "# maps 11 bits to 9 bits\n"
0038 "# 11 bits = (compressedPileupEstimate << 6) | abs(ieta)\n"
0039 "# compressedPileupEstimate is unsigned 5 bits, abs(ieta) is unsigned 6 bits\n"
0040 "# data: tower energy threshold returned has 9 bits \n"
0041 "# anything after # is ignored with the exception of the header\n"
0042 "# the header is first valid line starting with #<header> versionStr nrBitsAddress nrBitsData </header>\n"
0043 "#<header> v1 11 9 </header>\n"
0044
0045 )
0046
0047
0048
0049
0050 towerAreas = [0.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,
0051 1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,
0052 1.03,1.15,1.3,1.48,1.72,2.05,1.72,4.02,
0053 3.29,2.01,2.02,2.01,2.02,2.0,2.03,1.99,2.02,2.04,2.00,3.47];
0054
0055 etaRange = xrange(0,41)
0056 compNTT4Range = xrange(0,32)
0057 addr = 0
0058 printBins = ""
0059
0060 for compNTT4 in compNTT4Range:
0061 for ieta in etaRange:
0062 towEtThresh = int(round(float(towerAreas[ieta])*(1/(1+math.exp(-0.2*(ieta-5))))*(float(compNTT4)/10)))
0063 if ieta > 28:
0064 towEtThresh -= 4
0065 if towEtThresh > 16:
0066 towEtThresh = int(16)
0067 if ieta < 13 or towEtThresh < 0:
0068 towEtThresh = 0
0069 if ieta == 29:
0070 towEtThresh = 511
0071 if (addr % 64) == 0:
0072 printBins = " # nTT4 = " + str(5*compNTT4) + "-" + str((5*compNTT4)+5) + " ieta = " + str(ieta)
0073 else:
0074 printBins = ""
0075 towEtThreshLUTFile.write(
0076 str(addr) + " " +
0077 str(towEtThresh) +
0078 printBins +
0079 "\n"
0080 )
0081 addr+=1
0082 if ieta == 40:
0083 extraCount = 0
0084 while extraCount < 23:
0085 towEtThreshLUTFile.write(
0086 str(addr) + " " +
0087 str(0) +
0088 " #dummy\n"
0089 )
0090 addr+=1
0091 extraCount +=1
0092
0093 if addr < 2047:
0094 for addr in xrange(addr,2047):
0095 towEtThreshLUTFile.write(str(addr) + " " + str(0) + " # dummy\n")
0096 addr+=1
0097
0098 print("Done. Closing file...")
0099
0100 towEtThreshLUTFile.close()