#ifndef TS_MATCH_STATS_H
#define TS_MATCH_STATS_H

#include "taCalibObj.h"

/* Statistics for comparing a set of pairs of numbers */
typedef struct tsDiff
{
  double av;   /* average difference */
  double rms;  /* rms difference */
  int nPairs;  /* number of pairs used for statistics */
} TSDIFF;  /* pragma SCHEMA */

/* Statistics for comparing objects in a single field of the same type with
   its matching objects in another (could be the same) Frames Pipeline Run */
typedef struct tsStats
{
  int nObjects;        /* number of GOOD objects */
  int nMatches;        /* number of matched GOOD objects */
  int nObjectsBright;  /* number of bright GOOD objects */
  int nMatchesBright;  /* number of matched bright GOOD objects */
  TSDIFF row;          /* bright matches row differences (pixels or arcsec) */
  TSDIFF col;          /* bright matches column differences(pixels or arcsec)*/
  TSDIFF mag[5];       /* bright matches mag differences (luptitudes, ugriz) */
  TSDIFF color[4];     /* bright matches color differences (luptitudes,
			  u-g, g-r, r-i, i-z) */
} TSSTATS;   /* pragma SCHEMA */

/* Matching statistics for a single field */
typedef struct tsMatchStats
{
  float field;           /* field number */
  int nOverlap;          /* number of unmatched GOOD stars and galaxies which
			    are neither OK_RUN nor DUPLICATE */
  int nOverlapBright;    /* number of unmatched bright GOOD stars and galaxies
			    which are neither OK_RUN nor DUPLICATE */
  int nMismatches;       /* mismatched star-galaxy pairs */
  int nMismatchesBright; /* bright mismatched star-galaxy pairs */
  int nUnknown;          /* number of UNK objects */
  int nUnknownBright;    /* number of bright UNK objects */
  TSSTATS stars;         /* star matching statistics */
  TSSTATS galaxies;      /* galaxies matching statistics */
} TSMATCHSTATS;   /* pragma SCHEMA */

/* A single matched pair of stars */
typedef struct tsMatchedPair
{
  int objc_flags[2];      /* objc_flags for each object in pair (order 1,2) */
  int objc_flags2[2];     /* objc_flags2 for each object in pair (order 1,2) */
  double mu;              /* Mu of first object (deg) */
  double dmu;             /* Difference in mu (1-2, asec) */
  double nu;              /* Nu of first object (deg) */
  double dnu;             /* Difference in nu (1-2, asec)) */
  double mag[5];          /* Magnitudes of first object (u,g,r,i,z) */
  double dmag[5];         /* Difference in magnitudes (1-2) */
  double color[4];        /* Model colors of first object (luptititudes,
			     u-g, g-r, r-i, i-z) */
  double dcolor[4];       /* Differences in model colors (1-2, luptititudes,
			     u-g, g-r, r-i, i-z) */
  TA_CALIB_OBJ *obj1;     /* Handle to first object */
  TA_CALIB_OBJ *obj2;     /* Handle to matching object */
} TSMATCHEDPAIR;  /* pragma SCHEMA */

#endif
