McXtrace logo

McXtrace - An X-ray ray-trace simulation package

Synchrotron SOLEIL DTU Physics

McXtrace

About McXtrace
 Publications
 Project Partners
 Project People
 Goal

Download
 Components

Documentation
 Manual
 Commands
 Wiki (GitHub)
 Tutorial

Mailing list

Links

Search

Code-repository (GitHub)

Report bugs (GitHub)


6 The McXtrace kernel and meta-language

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

  • Computing the intersection between a photon flight-path and various objects (such as planes, cylinders, boxes and spheres).

  • Functions for generating random numbers with various distributions.

  • Functions for reading or writing informations from/to data files.

  • Convenient conversion factors between relevant units, etc.

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.


Last Modified: Monday, 05-Oct-2026 10:48:08 CEST
Search website mailinglist archive GitHub repos