πŸ“š LIBRARIES#

ANA#

SUMMARY

Waveforms related functions.

  • General analysis. Insert a new variable in the dictionary (insert_variable), generate the cut array, get the units of the variables stored in the dictionary.

  • Peak/pedestal variables. Compute the peak and pedestal variables of the raw waveforms (compute_peak_variables, compute_pedestal_variables, compute_pedestal_variables_sliding_window, compute_pedestal_sliding_windows). We can also compute the processed waveforms with the pedestal subtracted as well as computing the power spectrum of the waveforms (compute_ana_wvfs, compute_power_spec). Finally, we are trying to optimize the functions by introducing numba libraries. The shift_ADCs function is used to shift the ADCs of the waveforms to the pedestal value. The shift4_numba function is used to shift the ADCs of the waveforms to the pedestal value using numba library.

  • Average waveforms. The following functions compute the average waveforms of the processed individual events.

  • Integration. Then we can use these average waveform reference values to choose an integration (or other criteria) to get the pC and PE.

lib.ana_functions.average_wvfs(my_runs, info, key, label, centering='NONE', threshold=0, cut_label='', OPT={}, debug=False)[source]#

This function calculates the average waveform of a run.

Parameters
  • my_runs (dict) – dictionary containing the data.

  • info (dict) – dictionary containing the info.

  • key (str) – key to be inserted.

  • label (str) – label to be inserted.

  • centering (str, optional) – centering method (NONE, PEAK, THRESHOLD), defaults to β€œNONE”

  • threshold (int, optional) – threshold value, defaults to 0

  • cut_label (str, optional) – label for the cut, defaults to β€œβ€

  • OPT (dict, optional) – dictionary containing the options, defaults to {}

  • debug (bool, optional) – boolean to print debug messages, defaults to False

lib.ana_functions.compute_ana_wvfs(my_runs: dict, info: dict, filter: bool = False, debug: bool = False)[source]#

Computes the AnaADC wvfs from the RawADC and the baseline value computed from PED_KEY.

Parameters
  • my_runs (dict) – dictionary containing the data.

  • info (dict) – dictionary containing the info.

  • filter (bool, optional) – boolean to apply filter to the wvfs, defaults to False

  • debug (bool, optional) – boolean to print debug messages, defaults to False

Returns

True if the computation was successful, False otherwise.

Return type

bool

lib.ana_functions.compute_fft_wvfs(my_runs: dict, info: dict, key: str, label: str, debug: bool = False)[source]#

Computes the FFT wvfs from the given ADC key.

Parameters
  • my_runs (dict) – dictionary containing the data.

  • info (dict) – dictionary containing the info.

  • key (str) – key to be inserted.

  • label (str) – label to be inserted.

  • debug (bool, optional) – boolean to print debug messages, defaults to False

lib.ana_functions.compute_peak_RMS(my_runs, info, key, label, debug=False)[source]#

This function uses the calculated average wvf for a given run and computes the RMS of the peak in the given buffer.

Parameters
  • my_runs (dict) – dictionary containing the data.

  • info (dict) – dictionary containing the info.

  • key (str) – key to be inserted.

  • label (str) – label to be inserted.

  • debug (bool, optional) – boolean to print debug messages, defaults to False

Return my_runs

dictionary containing the data with the RMS values.

Return type

dict

lib.ana_functions.compute_peak_variables(my_runs: dict, info: dict, key: str, label: str, buffer: int = 30, debug: bool = False)[source]#

Computes the peaktime and amplitude for a given ADC key.

Parameters
  • my_runs (dict) – dictionary containing the data.

  • info (dict) – dictionary containing the info.

  • key (str) – key to be inserted.

  • label (str) – label to be inserted.

  • buffer (int, optional) – size in bins of the buffer to compute the valley amplitude, defaults to 30

  • debug (bool, optional) – boolean to print debug messages, defaults to False

lib.ana_functions.compute_pedestal_sliding_windows(ADC, ped_lim, sliding=200, debug=False)[source]#

Taking the best between different windows in pretrigger. Same variables than β€œcompute_pedestal_variables_sliding_window”. It checks for the best window.

Parameters
  • ADC (nparray) – array containing the ADCs.

  • ped_lim (int) – size in bins of the sliding window.

  • sliding (int, optional) – bins moved between shifts of the window, defaults to 200

  • debug (bool, optional) – boolean to print debug messages, defaults to False

Returns

ADC_s, start_window – shifted ADCs and start window.

Return type

nparray, nparray

lib.ana_functions.compute_pedestal_variables(my_runs, info, key, label, ped_lim='', buffer=50, sliding=200, debug=False)[source]#

Computes the pedestal variables of a collection of a run’s collection in several windows.

Parameters
  • my_runs (dict) – dictionary containing the data.

  • info (dict) – dictionary containing the info.

  • key (str) – key to be inserted.

  • label (str) – label to be inserted. Eg: label = Raw, variable = PedSTD –> RawPedSTD.

  • ped_lim (str, optional) – size in bins of the sliding window, defaults to β€œβ€

  • buffer (int, optional) – size in bins of the buffer to compute the valley amplitude, defaults to 50

  • sliding (int, optional) – bins moved between shifts of the window, defaults to 200

  • debug (bool, optional) – boolean to print debug messages, defaults to False

lib.ana_functions.compute_power_spec(ADC, timebin, debug=False)[source]#

Computes the power spectrum of the given events. It returns both axis.

Parameters
  • ADC (nparray) – array containing the ADCs.

  • timebin (float) – timebin of the data.

  • debug (bool, optional) – boolean to print debug messages, defaults to False

Returns

power spectrum and frequency axis.

Return type

nparray, nparray

lib.ana_functions.compute_wvf_variables(my_runs, info, key, label, debug=False)[source]#

Computes the mean, std and rms of the given ADC key.

Parameters
  • my_runs (dict) – dictionary containing the data.

  • info (dict) – dictionary containing the info.

  • key (str) – key to be inserted.

  • label (str) – label to be inserted.

  • debug (bool, optional) – boolean to print debug messages, defaults to False

lib.ana_functions.expo_average(my_run, alpha, debug=False)[source]#

This function calculates the exponential average with a given alpha.

Parameters
  • my_run (nparray) – run we want to use.

  • alpha (float) – alpha value.

  • debug (bool, optional) – boolean to print debug messages, defaults to False

Returns

v_averaged – averaged run computed as average[i+1] = (1-alpha) * average[i] + alpha * my_run[i+1]

Return type

nparray

lib.ana_functions.filter_wvf(wvf)[source]#
lib.ana_functions.find_amp_decrease(raw, thrld, debug=False)[source]#

It finds bin where the amp has fallen above a certain threshold relative to the main peak. It returns the index of both bins.

Parameters
  • raw (nparray) – the np array that you want to analize.

  • thrld (float) – the relative amp that you want to analize.

  • debug (bool, optional) – boolean to print debug messages, defaults to False

Returns

i_idx, f_idx – initial and final index of the cuts.

Return type

int, int

lib.ana_functions.find_baseline_cuts(raw, debug=False)[source]#

It finds the cuts with the x-axis. It returns the index of both bins.

Parameters
  • raw (nparray) – the np array that you want to analize.

  • debug (bool, optional) – boolean to print debug messages, defaults to False

Returns

i_idx, f_idx – initial and final index of the cuts.

Return type

int, int

lib.ana_functions.get_ADC_key(my_runs, key, debug=False)[source]#

This function returns the ADC key for a given run.

Parameters
  • my_runs (dict) – dictionary containing the data.

  • key (str) – key to be inserted.

  • debug (bool, optional) – boolean to print debug messages, defaults to False

Returns

key, label – key and label for the ADC.

Return type

str, str

lib.ana_functions.get_wvf_label(my_runs, key, label, debug=False)[source]#

This function returns the label for a given run. This depends on the found ADC key or the one provided by the user.

Parameters
  • my_runs (dict) – dictionary containing the data.

  • key (str) – key to be inserted.

  • label (str) – label to be inserted.

  • debug (bool, optional) – boolean to print debug messages, defaults to False

Returns

out_key, out_label – key and label for the ADC.

Return type

str, str

lib.ana_functions.insert_variable(my_runs, var, key, debug=False)[source]#

Insert values for each type of signal.

Parameters
  • my_runs (dict) – dictionary containing the data.

  • var (nparray) – array of values to be inserted.

  • key (str) – key to be inserted.

  • debug (bool, optional) – boolean to print debug messages, defaults to False

lib.ana_functions.integrate_wvfs(my_runs, info, key, label, cut_label='', debug=False)[source]#

This function integrates each event waveform. There are several ways to do it and we choose it with the argument β€œtypes”.

Parameters
  • my_runs (dict) – dictionary containing the data.

  • info (dict) – dictionary containing the info.

  • key (str) – key to be inserted (by default any ADC).

  • label (str) – label to be inserted.

  • cut_label (str, optional) – label for the cut, defaults to β€œβ€

  • debug (bool, optional) – boolean to print debug messages, defaults to False

Return my_runs

dictionary containing the data with the integrated values.

Return type

dict

lib.ana_functions.shift4_numba(arr, num, fill_value=0, debug=False)[source]#

Used for the sliding window.

Parameters
  • arr (nparray) – array containing the ADCs.

  • num (nparray) – array containing the shift values.

  • fill_value (int, optional) – value to be inserted in the empty bins, defaults to 0

  • debug (bool, optional) – boolean to print debug messages, defaults to False

Returns

arr – shifted array.

Return type

nparray

lib.ana_functions.shift_ADCs(ADC, shift, debug=False)[source]#

Used for the sliding window.

Parameters
  • ADC (nparray) – array containing the ADCs.

  • shift (nparray) – array containing the shift values.

  • debug (bool, optional) – boolean to print debug messages, defaults to False

Returns

aux_ADC – shifted ADCs.

Return type

nparray

lib.ana_functions.smooth(my_run, alpha, debug=False)[source]#

This function calculates the exponential average and then the unweighted average.

Parameters
  • my_run (nparray) – run we want to use.

  • alpha (float) – alpha value.

  • debug (bool, optional) – boolean to print debug messages, defaults to False

Returns

my_run – averaged run computed as average[i+1] = (my_run[i] + my_run[i+1] + my_run[i+2]) / 3 with my_run = (1-alpha) * average[i] + alpha * my_run[i+1]

Return type

nparray

lib.ana_functions.unweighted_average(my_run, debug=False)[source]#

This function calculates the unweighted average.

Parameters
  • my_run (nparray) – run we want to use.

  • debug (bool, optional) – boolean to print debug messages, defaults to False

Returns

v_averaged – averaged run computed as average[i+1] = (my_run[i] + my_run[i+1] + my_run[i+2]) / 3

Return type

nparray


CAL#

SUMMARY

These functions are used to perform calibration.

lib.cal_functions.calibrate(my_runs, info, keys, OPT={}, save=False, debug=False)[source]#

Computes calibration hist of a collection of runs. A fit is performed (train of gaussians) and we have as a return the popt, pcov, perr for the best fitted parameters. Not only that but a plot is displayed.

Parameters
  • my_runs (dict) – run(s) we want to check.

  • info (dict) – dictionary with the information of the run.

  • keys (list) – variables we want to plot as histograms.

  • OPT (dict) – several options that can be True or False. (a) LOGY: True if we want logarithmic y-axis (b) SHOW: if True, it will show the calibration plot

  • save (bool) – if True, it will save the plot in the images folder.

  • debug (bool) – if True, it will display the debug messages.

Returns

calibration

Return type

dict

lib.cal_functions.calibration_fit_plot(ax_cal, counts, bins, OPT, debug=False)[source]#

This function performs the calibration fit and plots the results.

Parameters
  • ax_cal (matplotlib axis) – axis to plot the calibration fit.

  • counts (nparray) – counts of the histogram.

  • bins (nparray) – bins of the histogram.

  • OPT (dict) – several options that can be True or False.

  • debug (bool) – if True, it will display the debug messages.

Returns

popt, pcov

Return type

tuple

lib.cal_functions.calibration_txt(run, ch, key, popt, pcov, info, debug=False) bool[source]#

Computes calibration parameters.

Parameters
  • run (int) – run number.

  • ch (int) – channel number.

  • key (str) – key of the histogram.

  • popt (nparray) – best fit parameters.

  • pcov (nparray) – covariance matrix.

  • info (dict) – dictionary with the information of the run.

  • debug (bool) – if True, it will display the debug messages.

Returns

export

Return type

bool

lib.cal_functions.charge_fit(my_runs, keys, OPT={})[source]#

Computes charge hist of a collection of runs. A fit is performed (1 gaussian) and we have as a return the popt, pcov, perr for the best fitted parameters. Not only that but a plot is displayed.

Parameters
  • my_runs (dict) – run(s) we want to check.

  • keys (list) – variables we want to plot as histograms.

  • OPT (dict) – several options that can be True or False. (a) LOGY: True if we want logarithmic y-axis (b) SHOW: if True, it will show the calibration plot

Returns

all_popt, all_pcov, all_perr

Return type

list, list, list

lib.cal_functions.export_txt(data: dict, info: dict, debug: bool = False) None[source]#

This function exports the calibration and xtalk data to a txt file.

Parameters
  • data (dict) – data to be exported.

  • info (dict) – dictionary with the information of the run.

  • debug (bool) – if True, it will display the debug messages.

Returns

None

lib.cal_functions.get_gains(run, channels, folder_path='TUTORIAL', debug=False)[source]#

This function reads the gains from the txt files.

Parameters
  • run (int) – run number.

  • channels (list) – channels to read the gains from.

  • folder_path (str) – path to the folder where the gains are stored.

  • debug (bool) – if True, it will display the debug messages.

Returns

gains, Dgain

Return type

dict, dict

lib.cal_functions.save_figures(fig_cal, fig_xt, labels, save_path, debug=False)[source]#

Saves the figures in the images folder.

Parameters
  • fig_cal (matplotlib figure) – figure of the calibration.

  • fig_xt (matplotlib figure) – figure of the xtalk.

  • labels (tuple) – labels of the histogram.

  • save_path (str) – path to the folder where the images are stored.

  • debug (bool) – if True, it will display the debug messages.

Returns

None

lib.cal_functions.scintillation_txt(run, ch, key, popt, pcov, filename, info)[source]#

Computes charge parameters. Given popt and pcov which are the output for the best parameters when performing the Gaussian fit.

Parameters
  • run (int) – run number.

  • ch (int) – channel number.

  • key (str) – key of the histogram.

  • popt (nparray) – best fit parameters.

  • pcov (nparray) – covariance matrix.

  • filename (str) – name of the file to save the parameters.

  • info (dict) – dictionary with the information of the run.

Returns

export

Return type

bool

lib.cal_functions.vis_persistence(my_run, info, OPT, save=False, debug=False)[source]#

This function plot the PERSISTENCE histogram of the given runs&ch. It perfoms a cut in 20<”PeakTime”(bins)<50 so that all the events not satisfying the condition are removed. Binning is fixed (x=5000, y=1000) [study upgrade]. X_data (time) and Y_data (waveforms) are deleted after the plot to save space. WARNING! flattening long arrays leads to MEMORY problems :/.

Parameters
  • my_run (dict) – run(s) we want to check.

  • info (dict) – dictionary with the information of the run.

  • OPT (dict) – several options that can be True or False.

  • save (bool) – if True, it will save the plot in the images folder.

  • debug (bool) – if True, it will display the debug messages.

lib.cal_functions.xtalk_fit_plot(ax_xt, popt, labels, OPT, debug=False)[source]#

This function performs the xtalk fit and plots the results.

Parameters
  • ax_xt (matplotlib axis) – axis to plot the xtalk fit.

  • popt (nparray) – best fit parameters.

  • labels (tuple) – labels of the histogram.

  • OPT (dict) – several options that can be True or False.

  • debug (bool) – if True, it will display the debug messages.

Returns

xt_popt, xt_pcov

Return type

tuple

lib.cal_functions.xtalk_txt(run, ch, key, xt_popt, xt_pcov, info, debug=False) bool[source]#

Computes xtalk parameters.

Parameters
  • run (int) – run number.

  • ch (int) – channel number.

  • key (str) – key of the histogram.

  • xt_popt (nparray) – best fit parameters.

  • xt_pcov (nparray) – covariance matrix.

  • info (dict) – dictionary with the information of the run.

  • debug (bool) – if True, it will display the debug messages.

Returns

export

Return type

bool


CUT#

SUMMARY

These functions are used to perform cuts.

lib.cut_functions.cut_df(my_runs, cut_dict={}, debug=False)[source]#

This function cuts the data using a dictionary with the cuts.

Parameters
  • my_runs (dict) – dictionary containing the data

  • cut_dict (dict, optional) – dictionary containing the cuts, defaults to {}. It must follow the format {(key, logic, value, inclusive): channels}

  • debug (bool) – boolean to print debug messages, defaults to False

Returns

None

lib.cut_functions.cut_lin_rel(my_runs, keys, compare='NONE', percentile=[0.1, 99.9])[source]#

This is a function to cut manually with a polygonal figure on two variables. You can do any polygonal figure (avoid strange figures with crossed lines). β€œLeft click” chooses vertexes, β€œright click” deletes the last vertex and β€œmiddle click” finishes the figure.

Parameters
  • my_runs (dict) – dictionary containing the data

  • keys (list) – list of variables you want to plot and cut

  • compare (str, optional) – NONE, RUNS, CHANNELS to decide the histogram to use, defaults to β€œNONE”

  • percentile (list, optional) – the percentile used to reject outliers in the histogram, defaults to [0.1, 99.9]

Returns

None

lib.cut_functions.cut_min_max(my_runs, keys, limits, ranges=[0, 0], chs_cut=[], apply_all_chs=False, debug=False)[source]#

This is a fuction for cuts of min - max values. It takes a variable(s) and checks whether its value is between the specified limits. Important! Each key works independently. If one key gives True and the other False, it remains False. Example: keys = [β€œPeakAmp”, β€œPeakTime”], limits = {β€œPeakAmp”: [20,50], β€œPeakTime”: [4e-6, 5e-6]}

Parameters
  • my_runs (dict) – dictionary containing the data

  • keys (list) – list of variables you want to constrain

  • limits (dict) – dictionary with same keys than variable β€œkeys” and a list of the min and max values you want

  • ranges (list, optional) – list with the range where we want to check the key value. If [0,0] it uses the whole window. Time in sec, defaults to [0,0]

  • chs_cut (list, optional) – list with the affected channels, defaults to []

  • apply_all_chs (bool, optional) – boolean to decide if we want to reject each cut event for ALL loaded channels, defaults to False

  • debug (bool) – boolean to print debug messages, defaults to False

Returns

None

lib.cut_functions.cut_min_max_sim(my_runs, keys, limits, debug=False)[source]#

This is a fuction for cuts of min - max values. It takes a variable(s) and checks whether its value is between the specified limits. Important! Keys are related, so all keys must be False to cut the event. If any of the conditions is True, the event is not cutted. Example: keys = [β€œPeakAmp”], limits = {β€œPeakAmp”: [20,50]}

Parameters
  • my_runs (dict) – dictionary containing the data

  • keys (list) – list of variables you want to constrain

  • limits (dict) – dictionary with same keys than variable β€œkeys” and a list of the min and max values you want

  • debug (bool) – boolean to print debug messages, defaults to False

Returns

None

lib.cut_functions.cut_peak_finder(my_runs, number_peaks, wdth=4, prom=0.01, dist=30)[source]#

This is a peak finder (aprox) and cuts events with more than β€œnumber_peaks” in the window. It checks if AveWvfSPE exists (for calibration runes) and set the threshold in 3/4 of the SPE max. Other way it takes into account the Max value in Pedestal (this works well for laser runes). WARNING! Maybe the values of width, prominence and distance may be changed.

Parameters
  • my_runs (dict) – dictionary containing the data

  • number_peaks (int) – number of peaks to cut

  • wdth (int, optional) – width of the peaks, defaults to 4

  • prom (float, optional) – prominence of the peaks, defaults to 0.01

  • dist (int, optional) – distance between peaks, defaults to 30

Returns

None

lib.cut_functions.cut_ped_std(my_runs, n_std=2, chs_cut=[], apply_all_chs=False, debug=False)[source]#

This is a fuction for a cut in the PedSTD. It uses the median as reference and eliminates events with PedSTD > median + n_std*std, where std is the Standard Deviation of the PedSTD distribution (previously filtered with percentiles).

Parameters
  • my_runs (dict) – dictionary containing the data

  • n_std (int, optional) – number of standard deviations to cut, defaults to 2

  • chs_cut (list, optional) – list with the affected channels, defaults to []

  • apply_all_chs (bool, optional) – boolean to decide if we want to reject each cut event for ALL loaded channels, defaults to False

  • debug (bool) – boolean to print debug messages, defaults to False

Returns

None

lib.cut_functions.cut_selector(my_runs, user_input, debug=False)[source]#
lib.cut_functions.generate_cut_array(my_runs, ref='', debug=False)[source]#

This function generates an array of bool = True. If cuts are applied and then you run this function, it resets the cuts.

Parameters
  • my_runs (dict) – dictionary containing the data

  • ref (str, optional) – reference variable to generate the cut array, defaults to β€œβ€

  • debug (bool, optional) – boolean to print debug messages, defaults to False

Returns

my_runs

Return type

dict

lib.cut_functions.print_cut_info(my_cuts, stage='partial', debug=False)[source]#

DEC#

SUMMARY

These functions are used to perform deconvolution.

lib.dec_functions.check_array_even(wvf)[source]#
lib.dec_functions.check_array_len(wvf1, wvf2)[source]#
lib.dec_functions.conv_func2(wvf, t0, sigma, tau1, a1, tau2, a2)[source]#
lib.dec_functions.deconvolve(my_runs, info, keys=[], noise_run=[], peak_buffer=20, OPT={}, debug=False)[source]#

This function deconvolves any given number of arrays according to a provided SPE template.

Parameters
  • my_runs (dict) – dictionary containing the wvf to be deconvolved

  • info (dict) – dictionary containing the output path

  • keys (list) – list containing the keys of [wvf, template, outputkey]

  • noise_run (dict) – dictionary containing the noise run

  • peak_buffer (int) – left distance from peak to calculate baseline

  • OPT (dict) – dictionary with settings and vis options (β€œSHOW”, β€œLOGY”, β€œNORM”, β€œFILTER”: Gauss/Wiener, etc.).

  • debug (bool, optional) – debug flag, defaults to False

lib.dec_functions.generate_SER(my_runs, light_runs, SPE_runs, scaling_type='Amplitude', debug=False)[source]#

This function rescales AveWvfs from light runs to SPE level to be used for wvf deconvolution.

Parameters
  • my_runs (dict) – dictionary containing the wvf to be deconvolved

  • light_runs (dict) – dictionary containing the wvfs that work as detector response (light runs)

  • SPE_runs (dict) – dictionary containing the SPE wvf that serve as reference to rescale dec_runs

  • scaling_type (str, optional) – type of scaling to be used, defaults to β€œAmplitude”

  • debug (bool, optional) – debug flag, defaults to False

lib.dec_functions.logconv_func2(wvf, t0, sigma, tau1, a1, tau2, a2)[source]#

FIG CONFIG#

lib.fig_config.add_grid(ax, lines=True, locations=None)[source]#

Add a grid to the current plot.

Parameters
  • ax (Axis) – axis object in which to draw the grid.

  • lines (bool, optional) – add lines to the grid, defaults to True

  • locations (tuple, optional) – (xminor, xmajor, yminor, ymajor), defaults to None

lib.fig_config.figure_features(tex=True, font='serif', dpi=600)[source]#

Customize figure settings.

Parameters
  • tex (bool, optional) – use LaTeX, defaults to tex_installed

  • font (str, optional) – font type, defaults to β€œserif”

  • dpi (int, optional) – dots per inch, defaults to 600

lib.fig_config.format_coustom_plotly(fig: plotly.graph_objs._figure.Figure, title: Optional[str] = None, legend: dict = {}, fontsize: int = 16, figsize: Optional[int] = None, ranges: tuple = (None, None), matches: tuple = ('x', 'y'), tickformat: tuple = ('.s', '.s'), log: tuple = (False, False), margin: dict = {'auto': True}, add_units: bool = True, debug: bool = False)[source]#

Format a plotly figure

Parameters
  • fig (go.Figure) – plotly figure

  • title (str, optional) – title of the figure, defaults to None

  • legend (dict, optional) – legend options, defaults to dict()

  • fontsize (int, optional) – font size, defaults to 16

  • figsize (tuple, optional) – figure size, defaults to None

  • ranges (tuple, optional) – axis ranges, defaults to (None,None)

  • matches (tuple, optional) – axis matches, defaults to (β€œx”,”y”)

  • tickformat (tuple, optional) – axis tick format, defaults to (β€˜.s’,’.s’)

  • log (tuple, optional) – axis log scale, defaults to (False,False)

  • margin (dict, optional) – figure margin, defaults to {β€œauto”:True}

  • add_units (bool, optional) – True to add units to axis labels, False otherwise, defaults to True

  • debug (bool, optional) – True to print debug statements, False otherwise, defaults to False

Returns

plotly figure

Return type

go.Figure

lib.fig_config.get_run_units(var, debug=False)[source]#

Returns the units of a variable based on the variable name

Parameters
  • var (str) – variable name

  • debug (bool) – True to print debug statements, False otherwise, defaults to False

Returns

units

Return type

str

lib.fig_config.unicode(x)[source]#

Returns the unicode character for a given string

Parameters

x (str) – string to convert to unicode

Returns

unicode character

Return type

str


FIT#

SUMMARY

These functions are used to perform fits.

lib.fit_functions.B(i, k, debug=False)[source]#

Factorial factor of F

lib.fit_functions.F(K, p, L, debug=False)[source]#

Computes prob of the kth point in a convoluted poisson+binomial distribution. L is the mean value of the poisson, p is the binomial coef, i.e. the crosstalk we want to compute

lib.fit_functions.PoissonPlusBinomial(x, N, p, L, debug=False)[source]#
lib.fit_functions.chi_squared(x, y, popt)[source]#
lib.fit_functions.cut_threshold(raw, thrld)[source]#
lib.fit_functions.dec_gauss(f, fc, n)[source]#
lib.fit_functions.fit_dec_gauss(f, fc, n)[source]#
lib.fit_functions.fit_gaussians(x, y, *p0)[source]#
lib.fit_functions.fit_wvfs(my_runs, info, signal_type, thrld, fit_range=[0, 200], i_param={}, in_key=['ADC'], out_key='', OPT: Optional[dict] = None, save: bool = False, debug: bool = False)[source]#

DOC

lib.fit_functions.func(t, t0, sigma, a, tau)[source]#
lib.fit_functions.func2(t, p, t0, sigma, a1, tau1, sigma2, a2, tau2)[source]#
lib.fit_functions.func3(t, p, t0, sigma, a1, tau1, a2, tau2, a3, tau3)[source]#
lib.fit_functions.gauss(x, a, x0, sigma)[source]#
lib.fit_functions.gaussian(x, center, height, width)[source]#
lib.fit_functions.gaussian_fit(counts, bins, bars, thresh, fit_function='gaussian', custom_fit=[0])[source]#

This function fits the histogram, to a gaussians.

Params counts

counts of the histogram

Params bins

bins of the histogram

Params bars

bars of the histogram

Params thresh

threshold value (for height of peaks and valleys)

Params fit_function

function to fit to, defaults to β€œgaussian”

Params custom_fit

custom fit, defaults to [0]

Returns

x, popt, pcov, perr – x values, fit parameters, covariance matrix and errors

Return type

tuple

lib.fit_functions.gaussian_train(x, *params)[source]#
lib.fit_functions.gaussian_train_fit(fig, x, y, y_intrp, peak_idx, valley_idx, params, debug=False)[source]#

This function fits the histogram, to a train of gaussians.

lib.fit_functions.get_initial_parameters(i_param)[source]#

DOC

lib.fit_functions.lmfit_models(function)[source]#
lib.fit_functions.log_scint_profile(x, const, a_f, tau_f, tau_s)[source]#
lib.fit_functions.log_tau_slow_profile(x, a_s, tau_s)[source]#
lib.fit_functions.logfunc2(t, p, t0, sigma1, a1, tau1, sigma2, a2, tau2)[source]#
lib.fit_functions.logfunc3(t, p, t0, sigma, a1, tau1, a2, tau2, a3, tau3)[source]#
lib.fit_functions.loggaussian(x, center, height, width)[source]#
lib.fit_functions.loggaussian_train(x, *params)[source]#
lib.fit_functions.logpurity(t, p, t0, a1, a3, sigma, quenching)[source]#
lib.fit_functions.logsimple_purity(t, p, t0, a0, a1, sigma, quenching)[source]#
lib.fit_functions.peak_fit(fit_raw, raw_x, buffer, thrld, sigma_fast=1e-09, a_fast=1, tau_fast=1e-08, OPT={})[source]#

This function fits the peak to a gaussian function, and returns the parameters

lib.fit_functions.peak_valley_finder(x, y, params)[source]#

This function finds the peaks and valleys of the histogram.

lib.fit_functions.pmt_spe_fit(counts, bins, bars, thresh)[source]#

This function fits the histogram, to a train of gaussians

[es muy parecida a gaussian_train_fit; hay algunas cosas que las coge en log pero igual se pueden unificar]

[se le puede dedicar un poco mas de tiempo para tener un ajuste mas fino pero parece que funciona]

lib.fit_functions.pure_scint(time, t0, a1, a2, tau1, tau2)[source]#
lib.fit_functions.purity(t, p, t0, a1, a3, sigma, quenching)[source]#
lib.fit_functions.purity_fit(info, labels, raw, raw_x, fit_range, thrld=1e-06, i_param={}, OPT: Optional[dict] = None, save: bool = False, debug: bool = False)[source]#

DOC

lib.fit_functions.sc_fit(info, labels, raw, raw_x, fit_range, thrld=1e-06, OPT: Optional[dict] = None, save: bool = False, debug: bool = False)[source]#
lib.fit_functions.scfunc(t, a, b, c, d, e, f)[source]#
lib.fit_functions.scint_fit(info, labels, raw, raw_x, fit_range, thrld=1e-06, i_param={}, OPT: Optional[dict] = None, save: bool = False, debug: bool = False)[source]#

DOC

lib.fit_functions.scint_profile(x, const, a_f, tau_f, tau_s)[source]#
lib.fit_functions.simple_purity(t, p, t0, a0, a1, sigma, quenching)[source]#
lib.fit_functions.simple_purity_fit(info, labels, raw, raw_x, fit_range, thrld=1e-06, i_param={}, OPT: Optional[dict] = None, save: bool = False, debug: bool = False)[source]#

DOC

lib.fit_functions.simple_scint_fit(info, labels, raw, raw_x, fit_range, i_param={}, OPT: Optional[dict] = None, save: bool = False, debug: bool = False)[source]#

DOC

lib.fit_functions.sipm_fit(info, labels, raw, raw_x, fit_range, thrld=1e-06, OPT: Optional[dict] = None, save: bool = False, debug: bool = False)[source]#

DOC

lib.fit_functions.tau_fit(info, labels, raw, raw_x, fit_range, i_param={}, OPT: Optional[dict] = None, save: bool = False, debug: bool = False)[source]#

DOC

lib.fit_functions.tau_slow_profile(x, a_s, tau_s)[source]#
lib.fit_functions.test_gaussian(x, center, width)[source]#

GROUP#

lib.group_functions.group_chns(data, chs: tuple, operation, remove=True, debug=False)[source]#

Group chs in the data dictionary

Parameters
  • data (dict) – dictionary containing the data

  • chs (tuple) – tuple containing the chs to group

  • operation (str) – operation to perform on the data

  • remove (bool, optional) – flag to remove the chs from the data dictionary, defaults to True

  • debug (bool, optional) – flag to print debug information, defaults to False

Returns

grouped_chns

Return type

dict

lib.group_functions.group_data(data, combination_dict, remove=False, operation='add', debug=False)[source]#

Group runs and/or chs in the data dictionary.

Parameters
  • data (dict) – dictionary containing the data

  • combination_dict (dict) – dictionary containing the runs and chs to group

  • remove (bool, optional) – flag to remove the runs/chs from the data dictionary, defaults to False

  • operation (str, optional) – operation to perform on the data, defaults to β€œadd”

  • debug (bool, optional) – flag to print debug information, defaults to False

Returns

data

Return type

dict

lib.group_functions.group_runs(data, runs: tuple, operation, remove=True, debug=False)[source]#

Group runs in the data dictionary

Parameters
  • data (dict) – dictionary containing the data

  • runs (tuple) – tuple containing the runs to group

  • operation (str) – operation to perform on the data

  • remove (bool, optional) – flag to remove the runs from the data dictionary, defaults to True

  • debug (bool, optional) – flag to print debug information, defaults to False

Returns

grouped_runs

Return type

dict

lib.group_functions.group_selector(data, remove=False, operation='add', debug=False)[source]#

Ask the user to select runs and/or chs to group and generate a combination dictionary

Parameters
  • data (dict) – dictionary containing the data

  • remove (bool, optional) – flag to remove the runs/chs from the data dictionary, defaults to False

  • operation (str, optional) – operation to perform on the data, defaults to β€œadd”

  • debug (bool, optional) – flag to print debug information, defaults to False

Returns

comb_data

Return type

dict

lib.group_functions.group_vars(operation, data, grouped_chns, run, new_ch, var, ch, debug=False)[source]#

Group variables in the data dictionary

Parameters
  • operation (str) – operation to perform on the data

  • data (dict) – dictionary containing the data

  • grouped_chns (dict) – dictionary containing the grouped data

  • run (str) – run number

  • new_ch (str) – new channel

  • var (str) – variable

  • ch (str) – channel

  • debug (bool, optional) – flag to print debug information, defaults to False

Returns

grouped_chns

Return type

dict



IO#

SUMMARY

  • Read/write. Input files stored in the config/input folder (read_input_file). After deconvolution, new input files generated and can be used to re-run the workflow (list_to_string + generate_input_file).

  • Conversion. From raw(.root or .dat) data files to .npy or .npz files. For example, with raw data stored as run00/wave0.dat after running binary2npy we will create folders run00/ch0 where we will store the .npy files. Each .npy file will have the name of the variable we are storing (i.e ADC.npy, AveWvf.npy, PedSTD.npy, Sampling.npy).

  • [DEPRECATING] Check and delete the keys of a dictionary. The keys are the names of the variables stored in the dictionary that correspond to the names of the .npy files stored before.

  • Load/save .npy files. Get the list of preset names that we want to load or save. This output list is used then in the load/save functions.

lib.io_functions.binary2npy(runs, channels, info, compressed=True, header_lines=6, force=False, debug=False)[source]#

Dumper from binary format to npy tuples. Input are binary input file path and npy outputfile as strings. Depends numpy.

Parameters
  • runs (np.array) – array with the run numbers

  • channels (np.array) – array with the channel numbers

  • info (dict) – dictionary with the information stored in the input file

  • compressed (bool, optional) – if True, save the file as .npz, defaults to True

  • header_lines (int, optional) – number of header lines, defaults to 6

  • force (bool, optional) – if True, overwrite the file, defaults to False

  • debug (bool) – if True, print debug messages, defaults to False

lib.io_functions.binary2npy_express(in_file: str, header_lines: int = 6, debug: bool = False) tuple[source]#

Dumper from binary format to npy tuples. Input are binary input file path and npy outputfile as strings.

Parameters
  • in_file (str) – binary input file path

  • header_lines (int, optional) – number of header lines, defaults to 6

  • debug (bool) – if True, print debug messages, defaults to False

Returns

ADC, TIMESTAMP

Return type

tuple

lib.io_functions.check_key(OPT, key) bool[source]#

Checks if the given key is included in the dictionary OPT. Returns True if it finds the key.

Parameters
  • OPT (dict) – dictionary

  • key (str) – key to be checked

Returns

bool

lib.io_functions.cuts_info2dict(user_input: dict, info: dict, debug: bool = False) dict[source]#

Convert the information stored in the input file to a dictionary with the cuts information.

Parameters
  • user_input (dict) – dictionary with the user input

  • info (dict) – dictionary with the information stored in the input file

  • debug (bool) – if True, print debug messages, defaults to False

Returns

cuts_dict

Return type

dict

lib.io_functions.delete_keys(my_runs: dict, keys: list, debug: bool = False)[source]#

Delete the keys list introduced as 2nd variable

Parameters
  • my_runs (dict) – dictionary with the runs and channels

  • keys (list) – list with the keys to be deleted

  • debug (bool) – if True, print debug messages, defaults to False

lib.io_functions.generate_input_file(input_file, info, path: str = '/home/docs/checkouts/readthedocs.org/user_builds/scint/checkouts/stable/config/input/', label: str = '', debug: bool = False)[source]#

Generate a .txt file with the information needed to load the runs and channels. Used when deconvolving signals to be able to re-start the analysis workflow with the deconvolved waveforms.

Parameters
  • input_file (str) – name of the input file

  • info (dict) – dictionary with the information stored in the input file

  • path (str, optional) – path to the input file, defaults to f”{root}/config/input/”

  • label (str, optional) – label to be added to the input file, defaults to β€œβ€

  • debug (bool) – if True, print debug messages, defaults to False

lib.io_functions.get_preset_list(my_run: dict, path: str, folder: str, preset: str, option: str, debug: bool = False)[source]#

Return as output presets lists for load/save npy files. :param my_run: dictionary with the runs and channels (my_runs[run][ch]) :type my_run: dict :param path: path to the folder :type path: str :param folder: folder name :type folder: str :param preset: preset to be used (ALL, RAW, ANA, EVA, DEC, CAL, WVF) :type preset: str :param option: option to be used (LOAD, SAVE) :type option: str :param debug: if True, print debug messages, defaults to False :type debug: bool

Returns

branch_list

Return type

list

lib.io_functions.list_to_string(input_list: list) str[source]#

Convert a list to a string to be written in a .txt file. Used in generate_input_file.

Parameters

input_list (list) – list to be converted to string

Returns

string

Return type

str

lib.io_functions.load_npy(runs, channels, info, preset=None, branch_list=[], debug: bool = False, compressed: bool = True)[source]#

Loads the selected channels and runs, for simplicity, all runs must have the same number of channels. Presets can be used to only load a subset of desired branches.

Parameters
  • runs (list) – list of runs to load

  • channels (list) – list of channels to load

  • info (dict) – dictionary with the info of the run

  • preset (str, optional) – preset to be used (ALL, RAW, ANA, EVA, DEC, CAL, WVF), defaults None

  • branch_list (list) – list of branches to load, defaults []

  • debug (bool) – if True, print debug info, defaults False

  • compressed (bool, optional) – if True, load the file as .npz, defaults to True

Returns

my_runs with structure: run_dict[runs][channels][BRANCH]

Return type

dict

lib.io_functions.npy2df(my_runs, debug: bool = False) pandas.core.frame.DataFrame[source]#

Converts the npy files to a pandas dataframe.

Parameters
  • my_runs (dict) – dictionary with the runs and channels to be saved

  • debug (bool) – if True, print debug messages, defaults to False

Returns

df

Return type

pd.DataFrame

lib.io_functions.npy2root(my_runs, debug: bool = False)[source]#

Converts the npy files to root TTree files by converting the dictionaries to a RDataFrame from ROOT & using the snapshot method.

Parameters
  • my_runs (dict) – dictionary with the runs and channels to be saved

  • debug (bool) – if True, print debug messages, defaults to False

lib.io_functions.read_input_file(input: str, NUMBERS=[], DOUBLES=[], STRINGS=[], BOOLEAN=[], path: str = '/home/docs/checkouts/readthedocs.org/user_builds/scint/checkouts/stable/config/input/', debug: bool = False) dict[source]#

Obtain the information stored in a .txt input file to load the runs and channels needed.

Parameters
  • input (str) – name of the input file

  • NUMBERS (list, optional) – list of variables that are expected to be integers, defaults to []

  • DOUBLES (list, optional) – list of variables that are expected to be floats, defaults to []

  • STRINGS (list, optional) – list of variables that are expected to be strings, defaults to []

  • BOOLEAN (list, optional) – list of variables that are expected to be booleans, defaults to []

  • path (str, optional) – path to the input file, defaults to f”{root}/config/input/”

  • debug (bool, optional) – if True, print debug messages, defaults to False

Returns

info

Return type

dict

lib.io_functions.read_yaml_file(input: str, path: str = '/home/docs/checkouts/readthedocs.org/user_builds/scint/checkouts/stable/config/input/', debug: bool = False) dict[source]#

Obtain the information stored in a .yml input file to load the runs and channels needed.

Parameters
  • input (str) – name of the input file

  • path (str) – path to the input file, defaults to f”{root}/config/input/”

  • debug (bool) – if True, print debug messages, defaults to False

Returns

data

Return type

dict

lib.io_functions.root2npy(runs, channels, info: dict = {}, debug: bool = False)[source]#

[DEPRECATED - NEEDS UPDATE!! (see binary2npy)] Dumper from .root format to npy tuples. Input are root input file path and npy outputfile as strings. Depends on uproot, awkward and numpy. Size increases x2 times.

Parameters
  • runs (np.array) – array with the run numbers

  • channels (np.array) – array with the channel numbers

  • info (dict) – dictionary with the information stored in the input file

  • debug (bool) – if True, print debug messages, defaults to False

lib.io_functions.save_figure(fig, path, run, ch, label, debug: bool = False)[source]#

Saves the figure in the desired path with the desired name.

Parameters
  • fig (matplotlib.figure.Figure) – figure to be saved

  • path (str) – path to save the figure

  • run (int) – run number

  • ch (int) – channel number

  • label (str) – label of the figure

  • debug (bool) – if True, print debug messages, defaults to False

lib.io_functions.save_proccesed_variables(my_runs, info, preset='', branch_list=None, force=False, compressed=True, debug=False)[source]#

Saves the processed variables an npx file.

Parameters
  • my_runs (dict) – dictionary with the runs and channels to be saved

  • info (dict) – dictionary with the path and month to be used

  • preset (str) – preset to be used to save the variables

  • branch_list (list) – list of branches to be saved

  • force (bool, optional) – if True, the files will be overwritten, defaults to False

  • compressed (bool, optional) – if True, the files will be saved as npz, if False, as npy, defaults to True

  • debug (bool) – if True, the function will print the branches that are being saved, defaults to False

lib.io_functions.write_output_file(run, ch, output, filename, info, header_list, write_mode='w', not_saved=[2, 3], debug=False) bool[source]#

General function to write a txt file with the outputs obtained. The file name is defined by the given β€œfilename” variable + _chX. If the file existed previously it appends the new fit values (it save the run for each introduced row). By default we dont save the height of the fitted gaussian in the txt.

Parameters
  • run (int) – run number

  • ch (int) – channel number

  • output (list) – output to be written in the file

  • filename (str) – name of the file

  • info (dict) – dictionary with the information stored in the input file

  • header_list (list) – list with the header to be written in the file

  • write_mode (str, optional) – mode to write the file, defaults to β€œw”

  • not_saved (list, optional) – list of columns that are not saved in the file, defaults to [2, 3]

  • debug (bool) – if True, print debug messages, defaults to False

Returns

bool

Return type

bool


MINUIT#

SUMMARY

These functions are used to perform fits.

lib.minuit_functions.initial_values(data, function, debug: bool = False)[source]#
lib.minuit_functions.minuit_fit(data, OPT, debug: bool = False)[source]#

This function performs a fit to the data, using the function specified in the input using MINUIT. It returns the parameters of the fit (if performed)

Parameters
  • data (np.array) – data to fit

  • OPT (dict) – dictionary containing the options

  • debug (bool, optional) – debug flag, defaults to False

Returns

m, xdata, norm_ydata – fit parameters, xdata and normalized ydata

lib.minuit_functions.percentile_cut(data, percentile)[source]#
lib.minuit_functions.plot_minuit_fit(m_fit, xdata, ydata, labels, user_input, info, OPT)[source]#
lib.minuit_functions.save_fit_parameters(run, ch, m_fit, fit_function, variable, info, user_input)[source]#

PLY#

lib.ply_functions.custom_legend_name(fig_px, new_names)[source]#
lib.ply_functions.custom_plotly_layout(fig_px, xaxis_title='', yaxis_title='', title='', barmode='stack', bargap=0)[source]#
lib.ply_functions.save_plot(fig_px, name)[source]#
lib.ply_functions.show_html(fig_px)[source]#
lib.ply_functions.vis_event(in_file)[source]#

SIM#

lib.sim_functions.combi_convolve_poisson(bins, height, eff)[source]#
lib.sim_functions.expand_bins(bins, data)[source]#

This function expands the bins to the data range if the bins are smaller than the data range.

Parameters
  • bins (nparray) – bins.

  • data (nparray) – data.

Returns

array – expanded bins.

Return type

nparray

lib.sim_functions.fitting_function(function, debug=False)[source]#
lib.sim_functions.interpolate_sim_data(bins, path, percentile=(1, 99))[source]#

This function interpolates the simulated data to the desired binning.

Parameters
  • bins (int or nparray) – bins.

  • path (str) – path to the simulated data.

  • percentile (tuple, optional) – percentile range to consider, defaults to (1, 99).

Returns

bin_centers, hist – bin centers and histogram.

Return type

tuple

lib.sim_functions.larsoft_template(time_in_us, fPeakTime, fVoltageToADC, fMaxAmplitude, fFrontTime, fBackTime)[source]#

LArSoft template

Parameters
  • time_in_us (nparray) – time in microseconds.

  • fPeakTime (float) – peak time.

  • fVoltageToADC (float) – voltage to ADC conversion.

  • fMaxAmplitude (float) – maximum amplitude.

  • fFrontTime (float) – front time.

  • fBackTime (float) – back time.

Returns

array – template.

Return type

nparray

lib.sim_functions.rand_scint_times(n, fast=6e-09, slow=1.4e-06, ratio=0.23)[source]#

This function is a randon number generator that returns a sorted nparray of photon arrival times according to a given scintilation profile. Values adopted from: Enhancement of the X-Arapuca photon detection device for the DUNE experiment, Journal of Instrumentation, vol. 16, p. P09027, sep (2021).

Parameters
  • n (int) – number of produced times.

  • fast (float) – tau value of fast scint component – default: 6e-9 [s]

  • slow (float) – tau value of slow scint component – default: 1e-6 [s]

  • ratio (float) – ratio of the slow scint components sholud be [0,1] – default: 0.23

Returns

sorted nparray of photon arrival times.

Return type

nparray

Returns

array – sorted nparray of photon arrival times.

Return type

nparray

lib.sim_functions.setup_fitting_function(function_name, ydata, xdata, debug=False)[source]#
lib.sim_functions.sipm1_convolve_poisson(bins, height, eff)[source]#

STY#

lib.sty_functions.get_color(number, even=True, style='prism', debug=False)[source]#
lib.sty_functions.get_even_color(number)[source]#
lib.sty_functions.get_prism_colors()[source]#
lib.sty_functions.style_selector(OPT: Optional[dict] = None)[source]#

UNIT#

lib.unit_functions.calibrate_charges(my_runs, info, user_input, debug=False)[source]#
lib.unit_functions.get_run_units(my_runs, debug=False)[source]#

Computes and store in a dictionary the units of each variable.

Parameters
  • my_runs (dict) – dictionary containing the data

  • debug (bool, optional) – boolean to print debug messages, defaults to False

Returns

None

lib.unit_functions.get_unit(key, debug=False)[source]#

VIS#

SUMMARY

These functions are used to visualize the data.

  • Individual evts. We can compare them with the computed AveWaveform is computed, and also we can plot several average waveforms in the same plot (vis_npy, vis_compare_wvf).

  • Histograms. 1D and 2D histograms of the chosen variables. In principle these histograms are used to generate cuts of outlying events (vis_var_hist, vis_two_var_hist).

  • Statistics. we can print the statistics of the variables stored in the dictionary (print_stats).

lib.vis_functions.plot_compare_wvf(my_run, run, ch, key, fig, axs, idx, OPT, ref_max_idx=None, stats=False)[source]#

This function plots the waveform of the selected key. It allows to compare between runs or channels.

Parameters
  • my_run (dict) – run(s) we want to check

  • run (int) – run we want to check

  • ch (int) – channel we want to check

  • key (str) – key we want to plot

  • fig (matplotlib.figure.Figure) – figure to plot

  • axs (matplotlib.axes._subplots.AxesSubplot) – axis to plot

  • idx (int) – index to plot

  • OPT (dict) – several options that can be True or False (a) MICRO_SEC: if True we multiply Sampling by 1e6 (b) NORM: True if we want normalized waveforms (c) LOGY: True if we want logarithmic y-axis (d) STATS: True if we want to print statistics

  • ref_max_idx (int) – index to align the waveforms

  • stats (bool) – True if we want to print statistics

Returns

ref_max_idx

Return type

int

lib.vis_functions.print_stats(my_run, labels, ax, data, info, save=False, debug=False)[source]#

This function prints the statistics of the data.

Parameters
  • my_run (dict) – run(s) we want to check

  • labels (tuple) – labels of the data

  • ax (matplotlib axis) – axis to plot

  • data (list) – data to analyze

  • info (dict) – info dictionary

  • save (bool) – True if we want to save the statistics

  • debug (bool) – True if we want to print debug messages

Returns

None

lib.vis_functions.print_stats_terminal(my_run, labels, data)[source]#

This function prints the statistics of the data in the terminal.

Parameters
  • my_run (dict) – run(s) we want to check

  • labels (tuple) – labels of the data

  • data (list) – data to analyze

Returns

rate

Return type

float

lib.vis_functions.vis_compare_wvf(my_run, info, keys, OPT={}, save=False, debug=False)[source]#

This function is a waveform visualizer. It plots the selected waveform with the key and allow comparisson between runs/channels.

Parameters
  • my_run (dict) – run(s) we want to check

  • info (dict) – info dictionary

  • keys (list) – waveform to plot (AveWvf, AveWvdSPE, …)

  • OPT (dict) – several options that can be True or False (a) MICRO_SEC: if True we multiply Sampling by 1e6 (b) NORM: True if we want normalized waveforms (c) LOGY: True if we want logarithmic y-axis (d) COMPARE: β€œRUNS” to get a plot for each channel and the selected runs, β€œCHANNELS” to get a plot for each run and the selected channels (e) STATS: True if we want to print statistics

  • save (bool) – True if we want to save the plot

  • debug (bool) – True if we want to print debug messages

Returns

None

lib.vis_functions.vis_npy(my_run, info, keys, OPT={}, save=False, debug=False)[source]#

This function is a event visualizer. It plots individual events of a run, indicating the pedestal level, pedestal std and the pedestal calc limit. We can interact with the plot and pass through the events freely (go back, jump to a specific event…)

Parameters
  • my_run (dict) – run(s) we want to check

  • info (dict) – info dictionary

  • keys (list) – choose between ADC or AnaADC to see raw (as get from ADC) or Analyzed events (starting in 0 counts), respectively

  • OPT (dict) – several options that can be True or False (a) MICRO_SEC: if True we multiply Sampling by 1e6 (b) NORM: True if we want normalized waveforms (c) LOGY: True if we want logarithmic y-axis (d) SHOW_AVE: if computed and True, it will show average (e) SHOW_PARAM: True if we want to check calculated parameters (pedestal, amplitude, charge…) (f) CHARGE_KEY: if computed and True, it will show the parametre value (g) PEAK_FINDER: True if we want to check how many peaks are (h) CUTTED_WVF: choose the events we want to see. If -1 all events are displayed, if 0 only uncutted events are displayed, if 1 only cutted events are displayed (i) SAME_PLOT: True if we want to plot different channels in the SAME plot

  • save (bool) – True if we want to save the plot

  • debug (bool) – True if we want to print debug messages

Returns

None

lib.vis_functions.vis_two_var_hist(my_run, info, keys, percentile=[0.1, 99.9], select_range=False, OPT: Optional[dict] = None, save=False, debug=False)[source]#

This function plots two variables in a 2D histogram. Outliers are taken into account with the percentile. It plots values below and above the indicated percetiles, but values are not removed from data.

Parameters
  • my_run (dict) – run(s) we want to check

  • info (dict) – info dictionary

  • keys (list) – variables we want to plot as histograms. Type: List

  • percentile (list) – percentile used for outliers removal

  • select_range (bool) – True if we want to select the range of the histogram (useful if there are many outliers)

  • OPT (dict) – several options that can be True or False (a) DENSITY: True if we want density histograms (b) ACCURACY: binning of the histogram (c) TERMINAL_MODE: True if we want to select the channels in the terminal (d) COMPARE: β€œRUNS” to get a plot for each channel and the selected runs, β€œCHANNELS” to get a plot for each run and the selected channels (e) SHOW: True if we want to show the plot (f) SAVE: True if we want to save the plot

  • save (bool) – True if we want to save the plot

  • debug (bool) – True if we want to print debug messages

Returns

None

lib.vis_functions.vis_var_hist(my_run, info, key, percentile=[0.1, 99.9], OPT={'SHOW': True}, select_range=False, save=False, debug=False)[source]#

This function takes the specified variables and makes histograms. The binning is fix to 600, so maybe it is not the appropriate. Outliers are taken into account with the percentile. It discards values below and above the indicated percetiles. It returns values of counts, bins and bars from the histogram to be used in other function. WARNING! Maybe the binning stuff should be studied in more detail.

Parameters
  • my_run (dict) – run(s) we want to check

  • info (dict) – info dictionary

  • key (list) – variables we want to plot as histograms. Type: List (a) PeakAmp: histogram of max amplitudes of all events. The binning is 1 ADC. There are not outliers. (b) PeakTime: histogram of times of the max amplitude in events. The binning is the double of the sampling. There are not outliers. (c) Other variable: any other variable. Here we reject outliers.

  • percentile (list) – percentile used for outliers removal

  • OPT (dict) – several options that can be True or False (a) DENSITY: True if we want density histograms (b) ACCURACY: binning of the histogram (c) TERMINAL_MODE: True if we want to select the channels in the terminal (d) COMPARE: β€œRUNS” to get a plot for each channel and the selected runs, β€œCHANNELS” to get a plot for each run and the selected channels (e) SHOW: True if we want to show the plot (f) SAVE: True if we want to save the plot

  • select_range (bool) – True if we want to select the range of the histogram

  • save (bool) – True if we want to save the plot

  • debug (bool) – True if we want to print debug messages

Returns

all_counts, all_bins