aboutsummaryrefslogtreecommitdiff
path: root/utils/chi2
diff options
context:
space:
mode:
Diffstat (limited to 'utils/chi2')
-rwxr-xr-xutils/chi212
1 files changed, 8 insertions, 4 deletions
diff --git a/utils/chi2 b/utils/chi2
index 67ed743..e09d8d5 100755
--- a/utils/chi2
+++ b/utils/chi2
@@ -112,7 +112,7 @@ def get_mc_hists_fast(ke_dict,x,bins,apply_norm=False):
mc_hists = {}
# FIXME: May need to increase number of bins here
- bins2 = np.logspace(np.log10(20),np.log10(10e3),1000)
+ bins2 = np.logspace(np.log10(20),np.log10(10e3),100)
bincenters2 = (bins2[1:] + bins2[:-1])/2
for id in (20,22,2020,2022,2222):
@@ -236,7 +236,7 @@ def make_nll(data, muons, mc, bins):
return nll
return nll
-def get_mc_hists_posterior(data,muon_hists,data_hists,x,bins):
+def get_mc_hists_posterior(ke_dict,muon_hists,data_hists,x,bins):
"""
Returns the posterior on the Monte Carlo histograms.
@@ -260,7 +260,7 @@ def get_mc_hists_posterior(data,muon_hists,data_hists,x,bins):
Returns a dictionary mapping particle id combo -> histogram.
"""
- mc_hists = get_mc_hists(data,x,bins)
+ mc_hists = get_mc_hists_fast(ke_dict,x,bins)
for id in (20,22,2020,2022,2222):
mc_hists[id] = get_mc_hist_posterior(mc_hists[id],data_hists[id],norm=x[0])
# FIXME: does the orering of when we add the muons matter here?
@@ -290,10 +290,14 @@ def get_multinomial_prob(data, data_muon, data_mc, id, x_samples, bins, percenti
data_hists = get_data_hists(data,bins)
muon_hists = get_data_hists(data_muon,bins)
+ ke_dict = {}
+ for id in (20,22,2020,2022,2222):
+ ke_dict[id] = data_mc[data_mc.id == id].ke.values
+
ps = []
for i in range(size):
x = x_samples[np.random.randint(x_samples.shape[0])]
- mc = get_mc_hists_posterior(data_mc,muon_hists,data_hists,x,bins)[id]
+ mc = get_mc_hists_posterior(ke_dict,muon_hists,data_hists,x,bins)[id]
N = mc.sum()
# Fix a bug in scipy(). See https://github.com/scipy/scipy/issues/8235 (I think).
mc = mc + 1e-10