aboutsummaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
Diffstat (limited to 'utils')
-rw-r--r--utils/sddm/plot_energy.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/utils/sddm/plot_energy.py b/utils/sddm/plot_energy.py
index 5838020..d2c9656 100644
--- a/utils/sddm/plot_energy.py
+++ b/utils/sddm/plot_energy.py
@@ -442,6 +442,21 @@ def michel_spectrum(T):
y *= 2*MUON_MASS
return y
+BURST_WINDOW = 1e9
+BURST_MAX_EVENTS = 2
+
+def burst_cut(ev):
+ """
+ Cuts events in which there are more than BURST_MAX_EVENTS prompt events
+ within a BURST_WINDOW time window.
+
+ The idea here is to cut instrumentals which somehow make it past the data
+ cleaning cuts.
+ """
+ burst = (ev.nhit >= 100)
+ burst.loc[burst] &= np.concatenate(([True],np.diff(ev[burst].gtr.values) > BURST_WINDOW))
+ return ev.groupby(burst.cumsum()).filter(lambda ev: len(ev[ev.prompt]) <= BURST_MAX_EVENTS).reset_index()
+
def get_events(filenames, merge_fits=False, nhit_thresh=None, mc=False):
ev = pd.concat([read_hdf(filename, "ev").assign(filename=filename) for filename in filenames],ignore_index=True)
fits = pd.concat([read_hdf(filename, "fits") for filename in filenames],ignore_index=True)
@@ -583,6 +598,8 @@ def get_events(filenames, merge_fits=False, nhit_thresh=None, mc=False):
# to simulate
ev = ev.groupby('run',group_keys=False).apply(retrigger_cut)
+ ev = ev.groupby('run',group_keys=False).apply(burst_cut)
+
# Label instrumentals
ev['noise'] = ev.dc & (DC_JUNK | DC_CRATE_ISOTROPY | DC_QVNHIT | DC_ITC | DC_ESUM) != 0
ev['neck'] = ((ev.dc & DC_NECK) != 0) & ~ev.noise