Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 # Generate 2^6 = 64 entries
0002 # a=12, b=23, c=34, d=13, e=14, f=24
0003 
0004 entries = []
0005 for a in [1,0]:
0006   for b in [1,0]:
0007     for c in [1,0]:
0008       for d in [1,0]:
0009         for e in [1,0]:
0010           for f in [1,0]:
0011             entry = (a,b,c,d,e,f)
0012             entries.append(entry)
0013 
0014 ## Debug
0015 #for entry in entries:
0016 #  print entry
0017 
0018 # ______________________________________________________________________________
0019 # Encode the truth table logic
0020 #
0021 # From Andrew Brinkerhoff (2017-11-30):
0022 #   * All stations which are kept in the track must have a valid dTheta (< max) to all other stations kept in the track.
0023 #   * 3-station tracks are always preferred over 2-station tracks.
0024 #   * Tracks where the first station is ME1 are most-preferred, followed by ME2, followed by ME3.
0025 #   * After that, tracks where the second station is ME2 are most-preferred, followed by ME3, followed by ME4.
0026 
0027 results = []
0028 for entry in entries:
0029   (a,b,c,d,e,f) = entry
0030 
0031   # Everyone is good
0032   if a and b and c and d and e and f:
0033     vmask = (1,1,1,1)
0034 
0035   # 12, 23, 13 are good
0036   elif a and b and d:
0037     vmask = (1,1,1,0)  # mask s4
0038 
0039   # 12, 24, 14 are good
0040   elif a and f and e:
0041     vmask = (1,1,0,1)  # mask s3
0042 
0043   # 13, 34, 14 are good
0044   elif d and c and e:
0045     vmask = (1,0,1,1)  # mask s2
0046 
0047   # 23, 34, 24 are good
0048   elif b and c and f:
0049     vmask = (0,1,1,1)  # mask s1
0050 
0051   # 12 is good
0052   elif a:
0053     vmask = (1,1,0,0)  # mask s3 and s4
0054 
0055   # 13 is good
0056   elif d:
0057     vmask = (1,0,1,0)  # mask s2 and s4
0058 
0059   # 14 is good
0060   elif e:
0061     vmask = (1,0,0,1)  # mask s2 and s3
0062 
0063   # 23 is good
0064   elif b:
0065     vmask = (0,1,1,0)  # mask s1 and s4
0066 
0067   # 24 is good
0068   elif f:
0069     vmask = (0,1,0,1)  # mask s1 and s3
0070 
0071   # 34 is good
0072   elif c:
0073     vmask = (0,0,1,1)  # mask s1 and s2
0074 
0075   # else
0076   else:
0077     vmask = (0,0,0,0)  # fail
0078 
0079   results.append(vmask)
0080 
0081 
0082 # ______________________________________________________________________________
0083 # Output
0084 for result in results:
0085   (w,x,y,z) = result
0086   print("%i%i%i%i" % (z,y,x,w))
0087 
0088 # Output as C++ array
0089 generate_cpp_array = False
0090 if generate_cpp_array:
0091   linebreak = "\n    "
0092   sep = ", "
0093   s = "static const int trk_bld[64] = {"
0094   s += linebreak
0095   i = 0
0096   for result in results:
0097     (w,x,y,z) = result
0098     s += "0b%i%i%i%i" % (z,y,x,w)
0099     if i != 63: s += sep
0100     if i%8 == 7 and i != 63:  s += linebreak
0101     i += 1
0102   s += "\n};"
0103   print(s)