Index: trunk/ippTools/src/magicdstool.c
===================================================================
--- trunk/ippTools/src/magicdstool.c	(revision 27786)
+++ trunk/ippTools/src/magicdstool.c	(revision 28536)
@@ -122,6 +122,8 @@
     PXOPT_COPY_S64(config->args, where, "-exp_id",  "exp_id", "==");
     PXOPT_COPY_S64(config->args, where, "-chip_id", "chip_id", "==");
+    PXOPT_COPY_S64(config->args, where, "-chip_bg_id", "chip_bg_id", "==");
     PXOPT_COPY_S64(config->args, where, "-cam_id",  "cam_id", "==");
     PXOPT_COPY_S64(config->args, where, "-warp_id", "warp_id", "==");
+    PXOPT_COPY_S64(config->args, where, "-warp_bg_id", "warp_bg_id", "==");
     PXOPT_COPY_S64(config->args, where, "-diff_id", "diff_id", "==");
     PXOPT_COPY_S64(config->args, where, "-magic_id","magicRun.magic_id", "==");
@@ -140,4 +142,7 @@
         query = pxDataGet("magicdstool_definebyquery_chip.sql");
         break;
+    case IPP_STAGE_CHIP_BG:
+        query = pxDataGet("magicdstool_definebyquery_chip_bg.sql");
+        break;
     case IPP_STAGE_CAMERA:
         query = pxDataGet("magicdstool_definebyquery_camera.sql");
@@ -145,4 +150,7 @@
     case IPP_STAGE_WARP:
         query = pxDataGet("magicdstool_definebyquery_warp.sql");
+        break;
+    case IPP_STAGE_WARP_BG:
+        query = pxDataGet("magicdstool_definebyquery_warp_bg.sql");
         break;
     case IPP_STAGE_DIFF:
@@ -720,4 +728,7 @@
         query = "UPDATE chipProcessedImfile SET magicked = %" PRId64 " where chip_id = %" PRId64 " AND class_id = '%s'";
         break;
+    case IPP_STAGE_CHIP_BG:
+        query = "UPDATE chipBackgroundImfile SET magicked = %" PRId64 " where chip_bg_id = %" PRId64 " AND class_id = '%s'";
+        break;
     case IPP_STAGE_CAMERA:
         // no there is no magicked column in camProcessedExp so we have nothing to do
@@ -727,4 +738,7 @@
         query = "UPDATE warpSkyfile SET magicked = %" PRId64 " where warp_id = %" PRId64 " AND skycell_id = '%s'";
         break;
+    case IPP_STAGE_WARP_BG:
+        query = "UPDATE warpBackgroundSkyfile SET magicked = %" PRId64 " where warp_bg_id = %" PRId64 " AND skycell_id = '%s'";
+        break;
     case IPP_STAGE_DIFF:
         query = "UPDATE diffSkyfile SET magicked = %" PRId64 " where diff_id = %" PRId64 " AND skycell_id = '%s'";
@@ -794,4 +808,7 @@
         query = "UPDATE chipRun SET magicked = %" PRId64 " where chip_id = %" PRId64;
         break;
+    case IPP_STAGE_CHIP_BG:
+        query = "UPDATE chipBackgroundRun SET magicked = %" PRId64 " where chip_bg_id = %" PRId64;
+        break;
     case IPP_STAGE_CAMERA:
         query = "UPDATE camRun SET magicked = %" PRId64 " where cam_id = %" PRId64;
@@ -799,4 +816,7 @@
     case IPP_STAGE_WARP:
         query = "UPDATE warpRun SET magicked = %" PRId64 " where warp_id = %" PRId64;
+        break;
+    case IPP_STAGE_WARP_BG:
+        query = "UPDATE warpBackgroundRun SET magicked = %" PRId64 " where warp_bg_id = %" PRId64;
         break;
     case IPP_STAGE_DIFF:
