Index: trunk/ippScripts/scripts/detrend_resid_exp.pl
===================================================================
--- trunk/ippScripts/scripts/detrend_resid_exp.pl	(revision 23323)
+++ trunk/ippScripts/scripts/detrend_resid_exp.pl	(revision 23342)
@@ -45,5 +45,5 @@
 
 # parse the command-line options
-my ( $det_id, $iter, $exp_id, $exp_tag, $det_type, $camera, $filter, $reject, $outroot, $dbname, $reduction,
+my ( $det_id, $iter, $exp_id, $exp_tag, $det_mode, $det_type, $camera, $filter, $reject, $outroot, $dbname, $reduction,
      $verbose, $no_update, $no_op, $save_temps, $redirect );
 GetOptions(
@@ -53,4 +53,5 @@
            'exp_tag|=s'        => \$exp_tag,
            'det_type|t=s'      => \$det_type,
+           'det_mode=s'        => \$det_mode,
            'camera=s'          => \$camera,
            'outroot|w=s'       => \$outroot,   # output file base name
@@ -74,4 +75,5 @@
     defined $exp_tag  and
     defined $det_type and
+    defined $det_mode and
     defined $camera   and
     defined $outroot;
@@ -93,5 +95,5 @@
 # Get list of normalizations by class_id : stored as $norms; save to temp file for ppImage runs below
 my (%norms, $normsName);
-{
+if ($det_mode eq 'master') {
     # dettool command to select imfile data for this exp_id
     $command  = "$dettool -normalizedstat";
@@ -164,4 +166,6 @@
     my ($statFile, $statName) = tempfile( "/tmp/$exp_tag.detresid.$det_id.$iter.stats.XXXX", UNLINK => !$save_temps );
 
+    print $statFile "rawResidImfile MULTI\n";
+
     # parse the file info in the metadata
     # as we parse the list of files and their stats, apply the normalization to the relevant fields
@@ -188,5 +192,8 @@
         # modify and save the data in this block:
         foreach my $data (@$mdComponents) {
-            my $norm = $norms{$class_id};
+	    my $norm = 1.0;
+	    if ($det_mode eq "master") {
+		$norm = $norms{$class_id};
+	    }
 
             # fields to modify by the normalization:
@@ -252,5 +259,5 @@
     $command .= " -recipe PPIMAGE PPIMAGE_J1";
     $command .= " -recipe JPEG $recipe";
-    $command .= " -normlist $normsName";
+    $command .= " -normlist $normsName" if defined $normsName;
     $command .= " -dbname $dbname" if defined $dbname;
     ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
@@ -267,5 +274,5 @@
     $command .= " -recipe PPIMAGE PPIMAGE_J2";
     $command .= " -recipe JPEG $recipe";
-    $command .= " -normlist $normsName";
+    $command .= " -normlist $normsName" if defined $normsName;
     $command .= " -dbname $dbname" if defined $dbname;
     ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
