7 chip_conductor_matrix = numpy.array([
8 [(
'u', 19), ('u', 17), ('u', 15), ('u', 13), ('u', 11), ('v', 19),
9 (
'v', 17), (
'v', 15), (
'v', 13), (
'v', 11), (
'w', 23), (
'w', 21),
10 (
'w', 19), (
'w', 17), (
'w', 15), (
'w', 13)],
11 [(
'u', 9), ('u', 7), ('u', 5), ('u', 3), ('u', 1), ('v', 9),
12 (
'v', 7), (
'v', 5), (
'v', 3), (
'v', 1), (
'w', 11), (
'w', 9),
13 (
'w', 7), (
'w', 5), (
'w', 3), (
'w', 1)],
14 [(
'w', 14), (
'w', 16), (
'w', 18), (
'w', 20), (
'w', 22), (
'w', 24),
15 (
'v', 12), (
'v', 14), (
'v', 16), (
'v', 18), (
'v', 20), (
'u', 12), 16 ('u', 14), ('u', 16), ('u', 18), ('u', 20)], 17 [('w', 2), (
'w', 4), (
'w', 6), (
'w', 8), (
'w', 10), (
'w', 12),
18 (
'v', 2), (
'v', 4), (
'v', 6), (
'v', 8), (
'v', 10), (
'u', 2), 19 ('u', 4), ('u', 6), ('u', 8), ('u', 10)], 20 [('u', 29), ('u', 27), ('u', 25), ('u', 23), ('u', 21), ('v', 29),
21 (
'v', 27), (
'v', 25), (
'v', 23), (
'v', 21), (
'w', 35), (
'w', 33),
22 (
'w', 31), (
'w', 29), (
'w', 27), (
'w', 25)],
23 [(
'u', 39), ('u', 37), ('u', 35), ('u', 33), ('u', 31), ('v', 39),
24 (
'v', 37), (
'v', 35), (
'v', 33), (
'v', 31), (
'w', 47), (
'w', 45),
25 (
'w', 43), (
'w', 41), (
'w', 39), (
'w', 37)],
26 [(
'w', 26), (
'w', 28), (
'w', 30), (
'w', 32), (
'w', 34), (
'w', 36),
27 (
'v', 22), (
'v', 24), (
'v', 26), (
'v', 28), (
'v', 30), (
'u', 22), 28 ('u', 24), ('u', 26), ('u', 28), ('u', 30)], 29 [('w', 38), (
'w', 40), (
'w', 42), (
'w', 44), (
'w', 46), (
'w', 48),
30 (
'v', 32), (
'v', 34), (
'v', 36), (
'v', 38), (
'v', 40), (
'u', 32), 31 ('u', 34), ('u', 36), ('u', 38), ('u', 40)]], dtype=object) 35 Flatten an ASIC channel X number matrix to a dictionary keyed by 36 (plane letter, local wire attachment number (1-48 or 1-40). Value 37 is a tuple (ichip, ich) with ichip:{1-8} and ich:{1-16} 43 ret[cell] = (ichip+1, ich+1)
49 Test creating a full detector connectivity (no geometry) 52 ses = db.session(
"sqlite:///test_full.db")
60 protodun_dim = (1,2,3)
63 napas =
reduce(
lambda x,y: x*y, apa_dim)
64 apa_indices = numpy.array(range(napas)).reshape(*apa_dim)
66 def anode_crate_address(layer, column, row):
68 return layer*1000+row*100+column
83 nconductors_in_board_by_layer = (40,40,48)
84 nconductors_in_board = sum (nconductors_in_board_by_layer)
86 nboards = nfaces * nface_spots
87 nchips = nboards*nchip_on_board
88 nconductors = nboards * nconductors_in_board
92 iboard_by_face_spot = numpy.array(range(nboards)).reshape(nfaces, nface_spots)
94 iboard_by_conn_wib = numpy.array(range(nboards)).reshape(nwib_conns, ncrate_wibs)
96 ichip_by_face_board_chip = numpy.array(range(nchips))\
97 .reshape(nfaces, nface_spots, nchip_on_board)
101 conductor_indices = numpy.asarray(range(nconductors))\
102 .reshape(nfaces, nface_spots,
103 nchan_in_chip, nchip_on_board)
104 def conductor_spot_map(face, board, layer, spot):
106 map face, board in face, layer in board and spot in layer to a conductor index 108 nchip,nch = chip_conductor_map[(
"uvw"[layer], spot+1)]
111 icond = conductor_indices[face, board, ich, ichip]
112 return (icond, ichip, ich)
120 for apa_layer
in range(apa_dim[0]):
121 for apa_column
in range(apa_dim[1]):
122 for apa_row
in range(apa_dim[2]):
123 apa_lcr = (apa_layer, apa_column, apa_row)
126 det.add_anode(anode, *apa_dim)
128 det.add_crate(crate, anode_crate_address(*apa_lcr))
130 wibs = [db.Wib()
for n
in range(ncrate_wibs)]
131 faces = [db.Face()
for n
in range(nfaces)]
132 planes = [db.Plane()
for n
in range(nfaces*nface_layers)]
133 boards = [db.Board()
for n
in range(nboards)]
134 chips = [db.Chip()
for n
in range(nchips)]
135 conductors = [db.Conductor()
for n
in range(nconductors)]
136 channels = [db.Channel()
for n
in range(nconductors)]
138 for islot
in range(ncrate_wibs):
140 crate.add_wib(wib, islot+offset)
141 for iconnector
in range(nwib_conns):
142 iboard = iboard_by_conn_wib[iconnector, islot]
143 board = boards[iboard]
144 wib.add_board(board, iconnector+offset)
145 iface = iboard//nface_spots
146 iboard_in_face = iboard%nface_spots
147 print '\t',iface,islot,iconnector,iboard,iboard_in_face
148 for ilayer, ispots
in enumerate(nconductors_in_board_by_layer):
149 for ispot
in range(ispots):
150 icond,ichip,ich = conductor_spot_map(iface, iboard_in_face,
152 conductor = conductors[icond]
153 board.add_conductor(conductor, ispot+offset, ilayer+offset)
155 ichip_global = ichip_by_face_board_chip[iface,iboard_in_face,ichip]
156 chip = chips[ichip_global]
157 if not ichip_global
in seen_chips:
158 board.add_chip(chip, ichip+offset)
159 seen_chips.add(ichip_global)
160 channel = channels[icond]
161 channel.conductor = conductor
162 chip.add_channel(channel, ich+offset)
static std::string reduce(const std::string &str, const std::string &fill=" ", const std::string &whitespace=" \t")
def flatten_chip_conductor_map(ccm=chip_conductor_matrix)
auto enumerate(Iterables &&...iterables)
Range-for loop helper tracking the number of iteration.