This command builds a simulated energy spectrum of particles from a
 nuclear reaction, taking into account:
 1. Y(z): the concentration and/or nuclear encounter probability as a
    function of depth. Read from an ASCII file or an -.FLX file.
 2. The energy loss and straggling in the incoming trajectory,
    using Ziegler et al.'s stopping powers and Bohr straggling,
    or, read in from an -.FLX file.
 3. The energy loss and straggling in the outgoing trajectory,
    using Ziegler et al.'s stopping powers and Bohr straggling.
 4. X(E): the reaction cross section as a function of energy.
    Options: 0. uniform, or already included in Y(z).
             1. Rutherford cross section
             2. Read in from an ASCII file
 5. The detector resolution (FWHM).
 Restriction. An approximation is made that is only valid if the
  yield varies smoothly with energy, i.e. at any depth the cross
  section is assumed constant, although the energy has a distribution
  of finite width.

 Input: a. FLX file name (give <return> if not needed)
        b. ASCII file name (      "     "   "    "   )
        c. Random (=uniform) Y(z)? (type Yes or No)
        d. Random energy loss?     (Yes or No; if 'No': use simulated
                                               energy loss of FLX file)
        e. Random straggling?      ( ditto )
        f. Cross section type      (0,1,2; see above)
        g. The following input depends on the options chosen.
 If a cross section of type 1 was specified the program asks the
  subfile name in the ASCII file.
 If a non-random Y(z) was specified, the program asks what to read:
      1=ASCII file, 2=FLX file
      after option 1 a subfile name is asked, and also the value
       of the beam energy.
      after option 2 a sequence number is asked, and, only if needed,
       also the layer number and  atom species that is involved in the
 If a random Y(z) was specified, the program asks for the beam energy
  and also of the maximum depth in nm.

       h. Specify the reaction, example: 4He 28Si 4He 28Si
       i. phi-in, phi-out, theta (see also Note below)
          phi-in: the angle in degrees between the normal to
                  the surface and the incoming beam (< 90).
          phi-out: the angle between the normal and the outgoing
                  particles (< 90).
          theta:  the angle between the beam and the outgoing
                  particles (backwards = 180).
       j. substrate composition, example Si1O2
          density (g/cm3), average atomic number A
          If the substrate consists of a single element the
          density and A are nor asked, but looked up instead.
       l. Thickness of extra surface layer (nm)
          Fraction of bulk atoms in surface layer.
          (this is to "add" an extra surface peak to the Y(z) specified
           it does not take the different stopping into account)
       m. spectrum calibration (+ch where E=Emax, or, -keV/channel)
          zero crossing (E(keV) corresponding to ch 0)
       n. output spectrum for yield (spectrum is always 1024 channels )
       o. output spectrum for depth (spectrum is always 1024 channels )
       p. detector resolution (keV FWHM)
       q. Fin,Fuit: multiplicative factors for the stopping powers

LAYOUT of Y(z) ASCII subfile:

   **NAME     ( an identifier of 8 symbols maximum )
   NZ, depth step (nm).
   Y(i), i=1..NZ

LAYOUT of Cross Section ASCII subfile:

   NE*2, 0        (Note that  t w i c e the nr of values is given!!)
   E(i), i=1..NE
   X(i), i=1..NE  (X is cross section in arbitrary units)

Note about the choice of angles.

                   : DET :
                      M3    <---> depth
                        \__           .
                        /\  |||||    .
                          \ |       .
                           \|      .  ..M4
                            \     .  .:
          phi_out           |\   .  .:
                            | \ .  .:
                            | /
          phi_in            |/
                        __/ |
                         /\ ||||
                        /   ^
                      M1    SURFACE

This bit of ASCII art illustrates the choice of the angles phi_in, phi_out and theta used in RBSIM. M1 is the beam particle that is comes in with angle phi_in with respect to the normal to the surface. It hits target nucleus M2 and the detected reaction product M3 exits the sample with an angle phi_out with respect to the surface normal. The direction of M3 has an angle theta with respect to the beam.

Thus the incoming path length is depth/cos(phi_in), the outgoing path length is depth/cos(phi_out), and the reaction angle is theta (0 for forward scattering).

In a 2-dimensional world we would have theta + phi_in + phi_out = 180 in the situation as sketched, or, theta + phi_in - phi_out = 180 if the detector were on the other side of the normal.

In general the directions of beam, normal and detector cut an imaginary sphere of radius 1 in the corners of a spherical triangle with sides phi_in, phi_out, and (PI - theta). If the normal is in the same plane as beam and detector we get one of the cases above.

                  / |               This is a very poor picture.
          phi_out/  |
                /   |               The three lines represent the
               /    |
              /     |               sides of the spherical triangle
             /      |PI-theta
     normal /       |               formed by 3 unit vectors in the
            \       |
             \      |               directions of beam, normal,
              \     |
               \    |               detector.
         phi_in \   |
                 \  |
                  \ |