3 This holds MicroBooNE specific routines related to wire geometry. 7 from wirecell
import units
10 import matplotlib.pyplot
as plt
11 import matplotlib.patches
as mpatches
13 from collections
import defaultdict
16 '''Load a "celltree wire geometry file". 18 Return a list of schema.Store. 21 Somewhere, there exists code to dump wires from larsoft in a text 22 format such as what made the files found: 24 https://github.com/BNLIF/wire-cell-celltree/tree/master/geometry 26 The file is line oriented. Comment lines may begin with "#" and then have columns of: 28 - channel: some channel ID 30 - plane: plane number (0 == U, 1 == V, 2 == W) 32 - wip: wire index in its plane 34 - tail: triplet (sx,sy,sz) starting position of the wire in cm 36 - head: triplet (ex,ey,ez) ending position of the wire in cm 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 45 Some assumptions made by wire cell in using these files: 47 - There is no wire wrapping, all wires have segment=0. 49 - The wire index in plane (wip) counts from 0 for each plane, has no holes and 50 increases with increasing Z coordinate. 54 store = schema.maker()
63 planes = defaultdict(list)
64 with
open(filename)
as fp:
65 for line
in fp.readlines():
66 if line.startswith(
"#"):
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]]
76 if abs(beg[ind]) < 1e-13:
78 if abs(end[ind]) < 1e-13:
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)
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)
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()
int open(const char *, int)
Opens a file descriptor.