All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Functions
wirecell.util.wires.onesided Namespace Reference

Functions

def load (filename)
 

Detailed Description

This holds MicroBooNE specific routines related to wire geometry.

Function Documentation

def wirecell.util.wires.onesided.load (   filename)
Load a "celltree wire geometry file".

Return a list of schema.Store.


Somewhere, there exists code to dump wires from larsoft in a text
format such as what made the files found:

https://github.com/BNLIF/wire-cell-celltree/tree/master/geometry

The file is line oriented.  Comment lines may begin with "#" and then have columns of:

- channel: some channel ID

- plane: plane number (0 == U, 1 == V, 2 == W)

- wip: wire index in its plane

- tail: triplet (sx,sy,sz) starting position of the wire in cm

- head: triplet (ex,ey,ez) ending position of the wire in cm

Example lines:

    # channel plane wind sx sy sz ex ey ex
    0 0 0 -6.34915e-14 117.153 0.0352608 -6.34287e-14 117.45 0.548658
    1 0 1 -6.34915e-14 116.807 0.0352608 -6.33552e-14 117.45 1.14866
    ...

Some assumptions made by wire cell in using these files:

- There is no wire wrapping, all wires have segment=0.

- The wire index in plane (wip) counts from 0 for each plane, has no holes and
  increases with increasing Z coordinate.

Definition at line 15 of file onesided.py.

15 def load(filename):
16  '''Load a "celltree wire geometry file".
17 
18  Return a list of schema.Store.
19 
20 
21  Somewhere, there exists code to dump wires from larsoft in a text
22  format such as what made the files found:
23 
24  https://github.com/BNLIF/wire-cell-celltree/tree/master/geometry
25 
26  The file is line oriented. Comment lines may begin with "#" and then have columns of:
27 
28  - channel: some channel ID
29 
30  - plane: plane number (0 == U, 1 == V, 2 == W)
31 
32  - wip: wire index in its plane
33 
34  - tail: triplet (sx,sy,sz) starting position of the wire in cm
35 
36  - head: triplet (ex,ey,ez) ending position of the wire in cm
37 
38  Example lines:
39 
40  # channel plane wind sx sy sz ex ey ex
41  0 0 0 -6.34915e-14 117.153 0.0352608 -6.34287e-14 117.45 0.548658
42  1 0 1 -6.34915e-14 116.807 0.0352608 -6.33552e-14 117.45 1.14866
43  ...
44 
45  Some assumptions made by wire cell in using these files:
46 
47  - There is no wire wrapping, all wires have segment=0.
48 
49  - The wire index in plane (wip) counts from 0 for each plane, has no holes and
50  increases with increasing Z coordinate.
51 
52  '''
53 
54  store = schema.maker()
55 
56  # microboone is single-sided, no wrapping
57  segment = 0
58  face = 0
59  apa = 0
60 
61  # temporary per-plane lists of wires to allow sorting before tuplizing.
62  #planes = [list(), list(), list()]
63  planes = defaultdict(list)
64  with open(filename) as fp:
65  for line in fp.readlines():
66  if line.startswith("#"):
67  continue
68  line = line.strip()
69  if not line:
70  continue
71  chunks = line.split()
72  ch, plane, wip = [int(x) for x in chunks[:3]]
73  beg = [float(x)*units.cm for x in chunks[3:6]]
74  end = [float(x)*units.cm for x in chunks[6:9]]
75  for ind in range(3): # some zeros are not
76  if abs(beg[ind]) < 1e-13:
77  beg[ind] = 0.0
78  if abs(end[ind]) < 1e-13:
79  end[ind] = 0.0
80  if end[1] < beg[1]: # assure proper
81  beg,end = end,beg # direction
82 
83  begind = store.make("point", *beg)
84  endind = store.make("point", *end)
85  wpid = schema.wire_plane_id(plane, face, apa)
86  wireind = store.make("wire", wip, ch, segment, begind, endind)
87  planes[wpid].append(wireind)
88 
89  def wire_pos(ind):
90  wire = store.get("wire", ind)
91  p1 = store.get("point", wire.tail)
92  p2 = store.get("point", wire.head)
93  return 0.5*(p1.z + p2.z)
94 
95  wire_plane_indices = list()
96  for plane, wire_list in sorted(planes.items()):
97  wire_list.sort(key = wire_pos)
98  index = store.make("plane", plane, wire_list)
99  wire_plane_indices.append(index)
100  assert(wire_plane_indices == range(3))
101  face_index = store.make("face", 0, wire_plane_indices)
102  store.make("anode", 0, [face_index])
103  return store.schema()
104 
105 
106 
107 
int open(const char *, int)
Opens a file descriptor.
T abs(T value)