From d48be389e496801d48af305fad67c0d79bb7585a Mon Sep 17 00:00:00 2001 From: tlatorre Date: Mon, 6 Jul 2020 11:29:47 -0500 Subject: small updates to plot-muons and plot_energy.py - use pd.Series.where() instead of DataFrame.loc() to speed things up in tag_michels - don't set y limits when plotting bias and resolution for stopping muons --- utils/plot-muons | 2 -- utils/sddm/plot_energy.py | 8 ++++---- 2 files changed, 4 insertions(+), 6 deletions(-) (limited to 'utils') diff --git a/utils/plot-muons b/utils/plot-muons index f130444..ab2be0e 100755 --- a/utils/plot-muons +++ b/utils/plot-muons @@ -203,7 +203,6 @@ if __name__ == '__main__': fig = plt.figure() plt.errorbar(T, dT['median']*100/T, yerr=dT['median_err']*100/T, color='C0', label="Data") plt.errorbar(T, dT_mc['median']*100/T, yerr=dT_mc['median_err']*100/T, color='C1', label="Monte Carlo") - plt.gca().set_ylim(-500,500) plt.legend() despine(fig,trim=True) plt.xlabel("Kinetic Energy (MeV)") @@ -218,7 +217,6 @@ if __name__ == '__main__': fig = plt.figure() plt.errorbar(T, dT['iqr_std']*100/T, yerr=dT['iqr_std_err']*100/T, color='C0', label="Data") plt.errorbar(T, dT_mc['iqr_std']*100/T, yerr=dT_mc['iqr_std_err']*100/T, color='C1', label="Monte Carlo") - plt.gca().set_ylim(-500,500) despine(fig,trim=True) plt.xlabel("Kinetic Energy (MeV)") plt.ylabel(r"Energy resolution (\%)") diff --git a/utils/sddm/plot_energy.py b/utils/sddm/plot_energy.py index 90c4498..cf59bc6 100755 --- a/utils/sddm/plot_energy.py +++ b/utils/sddm/plot_energy.py @@ -116,10 +116,10 @@ def tag_michels(ev): ev['michel'] &= ev.dc & (DC_JUNK | DC_CRATE_ISOTROPY | DC_QVNHIT | DC_FLASHER | DC_NECK | DC_ESUM | DC_OWL | DC_OWL_TRIGGER | DC_FTS) == 0 ev['michel'] &= ev.nhit >= 100 ev['michel'] &= (time_since_last_prompt_plus_muon > 800) & (time_since_last_prompt_plus_muon < 200e3) - ev.loc[~ev.michel,'muon_gtid'] = -1 - ev.loc[~ev.michel,'muon_nhit'] = -1 - ev['stopping_muon'] = np.zeros(len(ev),dtype=np.bool) - ev.loc[ev.gtid.isin(ev.muon_gtid[ev.muon_gtid > 0].values),'stopping_muon'] = 1 + ev['muon_gtid'] = ev.muon_gtid.where(ev.michel,other=-1) + ev['muon_nhit'] = ev.muon_nhit.where(ev.michel,other=-1) + ev['stopping_muon'] = np.ones(len(ev),dtype=np.bool) + ev['stopping_muon'] = ev.stopping_muon.where(ev.gtid.isin(ev.muon_gtid[ev.muon_gtid > 0].values),other=False) return ev def atmospheric_events(ev): -- cgit