Skip to content

Commit

Permalink
peakfit: improve numerical convolution treatment
Browse files Browse the repository at this point in the history
  • Loading branch information
mieskolainen committed Nov 7, 2024
1 parent e6aa007 commit ae99903
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 17 deletions.
14 changes: 7 additions & 7 deletions configs/peakfit/tune0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
input_path: './actions-stash/input/icefit/dqcd_2018_test/flat/muon/generalTracks/JPsi'
output_name: 'tune0'

years: [2018] #[2016, 2017, 2018]
fitrange: [2.91, 3.29] # Nominal fit window (GeV)
years: [2018] # [2016, 2017, 2018]
fitrange: [2.91, 3.29] # Nominal fit window (GeV)
systematics: ['Nominal'] # ['Nominal', 'nVertices_Up', 'nVertices_Down']

# List of systematic variations active
variations: ['DEFAULT'] #, 'SYMMETRIC-SIGNAL_CB_asym_RBW', 'MASS-WINDOW-DOWN', 'MASS-WINDOW-UP']
variations: ['DEFAULT'] #, 'SYMMETRIC-SIGNAL_CB_asym_RBW', 'MASS-WINDOW-DOWN', 'MASS-WINDOW-UP']

num_cpus: 0 # put 0 for automatic, set manually to 1 if problems (ray not used with 1)

Expand All @@ -30,9 +30,9 @@ fit:
func: 'generic_conv_pdf'
args:
norm: True
Nmin: 256 # minimum number of function samples for convolution integral
xfactor: 0.2 # extra domain extension factor for convolution integral (0.2 gives 20%)

Nmin: 128 # minimum number of function samples for convolution integral
xfactor: 0.3 # extra domain extension factor for convolution integral (0.2 gives +-20%)
pdf_pair: ['CB_pdf', 'asym_RBW_pdf'] # name of pdfs to be convoluted
par_index: [[0,1,2,3], [0,4,5]] # parameter indices per pdf (use same index for shared parameters)

Expand Down Expand Up @@ -130,5 +130,5 @@ techno:
tol: 0.1 # Default 0.1, https://iminuit.readthedocs.io/en/stable/reference.html#iminuit.Minuit.tol

cov_eps: 0.0 # Covariance matrix post-regularization (added to diagonal) (set to 0 for none, can bias!)

draw_mnmatrix: False # Draw MINOS profile likelihood scan 2D contours (very slow)
8 changes: 4 additions & 4 deletions configs/peakfit/tune2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
input_path: './actions-stash/input/icefit/dqcd_2018_test/flat/muon/generalTracks/JPsi'
output_name: 'tune2'

years: [2018] #[2016, 2017, 2018]
fitrange: [2.91, 3.29] # Nominal fit window (GeV)
years: [2018] # [2016, 2017, 2018]
fitrange: [2.91, 3.29] # Nominal fit window (GeV)
systematics: ['Nominal'] # ['Nominal', 'nVertices_Up', 'nVertices_Down']

# List of systematic variations active
variations: ['DEFAULT'] #, 'MASS-WINDOW-DOWN', 'MASS-WINDOW-UP']
variations: ['DEFAULT'] #, 'MASS-WINDOW-DOWN', 'MASS-WINDOW-UP']

num_cpus: 0 # put 0 for automatic, set manually to 1 if problems (ray not used with 1)

Expand Down Expand Up @@ -121,5 +121,5 @@ techno:
tol: 0.1 # Default 0.1, https://iminuit.readthedocs.io/en/stable/reference.html#iminuit.Minuit.tol

cov_eps: 0.0 # Covariance matrix post-regularization (added to diagonal) (set to 0 for none, can bias!)

draw_mnmatrix: False # Draw MINOS profile likelihood scan 2D contours (very slow)
12 changes: 7 additions & 5 deletions icefit/icepeak.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,9 @@ def generic_conv_pdf(x: np.ndarray, par: np.ndarray, pdf_pair: List[str],
xp = highres_x(x=x, xfactor=xfactor, Nmin=Nmin)
f0 = func0(x=xp, par=f0_param, norm=False)
f1 = func1(x=xp, par=f1_param, norm=False)
yp = np.convolve(a=f0, v=f1, mode='same')

dx = xp[1] - xp[0]
yp = np.convolve(a=f0, v=f1, mode='same') * dx
y = interpolate.interp1d(xp, yp)(x)

if norm:
Expand All @@ -296,14 +298,14 @@ def generic_conv_pdf(x: np.ndarray, par: np.ndarray, pdf_pair: List[str],
return y

@numba.njit
def highres_x(x: np.ndarray, xfactor: float=0.2, Nmin: int=256):
def highres_x(x: np.ndarray, xfactor: float=0.5, Nmin: int=256):
"""
Extend range and sampling of x.
Args:
x: Array of values.
xfactor: Domain extension factor (default is 0.2).
Nmin: Minimum number of samples (default is 256).
x: Array of values
xfactor: Domain extension factor (e.g. 0.2 gives +- 20%)
Nmin: Minimum number of samples
Returns:
np.ndarray: Extended high-resolution array.
Expand Down
2 changes: 1 addition & 1 deletion icefit/peakfit.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

import ray

__VERSION__ = 0.06
__VERSION__ = 0.07
__AUTHOR__ = '[email protected]'


Expand Down

0 comments on commit ae99903

Please sign in to comment.