Index: trunk/ippTools/src/dettool.c
===================================================================
--- trunk/ippTools/src/dettool.c	(revision 7387)
+++ trunk/ippTools/src/dettool.c	(revision 7421)
@@ -31,5 +31,5 @@
 static bool masterMode(pxConfig *config);
 
-static detInputExpRow *rawDetrenTodetInputExpRow(rawDetrendExpRow *rawExp, psS32 det_id);
+static detInputExpRow *rawDetrenTodetInputExpRow(rawDetrendExpRow *rawExp, psS32 det_id, psS32 iteration);
 static psArray *searchRawImfiles(pxConfig *config, psMetadata *where);
 
@@ -83,8 +83,21 @@
 
     // what type of detRun is this?
+    // det_type & iteration are required
     psString det_type = psMetadataLookupStr(&status, config->args, "-det_type");
-    // this flag is required
+    if (!status) {
+        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -det_type");
+        return false;
+    }
     if (!det_type) {
         psError(PS_ERR_UNKNOWN, true, "-det_type is required");
+        return false;
+    }
+    psS32 iteration = psMetadataLookupS32(&status, config->args, "-iteration");
+    if (!status) {
+        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -iteration");
+        return false;
+    }
+    if (!iteration) {
+        psError(PS_ERR_UNKNOWN, true, "-iteration is required");
         return false;
     }    
@@ -187,5 +200,6 @@
         detInputExpRow *inputExp = rawDetrenTodetInputExpRow(
             rawExps->data[i],
-            det_id
+            det_id,
+            iteration
         );
         psArrayAdd(inputExps, 0, inputExp);
@@ -286,5 +300,5 @@
 }
 
-static detInputExpRow *rawDetrenTodetInputExpRow(rawDetrendExpRow *rawExp, psS32 det_id)
+static detInputExpRow *rawDetrenTodetInputExpRow(rawDetrendExpRow *rawExp, psS32 det_id, psS32 iteration)
 {
     PS_ASSERT_PTR_NON_NULL(rawExp, NULL);
@@ -292,4 +306,5 @@
     return detInputExpRowAlloc(
         det_id,
+        iteration,
         rawExp->exp_id,
         rawExp->camera,
@@ -765,4 +780,13 @@
         return false;
     }
+    psS32 iteration = psMetadataLookupS32(&status, config->args, "-iteration");
+    if (!status) {
+        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -iteration");
+        return false;
+    }
+    if (!iteration) {
+        psError(PS_ERR_UNKNOWN, true, "-iteration is required");
+        return false;
+    }    
     psString class_id = psMetadataLookupStr(&status, config->args, "-class_id");
     if (!status) {
@@ -835,5 +859,5 @@
     // create a new detStackedImfile object
     detStackedImfileRow *stackedImfile = detStackedImfileRowAlloc(
-        (psS32)atol(det_id), class_id, uri, stats, recipe
+        (psS32)atol(det_id), iteration, class_id, uri, stats, recipe
     );   
 
@@ -1091,4 +1115,13 @@
         return false;
     }
+    psS32 iteration = psMetadataLookupS32(&status, config->args, "-iteration");
+    if (!status) {
+        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -iteration");
+        return false;
+    }
+    if (!iteration) {
+        psError(PS_ERR_UNKNOWN, true, "-iteration is required");
+        return false;
+    }    
     psString class_id = psMetadataLookupStr(&status, config->args, "-class_id");
     if (!status) {
@@ -1169,5 +1202,5 @@
     // create a new detNormalizedImfile object
     detNormalizedImfileRow *masterImfile = detNormalizedImfileRowAlloc(
-        (psS32)atol(det_id), class_id, uri, stats, recipe
+        (psS32)atol(det_id), iteration, class_id, uri, stats, recipe
     );   
 
@@ -1353,4 +1386,13 @@
         return false;
     }
+    psS32 iteration = psMetadataLookupS32(&status, config->args, "-iteration");
+    if (!status) {
+        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -iteration");
+        return false;
+    }
+    if (!iteration) {
+        psError(PS_ERR_UNKNOWN, true, "-iteration is required");
+        return false;
+    }    
     psString exp_id = psMetadataLookupStr(&status, config->args, "-exp_id");
     if (!status) {
@@ -1440,4 +1482,5 @@
     detResidImfileAnalysisRow *residImfile = detResidImfileAnalysisRowAlloc(
                 (psS32)atol(det_id),
+                iteration,
                 exp_id,
                 class_id,
@@ -1507,4 +1550,13 @@
         return false;
     }
+    psS32 iteration = psMetadataLookupS32(&status, config->args, "-iteration");
+    if (!status) {
+        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -iteration");
+        return false;
+    }
+    if (!iteration) {
+        psError(PS_ERR_UNKNOWN, true, "-iteration is required");
+        return false;
+    }    
     psString exp_id = psMetadataLookupStr(&status, config->args, "-exp_id");
     if (!status) {
@@ -1572,4 +1624,5 @@
     detResidExpAnalysisRow *residExp = detResidExpAnalysisRowAlloc(
                 (psS32)atol(det_id),
+                iteration,
                 exp_id,
                 stats,
@@ -1710,4 +1763,34 @@
 {
     PS_ASSERT_PTR_NON_NULL(config, false);
-    return true;
-}
+
+    // join detMasterFrame & detNormalizedImfile tables
+    // no options are required... use the default where statement
+    psArray *normalizedImfiles = detNormalizedImfileSelectRowObjects(
+            config->dbh, config->where, 0);
+    if (!normalizedImfiles) {
+        psError(PS_ERR_UNKNOWN, false, "no detNormalizedImfile rows found");
+        return false;
+    }
+
+    if (psArrayLength(normalizedImfiles)) {
+        // print imfile list
+        psMetadata *output = psMetadataAlloc();
+        for (long i = 0; i < psArrayLength(normalizedImfiles); i++) {
+            psMetadata *md = detMasterFrameMetadataFromObject(
+                    normalizedImfiles->data[i]);
+            psMetadataAddMetadata(
+                output, PS_LIST_TAIL, "detNormalizedImfile",
+                PS_META_DUPLICATE_OK, NULL, md
+            );
+        }
+
+        psString str = psMetadataConfigFormat(output); 
+        psFree(output);
+        fprintf(stdout, "%s\n", str);
+        psFree(str);
+    }
+
+    psFree(normalizedImfiles);
+
+    return true;
+}
