Index: /branches/eam_branches/20091201/ippScripts/scripts/magic_process.pl
===================================================================
--- /branches/eam_branches/20091201/ippScripts/scripts/magic_process.pl	(revision 26811)
+++ /branches/eam_branches/20091201/ippScripts/scripts/magic_process.pl	(revision 26812)
@@ -31,4 +31,5 @@
 my $magictool      = can_run('magictool') or (warn "Can't find magictool" and $missing_tools = 1);
 my $detectstreaks = can_run('DetectStreaks') or (warn "Can't find DetectStreaks" and $missing_tools = 1);
+my $VerifyStreaks = can_run('VerifyStreaks') or (warn "Can't find VerifyStreaks, will not produce png images");
 if ($missing_tools) {
     warn("Can't find required tools.");
@@ -37,5 +38,5 @@
 
 # Parse the command-line arguments
-my ($magic_id, $node, $camera, $dbname, $outroot, $save_temps, $verbose, $no_update, $no_op, $logfile);
+my ($magic_id, $node, $camera, $dbname, $baseroot, $save_temps, $verbose, $no_update, $no_op, $logfile);
 
 GetOptions(
@@ -44,5 +45,5 @@
            'camera=s'        => \$camera,     # Camera name
            'dbname=s'        => \$dbname,     # Database name
-           'outroot=s'       => \$outroot,    # Output root name
+           'baseroot=s'      => \$baseroot,   # Output root name
            'save-temps'      => \$save_temps, # Save temporary files?
            'verbose'         => \$verbose,    # Print stuff?
@@ -53,24 +54,30 @@
 
 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
-pod2usage( -msg => "Required options: --magic_id --camera --node --outroot",
+pod2usage( -msg => "Required options: --magic_id --camera --node --baseroot",
            -exitval => 3) unless
     defined $magic_id and
     defined $node and
     defined $camera and
-    defined $outroot;
+    defined $baseroot;
 
 my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $magic_id, $node, $PS_EXIT_CONFIG_ERROR ); # IPP configuration
 $ipprc->redirect_output($logfile) or my_die( "Unable to redirect output", $magic_id, $node, $PS_EXIT_SYS_ERROR ) if $logfile;
 
-# DetectStreaks doesn't know about nebulous. It expects to be able to append strings to outroot
-# to form valid file names.
-# So forbid nebulous path in outroot. We could relax this by change DetectStreaks to take all
-# of the file names as arguments or by teaching it about Nebulous
-if ($outroot =~ 'neb:/') {
+# DetectStreaks doesn't know about nebulous. It expects to be able to
+# append strings to baseroot to form valid file names.  So forbid
+# nebulous path in baseroot. We could relax this by change
+# DetectStreaks to take all of the file names as arguments or by
+# teaching it about Nebulous
+if ($baseroot =~ 'neb:/') {
     &my_die("DetectStreaks does not support nebulous paths in outroot", $magic_id, $node, $PS_EXIT_CONFIG_ERROR);
 }
 
+# most filenames are of the form $baseroot.$node.*, but VerifyStreaks
+# needs access to $baseroot.*, so we construct $outroot =
+# $baseroot.$node in here
+
 # resolve any path:// or file:// in outroot
-$outroot = $ipprc->file_resolve($outroot);
+$baseroot = $ipprc->file_resolve($baseroot);
+my $outroot = "$baseroot.$node";
 
 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files
@@ -255,4 +262,6 @@
     }
 
+    &run_verifystreaks($baseroot);
+
     my $command = "$magictool -addmask";
     $command   .= " -magic_id $magic_id";
@@ -275,7 +284,50 @@
 }
 
-
-
 ### Pau.
+
+sub run_verifystreaks {
+
+    my $baseroot = shift;
+
+    unless ($VerifyStreaks) { 
+	print STDERR "skipping VerifyStreaks\n";
+	return 1;
+    }
+
+    # VerifyStreaks --out $outdir --clusters $outdir/clusters.list $rootname.root.streakMap
+
+    my $outdir = "$baseroot.verify";
+
+    my($status) = system ("mkdir -p $outdir");
+    if ($status) { 
+	print STDERR "failed to create output directory $outdir\n"; 
+	return 1;
+    }
+
+    my @files = <$baseroot.*.clusters>;
+    unless (OPEN (FILE, ">$outdir/clusters.list")) {
+	print "failed to create cluster file $outdir/clusters.list\n"; 
+	return 1;
+    }
+    foreach my $file (@files) {
+	print FILE "$file\n";
+    }
+    close (FILE);
+    if ($status) { 
+	print "failed to create cluster file $outdir/clusters.list\n"; 
+	return 1;
+    }
+
+    my $command = "$VerifyStreaks --out $outdir --clusters $outdir/clusters.list $baseroot.root.streakMap";
+
+    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
+	run(command => $command, verbose => $verbose);
+    unless ($success) {
+	print "failed to run VerifyStreaks:\n stderr: $stderr_buff\n stdout: $stdout_buff"; 
+	return 1;
+    }
+
+    return 0;
+}
 
 sub open_list_file {
Index: /branches/eam_branches/20091201/ippTasks/magic.pro
===================================================================
--- /branches/eam_branches/20091201/ippTasks/magic.pro	(revision 26811)
+++ /branches/eam_branches/20091201/ippTasks/magic.pro	(revision 26812)
@@ -283,10 +283,7 @@
     $WORKDIR = $WORKDIR_TEMPLATE
 
-    sprintf outroot "%s/%s/%s.mgc.%s.%s" $WORKDIR $EXP_ID $EXP_ID $MAGIC_ID $NODE
-
-    ## generate output log based on filerule (convert the URI to a PATH)
-    ## caution with neb:// names here:
-    # $logfile = `ipp_filename.pl --filerule LOG.EXP --camera $CAMERA --class_id $MAGIC_ID --basename $outroot`
-    $logfile = $outroot.log
+    sprintf baseroot "%s/%s/%s.mgc.%s" $WORKDIR $EXP_ID $EXP_ID $MAGIC_ID
+
+    $logfile = $baseroot.$NODE.log
     if ("$logfile" == "") 
       echo "WARNING: logfile not defined in magic.process.run"
@@ -299,5 +296,5 @@
     mkdir $outpath
 
-    $run = magic_process.pl --magic_id $MAGIC_ID --camera $CAMERA --node $NODE --outroot $outroot --logfile $logfile
+    $run = magic_process.pl --magic_id $MAGIC_ID --camera $CAMERA --node $NODE --baseroot $baseroot --logfile $logfile
     add_standard_args run
 
