Skip to content
Snippets Groups Projects
Commit 47097af6 authored by ChiWai Chan's avatar ChiWai Chan
Browse files

gstlal_inspiral, lloidhandler.py, and streamthinca.py: allow choosing...

gstlal_inspiral, lloidhandler.py, and streamthinca.py: allow choosing different background collector based on the 'bank_type' parameter in the svd bank file.
parent 6507ef3a
No related branches found
No related tags found
No related merge requests found
......@@ -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:
......
......@@ -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
)
#
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment