aboutsummaryrefslogtreecommitdiff
path: root/utils/sddm
diff options
context:
space:
mode:
Diffstat (limited to 'utils/sddm')
-rwxr-xr-xutils/sddm/plot_energy.py2
-rw-r--r--utils/sddm/stats.py10
2 files changed, 12 insertions, 0 deletions
diff --git a/utils/sddm/plot_energy.py b/utils/sddm/plot_energy.py
index a504d39..90c4498 100755
--- a/utils/sddm/plot_energy.py
+++ b/utils/sddm/plot_energy.py
@@ -111,11 +111,13 @@ def tag_michels(ev):
"""
time_since_last_prompt_plus_muon = ev.gtr - ev.gtr.where(ev.prompt | ((ev.dc & DC_MUON) != 0)).ffill()
ev['muon_gtid'] = ev.gtid.where(ev.prompt | ((ev.dc & DC_MUON) != 0)).ffill()
+ ev['muon_nhit'] = ev.nhit_cal.where(ev.prompt | ((ev.dc & DC_MUON) != 0)).ffill()
ev['michel'] = ~ev.prompt
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
return ev
diff --git a/utils/sddm/stats.py b/utils/sddm/stats.py
new file mode 100644
index 0000000..96ca87a
--- /dev/null
+++ b/utils/sddm/stats.py
@@ -0,0 +1,10 @@
+import numpy as np
+from scipy.stats import gamma, dirichlet
+
+def chi2(samples,expected):
+ return np.sum((samples-expected)**2/expected,axis=-1)
+
+def sample_mc_hist(hist, norm):
+ alpha = np.ones_like(hist) + hist
+ N = gamma.rvs(np.sum(hist)+1e-10,scale=1)
+ return dirichlet.rvs(alpha)[0]*N*norm