def get_rate_normalization(hit_file, parameter, reference='<STR_LIT>', cluster_file=None, plot=False, chunk_size=<NUM_LIT>):
logging.info('<STR_LIT>')<EOL>with tb.open_file(hit_file, mode="<STR_LIT>") as in_hit_file_h5:  <EOL><INDENT>meta_data = in_hit_file_h5.root.meta_data[:]<EOL>scan_parameter = get_scan_parameter(meta_data)[parameter]<EOL>event_numbers = get_meta_data_at_scan_parameter(meta_data, parameter)['<STR_LIT>']  <EOL>event_range = get_ranges_from_array(event_numbers)<EOL>normalization_rate = []<EOL>normalization_multiplicity = []<EOL>try:<EOL><INDENT>event_range[-<NUM_LIT:1>, <NUM_LIT:1>] = in_hit_file_h5.root.Hits[-<NUM_LIT:1>]['<STR_LIT>'] + <NUM_LIT:1><EOL><DEDENT>except tb.NoSuchNodeError:<EOL><INDENT>logging.error('<STR_LIT>')<EOL>return<EOL><DEDENT>if reference == '<STR_LIT>':<EOL><INDENT>n_events = event_range[:, <NUM_LIT:1>] - event_range[:, <NUM_LIT:0>]  <EOL>normalization_rate.extend(n_events)<EOL><DEDENT>elif reference == '<STR_LIT:time>':<EOL><INDENT>time_start = get_meta_data_at_scan_parameter(meta_data, parameter)['<STR_LIT>']<EOL>time_spend = np.diff(time_start)<EOL>time_spend = np.append(time_spend, meta_data[-<NUM_LIT:1>]['<STR_LIT>'] - time_start[-<NUM_LIT:1>])  <EOL>normalization_rate.extend(time_spend)<EOL><DEDENT>else:<EOL><INDENT>raise NotImplementedError('<STR_LIT>' + reference + '<STR_LIT>')<EOL><DEDENT>if cluster_file:  <EOL><INDENT>cluster_table = in_hit_file_h5.root.Cluster<EOL>index_event_number(cluster_table)<EOL>index = <NUM_LIT:0>  <EOL>best_chunk_size = chunk_size  <EOL>total_cluster = <NUM_LIT:0><EOL>progress_bar = progressbar.ProgressBar(widgets=['<STR_LIT>', progressbar.Percentage(), '<STR_LIT:U+0020>', progressbar.Bar(marker='<STR_LIT:*>', left='<STR_LIT:|>', right='<STR_LIT:|>'), '<STR_LIT:U+0020>', progressbar.AdaptiveETA()], maxval=cluster_table.shape[<NUM_LIT:0>], term_width=<NUM_LIT>)<EOL>progress_bar.start()<EOL>for start_event, stop_event in event_range:  <EOL><INDENT>readout_cluster_len = <NUM_LIT:0>  <EOL>n_cluster_per_event = None<EOL>for clusters, index in data_aligned_at_events(cluster_table, start_event_number=start_event, stop_event_number=stop_event, start_index=index, chunk_size=best_chunk_size):<EOL><INDENT>if n_cluster_per_event is None:<EOL><INDENT>n_cluster_per_event = analysis_utils.get_n_cluster_in_events(clusters['<STR_LIT>'])[:, <NUM_LIT:1>]  <EOL><DEDENT>else:<EOL><INDENT>n_cluster_per_event = np.append(n_cluster_per_event, analysis_utils.get_n_cluster_in_events(clusters['<STR_LIT>'])[:, <NUM_LIT:1>])<EOL><DEDENT>readout_cluster_len += clusters.shape[<NUM_LIT:0>]<EOL>total_cluster += clusters.shape[<NUM_LIT:0>]<EOL>progress_bar.update(index)<EOL><DEDENT>best_chunk_size = int(<NUM_LIT> * readout_cluster_len) if int(<NUM_LIT> * readout_cluster_len) < chunk_size else chunk_size  <EOL>normalization_multiplicity.append(np.mean(n_cluster_per_event))<EOL><DEDENT>progress_bar.finish()<EOL>if total_cluster != cluster_table.shape[<NUM_LIT:0>]:<EOL><INDENT>logging.warning('<STR_LIT>', total_cluster, cluster_table.shape[<NUM_LIT:0>])<EOL><DEDENT><DEDENT><DEDENT>if plot:<EOL><INDENT>x = scan_parameter<EOL>if reference == '<STR_LIT>':<EOL><INDENT>plotting.plot_scatter(x, normalization_rate, title='<STR_LIT>' + parameter + '<STR_LIT>', x_label=parameter, y_label='<STR_LIT>', log_x=True, filename=os.path.splitext(hit_file)[<NUM_LIT:0>] + '<STR_LIT>')<EOL><DEDENT>elif reference == '<STR_LIT:time>':<EOL><INDENT>plotting.plot_scatter(x, normalization_rate, title='<STR_LIT>', x_label=parameter, y_label='<STR_LIT>', log_x=True, filename=os.path.splitext(hit_file)[<NUM_LIT:0>] + '<STR_LIT>')<EOL><DEDENT>if cluster_file:<EOL><INDENT>plotting.plot_scatter(x, normalization_multiplicity, title='<STR_LIT>', x_label=parameter, y_label='<STR_LIT>', log_x=True, filename=os.path.splitext(hit_file)[<NUM_LIT:0>] + '<STR_LIT>')<EOL><DEDENT><DEDENT>if cluster_file:<EOL><INDENT>normalization_rate = np.array(normalization_rate)<EOL>normalization_multiplicity = np.array(normalization_multiplicity)<EOL>return np.amax(normalization_rate * normalization_multiplicity).astype('<STR_LIT>') / (normalization_rate * normalization_multiplicity)<EOL><DEDENT>return np.amax(np.array(normalization_rate)).astype('<STR_LIT>') / np.array(normalization_rate)<EOL>
Takes different hit files (hit_files), extracts the number of events or the scan time (reference) per scan parameter (parameter)
    and returns an array with a normalization factor. This normalization factor has the length of the number of different parameters.
    If a cluster_file is specified also the number of cluster per event are used to create the normalization factor.

    Parameters
    ----------
    hit_files : string
    parameter : string
    reference : string
    plot : bool

    Returns
    -------
    numpy.ndarray