gov.sns.xal.model.probe
Class Probe

java.lang.Object
  |
  +--gov.sns.xal.model.probe.Probe
All Implemented Interfaces:
IArchive, IProbe
Direct Known Subclasses:
BeamProbe, DiagnosticProbe, ParticleProbe, Perturbation, SynchronousProbe, TransferMapProbe

public abstract class Probe
extends java.lang.Object
implements IProbe, IArchive

Provides a base class implementation of the IProbe interface that is useful for most standard probe types. This class provides most of the functionality necessary for the implementation of the IProbe interface, except a definition and implementation of a probe "state". Thus, it is up to base classes to provide and implement the particular aspect of a beam the probe represents.


Field Summary
static java.lang.String PROBE_LABEL
          element tag for probe data
 
Fields inherited from interface gov.sns.xal.model.IProbe
LightSpeed, Permittivity, UnitCharge
 
Constructor Summary
protected Probe()
          Creates a new instance of Probe.
protected Probe(IAlgorithm ifcAlg)
          Creates a new instance of Probe.
  Probe(Probe probe)
          Copy constructor for Probe.
 
Method Summary
 void applyState(ProbeState state)
          Apply the contents of ProbeState to update my current state.
protected  double computeBetaFromGamma(double gamma)
          Convenience function for computing the probe's velocity beta (w.r.t.
protected  double computeGammaFromBeta(double beta)
          Computes the relatavistic factor gamma from the current beta value
protected  double computeGammaFromW(double W)
          Convenience function for computing the relatistic factor gamma from the probe's kinetic energy (using the particle species rest energy m_dblParEr).
abstract  ProbeState createProbeState()
          Captures the probe's state in a ProbeState of the appropriate species.
protected abstract  Trajectory createTrajectory()
          Require concrete implementations to override this method to create a Trajectory object of the appropriate species.
protected  void deepCopyProbeBase(Probe probe)
          This is a convenience function for derived classes when implementing their deepCopy() method.
 IAlgorithm getAlgorithm()
          Return the algorithm defining the probes dynamics.
 IArchive getArchive()
          Return the archiving interface for this object.
 double getBeta()
          Returns the probe velocity normalized to the speed of light.
protected  double getBetaGamma()
          Convenience function for multiplication of beta * gamma
 java.lang.String getComment()
          Returns the comment string associated with the probe
 java.lang.String getCurrentElement()
          Returns the id of the current lattice element that the probe is visiting.
 double getGamma()
          Returns the relativistic parameter corresponding to the probe velocity.
 double getKineticEnergy()
          Return the kinetic energy of the probe.
 double getPosition()
          Returns the current beam-line position of the probe
 double getSpeciesCharge()
          Returns the charge of probe's particle species
 double getSpeciesRestEnergy()
          Returns the rest energy of particle species
 double getTime()
          Return the time elapsed since the probe began propagation.
 java.util.Date getTimestamp()
          Returns the time stamp of the probe.
 Trajectory getTrajectory()
          Get the state history of the probe.
 void initialize()
          Initializes the probe, resetting state as necessary.
 void load(DataAdaptor daptSource)
          Load the contents of a probe from an data archive represented by a DataAdaptor interface.
static Probe newProbeInitializedFrom(Probe probeInit)
          Clone factory method.
static Probe readFrom(DataAdaptor container)
          Read the contents of the supplied DataAdaptor and return an instance of the appropriate Probe species.
 void reset()
          Resets the probe to the saved initial state, if there is one and clears the m_trajHist.
 void save(DataAdaptor daptProbe)
          Save the contents of a probe to a data archive represented by a DataAdaptor interface.
 boolean setAlgorithm(IAlgorithm ifcAlg)
          Set the algorithm defining the probes dynamics through elements
 void setComment(java.lang.String strComment)
          Provide a user comment associated with the probe
 void setCurrentElement(java.lang.String id)
          Set the current lattice element id.
 void setKineticEnergy(double W)
          Set the current kinetic energy of the probe.
 void setPosition(double s)
          Set the current position of the probe along the beamline.
 void setSpeciesCharge(double q)
          Set the charge of the particle species in the beam
 void setSpeciesRestEnergy(double Er)
          Set the rest energy of a single particle in the beam
 void setTime(double dblTime)
          Set the current time since the probe began propagating
 void setTimestamp(java.util.Date dateStamp)
          Sets a time stamp for the probe.
 void setTracking(boolean bolTrack)
          Set particle m_trajHist tracking for probes.
 void update()
          Save the probe state into m_trajHist.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROBE_LABEL

public static final java.lang.String PROBE_LABEL
element tag for probe data

See Also:
Constant Field Values
Constructor Detail

Probe

protected Probe()
Creates a new instance of Probe. Since Probe is an abstract base only derived classes may call constructor.


Probe

protected Probe(IAlgorithm ifcAlg)
Creates a new instance of Probe. Since Probe is an abstract base only derived classes may call constructor.

Parameters:
ifcAlg - default dynamics algorithm for probe

Probe

public Probe(Probe probe)
Copy constructor for Probe. This constructor does a deep copy of the Probe base attributes by calling member support method deepCopyProbeBase().

Parameters:
probe - Probe object to be cloned
Method Detail

readFrom

public static Probe readFrom(DataAdaptor container)
                      throws ParsingException
Read the contents of the supplied DataAdaptor and return an instance of the appropriate Probe species.

Parameters:
container - DataAdaptor to read a Probe from
Returns:
a Probe for the contents of the DataAdaptor
Throws:
ParsingException - error encountered reading the DataAdaptor

newProbeInitializedFrom

public static Probe newProbeInitializedFrom(Probe probeInit)
Clone factory method. Creates a new Probe object, of the appropriate type, initialized to the argument Probe. NOTE: There is now a reset() method that is preferable to this one. It clears the probe m_trajHist and restores the initial state saved in the initialize() method, without creating a new probe instance.

Parameters:
probeInit - Probe object containing initial data
Returns:
new Probe object initialized to argument

createTrajectory

protected abstract Trajectory createTrajectory()
Require concrete implementations to override this method to create a Trajectory object of the appropriate species.

Returns:
a Trajectory of the appropriate species for this probe type

createProbeState

public abstract ProbeState createProbeState()
Captures the probe's state in a ProbeState of the appropriate species.


applyState

public void applyState(ProbeState state)
Apply the contents of ProbeState to update my current state. Subclass implementations should call super.applyState to ensure superclass state is applied.

Parameters:
state - ProbeState object containing new probe state data

setComment

public void setComment(java.lang.String strComment)
Provide a user comment associated with the probe

Parameters:
strComment - user comment string

setTimestamp

public void setTimestamp(java.util.Date dateStamp)
Sets a time stamp for the probe.

Parameters:
dateStamp - time stamp for probe

setSpeciesCharge

public void setSpeciesCharge(double q)
Set the charge of the particle species in the beam

Parameters:
q - species particle charge (Coulombs)

setSpeciesRestEnergy

public void setSpeciesRestEnergy(double Er)
Set the rest energy of a single particle in the beam

Parameters:
Er - particle rest energy (electron-volts)

setAlgorithm

public boolean setAlgorithm(IAlgorithm ifcAlg)
Set the algorithm defining the probes dynamics through elements

Parameters:
ifcAlg - object exposing the IAlgorithm interface

setTracking

public void setTracking(boolean bolTrack)
Set particle m_trajHist tracking for probes.

Parameters:
bolTrack - turn tracking on or off

getComment

public java.lang.String getComment()
Returns the comment string associated with the probe

Returns:
comment string

getTimestamp

public java.util.Date getTimestamp()
Returns the time stamp of the probe.

Returns:
time stamp

getTrajectory

public Trajectory getTrajectory()
Get the state history of the probe.

Returns:
Trajectory object of the proper sub-type for the probe type

getSpeciesCharge

public double getSpeciesCharge()
Returns the charge of probe's particle species

Specified by:
getSpeciesCharge in interface IProbe
Returns:
particle species charge (Coulombs)

getSpeciesRestEnergy

public double getSpeciesRestEnergy()
Returns the rest energy of particle species

Specified by:
getSpeciesRestEnergy in interface IProbe
Returns:
particle species rest energy (electron-volts)

getCurrentElement

public java.lang.String getCurrentElement()
Returns the id of the current lattice element that the probe is visiting.

Specified by:
getCurrentElement in interface IProbe
Returns:
id of current lattice element

getPosition

public double getPosition()
Returns the current beam-line position of the probe

Specified by:
getPosition in interface IProbe
Returns:
probe position (meters)

getTime

public double getTime()
Return the time elapsed since the probe began propagation.

Specified by:
getTime in interface IProbe
Returns:
elapsed time in seconds

getKineticEnergy

public double getKineticEnergy()
Return the kinetic energy of the probe. Depending upon the probe type, this could be the actual kinetic energy of a single constituent particle, the average kinetic energy of an ensemble, the design energy, etc.

Specified by:
getKineticEnergy in interface IProbe
Returns:
probe kinetic energy (electron-volts)

getBeta

public double getBeta()
Returns the probe velocity normalized to the speed of light.

Specified by:
getBeta in interface IProbe
Returns:
normalized probe velocity v/c (unitless

getGamma

public double getGamma()
Returns the relativistic parameter corresponding to the probe velocity. The relativistic factor is given by the formulae gamma = (Kinetic Energy/Rest Energy) + 1 = sqrt[1/(1-v^2/c^2)]

Specified by:
getGamma in interface IProbe
Returns:
probe relatistic factor (unitless)

setCurrentElement

public void setCurrentElement(java.lang.String id)
Set the current lattice element id.

Specified by:
setCurrentElement in interface IProbe
Parameters:
id - element id of current lattice element

setPosition

public void setPosition(double s)
Set the current position of the probe along the beamline.

Specified by:
setPosition in interface IProbe
Parameters:
s - new probe position (meters)
See Also:
getPosition

setTime

public void setTime(double dblTime)
Set the current time since the probe began propagating

Specified by:
setTime in interface IProbe
Parameters:
dblTime - new probe current time in seconds

setKineticEnergy

public void setKineticEnergy(double W)
Set the current kinetic energy of the probe.

Specified by:
setKineticEnergy in interface IProbe
Parameters:
W - new probe kinetic energy (electron-volts)
See Also:
getKineticEnergy

initialize

public void initialize()
Initializes the probe, resetting state as necessary.

Specified by:
initialize in interface IProbe

reset

public void reset()
Resets the probe to the saved initial state, if there is one and clears the m_trajHist.


update

public void update()
            throws ModelException
Save the probe state into m_trajHist.

Specified by:
update in interface IProbe
Throws:
ModelException - an error occurred while trying to update the probe

getAlgorithm

public IAlgorithm getAlgorithm()
Return the algorithm defining the probes dynamics.

Specified by:
getAlgorithm in interface IProbe
Returns:
interface to probe dynamics

getArchive

public IArchive getArchive()
Return the archiving interface for this object.

Specified by:
getArchive in interface IProbe
See Also:
IArchive

load

public void load(DataAdaptor daptSource)
          throws DataFormatException
Load the contents of a probe from an data archive represented by a DataAdaptor interface.

Specified by:
load in interface IArchive
Parameters:
daptSource - data archive containing probe info
Throws:
DataFormatException - bad probe type, missing child data node, or bad number format

save

public void save(DataAdaptor daptProbe)
Save the contents of a probe to a data archive represented by a DataAdaptor interface.

Specified by:
save in interface IArchive
Parameters:
daptProbe - data archive to receive probe information

deepCopyProbeBase

protected void deepCopyProbeBase(Probe probe)
This is a convenience function for derived classes when implementing their deepCopy() method. This functions deep copies all attributes in the Probe base class. The derived classes need only then deep copy all attributes particular to their type (e.g., state, etc.).

Parameters:
probe - probe object whose Probe base is to be deep copied into this

computeGammaFromBeta

protected double computeGammaFromBeta(double beta)
Computes the relatavistic factor gamma from the current beta value

Parameters:
beta - speed of probe w.r.t. the speed of light
Returns:
relatavistic factor gamma

computeGammaFromW

protected double computeGammaFromW(double W)
Convenience function for computing the relatistic factor gamma from the probe's kinetic energy (using the particle species rest energy m_dblParEr).

Parameters:
W - kinetic energy of the probe
Returns:
relatavistic factor gamma

computeBetaFromGamma

protected double computeBetaFromGamma(double gamma)
Convenience function for computing the probe's velocity beta (w.r.t. the speed of light) from the relatistic factor gamma.

Returns:
speed of probe (w.r.t. speed of light)

getBetaGamma

protected double getBetaGamma()
Convenience function for multiplication of beta * gamma