Class Tracker
- All Implemented Interfaces:
Remote
,IAlgorithm
,IArchive
,IContextAware
- Direct Known Subclasses:
DiagnosticTracker
,EnsembleTracker
,EnvelopeTrackerBase
,ParticleTracker
,SynchronousTracker
,Trace3dTracker
,TrackerAdaptive
,TransferMapTracker
,TwissTracker
Abstract Base Class for Tracking Algorithms
Provides boiler plate functionality for probe tracking algorithms from which more sophisticated algorithms may inherit.
Tracking algorithm objects are classes that implement the
IAlgorithm
interface. This class provides default
implementations for all methods of the IAlgorithm
interface.
Derived classes must implement the doPropagation() abstract
method in order to provide the actual dynamics of the algorithm. Note that
derived classes may wish to override the
propagate(IProbe, IElement)
method directly for complete control
of the propagation mechanism.
This class provides the methods the methods advanceProbe
and
retractProbe
for forward-propagating and back-propagating the
common probe properties upstream and downstream, respectively. (Common
properties meaning all properties except the defining state, which is clearly
unknowable by this class.) These methods are conveniences meant to be used in
the abstract method doPropagation
.
NOTES: CKA
· We might get a significant performance upgrade by eliminating the
calls to validElement(IElement)
and
validProbe(IProbe)
within the method
propagate(IProbe, IElement)
.
· Derived classes should call registerProbeType(Class)
in
order that the the validProbe()
method function properly, that
is, identify all probes that this class recognizes.
· Perhaps it's better to eliminate validProbe
as a safety
measure since, in the current implementation, each probe carries it's own
algorithm object. So the probe already knows it's valid.
- Author:
- Christopher K. Allen, Craig McChesney
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
attribute tag for debugging flagstatic final String
flag to update the beam phase in RF gaps ( a la parmila) rather than use default valuesstatic final String
attribute label for type string identifierstatic final String
attribute tag for trajectory state update policystatic final String
attribute tag for the algorithm version numberstatic final String
data node label for algorithm datastatic final String
data node tag for common datastatic final String
EditContext table name for Tracker Datastatic final String
Table record primary key namestatic final int
save every state whenever probe is movedstatic final int
never update - this is done custom somewhere elsestatic final int
save state at element entrancestatic final int
save state at element exit and entrancestatic final int
save state at element exit only -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
advanceProbe
(IProbe probe, IElement elem, double dblLen) Convenience method for common propagation dynamics for all probes.abstract void
doPropagation
(IProbe probe, IElement elem) The implementation must propagate the probe through the element according to the dynamics of the specific algorithm.boolean
Indicate whether or not algorithm is in debug mode.protected double
Return the current position within the element through which the probe is being propagatedThe implementation must propagate the probe through the element according to the dynamics of the specific algorithm.int
Return the probe trajectory updating policy.boolean
Indicates whether to calculate the beam phase in multi gap Rf cavities, (a la Parmila) rather than use default values (a la Trace 3D)Get the modeling element string identifier where propagation is to start.Get the modeling element string identifier where propagation is to stop.getType()
Return the algorithm type.int
Returns the version number of this algorithmvoid
Initializes the algorithm to begin a new propagation cycle.boolean
Returns the flag that indicates whether or not the stop element is propagated through.void
load
(String strPrimKeyVal, EditContext ecTableData) Load the parameters of thisIAlgorithm
object from the table data in the givenEditContext
.void
load
(DataAdaptor daSource) Load the state and settings of this algorithm from a data source exposing theDataAdaptor
interface.static IAlgorithm
newFromEditContext
(String strLocationId, AcceleratorSeq sequence) Deprecated.I want to discourage use of this method since it return the same "default" algorithm regardless the type of probe being used.static IAlgorithm
newFromEditContext
(AcceleratorSeq sequence) Deprecated.I want to discourage use of this method since it return the same "default" algorithm regardless the type of probe being used.static IAlgorithm
newInstance
(DataAdaptor daSource) Read the contents of the suppliedDataAdaptor
and return a new instance of the appropriateIAlgorithm
object initialized with the data source behind theDataAdaptor
interface.void
Propagates the probe through the elementprotected void
registerProbeType
(Class<? extends IProbe> clsProbeType) Register the class of a probe recognized by this algorithm.protected void
retractProbe
(IProbe probe, IElement elem, double dblLen) Override of xal.model.alg.Tracker#advanceProbe(xal.model.IProbe, xal.model.IElement, double)void
save
(DataAdaptor daptArchive) Save the state and settings of this algorithm to a data source exposing theDataAdaptor
interface.void
setDebugMode
(boolean bolDebug) Set or clear the debugging mode flag.void
setElemPosition
(double dblPosElem) Set the current position within the element though which the probe is being propagated.void
setIncludeStopElement
(boolean bolInclStopElem) Sets the flag that determines whether or not the propagation stops at the entrance of the stop element (if set), or at the exit of the stop node.void
setProbeUpdatePolicy
(int enmPolicy) Set the frequency of probe trajectory updates.void
setRfGapPhaseCalculation
(boolean tf) Toggle the RF phase calculation on or off.void
Sets the element from which to start propagation.void
Sets the element at which to stop propagation.void
reset the Start Element Id to nullvoid
reset the Stop Element Id to nullprotected 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
Methods inherited from interface xal.model.IAlgorithm
copy
-
Field Details
-
UPDATE_CUSTOM
public static final int UPDATE_CUSTOMnever update - this is done custom somewhere else- See Also:
-
UPDATE_ALWAYS
public static final int UPDATE_ALWAYSsave every state whenever probe is moved- See Also:
-
UPDATE_EXIT
public static final int UPDATE_EXITsave state at element exit only- See Also:
-
UPDATE_ENTRANCE
public static final int UPDATE_ENTRANCEsave state at element entrance- See Also:
-
UPDATE_ENTRANCEANDEXIT
public static final int UPDATE_ENTRANCEANDEXITsave state at element exit and entrance- See Also:
-
NODETAG_ALG
data node label for algorithm data- See Also:
-
ATTRTAG_TYPE
attribute label for type string identifier- See Also:
-
ATTRTAG_VER
attribute tag for the algorithm version number- See Also:
-
NODETAG_TRACKER
data node tag for common data- See Also:
-
ATTRTAG_UPDATE
attribute tag for trajectory state update policy- See Also:
-
ATTRTAG_DEBUG
attribute tag for debugging flag- See Also:
-
ATTRTAG_RFGAP_PHASE
flag to update the beam phase in RF gaps ( a la parmila) rather than use default values- See Also:
-
TBL_LBL_ALGORITHM
EditContext table name for Tracker Data- See Also:
-
TBL_PRIM_KEY_NAME
Table record primary key name- See Also:
-
-
Constructor Details
-
Tracker
Creates a new, empty, 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 algorithmintVersion
- version of algorithmclsProbeType
- class object for probe handled by this algorithm.
-
Tracker
Copy constructor for Tracker- Parameters:
sourceTracker
- Tracker that is being copied
-
-
Method Details
-
doPropagation
The implementation must propagate 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.NOTE:
The protected methodadvanceProbe(IProbe, IElement, double)
is available for derived classes. It is a convenience method for performing many of the common tasks in the forward propagation of any probe. Thus, its use is not required.- Parameters:
probe
- probe to propagateelem
- element acting on probe- Throws:
ModelException
- invalid probe type or error in advancing probe- See Also:
-
newInstance
Read the contents of the suppliedDataAdaptor
and return a new instance of the appropriateIAlgorithm
object initialized with the data source behind theDataAdaptor
interface.- Parameters:
daSource
-DataAdaptor
to read a Probe from- Returns:
- new IAlgorithm object initialized to the given data source
- Throws:
DataFormatException
- bad data format, error reading data
-
newFromEditContext
Deprecated.I want to discourage use of this method since it return the same "default" algorithm regardless the type of probe being used. Please refer to
.AlgorithmFactory
Load the sequence's model parameters for the adaptive tracker from the global XAL edit context, which is retrievable through the given
AcceleratorSeq
argument.The actual record used for the initializing data is taken as the that with the primary key having the name of the given
AcceleratorSeq
name.NOTE
· The returned algorithm type is that specified by the "type" attribute of the
<Algorithm>
table contained in themodel.params
file. The developer must ensure that the Probe and the Algorithm objects are of the correct type.- Parameters:
sequence
- sequence from which to retrieve the algorithms' parameters.- Returns:
- new IAlgorithm object initialized to the given table data
- Throws:
DataFormatException
- bad data format, error reading data- Since:
- > Oct 17, 2012
-
newFromEditContext
@Deprecated public static IAlgorithm newFromEditContext(String strLocationId, AcceleratorSeq sequence) Deprecated.I want to discourage use of this method since it return the same "default" algorithm regardless the type of probe being used. Please refer to
.AlgorithmFactory
Load the sequence's model parameters for the adaptive tracker from the global XAL edit context, which is retrievable through the given
AcceleratorSeq
argument.The record used to initialize the data is that with the primary key have the given value of the argument
strLocationId
.NOTE
· The returned algorithm type is that specified by the "type" attribute of the
<Algorithm>
table contained in themodel.params
file. The developer must ensure that the Probe and the Algorithm objects are of the correct type.- Parameters:
strLocationId
- The location ID of the entrance parameters to usesequence
- The sequence for which to get the adaptive tracker parameters.- Returns:
- new IAlgorithm object initialized to the given table data
- Throws:
DataFormatException
- bad data format, error reading data- Since:
- > Oct 17, 2012
-
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
-
isStopElementIncluded
public boolean isStopElementIncluded()Returns the flag that indicates whether or not the stop element is propagated through.- Returns:
true
indicates propagation stops after the stop element,false
indicates propagation stops before the stop element (entrance)- Since:
- Oct 20, 2014
-
getProbeType
The implementation must propagate 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.NOTE:
The protected methodadvanceProbe(IProbe, IElement, double)
is available for derived classes. It is a convenience method for performing many of the common tasks in the forward propagation of any probe. Thus, its use is not required.- Parameters:
probe
- probe to propagateelem
- element acting on probe- Throws:
ModelException
- invalid probe type or error in advancing probe- Since:
- Oct 20, 2014
-
getRfGapPhaseCalculation
public boolean getRfGapPhaseCalculation()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:
getRfGapPhaseCalculation
in interfaceIAlgorithm
- Returns:
true
if phase calculations are made,false
otherwise
-
getType
Return the algorithm type.- Specified by:
getType
in interfaceIAlgorithm
- Returns:
- name of the integration algorithm
-
getVersion
public int getVersion()Returns the version number of this algorithm- Specified by:
getVersion
in interfaceIAlgorithm
- Returns:
- version number of the integration algorithm
-
validProbe
Check if probe can be handled by this algorithm.- Specified by:
validProbe
in interfaceIAlgorithm
- Parameters:
ifcProbe
- probe interface to be validated- Returns:
- true if algorithm supports the probe type
-
getStartElementId
Get the modeling element string identifier where propagation is to start.- Specified by:
getStartElementId
in interfaceIAlgorithm
- Returns:
- string id if element is defined, null otherwise
-
getStopElementId
Get the modeling element string identifier where propagation is to stop.- Specified by:
getStopElementId
in interfaceIAlgorithm
- Returns:
- string id if element is defined, null otherwise
-
setRfGapPhaseCalculation
public void setRfGapPhaseCalculation(boolean tf) Toggle the RF phase calculation on or off.- Specified by:
setRfGapPhaseCalculation
in interfaceIAlgorithm
- Parameters:
tf
- flag for turning on/off the phase calculations
-
setStartElementId
Sets the element from which to start propagation.- Specified by:
setStartElementId
in interfaceIAlgorithm
- Parameters:
id
-String
id of the element from which to start propagation
-
setStopElementId
Sets the element at which to stop propagation.- Specified by:
setStopElementId
in interfaceIAlgorithm
- Parameters:
id
-String
id of the element at which to stop propagation
-
setIncludeStopElement
public void setIncludeStopElement(boolean bolInclStopElem) Sets the flag that determines whether or not the propagation stops at the entrance of the stop element (if set), or at the exit of the stop node. The later case is the default.- Specified by:
setIncludeStopElement
in interfaceIAlgorithm
- Parameters:
bolInclStopElem
- propagation stops after stop element iftrue
, before the stop element iffalse
- Since:
- Oct 20, 2014
-
unsetStartElementId
public void unsetStartElementId()reset the Start Element Id to null- Specified by:
unsetStartElementId
in interfaceIAlgorithm
-
unsetStopElementId
public void unsetStopElementId()reset the Stop Element Id to null- Specified by:
unsetStopElementId
in interfaceIAlgorithm
-
initialize
public void initialize()Initializes the algorithm to begin a new propagation cycle.- Specified by:
initialize
in interfaceIAlgorithm
- See Also:
-
propagate
Propagates the probe through the element
NOTE: CKA
· We might get a significant performance upgrade by eliminating the internal call to
.validProbe(IProbe)
· The methodvalidElement(IElement)}
needs to be called here in the current implementation. It is called for every element - Is there a better (faster) way?- Specified by:
propagate
in interfaceIAlgorithm
- Parameters:
probe
- probe to propagateelem
- element acting on probe- Throws:
ModelException
- invalid probe type or error in advancing probe
-
load
Load the parameters of thisIAlgorithm
object from the table data in the givenEditContext
. Here we load only the parameters specific to the base class. It is expected that Subclasses should override this method to recover the data particular to there own operation.- Specified by:
load
in interfaceIContextAware
- Parameters:
strPrimKeyVal
- primary key value specifying the name of the data recordecTableData
- EditContext containing table data- Throws:
DataFormatException
- bad data format - error in reading- See Also:
-
load
Load the state and settings of this algorithm from a data source exposing theDataAdaptor
interface. Subclasses should override this method to recover the data particular to there own operation.- Specified by:
load
in interfaceIArchive
- Parameters:
daSource
- data source containing algorithm configuration- Throws:
DataFormatException
- bad format in algorithm data- See Also:
-
save
Save the state and settings of this algorithm to a data source exposing theDataAdaptor
interface. Subclasses should override this method to store the data particular to there own operation. -
advanceProbe
Convenience method for common 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 probedblLen
- length of element subsection to advance through- Throws:
ModelException
- unable to advance probe through element
-
retractProbe
Override of xal.model.alg.Tracker#advanceProbe(xal.model.IProbe, xal.model.IElement, double)
This method is the converse of
advanceProbe(IProbe, IElement, double)
. Rather than forward propagating the probe through anIElement
object, the method back-propagates the probe object. These effects include the loss of kinetic energy, the decrement of lattice position, etc.NOTES: CKA
· In order to use this method the derived class must override thepropagate
method, since it default implementation forward propagates the probe.- Parameters:
probe
- beam probe to propagate backwardselem
- element through which beam is backwards propagateddblLen
- distance to backward propagate the beam- Throws:
ModelException
- error occured while trying to update the probe values (unlikely)- Since:
- Feb 3, 2009
- See Also:
-
validElement
Check if the specified element is requires probe propagating. That is, is the element within the specified start and stop boundaries defined with this algorithm object.
NOTE: CKA
· Maybe there is a better way of using start and stop elements.- Parameters:
elem
- element interface to validate propagation- Returns:
- true if we propagate, false if not
-
registerProbeType
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
public void setElemPosition(double dblPosElem) Set the current position within the element though which the probe is being propagated.- Parameters:
dblPosElem
- current element position in meters
-