4. API

4.1. detectors

This file helps map the data to actual detectors and group them.

-Caleb Marshall, Ohio University 2022

class sauce.detectors.Detector(name: str, primary_energy_col: str | None = None, primary_time_col: str | None = None)

Bases: object

Class to hold data relevant to the specific channel.

apply_cut(cut: Sequence[float], col: str | None = None) Self
apply_gate(gate)
apply_gate(gate: Gate1D)
apply_gate(gate: Gate2D)

Generic function to apply gates to the data contained within a Detector. Dispatches on the types of gates found in sauce.gates.

apply_poly_cut(cut2d: Gate2D) Self

Apply a 2D polygon cut to the data. Gate info is found in Gate2D object found in sauce.gates

apply_threshold(threshold: float, col: str | None = None) Self
build_referenceless_events(build_window: float, col: str | None = None) Self

Assign event numbers to the detector based on just the detectors hits. Also give the multiplicity of the event :param build_window: build window in ns. :returns:

copy() Self

Copy data from detector into new detector instance.

Returns:

Copied instance of detector

counts() int

Returns the number of rows in the data frame

filter(*predicates, **constraints)
find_hits(run_data: str | Run, **kwargs) Self

After more usage, I think it is useful to either load the entire run (detailed analysis) or pull from disk just the specific data.

As such this function is now more general, and calls two other methods to select the data depending on whether a Run object is passed or a path to an h5 file.

get_coin() bool

Returns the current value of coin, and then resets it to True.

If you are constructing anti-coincidences, this makes sure that you will always have self.__coin = True unless you have just called the ~ operator.

Returns:

hist(lower: float, upper: float, bins: int, col: str | None = None, centers: bool = True, norm: float = 1.0) Tuple[ndarray[tuple[int, ...], dtype[Any]], ndarray[tuple[int, ...], dtype[Any]]]

Return a histrogram of the given col.

load(filename) Self
save(filename, file_type: str = 'parquet') Self
sort(by, *more_by, descending=False, nulls_last=False, multithreaded=True, maintain_order=False)
tag(tag: Any, tag_name: str = 'tag') Self

Create a tag column in the dataframe. Examples could be run number, a simple index, or any other desired information.

Parameters:
  • tag

  • tag_name

Returns:

unique(subset=None, *, keep='any', maintain_order=False)
with_columns(*exprs, **named_exprs)
sauce.detectors.detector_union(name: str, *dets: Detector, on: str | None = None) Detector

Union different detectors if into a new detector called “name”

Parameters:

name – string, new detector name

Returns:

Detector object

sauce.detectors.referenceless_event_sort(times, build_window) ndarray[tuple[int, ...], dtype[float64]]

Produce an array with event number.

The event number is based on a simple build window starting from the earliest event. :param times: :param build_window: :returns:

4.2. run_handling

class sauce.run_handling.Run(filename, primary_time_col: str | None = None)

Bases: object

This loads in an entire run to memory to improve the speed at which Detector objects can be created. It also sorts the run by time stamps

4.3. gates

class sauce.gates.CreateGate2D(det, x_col, y_col, **hist2d_kwargs)

Bases: Gate2D

Likely to depreciate this.

drawing_logic()
on_click(event)
on_press(event)
patch_update(closed=False, facecolor='none', alpha=1.0)
class sauce.gates.Gate1D(col: str, points=None)

Bases: object

static load(filename)
save(gate_name)
class sauce.gates.Gate1DFromHist1D(x: Series, bins=None, range=None, **hist1d_kwargs)

Bases: Gate1D

drawing_logic(point=None)
finish_up()
on_click(event)
class sauce.gates.Gate2D(x_col, y_col, points=None)

Bases: object

static load(filename)
save(gate_name)
class sauce.gates.Gate2DFromHist2D(x: Series, y: Series, **hist2d_kwargs)

Bases: Gate2D

drawing_logic()
on_click(event)
on_press(event)
patch_update(closed=False, facecolor='none', alpha=1.0)
sauce.gates.maybe_close_polygon(points)

Close a polygon if it is not already closed. Returns a fresh list.

Parameters:

points – list of tuples

Returns:

list of tuples

4.4. utils

sauce.utils.eff(det1, det2)

Just a basic measure of efficiency, where number of events in det1 is compared to those in det2

sauce.utils.gate2d(x, y, gate, **kwargs)
sauce.utils.hist2d(x, y, **kwargs)

This is so that 2d histograms can be generated uniformly in style

sauce.utils.save_txt_spectrum(filename, x, y)

Save binned data to a two column text file.

Parameters:
  • filename

  • x

  • y

Returns:

sauce.utils.step(x, y, **step_kwargs)

The default step drawing will appear incorrect without where = “post”. Note that the data is the same in both cases, this is just to make the plots appear correct.

Parameters:
  • x

  • y

Returns:

4.5. config

This module holds global configurations that are referenced in all of sauce. For example the default time or energy column. The purpose is to allow additional flexability on how the data file are defined.

-Caleb Marshall UNC/TUNL, 2024

sauce.config.set_default_energy_col(col_name: str)
sauce.config.set_default_time_col(col_name: str)