def write_hits_in_event_range(hit_table_in, hit_table_out, event_start=None, event_stop=None, start_hit_word=<NUM_LIT:0>, chunk_size=<NUM_LIT>, condition=None):
logging.debug('<STR_LIT>' + str(event_start) + '<STR_LIT>' + str(event_stop) + '<STR_LIT>')<EOL>table_size = hit_table_in.shape[<NUM_LIT:0>]<EOL>for iHit in range(<NUM_LIT:0>, table_size, chunk_size):<EOL><INDENT>hits = hit_table_in.read(iHit, iHit + chunk_size)<EOL>last_event_number = hits[-<NUM_LIT:1>]['<STR_LIT>']<EOL>selected_hits = get_data_in_event_range(hits, event_start=event_start, event_stop=event_stop)<EOL>if condition is not None:<EOL><INDENT>for variable in set(re.findall(r'<STR_LIT>', condition)):<EOL><INDENT>exec(variable + '<STR_LIT>' + variable + '<STR_LIT>')<EOL><DEDENT>selected_hits = selected_hits[ne.evaluate(condition)]<EOL><DEDENT>hit_table_out.append(selected_hits)<EOL>if last_event_number > event_stop:  <EOL><INDENT>return iHit + chunk_size<EOL><DEDENT><DEDENT>return start_hit_word<EOL>
Selects the hits that occurred in given event range [event_start, event_stop[ and write them to a pytable. This function reduces the in RAM
       operations and has to be used if the get_data_in_event_range function raises a memory error. Also a condition can be set to select hits.

    Parameters
    ----------
    hit_table_in : pytable.table
    hit_table_out : pytable.table
        functions need to be able to write to hit_table_out
    event_start, event_stop : int, None
        start/stop event numbers. Stop event number is excluded. If None start/stop is set automatically.
    chunk_size : int
        defines how many hits are analyzed in RAM. Bigger numbers increase the speed, too big numbers let the program crash with a memory error.
    condition : string
        A condition that is applied to the hits in numexpr style. Only if the expression evaluates to True the hit is taken.
    Returns
    -------
    start_hit_word: int
        Index of the last hit word analyzed. Used to speed up the next call of write_hits_in_events.