46 def electron_toy_recoeff(matchos_peak, matchos_tail, matchss_tail, nomatchos_peak, nomatchos_tail, templateos_peak, templateos_tail, templatess_tail, ntoys=1000):
47 matchos_peak = np.random.poisson(matchos_peak, ntoys)
48 matchos_tail = np.random.poisson(matchos_tail, ntoys)
49 matchss_tail = np.random.poisson(matchss_tail, ntoys)
50 nomatchos_peak = np.random.poisson(nomatchos_peak, ntoys)
51 nomatchos_tail = np.random.poisson(nomatchos_tail, ntoys)
53 templateos_peak = np.random.poisson(templateos_peak, ntoys)
54 templateos_tail = np.random.poisson(templateos_tail, ntoys)
55 templatess_tail = np.random.poisson(templatess_tail, ntoys)
57 totalos_peak = matchos_peak + nomatchos_peak
58 totalos_tail = matchos_tail + nomatchos_tail
61 n2 = np.multiply(templateos_peak,
nan_divide(matchss_tail, templatess_tail))
63 d2 = np.multiply(templateos_peak,
nan_divide(nomatchos_tail, templateos_tail))
64 iterative_eff =
nan_divide((n1 - n2), (d1 - d2))
66 d2 = np.multiply(templateos_peak,
nan_divide((totalos_tail -
nan_divide(matchos_tail, iterative_eff)), templateos_tail))
68 nonan_eff = eff[~np.isnan(eff)]
69 if nonan_eff.size > 0:
70 out_eff = np.median(nonan_eff)
71 out_err = nonan_eff.std()
76 return out_eff, out_err, eff