#ifndef TA_QUASARS_PARAM_H
#define TA_QUASARS_PARAM_H

#ifdef __cplusplus
extern "C" {
#endif

/*
 * Quasars Working Group target selection interface
 */

#include <dervish.h>
#include "taCalibObj.h"

/* Maximum number of locus points */
#define TA_MAX_LOCUS_POINTS 50


/* Quasars Working Group target selection parameters */

typedef struct taQuasarLocus
{
  float lk[TA_MAX_LOCUS_POINTS]; 	/* Stellar locus arrays k values */
  int ln[TA_MAX_LOCUS_POINTS]; 		/* Stellar locus arrays npts values (not used)*/
  double lxl[TA_MAX_LOCUS_POINTS]; 	/* Stellar locus arrays xlocus */
  double lyl[TA_MAX_LOCUS_POINTS]; 	/* Stellar locus arrays ylocus */
  double lzl[TA_MAX_LOCUS_POINTS]; 	/* Stellar locus arrays zlocus */
  double lkhatx[TA_MAX_LOCUS_POINTS]; 	/* Stellar locus arrays kx */
  double lkhaty[TA_MAX_LOCUS_POINTS]; 	/* Stellar locus arrays ky */
  double lkhatz[TA_MAX_LOCUS_POINTS]; 	/* Stellar locus arrays kz */
  double la[TA_MAX_LOCUS_POINTS]; 	/* Stellar locus arrays a */
  double lb[TA_MAX_LOCUS_POINTS]; 	/* Stellar locus arrays b */
  double theta[TA_MAX_LOCUS_POINTS]; 	/* Stellar locus arrays theta */
  int   npts; 			        /* number of points in locus array */
  double mink;				/* first point in locus;  blue end */
  double minkdist;			/* radius from first point in locus;  blue end */
  double maxk;				/* last point in locus;  red end */
  double maxkdist;			/* radius from last point in locus;  red end */
  double nsigmaerrors;			/* radius multiplier for error Gaussian */
  double galaxyklimit;			/* k limit to consider extended sources with l>0 galaxies */
  char  LOCUSID[256];			/* id string for locus, i.e. CAP-LOCUS or SKIRT-LOCUS-1a */
} TA_QUASARS_LOCUS;  /* pragma SCHEMA */

typedef struct taQuasarsParams

{

  /* This will have to be modified if we use different loci for different
	l,b in the skirt */
  /* Variables that are currently in use have ** beginning the comment */

  TA_QUASARS_LOCUS *caplocusarray;/** this must be allocated when the files
					are read in */
  double *caplocusmaglimits;	/** this must be allocated when the files
					are read in */
  int capnloci;			/** number of loci in the cap */
  TA_QUASARS_LOCUS *skirtlocusarray;/** this must be allocated when the files
					are read in */
  double *skirtlocusmaglimits;	/** this must be allocated when the files
					are read in */
  int skirtnloci;		/** number of loci in the skirt */
  TA_QUASARS_LOCUS *hizlocusarray;/** this must be allocated when the files
					are read in */
  double *hizlocusmaglimits;	/** this must be allocated when the files
					are read in */
  int hiznloci;			/** number of loci in the hiz array */
  char  LOCUSFILEDIR[256];	/** directory of locus point array param (need to expand for many loci)*/

  float magnitudeFuzz;		/** Maximum fuzz on magnitude limits */
  float drMin;			/* deVauc radius params */
  float drMax;			/* deVauc radius params look for fuzzies */
  float firstDelta;		/** first matching radius tolerance (arcsec) */

  float HIZULIMIT;		/* limiting magnitude to check error
				 * reasonableness in u' (luptitudes) */
  float HIZUERROR;		/* limiting error that is reasonable in u'
				 * (luptitudes) */
  float HIZGLIMIT;		/* limiting magnitude to check error
				 * reasonableness in g' (luptitudes) */
  float HIZGERROR;		/* limiting error that is reasonable in g'
				 * (luptitudes) */
  float HIZRLIMIT;		/* limiting magnitude to check error
				 * reasonableness in r' (luptitudes) */
  float HIZRERROR;		/* limiting error that is reasonable in r'
				 * (luptitudes) */
  float HIZILIMIT;		/* limiting magnitude to check error
				 * reasonableness in i' (luptitudes) */
  float HIZIERROR;		/* limiting error that is reasonable in i'
				 * (luptitudes) */
  float HIZZLIMIT;		/* limiting magnitude to check error
				 * reasonableness in z' (luptitudes) */
  float HIZZERROR;		/* limiting error that is reasonable in z'
				 * (luptitudes) */

  float LOWZULIMIT ;		/** limiting magnitude to check error
				 ** reasonableness in u' (luptitudes) */
  float LOWZUERROR;		/* limiting error that is reasonable in u'
				 * (luptitudes) */
  float LOWZGLIMIT ;		/** limiting magnitude to check error
				 ** reasonableness in g' (luptitudes) */
  float LOWZGERROR;		/* limiting error that is reasonable in g'
				 * (luptitudes) */
  float LOWZRLIMIT ;		/** limiting magnitude to check error
				 ** reasonableness in r' (luptitudes) */
  float LOWZRERROR;		/* limiting error that is reasonable in r'
				 * (luptitudes) */
  float LOWZILIMIT ;		/** limiting magnitude to check error
				 ** reasonableness in i' (luptitudes) */
  float LOWZIERROR;		/* limiting error that is reasonable in i'
				 * (luptitudes) */
  float LOWZZLIMIT ;		/** limiting magnitude to check error
				 ** reasonableness in z' (luptitudes) */
  float LOWZZERROR;		/* limiting error that is reasonable in z'
				 * (luptitudes) */
  float SYSUERR;                /* systematic error in u' (luptitudes) */
  float SYSGERR;                /* systematic error in u' (luptitudes) */
  float SYSRERR;                /* systematic error in u' (luptitudes) */
  float SYSIERR;                /* systematic error in u' (luptitudes) */
  float SYSZERR;                /* systematic error in u' (luptitudes) */



  float SPECGLIMIT;		/* limiting magnitude of spectrograph in g'
				 * (luptitudes) */
  float SPECRLIMIT;		/* limiting magnitude of spectrograph in r'
				 * (luptitudes) */
  float SPECILIMIT;		/* limiting magnitude of spectrograph in i'
				 * (luptitudes) */
  float IPSFLIMIT;		/* limiting magnitude to check for stellarness
				 * in i' (luptitudes) */
  float ZPSFLIMIT;		/* limiting magnitude to check for stellarness
				 * in z' (luptitudes) */
  float LIKELIHOOD;		/* limit on acceptable fit to PSF (0.8) */
  float PSFFRACTION;		/* fraction of light that must be contributed
				 * by the central point source (fuzzy QSO
				 * detector) */

  float CAPSTARS;		/** sets the limit on the boundary of the cap
				 ** region based on the stellar density from
				 ** the Bahcall-Soneira model (1500/sq degree
				 ** for M<20) */
  float CAPGLIMIT;		/* limiting magnitude for spectroscopy in g',
				 * corrected for reddening (luptitudes) */
  float CAPRLIMIT;		/* limiting magnitude for spectroscopy in r',
				 * corrected for reddening (luptitudes) */
  float CAPILIMIT;		/** limiting magnitude for spectroscopy in i',
				 ** corrected for reddening (luptitudes) */

  float HIZUILIMIT;		/* limiting U-I color for hi-z quasars
				* (luptitudes) */
  float HIZUZLIMIT;		/* limiting U-Z color for hi-z quasars
				 * (luptitudes) */
  float HIZGILIMIT;		/* limiting G-I color for hi-z quasars
				 * (luptitudes) */
  float HIZGZLIMIT;		/* limiting G-Z color for hi-z quasars
				 * (luptitudes) */

  float SKIRTGLIMIT;		/* limiting magnitude for spectroscopy in g',
				 * corrected for reddening (luptitudes) */
  float SKIRTRLIMIT;		/* limiting magnitude for spectroscopy in r',
				 * corrected for reddening (luptitudes) */
  float SKIRTILIMIT;		/** limiting magnitude for spectroscopy in i',
				 ** corrected for reddening (luptitudes) */

  float SKIRTFIRSTGLIMIT;	/* limiting magnitude for FIRST source skirt
				 * spectroscopy in g' (luptitudes) */
  float SKIRTFIRSTRLIMIT;	/* limiting magnitude for FIRST source skirt
				 * spectroscopy in r' (luptitudes) */
  float SKIRTFIRSTILIMIT;	/* limiting magnitude for FIRST source skirt
				 * spectroscopy in i' (luptitudes) */

  float FIRSTERRORBOX;		/* matching radius for FIRST source with
				 * optical source (arcsecs) */

  float MAXQSOSPERFIELD;	/* if more than N candidates found per
				 * 0.17x0.2 sq degree field, then something
				 * may be wrong */

  float MAXQSOSPERTARGETAREA;	/* if more than NN candidates found per
				 * 3x3 sq degree target area something may
				 * be wrong */
} TA_QUASARS_PARAMS;  /* pragma SCHEMA */

/* Prototypes */
int taQuasarsTargetSelect(TA_CALIB_OBJ *obj, const TA_QUASARS_PARAMS *params);

#ifdef __cplusplus
}
#endif

#endif
