def get_hits_in_events(hits_array, events, assume_sorted=True, condition=None):
logging.debug("<STR_LIT>" % len(events))<EOL>if assume_sorted:<EOL><INDENT>events, _ = reduce_sorted_to_intersect(events, hits_array['<STR_LIT>'])  <EOL>if events.shape[<NUM_LIT:0>] == <NUM_LIT:0>:  <EOL><INDENT>return hits_array[<NUM_LIT:0>:<NUM_LIT:0>]<EOL><DEDENT><DEDENT>try:<EOL><INDENT>if assume_sorted:<EOL><INDENT>selection = analysis_utils.in1d_events(hits_array['<STR_LIT>'], events)<EOL><DEDENT>else:<EOL><INDENT>logging.warning('<STR_LIT>')<EOL>selection = np.in1d(hits_array['<STR_LIT>'], events)<EOL><DEDENT>if condition is None:<EOL><INDENT>hits_in_events = hits_array[selection]<EOL><DEDENT>else:<EOL><INDENT>for variable in set(re.findall(r'<STR_LIT>', condition)):<EOL><INDENT>exec(variable + '<STR_LIT>' + variable + '<STR_LIT>')<EOL><DEDENT>hits_in_events = hits_array[ne.evaluate(condition + '<STR_LIT>')]<EOL><DEDENT><DEDENT>except MemoryError:<EOL><INDENT>logging.error('<STR_LIT>')<EOL>raise MemoryError<EOL><DEDENT>return hits_in_events<EOL>
Selects the hits that occurred in events and optional selection criterion.
        If a event range can be defined use the get_data_in_event_range function. It is much faster.

    Parameters
    ----------
    hits_array : numpy.array
    events : array
    assume_sorted : bool
        Is true if the events to select are sorted from low to high value. Increases speed by 35%.
    condition : string
        A condition that is applied to the hits in numexpr. Only if the expression evaluates to True the hit is taken.

    Returns
    -------
    numpy.array
        hit array with the hits in events.