User and Programmers’ Guide to the X Ray-Tracing Package McXtrace, version 3.8.6

6  The McXtrace kernel and meta-language

Beamline definitions are written in a special McXtrace meta-language which is translated automatically by the McXtrace compiler into a C program which is in turn compiled to an executable that performs the simulation. The meta-language is custom-designed for x-ray scattering and serves two main purposes: (i) to specify the interaction of a single x-ray with a single optical component, and (ii) to build a simulation by constructing a complete beamline from individual components.

For maximum flexibility, efficiency and portability, the meta-language is based on C. Instrument geometry, propagation of x-rays between the different components, parameters, data input/output etc. is handled in the meta-language and by the McXtrace compiler. Complex calculations are written in C embedded in the meta-language description of the components. However, it is possible to set up an instrument from existing components and run a simulation without writing a single line of C code, working entirely in the meta-language.

Apart from the meta-language, McXtrace also includes a number of C library functions and definitions that are useful for x-ray tracing simulations. The definitions available for component developers are listed in appendix A.2. The list includes functions for

The McXtrace meta-language was designed to be readable, with a verbose syntax and explicit mentioning of otherwise implicit information. The recommended way to get started with the meta-language is to start by looking at the examples supplied with McXtrace, modifying them as necessary for the application at hand.

6.1 Notational conventions
6.2 Syntactical conventions
6.3 Writing instrument definitions
6.3.1 The instrument definition head
6.3.2 The DECLARE section
6.3.3 The INITIALIZE section
6.3.4 The NEXUS extension
6.3.5 The TRACE section
6.3.6 The SAVE section
6.3.7 The FINALLY section
6.3.8 The end of the instrument definition
6.4 Writing instrument definitions - complex arrangements and syntax
6.4.1 Embedding instruments in instruments TRACE
6.4.2 Component extensions - EXTEND
6.4.3 Mutually exclusive components in parallell - GROUP
6.4.4 Duplication of component instances - COPY
6.4.5 Conditional components - WHEN
6.4.6 Component loops and non sequential propagation - JUMP
6.4.7 Enhancing statistics reaching components - SPLIT
6.5 Writing component definitions
6.5.1 The component definition header
6.5.2 The DECLARE section
6.5.3 The SHARE section
6.5.4 The INITIALIZE section
6.5.5 The TRACE section
6.5.6 The SAVE section
6.5.7 The FINALLY section
6.5.8 The MCDISPLAY section
6.5.9 The end of the component definition
6.5.10 A component example: Semi-transparent mirror
6.6 Extending component definitions
6.6.1 Extending from the instrument definition file
6.6.2 Explicitly modify an existing library component
6.6.3 Component heritage and duplication
6.7 MxDoc, the McXtrace library documentation tool