Classes | Functions | Variables
wirecell.util.wires.apa Namespace Reference

Classes

class  Description
 
class  Plex
 

Functions

def flatten_cclsm (mat=chip_channel_layer_spot_matrix)
 
def maker (G, ac, typename)
 
def graph (desc, maker=maker)
 
def channel_tuple (G, wire)
 
def channel_hash (iconn, islot, ichip, iaddr)
 
def channel_unhash (chident)
 
def channel_ident (G, wire)
 

Variables

 chip_channel_layer_spot_matrix
 
 chip_channel_spot = chip_channel_layer_spot_matrix[:,:,1].astype(numpy.int32)
 
 chip_channel_layer = numpy.asarray(["uvw".index(i) for i in chip_channel_layer_spot_matrix[:,:,0].flat]).reshape(chip_channel_layer_spot_matrix.shape[:2]).astype(numpy.int32)
 
 FaceParams = namedtuple("FaceParams", ["nlayers", "nboards"]);
 
 BoardParams = namedtuple("BoardParams", ["nchips", "nchanperchip"])
 
 DaqParams = namedtuple("DaqParams", ["nwibs", "nconnperwib"])
 
 GeomParams = namedtuple("GeomParams", ["width", "height", "pitch","angle","offset","planex"])
 
 Params
 
float plane_separation = 4.71
 
 default_params
 
 GeomPoint = namedtuple("GeomPoint", ["x","y","z"])
 
 GeomWire = namedtuple("GeomWire", ["ploc", "wip", "spot", "seg", "p1" ,"p2"])
 
 Parts
 
tuple oneapa_lcr = (1,1,1)
 
tuple protodun_lcr = (1,2,3)
 
tuple dune_lcr = (2,25,3)
 

Detailed Description

This module provides connectivity information about DUNE APAs
(protoDUNE or nominal DUNE FD design, and not 35t prototype)

See the Plex class for a convenient one-stop user shop. 

Function Documentation

def wirecell.util.wires.apa.channel_hash (   iconn,
  islot,
  ichip,
  iaddr 
)
Hash a channel address tuple into a single integer.  

See also channel_tuple().

Definition at line 429 of file apa.py.

429 def channel_hash(iconn, islot, ichip, iaddr):
430  '''
431  Hash a channel address tuple into a single integer.
432 
433  See also channel_tuple().
434  '''
435  return int("%d%d%d%02d" % (iconn+1, islot+1, ichip+1, iaddr+1))
436 
def channel_hash(iconn, islot, ichip, iaddr)
Definition: apa.py:429
def wirecell.util.wires.apa.channel_ident (   G,
  wire 
)
Return an identifier number for the channel attached to the given wire.

Definition at line 445 of file apa.py.

445 def channel_ident(G, wire):
446  '''
447  Return an identifier number for the channel attached to the given wire.
448  '''
449  return channel_hash(*channel_tuple(G, wire))
450 
451 
452 
def channel_tuple(G, wire)
Definition: apa.py:405
def channel_ident(G, wire)
Definition: apa.py:445
def channel_hash(iconn, islot, ichip, iaddr)
Definition: apa.py:429
def wirecell.util.wires.apa.channel_tuple (   G,
  wire 
)
Return a channel address tuple associated with the given wire.

The tuple is intended to be directly passed to channel_hash().

Definition at line 405 of file apa.py.

405 def channel_tuple(G, wire):
406  '''
407  Return a channel address tuple associated with the given wire.
408 
409  The tuple is intended to be directly passed to channel_hash().
410  '''
411 
412  # fixme: some problems with dependencies here:
413  from .graph import parent
414 
415  conductor = parent(G, wire, 'conductor')
416  channel = parent(G, conductor, 'channel')
417  chip = parent(G, channel, 'chip')
418  board = parent(G, chip, 'board')
419  box = parent(G, board, 'face')
420  wib = parent(G, board, 'wib')
421  apa = parent(G, wib, 'apa')
422 
423  islot = G[apa][wib]['slot']
424  iconn = G[wib][board]['connector']
425  ichip = G[board][chip]['spot']
426  iaddr = G[chip][channel]['address']
427  return (iconn, islot, ichip, iaddr)
428 
def channel_tuple(G, wire)
Definition: apa.py:405
def parent(G, child, parent_type)
Definition: graph.py:67
def wirecell.util.wires.apa.channel_unhash (   chident)
Return tuple used to produce the given hash.

Definition at line 437 of file apa.py.

437 def channel_unhash(chident):
438  '''
439  Return tuple used to produce the given hash.
440  '''
441  a = str(chident)
442  return tuple([int(n)-1 for n in [a[0], a[1], a[2], a[3:5]]])
443 
444 
static QCString str
def channel_unhash(chident)
Definition: apa.py:437
def wirecell.util.wires.apa.flatten_cclsm (   mat = chip_channel_layer_spot_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 60 of file apa.py.

60 def flatten_cclsm(mat = chip_channel_layer_spot_matrix):
61  '''
62  Flatten an ASIC channel X number matrix to a dictionary keyed by
63  (plane letter, local wire attachment number (1-48 or 1-40). Value
64  is a tuple (ichip, ich) with ichip:{1-8} and ich:{1-16}
65  '''
66  ret = dict()
67  for ichip, row in enumerate(mat):
68  for ich, cell in enumerate(row):
69  cell = tuple(cell)
70  ret[cell] = (ichip+1, ich+1)
71  return ret
72 
73 
def flatten_cclsm(mat=chip_channel_layer_spot_matrix)
Definition: apa.py:60
auto enumerate(Iterables &&...iterables)
Range-for loop helper tracking the number of iteration.
Definition: enumerate.h:69
def wirecell.util.wires.apa.graph (   desc,
  maker = maker 
)
Return a directed graph expressing the connectivity and
containment given the apa.Description object.

Definition at line 294 of file apa.py.

294 def graph(desc, maker = maker):
295  '''
296  Return a directed graph expressing the connectivity and
297  containment given the apa.Description object.
298  '''
299  G = networkx.DiGraph()
300 
301  p = Parts(*[maker(G, desc, typename) for typename in Parts._fields])
302 
303  def join(n1, n2, link, relationship = "containment", **params):
304 
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)
308  return
309  if relationship in ["direct","simple"]:
310  G.add_edge(n1, n2, relationship=relationship, link=link, **params)
311  return
312  # parent/child
313  G.add_edge(n1, n2, relationship="children", link=link, **params)
314  G.add_edge(n2, n1, relationship="parent", link=link, **params)
315 
316  # FIXME: for now hard-code the single apa connection. This should
317  # be expanded to 6 for protoDUNE or 150 for DUNE SP FD. But, each
318  # APA is identical up to a translation in global coordinates so it
319  # is not yet obvious that it's necessary to exaustively construct
320  # them all.
321  join(p.detector, p.apa, 'submodule', anode_lcr = desc.p.anode_loc)
322 
323  # variable name convention below: gi_ = "global index", "i_" just an index.
324  # everything else an object
325  for gi_wib in range(desc.nwibs):
326  wib = p.wib[gi_wib]
327 
328  join(p.apa, wib, 'slot', slot=gi_wib)
329 
330 
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]
334 
335  join(wib, board, 'cable', connector = i_wibconn)
336 
337  gi_face, iboard_in_face = desc.iface_board(gi_board)
338 
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): # 40,40,48
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)
344 
345  conductor = p.conductor[gi_cond]
346  join(board, conductor, 'trace', layer=ilayer_in_face, spot=ispot_in_layer)
347 
348  gi_chip = desc.ichip_by_face_board_chip[gi_face, iboard_in_face, ichip_on_board]
349  chip = p.chip[gi_chip]
350 
351  # Note: this will be called multiple times. Since
352  # G is not a multigraph subsequent calls are no-ops
353  join(board, chip, 'place', spot=ichip_on_board)
354 
355  # channels and conductors are one-to-one
356  channel = p.channel[gi_cond]
357  join(chip, channel, 'address', address=ichan_in_chip)
358 
359  join(channel, conductor, 'channel', relationship="peer")
360 
361  for ipoint, point in enumerate(p.point):
362  G.node[point]['pos'] = desc.points[ipoint]
363 
364  for gi_face in range(desc.nfaces):
365  face = p.face[gi_face]
366  join(p.apa, face, 'side', side=gi_face)
367 
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)
372 
373  for iplane_in_face, wires in enumerate(desc.wires_by_face_plane[gi_face]):
374 
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)
378 
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
384 
385  # odd segments are on the "other" face.
386  spot_face = (gi_face + gwire.seg%2)%2
387 
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)
391 
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)
396 
397  return G,p
398 
399 # The (#layers, #columns, #rows) for DUNE "anodes" in different detectors
def graph(desc, maker=maker)
Definition: apa.py:294
auto enumerate(Iterables &&...iterables)
Range-for loop helper tracking the number of iteration.
Definition: enumerate.h:69
def maker(G, ac, typename)
Definition: apa.py:280
def wirecell.util.wires.apa.maker (   G,
  ac,
  typename 
)

Definition at line 280 of file apa.py.

280 def maker(G, ac, typename):
281  try:
282  n = getattr(ac, 'n'+typename+'s')
283  except AttributeError:
284  G.add_node(typename, type=typename)
285  return typename
286  ret = list()
287  for ind in range(n):
288  name = "%s%d" % (typename, ind)
289  G.add_node(name, type=typename, index=ind)
290  ret.append(name)
291  return ret
292 
293 
def maker(G, ac, typename)
Definition: apa.py:280

Variable Documentation

wirecell.util.wires.apa.BoardParams = namedtuple("BoardParams", ["nchips", "nchanperchip"])

Definition at line 75 of file apa.py.

wirecell.util.wires.apa.chip_channel_layer = numpy.asarray(["uvw".index(i) for i in chip_channel_layer_spot_matrix[:,:,0].flat]).reshape(chip_channel_layer_spot_matrix.shape[:2]).astype(numpy.int32)

Definition at line 57 of file apa.py.

wirecell.util.wires.apa.chip_channel_layer_spot_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 29 of file apa.py.

wirecell.util.wires.apa.chip_channel_spot = chip_channel_layer_spot_matrix[:,:,1].astype(numpy.int32)

Definition at line 56 of file apa.py.

wirecell.util.wires.apa.DaqParams = namedtuple("DaqParams", ["nwibs", "nconnperwib"])

Definition at line 76 of file apa.py.

wirecell.util.wires.apa.default_params

Definition at line 82 of file apa.py.

tuple wirecell.util.wires.apa.dune_lcr = (2,25,3)

Definition at line 402 of file apa.py.

wirecell.util.wires.apa.FaceParams = namedtuple("FaceParams", ["nlayers", "nboards"]);

Definition at line 74 of file apa.py.

wirecell.util.wires.apa.GeomParams = namedtuple("GeomParams", ["width", "height", "pitch","angle","offset","planex"])

Definition at line 77 of file apa.py.

wirecell.util.wires.apa.GeomPoint = namedtuple("GeomPoint", ["x","y","z"])

Definition at line 117 of file apa.py.

wirecell.util.wires.apa.GeomWire = namedtuple("GeomWire", ["ploc", "wip", "spot", "seg", "p1" ,"p2"])

Definition at line 118 of file apa.py.

tuple wirecell.util.wires.apa.oneapa_lcr = (1,1,1)

Definition at line 400 of file apa.py.

wirecell.util.wires.apa.Params
Initial value:
1 = namedtuple("ApaParams", ["nfaces", "anode_loc", "crate_addr",
2  "face", "board", "daq", "geom"])

Definition at line 78 of file apa.py.

wirecell.util.wires.apa.Parts
Initial value:
1 = namedtuple("Parts",
2  ["detector", "apa", "face", "plane",
3  "wib", "board", "chip", "conductor",
4  "channel", "wire", "point"
5  ])

Definition at line 274 of file apa.py.

float wirecell.util.wires.apa.plane_separation = 4.71

Definition at line 81 of file apa.py.

tuple wirecell.util.wires.apa.protodun_lcr = (1,2,3)

Definition at line 401 of file apa.py.