;----------------------------------------------------------------------- ; Name: getDispDist ; ; Purpose: Compute the dispersion distance (dd) and the ; cross-dispersion distance (dxd) for each detected ; photon from a MARX simulation. ; ; Inputs: ; grating = structure containing grating parameters ; ; maxdist = max allowed distance (mm) from dispersion line ; ; y,z = focal plane coordinate vectors (one (y,z) pair per photon) ; ; y0,z0 = coordinates of zero-order point of interest ; ; offset = distance from zero-order to which counts ignored ; ; Outputs: ; dd = vector of photon distances (mm) from zero order parallel to ; dispersion. ; ; dxd = vector of photon perpendicular distances (mm) from ; dispersion line ; ; list_selected = optional vector of selected photon indices ; ; Comments: ; ; To get a list of all photons distances when treated as either all MEG ; or HEG, use a maxdist larger than a CCD, say 50mm. Otherwise, the ; dd,dxd pairs no longer correspond to the input vectors or ; associated vectors. ; ; Revision history: ; re-written from tg_extract (from dph) J. Houck 03-26-97 ; added offset, changed name to getDispDist J. Houck 04-01-97 ;----------------------------------------------------------------------- pro getDispDist, grating, maxdist, y0, z0, y, z, offset, dd, dxd, list_selected ; check for correct number of parameters if n_params() eq 0 then begin print,'getDispDist, grating, maxdist, y0, z0, y, z, offset, dd, dxd, [list_selected]' return endif ; the dispersion line goes through (y0,z0) dd = (y-y0)*cos(grating.tilt) + (z-z0)*sin(grating.tilt) dxd = -(y-y0)*sin(grating.tilt) + (z-z0)*cos(grating.tilt) dd = abs(dd) ; select photons only within the specified perpendicular distance ; from the dispersion line and offset by required amount list_selected = where( (abs(dxd) lt maxdist) and (abs(dd) gt offset) ) dxd = dxd(list_selected) dd = dd(list_selected) end