Index: /tags/ipp-20111110/psModules/src/objects/pmSourcePhotometry.c
===================================================================
--- /tags/ipp-20111110/psModules/src/objects/pmSourcePhotometry.c	(revision 32842)
+++ /tags/ipp-20111110/psModules/src/objects/pmSourcePhotometry.c	(revision 32843)
@@ -56,4 +56,6 @@
 static psImageMaskType maskBurntool = 0;
 static psImageMaskType maskConvPoor = 0;
+static psImageMaskType maskGhost    = 0;
+static psImageMaskType maskGlint    = 0;
 
 bool pmSourceMagnitudesInit (pmConfig *config, psMetadata *recipe)
@@ -68,4 +70,6 @@
 	maskBurntool = pmConfigMaskGet("BURNTOOL", config);
 	maskConvPoor = pmConfigMaskGet("CONV.POOR", config);
+	maskGhost    = pmConfigMaskGet("GHOST", config);
+	maskGlint    = pmConfigMaskGet("GHOST", config);
 	maskSuspect  = maskSpike | maskStarCore | maskBurntool | maskConvPoor;
     }
@@ -533,4 +537,32 @@
     }
 
+    // Check that if the peak is on/off a ghost, glint, or diffraction spike.  In regular IPP
+    // processing, these values are only set in the image mask after the 'camera' stage
+
+    int xChip = source->peak->x;
+    int yChip = source->peak->y;
+
+    bool onChip = true;
+    onChip &= (xChip >= 0);
+    onChip &= (xChip < mask->numCols);
+    onChip &= (yChip >= 0);
+    onChip &= (yChip < mask->numRows);
+    if (!onChip) {
+	// if the source is off the edge of the chip, raise a different bit?
+	source->mode |= PM_SOURCE_MODE_OFF_CHIP;
+    } else {
+	psImageMaskType maskValue = mask->data.PS_TYPE_IMAGE_MASK_DATA[yChip][xChip];
+	if (maskValue & maskGhost) {
+	    source->mode |= PM_SOURCE_MODE_ON_GHOST;
+	}
+	pmSourceMode PM_SOURCE_MODE_ON_GLINT = PM_SOURCE_MODE_ON_GHOST;
+	if (maskValue & maskGlint) {
+	    source->mode |= PM_SOURCE_MODE_ON_GLINT;
+	}
+	if (maskValue & maskSpike) {
+	    source->mode |= PM_SOURCE_MODE_ON_SPIKE;
+	}
+    }
+
     return (true);
 }
