----- file created by makedoc on: Tue Apr  1 15:29:56 2008
----- Documentation for /scisoft/xop2.3/extensions/shadowvui/src/lib/vr_2slits.pro -----

 NAME:
	VR_2SLITS
 PURPOSE:
	This function creates a SHADOW source using a variance reduction method:
	  The rays are forced to pass through two slits.
 CATEGORY:
	SHADOW's utilities.
 CALLING SEQUENCE:
	output=vr_2slits(slit1,slit2)
 OUTPUTS:
	output is a SHADOW-IDL structure containing the source
 INPUTS:
	slit1: a 2-element array containing the entrance slit width (in X) and 
		height (in Z):  slit1=[w,h]
	slit2: a 2-element array containing the exit slit width (in X) and 
		height (in Z):  slit2=[w,h]
	dist: the distance from slit1 to slit2
       
 KEYWORD PARAMETERS:
	file: set this keyword to a string containing the name of the
		file for writing the output (Default: no file)
	nrays: the number of generated rays. Note that this number is
		not limeted here, but it is limited in the SHADOW kernel
		at compilation time. 
	iseed: a seed for the random number generator
	verbose: Set this keyword to produce a text window with
		information on the weihghting process (if selected):
		verbose=1 creates xdisplayfile1 window
		verbose=2 appends to last window
	

	retrace: The distance from slit 1 where to trace the rays
		(usually the source plane). The output and output files
		refer to this point. Default=0 
	
	---  Weighting parameters: 
		Define these two parameters if you want to give a Gaussian 
		weight to the rays
		
	wcols: array with SHADOW columns where to apply weights. 
	wsigma: array of the same dimension than wcols containg
		the sigma of the Gaussians for weighting. 
 PROCEDURE:
	Creeates a random point inside slit 1 and another one in slit2
	Link the two points with a straight line. This defines one ray.
	Repeat the process for NRAYS. Retrace the rays to the point 
	defined in retrace (if not set, rays are defined at the slit1
	plane)at the slit1 plane).

	If weights are selected, weight each ray by the product
	of exp(-r**2/2/sigmar**2) where r is summed ever the selected
	SHADOW columns. 

 MODIFICATION HISTORY:
	M. Sanchez del Rio. ESRF. Grenoble, May 2006

