/*******************************************************************************
*         McStas instrument definition URL=http://www.mcstas.org
*
* Instrument: ISIS_TS2_Brilliance (rename also the example and DEFINE lines below)
*
* %Identification
* Written by: Peter Willendrup
* Date: 20130425
* Origin: DTU Fysik
* %INSTRUMENT_SITE: ISIS
*
* This instrument produces brilliance curves from the ISIS TS2 facility.
*
* %Description
* This instrument produces brilliance curves from the ISIS TS2 facility.
* 
* The Brilliance_monitor is used to determine both the mean and peak brilliances, plus pulse-shapes for different wavelengths.
*
* Example: ISIS_brilliance Detector: Brillmon_I=3.80e+15 (First detector output)
*
* %Parameters
* modfile: [string]  Name of moderator face - TS2=groove,hydrogen,narrow,broad - - TS1=Water,ch4,h2,merlin or instrument name eg maps, crisp etc.
*
* %Link
*
* %End
*******************************************************************************/
DEFINE INSTRUMENT ISIS_TS2_Brilliance(string modfile="hydrogen")

/* The DECLARE section allows us to declare variables or  small      */
/* functions in C syntax. These may be used in the whole instrument. */
DECLARE
%{
  double lambdamin,lambdamax;
%}

/* The INITIALIZE section is executed when the simulation starts     */
/* (C code). You may use them as component parameter values.         */
INITIALIZE
%{
  lambdamin=0.5;
  lambdamax=20;
%}

/* Here comes the TRACE section, where the actual      */
/* instrument is defined as a sequence of components.  */
TRACE

/* The Arm() class component defines reference points and orientations  */
/* in 3D space. Every component instance must have a unique name. Here, */
/* Origin is used. This Arm() component is set to define the origin of  */
/* our global coordinate system (AT (0,0,0) ABSOLUTE). It may be used   */
/* for further RELATIVE reference, Other useful keywords are : ROTATED  */
/* EXTEND GROUP PREVIOUS. Also think about adding a neutron source !    */
/* Progress_bar is an Arm displaying simulation progress.               */
COMPONENT Origin = Progress_bar()
  AT (0,0,0) ABSOLUTE

COMPONENT Source = ISIS_moderator(Face = modfile, Emin = -lambdamin,Emax = -lambdamax, dist = 1.0, focus_xw = 0.01,
   focus_yh = 0.01,  xwidth = 0.01, yheight = 0.01, CAngle = 0.0,SAC=1)
  AT (0, 0, 0) RELATIVE Origin

COMPONENT Brillmon = Brilliance_monitor(
    nlam = 196, nt = 601, filename = "brill", t_0 = 0,
    t_1 = 600, lambda_0 = lambdamin, lambda_1 = lambdamax,
    Freq =10.0)
  AT (0, 0, 0.0000001) RELATIVE Source

/* This section is executed when the simulation ends (C code). Other    */
/* optional sections are : SAVE                                         */
FINALLY
%{
%}
/* The END token marks the instrument definition end */
END








