Skip to content

McCode_tools.md

Peter Willendrup edited this page Aug 24, 2026 · 6 revisions

McStas / McXtrace User Tools Cheat Sheet

Source: McCode/tools/Python (plus McCode/tools/matlab for the legacy Matlab/Octave/iFit variants)

Naming convention: almost everything named mc<something> on the McStas side has a direct mx<something> counterpart on the McXtrace side, built from the same source, with the neutron/photon ("particle") wording and a few McStas-only options (e.g. --gravity, time-of-flight mode) adjusted accordingly. Where a tool has several rendering variants (html / matplotlib / pyqtgraph / webgl / ...), the variant is appended after a dash, e.g. mcplot-html / mxplot-html.

On the commandline: Most tools accept --help

Tool-class pages

Page Covers
Code generators mcstas/mcxtrace, mcstas-pygen/mcxtrace-pygen, mcstas-jupylab/mcxtrace-jupylab
mcgui mcgui / mxgui
mcrun mcrun / mxrun
mcplot family mcplot / mxplot, mcplotdiff / mxplotdiff, mccoplot / mxcoplot — html / matplotlib / pyqtgraph / matlab variants
mcdisplay family mcdisplay / mxdisplay — pyqtgraph (default) / matplotlib / webgl / webgl-classic / cad / matlab variants
mctest family mctest / mxtest, mcviewtest / mxviewtest
mcdoc mcdoc / mxdoc

Quick reference: which tool for which job?

I want to... Use
Compile an .instr file to C directly (rarely needed by hand) mcstas / mcxtrace
Convert an .instr model to Python for use with McStasScript mcstas-pygen / mcxtrace-pygen
Explore an instrument interactively in Jupyter via McStasScript mcstas-jupylab / mcxtrace-jupylab
Edit/compile/run instruments interactively mcgui / mxgui
Run a simulation from the command line, or a parameter scan/optimisation mcrun / mxrun
Plot one simulation's results mcplot-{html,matplotlib,pyqtgraph}
mxplot-{html,matplotlib,pyqtgraph}
Compare exactly two simulations (a - b) mcplotdiff-{html,matplotlib,pyqtgraph}
mxplotdiff-{html,matplotlib,pyqtgraph}
Overlay 2+ simulations for direct comparison mccoplot-{html,matplotlib,pyqtgraph}
mxcoplot-{html,matplotlib,pyqtgraph}
Visualise instrument geometry + particle trajectories mcdisplay-{pyqtgraph,matplotlib,webgl,webgl-classic}
mxdisplay-{pyqtgraph,matplotlib,webgl,webgl-classic}
Export instrument geometry to a CAD file mcdisplay-cad
mxdisplay-cad
Plot/display results in Matlab, Octave, or iFit instead mcplot-matlab / mxplot-matlab
mcdisplay-matlab / mxdisplay-matlab
Test/benchmark the whole instrument library against a McCode installation mctest / mxtest
Build a browsable pass/fail + diff report from mctest results mcviewtest / mxviewtest
Generate/browse instrument & component documentation mcdoc / mxdoc

Clone this wiki locally