def analyze_hits_per_scan_parameter(analyze_data, scan_parameters=None, chunk_size=<NUM_LIT>):
if analyze_data.out_file_h5 is None or analyze_data.out_file_h5.isopen == <NUM_LIT:0>:<EOL><INDENT>in_hit_file_h5 = tb.open_file(analyze_data._analyzed_data_file, '<STR_LIT>')<EOL>close_file = True<EOL><DEDENT>else:<EOL><INDENT>in_hit_file_h5 = analyze_data.out_file_h5<EOL>close_file = False<EOL><DEDENT>meta_data = in_hit_file_h5.root.meta_data[:]  <EOL>try:<EOL><INDENT>hit_table = in_hit_file_h5.root.Hits  <EOL><DEDENT>except tb.NoSuchNodeError:<EOL><INDENT>logging.error('<STR_LIT>')<EOL>return<EOL><DEDENT>meta_data_table_at_scan_parameter = analysis_utils.get_unique_scan_parameter_combinations(meta_data, scan_parameters=scan_parameters)<EOL>parameter_values = analysis_utils.get_scan_parameters_table_from_meta_data(meta_data_table_at_scan_parameter, scan_parameters)<EOL>event_number_ranges = analysis_utils.get_ranges_from_array(meta_data_table_at_scan_parameter['<STR_LIT>'])  <EOL>analysis_utils.index_event_number(hit_table)  <EOL>index = <NUM_LIT:0>  <EOL>best_chunk_size = chunk_size  <EOL>for parameter_index, (start_event_number, stop_event_number) in enumerate(event_number_ranges):<EOL><INDENT>logging.info('<STR_LIT>' + str(scan_parameters) + '<STR_LIT>' + str(parameter_values[parameter_index]))<EOL>analyze_data.reset()  <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=best_chunk_size):<EOL><INDENT>analyze_data.analyze_hits(hits, scan_parameter=False)  <EOL>readout_hit_len += hits.shape[<NUM_LIT:0>]<EOL><DEDENT>best_chunk_size = int(<NUM_LIT> * readout_hit_len) if int(<NUM_LIT> * readout_hit_len) < chunk_size and int(<NUM_LIT> * readout_hit_len) > <NUM_LIT> else chunk_size  <EOL>file_name = "<STR_LIT:U+0020>".join(re.findall("<STR_LIT>", str(scan_parameters))) + '<STR_LIT:_>' + "<STR_LIT:U+0020>".join(re.findall("<STR_LIT>", str(parameter_values[parameter_index])))<EOL>analyze_data._create_additional_hit_data(safe_to_file=False)<EOL>analyze_data._create_additional_cluster_data(safe_to_file=False)<EOL>yield analyze_data, file_name<EOL><DEDENT>if close_file:<EOL><INDENT>in_hit_file_h5.close()<EOL><DEDENT>
Takes the hit table and analyzes the hits per scan parameter

    Parameters
    ----------
    analyze_data : analysis.analyze_raw_data.AnalyzeRawData object with an opened hit file (AnalyzeRawData.out_file_h5) or a
    file name with the hit data given (AnalyzeRawData._analyzed_data_file)
    scan_parameters : list of strings:
        The names of the scan parameters to use
    chunk_size : int:
        The chunk size of one hit table read. The bigger the faster. Too big causes memory errors.
    Returns
    -------
    yields the analysis.analyze_raw_data.AnalyzeRawData for each scan parameter