Element Classes

The concept of element classes solves the problem of addressing instances of elements in the accelerator in a convenient manner. It will first be explained by an example. All the quadrupoles in the accelerator form a class QUADRUPOLE. Let us define three subclasses for the focussing quadrupoles, the defocussing quadrupoles, and the skewed quadrupoles:
MQF: QUADRUPOLE,L=LQM,K1=KQD;     ! Focussing quadrupoles
MQD: QUADRUPOLE,L=LQM,K1=KQF;     ! Defocussing quadrupoles
MQT: QUADRUPOLE,L=LQT;            ! Skewed quadrupoles
These classes can be thought of as new keywords which define elements with specified default attributes. We now use theses classes to define the real quadrupoles:
QD1: MQD;           ! Defocussing quadrupoles
QD2: MQD;
QD3: MQD;
 ...
QF1: MQF;           ! Focussing quadrupoles
QF2: MQF;
QF3: MQF;
 ...
QT1: MQT,K1S=KQT1;   ! Skewed quadrupoles
QT2: MQT,K1S=KQT2;
 ...
These quadrupoles inherit all unspecified attributes from their class. This allows to build up a hierarchy of objects with a rather economic input structure.

The full power of the class concept is revealed when object classes are used to select instances of elements for various purposes. Example:

select,flag=twiss,class=QUADRUPOLE; ! Select all quadrupoles for the
                                    ! Twiss TFS file

More formally, for each element keyword MAD maintains a class of elements with the same name. A defined element becomes itself a class which can be used to define new objects, which will become members of this class. A new object inherits all attributes from its class; but its definition may override some of those values by new ones. All class and object names can be used in range selections, providing a powerful mechanism to specify positions for matching constraints and printing.

hansg, January 24, 1997