/*******************************************************************************
*
* McStas, neutron ray-tracing package
*         Copyright (C) 1997-2008, All rights reserved
*         Risoe National Laboratory, Roskilde, Denmark
*         Institut Laue Langevin, Grenoble, France
*
* Instrument: SNS_analytic_test
*
* %Identification
* Written by: G. Granroth
* Date: July 2004
* Origin: SNS Project Oak Ridge National Laboratory
* %INSTRUMENT_SITE:SNS
*
* Simple test instrument for the SNS_source component.
*
* %Description
* Simple test instrument for the SNS_source component.
* Refer to SNS <A href="http://neutrons.ornl.gov/instrument_systems/components/moderators.shtml">Source files.</A>
*
* Example: filename="source_sct091_tu_02_1.dat" Detector: det_I=9.89304e+09
*
* %Parameters
* filename: [string] Source file 
*
* %Link
* Written by G. Granroth
* SNS_source component
* <A href="http://neutrons.ornl.gov/instrument_systems/components/moderators.shtml">Source files </A>
* %End
*******************************************************************************/

DEFINE INSTRUMENT SNS_analytic_test(string filename="a1Gw2-5-f5_fit_fit.dat")
DEPENDENCY " -DLOADPATH=GETPATH(data) "

DECLARE %{
  char fullfile[256];
%}

INITIALIZE %{
#define QUOTE(name) #name
#define STR(macro) QUOTE(macro)

#ifndef LOADPATH
#define LOADPATH=/usr/share/mcstas/3.1/data
#endif

#define LOADPATH_ STR(LOADPATH)
  sprintf(fullfile,"%s/%s",LOADPATH_,filename);
printf("Using the input file: %s\n", fullfile);
  
%}

TRACE
COMPONENT mod=SNS_source_analytic(filename=fullfile,
  xwidth=0.1, yheight=0.12,
  dist=1, focus_xw=0.10, focus_yh=0.24,
  Emin=1.0,Emax=10.0)
AT(0,0,0) ABSOLUTE

COMPONENT dett=TOF_monitor(
  xmin = -.025, xmax = .025,
  ymin = -.06, ymax = .06,
  nt=500, dt=10,
  filename="tout.det")
At (0,0,1) RELATIVE mod

COMPONENT det=Monitor_nD(
  xwidth = 1, yheight = 1,
  options=" square x bins 100 limits=[-0.05 0.05]; y bins 100 limits=[-0.12 0.12]")
AT (0,0,1.0000000000001) RELATIVE mod
END
