/*******************************************************************************
*
* McStas, neutron ray-tracing package
*         Copyright (C) 1997-2008, All rights reserved
*         Risoe National Laboratory, Roskilde, Denmark
*         Institut Laue Langevin, Grenoble, France
*
* Instrument: ILL_H143_LADI
*
* %Identification
* Written by: <a href="mailto:farhi@ill.fr">Emmanuel Farhi</a>
* Date: Sept 2014.
* Origin: <a href="http://www.ill.fr">ILL (France)</a>
* %INSTRUMENT_SITE: ILL
*
* The LADI protein crystallography cold Laue diffractometer
*
* %Description
*
* LADI-III is a quasi-Laue neutron diffractometer used for single-crystal studies
* of biological macromolecules at high resolution (1.5 - 2.5Å) in order to locate
* individual protons or deuterons of special interest, water structures or other
* small molecules that can be marked with deuterium to be particularly visible.
* Data collection is feasible for samples with unit-cell edges ranging from 50
* to 150Å using crystal volumes from ~0.05 to 0.5mm3, respectively.
*
* LADI-III uses a large cylindrical area detector composed of neutron-sensitive
* image-plates, which completely surround the crystal and allows large numbers
* of reflections to be recorded simultaneously. Data are collected using a
* quasi-Laue method in order to provide a rapid survey of reciprocal space, while
* reducing the background on the detector compared to use of the full white beam.
*
* LADI:
* Guide H143:
*               H14_1     H14_2     H14_3 [OT1] H143_1 [OT2]  H143_2    last
* Length  [m]   6.8       6         21          30            35        1
* m             2         2         2           1,bot=1.4     1,bot=1.4 idem
* Rh      [km]  -         2.7       4.0         -             -         -
* Rv      [km]  -         -         -           2.0           2.0       2.0
* n_elm.        2         5         11          15            14        last=1m
* section [mm]  45x220    45x220    45x220-200  45x30+95      30x30+95  [w*h+v.offset]
*
* Filter:      Ni/Ti multilayer band-pass filter, Quasi-Laue (dlambda/lambda<30%)
* Collimation: Pinholes 0.5 to 2.9 mm
* Detector:    image plate 1250 x 450 mm2
* Sample:      at 2.710 mm from the end of the guide H143.
*
* %Parameters
* lambda: [Angs]      wavelength
* dlambda: [Angs]     wavelength HALF spread.
* reflections: [str]  list of reflections describing the sample SX
*
* %End
*******************************************************************************/
DEFINE INSTRUMENT ILL_H143_LADI(lambda=3.2, dlambda=1, string reflections="leucine.lau")

DECLARE
%{
  /* gaps and Al windows parameters */
  double Al_Thickness = 0.002;
  double gGap         = 0.001;

  /* guide section parameters (total length/number of elements) */
  double L_H14_1= 2.0;      /* length of elements */
  double L_H14_2= 6.0/5;
  double L_H14_3= 21.0/11;
  double L_H143_1=30.0/15;
  double L_H143_2=35.0/14;  /* +1m at end */

  double Rh_H14_2,  Rh_H14_3;
  double Rv_H143_1, Rv_H143_2;
%}

USERVARS
%{
  double vel;
  double eff;
%}

INITIALIZE
%{

  /* Element rotations = Element length / Curvature Radius * RAD2DEG */
  Rh_H14_2  = L_H14_2 /2700.0*RAD2DEG;  /* 2.7 km horz curvature */
  Rh_H14_3  = L_H14_3 /4000.0*RAD2DEG;  /* 4 km horz curvature */
  Rv_H143_1 = -L_H143_1/2000*RAD2DEG;    /* 2 km vert curvature */
  Rv_H143_2 = -L_H143_2/2000*RAD2DEG;    /* 2 km vert curvature */

  printf("Instrument: ILL_H143_LADI (LADI@H143 ILL cold guide on VCS).\n");

%}

TRACE

COMPONENT Origin = Progress_bar()
AT(0,0,0) ABSOLUTE

/* H14_1: 6.8 m pink Carter (straight) m=2 section 45x220 mm ================ */

/* In this model, capture flux at OT1 is 0.842e10. Was measured as 1e10

   The results must thus be scaled by +1.1876
 */
COMPONENT VCS = Source_gen(
  yheight  = 0.22,
  xwidth   = 0.14,
  dist     = 2.525,
  focus_xw = 0.045,
  focus_yh = 0.2,
  lambda0  = lambda,
  dlambda  = dlambda,
  T1=216.8,I1=1.24e+13,	/* VCS parameters */
  T2=33.9, I2=1.02e+13,
  T3=16.7 ,I3=3.0423e+12,
  verbose  = 1)
  AT (0, 0, 0) RELATIVE PREVIOUS

COMPONENT Al_window1 = Al_window(thickness=Al_Thickness)
AT (0,0,0.21) RELATIVE VCS

COMPONENT Al_window2 = Al_window(thickness=Al_Thickness)
AT (0,0,0.61) RELATIVE VCS

COMPONENT Al_window3 = Al_window(thickness=Al_Thickness)
AT (0,0,0.78) RELATIVE VCS

COMPONENT Al_window4 = Al_window(thickness=Al_Thickness)
AT (0,0,0.92) RELATIVE VCS

COMPONENT Al_window5 = Al_window(thickness=Al_Thickness)
AT (0,0,2.43) RELATIVE VCS

/* H14_1: L=3.17 m in 1 element. no curvature */
/* from the source we consider we reach 6.8 m (1st section) */

COMPONENT PinkCarter = Guide_gravity(
  w1=0.045, h1=0.2, w2=0.045, h2=0.2, l=3.170, m = 2, nelements=2)
AT (0,0,2.525) RELATIVE VCS

COMPONENT FirstObturator = Guide_gravity(
  w1=0.045, h1=0.2, w2=0.045, h2=0.2, l=0.228, m = 2)
AT (0,0,3.17+0.02) RELATIVE PinkCarter

COMPONENT Source_lambda = Monitor_nD(
  xwidth=0.045, yheight=0.2, options="y lambda limits=[0 10]", bins=100)
AT (0,0,0.228+0.001) RELATIVE PREVIOUS

COMPONENT Source_lambda0 = Monitor_nD(
  xwidth=0.045, yheight=0.2, options="lambda limits=[0 10]", bins=100)
AT (0,0,0.001) RELATIVE PREVIOUS

/* ******************** swiming pool guide ******************** */

/* H14-2: L=6 m in 5 elements R horiz=2700 m. m=2  */

COMPONENT H14_2 = Arm()
AT (0,0,3.59) RELATIVE PinkCarter

COMPONENT H14_2_In = Al_window(thickness=Al_Thickness)
AT (0,0,0) RELATIVE PREVIOUS

COMPONENT H14_2_1 = Guide_gravity(
  w1=0.03, h1=0.2, l=L_H14_2, m = 2)
AT (0,0,Al_Thickness+gGap) RELATIVE PREVIOUS ROTATED (0,Rh_H14_2,0) RELATIVE PREVIOUS

COMPONENT H14_2_2 = COPY(PREVIOUS)
AT (0,0,L_H14_2+gGap) RELATIVE PREVIOUS ROTATED (0,Rh_H14_2,0) RELATIVE PREVIOUS

COMPONENT H14_2_3 = COPY(PREVIOUS)
AT (0,0,L_H14_2+gGap) RELATIVE PREVIOUS ROTATED (0,Rh_H14_2,0) RELATIVE PREVIOUS

COMPONENT H14_2_4 = COPY(PREVIOUS)
AT (0,0,L_H14_2+gGap) RELATIVE PREVIOUS ROTATED (0,Rh_H14_2,0) RELATIVE PREVIOUS

COMPONENT H14_2_5 = COPY(PREVIOUS)
AT (0,0,L_H14_2+gGap) RELATIVE PREVIOUS ROTATED (0,Rh_H14_2,0) RELATIVE PREVIOUS

COMPONENT H14_2_6 = COPY(PREVIOUS)
AT (0,0,L_H14_2+gGap) RELATIVE PREVIOUS ROTATED (0,Rh_H14_2,0) RELATIVE PREVIOUS

COMPONENT H14_2_Out = Al_window(thickness=Al_Thickness)
AT (0,0,L_H14_2+gGap) RELATIVE PREVIOUS

/* gap 0.198 m (VS) */

/* H14_3: L=21 m in 11 elements Rh=4000 m. 21 m R=4km horz m=2 section 45x220->45x200 mm */

/* this vertically converging section requires gradual adaption of the height */

COMPONENT H14_3 = Arm()
AT (0,0,0.198) RELATIVE H14_2_Out

COMPONENT H14_3_In = Al_window(thickness=Al_Thickness)
AT (0,0,0) RELATIVE PREVIOUS

COMPONENT H14_3_1 = Guide_gravity(
  w1=0.045, h1=0.22, w2=0.045, h2=0.22, l=L_H14_3, m = 2)
AT (0,0,Al_Thickness+gGap) RELATIVE PREVIOUS ROTATED (0,Rh_H14_3,0) RELATIVE PREVIOUS

COMPONENT H14_3_2 = COPY(PREVIOUS)(
  h1=COMP_GETPAR(H14_3_1, h2), h2=COMP_GETPAR(H14_3_1, h2)-0.02/11)
AT (0,0,L_H14_3+gGap) RELATIVE PREVIOUS ROTATED (0,Rh_H14_3,0) RELATIVE PREVIOUS

COMPONENT H14_3_3 = COPY(PREVIOUS)(
  h1=COMP_GETPAR(H14_3_2, h2), h2=COMP_GETPAR(H14_3_2, h2)-0.02/11)
AT (0,0,L_H14_3+gGap) RELATIVE PREVIOUS ROTATED (0,Rh_H14_3,0) RELATIVE PREVIOUS

COMPONENT H14_3_4 = COPY(PREVIOUS)(
  h1=COMP_GETPAR(H14_3_3, h2), h2=COMP_GETPAR(H14_3_3, h2)-0.02/11)
AT (0,0,L_H14_3+gGap) RELATIVE PREVIOUS ROTATED (0,Rh_H14_3,0) RELATIVE PREVIOUS

COMPONENT H14_3_5 = COPY(PREVIOUS)(
  h1=COMP_GETPAR(H14_3_4, h2), h2=COMP_GETPAR(H14_3_4, h2)-0.02/11)
AT (0,0,L_H14_3+gGap) RELATIVE PREVIOUS ROTATED (0,Rh_H14_3,0) RELATIVE PREVIOUS

COMPONENT H14_3_6 = COPY(PREVIOUS)(
  h1=COMP_GETPAR(H14_3_5, h2), h2=COMP_GETPAR(H14_3_5, h2)-0.02/11)
AT (0,0,L_H14_3+gGap) RELATIVE PREVIOUS ROTATED (0,Rh_H14_3,0) RELATIVE PREVIOUS

COMPONENT H14_3_7 = COPY(PREVIOUS)(
  h1=COMP_GETPAR(H14_3_6, h2), h2=COMP_GETPAR(H14_3_6, h2)-0.02/11)
AT (0,0,L_H14_3+gGap) RELATIVE PREVIOUS ROTATED (0,Rh_H14_3,0) RELATIVE PREVIOUS

COMPONENT H14_3_8 = COPY(PREVIOUS)(
  h1=COMP_GETPAR(H14_3_7, h2), h2=COMP_GETPAR(H14_3_7, h2)-0.02/11)
AT (0,0,L_H14_3+gGap) RELATIVE PREVIOUS ROTATED (0,Rh_H14_3,0) RELATIVE PREVIOUS

COMPONENT H14_3_9 = COPY(PREVIOUS)(
  h1=COMP_GETPAR(H14_3_8, h2), h2=COMP_GETPAR(H14_3_8, h2)-0.02/11)
AT (0,0,L_H14_3+gGap) RELATIVE PREVIOUS ROTATED (0,Rh_H14_3,0) RELATIVE PREVIOUS

COMPONENT H14_3_10 = COPY(PREVIOUS)(
  h1=COMP_GETPAR(H14_3_9, h2), h2=COMP_GETPAR(H14_3_9, h2)-0.02/11)
AT (0,0,L_H14_3+gGap) RELATIVE PREVIOUS ROTATED (0,Rh_H14_3,0) RELATIVE PREVIOUS

COMPONENT H14_3_11 = COPY(PREVIOUS)(
  h1=COMP_GETPAR(H14_3_10, h2), h2=COMP_GETPAR(H14_3_10, h2)-0.02/11)
AT (0,0,L_H14_3+gGap) RELATIVE PREVIOUS ROTATED (0,Rh_H14_3,0) RELATIVE PREVIOUS

COMPONENT H14_3_Out = Al_window(thickness=Al_Thickness)
AT (0,0,L_H14_3+gGap) RELATIVE PREVIOUS

/* gap 0.03 m at OT1 */

/* H143_1: L=30 m in 15 elements Rv=2000 m. */

COMPONENT H143_1 = Arm()
AT (0,0,0.03) RELATIVE H14_3_Out

COMPONENT H143_1_In = Al_window(thickness=Al_Thickness)
AT (0,0.058,0) RELATIVE PREVIOUS

COMPONENT H143_1_lambda = Monitor_nD(
  xwidth=0.045, yheight=0.03, options="y lambda limits=[1 5]", bins=50)
AT (0,0,0.005) RELATIVE PREVIOUS

COMPONENT H143_1_lambda0 = Monitor_nD(
  xwidth=0.045, yheight=0.03, options="lambda limits=[0 10]", bins=100)
AT (0,0,0.001) RELATIVE PREVIOUS

COMPONENT H143_1_PhiC = Monitor_nD(
  xwidth=0.045, yheight=0.03, options="capture lambda limits=[0 10], y", bins=100)
AT (0,0,0.001) RELATIVE PREVIOUS

COMPONENT H143_1_1 = Guide_gravity(
  w1=0.045, h1=0.03, l=L_H143_1, m=1, mbottom=1.4)
AT (0,0,Al_Thickness+gGap) RELATIVE PREVIOUS ROTATED (Rv_H143_1,0,0) RELATIVE PREVIOUS

COMPONENT H143_1_2 = COPY(PREVIOUS)
AT (0,0,L_H143_1+gGap) RELATIVE PREVIOUS ROTATED (Rv_H143_1,0,0) RELATIVE PREVIOUS

COMPONENT H143_1_3 = COPY(PREVIOUS)
AT (0,0,L_H143_1+gGap) RELATIVE PREVIOUS ROTATED (Rv_H143_1,0,0) RELATIVE PREVIOUS

COMPONENT H143_1_4 = COPY(PREVIOUS)
AT (0,0,L_H143_1+gGap) RELATIVE PREVIOUS ROTATED (Rv_H143_1,0,0) RELATIVE PREVIOUS

COMPONENT H143_1_5 = COPY(PREVIOUS)
AT (0,0,L_H143_1+gGap) RELATIVE PREVIOUS ROTATED (Rv_H143_1,0,0) RELATIVE PREVIOUS

COMPONENT H143_1_6 = COPY(PREVIOUS)
AT (0,0,L_H143_1+gGap) RELATIVE PREVIOUS ROTATED (Rv_H143_1,0,0) RELATIVE PREVIOUS

COMPONENT H143_1_7 = COPY(PREVIOUS)
AT (0,0,L_H143_1+gGap) RELATIVE PREVIOUS ROTATED (Rv_H143_1,0,0) RELATIVE PREVIOUS

COMPONENT H143_1_8 = COPY(PREVIOUS)
AT (0,0,L_H143_1+gGap) RELATIVE PREVIOUS ROTATED (Rv_H143_1,0,0) RELATIVE PREVIOUS

COMPONENT H143_1_9 = COPY(PREVIOUS)
AT (0,0,L_H143_1+gGap) RELATIVE PREVIOUS ROTATED (Rv_H143_1,0,0) RELATIVE PREVIOUS

COMPONENT H143_1_10 = COPY(PREVIOUS)
AT (0,0,L_H143_1+gGap) RELATIVE PREVIOUS ROTATED (Rv_H143_1,0,0) RELATIVE PREVIOUS

COMPONENT H143_1_11 = COPY(PREVIOUS)
AT (0,0,L_H143_1+gGap) RELATIVE PREVIOUS ROTATED (Rv_H143_1,0,0) RELATIVE PREVIOUS

COMPONENT H143_1_12 = COPY(PREVIOUS)
AT (0,0,L_H143_1+gGap) RELATIVE PREVIOUS ROTATED (Rv_H143_1,0,0) RELATIVE PREVIOUS

COMPONENT H143_1_13 = COPY(PREVIOUS)
AT (0,0,L_H143_1+gGap) RELATIVE PREVIOUS ROTATED (Rv_H143_1,0,0) RELATIVE PREVIOUS

COMPONENT H143_1_14 = COPY(PREVIOUS)
AT (0,0,L_H143_1+gGap) RELATIVE PREVIOUS ROTATED (Rv_H143_1,0,0) RELATIVE PREVIOUS

COMPONENT H143_1_15 = COPY(PREVIOUS)
AT (0,0,L_H143_1+gGap) RELATIVE PREVIOUS ROTATED (Rv_H143_1,0,0) RELATIVE PREVIOUS

COMPONENT H143_1_Out = Al_window(thickness=Al_Thickness)
AT (0,0,L_H143_1+gGap) RELATIVE PREVIOUS

/* gap 0.03 m OT2 */

/* H14-5: L=4.75 m in 5 elements Rh=2700 m. Here d_c ~ 28.4 */

COMPONENT H143_2 = Arm()
AT (0,0,0.03) RELATIVE H143_1_Out

COMPONENT H143_2_In = Al_window(thickness=Al_Thickness)
AT (0,0,0) RELATIVE PREVIOUS

COMPONENT H143_2_lambda = Monitor_nD(
  xwidth=0.045, yheight=0.03, options="y lambda limits=[1 5]", bins=50)
AT (0,0,0.005) RELATIVE PREVIOUS

COMPONENT H143_2_lambda0 = Monitor_nD(
  xwidth=0.045, yheight=0.03, options="lambda limits=[0 10]", bins=100)
AT (0,0,0.001) RELATIVE PREVIOUS

COMPONENT H143_2_PhiC = Monitor_nD(
  xwidth=0.045, yheight=0.03, options="capture lambda limits=[0 10], y", bins=50)
AT (0,0,0.001) RELATIVE PREVIOUS

COMPONENT H143_2_1 = Guide_gravity(
  w1=0.03, h1=0.03, l=L_H143_2, m = 1, mbottom=1.4)
AT (0,0,Al_Thickness+gGap) RELATIVE PREVIOUS ROTATED (Rv_H143_2,0,0) RELATIVE PREVIOUS

COMPONENT H143_2_2 = COPY(PREVIOUS)
AT (0,0,L_H143_2+gGap) RELATIVE PREVIOUS ROTATED (Rv_H143_2,0,0) RELATIVE PREVIOUS

COMPONENT H143_2_3 = COPY(PREVIOUS)
AT (0,0,L_H143_2+gGap) RELATIVE PREVIOUS ROTATED (Rv_H143_2,0,0) RELATIVE PREVIOUS

COMPONENT H143_2_4 = COPY(PREVIOUS)
AT (0,0,L_H143_2+gGap) RELATIVE PREVIOUS ROTATED (Rv_H143_2,0,0) RELATIVE PREVIOUS

COMPONENT H143_2_5 = COPY(PREVIOUS)
AT (0,0,L_H143_2+gGap) RELATIVE PREVIOUS ROTATED (Rv_H143_2,0,0) RELATIVE PREVIOUS

COMPONENT H143_2_6 = COPY(PREVIOUS)
AT (0,0,L_H143_2+gGap) RELATIVE PREVIOUS ROTATED (Rv_H143_2,0,0) RELATIVE PREVIOUS

COMPONENT H143_2_7 = COPY(PREVIOUS)
AT (0,0,L_H143_2+gGap) RELATIVE PREVIOUS ROTATED (Rv_H143_2,0,0) RELATIVE PREVIOUS

COMPONENT H143_2_8 = COPY(PREVIOUS)
AT (0,0,L_H143_2+gGap) RELATIVE PREVIOUS ROTATED (Rv_H143_2,0,0) RELATIVE PREVIOUS

COMPONENT H143_2_9 = COPY(PREVIOUS)
AT (0,0,L_H143_2+gGap) RELATIVE PREVIOUS ROTATED (Rv_H143_2,0,0) RELATIVE PREVIOUS

COMPONENT H143_2_10 = COPY(PREVIOUS)
AT (0,0,L_H143_2+gGap) RELATIVE PREVIOUS ROTATED (Rv_H143_2,0,0) RELATIVE PREVIOUS

COMPONENT H143_2_11 = COPY(PREVIOUS)
AT (0,0,L_H143_2+gGap) RELATIVE PREVIOUS ROTATED (Rv_H143_2,0,0) RELATIVE PREVIOUS

COMPONENT H143_2_12 = COPY(PREVIOUS)
AT (0,0,L_H143_2+gGap) RELATIVE PREVIOUS ROTATED (Rv_H143_2,0,0) RELATIVE PREVIOUS

COMPONENT H143_2_13 = COPY(PREVIOUS)
AT (0,0,L_H143_2+gGap) RELATIVE PREVIOUS ROTATED (Rv_H143_2,0,0) RELATIVE PREVIOUS

COMPONENT H143_2_14 = COPY(PREVIOUS)
AT (0,0,L_H143_2+gGap) RELATIVE PREVIOUS ROTATED (Rv_H143_2,0,0) RELATIVE PREVIOUS

/* last one is only 1 m long */

COMPONENT H143_2_15 = COPY(PREVIOUS)(l=1.0)
AT (0,0,L_H143_2+gGap) RELATIVE PREVIOUS ROTATED (1.0/2000.0*RAD2DEG,0,0) RELATIVE PREVIOUS

COMPONENT H143_2_Out = Al_window(thickness=Al_Thickness)
AT (0,0,1.0+gGap) RELATIVE PREVIOUS

/* The LADI-III position (end of guide) */

COMPONENT LADI3_XY = Monitor_nD(
  xwidth=0.03, yheight=0.03, options="x y", bins=50)
AT (0,0,0.01) RELATIVE PREVIOUS

COMPONENT LADI3_lambda = Monitor_nD(
  xwidth=0.03, yheight=0.03, options="y lambda limits=[1 5]", bins=50)
AT (0,0,0.01) RELATIVE PREVIOUS

COMPONENT LADI3_lambda0 = Monitor_nD(
  xwidth=0.03, yheight=0.03, options="lambda limits=[0 10]", bins=100)
AT (0,0,0.01) RELATIVE PREVIOUS

COMPONENT LADI3_PhiC = Monitor_nD(
  xwidth=0.03, yheight=0.03, options="capture lambda limits=[0 10], y", bins=50)
AT (0,0,0.01) RELATIVE PREVIOUS

COMPONENT LADI3_YdY0 = Monitor_nD(
  xwidth=0.03, yheight=0.03, options="dy limits=[-1 1], y", bins=50)
AT (0,0,0.01) RELATIVE PREVIOUS

COMPONENT LADI3_YdY = Monitor_nD(
  xwidth=0.03, yheight=0.03, options="dy limits=[0 3], y", bins=50)
AT (0,0,0.01) RELATIVE PREVIOUS
ROTATED (0,0,0) RELATIVE H14_3_Out

COMPONENT slit1 = Slit(radius=.025/2)
  AT (0,0,0.85+1.0) RELATIVE H143_2_Out
  ROTATED (0,0,0) RELATIVE H143_2_Out

/* image on a Li foil */
COMPONENT LADI3_XY_Li = Monitor_nD(
  xwidth=0.03, yheight=0.03, options="x y", bins=50)
AT (0,0,0.01) RELATIVE PREVIOUS

COMPONENT slit2 = Slit(radius=.02/2)
  AT (0,0,0.35) RELATIVE PREVIOUS

COMPONENT slit3 = Slit(radius=.012/2)
  AT (0,0,0.58) RELATIVE PREVIOUS

COMPONENT slit4 = Slit(radius=.006/2)
  AT (0,0,0.48) RELATIVE PREVIOUS

COMPONENT sample_pos1 = Monitor_nD(
  xwidth=.01, yheight=.01, options="lambda limits=[2.9 3.3]", bins=10,
  restore_neutron=1)
  AT (0,0,0.3) RELATIVE PREVIOUS

COMPONENT sample_pos2 = Monitor_nD(
  xwidth=.01, yheight=.01, options="lambda limits=[3.5 4.5]", bins=10,
  restore_neutron=1)
  AT (0,0,0.3) RELATIVE PREVIOUS

COMPONENT sample_Phic1 = Monitor_nD(
  xwidth=.01, yheight=.01, options="capture lambda limits=[2.9 3.3]", bins=10,
  restore_neutron=1)
  AT (0,0,0.3) RELATIVE PREVIOUS

COMPONENT sample_Phic2 = Monitor_nD(
  xwidth=.01, yheight=.01, options="capture lambda limits=[3.5 4.5]", bins=10,
  restore_neutron=1)
  AT (0,0,0.3) RELATIVE PREVIOUS

SPLIT 50 COMPONENT sample = Single_crystal(
  xwidth=0.01, yheight=0.01, zdepth=0.01,
  mosaic = 5, reflections=reflections, order=1)
  AT (0,0,0) RELATIVE sample_pos1
  ROTATED (0,5,10) RELATIVE sample_pos1
EXTEND %{
  /* take into account detector efficiency (absorption law) */
  if (!SCATTERED) ABSORB;
  eff=0.5;
  vel=sqrt(vx*vx+vy*vy+vz*vz);
  p *= 1.0-exp(3960.0/vel*log(1.0-eff/100.0));
%}

COMPONENT ImagePlate = Monitor_nD(
  radius = 0.2, yheight= 0.45,
  options="banana, theta limits=[-180 180] bins=1250, y bins=450")
  AT (0,0,0) RELATIVE sample_pos1

END
