Skip to content

mcdoc component header

Peter Willendrup edited this page Jan 14, 2026 · 5 revisions

Example component header

Inspired from Beamstop.comp, with a few additions for completeness:

/*******************************************************************************
*
* McStas, neutron ray-tracing package
*         Copyright 1997-2002, All rights reserved
*         Risoe National Laboratory, Roskilde, Denmark
*         Institut Laue Langevin, Grenoble, France
*
* Component: Beamstop
*
* %ID
*
* Written by: Kristian Nielsen
* Date: January 2000
* Origin: Risoe
*
* Rectangular/circular beam stop.
*
* %D
* A simple rectangular or circular beam stop.
* Infinitely thin and infinitely absorbing.
* The beam stop is by default rectangular. You may either
* specify the radius (circular shape), or the rectangular bounds.
*
* Example: Beamstop(xmin=-0.05, xmax=0.05, ymin=-0.05, ymax=0.05)
*          Beamstop(radius=0.1)
*
* <div class="latex">
* $\frac{\alpha}{\beta}$
* </div>
*
* %PAR
*
* INPUT PARAMETERS
*
* radius: [m]   radius of the beam stop in the z=0 plane, centered at Origo 
* xmin: [m]     Lower x bound 
* xmax: [m]     Upper x bound 
* ymin: [m]     Lower y bound 
* ymax: [m]     Upper y bound 
* xwidth: [m]   Width of beamstop (x). Overrides xmin, xmax. 
* yheight: [m]  Height of beamstop (y). Overrides ymin, ymax. 
*
* %L
*
* %END
*******************************************************************************/


DEFINE COMPONENT Beamstop

SETTING PARAMETERS (xmin=-0.05, xmax=0.05, ymin=-0.05, ymax=0.05,
xwidth=0, yheight=0, radius=0)

Tips for writing a parseable mccode component header:

  1. Please consult existing components of similar type and write documentation in a similar style.

  2. Ensure that the identifier Component: Name matches

  • the filename (i.e. Name.comp)
  • the first code-line of DEFINE COMPONENT Name
  1. The header lines should
  • start with a /*******...(c-style start comment-block)
  • all subsequent header lines should start with * character
  • the last header line should end by ...*****/
  1. All of the %-tags have a meaning and should be left in the component header
  2. Fill in the
  • Written by: (good practice is to include an email-adress)
  • Date: and
  • Origin: fields
  1. Add description information:
  • A short Description line before the %D tag (will be listed on mcdoc overview page)
  • A longer description below the %D tag (will be visible on the actual component mcdoc page)
  1. Add component input parameter description lines after %P and and before %END.
    Such lines should always be of the form
* parameter: [unit]  Descriptive information for parameter
  1. Optionally add links (in html syntax) under %L
  2. It is possible to include (limited) LaTeX formula-syntax in the %D long description, such as:
* <div class="latex">
* $\frac{\alpha}{\beta}$
* </div>
  1. Please keep the lines for SETTING PARAMETERS free of any comments such as // a comment. Put such things within the input parameter lines!
    An example of a valid parameter line, including all McCode types:
SETTING PARAMETERS (par1=1, int par2=0, string par3=“NULL”, vector par4={0,0,0,0})

Check and correct your component doc header

You may use mcdoc with the —-dir Directory parameter to build components under Directory. Your own component developments / edited components should appear in the Local components table at the bottom of the generated mcdoc page.

If you have issues spelling etc...

Please run a spell-checker, please use an AI agent etc. Bad spelling or poor writing does not look serious to another McStas/McXtrace user - or leaves work for others that you should have done yourself!

Clone this wiki locally