def analyze_beam_spot(scan_base, combine_n_readouts=<NUM_LIT:1000>, chunk_size=<NUM_LIT>, plot_occupancy_hists=False, output_pdf=None, output_file=None):
time_stamp = []<EOL>x = []<EOL>y = []<EOL>for data_file in scan_base:<EOL><INDENT>with tb.open_file(data_file + '<STR_LIT>', mode="<STR_LIT>") as in_hit_file_h5:<EOL><INDENT>meta_data_array = in_hit_file_h5.root.meta_data[:]<EOL>hit_table = in_hit_file_h5.root.Hits<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(hit_table)<EOL>analyze_data = AnalyzeRawData()<EOL>analyze_data.create_tot_hist = False<EOL>analyze_data.create_bcid_hist = False<EOL>analyze_data.histogram.set_no_scan_parameter()<EOL>index = <NUM_LIT:0>  <EOL>best_chunk_size = chunk_size<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>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_hit_len = <NUM_LIT:0>  <EOL>for hits, index in analysis_utils.data_aligned_at_events(hit_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>analyze_data.analyze_hits(hits)  <EOL>readout_hit_len += hits.shape[<NUM_LIT:0>]<EOL>progress_bar.update(index)<EOL><DEDENT>best_chunk_size = int(<NUM_LIT> * readout_hit_len) if int(<NUM_LIT> * readout_hit_len) < chunk_size else chunk_size  <EOL>occupancy_array = analyze_data.histogram.get_occupancy()<EOL>projection_x = np.sum(occupancy_array, axis=<NUM_LIT:0>).ravel()<EOL>projection_y = np.sum(occupancy_array, axis=<NUM_LIT:1>).ravel()<EOL>x.append(analysis_utils.get_mean_from_histogram(projection_x, bin_positions=list(range(<NUM_LIT:0>, <NUM_LIT>))))<EOL>y.append(analysis_utils.get_mean_from_histogram(projection_y, bin_positions=list(range(<NUM_LIT:0>, <NUM_LIT>))))<EOL>time_stamp.append(parameter_range[<NUM_LIT:0>])<EOL>if plot_occupancy_hists:<EOL><INDENT>plotting.plot_occupancy(occupancy_array[:, :, <NUM_LIT:0>], title='<STR_LIT>' + time.strftime('<STR_LIT>', time.localtime(parameter_range[<NUM_LIT:0>])) + '<STR_LIT>' + time.strftime('<STR_LIT>', time.localtime(parameter_range[<NUM_LIT:1>])), filename=output_pdf)<EOL><DEDENT><DEDENT>progress_bar.finish()<EOL><DEDENT><DEDENT>plotting.plot_scatter([i * <NUM_LIT> for i in x], [i * <NUM_LIT:50> for i in y], title='<STR_LIT>', x_label='<STR_LIT>', y_label='<STR_LIT>', marker_style='<STR_LIT>', filename=output_pdf)<EOL>if output_file:<EOL><INDENT>with tb.open_file(output_file, mode="<STR_LIT:a>") as out_file_h5:<EOL><INDENT>rec_array = np.array(list(zip(time_stamp, x, y)), dtype=[('<STR_LIT>', float), ('<STR_LIT:x>', float), ('<STR_LIT:y>', float)])<EOL>try:<EOL><INDENT>beam_spot_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>beam_spot_table[:] = rec_array<EOL><DEDENT>except tb.exceptions.NodeError:<EOL><INDENT>logging.warning(output_file + '<STR_LIT>')<EOL><DEDENT><DEDENT><DEDENT>return time_stamp, x, y<EOL>
Determines the mean x and y beam spot position as a function of time. Therefore the data of a fixed number of read outs are combined ('combine_n_readouts'). The occupancy is determined
    for the given combined events and stored into a pdf file. At the end the beam x and y is plotted into a scatter plot with absolute positions in um.

     Parameters
    ----------
    scan_base: list of str
        scan base names (e.g.:  ['//data//SCC_50_fei4_self_trigger_scan_390', ]
    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