Next: Lines and Sequences with
Up: Beam Lines, Sequences, and
Previous: Reflection and Repetition
  Contents
  Index
Beam Line Sequences
A sequence of elements can easily be generated from a data base
using a command looking like
label:SEQUENCE,REFER=keyword,L=expression,REFPOS=name;
object-definition;
...;
object-definition;
ENDSEQUENCE;
It reads a sequence of element definitions,
compiles an object which resembles a beam line definition,
and gives it the name "label".
The resulting sequence can be used like a beam line.
The attributes of the sequence are:
- REFER
-
The reference points for the elements are specified by the REFER
attribute:
- REFER=CENTRE
-
The reference points are at the element centres (default).
- REFER=ENTRY
-
The reference points are at element entrances.
- REFER=EXIT
-
The reference points are at element exits.
- L
-
The length of the SEQUENCE can be given on the
SEQUENCE command,
or it may be entered with the ENDSEQUENCE command.
- REFPOS
-
Normally, the reference position for a nested sequence is defined by
the REFER attribute of the enclosing sequence,
but, if REFPOS is given, it specifies a unique
element in the sequence whose AT attribute becomes the
reference point for the sequence.
For each non-drift element in the sequence one element definition appears
following the SEQUENCE command and preceding the
ENDSEQUENCE command.
These look similar to ordinary element definitions,
but they may contain an optional specification to place the element:
class-name,AT=expression;
class-name,AT=expression,FROM=name;
class-name,DRIFT=expression;
object-name,class-name,AT=expression,attribute,...,attribute;
object-name,class-name,AT=expression,FROM=name,attribute,...,attribute;
object-name,class-name,DRIFT=expression,attribute,...,attribute;
The meaning of the AT specifications is:
- AT=expression
-
Place the element's entrance, centre, or exit at the specifiet
position.
- FROM=name
-
Interpret the AT specification as relative to the
unique element name.
- FROM=#S
-
Like omitting the FROM specification, AT is
relative to the beginning of the sequence.
- FROM=#E
-
The AT specification is relative to the end of the
sequence.
- FROM=PREVIOUS
-
The AT specification is relative to the previous element.
- FROM=NEXT
-
The AT specification is relative to the following element.
- DRIFT=expression
-
The element is preceded by a drift of the given length.
One should consider the following:
- The name class-name must be an element
class name,
it may optionally be preceded by a minus sign (-).
This inverts the order of the elements in the inserted object.
This makes sense only for a beam line or sequence.
- If the name object-name is not given,
MAD inserts the element specified by class-name.
In this case no further attributes are allowed.
- If there is a non-blank object-name,
this name should not be defined earlier in the data.
MAD then first makes a copy of class-name and gives it
the new name object-name.
Any further attributes override the attributes inherited from
class-name.b
- The elements must be entered in order of increasing position,
and they must not overlap.
Their positions are evaluated while reading the SEQUENCE
definition, and become constant values.
- A LINE or
SEQUENCE can be nested in another
SEQUENCE or LINE.
Within the SEQUENCE,
MAD generates the drift spaces for proper positioning.
Example:
// Define element classes for a simple cell:
B: SBEND,L=35.09,ANGLE = 0.011306116;
QF: QUADRUPOLE,L=1.6,K1=-0.02268553;
QD: QUADRUPOLE,L=1.6,K1=0.022683642;
SF: SEXTUPOLE,L=0.4,K2=-0.13129;
SD: SEXTUPOLE,L=0.76,K2=0.26328;
// Define the cell as a sequence:
CELL:SEQUENCE,L=79.0;
B1: B, AT=19.115;
SF1:SF,AT=37.42;
QF1:QF,AT=38.70;
B2: B, AT=58.255,ANGLE=-B1->ANGLE;
SD1:SD,AT=76.74;
QD1:QD,AT=78.20;
ENDSEQUENCE;
In this example all members of the sequence have a new name,
and MAD generates copies of the corresponding classes.
The bending magnet B1 is wrapped to change sign,
but its definition is still equal to B.
Thus B2, which has the negative field of B1,
has the same effect as the wrapped element B1.
Next: Lines and Sequences with
Up: Beam Lines, Sequences, and
Previous: Reflection and Repetition
  Contents
  Index
MAD User Guide, http://wwwslap.cern.ch/mad/