Package cnuphys.swim

Class Swimmer

java.lang.Object
cnuphys.swim.Swimmer

public final class Swimmer extends Object
Handles the swimming of a particle through a magnetic field.
Author:
heddle
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final ButcherTableau
     
    static final double
     
    static double[]
     
    static Logger
     
    static final double
     
    static final double
     
    static final String
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Create a swimmer using the current active field
    Swimmer(IMagField magneticField)
    Create a swimmer specific to a magnetic field
    Swimmer(MagneticField magneticField)
    Create a swimmer specific to a magnetic field
  • Method Summary

    Modifier and Type
    Method
    Description
    static double
    Get the tolerance used by the CLAS_Toleance array
    Get the underlying field probe
    static final String
    Return the version string
    static double
    radiusOfCurvature(int Q, double p, double B)
    Compute the radius of curvature in cm
    sectorSwim(int sector, int charge, double xo, double yo, double zo, double momentum, double theta, double phi, double fixedZ, double accuracy, double sMax, double stepSize, double[] relTolerance, double[] hdata)
    Swims a charged particle in a sector coordinate system.
    sectorSwim(int sector, int charge, double xo, double yo, double zo, double momentum, double theta, double phi, double fixedZ, double accuracy, double maxRad, double sMax, double stepSize, double[] relTolerance, double[] hdata)
    Swims a charged particle in a sector coordinate system.
    static void
    setCLASTolerance(double eps)
    Set the tolerance used by the CLAS_Tolerance array
    swim(int charge, double xo, double yo, double zo, double momentum, double theta, double phi, double rmax, double maxPathLength, double stepSize, double distanceBetweenSaves)
    Swims a Lund particle with a built in stopper for the maximum value of the radial coordinate.
    swim(int charge, double xo, double yo, double zo, double momentum, double theta, double phi, double fixedZ, double accuracy, double sMax, double stepSize, double[] relTolerance, double[] hdata)
    Swims a charged particle.
    swim(int charge, double xo, double yo, double zo, double momentum, double theta, double phi, double fixedZ, double accuracy, double maxRad, double maxPathLength, double stepSize, double distanceBetweenSaves)
    Swims a particle with a built it stopper for the maximum value of the radial coordinate.
    swim(int charge, double xo, double yo, double zo, double momentum, double theta, double phi, double fixedZ, double accuracy, double maxRad, double sMax, double stepSize, double[] relTolerance, double[] hdata)
    Swims a charged particle.
    swim(int charge, double xo, double yo, double zo, double momentum, double theta, double phi, double normX, double normY, double normZ, double d, double accuracy, double sMax, double stepSize, double[] relTolerance, double[] hdata)
    Swims a charged particle.
    swim(int charge, double xo, double yo, double zo, double momentum, double theta, double phi, double normX, double normY, double normZ, double d, double accuracy, double maxRad, double sMax, double stepSize, double[] relTolerance, double[] hdata)
    Swims a charged particle.
    int
    swim(int charge, double xo, double yo, double zo, double momentum, double theta, double phi, IRkListener listener, double rmax, double maxPathLength, double stepSize)
    Swims a Lund particle with a built it stopper for the maximum value of the radial coordinate.
    swim(int charge, double xo, double yo, double zo, double momentum, double theta, double phi, IStopper stopper, double maxPathLength, double stepSize, double distanceBetweenSaves)
    Swims a Lund particle with a built it stopper for the maximum value of the radial coordinate.
    swim(int charge, double xo, double yo, double zo, double momentum, double theta, double phi, IStopper stopper, double sMax, double stepSize, double[] relTolerance, double[] hdata)
    Swims a charged particle.
    swim(int charge, double xo, double yo, double zo, double momentum, double theta, double phi, IStopper stopper, double maxPathLength, double stepSize, double tolerance, double[] hdata)
    Swims a charged particle.
    swim(int charge, double xo, double yo, double zo, double momentum, double theta, double phi, IStopper stopper, double s0, double sMax, double stepSize, double[] relTolerance, double[] hdata)
    Swims a charged particle.
    int
    swim(int charge, double xo, double yo, double zo, double momentum, double theta, double phi, IStopper stopper, IRkListener listener, double maxPathLength, double stepSize)
    Swims a charged particle.
    int
    swim(int charge, double xo, double yo, double zo, double momentum, double theta, double phi, IStopper stopper, IRkListener listener, double maxPathLength, double stepSize, double[] relTolerance, double[] hdata)
    Swims a charged particle for the listener mode, where a callback is called for each advance of the integration Uses an adaptive stepsize algorithm.
    int
    swim(int charge, double xo, double yo, double zo, double momentum, double theta, double phi, IStopper stopper, IRkListener listener, double maxPathLength, double stepSize, double tolerance, double[] hdata)
    Swims a Lund particle for the listener mode, where a callback is called for each advance of the integration Uses an adaptive stepsize algorithm.
    swim(int charge, double xo, double yo, double zo, double momentum, double theta, double phi, Plane plane, double accuracy, double sMax, double stepSize, double[] relTolerance, double[] hdata)
    Swims a charged particle.
    swimBackwardsToVertex(int q, double xo, double yo, double zo, double px, double py, double pz)
     
    void
    swimCylinder(int charge, double xo, double yo, double zo, double momentum, double theta, double phi, double[] centerLineP1, double[] centerLineP2, double radius, double accuracy, double sMax, double stepSize, double[] relTolerance, AdaptiveSwimResult result)
    Swims a particle with a built in stopper at the boundary of an arbitrary cylinder.
    void
    swimCylinder(int charge, double xo, double yo, double zo, double momentum, double theta, double phi, double[] centerLineP1, double[] centerLineP2, double radius, double accuracy, double sMax, double stepSize, AdaptiveSwimResult result)
    Swims a particle with a built in stopper at the boundary of an arbitrary cylinder.
    void
    swimPlane(int charge, double xo, double yo, double zo, double momentum, double theta, double phi, double normX, double normY, double normZ, double pointX, double pointY, double pointZ, double accuracy, double sMax, double stepSize, double[] relTolerance, AdaptiveSwimResult result)
     
    void
    swimRho(int charge, double xo, double yo, double zo, double momentum, double theta, double phi, double fixedRho, double accuracy, double sMax, double stepSize, double[] relTolerance, AdaptiveSwimResult result)
    Swims a particle with a built in stopper for the rho coordinate.
    void
    swimRho(int charge, double xo, double yo, double zo, double momentum, double theta, double phi, double fixedRho, double accuracy, double sMax, double stepSize, AdaptiveSwimResult result)
    Swims a particle with a built it stopper for the rho coordinate.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • Swimmer

      public Swimmer()
      Create a swimmer using the current active field
    • Swimmer

      public Swimmer(MagneticField magneticField)
      Create a swimmer specific to a magnetic field
      Parameters:
      magneticField - the magnetic field
    • Swimmer

      public Swimmer(IMagField magneticField)
      Create a swimmer specific to a magnetic field
      Parameters:
      magneticField - the magnetic field
  • Method Details

    • getVersion

      public static final String getVersion()
      Return the version string
      Returns:
      the version string
    • getProbe

      public FieldProbe getProbe()
      Get the underlying field probe
      Returns:
      the probe
    • radiusOfCurvature

      public static double radiusOfCurvature(int Q, double p, double B)
      Compute the radius of curvature in cm
      Parameters:
      Q - the charge in units of e
      p - the momentum in GeV/c
      B - the field in kG
      Returns:
      the radius in cm.
    • setCLASTolerance

      public static void setCLASTolerance(double eps)
      Set the tolerance used by the CLAS_Tolerance array
      Parameters:
      eps - the baseline tolerance. The default is 1.0e-5. Probably should stay in the range 1e-10 (accurate but slow) to 1e-4 (inaccurate but fast)
    • swimCylinder

      public void swimCylinder(int charge, double xo, double yo, double zo, double momentum, double theta, double phi, double[] centerLineP1, double[] centerLineP2, double radius, double accuracy, double sMax, double stepSize, double[] relTolerance, AdaptiveSwimResult result) throws RungeKuttaException
      Swims a particle with a built in stopper at the boundary of an arbitrary cylinder. Uses an adaptive stepsize algorithm.
      Parameters:
      charge - the charge: -1 for electron, 1 for proton, etc
      xo - the x vertex position in meters
      yo - the y vertex position in meters
      zo - the z vertex position in meters
      momentum - initial momentum in GeV/c
      theta - initial polar angle in degrees
      phi - initial azimuthal angle in degrees
      centerLineP1 - one point [array: (x, y, z)] on the infinite center line (meters)
      centerLineP2 - another point [array: (x, y, z)] on the infinite center line (meters)
      radius - the radius of the cylinder in meters
      accuracy - the accuracy of the fixed rho termination, in meters
      sMax - Max path length in meters. This determines the max number of steps based on the step size. If a stopper is used, the integration might terminate before all the steps are taken. A reasonable value for CLAS is 8. meters
      stepSize - the initial step size in meters.
      relTolerance - the error tolerance as fractional diffs. Note it is a vector, the same dimension of the problem, e.g., 6 for [x,y,z,vx,vy,vz]. It might be something like {1.0e-10, 1.0e-10, 1.0e-10, 1.0e-8, 1.0e-8, 1.0e-8}
      result - upon return, results from the swim including the final state vector [x, y, z, px/p, py/p, pz/p]
      Throws:
      RungeKuttaException
    • swimCylinder

      public void swimCylinder(int charge, double xo, double yo, double zo, double momentum, double theta, double phi, double[] centerLineP1, double[] centerLineP2, double radius, double accuracy, double sMax, double stepSize, AdaptiveSwimResult result)
      Swims a particle with a built in stopper at the boundary of an arbitrary cylinder. Uses a fixed stepsize algorithm.
      Parameters:
      charge - the charge: -1 for electron, 1 for proton, etc
      xo - the x vertex position in meters
      yo - the y vertex position in meters
      zo - the z vertex position in meters
      momentum - initial momentum in GeV/c
      theta - initial polar angle in degrees
      phi - initial azimuthal angle in degrees
      centerLineP1 - one point [array: (x, y, z)] on the infinite center line (meters)
      centerLineP2 - another point [array: (x, y, z)] on the infinite center line (meters)
      radius - the radius of the cylinder in meters maxPathLength if reached first)
      accuracy - the accuracy of the fixed rho termination, in meters
      stopper - an optional object that can terminate the swimming based on some condition
      sMax - in meters. This determines the max number of steps based on the step size. If a stopper is used, the integration might terminate before all the steps are taken. A reasonable value for CLAS is 8. meters
      stepSize - the uniform step size in meters.
      result - upon return, results from the swim including the final state vector [x, y, z, px/p, py/p, pz/p]
    • swimRho

      public void swimRho(int charge, double xo, double yo, double zo, double momentum, double theta, double phi, double fixedRho, double accuracy, double sMax, double stepSize, double[] relTolerance, AdaptiveSwimResult result) throws RungeKuttaException
      Swims a particle with a built in stopper for the rho coordinate. Uses an adaptive stepsize algorithm.
      Parameters:
      charge - the charge: -1 for electron, 1 for proton, etc
      xo - the x vertex position in meters
      yo - the y vertex position in meters
      zo - the z vertex position in meters
      momentum - initial momentum in GeV/c
      theta - initial polar angle in degrees
      phi - initial azimuthal angle in degrees
      fixedRho - the fixed rho value (meters) that terminates (or maxPathLength if reached first)
      accuracy - the accuracy of the fixed rho termination, in meters
      sMax - Max path length in meters. This determines the max number of steps based on the step size. If a stopper is used, the integration might terminate before all the steps are taken. A reasonable value for CLAS is 8. meters
      stepSize - the initial step size in meters.
      relTolerance - the error tolerance as fractional diffs. Note it is a vector, the same dimension of the problem, e.g., 6 for [x,y,z,vx,vy,vz]. It might be something like {1.0e-10, 1.0e-10, 1.0e-10, 1.0e-8, 1.0e-8, 1.0e-8}
      result - upon return, results from the swim including the final state vector [x, y, z, px/p, py/p, pz/p]
      Throws:
      RungeKuttaException
    • swimRho

      public void swimRho(int charge, double xo, double yo, double zo, double momentum, double theta, double phi, double fixedRho, double accuracy, double sMax, double stepSize, AdaptiveSwimResult result)
      Swims a particle with a built it stopper for the rho coordinate. Uses a fixed stepsize algorithm.
      Parameters:
      charge - the charge: -1 for electron, 1 for proton, etc
      xo - the x vertex position in meters
      yo - the y vertex position in meters
      zo - the z vertex position in meters
      momentum - initial momentum in GeV/c
      theta - initial polar angle in degrees
      phi - initial azimuthal angle in degrees
      fixedRho - the fixed rho value (meters) that terminates (or maxPathLength if reached first)
      accuracy - the accuracy of the fixed rho termination, in meters
      stopper - an optional object that can terminate the swimming based on some condition
      sMax - in meters. This determines the max number of steps based on the step size. If a stopper is used, the integration might terminate before all the steps are taken. A reasonable value for CLAS is 8. meters
      stepSize - the uniform step size in meters.
      result - upon return, results from the swim including the final state vector [x, y, z, px/p, py/p, pz/p]
    • swimPlane

      public void swimPlane(int charge, double xo, double yo, double zo, double momentum, double theta, double phi, double normX, double normY, double normZ, double pointX, double pointY, double pointZ, double accuracy, double sMax, double stepSize, double[] relTolerance, AdaptiveSwimResult result) throws RungeKuttaException
      Throws:
      RungeKuttaException
    • getEps

      public static double getEps()
      Get the tolerance used by the CLAS_Toleance array
      Returns:
      the tolerance used by the CLAS_Toleance array
    • swim

      public SwimTrajectory swim(int charge, double xo, double yo, double zo, double momentum, double theta, double phi, IStopper stopper, double maxPathLength, double stepSize, double distanceBetweenSaves)
      Swims a Lund particle with a built it stopper for the maximum value of the radial coordinate. This is for the trajectory mode, where you want to cache steps along the path. Uses a fixed stepsize algorithm.
      Parameters:
      charge - the charge: -1 for electron, 1 for proton, etc
      xo - the x vertex position in meters
      yo - the y vertex position in meters
      zo - the z vertex position in meters
      momentum - initial momentum in GeV/c
      theta - initial polar angle in degrees
      phi - initial azimuthal angle in degrees
      stopper - an optional object that can terminate the swimming based on some condition
      maxPathLength - in meters. This determines the max number of steps based on the step size. If a stopper is used, the integration might terminate before all the steps are taken. A reasonable value for CLAS is 8. meters
      stepSize - the uniform step size in meters.
      distanceBetweenSaves - this distance is in meters. It should be bigger than stepSize. It is approximately the distance between "saves" where the point is saved in a trajectory for later drawing.
      Returns:
      the trajectory of the particle
    • swim

      public SwimTrajectory swim(int charge, double xo, double yo, double zo, double momentum, double theta, double phi, double rmax, double maxPathLength, double stepSize, double distanceBetweenSaves)
      Swims a Lund particle with a built in stopper for the maximum value of the radial coordinate. This is for the trajectory mode, where you want to cache steps along the path. Uses a fixed stepsize algorithm.
      Parameters:
      charge - the charge: -1 for electron, 1 for proton, etc
      xo - the x vertex position in meters
      yo - the y vertex position in meters
      zo - the z vertex position in meters
      momentum - initial momentum in GeV/c
      theta - initial polar angle in degrees
      phi - initial azimuthal angle in degrees
      rmax - the max radial coordinate in meters.
      maxPathLength - in meters. This is used to compute the maximum number of integration steps.
      stepSize - either the initial stepsize or the constant step size based on the integration method. Units are meters.
      distanceBetweenSaves - this should be bigger than stepSize. It is approximately the distance between "saves" where the point is saved in a trajectory for later drawing.
      Returns:
      the trajectory of the particle
    • swim

      public int swim(int charge, double xo, double yo, double zo, double momentum, double theta, double phi, IStopper stopper, IRkListener listener, double maxPathLength, double stepSize)
      Swims a charged particle. This is for the listener mode, where a callback is called for each advance of the integration Uses a fixed stepsize algorithm.
      Parameters:
      charge - the charge: -1 for electron, 1 for proton, etc
      xo - the x vertex position in meters
      yo - the y vertex position in meters
      zo - the z vertex position in meters
      momentum - initial momentum in GeV/c
      theta - initial polar angle in degrees
      phi - initial azimuthal angle in degrees
      stopper - an optional object that can terminate the swimming based on some condition
      listener - a callback object that is called on every step
      maxPathLength - in meters. This determines the max number of steps based on the step size. If a stopper is used, the integration might terminate before all the steps are taken. A reasonable value for CLAS is 8. meters
      stepSize - the uniform step size in meters.
      Returns:
      the total number of steps taken
    • swim

      public SwimTrajectory swim(int charge, double xo, double yo, double zo, double momentum, double theta, double phi, double fixedZ, double accuracy, double maxRad, double maxPathLength, double stepSize, double distanceBetweenSaves)
      Swims a particle with a built it stopper for the maximum value of the radial coordinate. This is for the trajectory mode, where you want to cache steps along the path. Uses a fixed stepsize algorithm.
      Parameters:
      charge - the charge: -1 for electron, 1 for proton, etc
      xo - the x vertex position in meters
      yo - the y vertex position in meters
      zo - the z vertex position in meters
      momentum - initial momentum in GeV/c
      theta - initial polar angle in degrees
      phi - initial azimuthal angle in degrees
      fixedZ - the fixed z value (meters) that terminates (or maxPathLength if reached first)
      accuracy - the accuracy of the fixed z termination, in meters
      stopper - an optional object that can terminate the swimming based on some condition
      maxPathLength - in meters. This determines the max number of steps based on the step size. If a stopper is used, the integration might terminate before all the steps are taken. A reasonable value for CLAS is 8. meters
      stepSize - the uniform step size in meters.
      distanceBetweenSaves - this distance is in meters. It should be bigger than stepSize. It is approximately the distance between "saves" where the point is saved in a trajectory for later drawing.
      Returns:
      the trajectory of the particle
    • sectorSwim

      public SwimTrajectory sectorSwim(int sector, int charge, double xo, double yo, double zo, double momentum, double theta, double phi, double fixedZ, double accuracy, double sMax, double stepSize, double[] relTolerance, double[] hdata) throws RungeKuttaException
      Swims a charged particle in a sector coordinate system. This swims to a fixed z value. This is for the trajectory mode, where you want to cache steps along the path. Uses an adaptive stepsize algorithm. THIS IS ONLY VALID IF THE FIELD IS A RotatedComnpositeField or RotatedCompositeProbe
      Parameters:
      sector - the sector [1..6]
      charge - the charge: -1 for electron, 1 for proton, etc
      xo - the x vertex position in meters
      yo - the y vertex position in meters
      zo - the z vertex position in meters
      momentum - initial momentum in GeV/c
      theta - initial polar angle in degrees
      phi - initial azimuthal angle in degrees
      fixedZ - the fixed z value (meters) that terminates (or maxPathLength if reached first)
      accuracy - the accuracy of the fixed z termination, in meters
      sMax - Max path length in meters. This determines the max number of steps based on the step size. If a stopper is used, the integration might terminate before all the steps are taken. A reasonable value for CLAS is 8. meters
      stepSize - the initial step size in meters.
      relTolerance - the error tolerance as fractional diffs. Note it is a vector, the same dimension of the problem, e.g., 6 for [x,y,z,vx,vy,vz]. It might be something like {1.0e-10, 1.0e-10, 1.0e-10, 1.0e-8, 1.0e-8, 1.0e-8}
      hdata - if not null, should be double[3]. Upon return, hdata[0] is the min stepsize used (m), hdata[1] is the average stepsize used (m), and hdata[2] is the max stepsize (m) used
      Returns:
      the trajectory of the particle
      Throws:
      RungeKuttaException
    • sectorSwim

      public SwimTrajectory sectorSwim(int sector, int charge, double xo, double yo, double zo, double momentum, double theta, double phi, double fixedZ, double accuracy, double maxRad, double sMax, double stepSize, double[] relTolerance, double[] hdata) throws RungeKuttaException
      Swims a charged particle in a sector coordinate system. This swims to a fixed z value. This is for the trajectory mode, where you want to cache steps along the path. Uses an adaptive stepsize algorithm. THIS IS ONLY VALID IF THE FIELD IS A RotatedComnpositeField or RotatedCompositeProbe
      Parameters:
      sector - the sector [1..6]
      charge - the charge: -1 for electron, 1 for proton, etc
      xo - the x vertex position in meters
      yo - the y vertex position in meters
      zo - the z vertex position in meters
      momentum - initial momentum in GeV/c
      theta - initial polar angle in degrees
      phi - initial azimuthal angle in degrees
      fixedZ - the fixed z value (meters) that terminates (or maxPathLength if reached first)
      accuracy - the accuracy of the fixed z termination, in meters
      maxRad - the max radial coordinate NOTE: NO LONGER USED (here for backwards compatibility)
      sMax - Max path length in meters. This determines the max number of steps based on the step size. If a stopper is used, the integration might terminate before all the steps are taken. A reasonable value for CLAS is 8. meters
      stepSize - the initial step size in meters.
      relTolerance - the error tolerance as fractional diffs. Note it is a vector, the same dimension of the problem, e.g., 6 for [x,y,z,vx,vy,vz]. It might be something like {1.0e-10, 1.0e-10, 1.0e-10, 1.0e-8, 1.0e-8, 1.0e-8}
      hdata - if not null, should be double[3]. Upon return, hdata[0] is the min stepsize used (m), hdata[1] is the average stepsize used (m), and hdata[2] is the max stepsize (m) used
      Returns:
      the trajectory of the particle
      Throws:
      RungeKuttaException
    • swim

      public SwimTrajectory swim(int charge, double xo, double yo, double zo, double momentum, double theta, double phi, double normX, double normY, double normZ, double d, double accuracy, double maxRad, double sMax, double stepSize, double[] relTolerance, double[] hdata) throws RungeKuttaException
      Swims a charged particle. This swims to a fixed plane. This is for the trajectory mode, where you want to cache steps along the path. Uses an adaptive stepsize algorithm.
      Parameters:
      charge - the charge: -1 for electron, 1 for proton, etc
      xo - the x vertex position in meters
      yo - the y vertex position in meters
      zo - the z vertex position in meters
      momentum - initial momentum in GeV/c
      theta - initial polar angle in degrees
      phi - initial azimuthal angle in degrees
      normX - the x component of the normal vector
      normY - the y component of the normal vector
      normZ - the z component of the normal vector
      d - the distance from the origin to the plane
      accuracy - the accuracy of the distance from plane termination, in meters
      maxRad - the max radial coordinate NOTE: NO LONGER USED (here for backwards compatibility)
      sMax - Max path length in meters. This determines the max number of steps based on the step size. If a stopper is used, the integration might terminate before all the steps are taken. A reasonable value for CLAS is 8. meters
      stepSize - the initial step size in meters.
      relTolerance - the error tolerance as fractional diffs. Note it is a vector, the same dimension of the problem, e.g., 6 for [x,y,z,vx,vy,vz]. It might be something like {1.0e-10, 1.0e-10, 1.0e-10, 1.0e-8, 1.0e-8, 1.0e-8}
      hdata - if not null, should be double[3]. Upon return, hdata[0] is the min stepsize used (m), hdata[1] is the average stepsize used (m), and hdata[2] is the max stepsize (m) used
      Returns:
      the trajectory of the particle
      Throws:
      RungeKuttaException
    • swim

      public SwimTrajectory swim(int charge, double xo, double yo, double zo, double momentum, double theta, double phi, double normX, double normY, double normZ, double d, double accuracy, double sMax, double stepSize, double[] relTolerance, double[] hdata) throws RungeKuttaException
      Swims a charged particle. This swims to a fixed plane. This is for the trajectory mode, where you want to cache steps along the path. Uses an adaptive stepsize algorithm.
      Parameters:
      charge - the charge: -1 for electron, 1 for proton, etc
      xo - the x vertex position in meters
      yo - the y vertex position in meters
      zo - the z vertex position in meters
      momentum - initial momentum in GeV/c
      theta - initial polar angle in degrees
      phi - initial azimuthal angle in degrees
      normX - the x component of the normal vector
      normY - the y component of the normal vector
      normZ - the z component of the normal vector
      d - the distance from the origin to the plane
      accuracy - the accuracy of the fixed z termination, in meters
      sMax - Max path length in meters. This determines the max number of steps based on the step size. If a stopper is used, the integration might terminate before all the steps are taken. A reasonable value for CLAS is 8. meters
      stepSize - the initial step size in meters.
      relTolerance - the error tolerance as fractional diffs. Note it is a vector, the same dimension of the problem, e.g., 6 for [x,y,z,vx,vy,vz]. It might be something like {1.0e-10, 1.0e-10, 1.0e-10, 1.0e-8, 1.0e-8, 1.0e-8}
      hdata - if not null, should be double[3]. Upon return, hdata[0] is the min stepsize used (m), hdata[1] is the average stepsize used (m), and hdata[2] is the max stepsize (m) used
      Returns:
      the trajectory of the particle
      Throws:
      RungeKuttaException
    • swim

      public SwimTrajectory swim(int charge, double xo, double yo, double zo, double momentum, double theta, double phi, Plane plane, double accuracy, double sMax, double stepSize, double[] relTolerance, double[] hdata) throws RungeKuttaException
      Swims a charged particle. This swims to a fixed plane. This is for the trajectory mode, where you want to cache steps along the path. Uses an adaptive stepsize algorithm.
      Parameters:
      charge - the charge: -1 for electron, 1 for proton, etc
      xo - the x vertex position in meters
      yo - the y vertex position in meters
      zo - the z vertex position in meters
      momentum - initial momentum in GeV/c
      theta - initial polar angle in degrees
      phi - initial azimuthal angle in degrees
      plane - the plane to swim to
      accuracy - the accuracy of the fixed z termination, in meters
      sMax - Max path length in meters. This determines the max number of steps based on the step size. If a stopper is used, the integration might terminate before all the steps are taken. A reasonable value for CLAS is 8. meters
      stepSize - the initial step size in meters.
      relTolerance - the error tolerance as fractional diffs. Note it is a vector, the same dimension of the problem, e.g., 6 for [x,y,z,vx,vy,vz]. It might be something like {1.0e-10, 1.0e-10, 1.0e-10, 1.0e-8, 1.0e-8, 1.0e-8}
      hdata - if not null, should be double[3]. Upon return, hdata[0] is the min stepsize used (m), hdata[1] is the average stepsize used (m), and hdata[2] is the max stepsize (m) used
      Returns:
      the trajectory of the particle
      Throws:
      RungeKuttaException
    • swim

      public SwimTrajectory swim(int charge, double xo, double yo, double zo, double momentum, double theta, double phi, double fixedZ, double accuracy, double maxRad, double sMax, double stepSize, double[] relTolerance, double[] hdata) throws RungeKuttaException
      Swims a charged particle. This swims to a fixed z value. This is for the trajectory mode, where you want to cache steps along the path. Uses an adaptive stepsize algorithm.
      Parameters:
      charge - the charge: -1 for electron, 1 for proton, etc
      xo - the x vertex position in meters
      yo - the y vertex position in meters
      zo - the z vertex position in meters
      momentum - initial momentum in GeV/c
      theta - initial polar angle in degrees
      phi - initial azimuthal angle in degrees
      fixedZ - the fixed z value (meters) that terminates (or maxPathLength if reached first)
      accuracy - the accuracy of the fixed z termination, in meters
      maxRad - the max radial coordinate NOTE: NO LONGER USED (here for backwards compatibility)
      sMax - Max path length in meters. This determines the max number of steps based on the step size. If a stopper is used, the integration might terminate before all the steps are taken. A reasonable value for CLAS is 8. meters
      stepSize - the initial step size in meters.
      relTolerance - the error tolerance as fractional diffs. Note it is a vector, the same dimension of the problem, e.g., 6 for [x,y,z,vx,vy,vz]. It might be something like {1.0e-10, 1.0e-10, 1.0e-10, 1.0e-8, 1.0e-8, 1.0e-8}
      hdata - if not null, should be double[3]. Upon return, hdata[0] is the min stepsize used (m), hdata[1] is the average stepsize used (m), and hdata[2] is the max stepsize (m) used
      Returns:
      the trajectory of the particle
      Throws:
      RungeKuttaException
    • swim

      public SwimTrajectory swim(int charge, double xo, double yo, double zo, double momentum, double theta, double phi, double fixedZ, double accuracy, double sMax, double stepSize, double[] relTolerance, double[] hdata) throws RungeKuttaException
      Swims a charged particle. This swims to a fixed z value. This is for the trajectory mode, where you want to cache steps along the path. Uses an adaptive stepsize algorithm.
      Parameters:
      charge - the charge: -1 for electron, 1 for proton, etc
      xo - the x vertex position in meters
      yo - the y vertex position in meters
      zo - the z vertex position in meters
      momentum - initial momentum in GeV/c
      theta - initial polar angle in degrees
      phi - initial azimuthal angle in degrees
      fixedZ - the fixed z value (meters) that terminates (or maxPathLength if reached first)
      accuracy - the accuracy of the fixed z termination, in meters
      sMax - Max path length in meters. This determines the max number of steps based on the step size. If a stopper is used, the integration might terminate before all the steps are taken. A reasonable value for CLAS is 8. meters
      stepSize - the initial step size in meters.
      relTolerance - the error tolerance as fractional diffs. Note it is a vector, the same dimension of the problem, e.g., 6 for [x,y,z,vx,vy,vz]. It might be something like {1.0e-10, 1.0e-10, 1.0e-10, 1.0e-8, 1.0e-8, 1.0e-8}
      hdata - if not null, should be double[3]. Upon return, hdata[0] is the min stepsize used (m), hdata[1] is the average stepsize used (m), and hdata[2] is the max stepsize (m) used
      Returns:
      the trajectory of the particle
      Throws:
      RungeKuttaException
    • swim

      public SwimTrajectory swim(int charge, double xo, double yo, double zo, double momentum, double theta, double phi, IStopper stopper, double sMax, double stepSize, double[] relTolerance, double[] hdata) throws RungeKuttaException
      Swims a charged particle. This is for the trajectory mode, where you want to cache steps along the path. Uses an adaptive stepsize algorithm.
      Parameters:
      charge - the charge: -1 for electron, 1 for proton, etc
      xo - the x vertex position in meters
      yo - the y vertex position in meters
      zo - the z vertex position in meters
      momentum - initial momentum in GeV/c
      theta - initial polar angle in degrees
      phi - initial azimuthal angle in degrees
      stopper - an optional object that can terminate the swimming based on some condition
      sMax - Max path length in meters. This determines the max number of steps based on the step size. If a stopper is used, the integration might terminate before all the steps are taken. A reasonable value for CLAS is 8. meters
      stepSize - the initial step size in meters.
      relTolerance - the error tolerance as fractional diffs. Note it is a vector, the same dimension of the problem, e.g., 6 for [x,y,z,vx,vy,vz]. It might be something like {1.0e-10, 1.0e-10, 1.0e-10, 1.0e-8, 1.0e-8, 1.0e-8}
      hdata - if not null, should be double[3]. Upon return, hdata[0] is the min stepsize used (m), hdata[1] is the average stepsize used (m), and hdata[2] is the max stepsize (m) used
      Returns:
      the trajectory of the particle
      Throws:
      RungeKuttaException
    • swim

      public SwimTrajectory swim(int charge, double xo, double yo, double zo, double momentum, double theta, double phi, IStopper stopper, double s0, double sMax, double stepSize, double[] relTolerance, double[] hdata) throws RungeKuttaException
      Swims a charged particle. This is for the trajectory mode, where you want to cache steps along the path. Uses an adaptive stepsize algorithm.
      Parameters:
      charge - the charge: -1 for electron, 1 for proton, etc
      xo - the x vertex position in meters
      yo - the y vertex position in meters
      zo - the z vertex position in meters
      momentum - initial momentum in GeV/c
      theta - initial polar angle in degrees
      phi - initial azimuthal angle in degrees
      stopper - an optional object that can terminate the swimming based on some condition
      s0 - Starting path length in meters
      sMax - Max path length in meters. This determines the max number of steps based on the step size. If a stopper is used, the integration might terminate before all the steps are taken. A reasonable value for CLAS is 8. meters
      stepSize - the initial step size in meters.
      relTolerance - the error tolerance as fractional diffs. Note it is a vector, the same dimension of the problem, e.g., 6 for [x,y,z,vx,vy,vz]. It might be something like {1.0e-10, 1.0e-10, 1.0e-10, 1.0e-8, 1.0e-8, 1.0e-8}
      hdata - if not null, should be double[3]. Upon return, hdata[0] is the min stepsize used (m), hdata[1] is the average stepsize used (m), and hdata[2] is the max stepsize (m) used
      Returns:
      the trajectory of the particle
      Throws:
      RungeKuttaException
    • swim

      public int swim(int charge, double xo, double yo, double zo, double momentum, double theta, double phi, IStopper stopper, IRkListener listener, double maxPathLength, double stepSize, double[] relTolerance, double[] hdata) throws RungeKuttaException
      Swims a charged particle for the listener mode, where a callback is called for each advance of the integration Uses an adaptive stepsize algorithm.
      Parameters:
      charge - the charge: -1 for electron, 1 for proton, etc
      xo - the x vertex position in meters
      yo - the y vertex position in meters
      zo - the z vertex position in meters
      momentum - initial momentum in GeV/c
      theta - initial polar angle in degrees
      phi - initial azimuthal angle in degrees
      stopper - an optional object that can terminate the swimming based on some condition
      listener - a callback object that is called on every step
      maxPathLength - in meters. This determines the max number of steps based on the step size. If a stopper is used, the integration might terminate before all the steps are taken. A reasonable value for CLAS is 8. meters
      stepSize - the initial step size in meters.
      relTolerance - the error tolerance as fractional diffs. Note it is a vector, the same dimension of the problem, e.g., 6 for [x,y,z,vx,vy,vz]. It might be something like {1.0e-10, 1.0e-10, 1.0e-10, 1.0e-8, 1.0e-8, 1.0e-8}
      hdata - if not null, should be double[3]. Upon return, hdata[0] (m) is the min stepsize used, hdata[1] (m) is the average stepsize used, and hdata[2] (m) is the max stepsize used
      Returns:
      the total number of steps taken
      Throws:
      RungeKuttaException
    • swim

      public SwimTrajectory swim(int charge, double xo, double yo, double zo, double momentum, double theta, double phi, IStopper stopper, double maxPathLength, double stepSize, double tolerance, double[] hdata) throws RungeKuttaException
      Swims a charged particle. This is for the trajectory mode, where you want to cache steps along the path. Uses an adaptive stepsize algorithm.
      Parameters:
      charge - the charge: -1 for electron, 1 for proton, etc
      xo - the x vertex position in meters
      yo - the y vertex position in meters
      zo - the z vertex position in meters
      momentum - initial momentum in GeV/c
      theta - initial polar angle in degrees
      phi - initial azimuthal angle in degrees
      stopper - an optional object that can terminate the swimming based on some condition
      maxPathLength - in meters. This determines the max number of steps based on the step size. If a stopper is used, the integration might terminate before all the steps are taken. A reasonable value for CLAS is 8. meters
      stepSize - the initial step size in meters.
      tolerance - the required accuracy, something like 1.0e07
      hdata - if not null, should be double[3]. Upon return, hdata[0] (m) is the min stepsize used, hdata[1] (m) is the average stepsize used, and hdata[2] (m) is the max stepsize used Swims a Lund particle. This is for the trajectory mode, where you want to cache steps along the path. Uses an adaptive stepsize algorithm.
      Throws:
      RungeKuttaException
    • swim

      public int swim(int charge, double xo, double yo, double zo, double momentum, double theta, double phi, IStopper stopper, IRkListener listener, double maxPathLength, double stepSize, double tolerance, double[] hdata) throws RungeKuttaException
      Swims a Lund particle for the listener mode, where a callback is called for each advance of the integration Uses an adaptive stepsize algorithm.
      Parameters:
      charge - the charge: -1 for electron, 1 for proton, etc
      xo - the x vertex position in meters
      yo - the y vertex position in meters
      zo - the z vertex position in meters
      momentum - initial momentum in GeV/c
      theta - initial polar angle in degrees
      phi - initial azimuthal angle in degrees
      stopper - an optional object that can terminate the swimming based on some condition
      listener - a callback object that is called on every step
      maxPathLength - in meters. This determines the max number of steps based on the step size. If a stopper is used, the integration might terminate before all the steps are taken. A reasonable value for CLAS is 8. meters
      stepSize - the initial step size in meters.
      tolerance - the required accuracy, something like 1.0e07
      hdata - if not null, should be double[3]. Upon return, hdata[0] (m) is the min stepsize used, hdata[1] (m) is the average stepsize used, and hdata[2] (m) is the max stepsize used
      Returns:
      the total number of steps taken
      Throws:
      RungeKuttaException
    • swim

      public int swim(int charge, double xo, double yo, double zo, double momentum, double theta, double phi, IRkListener listener, double rmax, double maxPathLength, double stepSize)
      Swims a Lund particle with a built it stopper for the maximum value of the radial coordinate. This is for the listener method, where a callback is called for each advance of the integration Uses a fixed stepsize algorithm.
      Parameters:
      charge - the charge: -1 for electron, 1 for proton, etc
      xo - the x vertex position in meters
      yo - the y vertex position in meters
      zo - the z vertex position in meters
      momentum - initial momentum in GeV/c
      theta - initial polar angle in degrees
      phi - initial azimuthal angle in degrees
      listener - a callback object that is called on every step
      rmax - the max radial coordinate in meters.
      maxPathLength - in meters. This determines the max number of steps based on the step size. all the steps are taken. A reasonable value for CLAS is 8. meters
      stepSize - the uniform step size in meters.
      Returns:
      the total number of steps taken
    • swimBackwardsToVertex

      public static SwimTrajectory swimBackwardsToVertex(int q, double xo, double yo, double zo, double px, double py, double pz)
      Parameters:
      q - the charge: -1 for electron, 1 for proton, etc
      xo - the x start position in meters
      yo - the y start position in meters
      zo - the z start position in meters
      px - the x start momentum in GeV/c
      py - the y start momentum in GeV/c
      pz - the z start momentum in GeV/c