def analyze_cluster_size_per_scan_parameter(input_file_hits, output_file_cluster_size, parameter='<STR_LIT>', max_chunk_size=<NUM_LIT>, overwrite_output_files=False, output_pdf=None):
logging.info('<STR_LIT>' + parameter + '<STR_LIT>' + input_file_hits)<EOL>if os.path.isfile(output_file_cluster_size) and not overwrite_output_files:  <EOL><INDENT>logging.info('<STR_LIT>' + output_file_cluster_size + '<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>with tb.open_file(output_file_cluster_size, mode="<STR_LIT:w>") as out_file_h5:  <EOL><INDENT>filter_table = tb.Filters(complib='<STR_LIT>', complevel=<NUM_LIT:5>, fletcher32=False)  <EOL>parameter_goup = out_file_h5.create_group(out_file_h5.root, parameter, title=parameter)  <EOL>cluster_size_total = None  <EOL>with tb.open_file(input_file_hits, mode="<STR_LIT>") as in_hit_file_h5:  <EOL><INDENT>meta_data_array = in_hit_file_h5.root.meta_data[:]<EOL>scan_parameter = analysis_utils.get_scan_parameter(meta_data_array)  <EOL>if scan_parameter:  <EOL><INDENT>scan_parameter_values = scan_parameter[parameter]  <EOL>if len(scan_parameter_values) == <NUM_LIT:1>:  <EOL><INDENT>logging.warning('<STR_LIT>' + str(input_file_hits) + '<STR_LIT>' + str(parameter) + '<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>logging.info('<STR_LIT>' + input_file_hits + '<STR_LIT>' + parameter + '<STR_LIT>' + str(len(scan_parameter_values)) + '<STR_LIT>' + str(np.amin(scan_parameter_values)) + '<STR_LIT>' + str(np.amax(scan_parameter_values)))<EOL>event_numbers = analysis_utils.get_meta_data_at_scan_parameter(meta_data_array, parameter)['<STR_LIT>']  <EOL>parameter_ranges = np.column_stack((scan_parameter_values, analysis_utils.get_ranges_from_array(event_numbers)))<EOL>hit_table = in_hit_file_h5.root.Hits<EOL>analysis_utils.index_event_number(hit_table)<EOL>total_hits, total_hits_2, index = <NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:0><EOL>chunk_size = max_chunk_size<EOL>analyze_data = AnalyzeRawData()<EOL>analyze_data.create_cluster_size_hist = True<EOL>analyze_data.create_cluster_tot_hist = True<EOL>analyze_data.histogram.set_no_scan_parameter()  <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=hit_table.shape[<NUM_LIT:0>], term_width=<NUM_LIT>)<EOL>progress_bar.start()<EOL>for parameter_index, parameter_range in enumerate(parameter_ranges):  <EOL><INDENT>analyze_data.reset()  <EOL>logging.debug('<STR_LIT>' + str(parameter_range[<NUM_LIT:0>]) + '<STR_LIT:U+0020>' + str(int(float(float(parameter_index) / float(len(parameter_ranges)) * <NUM_LIT>))) + '<STR_LIT:%>')<EOL>start_event_number = parameter_range[<NUM_LIT:1>]<EOL>stop_event_number = parameter_range[<NUM_LIT:2>]<EOL>logging.debug('<STR_LIT>' + str(start_event_number) + '<STR_LIT:U+002C>' + str(stop_event_number) + '<STR_LIT:[>')<EOL>actual_parameter_group = out_file_h5.create_group(parameter_goup, name=parameter + '<STR_LIT:_>' + str(parameter_range[<NUM_LIT:0>]), title=parameter + '<STR_LIT:_>' + str(parameter_range[<NUM_LIT:0>]))<EOL>readout_hit_len = <NUM_LIT:0>  <EOL>for hits, index in analysis_utils.data_aligned_at_events(hit_table, start_event_number=start_event_number, stop_event_number=stop_event_number, start_index=index, chunk_size=chunk_size):<EOL><INDENT>total_hits += hits.shape[<NUM_LIT:0>]<EOL>analyze_data.analyze_hits(hits)  <EOL>readout_hit_len += hits.shape[<NUM_LIT:0>]<EOL>progress_bar.update(index)<EOL><DEDENT>chunk_size = int(<NUM_LIT> * readout_hit_len) if int(<NUM_LIT> * readout_hit_len) < max_chunk_size else max_chunk_size  <EOL>if chunk_size < <NUM_LIT:50>:  <EOL><INDENT>chunk_size = <NUM_LIT:50><EOL><DEDENT>occupancy = analyze_data.histogram.get_occupancy()  <EOL>cluster_size_hist = analyze_data.clusterizer.get_cluster_size_hist()<EOL>cluster_size_hist_table = out_file_h5.create_carray(actual_parameter_group, name='<STR_LIT>', title='<STR_LIT>', atom=tb.Atom.from_dtype(cluster_size_hist.dtype), shape=cluster_size_hist.shape, filters=filter_table)<EOL>cluster_size_hist_table[:] = cluster_size_hist<EOL>if output_pdf is not False:<EOL><INDENT>plotting.plot_cluster_size(hist=cluster_size_hist, title='<STR_LIT>' + str(np.sum(cluster_size_hist)) + '<STR_LIT>' + parameter + '<STR_LIT>' + str(scan_parameter_values[parameter_index]), filename=output_pdf)<EOL><DEDENT>if cluster_size_total is None:  <EOL><INDENT>cluster_size_total = cluster_size_hist<EOL><DEDENT>else:<EOL><INDENT>cluster_size_total = np.vstack([cluster_size_total, cluster_size_hist])<EOL><DEDENT>total_hits_2 += np.sum(occupancy)<EOL><DEDENT>progress_bar.finish()<EOL>if total_hits != total_hits_2:<EOL><INDENT>logging.warning('<STR_LIT>')<EOL><DEDENT>logging.info('<STR_LIT>', total_hits)<EOL><DEDENT><DEDENT><DEDENT>cluster_size_total_out = out_file_h5.create_carray(out_file_h5.root, name='<STR_LIT>', title='<STR_LIT>', atom=tb.Atom.from_dtype(cluster_size_total.dtype), shape=cluster_size_total.shape, filters=filter_table)<EOL>cluster_size_total_out[:] = cluster_size_total<EOL><DEDENT><DEDENT>
This method takes multiple hit files and determines the cluster size for different scan parameter values of

     Parameters
    ----------
    input_files_hits: string
    output_file_cluster_size: string
        The data file with the results
    parameter: string
        The name of the parameter to separate the data into (e.g.: PlsrDAC)
    max_chunk_size: int
        the maximum chunk size used during read, if too big memory error occurs, if too small analysis takes longer
    overwrite_output_files: bool
        Set to true to overwrite the output file if it already exists
    output_pdf: PdfPages
        PdfPages file object, if none the plot is printed to screen, if False nothing is printed