Index: trunk/tools/bills/detectToMeasure
===================================================================
--- trunk/tools/bills/detectToMeasure	(revision 38842)
+++ trunk/tools/bills/detectToMeasure	(revision 38843)
@@ -15,5 +15,5 @@
 use Pod::Usage qw( pod2usage );
 
-my ($ra, $dec, $cat_id, $exp_id, $class_id, $det_id);
+my ($ra, $dec, $cat_id, $exp_id, $class_id, $stack_id, $det_id);
 
 my ($outputFile, $ofmt, $save_temps, $verbose);
@@ -26,4 +26,5 @@
     "exp_id=s"          =>  \$exp_id,
     "class_id=s"        =>  \$class_id,
+    "stack_id=s"        =>  \$stack_id,
     "det_id=s"          =>  \$det_id,
     "list-others"       =>  \$listOthers,
@@ -36,6 +37,6 @@
 ) or pod2usage( 2 );
 
-unless (defined $ra and defined $dec and defined $exp_id and defined $class_id) {
-    print STDERR "usage: $0 --ra <ra> --dec <dec> [--cat_id <cat_id>] --exp_id <exp_id> --class_id <class_id> [--det_id <det_id> --output <output file name>\n";
+unless (defined $ra and defined $dec and (defined $stack_id or (defined $exp_id and defined $class_id)) ) {
+    print STDERR "usage: $0 --ra <ra> --dec <dec> [--cat_id <cat_id>] (--exp_id <exp_id> --class_id <class_id> | --stack_id <stack_id>) [--det_id <det_id>] [--output <output file name>]\n";
     print STDERR "       Other options: --list-others --this-image --ofmt\n";
     exit 1;
@@ -50,4 +51,5 @@
 
 # XXX: make label and catdir options
+# XXX: should be using release_name which will have pointers to the right datat and the catdir
 my $label = "SAS.20141118";
 my $catdir = '/data/ipp079.0/gpc1/catdirs/SAS/SAS39.V1';
@@ -108,5 +110,5 @@
 my $extern_id;
 my $image_id;
-{
+if ($exp_id) {
     my $command = "$chiptool -processedimfile -exp_id $exp_id -class_id $class_id -label $label | grep chip_imfile_id | awk '{print \$3}'";
     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
@@ -123,4 +125,7 @@
     chomp $output;
     $extern_id = $output;
+} else {
+    die "Need exp_id or stack_id!!\n" unless $stack_id;
+    $extern_id = $stack_id;
 }
 
