
;+
; NAME: rd_hxt_drm
;	
; PURPOSE: read the yohkoh hxt response matrix 
;	
; CALLING SEQUENCE: rd_hxt_drm, drm, e_out, e_in, area, error=error
;	
; INPUTS: none
;		
; OUTPUTS:
;	drm - fltarr(4,1110)
;	  response in each HXT channel, cnts/cm2/keV, per incident xray 
;	e_out- fltarr(2,4) - low and hi edge in keV of hxt channels
;	e_in - fltarr(2,1110) - incident photon energy edges in keV
;	area - 55 cm2 - nominal total geometric area of summed HXT
;	error- set if data file not found	
; PROCEDURE: read from calibration file possi4.dat
;
; MODIFICATION HISTORY: ras, 20-apr-94
;	
;-
;
pro rd_hxt_drm, drm, e_out, e_in, area, error=error

error = 1 
hx_data=findfile(concat_dir(chklog('$DIR_HXT_CAL'),'possi4.dat'), count=ncount)
if ncount lt 1 then begin
	print,'Error, Cannot find HXT response function file $DIR_HXT_CAL/possi4.dat'
	return
endif

read_seqfile,buff, hx_data(0)
area = 55. ;cm2 for HXT
first='10.0      0.000  0.000  0.000  0.000  0.000  0.000'
last ='120.9      0.773  0.000  0.000  0.000  0.002  0.771'
ifirst = (where(strpos(buff,first) ne -1))(0)
ilast = (where(strpos(buff,last) ne -1))(0)
mat = fltarr(7,ilast-ifirst+1)
reads, buff(ifirst:ilast), mat

e_in = (mat(0,*))(*)
e_out=reform([15,24.4,35.2,56.8,100])
edge_products, e_out, mean=em, wid=wout, edges_2=e_out
e_in = [e_in-.05, e_in(ilast-ifirst)+.05]
edge_products, e_in, mean=em_in, edges_2=e_in

drm = mat(2:5,*)
drm = drm/rebin(wout,4,ilast-ifirst+1)

error = 0	;clear error condition
end
