Пример #1
0
def peak_fit(x, y):  # x as etaprime mass and y as pi0mass

    g = cf.gauss_fit()
    g.A.set(A_fit.signal_bt_bkg(y))
    g.x0.set(px0.poly(y))
    g.sigma.set(pS.poly(y))
    Y = g.gauss(x)
    return Y
Пример #2
0
def bkg_fit(x, y):  # x as etaprime mass and y as pi0mass

    f = cf.gauss_fit()
    f.b0.set(pB0.poly(y))
    f.db0.set(0.50)
    f.c0.set(pC0.poly(y))
    Y = f.bt_bkg(x)
    return Y
Пример #3
0
def bkg_fit(x, y):  # x as etaprime mass and y as pi0mass

    f = cf.gauss_fit()
    f.b0.set(pB0.poly(y))
    f.db0.set(0.5)  #  this should match f db0 value not A_fit db0 value
    f.m0.set(0.87)
    f.m1.set(1.05)
    f.c0.set(pC0.poly(y))
    Y = f.bt_bkg(x)
    return Y
Пример #4
0
def fit_histo(h2d):
    #define empty lists for parameters and their errors from  fits

    A_a, x0_a, sigma_a, c0_a, b0_a = [], [], [], [], []

    for i in range(h2d.nbins_y):  # looping over pi0mass bins
        h = h2d.project_x(bins=[i])
        M = h.bin_center
        C = h.bin_content
        dC = h.bin_error
        mr = np.linspace(M[0], M[-1], 1000)
        f = cf.gauss_fit()

        # set initial parameters for fitting
        f.A.set(C.max())
        f.x0.set(0.956)
        f.sigma.set(0.01)
        f.b0.set(0.05)
        f.db0.set(0.5)
        f.c0.set(500)

        # set bounds for the fit parameters
        f.A_min.set(0.)
        f.A_max.set(1e5)
        f.x0_min.set(0.95)
        f.x0_max.set(0.96)
        f.sigma_min.set(0.008)
        f.sigma_max.set(0.016)
        f.c0_min.set(0.)
        f.c0_max.set(1e5)
        f.b0_min.set(0.00)
        f.b0_max.set(0.20)

        f.set_fit_list(fit=['A', 'x0', 'sigma', 'c0', 'b0'])
        f.fit_gaussbt(M, C, dC)  # gauss peak with bernstein bkg
        A_a.append([f.A.value, f.A.err])
        x0_a.append([f.x0.value, f.x0.err])
        sigma_a.append([f.sigma.value, f.sigma.err])
        b0_a.append([f.b0.value, f.b0.err])
        c0_a.append([f.c0.value, f.c0.err])
        plt.figure()
        h.plot_exp()
        f.plot_fit()
        B.plot_line(mr, f.gauss(mr))
        B.plot_line(mr, f.bt_bkg(mr))

    return np.array(A_a), np.array(x0_a), np.array(sigma_a), np.array(
        b0_a), np.array(c0_a)
Пример #5
0
#%%
A_a, x0_a, S_a, B0_a, C0_a = fit_histo(h_epi0)

#%%
A_value = A_a[:, 0]
A_err = A_a[:, 1]
x0_value = x0_a[:, 0]
x0_err = x0_a[:, 1]
S_value = S_a[:, 0]
S_err = S_a[:, 1]
B0_value = B0_a[:, 0]
B0_err = B0_a[:, 1]
C0_value = C0_a[:, 0]
C0_err = C0_a[:, 1]

A_fit = cf.gauss_fit()
A_fit.set_fit_list(fit=['A', 'x0', 'sigma', 'c0', 'b0'])

# set parameters for combined gaussian linear fit
A_fit.A.set(A_value.max())
A_fit.x0.set(0.1365)
A_fit.sigma.set(0.004)
A_fit.b0.set(0.8)
A_fit.db0.set(0.1)
A_fit.c0.set(50.)

#set bounds for  combined gaussian linear fit
A_fit.A_min.set(100.)
A_fit.A_max.set(3000.)
A_fit.x0_min.set(0.13)
A_fit.x0_max.set(0.14)
Пример #6
0
cost_etap = d['cost_etap']
etaprimephiGJ = d['etaprimephiGJ']
#%%

mep_bins = 18
mep_min = 0.86
mep_max = 1.05
h = B.histo( metap,  bins = mep_bins,
                   range = [mep_min, mep_max] , title = 'etaprime', xlabel = "$M(\pi^{+}\pi^{-}\eta)$",
                   )
                                  
M = h.bin_center
C = h.bin_content
dC = h.bin_error
mr = np.linspace(M[0], M[-1], 1000)
f = cf.gauss_fit()

# set initial parameters for fitting
f.A.set(C.max()) 
f.x0.set(0.956)
f.sigma.set(0.01)
f.b0.set(0.05)
f.db0.set(0.5)
f.c0.set(500)

# set bounds for the fit parameters
f.A_min.set(0.); f.A_max.set(1e5)
f.x0_min.set(0.95); f.x0_max.set(0.96)
f.sigma_min.set(0.008); f.sigma_max.set(0.016)
f.c0_min.set(0.); f.c0_max.set(1e5)
f.b0_min.set(0.00); f.b0_max.set(0.20)