Index: trunk/Ohana/src/relphot/src/setMrelCatalog.c
===================================================================
--- trunk/Ohana/src/relphot/src/setMrelCatalog.c	(revision 38993)
+++ trunk/Ohana/src/relphot/src/setMrelCatalog.c	(revision 39041)
@@ -674,4 +674,22 @@
   } // Nsecfilt loop
 
+  // in PSPS, there will be a stackObject row with the primary values.  if all filter primary values which
+  // exist are also best values, then this row will be the best entry
+
+  // the secfilt[Ns] entries are defined to be the Best values, so
+
+  // conversely, if any secfilt[Ns] values are not PRIMARY, then the PRIMARY row is not the BEST row
+
+  int PrimaryIsBest = TRUE;
+  for (Ns = 0; Ns < Nphotcodes; Ns++) {
+    if (!(secfilt[Ns].flags & ID_SECF_HAS_PS1_STACK)) continue; // no stack detection in PS1, nothing is best
+    if (secfilt[Ns].flags & ID_SECF_STACK_PRIMARY) continue;    // primary stack detection is best
+    PrimaryIsBest = FALSE;
+  }
+
+  if (PrimaryIsBest) {
+    average[0].flags |= ID_OBJ_BEST_STACK;
+  }
+
   if (NstackGood >= 2) {
     average[0].flags |= ID_OBJ_GOOD_STACK;
