Index: trunk/ippTasks/detrend.process.pro
===================================================================
--- trunk/ippTasks/detrend.process.pro	(revision 12747)
+++ trunk/ippTasks/detrend.process.pro	(revision 13680)
@@ -154,13 +154,18 @@
     ## output log filename
     if ("$WORKDIR" == "NULL")
-      $outroot = `pwd`
-    else
-      $outroot = `ipp_datapath.pl $WORKDIR`
-    end
-    $outroot = $outroot/$CAMERA.$DET_TYPE.$DET_ID/$EXP_TAG
-    $logfile = $outroot/detproc.$DET_ID.$CLASS_ID.log
+      $outpath = `pwd`
+    else
+      $outpath = `ipp_datapath.pl $WORKDIR`
+    end
+    $outpath = $outpath/$CAMERA.$DET_TYPE.$DET_ID/$EXP_TAG
+    $outroot = $outpath/$EXP_TAG.detproc.$DET_ID
+    $logfile = `ipp_filename.pl --filerule LOG.IMFILE --camera $CAMERA --class_id $CLASS_ID --basename $outroot`
+    if ($logfile == "") 
+      $logfile = $outroot.$CLASS_ID.log
+    end
+
     stdout $logfile
     stderr $logfile
-    exec mkdir -p $outroot
+    exec mkdir -p $outpath
 
     $run = detrend_process_imfile.pl --det_id $DET_ID --det_type $DET_TYPE --exp_tag $EXP_TAG --class_id $CLASS_ID --input_uri $URI --camera $CAMERA
@@ -276,13 +281,18 @@
     # XXX push this into the filerules?
     if ("$WORKDIR" == "NULL")
-      $outroot = `pwd`
-    else
-      $outroot = `ipp_datapath.pl $WORKDIR`
-    end
-    $outroot = $outroot/$CAMERA.$DET_TYPE.$DET_ID/$EXP_TAG
-    $logfile = $outroot/detproc.$DET_ID.$ITERATION.log
+      $outpath = `pwd`
+    else
+      $outpath = `ipp_datapath.pl $WORKDIR`
+    end
+    $outpath = $outpath/$CAMERA.$DET_TYPE.$DET_ID/$EXP_TAG
+    $outroot = $outpath/$EXP_TAG.detproc.$DET_ID.$ITERATION
+    $logfile = `ipp_filename.pl --filerule LOG.EXP --camera $CAMERA --class_id NONE --basename $outroot`
+    if ($logfile == "") 
+      $logfile = $outroot.log
+    end
+
     stdout $logfile
     stderr $logfile
-    exec mkdir -p $outroot
+    exec mkdir -p $outpath
 
     $run = detrend_process_exp.pl --det_id $DET_ID --exp_tag $EXP_TAG --det_type $DET_TYPE --camera $CAMERA
