Index: trunk/ippScripts/scripts/detrend_reject_imfile.pl
===================================================================
--- trunk/ippScripts/scripts/detrend_reject_imfile.pl	(revision 14823)
+++ trunk/ippScripts/scripts/detrend_reject_imfile.pl	(revision 16196)
@@ -43,5 +43,5 @@
 
 # parse the command-line options
-my ($det_id, $iter, $exp_id, $exp_tag, $det_type, $camera, $filter, $reject, $dbname, $workdir, $reduction, $no_update, $no_op);
+my ($det_id, $iter, $exp_id, $exp_tag, $det_type, $camera, $filter, $reject, $outroot, $dbname, $reduction, $no_update, $no_op);
 GetOptions(
 	   'det_id|d=s'        => \$det_id,
@@ -51,8 +51,8 @@
 	   'det_type|t=s'      => \$det_type,
 	   'camera=s'          => \$camera,
+	   'outroot|w=s'       => \$outroot,   # output file base name
 	   'filter=s'          => \$filter,
 	   'reject'            => \$reject,
 	   'dbname|d=s'        => \$dbname, # Database name
-	   'workdir|w=s'       => \$workdir, # Working directory, for output files
 	   'reduction|=s'      => \$reduction,
 	   'no-update'         => \$no_update,
@@ -61,12 +61,13 @@
 
 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
-pod2usage( -msg => "Required options: --det_id --iteration --exp_id --exp_tag --det_type --camera",
-	   -exitval => 3)
-    unless defined $det_id
-    and defined $iter
-    and defined $exp_id
-    and defined $exp_tag
-    and defined $det_type
-    and defined $camera;
+pod2usage( -msg => "Required options: --det_id --iteration --exp_id --exp_tag --det_type --camera --outroot",
+	   -exitval => 3) unless 
+    defined $det_id   and 
+    defined $iter     and 
+    defined $exp_id   and 
+    defined $exp_tag  and 
+    defined $det_type and 
+    defined $camera   and
+    defined $outroot;
 
 # load IPP config information for the specified camera
@@ -144,10 +145,15 @@
 }
 
-# Output products
-$workdir = caturi( $workdir, "$camera.$det_type.$det_id" ) if defined $workdir;
-my $outputRoot = $ipprc->file_prepare( "$exp_tag/$exp_tag.detresid.$det_id.$iter", $workdir, ${$files}[0]->{path_base} );
-my $jpeg1Name  = $ipprc->filename("PPIMAGE.JPEG1", $outputRoot); # Binned JPEG #1
-my $jpeg2Name  = $ipprc->filename("PPIMAGE.JPEG2", $outputRoot); # Binned JPEG #2
-my $logName    = $ipprc->filename("LOG.EXP", $outputRoot); # Name for log
+# outroot examples (HOST components must be set)
+# file://data/ipp004.0/gpc1/20080130
+# neb:///ipp004-v1/gpc1/20080130
+# neb:///*/gpc1/20080130 (volume not specified)
+
+# check for existing directory, generate if needed
+$ipprc->outroot_prepare($outroot);
+
+my $jpeg1Name  = $ipprc->filename("PPIMAGE.JPEG1", $outroot); # Binned JPEG #1
+my $jpeg2Name  = $ipprc->filename("PPIMAGE.JPEG2", $outroot); # Binned JPEG #2
+my $logName    = $ipprc->filename("LOG.EXP",       $outroot); # Name for log
 
 my $logFile;
@@ -170,5 +176,5 @@
 unless ($no_op) {
     # Make the jpeg for binning 1
-    $command = "$ppImage -list $list1Name $outputRoot -recipe PPIMAGE $recipe1"; # Command to run
+    $command = "$ppImage -list $list1Name $outroot -recipe PPIMAGE $recipe1"; # Command to run
     ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
 	run(command => $command, verbose => 1);
@@ -180,5 +186,5 @@
     
     # Make the jpeg for binning 2
-    $command = "$ppImage -list $list2Name $outputRoot -recipe PPIMAGE $recipe2"; # Command to run
+    $command = "$ppImage -list $list2Name $outroot -recipe PPIMAGE $recipe2"; # Command to run
     ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
 	run(command => $command, verbose => 1);
@@ -502,5 +508,5 @@
 
 $command  = "$dettool -addresidexp -det_id $det_id -iteration $iter -exp_id $exp_id";
-$command .= " -recip $recipe1,$recipe2 -path_base $outputRoot ";
+$command .= " -recip $recipe1,$recipe2 -path_base $outroot ";
 $command .= ' -reject' if $reject;
 $command .= " -dbname $dbname" if defined $dbname;
