Interface Factory<DetectorType extends Detector, SectorType extends Sector, SuperlayerType extends Superlayer, LayerType extends Layer>

Type Parameters:
DetectorType - the specific type of Detector produced by the Factory
SectorType - the specific type of Sector produced by the Factory
SuperlayerType - the specific type of Superlayer produced by the Factory
LayerType - the specific type of Layer produced by the Factory
All Superinterfaces:
Showable
All Known Implementing Classes:
AlertDCFactory, AlertTOFFactory, BSTFactory, CNDFactory, DCFactory, DCFactoryUpdated, ECFactory, FMTFactory, FTCALFactory, FTOFFactory

public interface Factory<DetectorType extends Detector, SectorType extends Sector, SuperlayerType extends Superlayer, LayerType extends Layer> extends Showable
A set of functions to create individual Detector, Sector, Superlayer, or Layer objects for a specific type of detector using the factory method pattern.

Detectors are constructed entirely from scratch using using as little hard coded information (primarily equations). Instead, detectors and their various components are constructed using a few important constants provided by a ConstantProvider.

Detectors can be produced in four different coordinate systems via four different methods:

  1. CLAS Coordinates: createDetectorCLAS(ConstantProvider)
    • Detectors created in CLAS coordinates are in their final nominal positions
    • z-axis: parallel to the beam, positive direction is down beam
    • y-axis: anti-parallel to gravity, positive direction is "up"
    • x-axis: forms a right-handed coordinate system, positive is left
    • To Sector: Rotate each sector CCW around the z-axis by sectorId·60° to φ = 0.
  2. Sector Coordinates: createDetectorSector(ConstantProvider)
    • All sectors from the same detector coincide at φ = 0.
    • To CLAS: Rotate each sector CW around z-axis by φ = sectorId·60°.
    • To Tilted: Rotate each sector CCW around the y-axis by 25° to θ = 0.
    • Exceptions: BST, CND, FTCAL
  3. Tilted Coordinates: createDetectorTilted(ConstantProvider)
    • The normal of the up-beam surface of each detector is parallel to the z-axis.
    • To Sector: Rotate each sector CW around the y-axis by 25°.
    • To Local: Translate each superlayer’s up-beam surface to z = 0.
    • Exceptions: FTOF Panel2, BST, CND
  4. Local Coordinates: createDetectorTilted(ConstantProvider)
    • All sectors belonging to the same detector coincide.
    • No rotations around the x-axis are required to get to CLAS.
    • No translations along the x- or y-axis are required to get to CLAS.
    • No rotations around the z-axis are required to get the first sector to CLAS.
    • The upstream surface of each superlayer is at z=0 and in the xy-plane.
    • Layers are in place relative to their respective superlayers and do not require further translations or rotations independently of their superlayer.
    • To Tilted: Translate each superlayer’s up-beam surface along the z-axis.
    • Exceptions: BST, CND

The Detector, Sector, Superlayer, and Layer construction methods return objects in Local coordinates.

Factory: Factory
Hierarchy: DetectorSectorSuperlayerLayerComponent

All objects are returned in their nominal positions. For information about calibration see Layer.setTransformation(org.jlab.geom.prim.Transformation3D).

Factories have no member variables or initialization procedure. It is acceptable to instantiate a new factory every time one is needed.

However some detectors DO have non-negligible initialization procedures. For example, the BST has 33792 wires, the end points of which are calculated using 67584 line-plane intersections. This can take ~0.5 seconds.

Example usage:

ConstantProvider constants = DataBaseLoader.getConstantsEC();
ECDetector detector;
detector = new ECFactory().createDetectorCLAS(constants);
detector = new ECFactory().createDetectorSector(constants);
detector = new ECFactory().createDetectorTilted(constants);
detector = new ECFactory().createDetectorLocal(constants);

// Constructed in “local” coordinates (varies by detector)
ECSector firstSector = factory.createSector(constants, 0);
ECSuperlayer outerEC = factory.createSuperlayer(constants, 0, 2);
ECLayer wLayer = factory.createLayer(constants, 0, 2, 2);

ConstantProvider dcConstants = DataBaseLoader.getConstantsDC();
DCDetector dc = new DCFactory().createDetectorCLAS(dcConstants);

DCSector sector = dc.getSector(0);
DCSuperlayer superlayer = sector.getSuperlayer(5);
DCLayer layer = superlayer.getLayer(5);
DriftChamberWire wire = layer.getComponent(12);
Point3D wireStart = wire.getLine().origin();

double length = dc.getSector(0).getSuperlayer(0).getLayer(0).getComponent(0).getLength();

int numSectors = dc.getNumSectors();

List midPoints = new ArrayList(); for (DCSector sector : dc.getAllSectors())
  for (DCSuperlayer superlayer : sector.getAllSuperlayers())
    for (DCLayer layer : sup.getAllLayers())
      for (DriftChamberWire wire : layer.getAllComponents())
        midPoints.add(wire.getMidpoint());

Author:
jnhankins
  • Method Details Link icon

    • createDetectorCLAS Link icon

      DetectorType createDetectorCLAS(ConstantProvider cp)
      Constructs a new Detector in CLAS coordinates using the given constants.
      Parameters:
      cp - the constant provider
      Returns:
      a detector in CLAS coordinates
    • createDetectorSector Link icon

      DetectorType createDetectorSector(ConstantProvider cp)
      Constructs a new Detector in Sector coordinates using the given constants.
      Parameters:
      cp - the constant provider
      Returns:
      a detector in Sector coordinates
    • createDetectorTilted Link icon

      DetectorType createDetectorTilted(ConstantProvider cp)
      Constructs a new Detector in Tilted coordinates using the given constants.
      Parameters:
      cp - the constant provider
      Returns:
      a detector in Tilted coordinates
    • createDetectorLocal Link icon

      DetectorType createDetectorLocal(ConstantProvider cp)
      Constructs a new Detector in Local coordinates using the given constants.
      Parameters:
      cp - the constant provider
      Returns:
      a detector in Local coordinates
    • createSector Link icon

      SectorType createSector(ConstantProvider cp, int sectorId)
      Constructs the specified Sector in Local coordinates using the given constants.
      Parameters:
      cp - the constant provider
      sectorId - the sector id of the desired sector
      Returns:
      a sector in Local coordinates
    • createSuperlayer Link icon

      SuperlayerType createSuperlayer(ConstantProvider cp, int sectorId, int superlayerId)
      Constructs the specified Superlayer in Local coordinates using the given constants.
      Parameters:
      cp - the constant provider
      sectorId - the sector id of the desired superlayer
      superlayerId - the superlayer id of the desired superlayer
      Returns:
      a superlayer in Local coordinates
    • createLayer Link icon

      LayerType createLayer(ConstantProvider cp, int sectorId, int superlayerId, int layerId)
      Constructs the specified Layer in Local coordinates using the given constants.
      Parameters:
      cp - the constant provider
      sectorId - the sector id of the desired layer
      superlayerId - the superlayer id of the desired layer
      layerId - the layer id of the desired layer
      Returns:
      a layer in Local coordinates
    • getType Link icon

      String getType()
      Returns a string that identifies the specific subtype of this factory.
      Returns:
      a string naming this factory's type
    • getTransformation Link icon

      Transformation3D getTransformation(ConstantProvider cp, int sector, int superlayer, int layer)
      Returns a transformation object for given sector, superlayer and layer
      Parameters:
      cp -
      sector -
      superlayer -
      layer -
      Returns:
    • getDetectorTransform Link icon

      DetectorTransformation getDetectorTransform(ConstantProvider cp)
    • show Link icon

      void show()
      Invokes System.out.println(this).
      Specified by:
      show in interface Showable