296 Return a directed graph expressing the connectivity and 297 containment given the apa.Description object. 299 G = networkx.DiGraph()
301 p =
Parts(*[
maker(G, desc, typename)
for typename
in Parts._fields])
303 def join(n1, n2, link, relationship = "containment", **params):
305 if relationship
in [
"peer",
"sibling"]:
306 G.add_edge(n1, n2, relationship=relationship, link=link, **params)
307 G.add_edge(n2, n1, relationship=relationship, link=link, **params)
309 if relationship
in [
"direct",
"simple"]:
310 G.add_edge(n1, n2, relationship=relationship, link=link, **params)
313 G.add_edge(n1, n2, relationship=
"children", link=link, **params)
314 G.add_edge(n2, n1, relationship=
"parent", link=link, **params)
321 join(p.detector, p.apa,
'submodule', anode_lcr = desc.p.anode_loc)
325 for gi_wib
in range(desc.nwibs):
328 join(p.apa, wib,
'slot', slot=gi_wib)
331 for i_wibconn
in range(desc.p.daq.nconnperwib):
332 gi_board = desc.iboard_by_conn_slot[i_wibconn, gi_wib]
333 board = p.board[gi_board]
335 join(wib, board,
'cable', connector = i_wibconn)
337 gi_face, iboard_in_face = desc.iface_board(gi_board)
339 for ilayer_in_face, ispots_in_layer
in enumerate(desc.nch_in_board_by_layer):
340 for ispot_in_layer
in range(ispots_in_layer):
341 gi_cond, ichip_on_board, ichan_in_chip \
342 = desc.iconductor_chip_chan(gi_face, iboard_in_face,
343 ilayer_in_face, ispot_in_layer)
345 conductor = p.conductor[gi_cond]
346 join(board, conductor,
'trace', layer=ilayer_in_face, spot=ispot_in_layer)
348 gi_chip = desc.ichip_by_face_board_chip[gi_face, iboard_in_face, ichip_on_board]
349 chip = p.chip[gi_chip]
353 join(board, chip,
'place', spot=ichip_on_board)
356 channel = p.channel[gi_cond]
357 join(chip, channel,
'address', address=ichan_in_chip)
359 join(channel, conductor,
'channel', relationship=
"peer")
362 G.node[point][
'pos'] = desc.points[ipoint]
364 for gi_face
in range(desc.nfaces):
365 face = p.face[gi_face]
366 join(p.apa, face,
'side', side=gi_face)
368 for iboard_in_face
in range(desc.p.face.nboards):
369 gi_board = desc.iboard_by_face_board[gi_face, iboard_in_face]
370 board = p.board[gi_board]
371 join(face, board,
'spot', spot = iboard_in_face)
373 for iplane_in_face, wires
in enumerate(desc.wires_by_face_plane[gi_face]):
375 gi_plane = desc.iplane(gi_face, iplane_in_face)
376 plane = p.plane[gi_plane]
377 join(face, plane,
'plane', plane=iplane_in_face)
379 for wip
in range(desc.nwires_by_plane[iplane_in_face]):
380 gi_wire, gwire = desc.wire_index_by_wip(gi_face, iplane_in_face, wip)
381 wire = p.wire[gi_wire]
382 join(plane, wire,
'wip', wip=wip)
383 G.node[wire][
'pitchloc'] = gwire.ploc
386 spot_face = (gi_face + gwire.seg%2)%2
388 gi_conductor = desc.iconductor_by_face_plane_spot(spot_face, iplane_in_face, gwire.spot)
389 conductor = p.conductor[gi_conductor]
390 join(conductor, wire,
'segment', segment=gwire.seg)
392 tail = p.point[gwire.p1]
393 join(wire, tail,
'pt', endpoint=0)
394 head = p.point[gwire.p2]
395 join(wire, head,
'pt', endpoint=1)
def graph(desc, maker=maker)
auto enumerate(Iterables &&...iterables)
Range-for loop helper tracking the number of iteration.
def maker(G, ac, typename)