← Back to Home

Fuse / Strax Quick Cheat Sheet

Minimal commands for the workshop: build targets, load data, plot fast.

Core commands

Core
st.make(run_id, "TARGET")          # compute + store
df  = st.get_df(run_id, "TARGET")  # pandas DataFrame
arr = st.get_array(run_id, "TARGET")  # numpy structured array

Quick checks:df.head()df.columnslen(df)

Multiple targets

Multiple targets
df = st.get_df(run_id, ["microphysics_summary",
                "s1_photon_hits"])

arr = st.get_array(run_id, ["peak_basics",
                "peak_truth"])

Works when rows match (same "data_kind").

Masks (selection)

Masks
mask = (df["electrons"] > 0) & (df["ed"] > 10)
sel = df[mask]

cid = df["cluster_id"].iloc[0]
one = df[df["cluster_id"] == cid]

Histogram + scatter

Plot
import matplotlib.pyplot as plt

plt.hist(df["ed"], bins=50, histtype="step")
plt.yscale("log")  # optional
plt.show()

plt.scatter(df["ed"], df["electrons"]/df["ed"],
            s=2, alpha=0.3)
plt.xscale("log")  # optional
plt.show()

plt.hist2d(...)plt.hexbin(...)plt.errorbar(...)

2D histogram

2D
h, x_edges, y_edges = np.histogram2d(
    df["x"], df["y"],
    bins=(np.linspace(-100, 100, 100),
          np.linspace(-100, 100, 100)))
plt.pcolormesh(x_edges, y_edges, h.T,
             norm=matplotlib.colors.LogNorm())
plt.colorbar(label="counts")

Save figure

Save
plt.savefig("plot.pdf", dpi=300, bbox_inches="tight")

Channels (top/bottom PMTs)

Channels
top    = (df["channel"] <= 253)
bottom = (df["channel"] >= 254)

counts = df["channel"].value_counts().sort_index()
plt.scatter(counts.index, counts.values, s=10)
plt.show()

Waveforms (records / raw_records)

Waveforms
rec = st.get_array(run_id, "records")  # or "raw_records"
r = rec[0]

plt.plot(r["data"][:r["length"]], drawstyle="steps-mid")
plt.show()

Time window example:rec[(rec["time"]>=t0)&(rec["time"]<=t1)]

Tip: if you're unsure what a target contains, try st.data_info("TARGET")