Index: trunk/tools/bills/comparep2detections
===================================================================
--- trunk/tools/bills/comparep2detections	(revision 39094)
+++ trunk/tools/bills/comparep2detections	(revision 39095)
@@ -7,4 +7,5 @@
 use Pod::Usage qw( pod2usage );
 use File::Basename;
+use PS::IPP::Config 1.01 qw( :standard );
 
 
@@ -13,5 +14,5 @@
 my $out;
 
-my $testdata;
+my ($check, $testdata, $sasdata, $release);
 
 my ($verbose, $save_temps);
@@ -19,5 +20,8 @@
 GetOptions(
     "testdata=s"        =>  \$testdata,
+#    "sasdata=s"         =>  \$sasdata,
+    "release=s"         =>  \$release,
     "join=s"            =>  \$joinType,
+    "check"             =>  \$check,
     "verbose|v"         =>  \$verbose,
     "save-temps"        =>  \$save_temps,
@@ -28,4 +32,9 @@
 $in = shift;
 $out = shift;
+
+die "need one of --testdata or --release\n" 
+    unless defined $testdata or defined $release;
+
+
 
 my $jardir = $ENV{JARDIR};
@@ -49,5 +58,5 @@
 # XXX TODO: check for success
 chomp $imageID;
-my $exp_id = $imageID / 100;
+my $exp_id = int($imageID / 100);
 print "exp_id is $exp_id\n" if $verbose;
 
@@ -56,10 +65,29 @@
 #    my $testdata = "/data/ippc19.0/home/bills/ipp/ippToPsps/test/testdata";
     $smf = sprintf "%s/test.%02d.smf", $testdata, $exp_id;
+#} elsif ($sasdata) {
+    # this attempted hack did not work
+#    die "only exp_id 1 works right now for sasdata\n" unless $exp_id eq 1;
+#
+#    $smf = sprintf "%s/o5748g0363o.358745.cm.1218981.smf", $sasdata;
 } else {
     # XXX: look up the smf for the exposure here
-    die "only test mode works right now\n";
+    # die "only test mode works right now\n";
+    my $cmd = "releasetool -listrelexp -release_name $release -exp_id $exp_id | grep path_base | awk '{print \$3}'";
+    print "$cmd\n" if $verbose;
+    my $path_base = `$cmd`;
+    chomp $path_base;
+    die "failed to find path_base for $exp_id\n" unless $path_base;
+    $smf = "$path_base.smf";
+    print "$smf for $exp_id is $smf\n";
 }
 
 my $ippcat = "cat." . basename($smf);
+
+if ($smf =~ /^neb:/) {
+    my $ipprc = PS::IPP::Config->new();
+    my $resolved = $ipprc->file_resolve($smf);
+    die "failed to resolve $smf\n" unless $resolved;
+    $smf = $resolved;
+}
 
 $command = "concatsmf $smf $ippcat";
@@ -76,5 +104,8 @@
 }
 
-runcommand("adddeltacolumns $matched $out");
+$command = "adddeltacolumns $matched $out";
+$command .= " --check" if $check;
+
+runcommand($command);
 
 exit 0;
