From c2c825b8f16db8c04208381f2adfd91e69e4f1d8 Mon Sep 17 00:00:00 2001
From: Kipp Cannon <kipp.cannon@ligo.org>
Date: Tue, 6 Nov 2018 05:39:31 -0800
Subject: [PATCH] gstlal_inspiral:  remove --min-log-L feature

- currently nonsense, redundant since addition of sum-of-SNR^2 cut.  the
  latter will be fixed, cleaned up, and made to incorporate this feature
---
 gstlal-inspiral/bin/gstlal_inspiral           |  4 +---
 gstlal-inspiral/bin/gstlal_inspiral_pipe      |  5 +----
 gstlal-inspiral/bin/gstlal_ll_inspiral_pipe   |  3 ---
 gstlal-inspiral/python/lloidhandler.py        | 14 ++++++-------
 gstlal-inspiral/python/streamthinca.py        | 20 +++++++------------
 .../share/O2/Makefile.BNS_test_dag            |  1 -
 .../share/O2/Makefile.O2_offline_dag          |  1 -
 .../O2/Makefile.O2_offline_hybridbank_dag     |  1 -
 .../O2/Makefile.O2_offline_injections_dag     |  1 -
 .../share/O2/Makefile.online_analysis         |  1 -
 .../share/O3/Makefile.online_analysis         |  3 +--
 .../share/O3/Makefile.online_analysis_small   |  3 +--
 12 files changed, 18 insertions(+), 39 deletions(-)

diff --git a/gstlal-inspiral/bin/gstlal_inspiral b/gstlal-inspiral/bin/gstlal_inspiral
index 7a7de4ef78..38b591e4da 100755
--- a/gstlal-inspiral/bin/gstlal_inspiral
+++ b/gstlal-inspiral/bin/gstlal_inspiral
@@ -257,8 +257,7 @@ def parse_command_line():
 	group.add_option("--chisq-type", metavar = "type", default = "autochisq", help = "Choose the type of chisq computation to perform. Must be one of (autochisq|timeslicechisq). The default is autochisq.")
 	group.add_option("--coincidence-threshold", metavar = "seconds", type = "float", default = 0.005, help = "Set the coincidence window in seconds (default = 0.005 s).  The light-travel time between instruments will be added automatically in the coincidence test.")
 	group.add_option("--min-instruments", metavar = "count", type = "int", default = 2, help = "Set the minimum number of instruments that must contribute triggers to form a candidate (default = 2).")
-	group.add_option("--min-log-L", metavar = "log likelihood ratio", type = "float", help = "Discard candidates that get assigned log likelihood ratios below this threshold (default = keep all).  When used without --ranking-stat-input, the cut is decided based on an internal approximate ranking statistic.")
-	group.add_option("--ranking-stat-input", metavar = "url", help = "Set the URL from which to load a ranking statistic definition.  When this is enabled, signal candidates will have ranking statistic values assigned on-the-fly, and the --min-log-L cut will be applied based on the assigned values.  Required when --data-source is lvshm or framexmit;  must also set --likelihood-snapshot-interval.")
+	group.add_option("--ranking-stat-input", metavar = "url", help = "Set the URL from which to load a ranking statistic definition.  When this is enabled, signal candidates will have ranking statistic values assigned on-the-fly.  Required when --data-source is lvshm or framexmit;  must also set --likelihood-snapshot-interval.")
 	group.add_option("--ranking-stat-output", metavar = "filename", action = "append", default = [], help = "Set the name of the file to which to write ranking statistic data collected from triggers (optional).  Can be given more than once.  If given, exactly as many must be provided as there are --svd-bank options and they will be writen to in order.")
 	group.add_option("--ranking-stat-output-cache", metavar = "filename", help = "Provide a cache of ranking statistic output files.  This can be used instead of giving multiple --ranking-stat-output options.  Cannot be combined with --ranking-stat-output.")
 	group.add_option("--likelihood-snapshot-interval", type = "float", metavar = "seconds", help = "How often to snapshot candidate and ranking statistic data to disk when running online.")
@@ -822,7 +821,6 @@ for output_file_number, (svd_bank_url_dict, output_url, ranking_stat_output_url,
 		rankingstatpdf_url = options.ranking_stat_pdf,
 		zerolag_rankingstatpdf_url = zerolag_rankingstat_pdf,
 		likelihood_snapshot_interval = options.likelihood_snapshot_interval,
-		min_log_L = options.min_log_L,
 		sngls_snr_threshold = options.singles_threshold,
 		tag = options.job_tag,
 		kafka_server = options.output_kafka_server,
diff --git a/gstlal-inspiral/bin/gstlal_inspiral_pipe b/gstlal-inspiral/bin/gstlal_inspiral_pipe
index e96a556f06..03e9a90120 100755
--- a/gstlal-inspiral/bin/gstlal_inspiral_pipe
+++ b/gstlal-inspiral/bin/gstlal_inspiral_pipe
@@ -357,7 +357,6 @@ def inspiral_node_gen(gstlalInspiralJob, gstlalInspiralInjJob, dag, svd_nodes, s
 								"data-source":"frames",
 								"local-frame-caching":"",
 								"min-instruments":options.min_instruments,
-								"min-log-L":options.min_log_L,
 								"reference-likelihood-file":options.reference_likelihood_file
 								},
 							input_files = {	"time-slide-file":options.time_slide_file,
@@ -430,7 +429,6 @@ def inspiral_node_gen(gstlalInspiralJob, gstlalInspiralInjJob, dag, svd_nodes, s
 								"data-source":"frames",
 								"local-frame-caching":"",
 								"min-instruments":options.min_instruments,
-								"min-log-L":options.min_log_L,
 								"reference-likelihood-file":options.reference_likelihood_file
 								},
 							input_files = {	"time-slide-file":options.inj_time_slide_file,
@@ -1038,8 +1036,7 @@ def parse_command_line():
 	parser.add_option("--control-peak-time", type="int", default = 8, metavar = "secs", help = "Set the peak finding time for the control signal, default 8")
 	parser.add_option("--coincidence-threshold", metavar = "value", type = "float", default = 0.005, help = "Set the coincidence window in seconds (default = 0.005).  The light-travel time between instruments will be added automatically in the coincidence test.")
 	parser.add_option("--min-instruments", metavar = "count", type = "int", default = 2, help = "Set the minimum number of instruments that must contribute triggers to form a candidate (default = 2).")
-	parser.add_option("--min-log-L", metavar = "log likelihood ratio", type = "float", help = "Discard candidates that get assigned log likelihood ratios below this threshold (default = keep all).")
-	parser.add_option("--reference-likelihood-file", metavar = "file", help = "Set a reference likelihood file to compute initial likelihood ratios for the min-log-L cut. Required")
+	parser.add_option("--reference-likelihood-file", metavar = "file", help = "Set a reference likelihood file to compute initial likelihood ratios. Required")
 	parser.add_option("--num-banks", metavar = "str", help = "The number of parallel subbanks per gstlal_inspiral job. can be given as a list like 1,2,3,4 then it will split up the bank cache into N groups with M banks each.")
 	parser.add_option("--max-inspiral-jobs", type="int", metavar = "jobs", help = "Set the maximum number of gstlal_inspiral jobs to run simultaneously, default no constraint.")
 	parser.add_option("--ht-gate-threshold", type="float", help="set a threshold on whitened h(t) to veto glitches")
diff --git a/gstlal-inspiral/bin/gstlal_ll_inspiral_pipe b/gstlal-inspiral/bin/gstlal_ll_inspiral_pipe
index 537d434e12..9f5a1daf7c 100755
--- a/gstlal-inspiral/bin/gstlal_ll_inspiral_pipe
+++ b/gstlal-inspiral/bin/gstlal_ll_inspiral_pipe
@@ -199,7 +199,6 @@ def parse_command_line():
 	parser.add_option("--reference-psd", metavar = "filename", help = "Set the reference psd file.")
 	parser.add_option("--bank-cache", metavar = "filenames", help = "Set the bank cache files in format H1=H1.cache,H2=H2.cache, etc..")
 	parser.add_option("--min-instruments", metavar = "count", type = "int", default = 2, help = "Set the minimum number of instruments that must contribute triggers to form a candidate (default = 2).")
-	parser.add_option("--min-log-L", metavar = "log likelihood ratio", type = "float", help = "Discard candidates that get assigned log likelihood ratios below this threshold (default = keep all).")
 	parser.add_option("--inj-channel-name", metavar = "name", default=[], action = "append", help = "Set the name of the injection channel to process for given mass bins (optional). 0000:0002:IFO1=CHANNEL-NAME1,IFO2=CHANNEL-NAME2 can be given multiple times.")
 	parser.add_option("--inj-state-channel-name", metavar = "name", default=[], action = "append", help = "Set the name of the injection state channel to process (required if --inj-channel-name set).")
 	parser.add_option("--inj-dq-channel-name", metavar = "name", default=[], action = "append", help = "Set the name of the injection DQ channel to process (required if --inj-channel-name set).")
@@ -459,7 +458,6 @@ for num_insp_nodes, (svd_banks, likefile, zerolikefile) in enumerate(zip(bank_gr
 		"job-tag":jobTags[-1],
 		"likelihood-snapshot-interval":options.likelihood_snapshot_interval,
 		"min-instruments":options.min_instruments,
-		"min-log-L":options.min_log_L,
 		"time-slide-file":options.time_slide_file,
 		"output-kafka-server": options.output_kafka_server
 		}
@@ -522,7 +520,6 @@ for num_insp_nodes, (svd_banks, likefile, zerolikefile) in enumerate(zip(bank_gr
 			"job-tag":inj_jobTags[-1],
 			"likelihood-snapshot-interval":options.likelihood_snapshot_interval,
 			"min-instruments":options.min_instruments,
-			"min-log-L":options.min_log_L,
 			"time-slide-file":options.time_slide_file
 			}
 		common_opts.update(datasource_opts)
diff --git a/gstlal-inspiral/python/lloidhandler.py b/gstlal-inspiral/python/lloidhandler.py
index febeffa4b6..4658eaff80 100644
--- a/gstlal-inspiral/python/lloidhandler.py
+++ b/gstlal-inspiral/python/lloidhandler.py
@@ -574,7 +574,7 @@ class Handler(simplehandler.Handler):
 	dumps of segment information, trigger files and background
 	distribution statistics.
 	"""
-	def __init__(self, mainloop, pipeline, coincs_document, rankingstat, horizon_distance_func, gracedbwrapper, zerolag_rankingstatpdf_url = None, rankingstatpdf_url = None, ranking_stat_output_url = None, ranking_stat_input_url = None, likelihood_snapshot_interval = None, min_log_L = None, sngls_snr_threshold = None, tag = "", kafka_server = "10.14.0.112:9092", verbose = False):
+	def __init__(self, mainloop, pipeline, coincs_document, rankingstat, horizon_distance_func, gracedbwrapper, zerolag_rankingstatpdf_url = None, rankingstatpdf_url = None, ranking_stat_output_url = None, ranking_stat_input_url = None, likelihood_snapshot_interval = None, sngls_snr_threshold = None, tag = "", kafka_server = "10.14.0.112:9092", verbose = False):
 		"""!
 		@param mainloop The main application's event loop
 		@param pipeline The gstreamer pipeline that is being
@@ -634,7 +634,6 @@ class Handler(simplehandler.Handler):
 			coincs_document.process_id,
 			delta_t = rankingstat.delta_t,
 			min_instruments = rankingstat.min_instruments,
-			min_log_L = min_log_L,
 			sngls_snr_threshold = sngls_snr_threshold
 		)
 
@@ -669,10 +668,7 @@ class Handler(simplehandler.Handler):
 		#
 		# if we have been supplied with external ranking statistic
 		# information then use it to enable ranking statistic
-		# assignment in streamthinca.  otherwise, if we have not
-		# been and yet we have been asked to apply the min log L
-		# cut anyway then enable ranking statistic assignment using
-		# the dataless ranking statistic variant
+		# assignment in streamthinca.
 		#
 
 		if self.ranking_stat_input_url is not None:
@@ -684,7 +680,11 @@ class Handler(simplehandler.Handler):
 				self.stream_thinca.ln_lr_from_triggers = None
 				if self.verbose:
 					print >>sys.stderr, "ranking statistic assignment DISABLED"
-		elif min_log_L is not None:
+		elif False:
+			# FIXME:  move sum-of-SNR^2 cut into this object's
+			# .__call__() and then use as coinc sieve function
+			# instead.  left here temporariliy to remember how
+			# to initialize it
 			self.stream_thinca.ln_lr_from_triggers = far.DatalessRankingStat(
 				template_ids = rankingstat.template_ids,
 				instruments = rankingstat.instruments,
diff --git a/gstlal-inspiral/python/streamthinca.py b/gstlal-inspiral/python/streamthinca.py
index ca6c35ac3b..9fbc105786 100644
--- a/gstlal-inspiral/python/streamthinca.py
+++ b/gstlal-inspiral/python/streamthinca.py
@@ -235,11 +235,10 @@ def lower_bound_in_seglist(seglist, x):
 
 
 class StreamThinca(object):
-	def __init__(self, xmldoc, process_id, delta_t, min_instruments = 2, min_log_L = None, sngls_snr_threshold = None):
+	def __init__(self, xmldoc, process_id, delta_t, min_instruments = 2, sngls_snr_threshold = None):
 		self.ln_lr_from_triggers = None
 		self.delta_t = delta_t
 		self.min_instruments = min_instruments
-		self.min_log_L = min_log_L
 		self.sngls_snr_threshold = sngls_snr_threshold
 		self.set_xmldoc(xmldoc, process_id)
 
@@ -367,14 +366,9 @@ class StreamThinca(object):
 				if zerolag_rankingstatpdf is not None and coinc.likelihood is not None:
 					zerolag_rankingstatpdf.zero_lag_lr_lnpdf.count[coinc.likelihood,] += 1
 
-
-			# if min_log_L is None, this test always passes,
-			# regardless of the value of .likelihood, be it
-			# None, some number, -inf or even nan.
-			if coinc.likelihood >= self.min_log_L:
-				# finally, append coinc to tables
-				self.coinc_tables.append_coinc(coinc, coincmaps, coinc_inspiral)
-				self.last_coincs.add(events, coinc, coincmaps, coinc_inspiral)
+			# finally, append coinc to tables
+			self.coinc_tables.append_coinc(coinc, coincmaps, coinc_inspiral)
+			self.last_coincs.add(events, coinc, coincmaps, coinc_inspiral)
 
 		# add singles that were not used for any candidates to the
 		# noise model
@@ -386,9 +380,9 @@ class StreamThinca(object):
 		# add any triggers that have been used in coincidences for
 		# the first time to the sngl_inspiral table
 		# FIXME:  because this information comes from the
-		# coincidence code, which is not aware of the min_log_L cut
-		# or the clustering, we record a lot of singles that aren't
-		# really used for any (retained) coincs.
+		# coincidence code, which is not aware of the clustering,
+		# we record a lot of singles that aren't really used for
+		# any (retained) coincs.
 
 		self.sngl_inspiral_table.extend(newly_reported)
 
diff --git a/gstlal-inspiral/share/O2/Makefile.BNS_test_dag b/gstlal-inspiral/share/O2/Makefile.BNS_test_dag
index 4c7f36347d..6eec99b227 100644
--- a/gstlal-inspiral/share/O2/Makefile.BNS_test_dag
+++ b/gstlal-inspiral/share/O2/Makefile.BNS_test_dag
@@ -213,7 +213,6 @@ dag : segments.xml.gz vetoes.xml.gz frame.cache inj_tisi.xml tisi.xml plots $(WE
 		--singles-threshold 100.0 \
 		--request-cpu 2 \
 		--request-memory 5GB \
-		--min-log-L 4. \
 		--min-instruments $(MIN_IFOS)
 	sed -i '1s/^/JOBSTATE_LOG logs\/trigger_pipe.jobstate.log\n/' trigger_pipe.dag
 
diff --git a/gstlal-inspiral/share/O2/Makefile.O2_offline_dag b/gstlal-inspiral/share/O2/Makefile.O2_offline_dag
index 07f8f88921..de93603dea 100644
--- a/gstlal-inspiral/share/O2/Makefile.O2_offline_dag
+++ b/gstlal-inspiral/share/O2/Makefile.O2_offline_dag
@@ -171,7 +171,6 @@ dag : segments.xml.gz vetoes.xml.gz frame.cache inj_tisi.xml tisi.xml plots $(WE
 		$(ADDITIONAL_DAG_OPTIONS) \
 		$(CONDOR_COMMANDS) \
 		--ht-gate-threshold-linear 0.8:15.0-45.0:100.0 \
-		--min-log-L -50.0 \
 		--singles-threshold 100.0 \
 		--request-cpu 2 \
 		--request-memory 5GB \
diff --git a/gstlal-inspiral/share/O2/Makefile.O2_offline_hybridbank_dag b/gstlal-inspiral/share/O2/Makefile.O2_offline_hybridbank_dag
index ae1bfb2b18..77302cb4a4 100644
--- a/gstlal-inspiral/share/O2/Makefile.O2_offline_hybridbank_dag
+++ b/gstlal-inspiral/share/O2/Makefile.O2_offline_hybridbank_dag
@@ -182,7 +182,6 @@ dag : segments.xml.gz vetoes.xml.gz frame.cache inj_tisi.xml tisi.xml plots $(WE
 		$(ADDITIONAL_DAG_OPTIONS) \
 		$(CONDOR_COMMANDS) \
 		--ht-gate-threshold-linear 0.8:15.0-45.0:100.0 \
-		--min-log-L -50.0 \
 		--singles-threshold 100.0 \
 		--request-cpu 2 \
 		--request-memory 5GB \
diff --git a/gstlal-inspiral/share/O2/Makefile.O2_offline_injections_dag b/gstlal-inspiral/share/O2/Makefile.O2_offline_injections_dag
index 31c9dabc6a..62b27429b5 100644
--- a/gstlal-inspiral/share/O2/Makefile.O2_offline_injections_dag
+++ b/gstlal-inspiral/share/O2/Makefile.O2_offline_injections_dag
@@ -121,7 +121,6 @@ dag : svd_bank.cache dist_stats.cache $(REF_PSD) $(ZERO_LAG_DB) $(SEGMENTS) $(VE
 		--reference-likelihood-file reference_likelihood_file.xml.gz \
 		--request-cpu 4 \
 		--request-memory 7GB \
-		--min-log-L -50.0 \
 		--min-instruments 1 \
 		$(ADDITIONAL_DAG_OPTIONS)
 	sed -i '1s/^/JOBSTATE_LOG logs\/trigger_pipe.jobstate.log\n/' trigger_pipe.dag
diff --git a/gstlal-inspiral/share/O2/Makefile.online_analysis b/gstlal-inspiral/share/O2/Makefile.online_analysis
index 655c0e69f1..4832859f3a 100644
--- a/gstlal-inspiral/share/O2/Makefile.online_analysis
+++ b/gstlal-inspiral/share/O2/Makefile.online_analysis
@@ -152,7 +152,6 @@ dag : marginalized_likelihood.xml.gz prior.cache plots ll_simplify_and_cluster.s
 		--injection-file $(NSBHINJFILE) \
 		--injection-file $(BBHINJFILE) \
 		--time-slide-file tisi.xml
-		#--min-log-L -50.0 \
 
 ll_simplify_and_cluster.sql:
 	wget http://versions.ligo.org/cgit/gstlal/plain/gstlal-inspiral/share/ll_simplify_and_cluster.sql
diff --git a/gstlal-inspiral/share/O3/Makefile.online_analysis b/gstlal-inspiral/share/O3/Makefile.online_analysis
index b80e594277..d15e19c831 100644
--- a/gstlal-inspiral/share/O3/Makefile.online_analysis
+++ b/gstlal-inspiral/share/O3/Makefile.online_analysis
@@ -147,8 +147,7 @@ dag : marginalized_likelihood.xml.gz prior.cache plots ll_simplify_and_cluster.s
 		--injection-file $(BNSINJFILE) \
 		--injection-file $(NSBHINJFILE) \
 		--injection-file $(BBHINJFILE) \
-		--time-slide-file tisi.xml \
-		--min-log-L 4
+		--time-slide-file tisi.xml
 
 ll_simplify_and_cluster.sql:
 	wget http://versions.ligo.org/cgit/gstlal/plain/gstlal-inspiral/share/ll_simplify_and_cluster.sql
diff --git a/gstlal-inspiral/share/O3/Makefile.online_analysis_small b/gstlal-inspiral/share/O3/Makefile.online_analysis_small
index 60adcfdd9c..2a54b23305 100644
--- a/gstlal-inspiral/share/O3/Makefile.online_analysis_small
+++ b/gstlal-inspiral/share/O3/Makefile.online_analysis_small
@@ -107,8 +107,7 @@ dag : plots ll_simplify_and_cluster.sql ll_simplify.sql tisi.xml rankingstat.cac
 		--web-dir $(WEBDIR) \
 		--min-instruments 1 \
 		--state-backup-destination gstlalcbc@pcdev3.phys.uwm.edu:/home/gstlalcbc/observing/2/uber_state_backup \
-		--time-slide-file tisi.xml \
-		--min-log-L 4
+		--time-slide-file tisi.xml
 	#python ~/trim_online_dag.py trigger_pipe.dag
 	#python ~/noretries.py trigger_pipe.dag
 
-- 
GitLab