; $Id: pan_ft_kww.pro,v 1.5 2006/10/12 21:36:12 kneller Exp $
;###############################################################################
;
; NAME:
;  PAN_FT_KWW
;
; PURPOSE:
;  PROVIDE A FUNCTION FOR QENS DATA
;
; CATEGORY:
;  DAVE, Data Analysis, PAN, curve fitting
;
; AUTHOR:
;   Antonio Faraone, Ph.D.
;   NIST Center for Neutron Research
;   100 Bureau Drive
;   Gaithersburg, MD 20899
;   Phone: (301) 975-5254
;   E-mail: antonio.faraone@nist.gov
;
; LICENSE:
;  The software in this file is written by an employee of
;  National Institute of Standards and Technology
;  as part of the DAVE software project.
;
;  The DAVE software package is not subject to copyright protection
;  and is in the public domain. It should be considered as an
;  experimental neutron scattering data reduction, visualization, and
;  analysis system. As such, the authors assume no responsibility
;  whatsoever for its use, and make no guarantees, expressed or
;  implied, about its quality, reliability, or any other
;  characteristic. The use of certain trade names or commercial
;  products does not imply any endorsement of a particular product,
;  nor does it imply that the named product is necessarily the best
;  product for the stated purpose. We would appreciate acknowledgment
;  if the DAVE software is used of if the code in this file is
;  included in another product.
;
;###############################################################################
function pan_ft_kww,x,parms, parmnames=parmnames, $
                 canDraw=canDraw, $
                 _Extra=extra


if n_params() eq 0 then begin
    parmnames = ['Area','x0','tau','beta','res_sigma']
    return,-1
endif
canDraw=0

npts = n_elements(x)

amp=parms[0]
x0=parms[1]
tau=parms[2]
beta=parms[3]
res_sigma=parms[4]
hbar=0.6528

    accuracy=10
    step=0.01

    z_temp=findgen(accuracy*100)
    z=transpose([-sort(-z_temp)*step,z_temp(1:accuracy*100-1)*step])
    z1=transpose([-sort(-z_temp(0:accuracy*100-1))*step,z_temp(1:accuracy*100-1)* $
       step,z_temp(1:accuracy*100-1)*step+step])


    dummy=intarr(n_elements(x))
    dummy(*)=1

;   matrix=cos((omega-x0)#exp(x))*(dummy#(exp(x)*step*exp(-(exp(x)/tau)^beta)))
    matrix=(cos((x-x0)#exp(z)/hbar)* $
        (dummy#(exp(-(res_sigma^2*(exp(z))^2/(2*hbar^2)))*exp(z)*exp(-(exp(z)/tau)^beta)))+ $
        cos((x-x0)#exp(z1)/hbar)* $
       (dummy#(exp(-(res_sigma^2*(exp(z1))^2/(2*hbar^2)))*exp(z1)*exp(-(exp(z1)/tau)^beta))))*step/2

    yout=Amp/(!pi)*total(matrix,2)/hbar
return,yout



end
