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

Classes

class  Anode
 
class  Detector
 
class  Face
 
class  Plane
 
class  Point
 
class  Store
 
class  Wire
 

Functions

def classes ()
 
def maker ()
 
def wire_plane_id (plane, face, apa)
 
def plane_face_apa (wpid)
 

Variables

int layer_mask = 0x7
 
int face_shift = 3
 
int face_mask = 0x1
 
int apa_shift = 4
 
 _makers
 

Detailed Description

This module defines an schema of object which describe the
wire-related geometry for the Wire Cell Toolkit.

It covers a hierarchy of object types:

    - Detector

    - Anode (eg, one APA)

    - Face

    - Plane

    - Wire

    - Point

Except for Point, all objects are organizational and describe
parentage.  Points are used to describe the end points of wire
segments (wires) and are MUST be expressed in GLOBAL coordinates.

In the following cases the children are referenced by their parent in
a strictly ordered list:

    - A face orders its child planes following how charge drifts.
      That is, in U/V/W order.

    - A plane orders its child wires in increasing pitch direction
      such that the cross product of the wire direction (see next) and
      this pitch direction gives a direction which is normal to the
      wire plane and anti-parallel to the nominal drift direction for
      that plane.

    - Wire places its head end-point closer to the input of the
      detector electronics.  The wire direction is taken from tail to
      head end-points.  For top DUNE APAs and all other current
      detectors this direction points generally upward and for bottom
      DUNE APAs it points generally downward.

Ordering of all other lists is not defined.

Most objects in the schema have an "ident" attribute.  This number is
made available to user C++ code but is treated as OPAQUE but UNIQUE by
the toolkit.  If an object is referenced in multiple contexts their
ident MUST match.  For example, a wire plane and a field reponse plane
must be correlated by their ident.

Schema objects are held in flat, per type store and a reference to an
object of a particular type is made via its index into the store for
that type.

All values MUST be in the WCT system of units.  Code that generates
these objects may use the Python module wirecell.units to assure this.

Although not specified here, there are places where "front" and "back"
qualifiers are applied to "face".  A "front" face is one for which the
cross product of wire and pitch directions (as described above) is
parallel to the global X-axis.

Function Documentation

def wirecell.util.wires.schema.classes ( )

Definition at line 171 of file schema.py.

171 def classes():
172  import sys, inspect
173  ret = list()
174  for name, obj in inspect.getmembers(sys.modules[__name__]):
175  if inspect.isclass(obj):
176  ret.append(obj)
177  return ret
178 
def wirecell.util.wires.schema.maker ( )
Return a schema instance maker.

>>> m = maker()
>>> hid = m.make('Point', x=..., y=..., z=...)
>>> tid = m.make('Point', x=..., y=..., z=...)
>>> wid = m.make('Wire', ident=0, channel=0, segment=0 tail=tid, head=hid)

>>> wire = m.get('Wire', wid)

>>> store = m.schema()

Definition at line 179 of file schema.py.

179 def maker():
180  '''
181  Return a schema instance maker.
182 
183  >>> m = maker()
184  >>> hid = m.make('Point', x=..., y=..., z=...)
185  >>> tid = m.make('Point', x=..., y=..., z=...)
186  >>> wid = m.make('Wire', ident=0, channel=0, segment=0 tail=tid, head=hid)
187 
188  >>> wire = m.get('Wire', wid)
189 
190  >>> store = m.schema()
191  '''
192  import sys, inspect
193  class SchemaMaker(object):
194 
195  def __init__(self):
196  self._makers = dict()
197  for klass in classes():
198  lname = klass.__name__.lower()
199  self.__dict__[lname+'s'] = list()
200  self._makers[lname] = klass
201 
202  def make(self, what, *args):
203  klass = self._makers[what]
204  collection = self.__dict__[what+'s']
205  nthings = len(collection)
206  thing = klass(*args)
207  collection.append(thing)
208  return nthings
209 
210  def get(self, what, ind):
211  collection = self.__dict__[what+'s']
212  return collection[ind]
213 
214  def wire_ypos(self, ind):
215  wire = self.get("wire", ind)
216  p1 = self.get("point", wire.tail)
217  p2 = self.get("point", wire.head)
218  return 0.5*(p1.y + p2.y)
219  def wire_zpos(self, ind):
220  wire = self.get("wire", ind)
221  p1 = self.get("point", wire.tail)
222  p2 = self.get("point", wire.head)
223  return 0.5*(p1.z + p2.z)
224 
225  def schema(self):
226  'Return self as a schema.Store'
227  return Store(self.anodes, self.faces, self.planes, self.wires, self.points)
228  return SchemaMaker()
229 
230 
unique_ptr< InputSource > make(ParameterSet const &conf, InputSourceDescription &desc)
auto const & get(AssnsNode< L, R, D > const &r)
Definition: AssnsNode.h:115
def wirecell.util.wires.schema.plane_face_apa (   wpid)

Definition at line 240 of file schema.py.

240 def plane_face_apa(wpid):
241  #return (wpid&layer_mask, (wpid>>face_shift)&face_mask, wpid>>apa_shift)
242  return (wpid&layer_mask, (wpid&(1<<face_shift))>>3, wpid>>apa_shift)
243 
244 
def plane_face_apa(wpid)
Definition: schema.py:240
def wirecell.util.wires.schema.wire_plane_id (   plane,
  face,
  apa 
)

Definition at line 236 of file schema.py.

236 def wire_plane_id(plane, face, apa):
237  'See WireCellIface/WirePlaneId.h'
238  return (plane&layer_mask) | (face << face_shift) | (apa << apa_shift)
239 
def wire_plane_id(plane, face, apa)
Definition: schema.py:236

Variable Documentation

wirecell.util.wires.schema._makers
private

Definition at line 196 of file schema.py.

int wirecell.util.wires.schema.apa_shift = 4

Definition at line 234 of file schema.py.

int wirecell.util.wires.schema.face_mask = 0x1

Definition at line 233 of file schema.py.

int wirecell.util.wires.schema.face_shift = 3

Definition at line 232 of file schema.py.

int wirecell.util.wires.schema.layer_mask = 0x7

Definition at line 231 of file schema.py.