Skip to content

Commit

Permalink
Merge pull request #514 from ggmarshall/main
Browse files Browse the repository at this point in the history
A/E and calibration changes
  • Loading branch information
gipert authored Nov 2, 2023
2 parents a721fe1 + 894e60b commit 29cce25
Show file tree
Hide file tree
Showing 7 changed files with 2,936 additions and 2,258 deletions.
16 changes: 16 additions & 0 deletions src/pygama/math/peak_fitting.py
Original file line number Diff line number Diff line change
Expand Up @@ -918,6 +918,8 @@ def get_mu_func(func, pars, cov = None, errors=None):
n_sig, mu, sigma, n_bkg, hstep = pars
elif len(pars) ==7:
n_sig, mu, sigma, n_bkg, hstep, low_range, high_range = pars
elif len(pars) ==8:
n_sig, mu, sigma, n_bkg, hstep, low_range, high_range, components = pars
if errors is not None:
return mu, errors[1]
elif cov is not None:
Expand All @@ -930,6 +932,8 @@ def get_mu_func(func, pars, cov = None, errors=None):
n_sig, mu, sigma, htail, tau, n_bkg, hstep = pars
elif len(pars) ==9:
n_sig, mu, sigma, htail, tau, n_bkg, hstep, low_range, high_range = pars
elif len(pars) ==10:
n_sig, mu, sigma, htail, tau, n_bkg, hstep, low_range, high_range, components = pars
if errors is not None:
return mu, errors[1]
elif cov is not None:
Expand All @@ -948,6 +952,8 @@ def get_fwhm_func(func, pars, cov = None):
n_sig, mu, sigma, n_bkg, hstep = pars
elif len(pars) ==7:
n_sig, mu, sigma, n_bkg, hstep, low_range, high_range = pars
elif len(pars) ==8:
n_sig, mu, sigma, n_bkg, hstep, low_range, high_range, components = pars
if cov is None:
return sigma*2*np.sqrt(2*np.log(2))
else:
Expand All @@ -958,6 +964,12 @@ def get_fwhm_func(func, pars, cov = None):
n_sig, mu, sigma, htail, tau, n_bkg, hstep = pars
elif len(pars) ==9:
n_sig, mu, sigma, htail, tau, n_bkg, hstep, low_range, high_range = pars
if cov is not None:
cov = cov[:7,:][:,:7]
elif len(pars) ==10:
n_sig, mu, sigma, htail, tau, n_bkg, hstep, low_range, high_range, components = pars
if cov is not None:
cov = cov[:7,:][:,:7]

return radford_fwhm(sigma, htail, tau, cov)
else:
Expand All @@ -971,6 +983,8 @@ def get_total_events_func(func, pars, cov = None, errors=None):
n_sig, mu, sigma, n_bkg, hstep = pars
elif len(pars) ==7:
n_sig, mu, sigma, n_bkg, hstep, low_range, high_range = pars
elif len(pars) ==8:
n_sig, mu, sigma, n_bkg, hstep, low_range, high_range, components = pars
if errors is not None:
return n_sig+n_bkg, np.sqrt(errors[0]**2 + errors[3]**2)
elif cov is not None:
Expand All @@ -983,6 +997,8 @@ def get_total_events_func(func, pars, cov = None, errors=None):
n_sig, mu, sigma, htail, tau, n_bkg, hstep = pars
elif len(pars) ==9:
n_sig, mu, sigma, htail, tau, n_bkg, hstep, low_range, high_range = pars
elif len(pars) ==10:
n_sig, mu, sigma, htail, tau, n_bkg, hstep, low_range, high_range, components = pars
if errors is not None:
return n_sig+n_bkg, np.sqrt(errors[0]**2 + errors[5]**2)
elif cov is not None:
Expand Down
Loading

0 comments on commit 29cce25

Please sign in to comment.