/*******************************************************************************
*
* McStas, neutron ray-tracing package
*         Copyright (C) 1997-2008, All rights reserved
*         Risoe National Laboratory, Roskilde, Denmark
*         Institut Laue Langevin, Grenoble, France
*
* Instrument: ISIS_HET
*
* %Identification
* Written by: <a href="mailto:d.champion@rl.ac.uk">Dickon Champion</a>
* Date: 22nd Jan 2004.
* Origin: <a href="http://www.isis.rl.ac.uk">ISIS (UK)</a>
* %INSTRUMENT_SITE: ISIS
*
* HET: High Energy Transfer Chopper Spectrometer
*
* %Description
* This instrument is a simple model of the HET spectrometer at the ISIS neutron
* facility. The input arguments are hardwired so that the Fermi chopper position
* is 10 metres from the moderator. This instrument uses the FC module written by
* Andrew Garret which comes with no guarantees as to its accuracy in modelling the
* Fermi Chopper.
*
* %Example: Emin=443 Detector: cyl_I=235837
*
* %Parameters
* Emin:   [meV] lowest energy sampled      
* Emax:   [meV] highest energy sampled     
* nu_chop: [Hz] frequency of chopper rotation 
* type:     [ ] chopper package - sloppy chopper = 1, B chopper = 2
*
* %End
********************************************************************************/
DEFINE INSTRUMENT ISIS_HET(Emin=443.0,Emax=470.0,nu_chop=600.0,int type=2)
DECLARE
%{
/* chopper variables to compute according to "type" input */
double c_h,roc, chan_w;
int nslits;
%}

INITIALIZE
%{
/*  type=1 sloppy chopper
  type=2 B chopper
*/
if (type==1)
  {c_h=0.064;
   roc=-1.3;
   nslits=16;
   chan_w=0.00283;
   fprintf(stderr,"sloppy chopper selected");
  }
if (type==2)
  {c_h=0.052;
   roc=-0.92;
   nslits=24;
   chan_w=0.00184;
   fprintf(stderr,"250mev chopper selected");
  }

%}
TRACE
COMPONENT a1 = Progress_bar()
  AT (0,0,0) ABSOLUTE

COMPONENT ts1_mod = ISIS_moderator(
    Face ="Water", Emin = Emin, Emax = Emax, dist = 9.85, focus_xw = 0.045,
    focus_yh = 0.045, xwidth = 0.074, yheight = 0.074, CAngle = 0.0, SAC=1)
  AT (0, 0, 0) RELATIVE a1

COMPONENT monFC = Monitor_nD(
    options = "square t limits=[1.03e-3 1.16e-3] bins=100",
    filename = "FC_mon2.dat", xwidth=0.2, yheight = 0.2)
  AT (0, 0, 9.8) RELATIVE a1

COMPONENT FC = FermiChopper(
  radius=0.05, nu=nu_chop, yheight=c_h,
  w=chan_w, nslit=nslits, curvature=1.0/roc, verbose=1, zero_time=2)
AT (0,0,10) RELATIVE ts1_mod

COMPONENT FCslit1 = Slit(
    xmin = -0.0225, xmax = 0.0225, ymin = -0.0225, ymax = 0.0225)
  AT (0, 0, 0.15) RELATIVE FC

COMPONENT monT = Monitor_nD(
    options = "square t limits=[1.07e-3 1.13e-3] bins=100",
    filename = "FC_mon.dat", xwidth=0.2, yheight = 0.2)
  AT (0, 0, 0.035) RELATIVE FCslit1

COMPONENT postFCslit = Slit(
    xmin = -0.0225, xmax = 0.0225, ymin = -0.0225, ymax = 0.0225)
  AT (0, 0, 0.2) RELATIVE FC

COMPONENT presampslit = Slit(
    xmin = -0.0225, xmax = 0.0225, ymin = -0.0225, ymax = 0.0225)
  AT (0, 0, 1.4) RELATIVE postFCslit

COMPONENT target = Incoherent(
  xwidth=0.04,yheight=0.04,zdepth=0.002,
  focus_aw=19.38,focus_ah=3.435,
  pack = 1,
  target_index=2)
  AT (0,0,0.2) RELATIVE presampslit

COMPONENT a2=Arm()
AT (0,0,0) RELATIVE target

COMPONENT cyl = Monitor_nD(
    options = "banana, t limits=[1.505e-3 1.575e-3] bins=100  , theta limits[9.31 28.69] bins=1",
    filename = "det_out.dat",   xwidth=5.0,   yheight = 0.3)
  AT (0, 0, 0) RELATIVE a2

END
