% Read in by FEYNMANDOC:  FEYNMANDOC4A.  Called by FD4A.COM
\chapter{Advanced Features}
% placement:  \advance,\negate,\multroothalf etc., \phantom, \boxlengths
% links:  lines,vertices
% stems:  lines,vertices
% caps:   lines,vertices
% loops
% saving and re-using:  \Xone, \newcount etc.; \drawandsave, \savebox etc.
% internal variables available:  \vertexcount etc., \unitheights etc.
% internal codes: \N==0 etc.
% errors:  FEYNMAN-defined; TeX-defined
%
This chapter describes a number of techniques and commands, some alluded to
earlier, which may be employed by the user to aid him or her in producing
the desired Feynman diagram as closely and quickly as possible.

\section{Placing It Where You Want It}

\FEYNMAN\ has been designed in such a way that particle lines may
be drawn in relation with one another with a minimum of effort.
Instances invariably arise, however, where the simple commands defined
thus far become inadequate to the task.  The user might then be condemned
to perform some algebra or, much worse, to experiment with the positions
of lines and vertices in order to make the appropriate lines connect
or place labels in the desired positions.

Fortunately a number of features and tricks are available to reduce
this unwanted tedium.

\subsection{Arithmetic Operations:  Manipulating Returned Parameters}

The most common placement problems occur when labels are used or
closed structures, such as loops, are included.  We've seen numerous
examples of loops.  Those which involve fermions and, to a lesser extent
scalars, are most easily constructed.  Re-examining the example in section
2.10.2 and the problems posed at the conclusions of sections
2.9.2, 2.10.2, and 2.12 we note one thing in common.  Each involves
drawing a fermion which is the same (or a simple constant times the) length 
of a gluon or photon.  These make use of the various \verb@\length@
parameters which are returned when a line is drawn: \verb@\gluonlengthx@,
\verb@\gluonlengthy@, \verb@\photonlengthx@, \verb@\photonlengthy@,
\verb@\fermionlengthx@, \verb@\fermionlengthy@, \verb@\scalarlengthx@, and
\verb@\scalarlengthy@, as well as \verb@\plengthx@ and 
\verb@\plengthy@, which correspond to the previous line.
Each of these has a sign and magnitude depending upon the direction drawn.
\verb@\fermionlength@ is an especially useful additional measure whose length
is always positive and equal to the entire length of the previously 
drawn fermion.
It is often more difficult to prepare loops when the \ddrawvertex\ statement
has been used since only the length of one line is recorded.  This was evident
in the example is section 3.8.2.

It is often desirable to know the separation of two arbitrary points,
perhaps on two different Feynman diagrams or between points in
different sub-branches of a single diagram.  Since these points will, in
general, be at co-ordinates unknown to the user,
the ability to perform simple arithmetic within the \TeX\ file is needed.

\TeX\ defines the following useful commands:
\begin{verbatim}

\global\advance  <variable name> by <increment  (number or variable)>
\global\multiply <variable name> by <multiplier (number or variable)>
\global\divide   <variable name> by <divisor    (number or variable)>

\end{verbatim}
where, as usual, \verb@<,>@ are not part of the syntax.  
In addition \FEYNMAN\ provides:
\begin{verbatim}

\negate       <variable name>
\double       <variable name>
\multroothalf <variable name>

\end{verbatim}

In each case the variable name, such as \bs fermionlength, will be an
integer and the result will be an integer (rounded).  The first three
add, multiply and divide respectively.  The second three multiply by minus
one, multiply by two, and multiply by $\frac{1}{\sqrt2}$ respectively.
Each represents an {\em action}, not a result.
Thus to subtract \bs Y from \bs X you would enter
\begin{verbatim}

\negate\Y
\global\advance \X by \Y

\end{verbatim}
but {\bf not}:  \verb@\global\advance \X by \negate\Y@.  (For the
cognoscente you must expand the token ``\bs negate \bs Y'' first).
Note that \LaTeX\ defines the commands:
\begin{verbatim}

\newcounter{<variable name>}
\setcounter{<variable name><variable value}
\addtocounter{<variable name><increment>}

\end{verbatim}
but that \verb@\addtocounter@ should not be used with \FEYNMAN\ unless
the variable has been user-defined (see section 4.2) {\em with \bs newcounter}.

As an example consider labelling the midpoint of a particle line.  Suppose
that the following is desired:

\hskip 1.75in
\begin{picture}(8000,8000)
\drawline\photon[\NE\REG](0,0)[10]
\global\advance\pmidx by 650
\global\advance\pmidy by -450
\put(\pmidx,\pmidy){$\gamma$}
\end{picture}
\bigskip

Where the label is at the midpoint of the photon on the lower side.
The {\it true} (geometric) midpoint is at the co-ordinates
(\bs pmidx,\bs pmidy).  However if we try:
\begin{verbatim}

\begin{picture}(8000,8000)
\drawline\photon[\NE\REG](0,0)[10]
\put(\pmidx,\pmidy){$\gamma$}
\end{picture}

\end{verbatim}
we'd produce:

\hskip 1.75in
\begin{picture}(8000,8000)
\drawline\photon[\NE\REG](0,0)[10]
\put(\pmidx,\pmidy){$\gamma$}
\end{picture}
\medskip

One would like to move the `$\gamma$' about two millimeters to the right and
about one and a half millimeters down.  This may be readily accomplished
with:
\begin{verbatim}

\begin{picture}(8000,8000)
\drawline\photon[\NE\REG](0,0)[10]
\global\advance\pmidx by 650
\global\advance\pmidy by -450
\put(\pmidx,\pmidy){$\gamma$}
\end{picture}

\end{verbatim}
The exact values used are a question of style and one will frequently
experiment to achieve particular \ae stetics.

A frequent use of \bs multroothalf occurs when one desires to make
a horizontal or vertical line the same length as a slanted line
(or vice-versa).  As a simple exercise, reproduce the following diagram
for Delbr\"uck scattering where all lines are of precisely the same
length.  Begin by drawing a photon.

\vskip-0.25in \hskip 0.75in
\begin{picture}(10000,10000)(0,0)
\drawline\photon[\SE\FLIPPED](0,5000)[6]
\double\photonlengthx  \multroothalf\photonlengthx  
\drawline\fermion[\E\REG](\photonbackx,\photonbacky)[\photonlengthx]
\drawline\photon[\NE\REG](\pbackx,\pbacky)[6]
\drawline\fermion[\S\REG](\photonfrontx,\photonfronty)[\fermionlength]
\drawline\photon[\SE\FLIPPED](\pbackx,\pbacky)[6]
\drawline\fermion[\W\REG](\photonfrontx,\photonfronty)[\fermionlength]
\drawline\photon[\SW\REG](\pbackx,\pbacky)[6]
\drawline\fermion[\N\REG](\photonfrontx,\photonfronty)[\fermionlength]
\end{picture}
%\vskip 0.5in \vskip 0.75in
\vskip 1.35in
As a final example we consider the following case, which is the lowest order
QED correction to Coulomb scattering of a lepton from a nucleus
which distinguishes between a positron and an electron.
\vskip 0.25in
\hskip 0.75in
\begin{picture}(10000,10000)(0,0)
\THICKLINES
\drawline\photon[\NE\REG](5000,0)[6]
\multiply\unitboxheight by 3
\multroothalf\unitboxheight 
\drawline\fermion[\E\REG](\photonbackx,\photonbacky)[\unitboxheight]
\drawline\fermion[\NW\REG](\photonbackx,\photonbacky)[\fermionlength]
\drawline\fermion[\N\REG](\fermionbackx,\fermionbacky)[\fermionlength]
\drawline\photon[\SW\FLIPPED](\fermionfrontx,\fermionfronty)[9]
\drawline\fermion[\E\REG](\photonbackx,\photonbacky)[7000]
\drawline\fermion[\W\REG](\photonbackx,\photonbacky)[3000]
\drawline\fermion[\E\REG](\fermionbackx,-500)[10000]
\drawline\fermion[\W\REG](\fermionbackx,-1000)[10000]
\end{picture}
%\vskip 0.2in
\newpage
%Here the problem is how to space the two photon lines such that 
%an integral number of half-wiggles (three in this case)
Here the problem is how to space the two photon lines, which differ in length
by three half-wiggles, such that both will connect smoothly
to the fermions.  To facilitate this we introduce
two new variables which are returned by \ddrawline\ and \ddrawvertex\ 
(and also by \bs drawloop):  \bs {\it unitboxwidth} and \bs {\it unitboxheight}.
They are (respectively) the width and height (x and y extents) of
the {\bf smallest complete unit} of the previously line.
For a gluon this is one loop, for a photon an {\em entire} wiggle,
for a scalar one segment plus one gap and for a fermion the entire length.
Of course one can equally well use a
\begin{verbatim}
\global\divide\gluonlengthx by <number of loops>
\end{verbatim}
and so forth to obtain the equivalent value.
Using these the above may be quickly drawn:
\begin{verbatim}

\hskip 0.75in
\begin{picture}(10000,10000)(0,0)
\THICKLINES
\drawline\photon[\NE\REG](5000,0)[6]
\multiply\unitboxheight by 3
\multroothalf\unitboxheight 
\drawline\fermion[\E\REG](\photonbackx,\photonbacky)[\unitboxheight]
\drawline\fermion[\NW\REG](\photonbackx,\photonbacky)[\fermionlength]
\drawline\fermion[\N\REG](\fermionbackx,\fermionbacky)[\fermionlength]
\drawline\photon[\SW\FLIPPED](\fermionfrontx,\fermionfronty)[9]
\drawline\fermion[\E\REG](\photonbackx,\photonbacky)[7000]
\drawline\fermion[\W\REG](\photonbackx,\photonbacky)[3000]
\drawline\fermion[\E\REG](\fermionbackx,-500)[10000]
\drawline\fermion[\W\REG](\fermionbackx,-1000)[10000]
\end{picture}

\end{verbatim}
Since ``\bs particlelengthx'', \etc represent the {\em extent}, or increment,
of the previous line they are often negative.  For a gluon drawn in the \bs SW
direction, for instance, both \bs gluonlengthx and \bs gluonlengthy are 
negative.   When using these to compare lengths one must generally employ
the ``\bs negate'' command.  An alternative is to use \bs {\em boxlengthx}
and \bs {\em boxlengthy} which give the {\em absolute magnitudes}
of the length parameters.  There are a few instances, however,
where the two might not match (see the sections on stems and caps).

The placement of arrows sometimes requires fine adjustments as well.
As an additional exercise try to draw the following as closely as possible.
Use a 12-point document size.

\begin{center}
Drell-Yan W-Production

\begin{picture}(10000,10000)
%\bigphotons
\THICKLINES
\drawline\photon[\E\REG](5000,5000)[11]
\drawarrow[\E\ATBASE](\pmidx,4820)
\put(\pmidx,5800){$W^+$}
\drawline\fermion[\NW\REG](\photonfrontx,\photonfronty)[5500]
\drawarrow[\SE\ATBASE](\pmidx,\pmidy)
\put(3500,7100){q}
\drawline\fermion[\SW\REG](\photonfrontx,\photonfronty)[5500]
\drawarrow[\SW\ATBASE](\pmidx,\pmidy)
\put(3500,2300){$\overline{q}'$}
\drawline\fermion[\NE\REG](\photonbackx,\photonbacky)[5500]
\drawarrow[\SW\ATBASE](\pmidx,\pmidy)
\advance \pmidx by -1400
\put(\pmidx,7100){$e^+$}
\drawline\fermion[\SE\REG](\photonbackx,\photonbacky)[5500]
\drawarrow[\SE\ATBASE](\pmidx,\pmidy)
\advance \pmidx by -1200
\put(\pmidx,2300){$\nu$}
\end{picture}
\end{center}
