def analyse_n_cluster_per_event(scan_base, include_no_cluster=False, time_line_absolute=True, combine_n_readouts=<NUM_LIT:1000>, chunk_size=<NUM_LIT>, plot_n_cluster_hists=False, output_pdf=None, output_file=None):
time_stamp = []<EOL>n_cluster = []<EOL>start_time_set = False<EOL>for data_file in scan_base:<EOL><INDENT>with tb.open_file(data_file + '<STR_LIT>', mode="<STR_LIT>") as in_cluster_file_h5:<EOL><INDENT>meta_data_array = in_cluster_file_h5.root.meta_data[:]<EOL>cluster_table = in_cluster_file_h5.root.Cluster<EOL>parameter_ranges = np.column_stack((analysis_utils.get_ranges_from_array(meta_data_array['<STR_LIT>'][::combine_n_readouts]), analysis_utils.get_ranges_from_array(meta_data_array['<STR_LIT>'][::combine_n_readouts])))<EOL>analysis_utils.index_event_number(cluster_table)<EOL>analyze_data = AnalyzeRawData()<EOL>analyze_data.create_tot_hist = False<EOL>analyze_data.create_bcid_hist = False<EOL>index = <NUM_LIT:0>  <EOL>best_chunk_size = chunk_size<EOL>total_cluster = cluster_table.shape[<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=total_cluster, term_width=<NUM_LIT>)<EOL>progress_bar.start()<EOL>for parameter_index, parameter_range in enumerate(parameter_ranges):<EOL><INDENT>logging.debug('<STR_LIT>' + str(parameter_range[<NUM_LIT:0>]) + '<STR_LIT>' + str(parameter_range[<NUM_LIT:2>]) + '<STR_LIT:U+002C>' + str(parameter_range[<NUM_LIT:3>]) + '<STR_LIT>' + str(int(float(float(parameter_index) / float(len(parameter_ranges)) * <NUM_LIT>))) + '<STR_LIT:%>')<EOL>analyze_data.reset()  <EOL>readout_cluster_len = <NUM_LIT:0>  <EOL>hist = None<EOL>for clusters, index in analysis_utils.data_aligned_at_events(cluster_table, start_event_number=parameter_range[<NUM_LIT:2>], stop_event_number=parameter_range[<NUM_LIT:3>], start_index=index, chunk_size=best_chunk_size):<EOL><INDENT>n_cluster_per_event = analysis_utils.get_n_cluster_in_events(clusters['<STR_LIT>'])[:, <NUM_LIT:1>]  <EOL>if hist is None:<EOL><INDENT>hist = np.histogram(n_cluster_per_event, bins=<NUM_LIT:10>, range=(<NUM_LIT:0>, <NUM_LIT:10>))[<NUM_LIT:0>]<EOL><DEDENT>else:<EOL><INDENT>hist = np.add(hist, np.histogram(n_cluster_per_event, bins=<NUM_LIT:10>, range=(<NUM_LIT:0>, <NUM_LIT:10>))[<NUM_LIT:0>])<EOL><DEDENT>if include_no_cluster and parameter_range[<NUM_LIT:3>] is not None:  <EOL><INDENT>hist[<NUM_LIT:0>] = (parameter_range[<NUM_LIT:3>] - parameter_range[<NUM_LIT:2>]) - len(n_cluster_per_event)  <EOL><DEDENT>readout_cluster_len += clusters.shape[<NUM_LIT:0>]<EOL>total_cluster -= len(clusters)<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>if plot_n_cluster_hists:<EOL><INDENT>plotting.plot_1d_hist(hist, title='<STR_LIT>' + str(parameter_range[<NUM_LIT:0>]), x_axis_title='<STR_LIT>', y_axis_title='<STR_LIT:#>', log_y=True, filename=output_pdf)<EOL><DEDENT>hist = hist.astype('<STR_LIT>') / np.sum(hist)  <EOL>if time_line_absolute:<EOL><INDENT>time_stamp.append(parameter_range[<NUM_LIT:0>])<EOL><DEDENT>else:<EOL><INDENT>if not start_time_set:<EOL><INDENT>start_time = parameter_ranges[<NUM_LIT:0>, <NUM_LIT:0>]<EOL>start_time_set = True<EOL><DEDENT>time_stamp.append((parameter_range[<NUM_LIT:0>] - start_time) / <NUM_LIT>)<EOL><DEDENT>n_cluster.append(hist)<EOL><DEDENT>progress_bar.finish()<EOL>if total_cluster != <NUM_LIT:0>:<EOL><INDENT>logging.warning('<STR_LIT>')<EOL><DEDENT><DEDENT><DEDENT>if time_line_absolute:<EOL><INDENT>plotting.plot_scatter_time(time_stamp, n_cluster, title='<STR_LIT>', marker_style='<STR_LIT:o>', filename=output_pdf, legend=('<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>') if include_no_cluster else ('<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>'))<EOL><DEDENT>else:<EOL><INDENT>plotting.plot_scatter(time_stamp, n_cluster, title='<STR_LIT>', x_label='<STR_LIT>', marker_style='<STR_LIT:o>', filename=output_pdf, legend=('<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>') if include_no_cluster else ('<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>'))<EOL><DEDENT>if output_file:<EOL><INDENT>with tb.open_file(output_file, mode="<STR_LIT:a>") as out_file_h5:<EOL><INDENT>cluster_array = np.array(n_cluster)<EOL>rec_array = np.array(list(zip(time_stamp, cluster_array[:, <NUM_LIT:0>], cluster_array[:, <NUM_LIT:1>], cluster_array[:, <NUM_LIT:2>], cluster_array[:, <NUM_LIT:3>], cluster_array[:, <NUM_LIT:4>], cluster_array[:, <NUM_LIT:5>])), dtype=[('<STR_LIT>', float), ('<STR_LIT>', float), ('<STR_LIT>', float), ('<STR_LIT>', float), ('<STR_LIT>', float), ('<STR_LIT>', float), ('<STR_LIT>', float)]).view(np.recarray)<EOL>try:<EOL><INDENT>n_cluster_table = out_file_h5.create_table(out_file_h5.root, name='<STR_LIT>', description=rec_array, title='<STR_LIT>', filters=tb.Filters(complib='<STR_LIT>', complevel=<NUM_LIT:5>, fletcher32=False))<EOL>n_cluster_table[:] = rec_array<EOL><DEDENT>except tb.exceptions.NodeError:<EOL><INDENT>logging.warning(output_file + '<STR_LIT>')<EOL><DEDENT><DEDENT><DEDENT>return time_stamp, n_cluster<EOL>
Determines the number of cluster per event as a function of time. Therefore the data of a fixed number of read outs are combined ('combine_n_readouts').

    Parameters
    ----------
    scan_base: list of str
        scan base names (e.g.:  ['//data//SCC_50_fei4_self_trigger_scan_390', ]
    include_no_cluster: bool
        Set to true to also consider all events without any hit.
    combine_n_readouts: int
        the number of read outs to combine (e.g. 1000)
    max_chunk_size: int
        the maximum chunk size used during read, if too big memory error occurs, if too small analysis takes longer
    output_pdf: PdfPages
        PdfPages file object, if none the plot is printed to screen