Class AbstractLayer<ComponentType extends Component>

java.lang.Object
org.jlab.geom.abs.AbstractLayer<ComponentType>
Type Parameters:
ComponentType - the specific type of Component contained by the Layer
All Implemented Interfaces:
Layer<ComponentType>, Showable
Direct Known Subclasses:
AlertDCLayer, AlertTOFLayer, BSTLayer, CNDLayer, DCLayer, ECLayer, FMTLayer, FTCALLayer, FTOFLayer, FTOFLayerMesh

public abstract class AbstractLayer<ComponentType extends Component> extends Object implements Layer<ComponentType>
This class provides a skeletal implementation of the Layer interface to minimize the effort required to implement a Layer.

To implement a Layer, the programmer needs only to extend this class and provide implementations for the Layer.getType() method.

Initially the Layer will contain no Components, so Components must be added to the Layer after AbstractLayer's constructor has been invoked via the addComponent(org.jlab.geom.base.Component) method.

To set the boundary, use getBoundary() to retrieve the point and modify it accordingly. Similarly, to set the plane, use getPlane().

If the subtyped Layer contains additional geometry data, then, to ensure that the additional geometry is properly rotated and translated with the Layer, the programmer must also override onSetTransformation(org.jlab.geom.prim.Transformation3D) which is invoked after setTransformation(org.jlab.geom.prim.Transformation3D) is invoked.

AbstractLayer's constructor takes a boolean argument useBoundaryAsHitFilter, which, if true, causes the getLayerHits(org.jlab.geom.prim.Path3D) and getHits(org.jlab.geom.prim.Path3D) methods to return empty lists if the Path3D does not intersects any faces in this Layer's boundary. This can be useful for performance optimization or used to simulate dead zones between the layer's sensing component's active regions.

AbstractLayer provides implementations for getLayerHits(Path3D) and getHits(Path3D) which test for intersections with the layer boundary and component volume shapes respectively. However, programmers may in many times need to override these methods based on the requirements of the type of detector this type of layer belongs to. Further, the these implementations are designed to be general enough to handle several types of detectors and components. Consequently, they do not contain optimizations that may be made available by the specific geometry of a specific detector or component type.

Author:
jhankins
  • Constructor Summary Link icon

    Constructors
    Modifier
    Constructor
    Description
    protected
    AbstractLayer(DetectorId detectorId, int sectorId, int superlayerId, int layerId, boolean useBoundaryAsHitFilter)
    Initializes an empty AbstractLayer with the given id.
  • Method Summary Link icon

    Modifier and Type
    Method
    Description
    final void
    Adds a component to this layer.
    Returns an unmodifiable list of all components contained in this layer.
    final Shape3D
    Returns a Shape3D object that approximately defines the target-side surface of this layer using a set of triangular faces.
    getComponent(int componentId)
    Returns the component associated with the given component id.
    final List<List<Line3D>>
    Returns a list of lists of lines such that each of the inner lists contains the cross section lines for a single component.
    Returns the id of the detector that this layer is contained in.
    Returns a list of DetecorHits which store information about intersections with components in this superlayer.
    Returns a list of DetecorHits which store information about intersections with layer surface boundaries in this layer.
    final int
    Returns the id of this layer.
    final int
    Returns the number of components contained in in this layer.
    final Plane3D
    Returns a plane on the up-beam surface of this layer such that in the local coordinate system the reference point is at x = 0 y = 0, the z-coordinate is equal to the the minimum of the z-coordinates of the points in the surface boundary, and the normal is pointing down-beam.
    final int
    Returns the id of the sector that this layer is contained in.
    final int
    Returns the id of the superlayer that this layer is contained in.
    Returns a copy of the transformation that was used to rotate and translate this layer from its initial position in local coordinates to its current position and orientation.
    protected void
    Classes extending AbstractLayer should implement onSetTransformation so that any additional geometric data they contain is transformed appropriately when AbstractLayer's onSetTransformation method is invoked.
    final void
    Sets the transformation for this layer.
    void
    Invokes System.out.println(this).
     

    Methods inherited from class java.lang.Object Link icon

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.jlab.geom.base.Layer Link icon

    getType
  • Constructor Details Link icon

    • AbstractLayer Link icon

      protected AbstractLayer(DetectorId detectorId, int sectorId, int superlayerId, int layerId, boolean useBoundaryAsHitFilter)
      Initializes an empty AbstractLayer with the given id.
      Parameters:
      detectorId - the id of this layer's detector
      sectorId - the id of this layer's sector
      superlayerId - the id of this layer's superlayer
      layerId - the id of this layer
      useBoundaryAsHitFilter - if true, the getLayerHits(org.jlab.geom.prim.Path3D) and getHits(org.jlab.geom.prim.Path3D) methods will return empty lists if the Path3D does not intersects any faces in this Layer's boundary. This can be useful for performance optimization or used to simulate dead zones between the layer's sensing component's active regions.
  • Method Details Link icon

    • getDetectorId Link icon

      public final DetectorId getDetectorId()
      Description copied from interface: Layer
      Returns the id of the detector that this layer is contained in.
      Specified by:
      getDetectorId in interface Layer<ComponentType extends Component>
      Returns:
      the id of this layer's detector
    • getSectorId Link icon

      public final int getSectorId()
      Description copied from interface: Layer
      Returns the id of the sector that this layer is contained in.
      Specified by:
      getSectorId in interface Layer<ComponentType extends Component>
      Returns:
      the id of this layer's sector
    • getSuperlayerId Link icon

      public final int getSuperlayerId()
      Description copied from interface: Layer
      Returns the id of the superlayer that this layer is contained in.
      Specified by:
      getSuperlayerId in interface Layer<ComponentType extends Component>
      Returns:
      the id of this layer's superlayer
    • getLayerId Link icon

      public final int getLayerId()
      Description copied from interface: Layer
      Returns the id of this layer.
      Specified by:
      getLayerId in interface Layer<ComponentType extends Component>
      Returns:
      the id of this layer.
    • getNumComponents Link icon

      public final int getNumComponents()
      Description copied from interface: Layer
      Returns the number of components contained in in this layer.
      Specified by:
      getNumComponents in interface Layer<ComponentType extends Component>
      Returns:
      the number of components
    • addComponent Link icon

      public final void addComponent(ComponentType component)
      Adds a component to this layer. If a component with the same id is contained in this layer then the preexisting component is replaced by the given component. Intended for use by detector factories.
      Parameters:
      component - the component to add
    • getComponent Link icon

      public final ComponentType getComponent(int componentId)
      Description copied from interface: Layer
      Returns the component associated with the given component id.
      Specified by:
      getComponent in interface Layer<ComponentType extends Component>
      Parameters:
      componentId - the component id
      Returns:
      the component with the specified id
    • getAllComponents Link icon

      public final List<ComponentType> getAllComponents()
      Description copied from interface: Layer
      Returns an unmodifiable list of all components contained in this layer.
      Specified by:
      getAllComponents in interface Layer<ComponentType extends Component>
      Returns:
      an unmodifiable list of components
    • getBoundary Link icon

      public final Shape3D getBoundary()
      Description copied from interface: Layer
      Returns a Shape3D object that approximately defines the target-side surface of this layer using a set of triangular faces.
      Specified by:
      getBoundary in interface Layer<ComponentType extends Component>
      Returns:
      the shape of boundary of the beam-side surface
    • getPlane Link icon

      public final Plane3D getPlane()
      Description copied from interface: Layer
      Returns a plane on the up-beam surface of this layer such that in the local coordinate system the reference point is at x = 0 y = 0, the z-coordinate is equal to the the minimum of the z-coordinates of the points in the surface boundary, and the normal is pointing down-beam.
      Specified by:
      getPlane in interface Layer<ComponentType extends Component>
      Returns:
      the up-beam surface plane
    • getTransformation Link icon

      public final Transformation3D getTransformation()
      Description copied from interface: Layer
      Returns a copy of the transformation that was used to rotate and translate this layer from its initial position in local coordinates to its current position and orientation.

      Note: The following paragraph uses the term "coordinate system" loosely. The layer's current "coordinate system" is ment to mean the true coordinate system (i.e. local, tilted, sector, or CLAS) with, optionally, additional translations and rotations applied to account for misalignments, etc.

      Applying the returned translation to a point will transform that point from the local coordinate system to this layer's coordinate system. To translate a point from this layer's current coordinate system.

      Example: Translating a point back to local coordinates
      Layer layer = ...
      Transformation3D inverse = layer.getTransformation().inverse();
      Point3D point = layer.getComponent(0).getMidpoint();
      Point3D local = new Point3D(point);
      inverse.apply(local);
      System.out.println("Current Coords:"+point+" Local Coords: "+local);
      Example: Applying alignment calibrations
      Transformation3D nominal = layer.getTransformation(); Transformation3D calibrated = new Transformation3D(nominal); ... // add rotations and translations to calibrate the alighnment layer.setTransformation(calibrated);

      Specified by:
      getTransformation in interface Layer<ComponentType extends Component>
      Returns:
      a copy of the current transformation
    • setTransformation Link icon

      public final void setTransformation(Transformation3D transform)
      Description copied from interface: Layer
      Sets the transformation for this layer.

      Internally, to apply the new transformation, this method will use the inverse of its current transformation to move itself back into local coordinates, it will then move itself to its new coordinates by applying the new the transformation before storing it.

      For much more information and example codesee Layer.getTransformation().

      Specified by:
      setTransformation in interface Layer<ComponentType extends Component>
      Parameters:
      transform - the new transform
      See Also:
    • onSetTransformation Link icon

      protected void onSetTransformation(Transformation3D transform)
      Classes extending AbstractLayer should implement onSetTransformation so that any additional geometric data they contain is transformed appropriately when AbstractLayer's onSetTransformation method is invoked. To implement this method simply apply the given transformation on all of the transformable contained in the layer that are not managed by AbstractLayer. This method is called at the end of AbstractLayer's setTransformation method.
      Parameters:
      transform - the full transformation from the old coordinate system to the new coordinate system
      See Also:
    • getCrossSections Link icon

      public final List<List<Line3D>> getCrossSections(Transformation3D transform)
      Description copied from interface: Layer
      Returns a list of lists of lines such that each of the inner lists contains the cross section lines for a single component.

      This method takes a Transformation3D object as an argument, then constructs a Plane3D object in the xy-plane and applies the transformation to the plane. The intersection of the layer's component's shapes with the transformed plane is then calculated and stored in a list of lists of lines of lines. The inverse of the transformation is then applied to each line ensuring that each returned line is in the xy-plane

      Specified by:
      getCrossSections in interface Layer<ComponentType extends Component>
      Parameters:
      transform - the transformation
      Returns:
      a list of list of lines representing the cross section
      See Also:
    • getLayerHits Link icon

      public List<DetectorHit> getLayerHits(Path3D path)
      Description copied from interface: Layer
      Returns a list of DetecorHits which store information about intersections with layer surface boundaries in this layer. The component ids stored in the detector hits will all be set to -1 to indicate that detector hit does not specify a specific component.
      Specified by:
      getLayerHits in interface Layer<ComponentType extends Component>
      Parameters:
      path - the path
      Returns:
      a list of detector hits
    • getHits Link icon

      public List<DetectorHit> getHits(Path3D path)
      Description copied from interface: Layer
      Returns a list of DetecorHits which store information about intersections with components in this superlayer.
      Specified by:
      getHits in interface Layer<ComponentType extends Component>
      Parameters:
      path - the path
      Returns:
      a list of detector hits
    • show Link icon

      public void show()
      Description copied from interface: Layer
      Invokes System.out.println(this).
      Specified by:
      show in interface Layer<ComponentType extends Component>
      Specified by:
      show in interface Showable
    • toString Link icon

      public String toString()
      Overrides:
      toString in class Object