Index: trunk/ippToPsps/jython/detectionbatch.py
===================================================================
--- trunk/ippToPsps/jython/detectionbatch.py	(revision 39094)
+++ trunk/ippToPsps/jython/detectionbatch.py	(revision 39097)
@@ -372,6 +372,18 @@
         sqlLine = sqlUtility("INSERT INTO " + tableName + "(")
 
+        nInjected = int(self.getKeyInt(header, 0, 'DETEFF.NUM'))
+        detectionThreshold = self.getKeyFloat(header, "%.8f", 'DETEFF.MAGREF')
+        expTime = self.getKeyFloat(header, "%.8f", 'EXPTIME')
+        zp      = self.getKeyFloat(header, "%.8f", 'ZPT_OBS')
+
+        zpImage = self.scratchDb.getImageZeroPoint(self.imageIDs[ota])
+
+        # XXX zp correction should come from DVO
+        detectionThreshold = detectionThreshold + zpImage + 2.5 * math.log10(expTime)
+
+
         sqlLine.group("frameID",          str(self.expID))
-        sqlLine.group("magref",           self.getKeyFloat(header,"%.8f","DETEFF.MAGREF"))
+        sqlLine.group("magref",           detectionThreshold)
+        sqlLine.group("nInjected",        nInjected)
         sql = sqlLine.make(") VALUES ( ", ")")
                       
@@ -1063,5 +1075,5 @@
         ## regex only works for -stilts import
         regex = ".*"
-    
+        
         ## for a quick test, just do the first chip:
         if self.config.test and self.config.camera == "gpc1":
