detect  vers3.3
10-OCT-94  MJF
14-MAY-96
29-MAT-99

	   Compute the response of an imaging detector
	   using data files for spectra and detector response.

example:
	detect << EOF
	detector_file
	mAs area label_flag
	EOF

standard output:

	The following is written to standard output:

	# units = XXX   per entered mAs and area 
	#     Signal    Noise      SNR      NEF
 	      ...	...	  ...	   ...

	where the computed values for signal and noise are
	reported in the units (XXX) identified in the detector file,
	SNR is the signal to noise ratio, and NEF is the noise
	equivalent quanta per unit area
	(photons/cm^2/mAs times mAs*area).

directories/links:

        _detector:     link to a directory containing
                       detector files in standard format.

arguments:

	detector_file: ascii file with energy absorbtion and noise
			efficiency in the following format:

			line1: label describing the detector
			line2: units min_keV max_keV dkeV
			       note units is in 6 character format
			line3: "keV"  "sig_eff"  "noise_eff2"
			line4...:three column table of detector data
				see definitions below for the efficiencies.

	mAs:		product of milliamps and exposure time
			(set to 1 to keep normalization)

	area:		Effective area of a detector element in cm2

	label_flag:	= 0 for no printing of column labels
			= 1 for printing of column labels

associated files:

	spectra.tmp:  	spectra of photons at a particular distance.

	  note:	The spectra.tmp file must be in /cm^2 units or the routine
		will return an error. Units of either photons/ or ergs/
		can be used and the routine will do the necessary conversion.

	detector_file:	see above

method:
	signal=  area * mAs *integral{ flux * E * sig_eff * dE} 

	noise =  [area * mAs * integral{flux * E*E * noise_eff * dE} ]**.5

		where flux is normalized to mAs, photons/cm2/mAs.

	SNR    = signal/noise

	NEQ    =  (SNR)**2 , noise equivalent quanta (no. of quanta), 

		Note on NEQ units:
			If the the mAs and area are both entered
			as 1.0,  the value returned for NEQ can
			be considered to have units of a fluence rate;
				photons/cm^2/mAs.
			Altenatively, if the area is entered as 1.0 
			but the mAs explicitly declared, the units will be
				photons/cm^2
			which could be called the
			noise equivalent fluence (NEF).
	
		sig_eff = [integral{prob(e,E) * e}de]/E

		noise_eff2 = [integral{prob(e,E) * e * e}de]/E*E

		where prob(e,E) is the probability that a photon of energy
		      E stikes the detector and deposits a signal e. 
		      This probability is normalized to a unit incident 
		      photon and thus integral{prob(e,E)*de} is typically less 
		      that 1.0 and equal to the fraction of input photons 
		      that interact in the detector and deposit energy.
		      sig_eff and noise_eff2 are the normalized first and 
		      second moments of the signal deposition probability.

		      sig_eff and (noise_eff2)**.5 are assumed to have
		      units of units/keV where units is specified in the
		      detector file. For units of keV/keV the efficiencies
		      are normalized energy detection efficiencies.
		      Efficiencies of electrons/keV are common and result
		      in signal and noise values with units of electrons.

                Alternatively, sig_eff and noise_eff2 may be computed from
                      prob(n,E) rather than prob(e,E) where prob(n,E) is the
                      probability that a photon of energy E strikes the
                      detector and produces n electrons in the collecting
                      sensors of the detector. When computed in this fashion,
                      sig_eff has units of electrons per keV and noise_eff2
                      has units of (electrons/keV)**2.

