diff --git a/gstlal-inspiral/bin/gstlal_inspiral b/gstlal-inspiral/bin/gstlal_inspiral index 6ae9e93b6fce80eb471e7f206b20274455129a4c..e3925b141ff0e71526695c2f4fb37548d2dce56c 100755 --- a/gstlal-inspiral/bin/gstlal_inspiral +++ b/gstlal-inspiral/bin/gstlal_inspiral @@ -716,6 +716,10 @@ for output_file_number, (svd_bank_url_dict, output_url, ranking_stat_output_url, # parse SVD template bank and expose bank metadata # + # check which background collector to use (also see streamthinca.py); + # currently only 'normal' and 'time_reverse' are supported + use_time_reverse = False + background_collector_type = "normal" banks = inspiral.parse_bank_files(svd_bank_url_dict, verbose = options.verbose) # assume all instruments have the same templates, just extract them @@ -723,6 +727,7 @@ for output_file_number, (svd_bank_url_dict, output_url, ranking_stat_output_url, sngl_inspiral_table = list(banks.values())[0][0].sngl_inspiral_table.copy() horizon_factors = {} for bank in list(banks.values())[0]: + use_time_reverse |= bank.bank_type == "noise_model" sngl_inspiral_table.extend(bank.sngl_inspiral_table) horizon_factors.update(bank.horizon_factors) @bottle.route("/template_bank.xml.gz") @@ -736,6 +741,8 @@ for output_file_number, (svd_bank_url_dict, output_url, ranking_stat_output_url, output.close() return outstr template_ids = frozenset(row.template_id for row in sngl_inspiral_table) + # switch between normal and time reverse background collector + background_collector_type = "time_reverse" if use_time_reverse else "normal" assert set(horizon_factors) == template_ids, "horizon factors are not assigned for each template id" assert len(template_ids) == len(sngl_inspiral_table), "template IDs are not unique within the template bank" @bottle.route("/template_ids.txt") @@ -927,6 +934,7 @@ for output_file_number, (svd_bank_url_dict, output_url, ranking_stat_output_url, activation_counts = options.activation_counts, track_latency = options.data_source in ("lvshm", "framexmit"), template_id_time_map = options.upload_time_before_merger, + background_collector_type = background_collector_type, verbose = options.verbose ) if options.verbose: diff --git a/gstlal-inspiral/python/lloidhandler.py b/gstlal-inspiral/python/lloidhandler.py index b2094e860313bc516affc44078422f9578bea78c..10ff1957db7bb0fc51efcb7b87a702e8cf389d08 100644 --- a/gstlal-inspiral/python/lloidhandler.py +++ b/gstlal-inspiral/python/lloidhandler.py @@ -746,7 +746,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, sngls_snr_threshold = None, analysis_tag = "test", job_tag = "", kafka_server = "10.14.0.112:9092", cluster = False, cap_singles = False, FAR_trialsfactor = 1.0, activation_counts = None, track_latency = False, template_id_time_map = None, 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, analysis_tag = "test", job_tag = "", kafka_server = "10.14.0.112:9092", cluster = False, cap_singles = False, FAR_trialsfactor = 1.0, activation_counts = None, track_latency = False, template_id_time_map = None, background_collector_type = "normal", verbose = False): """! @param mainloop The main application's event loop @param pipeline The gstreamer pipeline that is being @@ -825,7 +825,8 @@ class Handler(simplehandler.Handler): coincs_document.process_id, delta_t = rankingstat.delta_t, min_instruments = rankingstat.min_instruments, - sngls_snr_threshold = sngls_snr_threshold + sngls_snr_threshold = sngls_snr_threshold, + background_collector_type = background_collector_type ) # diff --git a/gstlal-inspiral/python/streamthinca.py b/gstlal-inspiral/python/streamthinca.py index 76d505ae9e96731dda070226ad982a679becfee5..3b9275b7122d74d4f9d786f11599e3271f57ddf9 100644 --- a/gstlal-inspiral/python/streamthinca.py +++ b/gstlal-inspiral/python/streamthinca.py @@ -235,7 +235,10 @@ class timereversebackgroundcollector(object): class StreamThinca(object): - def __init__(self, xmldoc, process_id, delta_t, min_instruments = 2, sngls_snr_threshold = None): + def __init__(self, xmldoc, process_id, delta_t, min_instruments = 2, sngls_snr_threshold = None, background_collector_type = "normal"): + if background_collector_type not in ("normal", "time_reverse"): + raise ValueError("background_collector_type can only be 'normal' or 'time_reverse'") + self.background_collector_type = background_collector_type self.ln_lr_from_triggers = None self.delta_t = delta_t self.min_instruments = min_instruments @@ -256,7 +259,7 @@ class StreamThinca(object): self.delta_t, min_instruments = self.min_instruments ) - self.backgroundcollector = backgroundcollector() + self.backgroundcollector = backgroundcollector() if self.background_collector_type == "normal" else timereversebackgroundcollector() def push(self, instrument, events, t_complete): @@ -349,7 +352,7 @@ class StreamThinca(object): # store these values in coinc_inspiral.combined_far = fapfar.far_from_rank(coinc.likelihood) * FAR_trialsfactor if len(events) == 1 and cap_singles and coinc_inspiral.combined_far < 1. / fapfar.livetime: - coinc_inspiral.combined_far = 1. / fapfar.livetime + coinc_inspiral.combined_far = 1. / fapfar.livetime coinc_inspiral.false_alarm_rate = fapfar.fap_from_rank(coinc.likelihood) if zerolag_rankingstatpdf is not None and coinc.likelihood is not None: zerolag_rankingstatpdf.zero_lag_lr_lnpdf.count[coinc.likelihood,] += 1