Index: trunk/ippScripts/scripts/magic_process.pl
===================================================================
--- trunk/ippScripts/scripts/magic_process.pl	(revision 25934)
+++ trunk/ippScripts/scripts/magic_process.pl	(revision 26901)
@@ -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,54 @@
 }
 
-
-
 ### 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 $FILE;
+
+    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) {
+        $file =~ s|.clusters$||;
+        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";
+        return 1;
+    }
+
+    return 0;
+}
 
 sub open_list_file {
