/******************************************************************************* * * McXtrace, X-ray tracing package * Copyright (C), All rights reserved * Risoe National Laboratory, Roskilde, Denmark * Institut Laue Langevin, Grenoble, France * * Component: PSD_monitor * * %I * Written by: Erik Knudsen * Date: June 22, 2009 * Origin: Risoe * Release: McXtrace 0.1 * * Position-sensitive wattage monitor. * * %D * Based on neutron PSD component written by Kim Lefmann * An n times m pixel PSD wattage monitor. This component may also be used as a beam * detector. * * Example: PSD_monitor(xmin=-0.1, xmax=0.1, ymin=-0.1, ymax=0.1, nx=90, ny=90, filename="Output.psd") * * %P * INPUT PARAMETERS: * * xmin: Lower x bound of detector opening (m) * xmax: Upper x bound of detector opening (m) * ymin: Lower y bound of detector opening (m) * ymax: Upper y bound of detector opening (m) * xwidth: Width of detector. Overrides xmin,xmax. (m) * yheight: Height of detector. Overrides ymin,ymax. (m) * nx: Number of pixel columns (1) * ny: Number of pixel rows (1) * filename: Name of file in which to store the detector image (text) * restore_xray: If set, the monitor does not influence the xray state (1) * * OUTPUT PARAMETERS: * * PSD_N: Array of xray counts * PSD_W: Array of xray weight counts * PSD_W2: Array of second moments * * %E *******************************************************************************/ DEFINE COMPONENT W_psd_monitor DEFINITION PARAMETERS () SETTING PARAMETERS (int nx=90, int ny=90, string filename=0, int restore_xray=0, xmin=-0.05, xmax=0.05, ymin=-0.05, ymax=0.05, xwidth=0, yheight=0) OUTPUT PARAMETERS (PSD_N, PSD_W, PSD_W2) /* X-ray parameters: (x,y,z,kx,ky,kz,phi,t,Ex,Ey,Ez,p) */ DECLARE %{ DArray2d PSD_N; DArray2d PSD_W; DArray2d PSD_W2; %} INITIALIZE %{ int i,j; if (xwidth > 0) { xmax = xwidth/2; xmin = -xmax; } if (yheight > 0) { ymax = yheight/2; ymin = -ymax; } if ((xmin >= xmax) || (ymin >= ymax)) { printf("PSD_monitor: %s: Null detection area !\n" "ERROR (xwidth,yheight,xmin,xmax,ymin,ymax). Exiting", NAME_CURRENT_COMP); exit(0); } PSD_N = create_darr2d(nx, ny); PSD_W = create_darr2d(nx, ny); PSD_W2 = create_darr2d(nx, ny); %} TRACE %{ int i,j; PROP_Z0; if (x>xmin && xymin && y