/****************************************************************************** * neutron ray-tracing package * Copyright (C) 1997-2007, All rights reserved * Risoe National Laboratory, Roskilde, Denmark * Institut Laue Langevin, Grenoble, France * * Component: CavitiesOut * * %I * Written by: Henrich Frielinghaus * Date: Oct 2007 * Origin: JCNS - FZ-Juelich * * Slit - sorting in channels * * %D * This routine sorts the 'full' neutron beam (given by xw,yw) * in xc,yc channels. These can be imagined as cavities. * CavitiesOut sorts these channels back to normal coordinates. * * Example: Slit(xw=0.05, yw=0.05, xc=4, yc=1) * * %P * INPUT PARAMETERS * * xw: [] width in X-dir (m) (full width, might be larger for trumpets) * yw: [] width in Y-dir (m) (full width, might be larger for trumpets) * * * %E *******************************************************************************/ DEFINE COMPONENT CavitiesOut DEFINITION PARAMETERS () SETTING PARAMETERS (xw=0.05, yw=0.05) INITIALIZE %{ %} TRACE %{ PROP_Z0; if (x<-0.5*xw/xcc || x>0.5*xw/xcc || y<-0.5*yw/ycc || y>0.5*yw/ycc) ABSORB; else { SCATTER; x = x+(mcs_xc+0.5-0.5*xcc)*xw/xcc; y = y+(mcs_yc+0.5-0.5*ycc)*yw/ycc; } %} MCDISPLAY %{ multiline(3, -(double)xw, 0.5*yw, 0.0, -0.5*xw, 0.5*yw, 0.0, -0.5*xw, (double)yw, 0.0); multiline(3, (double)xw, 0.5*yw, 0.0, 0.5*xw, 0.5*yw, 0.0, 0.5*xw, (double)yw, 0.0); multiline(3, -(double)xw,-0.5*yw, 0.0, -0.5*xw, -0.5*yw, 0.0, -0.5*xw,-(double)yw, 0.0); multiline(3, (double)xw,-0.5*yw, 0.0, 0.5*xw, -0.5*yw, 0.0, 0.5*xw,-(double)yw, 0.0); %} END