diff options
author | tlatorre <tlatorre@uchicago.edu> | 2019-09-09 19:20:30 -0500 |
---|---|---|
committer | tlatorre <tlatorre@uchicago.edu> | 2019-09-09 19:20:30 -0500 |
commit | f8ff1634bea94d92c64001d2070001dc7051bfcd (patch) | |
tree | a022a2d3c3ce1f0ef5c0ec71d12837b85754236b /utils/plot-energy | |
parent | 01b15115fe165bd694971b0908bb08441675b99e (diff) | |
download | sddm-f8ff1634bea94d92c64001d2070001dc7051bfcd.tar.gz sddm-f8ff1634bea94d92c64001d2070001dc7051bfcd.tar.bz2 sddm-f8ff1634bea94d92c64001d2070001dc7051bfcd.zip |
add retrigger, flasher follower, and breakdown follower cuts to plot-energy
Diffstat (limited to 'utils/plot-energy')
-rwxr-xr-x | utils/plot-energy | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/utils/plot-energy b/utils/plot-energy index 8d6cb31..9f5b53d 100755 --- a/utils/plot-energy +++ b/utils/plot-energy @@ -62,6 +62,7 @@ DC_OWL = 0x80 DC_OWL_TRIGGER = 0x100 DC_FTS = 0x200 DC_ITC = 0x400 +DC_BREAKDOWN = 0x800 def plot_hist(df, title=None): for id, df_id in sorted(df.groupby('id')): @@ -141,6 +142,28 @@ def unwrap_50_mhz_clock(gtr): """ return unwrap(gtr,0x7ffffffffff*20.0) +def retrigger_cut(ev): + """ + Cuts all retrigger events. + """ + return ev[ev.dt > 500] + +def breakdown_follower_cut(ev): + """ + Cuts all events within 1 second of breakdown events. + """ + breakdowns = ev[ev.dc & DC_BREAKDOWN != 0] + return ev[~np.any((ev.gtr.values > breakdowns.gtr.values[:,np.newaxis]) & \ + (ev.gtr.values < breakdowns.gtr.values[:,np.newaxis] + 1e9),axis=0)] + +def flasher_follower_cut(ev): + """ + Cuts all events within 200 microseconds of flasher events. + """ + flashers = ev[ev.dc & DC_FLASHER != 0] + return ev[~np.any((ev.gtr.values > flashers.gtr.values[:,np.newaxis]) & \ + (ev.gtr.values < flashers.gtr.values[:,np.newaxis] + 200e3),axis=0)] + if __name__ == '__main__': import argparse import matplotlib.pyplot as plt @@ -166,6 +189,10 @@ if __name__ == '__main__': # unwrap the 50 MHz clock within each run ev.gtr = ev.groupby(['run'],as_index=False)['gtr'].transform(unwrap_50_mhz_clock) + # calculate the time difference between each event and the previous event + # so we can tag retrigger events + ev['dt'] = ev.groupby(['run'],as_index=False)['gtr'].transform(lambda x: np.concatenate(([1e9],np.diff(x.values)))) + # This is a bit of a hack. It appears that many times the fit will # actually do much better by including a very low energy electron or # muon. I believe the reason for this is that of course my likelihood @@ -213,8 +240,17 @@ if __name__ == '__main__': print("number of events = %i" % len(ev)) + # flasher follower cut + ev = ev.groupby(['run'],as_index=False).apply(flasher_follower_cut) + + # breakdown follower cut + ev = ev.groupby(['run'],as_index=False).apply(breakdown_follower_cut) + + # retrigger cut + ev = ev.groupby(['run'],as_index=False).apply(retrigger_cut) + # First, do basic data cleaning which is done for all events. - ev = ev[ev.dc & (DC_JUNK | DC_CRATE_ISOTROPY | DC_QVNHIT | DC_FLASHER | DC_NECK | DC_ITC) == 0] + ev = ev[ev.dc & (DC_JUNK | DC_CRATE_ISOTROPY | DC_QVNHIT | DC_FLASHER | DC_NECK | DC_ITC | DC_BREAKDOWN) == 0] print("number of events after data cleaning = %i" % len(ev)) |