Index: trunk/ippToPsps/jython/detectionbatch.py
===================================================================
--- trunk/ippToPsps/jython/detectionbatch.py	(revision 39101)
+++ trunk/ippToPsps/jython/detectionbatch.py	(revision 39109)
@@ -356,5 +356,5 @@
     Populates the ImageDetEffMeta table for this OTA
     '''
-    def populateImageDetEffMetaTablePart1(self, ota, header):
+    def populateImageDetEffMetaTablePart1(self, ota, header, deteffHeader):
         print "---- *** populate ImageDetEffMetaTablePart1"
         ippTableName = ota + "_deteff"
@@ -373,14 +373,17 @@
 
         # CZW: 20151110 This needs to get the deteff header as well.
-        nInjected = int(self.getKeyInt(header, 0, 'DETEFF.NUM'))
-        detectionThreshold = self.getKeyFloat(header, "%.8f", 'DETEFF.MAGREF')
+        nInjected = int(self.getKeyInt(deteffHeader, 0, 'DETEFF.NUM'))
+        magref = self.getKeyFloat(deteffHeader, "%.8f", 'DETEFF.MAGREF')
+
         expTime = self.getKeyFloat(header, "%.8f", 'EXPTIME')
         zp      = self.getKeyFloat(header, "%.8f", 'ZPT_OBS')
 
+        # zp correction comes from DVO (unless it is not found)
         zpImage = self.scratchDb.getImageZeroPoint(self.imageIDs[ota])
 
-        # XXX zp correction should come from DVO
-        detectionThreshold = detectionThreshold + zpImage + 2.5 * math.log10(expTime)
-
+        if zpImage < 0.0:
+            zpImage = zp
+
+        detectionThreshold = magref + zpImage + 2.5 * math.log10(expTime)
 
         sqlLine.group("frameID",          str(self.expID))
@@ -672,6 +675,8 @@
         self.updateImageID("ImageMeta_" + chipname, x, y) 
 
+        deteffHeader = self.fits.findAndReadHeader(chipname + ".deteff", self.config.test)
+
         # XXX EAM 20151024 : problem is here?
-        self.populateImageDetEffMetaTablePart1(chipname, header)
+        self.populateImageDetEffMetaTablePart1(chipname, header, deteffHeader)
         self.updateImageID("ImageDetEffMeta_" + chipname, x, y)
         
