From 6384a01025bed448a5678e6d6aa2f6c8e05bef5b Mon Sep 17 00:00:00 2001
From: Kipp Cannon <kipp.cannon@ligo.org>
Date: Thu, 3 May 2018 13:57:39 +0900
Subject: [PATCH] RankingStat:  adjust .is_healthy() definition

- ignore instruments that haven't produced any triggers at all, because we
  wouldn't be worried about ranking those candidates anyway, but require at
  least one instrument to have produced triggers
---
 gstlal-inspiral/python/far.py | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/gstlal-inspiral/python/far.py b/gstlal-inspiral/python/far.py
index 148fe7a585..675d74aeb7 100644
--- a/gstlal-inspiral/python/far.py
+++ b/gstlal-inspiral/python/far.py
@@ -221,8 +221,21 @@ class RankingStat(snglcoinc.LnLikelihoodRatioMixin):
 
 	def is_healthy(self):
 		# do we believe the PDFs are sufficiently well-defined to
-		# compute ln L?
-		return min(self.denominator.triggerrates.counts.values()) > 10000000
+		# compute ln L?  not healthy until at least one instrument
+		# in the analysis has produced triggers, and until all that
+		# have produced triggers have each produced at least 10
+		# million.
+		# NOTE:  this will go badly if a detector that has never
+		# produced triggers, say because it joins an observing run
+		# late, suddenly starts producing triggers between snapshot
+		# cycles of an online analysis.  we're assuming, here, that
+		# detectors join science runs not at random times, but at
+		# scheduled times, say, during maintenance breaks, and that
+		# the analysis will not be collecting any candidates for
+		# approximately one snapshot interval around the addition
+		# of the new detector.
+		nonzero_counts = [count for count in self.denominator.triggerrates.counts.values() if count]
+		return nonzero_counts and min(nonzero_counts) > 10000000
 
 	@classmethod
 	def get_xml_root(cls, xml, name):
-- 
GitLab