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)
167 static std::string reduce(const std::string &str, const std::string &fill=" ", const std::string &whitespace=" \t")
auto enumerate(Iterables &&...iterables)
Range-for loop helper tracking the number of iteration.