π LIBRARIES
Contents
π 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.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.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
DEC#
SUMMARY
These functions are used to perform deconvolution.
- 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
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
FIT#
SUMMARY
These functions are used to perform fits.
- 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.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.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_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.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.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.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.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
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
HEAD#
SUMMARY
These functions are used to start the macros, configure the flags and information provided by the user.
- lib.head_functions.apply_cuts(user_input, info, debug=False)[source]#
This function asks the user to select the cuts to be apply to your events.
- Parameters
user_input (dict) β Dictionary with the user input.
info (dict) β Dictionary with the information from the input file.
debug (bool, optional) β Debug mode, defaults to False
- Returns
cut_dict β Dictionary with the cuts to be applied to your events.
- Return type
dict
- lib.head_functions.convert_str_to_type(value, debug=False)[source]#
This function converts a string to its corresponding type.
- Parameters
value (str) β Value to be converted.
debug (bool, optional) β Debug mode, defaults to False
- Returns
value β Converted value.
- Return type
any
- lib.head_functions.get_flag_dict()[source]#
This function returns a dictionary with the available flags for the macro.
- Params None
- Returns
flag_dict (dict) β Dictionary with the available flags for the macro.
- Return type
dict
- lib.head_functions.initialize_macro(macro, input_list: Optional[list] = ['input_file', 'debug'], default_dict: Optional[dict] = None, debug: bool = False)[source]#
This function initializes the macro by reading the input file and the user input.
- Parameters
macro (str) β Name of the macro to be executed.
input_list (list, optional) β List with the keys of the user input that need to be updated, defaults to [βinput_fileβ, βdebugβ]
default_dict (dict, optional) β Dictionary with the default values for the user input, defaults to None
debug (bool, optional) β Debug mode, defaults to False
- Returns
user_input, info β Dictionary with the user input and dictionary with the information from the input file.
- Return type
tuple
- lib.head_functions.opt_selector(filename: str = 'options', arguments: Optional[list] = None, debug: bool = False)[source]#
This function reads the options from a YAML file and allows the user to select the options to be used.
- Parameters
filename (str, optional) β Name of the YAML file, defaults to βoptionsβ
arguments (list, optional) β List with the arguments to be used, defaults to None
debug (bool, optional) β Debug mode, defaults to False
- Returns
updated_opt β Dictionary with the updated options.
- Return type
dict
- lib.head_functions.print_macro_info(macro, debug=False)[source]#
This function prints the information about the macro.
- Parameters
macro (str) β Name of the macro to be executed
debug (bool, optional) β Debug mode, defaults to False
- lib.head_functions.select_input_file(user_input, debug=False)[source]#
This function asks the user to select the input file.
- Parameters
user_input (dict) β Dictionary with the user input.
debug (bool, optional) β Debug mode, defaults to False
- Returns
new_user_input β Dictionary with the updated user input.
- Return type
dict
- lib.head_functions.update_user_input(user_input, new_input_list, info, debug=False)[source]#
This function updates the user input by asking the user to provide the missing information.
- Parameters
user_input (dict) β Dictionary with the user input.
new_input_list (list) β List with the keys of the user input that need to be updated.
info (dict) β Dictionary with the information from the input file.
debug (bool, optional) β Debug mode, defaults to False
- Returns
new_user_input, info β Dictionary with the updated user input and dictionary with the information from the input file.
- Return type
tuple
- lib.head_functions.update_yaml_file(file_path: str, new_data: dict, convert: bool = True, debug: bool = False)[source]#
This function updates a YAML file with new data.
- Parameters
file_path (str) β Path to the YAML file.
new_data (dict) β Dictionary with the new data to be added.
convert (bool, optional) β Convert string to type, defaults to True
debug (bool, optional) β Debug mode, defaults to False
- Returns
None
- lib.head_functions.use_default_input(user_input, default_dict, info, debug=False)[source]#
This function updates the user input by asking the user to provide the missing information.
- Parameters
user_input (dict) β Dictionary with the user input.
default_dict (dict) β Dictionary with the default values for the user input.
info (dict) β Dictionary with the information from the input file.
debug (bool, optional) β Debug mode, defaults to False
- Returns
new_user_input β Dictionary with the updated user input.
- 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.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
PLY#
SIM#
- 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.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
STY#
UNIT#
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