gov.sns.xal.model.alg
Class Tracker

java.lang.Object
  |
  +--gov.sns.xal.model.alg.Tracker
All Implemented Interfaces:
IAlgorithm, IArchive, java.rmi.Remote
Direct Known Subclasses:
DiagnosticTracker, EnsembleTracker, EnvelopeTracker, EnvTrackerAdapt, EnvTrackerAdapt1, EnvTrackerAdapt2, ParticleResponse, ParticleTracker, SynchronousTracker, Trace3dTracker, TransferMapTracker

public abstract class Tracker
extends java.lang.Object
implements IAlgorithm, IArchive

Abstract base class for tracking algorithms, classes implementing the IAlgorithm interface. Provides common functionality of all algorithms. Derived classes must implement a the validate() method to identify all probes that they can handle. They must also implement the advanceState() method to provide the actual dynamics of the algorithm.


Field Summary
static java.lang.String ATTRTAG_DEBUG
          attribute tag for debugging flag
static java.lang.String ATTRTAG_TYPE
          attribute tag for the algorithm type identifier
static java.lang.String ATTRTAG_UPDATE
          attribute tag for trajectory state update policy
static java.lang.String ATTRTAG_VER
          attribute tag for the algorithm version number
static java.lang.String CALC_RFGAP_PHASE
          flag to update the beam phase in RF gaps ( a la parmila) rather than use default values
static java.lang.String NODETAG_ALG
          data node tag for the algorithm root
static java.lang.String NODETAG_TRACKER
          data node tag for common data
static java.lang.String NODETAG_TRAJ
          data node tag for trajectory parameters
static int UPDATE_ALWAYS
          save every state whenever probe is moved
static int UPDATE_CUSTOM
          never update - this is done comstomly somewhere else
static int UPDATE_ENTRANCE
          save state at element entrance
static int UPDATE_ENTRANCEANDEXIT
          save state at element exit and entrance
static int UPDATE_EXIT
          save state at element exit only
 
Constructor Summary
protected Tracker(java.lang.String strType, int intVersion, java.lang.Class clsProbeType)
          Creates a new instance of Tracker.
 
Method Summary
protected  void advanceProbe(IProbe probe, IElement elem, double dblLen)
          Standard propagation dynamics for all probes.
abstract  void doPropagation(IProbe probe, IElement elem)
          Propagates the probe through the element according to the dynamics of the specific algorithm.
 IArchive getArchive()
          Return the archiving interface for this object.
 boolean getDebugMode()
          Indicate whether or not algorithm is in debug mode.
protected  double getElemPosition()
          Return the current position within the element through which the probe is being propagated
 int getProbeUpdatePolicy()
          Return the probe trajectory updating policy.
 java.lang.String getStartElementId()
          Get the modeling element string identifier where propagation is to start.
 java.lang.String getStopElementId()
          Get the modeling element string identifier where propagation is to stop.
 java.lang.String getType()
          Return the algorithm type.
 int getVersion()
          Returns the version number of this algorithm
 void initialize()
          Initializes the algorithm to begin a new propagation cycle.
 void load(DataAdaptor daptArchive)
          Load the state and settings of this aglorithm from a data source exposing the DataAdaptor interface.
 void propagate(IProbe probe, IElement elem)
          Propagates the probe through the element.
protected  void registerProbeType(java.lang.Class clsProbeType)
          Register the class of a probe recognized by this algorithm.
 void save(DataAdaptor daptArchive)
          Save the state and settings of this algorithm to a data source exposing the DataAdaptor interface.
 void setDebugMode(boolean bolDebug)
          Set or clear the debugging mode flag.
protected  void setElemPosition(double dblPosElem)
          Set the current position with the element though which the probe is being propagated.
 void setProbeUpdatePolicy(int enmPolicy)
          Set the frequency of probe trajectory updates.
 void setStartElementId(java.lang.String id)
          Sets the element from which to start propagation.
 void setStopElementId(java.lang.String id)
          Sets the element at which to stop propagation.
 void unsetStartElementId()
          reset the Start Element Id to null
 void unsetStopElementId()
          reset the Stop Element Id to null
 boolean useRfGapPhaseCalculation()
          indicates whether to calculate the beam phase in multi gap Rf cavities, (a la Parmila) rather than use default values (a la Trace 3D)
protected  boolean validElement(IElement elem)
          Check if the specified element is requires probe propagating.
 boolean validProbe(IProbe ifcProbe)
          Check if probe can be handled by this algorithm.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UPDATE_CUSTOM

public static final int UPDATE_CUSTOM
never update - this is done comstomly somewhere else

See Also:
Constant Field Values

UPDATE_ALWAYS

public static final int UPDATE_ALWAYS
save every state whenever probe is moved

See Also:
Constant Field Values

UPDATE_EXIT

public static final int UPDATE_EXIT
save state at element exit only

See Also:
Constant Field Values

UPDATE_ENTRANCE

public static final int UPDATE_ENTRANCE
save state at element entrance

See Also:
Constant Field Values

UPDATE_ENTRANCEANDEXIT

public static final int UPDATE_ENTRANCEANDEXIT
save state at element exit and entrance

See Also:
Constant Field Values

NODETAG_ALG

public static final java.lang.String NODETAG_ALG
data node tag for the algorithm root

See Also:
Constant Field Values

ATTRTAG_TYPE

public static final java.lang.String ATTRTAG_TYPE
attribute tag for the algorithm type identifier

See Also:
Constant Field Values

ATTRTAG_VER

public static final java.lang.String ATTRTAG_VER
attribute tag for the algorithm version number

See Also:
Constant Field Values

NODETAG_TRACKER

public static final java.lang.String NODETAG_TRACKER
data node tag for common data

See Also:
Constant Field Values

ATTRTAG_UPDATE

public static final java.lang.String ATTRTAG_UPDATE
attribute tag for trajectory state update policy

See Also:
Constant Field Values

ATTRTAG_DEBUG

public static final java.lang.String ATTRTAG_DEBUG
attribute tag for debugging flag

See Also:
Constant Field Values

NODETAG_TRAJ

public static final java.lang.String NODETAG_TRAJ
data node tag for trajectory parameters

See Also:
Constant Field Values

CALC_RFGAP_PHASE

public static final java.lang.String CALC_RFGAP_PHASE
flag to update the beam phase in RF gaps ( a la parmila) rather than use default values

See Also:
Constant Field Values
Constructor Detail

Tracker

protected Tracker(java.lang.String strType,
                  int intVersion,
                  java.lang.Class clsProbeType)
Creates a new instance of Tracker. Note that if the child algorithm may handle more than one probe type the additional types should be registered using the method registerProbeType() in the constructor.

Parameters:
strType - string type identifier of algorithm
intVersion - version of algorithm
clsProbeType - class object for probe handled by this algorithm.
Method Detail

doPropagation

public abstract void doPropagation(IProbe probe,
                                   IElement elem)
                            throws ModelException
Propagates the probe through the element according to the dynamics of the specific algorithm. Derived classes must implement this method but the Tracker base provided convenient methods for this implementation.

Parameters:
probe - probe to propagate
elem - element acting on probe
Throws:
ModelException - invalid probe type or error in advancing probe
See Also:
advanceProbe(gov.sns.xal.model.IProbe, gov.sns.xal.model.IElement, double), validProbe(gov.sns.xal.model.IProbe)

setProbeUpdatePolicy

public void setProbeUpdatePolicy(int enmPolicy)
Set the frequency of probe trajectory updates.

Parameters:
enmPolicy - probe update policy enumeration code

setDebugMode

public void setDebugMode(boolean bolDebug)
Set or clear the debugging mode flag.

Parameters:
bolDebug -

getProbeUpdatePolicy

public int getProbeUpdatePolicy()
Return the probe trajectory updating policy.

Returns:
enumeration code for the update policy

getDebugMode

public boolean getDebugMode()
Indicate whether or not algorithm is in debug mode.

Returns:
true if in debug mode

getStartElementId

public java.lang.String getStartElementId()
Get the modeling element string identifier where propagation is to start.

Returns:
string id if element is defined, null otherwise

getStopElementId

public java.lang.String getStopElementId()
Get the modeling element string identifier where propagation is to stop.

Returns:
string id if element is defined, null otherwise

useRfGapPhaseCalculation

public boolean useRfGapPhaseCalculation()
indicates whether to calculate the beam phase in multi gap Rf cavities, (a la Parmila) rather than use default values (a la Trace 3D)

Specified by:
useRfGapPhaseCalculation in interface IAlgorithm

getType

public java.lang.String getType()
Return the algorithm type.

Specified by:
getType in interface IAlgorithm

getVersion

public int getVersion()
Returns the version number of this algorithm

Specified by:
getVersion in interface IAlgorithm

validProbe

public boolean validProbe(IProbe ifcProbe)
Check if probe can be handled by this algorithm.

Specified by:
validProbe in interface IAlgorithm
Parameters:
ifcProbe - probe interface to be validated
Returns:
true if algorithm supports the probe type

setStartElementId

public void setStartElementId(java.lang.String id)
Sets the element from which to start propagation.

Specified by:
setStartElementId in interface IAlgorithm
Parameters:
id - String id of the element from which to start propagation

setStopElementId

public void setStopElementId(java.lang.String id)
Sets the element at which to stop propagation.

Specified by:
setStopElementId in interface IAlgorithm
Parameters:
id - String id of the element at which to stop propagation

initialize

public void initialize()
Initializes the algorithm to begin a new propagation cycle.

Specified by:
initialize in interface IAlgorithm
See Also:
IAlgorithm.initialize()

propagate

public void propagate(IProbe probe,
                      IElement elem)
               throws ModelException
Propagates the probe through the element.

Specified by:
propagate in interface IAlgorithm
Parameters:
probe - probe to propagate
elem - element acting on probe
Throws:
ModelException - invalid probe type or error in advancing probe

getArchive

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

Specified by:
getArchive in interface IAlgorithm
See Also:
IArchive

load

public void load(DataAdaptor daptArchive)
          throws DataFormatException
Load the state and settings of this aglorithm from a data source exposing the DataAdaptor interface. Subclasses should override this method to recover the data particular to there own operation.

Specified by:
load in interface IArchive
Parameters:
daptArchive - data source containing algorithm configuration
Throws:
DataFormatException - malformatted algorithm data
See Also:
gov.sns.tools.data.IArchive#load(gov.sns.tools.data.DataAdaptor)

save

public void save(DataAdaptor daptArchive)
Save the state and settings of this algorithm to a data source exposing the DataAdaptor interface. Subclasses should override this method to store the data particular to there own operation.

Specified by:
save in interface IArchive
Parameters:
daptArchive - data source to receive algorithm configuration
See Also:
gov.sns.tools.data.IArchive#save(gov.sns.tools.data.DataAdaptor)

advanceProbe

protected void advanceProbe(IProbe probe,
                            IElement elem,
                            double dblLen)
                     throws ModelException
Standard propagation dynamics for all probes. This method performs propagation tasks that are common to all probes. Advances the position, time, and the kinetic energy of the probe through a subsection of the specified element of the specified length.

Parameters:
probe - target probe whose position and energy will be modified.
elem - element acting on probe
dblLen - length of element subsection to advance through
Throws:
ModelException - unable to advance probe through element

validElement

protected boolean validElement(IElement elem)
Check if the specified element is requires probe propagating. That is, is the element within the specified start and stop positions defined with this algorithm.

Parameters:
elem - element interface to validate propagation
Returns:
true if we propagate, false if not

registerProbeType

protected void registerProbeType(java.lang.Class clsProbeType)
Register the class of a probe recognized by this algorithm. This method should be called in the constructor of all derived classes for each additional probe that the algorithm may propagate.

Parameters:
clsProbeType - class object of probe which this algorithm can propagate

getElemPosition

protected double getElemPosition()
Return the current position within the element through which the probe is being propagated

Returns:
the current element position in meters

setElemPosition

protected void setElemPosition(double dblPosElem)
Set the current position with the element though which the probe is being propagated.

Parameters:
dblPosElem - current element positin in meters

unsetStartElementId

public void unsetStartElementId()
reset the Start Element Id to null

Specified by:
unsetStartElementId in interface IAlgorithm

unsetStopElementId

public void unsetStopElementId()
reset the Stop Element Id to null

Specified by:
unsetStopElementId in interface IAlgorithm