diff --git a/gstlal-inspiral/python/inspiral.py b/gstlal-inspiral/python/inspiral.py index bf04081c898fe31e54f7b22175db15d0d107004f..3ad99691c31fc76b6a3257e92b81b3ef2e75a0ab 100644 --- a/gstlal-inspiral/python/inspiral.py +++ b/gstlal-inspiral/python/inspiral.py @@ -778,13 +778,20 @@ class Data(object): if not buf_is_gap: self.rankingstat.denominator.triggerrates[instrument].add_ratebin(map(float, buf_seg), len(events)) + # extract times when instruments were producing + # SNR. used to define "on instruments" for coinc + # tables among other things. will only need + # segment information for the times for which we + # have triggers, so use stream_thinca's discard + # boundary and a bisection search to clip the lists + # to reduce subsequent operation count. + discard_boundary = float(self.stream_thinca.discard_boundary) + snr_segments = segments.segmentlistdict((instrument, ratebinlist[bisect.bisect_left(ratebinlist, (discard_boundary,)):].segmentlist()) for instrument, ratebinlist in self.rankingstat.denominator.triggerrates.items()) + # times when at least 2 instruments were generating # SNR. used to sieve triggers for inclusion in the - # denominator. fast path: because all end times - # have been confirmed to be later than the start of - # the buffer we just collected, that can be used to - # clip the trigger rate history for speed - two_or_more_instruments = segmentsUtils.vote((ratebinlist[bisect.bisect_left(ratebinlist, (float(buf_timestamp),)):] for ratebinlist in self.rankingstat.denominator.triggerrates.values() if ratebinlist), 2) + # denominator. + two_or_more_instruments = segmentsUtils.vote(snr_segments.values(), 2) # run stream thinca. update the parameter # distribution data from sngls that weren't used in @@ -802,7 +809,7 @@ class Data(object): # contaminating our noise model, so it's not # necessary for this test to be super precisely # defined. - for event in itertools.chain(self.stream_thinca.add_events(self.coincs_document.xmldoc, self.coincs_document.process_id, events, buf_timestamp, self.rankingstat.segmentlists, fapfar = self.fapfar), self.stream_thinca.last_coincs.single_sngl_inspirals() if self.stream_thinca.last_coincs else ()): + for event in itertools.chain(self.stream_thinca.add_events(self.coincs_document.xmldoc, self.coincs_document.process_id, events, buf_timestamp, snr_segments, fapfar = self.fapfar), self.stream_thinca.last_coincs.single_sngl_inspirals() if self.stream_thinca.last_coincs else ()): if event.end in two_or_more_instruments: self.rankingstat.denominator.increment(event) self.coincs_document.commit()