1 FUNCTION
  Syntax: FUNCTION command

  Does something with a function. See HELP FUNCTION Menu for a short
  description of each command. For a detailed help on the functions
  available see HELP FUNCTION LIST and its subtopics. When you are
  asked to give function number(s), 0 means all the defined or
  selected functions.

  Note that all Mn_Fit functions by default include the bin width in
  the calculation of the function value.  Thus, if you want to fit a
  histogram that is actually stored as a series of data points, then
  you have to make sure that `DX' for each point corresponds to the
  bin width.  You can use the `SET FUNCTION BIN_WIDTH ON|OFF' command
  to change whether the bin width is taken into account.

  The AREA under a fucntion is by default the area obtained by
  integrating from -infinity to +inifinity. You can change this AREA
  to be that of the plot (or othogonality) limits using the command
  `SET FUNCTION AREA LIMIT'. This command applies to all forms of
  Gaussian, Landau, Breit-Wigner and Crystal Ball functions.

2 Menu
  The following is a list of the available commands.
  For more details see HELP FUNCTION and the individual subtopics:

  ADD       Adds a new function.
  COMPILE   Compiles a COMIS function.
  DELETE    Deletes a function from the list.
  EDIT      Enables you to edit and recompile a COMIS function.
  FETCH     Fetches a function that has been stored in a file.
  HISTOGRAM Stores the fit in a histogram.
  HOVERLAY  Overlays a function as a histogram on a plot.
  INFO      Gets information on the functions used.
  LIST      Lists the predefined functions that you can add.
  OVERLAY   Overlays a function on a plot.
  PLOT      Plots one or more of the functions.
  STORE     Stores a function in a file.
  USE       Uses a function in the fit or not.

  `SET FUNCTION' has a number of subcommands that control how the 
  functions are used. See HELP SET FUNCTION for more details:
  
  AREA      Specifies whether the AREA is that inside the plot or over
            the whole valid range.
  BIN_WIDTH Controls whether the bin width is used when calculating
            the value of a function.
  POINTS    Sets the number of points used when drawing a function.
  INTEGRATE Sets the number of intervals used when integrating a function.
  STEP      Sets the step size used for differentiation of a function.

2 ADD
  Syntax: FUNCTION ADD nfun
   where: nfun  is either the function name or number

  Only valid in `MN_CMD>'.

  Selects a new  function to be  used for fitting  with or plotting. You
  will be prompted  for the initial  values of the  parameters.

  See HELP FUNCTION LIST for a list of the  available functions and the
  various   subtopics  for  details of  the  syntax for  USER  and COMIS
  functions and how to fit using histograms as functions.

  In general I recommend using the function name rather than the
  number, as the number may change at some point, if I add new
  functions.

  Several functions have names consisting of more than one word. If
  you add a new function using the name, then just give the first
  word. For 2-D functions use the syntax
  `FUNCTION ADD 2D GAUSS SIGMA'.

  For the lepton and hadron spectra you will be given a list of the
  functions and must then give the relevant number. This is the same
  as the function number.

2 COMPILE
  Syntax: FUNCTION COMPILE nfun
   where: nfun  is the function number as in FUNCTION INFO

  Only valid in `MN_CMD>'.

  Recompiles  a COMIS  function  which you have  already  added with the
  `FUNCTION ADD COMIS' command.

2 EDIT
  Syntax: FUNCTION EDIT nfun
   where: nfun  is the function number as in FUNCTION INFO

  Only valid in `MN_CMD>'.

  Invokes the  editor and  then recompiles  the COMIS  function you have
  already  added  with the   `FUNCTION ADD'  command. See HELP EDIT for
  details on the default editor.  You can change the editor with the
  `SET EDIT' command.

2 DELETE
  Syntax: FUNCTION DELETE nfun1 [nfun2 ...]
   where: nfun1  is the 1st function number to delete as in FUNCTION INFO
   where: nfun2  is the 2nd function number to delete etc.

  Only valid in `MN_CMD>'.

  Deletes one or more functions from the list of those you have added.
  `nfun = 0' will delete all functions that have been added.

2 FETCH
  Syntax: FUNCTION FETCH filename
   where: filename  is the name of the file containing the functions.

  Only valid in `MN_CMD>'.

  Fetches functions which you have previously stored from a file.

2 HISTOGRAM
  Syntax: FUNCTION HISTOGRAM nfun1 [nfun2...]
          [&]idb nsymb/col
          npoint xlo xhi
   where: nfun   is the function number(s) as in FUNCTION INFO
          idb    is the secondary identifier for the function
          nsymb  is the symbol you want to plot the function with
     and  col      is the (optional) colour for the symbol.

  Plots one  or more of  the  functions you  have added as  a histogram.
  `nfun = 0' means  use all  functions which are  currently in use. This
  command is the same as `FUN PLOT',  but the function will be stored as
  a histogram. If you are fitting and your last picture was a `DISPLAY',
  the function will be given the  same primary identifier as the one you
  are fitting. Otherwise it will be  given the primary identifier 98765.
  To specify the  secondary identifier on the  same line as the function
  numbers precede it by a `&'. It will be given the secondary identifier
  you specify.

2 HOVERLAY
  Syntax: FUNCTION HISTOGRAM nfun1 [nfun2...]
          [&]idb nsymb/col
   where: nfun   is the function number(s) as in FUNCTION INFO
          idb    is the secondary identifier for the function
          nsymb  is the symbol you want to plot the function with
     and  col    is the (optional) colour for the symbol.

  Overlays one or more  of the functions you  have added as a histogram.
  `nfun = 0' means  use all  functions which are  currently in use. This
  command is the same as `FUN  OVERLAY', but the function will be stored
  as a  histogram with  the same  number of  points as the  plot you are
  fitting. If you are fitting and your last picture was a `DISPLAY', the
  function will be given the same  primary identifier as the one you are
  fitting. Otherwise it  will be given the  primary identifier 98765. To
  specify  the secondary  identifier  on the  same line as  the function
  numbers precede it by a `&'. It will be given the secondary identifier
  you specify.

2 INFO
  Syntax: FUNCTION INFO

  Gives information on the functions you have selected, whether they are
  in use, whether they are signal or background, and the values of their
  parameters.

2 LIST
  Syntax: FUNCTION LIST

  Note that all Mn_Fit functions by default include the bin width in the
  calculation of the function value.
  You can use the `SET FUNCTION BIN_WIDTH ON|OFF' command to change
  this behaviour.

  List of the functions which are available:
   1 Polynomial
   2 Exponential
   3 Quadratic Joining Two Lines
   4 Chebyshev Polynomial
   5 Legendre Polynomial
   6 Gaussian Distribution (sigma)
   7 Gaussian Distribution (FWHM)
   8 Landau Distribution
   9 Breit-Wigner Distribution
  10 x-a Gaussian Distribution (sigma)
  11 x-a Gaussian Distribution (FWHM)
  12 Lepton Spectrum Phase Space
  13 Lepton Spectrum V-A
  14 Lepton Spectrum V+A
  15 Lepton Spectrum Spin 0->Spin 0
  16 Hadron Spectrum Phase Space
  17 Hadron Spectrum V-A or V+A
  18 Hadron Spectrum Spin 0->Spin 0
  19 Two Gaussians (sigma)
  20 Two Gaussians (FWHM)
  21 Bifurcated Gaussian (sigma)
  22 Bifurcated Gaussian (FWHM)
  23 Sum Two Bifurcated Gaussians (sigma)
  24 Sum Two Bifurcated Gaussians (FWHM)
  25 ARGUS background function - phase space going to 0 at beam energy
  26 Pexp(Q)  A polynomial multiplied by the exponential of a polynomial
  27 Trigonometric Functions
  28 CB Line Shape
  29 Power Law Function
  30 Lifetime Function
  31 OChebyshev Polynomial - parameter 1 is not overall normalization
  32 OLegendre Polynomial - parameter 1 is not overall normalization
  33 Fermi Function (positive going)
  34 Fermi Function (negative going)
  35 Threshold Function
  36 rCB Line Shape (reversed CB line shape with a high-energy tail)
  37 rARGUS background function (reversed ARGUS background - phase
     space going to 0 at a certain energy)
  38 Dipion Inv Mass
  39 Fragmentation Functions
  40 Resonance Cross Section
  41 Continuum Cross Section
  42 User Defined Function (see subtopic USER for details)
  43 Histogram used as a function
  44 Smooth Histogram used as a function
  45 COMIS defined function (see subtopic COMIS for details)
  46 Convolution function
  47 2D Gaussian Distribution (sigma)
  48 2D Gaussian Distribution (FWHM)

3 Polynomial

  Polynomial of any order with an offset.
  The form used is:
  BIN_WIDTH * (NORM + POLY01*(x-OFFSET) + POLY02*(x-OFFSET)**2 + ...)
!=

  The parameters are:
  NORM
  POLY01
  POLY02...
  OFFSET

  The parameter `OFFSET' is redundant and should usually be fixed to a
  convenient value.

3 Exponential

  Falling exponential with an offset. The form used is:
  NORM * EXP(-SLOPE * (x - OFFSET))

  The parameters are:
  NORM
  SLOPE
  OFFSET

  The parameter `OFFSET' is redundant and should usually be fixed to a
  convenient value.

3 Quadratic_Joining_Two_Lines

  Given  ordinate   `CONST' and  abscissa  `JOIN1'  of one  point on a
  straight  line of slope  `SLOPE1', it  finds a  quadratic curve that
  smoothly connects  this line at that point  to another straight line
  of slope  `SLOPE2'  at an  abscissa  `JOIN2'.  In terms  of the five
  parameters, the equation of the quadratic equation is:

  a + b*x + c*x**2
!=

  where  c = (SLOPE2 - SLOPE1)/(2.0*(JOIN2-JOIN1)
         b = (SLOPE1*JOIN2 - SLOPE2*JOIN1)/(JOIN2 - JOIN1)
         a = CONST - b*JOIN1 - c*JOIN2**2

  The constant term of the second straight line `(a2 + SLOPE2*x**2)' is:

  a2 = a +b*JOIN2 + c*JOIN2**2 - SLOPE2*JOIN2

  The parameters are:
  CONST
  SLOPE1
  SLOPE2
  JOIN1
  JOIN2

3 Chebyshev

  The Chebyshev is valid between  the minimum and maximum limits which
  are either set  to the plot  limits or can be  manually set with the
  `SET ORTHOG' command.

  The form used is:

  DELX = (2*X - XMIN - XMAX) / (XMAX - XMIN)
  1st term = NORM
  2nd term = CHEB01 * DELX
  3rd term = CHEB02 * (2*DELX*DELX - 1)
  4th term = CHEB03 * (2*DELX*(2*DELX*DELX - 1) - DELX)
  etc.

  and the function value is given by the sum of the terms.

  The first parameter is the overall normalization. This is new for
  version 4 of Mn_Fit. The previous form of the Chebyshev is in
  the function OChebyshev.

  The parameters are:
  NORM
  CHEB01
  CHEB02...

3 Legendre

  The Legendre  is valid between  the minimum and maximum limits which
  are either set  to the plot  limits or can be  manually set with the
  `SET ORTHOG' command.

  The first parameter is the overall normalization. This is new for
  version 4 of Mn_Fit. The previous form of the Legendre is in
  function OLegendre.

  The parameters are:
  NORM
  PARM01
  PARM02...

3 Gaussian

  Gaussians can be given either in terms of `SIGMA' or `FWHM'. They
  are normalised, so that the area is what it says. The form in terms
  of `SIGMA' is:

  AREA / (SQRT(2*PI) * SIGMA) * EXP( (X-MEAN)**2/(2*SIGMA**2)

  The parameters are:
  AREA
  MEAN
  SIGMA

  In terms of `FWHM' it is the same except for the scale factor between
  the two.

3 Landau

  Gives the Landau density function in the form:

  AREA * DENLAN( (X - XLAN)/ WIDTH)

  `DENLAN' is the CERN library routine for the Landau density function
  of a normalized variable.

  The parameters are:
  AREA
  XLAN
  WIDTH

  Note that `XLAN' is not actually the peak of the distribution, which
  is why its name was changed in Mn_Fit version 4.07/22. This
  is discussed in the long write-up for the `DENLAN' routine. The
  actual peak is at -0.222782*WIDTH below the parameter `XLAN'.

3 Breit_Wigner

  This is the Breit-Wigner signal shape.  Its form is:

    (1/2*pi) * (AREA * WIDTH) / ( (X-MEAN)**2 + (WIDTH**2)/4 )

  The function is bin-width normalized.

  The parameters are:
  AREA
  MEAN
  WIDTH

3 x-a_Gaussian

  Gaussians can be given either in terms of `SIGMA' or `FWHM'. They
  are normalised, so that the area is what it says. The form in terms
  of `SIGMA' is:

  AREA * (X-OFFSET) / (SQRT(2*PI) * SIGMA) * EXP( (X-MEAN)**2/(2*SIGMA**2)

  The parameters are:
  AREA
  MEAN
  SIGMA
  OFFSET

  In terms of `FWHM' it is the same except for the scale factor between
  the two.

3 Lepton_Spectra

  A series of lepton momentum spectra for semileptonic b and c meson
  decays are available.
  For all the spectra the parameters are:
  AREA
  MS/MC   Ratio of strange/charm mass, or charm/bottom mass
  SCALE1
  SCALE2

  Although the second parameter is called `MS/MC' it means the ratio
  of the relevant quark masses, i.e. `MC/MB', `MU/MB' etc.

  The form for the phase space is:

  NORM * VAL * (1 - (MS/MC)**2 - VAL) / (1 - VAL)
  where VAL = X*SCALE2/SCALE1

  i.e. the spectrum is by default between 0 and `(1-(MS/MC)**2)'. You
  should set `SCALE1' and `SCALE2' so that their ratio gives the b or
  c quark momentum for your data.

  The forms for (V-A), (V+A) and Spin 0 -> Spin 0 are a bit more
  complicated.

  I am not sure why there are 2 parameters `SCALE1' and `SCALE2'. As
  far as I can tell only the ratio is used. You should therefore
  decide what ratio is needed and fix the parameters accordingly.

3 Hadron_Spectra

  A series of hadron momentum spectra for semileptonic b and c meson
  decays are available.
  For all the spectra the parameters are:
  AREA
  MS/MC   Ratio of strange/charm mass, or charm/bottom mass
  SCALE1
  SCALE2

  Although the second parameter is called `MS/MC' it means the ratio
  of the relevant quark masses, i.e. `MC/MB', `MU/MB' etc.

  The form for the phase space is:

  NORM * VAL * SQRT(VAL**2 - 4*(MS/MC)**2)
  where VAL = X*SCALE2/SCALE1

  You should set `SCALE1' and `SCALE2' so that their ratio gives the b
  or c quark momentum for your data.

  It is not clear to me that the form for the hadron spectra is
  correct or where it comes from. In particular for the phase space
  and Spin 0 -> Spin 0 form it rises monotonically, while for the
  (V-A) and (V+A) functions it goes negative. I do not know where
  these forms came from (I originally got them from Paul Avery's
  MULFIT). Any input would be welcome.

  The forms for (V-A), (V+A) and Spin 0 -> Spin 0 are a bit more
  complicated.

  I am not sure why there are 2 parameters `SCALE1' and `SCALE2'. As
  far as I can tell only the ratio is used. You should therefore
  decide what ratio is needed and fix the parameters accordingly.

3 Two_Gaussians

  Gaussians can be given either in terms of `SIGMA' or `FWHM'. They
  are normalised, so that the area is what it says. The parameters for
  the 2 Gaussians are such that it is easy to fix the difference in
  the means, or the ratio of the widths. The parameters for the second
  Gaussian are `AREA2/AREA', `(MEAN2-MEAN1)' and `SIGMA2/SIGMA1'.
  The form of each Gaussian in terms of `SIGMA' is:

  AREA / (SQRT(2*PI) * SIGMA) * EXP( (X-MEAN)**2/(2*SIGMA**2)

  The parameters are:
  AREA
  MEAN
  SIGMA1
  AR2/AREA
  DELM
  SIG2/SIG1

  For the first Gaussian the area is `AREA * (1-AR2/AREA)'. For the
  second Gaussian the area is `AREA * (AR2/AREA)'. The mean of the first
  Gaussian is `MEAN', while the mean of the second Gaussian is
  `MEAN + DELM'. The width of the first Gaussian is `SIGMA1' and the
  width of the second is `SIGMA1 * (SIG2/SIG1)'.

  In terms of `FWHM' everything is the same except for the scale
  factor between the two.

3 Bifurcated_Gaussian

  A Gaussian with different slopes either side of the mean.
  The form used is:

  AREA * (2 * SIGA / (SIGA + SIGB)) / (SQRT(2 * PI) * SIGA) *
    EXP(-0.5 * (X - MEAN) / SIGA**2)                      for X <  MEAN
  AREA * (2 * SIGB / (SIGA + SIGB)) / (SQRT(2 * PI) * SIGB) *
    EXP(-0.5 * (X - MEAN) / SIGB**2)                      for X >= MEAN


  The parameters are:
  AREA
  MEAN
  SIGA
  SIGB

3 Sum_Two_Bifurcated_Gaussians

  The sum of two  Gaussians with  different slopes  either side of the
  mean. The  mean is the  same for both  Gaussians. The  form used for
  each Gaussian is:

  AREA * (2 * SIGA / (SIGA + SIGB)) / (SQRT(2 * PI) * SIGA) *
    EXP(-0.5 * (X - MEAN) / SIGA**2)                      for X <  MEAN
  AREA * (2 * SIGB / (SIGA + SIGB)) / (SQRT(2 * PI) * SIGB) *
    EXP(-0.5 * (X - MEAN) / SIGB**2)                       for X >= MEAN

  The parameters are:
  AREA
  MEAN
  SIGA1
  SIGB/SIGA
  AR2/AREA
  SIG2/SIG1

  The parametrization  uses `AR2/AREA' so  that you can fix the ratio
  of the  areas,  and  `SIGB/SIGA'  so you  can fix  the  ratio of the
  widths. In  addition the  ratio of  both  of the  widths for the two
  Gaussians is same and is the parameter `SIG2/SIG1'.

3 ARGUS_Background

  This function is the form ARGUS used to parametrize their background
  for fitting B mass peaks. The form used is:
  P(1) * (x + P(2)) * SQRT(1 - ((x + P(2)) / P(3))**2) *
   EXP(P(4) * (1 - ((x + P(2)) / P(3))**2))
  where P(1) is the normalization
        P(2) is an offset which should always be fixed when fitting
             If you plot the mass P(2) should be 0,
             but if you plot (Mass - Ebeam), P(2) should be Ebeam
        P(3) is the beam energy
        P(4) is a scale factor for the exponential (0 to not use it)

  The parameters are:
  NORM
  OFFSET
  EBEAM
  EFACT

  Use the command `SET FIT AREA ON' to get a normalised function, so that NORM
  is actually the area within the range of the histogram you are fitting.

3 rARGUS_Background

  This function is an inverted version of the form ARGUS used to
  parametrize their background
  for fitting B mass peaks. The form used is:
  P(1) * (x + P(2)) * SQRT(((x + P(2)) / P(3))**2 - 1) *
   EXP(P(4) * (((x + P(2)) / P(3))**2) - 1)
  where P(1) is the normalization
        P(2) is an offset which should always be fixed when fitting
             If you plot the mass P(2) should be 0,
             but if you plot (Mass - Ebeam), P(2) should be Ebeam
        P(3) is the value at which the function goes to zero
        P(4) is a scale factor for the exponential (0 to not use it)

  The parameters are:
  NORM
  OFFSET
  EZERO
  EFACT

  Use the command `SET FIT AREA ON' to get a normalised function, so that NORM
  is actually the area within the range of the histogram you are fitting.

3 Pexp(Q)

  This function can be used to combine a polynomial with the
  exponential of a polynomial. In each case the polynomial for is:

  NORM * (1 + POLY01*(X-OFFSET) + POLY02*(X-OFFSET)**2 + ...)

  The parameters are:
  NORM
  OFFSET
  POLY01
  POLY02...
  EPOLY01
  EPOLY02...

  The parameter `OFFSET' is redundant and should usually be fixed to a
  convenient value.

3 Trigonometric

  The form used is:
  ASINE * SIN(OMEGA * x) + ACOSINE * COS(OMEGA * x)

  The parameters are:
  ASINE
  ACOSINE
  OMEGA

3 CB_Line_Shape

  This function uses the NaI line shape as obtained by the Crystal Ball
  experiment. The form used is:
  AREA * exp( -.5*((Et-Em)/s)**2 )                    for Em > Et - a*s
  AREA * (n/a)**n * exp(-.5*a**2) /
   (((Et-Em)/s +n/a -a )**n)                          for Em < Et - a*s
  where
   1/A = s*( (n/a)*exp(-.5*a**2)/(n-1.) +
         sqrt(pi/2.)*(1.+erf(a/sqrt(2.)) ))
   Em is measured energy
   Et is true energy
   s(igma) is energy resolution
   n and a(lpha) are empirical parameters as far as I can tell.

  The parameters are:
  AREA
  MEAN
  SIGMA
  ALPHA
  N

  `N' controls the length of the tail to lower energies. Both `ALPHA' and
  `N' should be none-zero and `N' should I think be smaller than the
  `MEAN'. `ALPHA' should be positive (maybe fixed?) and says where the
  function starts to diverge from a normal Gaussian in units of `SIGMA'.

3 rCB_Line_Shape

  This function uses the NaI line shape as obtained by the Crystal
  Ball. However it is reversed from the CB line shape
  (see `HELP FUNCTION LIST CB_LINE_SHAPE for more details) and has a
  high-energy rather than a low energy tail.
  The form used is:
  AREA * exp( -.5*((Et-Em)/s)**2 )                    for Em > Et - a*s
  AREA * (n/a)**n * exp(-.5*a**2) /
   (((Et-Em)/s +n/a -a )**n)                          for Em < Et - a*s

3 Power_Law

  The form used is:
  NORM * (x / SLOPE)**POWER

  Note that there is no protection against `(x / SLOPE)**POWER'
  going into overflow.

  The parameters are:
  NORM
  POWER
  SLOPE

3 Lifetime

  Falling exponential with an offset for lifetime fitting.
  The form used is:
  AREA * ABS(SLOPE) * EXP(-SLOPE * (x - OFFSET))
  for (x - OFFSET) >= 0

  The parameters are:
  AREA
  LIFETIME
  OFFSET

  The parameter `OFFSET' is redundant and should usually be fixed to a
  convenient value.

  The function can also be combined with a resolution function by
  using the `SET FIT CONVOLUTE' command.

3 Fermi

  A Fermi function. This form is useful for threshold or efficiency
  turn ons. It can be selected as either positive or negative
  going. The positive going form used is:
  NORM / (1 + EXP((X-X0)/SLOPE))

  with `(X0-X)' for the negative going function.

  The parameters are:
  NORM
  X0
  SLOPE

  The function can also be combined with a resolution function by
  using the `SET FIT CONVOLUTE' command.

3 Threshold

  Threshold function. The form has a sharp rise followed by an exponential
  tail. The form used is:
  NORM * (X-OFFSET)**POWER * EXP(COEFF1*(X-OFFSET) + COEFF2*(X-OFFSET)**2)
  where NORM    is the normalization
        OFFSET  is the threshold
        POWER   is the power of the turnon
        COEFF1  is the coefficient linear in x
        COEFF2  is the coefficient quadratic in x

  As the function is not smooth at the threshold it seems to be better to
  fix `OFFSET', if all other parameters are left free. Alternatively
  it should be possible to fix the `POWER' and leave the offset free.

3 Dipion_Inv_Mass

  This is a set of  functions containing  theoretical formulae for the
  dipion invariant mass spectrum from J/Psi and Upsilon decays.

  By default, the `AREA' has an arbitrary normalization. Use the
  `SET FIT AREA ON' command to make it meaningful. A Simpson
  integration of the function is then performed if any of the parameters
  change.

  These  functions  all  prompt  you  for the  parent  and  daughter
  resonance names and the pion type, and the following fit parameters,
  whose significance depends on the model chosen:
        AREA
        PARM

4 Phase_Space

  This is the dipion  invariant mass according to phase space arguments.
  It takes the form:
  AREA *
  SQRT(((Ep + Ed)**2 - x**2)*((Ep - Ed)**2 - x**2)*(x**2 - 4*mpi**2))
  where
        Ep  is the energy of the parent resonance,
        Ed  is the energy of the daughter resonance,
        mpi  is the mass of the pion.

4 Yan_Model

  This is the first order dipion invariant mass from the Yan model.
  It takes the form:
  AREA * PHASE SPACE * [(x**2 - 2*mpi**2) + (PARM/3)*(x**2 - 2*mpi**2)*
                        (x**2 - 4*mpi**2)   +   2*(x**2 + 2*mpi**2)*
                        (((Ep**2 + x**2 - Ed**2)/(2*Ep))**2)/x**2]
  where
    Ep  is the energy of the parent resonance,
    Ed  is the energy of the daughter resonance,
    mpi is the mass of the pion,
    PHASE SPACE  has the functional form of the Phase_Space model.

  `x' is limited to the range  `(2 * mpi) < x < (Ep - Ed)'.

4 Voloshin_Model

  This is the dipion invariant mass from the Voloshin-Zakharov model.
  It takes the form:
  AREA * PHASE_SPACE * ...

4 Novikov_Model

  This is the dipion invariant mass from the Novikov-Shifman model.
  It takes the form:
  AREA * PHASE_SPACE * ...

4 Full_Yan_Model

  This is the second  order  calculation  of  the dipion  invariant
  mass from the Yan model.  It takes the form:
  AREA * PHASE_SPACE * [ YAN_MODEL + ( ( PARM**2 ) / 20 ) *
                 ((X**2 - 4*mpi**2) + 4/3 * (X**2 - 4*mpi**2)
      * (X**2 + 6*mpi**2)*(((Ep**2 + X**2 - Ed**2)/(2*Ep))**2)/X**2)
      + ( 8/3 * ( X**4 + 2 * ( X**2 ) * ( mpi**2 ) + 6*mpi**4 ) *
        ( ( Ep**2 + X**2 - Ed**2 ) / ( 2 * Ep ) )**4 / X**2 )]
  where
    Ep  is the energy of the parent resonance,
    Ed  is the energy of the daughter resonance,
    mpi is the mass of the charged pion (0.1396 GeV/c).
    PHASE_SPACE  has the functional form of the Phase_Space model.
    YAN_MODEL is the first order Yan model calculation.

    HW problem:  derive this for yourself some weekend.

4 Peskin_Model

  This is the dipion invariant mass from the Peskin model, the
  corrected formula.

4 Isovector_Model

  This is  the  dipion  invariant  mass from the Voloshin Isovector
  model.

4 BW_x_Phase_Space

  This model for the dipion invariant mass takes the form of a
  Breit-Wigner function times the Phase_Space model.

4 Moxhay_Resonance

  This is the Moxhay resonance form for the dipion invariant mass.

3 Fragmentation_Functions

  This  is  a set  of   functions   containing   various   theoretical
  predictions for the fragmentation of quarks and gluons. The following
  models are available:

  1: Peterson         2: Kartvelishveli   3: Andersson        4: Collins
  5: Bowler

  By default, the `AREA' has an arbitrary normalization. Use the
  `SET FIT AREA ON' command to make it meaningful. A Simpson
  integration of the function is then performed if any of the parameters
  change.

3 Resonance_Cross_Section

  Parametrizes a resonance cross section such as an Upsilon state.

  The parameters are:
    AREA
    MEAN
    SIGMA
    AXIS

3 Continuum_Cross_Section

  Parametrizes  the  continuum  cross-section,  including new flavour
  thresholds and the beam energy dependence, for e+e- annihilation.

  The parameters are:
    LEVEL
    THRESH
    HEIGHT

3 Histogram

  Use one histogram to  fit to another. You  will be asked if you want
  to include the errors  on the histogram you  are fitting with in the
  chi**2.  The  errors  will not  be  included if  you do a normal
  likelihood fit even if you ask them to be. However you can use the
  `SLIKELIHOOD' fitting option (see HELP FIT) if you want them to be
  taken into account.

  This sort of function is very useful if you want to fit a complicated
  shape you got from Monte Carlo or an efficiency corrected function
  to a plot. It can also be used to fit the data to a number of
  different components which are described by histograms. If you want
  to be have the x coordinate free in the fit you should use a
  `Smooth Histogram' function.

3 Smooth_Histogram

  Use a smooth histogram to fit to another. You will be asked if you
  want to include the errors on the histogram you are fitting with in
  the chi**2.  The errors are assumed to be the square root of the
  value of each point. The errors will not be included if you do a
  normal likelihood fit even if you ask them to be. However, you can
  use the `SLIKELIHOOD' fitting option (see HELP FIT) if you want them
  to be taken into account.

  The possible modes for using the histogram are:
   0  Do not use the errors on the histogram function
   1  Errors are the square root of the value of each point
  1n  The ordinate is scaled by a free parameter

  This function is very useful if you want to fit a complicated shape
  you got from Monte Carlo, or an efficiency corrected function to a
  plot, or if you have a mass peak from Monte Carlo and want to
  determine its position and/or its relative width (mode 10 or 11).

  Note that what this function actually does is to smoothly
  interpolate using a cubic spline between the centres of the
  histogram bins. If your histogram also includes statistical
  fluctuations, then maybe you should first smooth the histogram
  itself. Use the `SMOOTH' command to do this.

3 2D_Gaussian

  Gaussians can be given either in terms of `SIGMA' or `FWHM'. They
  are normalised, so that the area is what it says. The form in terms
  of `SIGMA' is:

  AREA / (SIGMA1 * SIGMA2) * EXP( (X-MEAN1)**2/(2*SIGMA1**2)
                           * EXP( (Y-MEAN2)**2/(2*SIGMA2**2)

  The parameters are:
  AREA
  MEAN1
  MEAN2
  SIGMA1
  SIGMA2

  In terms of `FWHM' it is the same except for the scale factor between
  the two.

3 COMIS
  Syntax: FUN ADD COMIS filename [nfun] Y|N
          nparm
          Title
          Name(s)
   where: filename  is the file containing the function
          nfun      is the (optional) user function number
          Y|N       is whether you want to edit the file or not
          nparm     are the number of parameters in the function
          Title     is a title for the user function (<CR> means the
                    title will be "Comis Function [name]"
          Name(s)   are the names of the parameters

  Uses the CERN COMIS facility (COMpilation and Interpretation System)
  to enable you to define FORTRAN  functions interactively and execute
  them  without  recompiling  the code.  If you give the command in a
  macro you must either put `Y|N' on a separate line or include the
  function number (which can be 0). The form  of the  function is
  identical to that of a user  defined function. The function name can
  be whatever you like, but the arguments must be the same as the user
  function. Note that if you want to fit with 2 COMIS functions at the
  same time, the functions must have different names:

  DOUBLE PRECISION FUNCTION XMNCMI(XX,YY,NP,DPAR,NFUSER,WFERR)
  where XX     is the current x value for which the function is to be
               evaluated (REAL)
        YY     is the current y value for which the function is to be
               evaluated (REAL)
        NP     is the number of parameters
        DPAR   is a DOUBLE PRECISION array containing the parameters
        NFUSER is the Comis function number (set by the command
               FUN ADD COMIS n, where n is the Comis function number)
        WFERR  is the error on the function (usually 0, except when
               you are fitting with histograms) in DOUBLE PRECISION.

  All the arguments are  input, except  `WFERR'. An example of a COMIS
  function  can be  found in     `mn_fit_test:comis_test.for' (VMS) or
  `$MN_FIT/test/comis_test.for' (Unix).

  If  you add  two  or more COMIS  functions   and  want to   use them
  simultaneously, then  the   functions  must have   different  names,
  otherwise  whichever one you  compile last will  be  used for all of
  them.

  The orthogonality  limits for legendres etc.  and the bin widths are
  stored in the common block:

  COMMON/MNUSR/XMINNM,XMAXNM,XBINNM,YMINNM,YMAXNM,YBINNM
  XMINNM,XMAXNM are the orthogonality limits for the x axis
  YMINNM,YMAXNM are the orthogonality limits for the y axis
  XBINNM        is the bin width for the x axis
  YBINNM        is the bin width for the y axis

  If you want to have debug printout you can use the common block:
  COMMON/MNDBG/QDEBUG,NDEBUG
  QDEBUG            is a logical set with the SET DEBUG command
  NDEBUG            is the printout level for DEBUG output

  You can call any of the Mn_Fit predefined functions from within
  your own COMIS function. The calling sequence is:

  WVAL = XMNCLC(NFUN,DPAR,NP,NPAR2,X,Y)
  where NFUN   is the function number
        DPAR   are the function parameters (in DOUBLE PRECISION)
        NP     is the number of parameters
        NPAR2  only applies to function 26 - polynomial multiplied by
               the exponential of a polynomial
        X      is the X value for which the function returns its
               value (REAL)
        Y      is the Y value - not used in this routine (REAL)

  The 2-dimensional functions (only Gaussians at present) can also be
  called using the same calling sequence with function name XMNC2D.

  You will be prompted for the file containing the function and if the
  file  does not  exist a new  one will  be  created with  the correct
  function name  and arguments  supplied. You can  then edit the file.
  See HELP EDIT for more details on editing.  Use  the `SET EDIT'
  command to change to your favourite editor. If the file is a new one
  the `EDIT'  command will be  executed  automatically.  When you exit
  the editor, the  function will be  compiled and is  then ready to be
  used. Refer to the COMIS manual as to how to edit the function if it
  has compilation errors or type `HELP' if you get the prompt `MED>'.

  The same Cernlib subroutines and functions are available in Mn_Fit
  as in PAW with a few additions. For complete list of the routines
  available see HELP Using_COMIS.

  If you  want  your user   function to be   displayed as a  histogram
  instead of a smooth curve then the title should start with `Hist'.

  To change a COMIS function you have already added either edit it and
  use the   `FUNCTION  COMPILE'  command or  use the   `FUNCTION EDIT'
  command.

  Note that the file must be in a directory that you have write access
  to, and  that its  name must  begin with a  letter.  These are Comis
  restrictions.

  Note that single precision  constants cannot be assigned directly to
  double  precision  variables in a  COMIS  routine - but  you can use
  `DBLE(X)' etc. if you need to. Also COMIS is fairly picky about your
  FORTRAN. For  example if `DVAL'  is in `DOUBLE  PRECISION', the `IF'
  statement `IF(DVAL.LT.36.0)' will  always be `.FALSE.'. You must use
  the form `IF(DVAL.LE.36.0D0)'.

  You should do all relevant calculations in the COMIS functon in
  `DOUBLE PRECISION'. The `XX' and `YY' values are passed in single
  precision for historical reasons only.

4 Mn_Fit_Functions_in_COMIS

  All Mn_Fit functions (except the  dipion mass spectra) may be called
  in a COMIS  routine.  The  function names  and  arguments are listed
  below.  Note that  the  functions are  all  `DOUBLE  PRECISION'.
  There also exist single precision versions of the same functions,
  with the name RMN... (instead of XMN...).

  Note that all Mn_Fit functions include the bin width in the
  calculation of the function value.

  The arguments generally used are:

    NPAR=  Number of parameters
    P=     Parameters (DOUBLE PRECISION)
    X, Y=  X and Y (REAL)

  Y is only appropriate for 2D functions.

  In order to find out exactly what is calculated for each function
  you can look at the source code: $MN_FIT/src/function/xmnclc.fpp
  etc. If you do not have the source code you can get it from the
  Mn_Fit homepage:

  http://www-zeus.physik.uni-bonn.de/~brock/mn_fit.html

  Other arguments are listed with the functions:

  1) General Functions (1-37):  XMNCLC(NFUN,DPAR,NPAR,NPAR2,X,Y)
     NFUN=  Function number
     NPAR2= Number of secondary parameters
!=

  2) Continuum cross section:  XMNCNT(DPAR,NPAR,X)
!=

  3) Resonance cross section:  XMNRES(DPAR,NPAR,X)
!=

  4) Fragmentation functions:  XMNFRG(MODEL,BIN,DPAR,NPAR,X)
     BIN=   Unused
!=

  5) Histogram:  XMNHIS(IDHA,IDHB,MODE,X,Y,WMNHER)
     IDHA=   Primary Identifier of Histogram
     IDHB=   Secondary Identifier of Histogram
     NMODE=  0= No Errors, 1= Errors from histogram
     WMNHER= Error returned from XMNHIS - DOUBLE PRECISION
!=

  6) Smooth Histogram:  XMNHSM(IDHA,IDHB,OFFSET,NHS,MODE,X,Y,WMNHER)
     IDHA=   Primary Identifier of Histogram
     IDHB=   Secondary Identifier of Histogram
     OFFSET= X Shift of histogram
     NHS=    Element number that stores the spline parameters
     NMODE=  0= No Errors, 1= Errors from histogram
     WMNHER= Error returned from XMNHSM - DOUBLE PRECISION
!=
     The element number is defined if you do FUNCTION ADD SMOOTH id.
     You should therefore add the smooth histogram as a function, do
     a FUNCTION INFO and the element number is given after the id.
!=

  6) 2D Functions: XMNC2D(NFUN,DPAR,NPAR,NPAR2,X,Y)

3 User
  Syntax: FUN ADD USER [nfun]
          nparm
          Title
          Name(s)
   where: nfun    is the (optional) user function number
          nparm   are the number of parameters in the function
          Title   is a title for the user function (<CR> means the
                  title will be "User Function [nfun]"
          Name(s) are the names of the parameters

  User  functions are  identical to COMIS  functions  except that they
  must have the function name  XMNUSR, so see HELP FUNCTION LIST COMIS
  for details.

  To link Mn_Fit with a user function (Unix) you can use `Makefile.user' in
  the Mn_Fit top level directory:
  export MN_FIT=/usr/local/lib/mn_fit (bash, zsh, ksh, etc.)
  setenv MN_FIT /usr/local/lib/mn_fit (csh, tcsh, etc.)
  make -f $MN_FIT/Makefile.user all [LOCATION=XXX]' (Unix).

  Your user function must be in the file `xmnusr.fpp' in you current
  directory and the executable name will be `mn_user_x.exe'.
  Replace `/usr/local/lib/mn_fit' with wherever Mn_Fit is located on 
  your system.
  You may have to change compile options in `Makefile.user' if your system is
  not the same as I expect. `make -f $MN_FIT/Makefile.user' will give
  more information on the options available.

  Example functions and scripts to run them can be found in
  `$MN_FIT/test/xmnusr1.fpp' and `$MN_FIT/test/xmnusr1.mnf' and
  `$MN_FIT/test/xmnusr2.fpp' and `$MN_FIT/test/xmnusr2.mnf'.

  The first example contains a quadratic function. The second is
  probably more interesting and shows how to convolute a Breit-Wigner
  with a Gaussian\index{convolute}.

  Under VMS use the script `mn_fit_dir:mn_user.lnk'
  You can give the executable name (default is `mn_user_x.exe')
  the filename for your compiled function and any extra libraries or
  object files that you need, e.g.:

  $MN_FIT/mgr/mn_user.lnk /home/brock/exe/mn_user fittest.f

  To run with your user version give the command:

  mn_fit -u [/home/brock/exe/mn_user]

  Note that Mn_Fit must have been compiled on your system or installed
  on your system with the the Mn_Fit libraries available for
  this to work.

2 OVERLAY
  Syntax: FUNCTION OVERLAY nfun1 [nfun2...]
          [&]idb nsymb/col
   where: nfun  is the function number(s) as in FUNCTION INFO
          idb   is the secondary identifier for the function
          nsymb is the symbol you want to plot the function with
     and  col      is the (optional) colour for the symbol.

  Stores one of the  functions being fitted as  a histogram and overlays
  it on the  current picture. `nfun  = 0' means use  all functions which
  are currently in use.

  If you are fitting and your last picture was a `DISPLAY', the function
  will be given the same primary  identifier as the one you are fitting.
  Otherwise, it will be  given the primary  identifier 98765. It will be
  given the secondary  identifier you specify.  To specify the secondary
  identifier on  the same line as  the function  numbers precede it by a
  `&'. The function will  be drawn with 500  points (unless at least one
  of them is a histogram), so it will appear as a smooth curve. You
  can change the number of points with the `SET FUNCTION POINT' command.

2 PLOT
  Syntax: FUNCTION PLOT nfun1 [nfun2...]
          [&]idb nsymb/col
          [xlo xhi]
   where: nfun  is the function number(s) as in FUNCTION INFO
          idb   is the secondary identifier for the function
          nsymb is the symbol you want to plot the function with
     and  col      is the (optional) colour for the symbol.

  Stores one of the selected  functions as a histogram and plots it.
  `nfun = 0'  means use all  functions  which are  currently in use. You
  will be prompted for the lower and upper limits for the plot. The plot
  will be  given the  primary  identifier  98765.  It will be  given the
  secondary identifier you specify.  To specify the secondary identifier
  on the  same line as  the function  numbers  precede it  by a `&'. The
  function will be drawn with 500 points (unless at least one of them is
  a histogram), so it will appear as a smooth curve. You can change the
  number of points with the `SET FUNCTION POINT' command.

2 STORE
  Syntax: FUNCTION STORE filename n1 [n2...]
   where: n1,n2... are the function numbers you want to store

  Stores  functions in a  file. You can  access them at  some other time
  with the `FUNCTION FETCH' command.

2 USE
  Syntax: FUNCTION USE n1 [n2...]
   where: n1,n2 are the function number(s) as in FUNCTION INFO

  Only valid in `MN_CMD>'.

  Selects the function(s) you want to use in fitting. `n' positive means
  use the function, negative means do not.

