Class FieldProbe

java.lang.Object
cnuphys.magfield.FieldProbe
All Implemented Interfaces:
IField
Direct Known Subclasses:
CompositeProbe, SolenoidProbe, TorusProbe, ZeroProbe

public abstract class FieldProbe extends Object implements IField
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final IMagField
     
    protected String
     
    protected static final double[]
     
    protected GridCoordinate
    Holds the grid info for the slowest changing coordinate.
    protected GridCoordinate
    Holds the grid info for the medium changing coordinate This is cloned from the field.
    protected GridCoordinate
    Holds the grid info for the fastest changing coordinate This is cloned from the field.
    protected static final double
     
    protected static final double[]
     
    protected static final int
     
    protected static final int
     
    protected static final int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Create a probe, which is a thread safe way to use the field
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    contains(double x, double y, double z)
    Check whether the field boundaries include the point
    static FieldProbe
    Get the appropriate probe for the active field
    static FieldProbe
    Get the appropriate probe for the given field
    void
    field(int sector, float x, float y, float z, float[] result)
    Obtain the magnetic field at a given location expressed in Cartesian coordinates in the sector (not lab or global) system.
    float
    fieldMagnitude(float x, float y, float z)
    Get the field magnitude in kiloGauss at a given location expressed in Cartesian coordinates.
    final float
    getB1(int index)
    Get B1 at a given composite index.
    final float
    getB2(int index)
    Get B2 at a given index.
    final float
    getB3(int index)
    Get B3 at a given composite index.
    final int
    getCompositeIndex(int n1, int n2, int n3)
    Get the composite index to take me to the correct place in the buffer.
    Get the underlying field
    float
    Obtain the maximum field magnitude of any point in the map.
    Get the name of the field
     
    double
    Get the maximum phi coordinate of the field boundary (deg)
    double
    Get the minimum phi coordinate of the field boundary (deg)
     
    double
    Get the maximum rho coordinate of the field boundary
    double
    Get the minimum rho coordinate of the field boundary
    protected int
    getSector(double phi)
    Get the sector [1..6] from the phi value
     
    double
    Get the maximum z coordinate of the field boundary
    double
    Get the minimum z coordinate of the field boundary
    void
    gradient(float x, float y, float z, float[] result)
    Obtain an approximation for the magnetic field gradient at a given location expressed in Cartesian coordinates.
    boolean
    Checks whether the field has been set to always return zero.

    Methods inherited from class java.lang.Object

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

    Methods inherited from interface cnuphys.magfield.IField

    field
  • Field Details

    • X

      protected static final int X
      See Also:
    • Y

      protected static final int Y
      See Also:
    • Z

      protected static final int Z
      See Also:
    • ROOT3OVER2

      protected static final double ROOT3OVER2
    • cosSect

      protected static final double[] cosSect
    • sinSect

      protected static final double[] sinSect
    • _field

      protected final IMagField _field
    • _name

      protected String _name
    • q1Coordinate

      protected GridCoordinate q1Coordinate
      Holds the grid info for the slowest changing coordinate. This is cloned from the field.
    • q2Coordinate

      protected GridCoordinate q2Coordinate
      Holds the grid info for the medium changing coordinate This is cloned from the field.
    • q3Coordinate

      protected GridCoordinate q3Coordinate
      Holds the grid info for the fastest changing coordinate This is cloned from the field.
  • Constructor Details

    • FieldProbe

      public FieldProbe(IMagField field)
      Create a probe, which is a thread safe way to use the field
      Parameters:
      field - the underlying field
  • Method Details

    • getField

      public IMagField getField()
      Get the underlying field
      Returns:
      the field that backs this probe
    • getName

      public String getName()
      Get the name of the field
      Specified by:
      getName in interface IField
      Returns:
      the name of the underlying field
    • fieldMagnitude

      public float fieldMagnitude(float x, float y, float z)
      Get the field magnitude in kiloGauss at a given location expressed in Cartesian coordinates.
      Specified by:
      fieldMagnitude in interface IField
      Parameters:
      x - the x coordinate in cm
      y - the y coordinate in cm
      z - the z coordinate in cm
      Returns:
      the magnitude of the field in kiloGauss.
    • getMaxFieldMagnitude

      public float getMaxFieldMagnitude()
      Obtain the maximum field magnitude of any point in the map.
      Specified by:
      getMaxFieldMagnitude in interface IField
      Returns:
      the maximum field magnitude in the units of the map.
    • isZeroField

      public boolean isZeroField()
      Checks whether the field has been set to always return zero.
      Specified by:
      isZeroField in interface IField
      Returns:
      true if the field is set to return zero.
    • getCompositeIndex

      public final int getCompositeIndex(int n1, int n2, int n3)
      Get the composite index to take me to the correct place in the buffer.
      Parameters:
      n1 - the index in the q1 direction
      n2 - the index in the q2 direction
      n3 - the index in the q3 direction
      Returns:
      the composite index (buffer offset)
    • field

      public void field(int sector, float x, float y, float z, float[] result)
      Obtain the magnetic field at a given location expressed in Cartesian coordinates in the sector (not lab or global) system. The field is returned as a Cartesian vector in kiloGauss.
      Specified by:
      field in interface IField
      Parameters:
      sector - the sector [1..6]
      x - the x sector coordinate in cm
      y - the y sector coordinate in cm
      z - the z sector coordinate in cm
      result - the result is a float array holding the retrieved field in kiloGauss. The 0,1 and 2 indices correspond to x, y, and z components.
    • gradient

      public void gradient(float x, float y, float z, float[] result)
      Obtain an approximation for the magnetic field gradient at a given location expressed in Cartesian coordinates. The field is returned as a Cartesian vector in kiloGauss/cm.
      Specified by:
      gradient in interface IField
      Parameters:
      x - the x coordinate in cm
      y - the y coordinate in cm
      z - the z coordinate in cm
      result - a float array holding the retrieved field in kiloGauss. The 0,1 and 2 indices correspond to x, y, and z components.
    • factory

      public static FieldProbe factory()
      Get the appropriate probe for the active field
      Returns:
      the probe for the active field
    • factory

      public static FieldProbe factory(IMagField field)
      Get the appropriate probe for the given field
      Returns:
      the probe for the given field
    • contains

      public boolean contains(double x, double y, double z)
      Check whether the field boundaries include the point
      Specified by:
      contains in interface IField
      Parameters:
      x - the x coordinate in the map units
      y - the y coordinate in the map units
      z - the z coordinate in the map units
      Returns:
      true if the point is included in the boundary of the field
    • getSector

      protected int getSector(double phi)
      Get the sector [1..6] from the phi value
      Parameters:
      phi - the value of phi in degrees
      Returns:
      the sector [1..6]
    • getPhiCoordinate

      public GridCoordinate getPhiCoordinate()
      Returns:
      the phiCoordinate
    • getRCoordinate

      public GridCoordinate getRCoordinate()
      Returns:
      the rCoordinate
    • getZCoordinate

      public GridCoordinate getZCoordinate()
      Returns:
      the zCoordinate
    • getZMax

      public double getZMax()
      Get the maximum z coordinate of the field boundary
      Returns:
      the maximum z coordinate of the field boundary
    • getZMin

      public double getZMin()
      Get the minimum z coordinate of the field boundary
      Returns:
      the minimum z coordinate of the field boundary
    • getRhoMax

      public double getRhoMax()
      Get the maximum rho coordinate of the field boundary
      Returns:
      the maximum rho coordinate of the field boundary
    • getRhoMin

      public double getRhoMin()
      Get the minimum rho coordinate of the field boundary
      Returns:
      the minimum rho coordinate of the field boundary
    • getPhiMax

      public double getPhiMax()
      Get the maximum phi coordinate of the field boundary (deg)
      Returns:
      the maximum phi coordinate of the field boundary
    • getPhiMin

      public double getPhiMin()
      Get the minimum phi coordinate of the field boundary (deg)
      Returns:
      the minimum phi coordinate of the field boundary
    • getB1

      public final float getB1(int index)
      Get B1 at a given composite index.
      Parameters:
      index - the composite index.
      Returns:
      the B1 at the given index.
    • getB2

      public final float getB2(int index)
      Get B2 at a given index.
      Parameters:
      index - the composite index.
      Returns:
      the B2 at the given composite index.
    • getB3

      public final float getB3(int index)
      Get B3 at a given composite index.
      Parameters:
      index - the composite index.
      Returns:
      the B3 at the given composite index.