def make_multi_burst(process_id, coinc_event_id, events, offset_vector): multiburst = lsctables.MultiBurst() multiburst.process_id = process_id multiburst.coinc_event_id = coinc_event_id # snr = root sum of ms_snr squares multiburst.snr = math.sqrt(sum(event.ms_snr**2.0 for event in events)) # peak time = ms_snr squared weighted average of peak times (no # attempt to account for inter-site delays). LIGOTimeGPS objects # don't like being multiplied by things, so the first event's peak # time is used as a reference epoch. t = events[0].peak + offset_vector[events[0].ifo] multiburst.peak = t + sum( event.ms_snr**2.0 * float(event.peak + offset_vector[event.ifo] - t) for event in events) / multiburst.snr**2.0 # duration = ms_snr squared weighted average of durations multiburst.duration = sum(event.ms_snr**2.0 * event.duration for event in events) / multiburst.snr**2.0 # central_freq = ms_snr squared weighted average of peak frequencies multiburst.central_freq = sum(event.ms_snr**2.0 * event.peak_frequency for event in events) / multiburst.snr**2.0 # bandwidth = ms_snr squared weighted average of bandwidths multiburst.bandwidth = sum(event.ms_snr**2.0 * event.bandwidth for event in events) / multiburst.snr**2.0 # confidence = minimum of confidences multiburst.confidence = min(event.confidence for event in events) # "amplitude" = h_rss of event with highest confidence multiburst.amplitude = max( (event.ms_confidence, event.ms_hrss) for event in events)[1] # populate the false alarm rate with none. multiburst.false_alarm_rate = None # done return multiburst
def root_multi_trigger(root_event, columns=CWB_MULTI_COLUMNS): """Parse a multi-detector Coherent WaveBurst `ROOT` tree entry into a `MultiBurst` object. @param root_event `ROOT` `TChain` object @param columns a list of valid `LIGO_LW` column names to load (defaults to all) @returns a `MultiBurst` built from the `ROOT` data """ ifos = get_ifos(root_event) first_ifo_idx = CWB_DETECTOR_INDEX.index(list(ifos)[0]) mb = lsctables.MultiBurst() if 'process_id' in columns: mb.process_id = lsctables.ProcessID(root_event.run) if 'event_id' in columns: mb.event_id = lsctables.MultiBurstTable.get_next_id() if 'ifos' in columns: mb.set_ifos(ifos) peak_time = LIGOTimeGPS(list(root_event.time)[first_ifo_idx]) if 'peak_time' in columns: mb.peak_time = peak_time.gpsSeconds if 'peak_time_ns' in columns: mb.peak_time_ns = peak_time.gpsNanoSeconds start_time = LIGOTimeGPS(list(root_event.start)[first_ifo_idx]) if 'start_time' in columns: mb.start_time = start_time.gpsSeconds if 'start_time_ns' in columns: mb.start_time_ns = start_time.gpsNanoSeconds if 'duration' in columns: mb.duration = float(list(root_event.duration)[first_ifo_idx]) fmin = min(root_event.low) fmax = min(root_event.high) if 'central_freq' in columns: mb.central_freq = list(root_event.frequency)[0] if 'bandwidth' in columns: mb.bandwidth = fmax - fmin if 'snr' in columns: mb.snr = min(root_event.rho) if 'confidence' in columns: mb.confidence = root_event.likelihood return mb