Functions | Variables
test_full Namespace Reference

Functions

def flatten_chip_conductor_map (ccm=chip_conductor_matrix)
 
def test_full ()
 

Variables

 chip_conductor_matrix
 
 chip_conductor_map = flatten_chip_conductor_map()
 

Function Documentation

def test_full.flatten_chip_conductor_map (   ccm = chip_conductor_matrix)
Flatten an ASIC channel X number matrix to a dictionary keyed by
(plane letter, local wire attachment number (1-48 or 1-40).  Value
is a tuple (ichip, ich) with ichip:{1-8} and ich:{1-16}

Definition at line 33 of file test_full.py.

33 def flatten_chip_conductor_map(ccm = chip_conductor_matrix):
34  '''
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}
38  '''
39  ret = dict()
40  for ichip, row in enumerate(ccm):
41  for ich, cell in enumerate(row):
42  cell = tuple(cell)
43  ret[cell] = (ichip+1, ich+1)
44  return ret
def flatten_chip_conductor_map(ccm=chip_conductor_matrix)
Definition: test_full.py:33
auto enumerate(Iterables &&...iterables)
Range-for loop helper tracking the number of iteration.
Definition: enumerate.h:69
def test_full.test_full ( )
Test creating a full detector connectivity (no geometry)

Definition at line 47 of file test_full.py.

47 def test_full():
48  '''
49  Test creating a full detector connectivity (no geometry)
50  '''
51 
52  ses = db.session("sqlite:///test_full.db")
53 
54  # do we use one-based or zero-based counting:
55 
56  offset = 1
57 
58  # layers x columsn x rows
59  oneapa_dim = (1,1,1)
60  protodun_dim = (1,2,3)
61  dune_dim = (2,25,3)
62  apa_dim = dune_dim
63  napas = reduce(lambda x,y: x*y, apa_dim)
64  apa_indices = numpy.array(range(napas)).reshape(*apa_dim)
65 
66  def anode_crate_address(layer, column, row):
67  'ad-hoc flattenning'
68  return layer*1000+row*100+column
69 
70  # per apa parameters:
71 
72  nface_layers = 3
73 
74  nfaces = 2
75  nface_spots = 10
76 
77  ncrate_wibs = 5
78  nwib_conns = 4
79 
80  nchan_in_chip = 16
81  nchip_on_board = 8
82 
83  nconductors_in_board_by_layer = (40,40,48)
84  nconductors_in_board = sum (nconductors_in_board_by_layer)
85 
86  nboards = nfaces * nface_spots
87  nchips = nboards*nchip_on_board
88  nconductors = nboards * nconductors_in_board
89 
90  # need to locate a board by its face+spot and wib+conn
91  # map (face,spot) to a board index
92  iboard_by_face_spot = numpy.array(range(nboards)).reshape(nfaces, nface_spots)
93  # map (conn,wib) to a board index
94  iboard_by_conn_wib = numpy.array(range(nboards)).reshape(nwib_conns, ncrate_wibs)
95 
96  ichip_by_face_board_chip = numpy.array(range(nchips))\
97  .reshape(nfaces, nface_spots, nchip_on_board)
98 
99  # organize conductors indices into:
100  # (2 faces x 10 boards x 16 ch x 8 chips)
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):
105  '''
106  map face, board in face, layer in board and spot in layer to a conductor index
107  '''
108  nchip,nch = chip_conductor_map[("uvw"[layer], spot+1)]
109  ichip = nchip-1
110  ich = nch-1
111  icond = conductor_indices[face, board, ich, ichip]
112  return (icond, ichip, ich)
113 
114  # now make
115 
116  det = db.Detector()
117 
118  seen_chips = set()
119 
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)
124  print apa_lcr
125  anode = db.Anode()
126  det.add_anode(anode, *apa_dim)
127  crate = db.Crate()
128  det.add_crate(crate, anode_crate_address(*apa_lcr))
129 
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)]
137 
138  for islot in range(ncrate_wibs):
139  wib = wibs[islot]
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): # 40,40,48
150  icond,ichip,ich = conductor_spot_map(iface, iboard_in_face,
151  ilayer, ispot)
152  conductor = conductors[icond]
153  board.add_conductor(conductor, ispot+offset, ilayer+offset)
154 
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)
163  # to do next: wires
164  ses.add(det)
165  ses.commit()
166 
167 
static std::string reduce(const std::string &str, const std::string &fill=" ", const std::string &whitespace=" \t")
Definition: doxyindexer.cpp:63
auto enumerate(Iterables &&...iterables)
Range-for loop helper tracking the number of iteration.
Definition: enumerate.h:69
def test_full()
Definition: test_full.py:47

Variable Documentation

test_full.chip_conductor_map = flatten_chip_conductor_map()

Definition at line 45 of file test_full.py.

test_full.chip_conductor_matrix
Initial value:
1 = numpy.array([
2  [('u', 19), ('u', 17), ('u', 15), ('u', 13), ('u', 11), ('v', 19),
3  ('v', 17), ('v', 15), ('v', 13), ('v', 11), ('w', 23), ('w', 21),
4  ('w', 19), ('w', 17), ('w', 15), ('w', 13)],
5  [('u', 9), ('u', 7), ('u', 5), ('u', 3), ('u', 1), ('v', 9),
6  ('v', 7), ('v', 5), ('v', 3), ('v', 1), ('w', 11), ('w', 9),
7  ('w', 7), ('w', 5), ('w', 3), ('w', 1)],
8  [('w', 14), ('w', 16), ('w', 18), ('w', 20), ('w', 22), ('w', 24),
9  ('v', 12), ('v', 14), ('v', 16), ('v', 18), ('v', 20), ('u', 12),
10  ('u', 14), ('u', 16), ('u', 18), ('u', 20)],
11  [('w', 2), ('w', 4), ('w', 6), ('w', 8), ('w', 10), ('w', 12),
12  ('v', 2), ('v', 4), ('v', 6), ('v', 8), ('v', 10), ('u', 2),
13  ('u', 4), ('u', 6), ('u', 8), ('u', 10)],
14  [('u', 29), ('u', 27), ('u', 25), ('u', 23), ('u', 21), ('v', 29),
15  ('v', 27), ('v', 25), ('v', 23), ('v', 21), ('w', 35), ('w', 33),
16  ('w', 31), ('w', 29), ('w', 27), ('w', 25)],
17  [('u', 39), ('u', 37), ('u', 35), ('u', 33), ('u', 31), ('v', 39),
18  ('v', 37), ('v', 35), ('v', 33), ('v', 31), ('w', 47), ('w', 45),
19  ('w', 43), ('w', 41), ('w', 39), ('w', 37)],
20  [('w', 26), ('w', 28), ('w', 30), ('w', 32), ('w', 34), ('w', 36),
21  ('v', 22), ('v', 24), ('v', 26), ('v', 28), ('v', 30), ('u', 22),
22  ('u', 24), ('u', 26), ('u', 28), ('u', 30)],
23  [('w', 38), ('w', 40), ('w', 42), ('w', 44), ('w', 46), ('w', 48),
24  ('v', 32), ('v', 34), ('v', 36), ('v', 38), ('v', 40), ('u', 32),
25  ('u', 34), ('u', 36), ('u', 38), ('u', 40)]], dtype=object)

Definition at line 7 of file test_full.py.