def background_livetime_nonring_by_slide(connection, seglists, veto_segments=None, coinc_segments=None, verbose=False): # get the segment lists and live time # FIXME veto segments not handled yet seglists = seglists.copy() if veto_segments is not None: seglists -= veto_segments background_time_slides = dict( (time_slide_id, offsetvector) for time_slide_id, offsetvector in dbtables.TimeSlideTable( connection=connection).as_dict() if any(offsetvector.values())) instruments = frozenset(seglists.keys()) background_livetime = {} for on_inst, off_inst in detector_combos(list(instruments)): on_inst = frozenset(on_inst) off_inst = frozenset(off_inst) key = on_inst old_offsets = seglists.offsets.copy() background_livetime.setdefault(key, {}) for id, time_slide in background_time_slides.items(): seglists.offsets.update(time_slide) segs = seglists.intersection(list(on_inst)) - seglists.union( list(off_inst)) if coinc_segments is not None: segs &= coinc_segments tskey = frozenset(time_slide.items()) background_livetime[key].setdefault(tskey, 0) background_livetime[key][tskey] += float(abs(segs)) seglists.offsets.update(old_offsets) return background_livetime
def get_time_slides(connection): """ Query the database for the IDs and offsets of all time slides, and return two dictionaries one containing the all-zero time slides and the other containing the not-all-zero time slides. """ time_slides = dbtables.TimeSlideTable(connection = connection).as_dict() zero_lag_time_slides = dict((time_slide_id, offsetvector) for time_slide_id, offsetvector in time_slides.items() if not any(offsetvector.values())) background_time_slides = dict((time_slide_id, offsetvector) for time_slide_id, offsetvector in time_slides.items() if any(offsetvector.values())) return zero_lag_time_slides, background_time_slides