Skip to content

example instrument

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

Requirements for a new test instrument

For any new component addition to McStas or McXtrace, a corresponding test instrument must be included. Such an instrument should:

  1. Include a parsable mcdoc header with a standard layout - copy from template.instr included here:
/*******************************************************************************
*         McStas instrument definition URL=http://www.mcstas.org
*
* Instrument: template (rename also the example and DEFINE lines below)
*
* %Identification
* Written by: Your name (email)
* Date: Current Date
* Origin: Your institution
* %INSTRUMENT_SITE: Templates
*
* !!Please write a short instrument (1 line) here!!
*
* %Description
* Instrument longer description (type, elements, usage...)
*
* Example: mcrun template.instr <parameters=values>
*
* once your instrument is written and functional:
* - replace INSTRUMENT_SITE entry above with your Institution name as a single word
* - rename the instrument name after DEFINE INSTRUMENT below
* - update the parameter help in the following Parameters section
* - update the instrument description, and better add a usage example with a
*     sensible parameter set.
*
* %Parameters
* Par: [unit] A parameter description
*
* %Link
* A reference/HTML link for more information
*
* %End
*******************************************************************************/
DEFINE INSTRUMENT template(Par1=1)

Fill in the header in a similar way as mentioned in mcdoc component header

  1. Define a relevant instrument geometry, input-parameters with reasonable defaults to describe a test-scenario for the component.

  2. Define an %Example: within the %Description section of this form

* %Example: inputpar=inputvalue Detector: targetmonitor_I=outputvalue

exemplified by this line taken from PSI_DMC:

* %Example: lambda=2.5666 Detector: Detector_I=7.5965E+02

The final outputvalue is what your instrument will be measured against by the McCode continuous integration (CI)

  1. Please test your component and instrument manually on as many different operating systems as possible before attempting to contribute the instrument via a Pull Request. (Please consult our PR template)

Clone this wiki locally