Exemplo n.º 1
0
    def init_fitting(self):
        """
        Setup peak fitting parameters and arrays.

        Returns
        -------
        None.

        """
        sig = self.channel_data.par['sig']
        # set values for the peak shape (should have been determined in peak_sampling)
        self.alpha = B.Parameter(1./self.channel_data.par['decay_time'], 'alpha')
        self.beta = B.Parameter(1./self.channel_data.par['rise_time'], 'beta')

        # set boundary values
        self.n_sig_low = self.channel_data.par['n_sig_low']
        self.n_sig_boundary = self.channel_data.par['n_sig_boundary']            
        # determine lower (and upper) edges
        self.dt_l = self.n_sig_low*sig  # in us
        self.dl = int(self.dt_l/self.channel_data.dt) # in channels 
                
        self.boundary = self.n_sig_boundary*sig # boundary reagion in terms of sigma (peak width)
        self.in_boundary = np.zeros_like(self.tp, dtype = 'bool')  # array of logicals indicating if a peak in a boundary region
        
        # number of bkg parameters
        self.bkg_len=self.channel_data.var['bkg_len']
        self.vary_codes_bkg=self.channel_data.var['vary_codes_bkg']
        self.poly_order=self.channel_data.par['poly_order']
        
        return
Exemplo n.º 2
0
def fit_shape(self, ts, Vt):
    # fit function
    # initialize fit function parameters
    alpha = B.Parameter(1. / self.par['decay_time'], 'alpha')
    beta = B.Parameter(1. / self.par['rise_time'], 'beta')
    x0 = B.Parameter(ts[np.argmax(Vt)], 'x0')
    #x0 = B.Parameter(self.par['position'], 'x0')
    H = B.Parameter(1., 'H')
    offset = B.Parameter(0., 'offset')  #self.offset

    # shift peak shape
    def signal(x):
        sig, y = fu.peak(x - x0(), alpha(), beta())
        return y * H() + offset()

    F = B.genfit(signal, [alpha, beta, x0, H, offset], x=ts, y=Vt)

    return F, alpha(), beta(), H(), offset(), x0()
Exemplo n.º 3
0
    def fit_shape(self, ts, Vt):
        """
        Fit standard peak shape to data ts, Vt

        Parameters
        ----------
        ts : numpy array (float)
            times
        Vt : numpy array (float)
            Voltages

        Returns
        -------
        F : genfit opject
            fit results.
        alpha: float
            fit parameter (1/rise_time)
        beta: float
            fit parameter. (1/decay_time)
        H: float
            fit parameter. (signal height)
        offset: float
            fit parameter (constant background)
        x0: float
            fit parameter (peak position)

        """
        alpha = B.Parameter(1. / self.decay_time, 'alpha')
        beta = B.Parameter(1. / self.rise_time, 'beta')
        x0 = B.Parameter(ts[np.argmax(Vt)], 'x0')
        H = B.Parameter(1., 'H')
        offset = B.Parameter(0., 'offset')

        # shift peak shape
        def signal(x):
            sig, y = UT.peak(x - x0(), alpha(), beta())
            return y * H() + offset()

        F = B.genfit(signal, [alpha, beta, x0, H, offset],
                     x=ts,
                     y=Vt,
                     plot_fit=False)

        return F, alpha(), beta(), H(), offset(), x0()
Exemplo n.º 4
0
"""
Created on Thu Apr  8 20:11:52 2021

@author: rupeshdotel
"""

#qfactors with least square fitting

import numpy as np
import matplotlib.pyplot as plt
import LT.box as B
import scipy.spatial as SP

#%%

A = B.Parameter(50., 'A')
x0 = B.Parameter(0.956, 'x0')
sigma = B.Parameter(.005, 'sigma')


def gaus(x):
    return A() * np.exp(-(x - x0())**2 / (2. * sigma()**2))


a0 = B.Parameter(1., 'a0')
a1 = B.Parameter(1., 'a1')


def lin_bkg(x):
    return a0() + a1() * x
Exemplo n.º 5
0
def fit_interval(self, tmin=None, tmax=None, plot=None, save=None):

    sl = fu.get_window_slice(tmin * us, self.td, tmax * us)
    V = self.Vps[sl]
    td = self.td[sl]
    dt = self.dt

    # check that not too many point as requested for plotting
    if len(V) > 1000000:
        print('Too much to plot, will skip plotting.')
        plot = False
    plot_s = False  #do not plot if interval is not specified

    #-------------------------------------
    # setup peak finding
    #-------------------------------------
    Vstep = self.par['Vstep']
    Vth = self.par['Vth']

    sig = self.par['sig']

    if sig == None:
        dtmin = self.par['dtmin']
        n_samp = self.par['n_samp']
        ts = td[0:n_samp] - dtmin
        sig = fu.peak(ts, 1 / self.par['decay_time'],
                      1 / self.par['rise_time'])[0]

    bkg_len = self.var['bkg_len']
    vary_codes_bkg = self.var['vary_codes_bkg']
    poly_order = self.par['poly_order']

    def lish(x):  #''' Vectorize the line shape'''
        return lfitm1.LF.line_shape(x)

    line_shape = np.vectorize(lish)

    # set values for the peak shape (should have been determined in peak_sampling)
    alpha = B.Parameter(1. / self.par['decay_time'], 'alpha')
    beta = B.Parameter(1. / self.par['rise_time'], 'beta')

    # create arrays for peak locations
    results = np.zeros((2, ), dtype='int32')
    pmin = np.zeros((len(V) / 5, ), dtype='int32')
    pmax = np.zeros((len(V) / 5, ), dtype='int32')
    FP.find_peaks(len(V), Vstep, V, results, pmin, pmax)

    ## number of maxima
    n_max = results[1]
    print(" found : ", n_max, " maxima")
    imax = pmax[:n_max]

    ## number of minima
    nmin = results[0]
    print(" found : ", nmin, " minima")
    imin = pmin[:nmin]

    ## get the indices of peaks higher then threshold
    ipeak_tr = np.where(V[imax] > Vth)[0]

    #choose minimums close to previous maximum (to filter out electrical switching noise peaks)
    # reject of time difference < 0.5 us
    close_time = np.where((td[imin][ipeak_tr] - td[imax][ipeak_tr]) < 0.5)[0]

    # check if next minimum is not too negative (removing switching noize)
    neg_V_min = np.where(V[imin][ipeak_tr][close_time] < -0.3)[0]
    ipeak_ok = np.delete(ipeak_tr, close_time[neg_V_min])

    # good peak locations after electrical switching noise filtering
    Vp = V[imax][ipeak_ok]
    tp = td[imax][ipeak_ok]
    imax_fit = imax[ipeak_ok]  #indices of peaks to fit in raw data array

    # loop over the peaks
    Np = Vp.shape[0]
    t_start = time.clock()

    # forming fit groups using peak width to determine boundaries
    n_sig_low = self.par['n_sig_low']
    n_sig_boundary = self.par['n_sig_boundary']
    n_peaks_to_fit = self.par['n_peaks_to_fit']

    #--------------------------------
    # define window edges for fitting
    #--------------------------------

    # lower edge
    dt_l = n_sig_low * sig
    dl = int(dt_l / dt)

    boundary = n_sig_boundary * sig  # boundary reagion in terms of sigma (peak width)
    in_boundary = np.zeros_like(
        tp, dtype='bool'
    )  # array of logicals indicating if a peak in a boundary region

    # determine the fit groups
    fg, fw = fu.get_fit_groups_new(n_peaks_to_fit, imax_fit, 0., td)
    fg_shift, fw = fu.get_fit_groups_new(n_peaks_to_fit, imax_fit, fw / 2., td)
    #if interval is specified for fitting
    if tmin and tmax:

        if (tmin * us >= self.par['dtmin']) and (
                tmax * us <= self.par['dtmax']) and tmin < tmax:
            #find fit groups covering the interval
            inmin = np.where(td[imax_fit] >= tmin * us)[0][
                0]  #index of first peak in fitting interval in time data
            in_max = np.where(
                td[imax_fit] <= tmax * us)[0][-1]  #index of tmax in time data
            gtf = np.empty((0, 2), int)  #list of groups in interval to fit
            gtfs = np.empty((0, 2), int)

            for f in fg:
                if f[0] > in_max and f[1] > in_max:
                    break
                if f[0] > inmin or f[1] > inmin:
                    gtf = np.vstack([gtf, f])
            for f in fg_shift:
                if f[0] > in_max and f[1] > in_max:
                    break
                if f[0] > inmin or f[1] > inmin:
                    gtfs = np.vstack([gtfs, f])

            fg = gtf
            fg_shift = gtfs  #to fit only specified groups
        else:
            print("Interval out of range or incorrect.",
                  self.par['dtmin'] / us, self.par['dtmax'] / us)
            return

    # the number of peaks in each fit group
    fg_n_peaks = fg[:, 1] - fg[:, 0] + 1
    fg_shift_n_peaks = fg_shift[:, 1] - fg_shift[:, 0] + 1

    # loop over fit groups and define peaks in the boundary area
    # arrays for storing fit results
    A_fit = np.zeros_like(tp)
    sig_A_fit = np.zeros_like(tp)

    # bkg fit parameters
    bkg_par = np.zeros(shape=(len(tp), bkg_len))

    #-------------------------------------
    # loop over fit groups for fitting
    #-------------------------------------
    N_fitted = 0
    lims = []

    ifailed = 0
    # setup plotting if desired
    if plot:
        B.pl.xlabel('t(us)')
        B.pl.ylabel('V')
        B.pl.title('Not shifted fitting groups')
    # do the fitting
    for i, ff in enumerate(fg[:]):
        # print information on the current status of fitting
        N_fitted += fg_n_peaks[i]
        if (i % 10 == 0) & (i != 0):
            t_current = time.clock()
            a_rate = 0.
            t_diff = (t_current - t_start)
            if (t_diff != 0.):
                a_rate = float(N_fitted) / t_diff
            print("Fit ", i,
                  float(N_fitted) / Np * 100., "% completed, time ", t_current,
                  ' rate =', a_rate)
        # form a slice for the current peaks
        sl = slice(ff[0], ff[1] + 1)
        # times for the peaks
        tp_fit = tp[sl]
        # amplitudes for the peaks
        Vp_fit = Vp[sl]
        # array indices into full data arrays for the peaks
        ipos_fit = imax_fit[sl]
        # first peak to be fitted is at 0.
        tpk = tp_fit[0]
        # get full range data for fitting
        # index of peak into the data array
        first_peak_ind = ipos_fit[0]
        last_peak_ind = ipos_fit[-1]
        # slice for data range for fitting into the full array, extended by the number of sigmas selected
        i_start_data = max(0, first_peak_ind - dl)
        i_stop_data = min(last_peak_ind + dl, td.shape[0])
        it_fit = slice(i_start_data, i_stop_data)
        # find which peaks are in a boundary area
        if (it_fit.start == it_fit.stop):
            # nothing to fit continue
            continue
        start_fit_time = td[it_fit][0]
        end_fit_time = td[it_fit][-1]
        lims.append([start_fit_time, end_fit_time, tpk, it_fit])
        # determine of the peaks are in a boundar region
        in_boundary[sl] = ((tp_fit - start_fit_time) < boundary) | (
            (end_fit_time - tp_fit) < boundary)
        # place first peak at 0
        tt = td[it_fit] - tpk
        Vt = V[it_fit]
        # initialize fortran fit
        t_peaks = tp_fit - tp_fit[0]
        n_peaks = Vp_fit.shape[0]
        # initialize vary codes array
        vc = np.array(vary_codes_bkg + [1 for v in Vp_fit])
        # initalize fit
        lfitm1.LF.init_all(alpha(), beta(), t_peaks, n_peaks, poly_order, vc)
        # do the fit
        chisq = lfitm1.LF.peak_fit(tt, Vt, np.ones_like(Vt), Vt.shape[0])
        if (chisq < 0.):
            # failed fit
            print(' fit ', i, 'failed, chisq = ', chisq)
            ifailed += 1
            lfitm1.LF.free_all()
            continue

        if plot and len(tt) != 0:
            B.pl.plot(tt + tpk, Vt, '.', color='b')
            B.pl.plot(tt + tpk, line_shape(tt), color='m')

        # get the amplitudes the first bkg_len parameters are the bkg.
        fitted_A = np.copy(lfitm1.LF.a[bkg_len:])
        # get background parameters
        bkg = np.copy(lfitm1.LF.a[:bkg_len])
        # get covariance matrix
        cov = np.copy(lfitm1.LF.covar)
        # calculate the error of the amplitudes
        sig_fitted_A = np.sqrt(cov.diagonal()[bkg_len:] * chisq)
        # get the relevant fit parameters
        if (chisq > 0.):
            # its_shift.append((tp_fit, sl, Vp_fit, chisq, np.copy(LF.a), np.copy(LF.covar)))
            # same the values
            A_fit[sl] = fitted_A
            sig_A_fit[sl] = sig_fitted_A
            bkg_par[sl] = bkg
        # free the arrays
        lfitm1.LF.free_all()

    print(ifailed, ' fits failed out of', i)

    #--------------------------------
    # get second pass for boundary fit
    #--------------------------------

    # loop over the peaks
    lims_s = []
    t_start = time.clock()

    N_fitted = 0

    # arrays for storing fit results
    A_fit_s = np.zeros_like(tp)
    sig_A_fit_s = np.zeros_like(tp)

    # fit parameters
    bkg_par_s = np.zeros(shape=(len(tp), bkg_len))

    print('new start time: ', t_start)
    # fit shifted set

    ifailed1 = 0
    for i, ff in enumerate(fg_shift[:]):
        N_fitted += fg_shift_n_peaks[i]
        if (i % 10 == 0) & (i != 0):
            t_current = time.clock()
            a_rate = 0.
            t_diff = (t_current - t_start)
            if (t_diff != 0.):
                a_rate = float(N_fitted) / t_diff
            print("Fit ", i,
                  float(N_fitted) / Np * 100., "% completed, time ", t_current,
                  ' rate =', a_rate)
        # form a slice for the current peaks
        sl = slice(ff[0], ff[1] + 1)
        # times for the peaks
        tp_fit = tp[sl]
        # amplitudes for the peaks
        Vp_fit = Vp[sl]
        # array indices into full data arrays for the peaks
        ipos_fit = imax_fit[sl]
        # first peak to be fitted is at 0.
        tpk = tp_fit[0]
        # get full range data for fitting
        # index of peak into the data array
        first_peak_ind = ipos_fit[0]
        last_peak_ind = ipos_fit[-1]
        # slice for data range for fitting into the full array
        i_start_data = max(0, first_peak_ind - dl)
        i_stop_data = min(last_peak_ind + dl, td.shape[0])
        it_fit = slice(i_start_data, i_stop_data)
        # find which peaks are in a boundary area
        if (it_fit.start == it_fit.stop):
            # nothing to fit continue
            continue
        start_fit_time = td[it_fit][0]
        end_fit_time = td[it_fit][-1]
        lims_s.append([start_fit_time, end_fit_time, tpk, it_fit])
        # place first peak at 0
        tt = td[it_fit] - tpk
        Vt = V[it_fit]
        # initialize fortran fit
        t_peaks = tp_fit - tp_fit[0]
        n_peaks = Vp_fit.shape[0]
        # initialize vary codes array
        vc = np.array(vary_codes_bkg + [1 for v in Vp_fit])
        # initalize fit
        lfitm1.LF.init_all(alpha(), beta(), t_peaks, n_peaks, poly_order, vc)
        # do the fit
        chisq = lfitm1.LF.peak_fit(tt, Vt, np.ones_like(Vt), Vt.shape[0])
        if (chisq < 0.):
            # failed fit
            print(' fit ', i, 'failed, chisq = ', chisq)
            ifailed1 += 1
            lfitm1.LF.free_all()
            continue

        # plot result if interval specified
        if plot_s:
            B.pl.figure()
            if len(tt) != 0:
                B.pl.plot(tt + tpk, Vt, '.', color='b')
                B.pl.plot(tt + tpk, line_shape(tt), color='m')
            B.pl.title('Shifted fitting groups')
        # save the parameters
        # get the amplitudes the first 3 parameters are the bkg.
        fitted_A = np.copy(lfitm1.LF.a[bkg_len:])
        # get background parameters
        bkg = np.copy(lfitm1.LF.a[:bkg_len])
        # get covariance matrix
        cov = np.copy(lfitm1.LF.covar)
        # calculate the error of the amplitudes
        sig_fitted_A = np.sqrt(cov.diagonal()[bkg_len:] * chisq)
        # get the relevant fit parameters
        if (chisq > 0.):
            # its_shift.append((tp_fit, sl, Vp_fit, chisq, np.copy(LF.a), np.copy(LF.covar)))
            # same the values
            A_fit_s[sl] = fitted_A
            sig_A_fit_s[sl] = sig_fitted_A
            bkg_par_s[sl] = bkg
        # free the arrays
        lfitm1.LF.free_all()

    print(ifailed1, ' fits failed out of', i)

    #--------------------------------
    # copy results of those peaks that are in the boundaryregion from the 2nd fit
    # in_boundary is try for all peaks that lie in a boundary region
    # need to get the fit results from the shifted fit for those peaks e.g. for the indices
    #--------------------------------

    A_fit[in_boundary] = A_fit_s[in_boundary]
    sig_A_fit[in_boundary] = sig_A_fit_s[in_boundary]
    bkg_par[in_boundary] = bkg_par_s[in_boundary]

    #---------------------------------------------
    # save the data as numpy compressed data files
    #---------------------------------------------
    if not save:
        print('no results saved!')
    else:
        # save the fitted data
        o_file = self.var['res_dir'] + "fit_results_" + str(
            self.par['shot']) + "_{0:5.3f}_{1:5.3f}_{2:d}.npz".format(
                tmin, tmax, self.par['channel'])
        if not os.path.exists(os.path.dirname(o_file)):
            os.makedirs(os.path.dirname(o_file))
        if os.path.isfile(o_file):
            o_file = self.var['res_dir'] + "fit_results_" + str(
                self.par['shot']) + "_{0:5.3f}_{1:5.3f}_{2:d}".format(
                    tmin, tmax, self.par['channel']) + time.strftime(
                        '%d_%m_%Y_%H_%M_%S') + ".npz"
        n_lines = tp.shape[0]
        np.savez_compressed(o_file,
                            t=tp,
                            V=Vp,
                            A=A_fit,
                            sig_A=sig_A_fit,
                            bkg=bkg_par)
        print("Wrote : ", n_lines, " lines to the output file")
Exemplo n.º 6
0
    alpha = 2.e5
    lam = 10.
    A1 = 0.1
    #    alpha = B.Parameter(cd.get_value('alpha') , 'alpha')
    #    lam   = B.Parameter(cd.get_value('lam') , 'lam')
    #    A1    = B.Parameter(cd.get_value('A1') , 'A1')
    use_all_variables = True
    Em_func = Em_pow_mod
    Em_func_der = Em_pow_mod_der
    print('initial parameters :', alpha(), lam(), A1())
    current_fit_par = [alpha, lam, A1]

elif model == 'pow_mods':
    # modulated power law sine

    alpha = B.Parameter(cd.get_value('alpha'), 'alpha')
    lam = B.Parameter(cd.get_value('lam'), 'lam')
    A1 = B.Parameter(cd.get_value('A1'), 'A1')
    use_all_variables = True
    Em_func = Em_pow_mods
    Em_func_der = Em_pow_mods_der
    print('initial parameters :', alpha(), lam(), A1())
    current_fit_par = [alpha, lam, A1]

elif model == 'simple_gauss':
    A = B.Parameter(0.1, 'A')
    pos = B.Parameter(1.2, 'r0')
    sig = B.Parameter(0.5, 'sig')
    #A = B.Parameter(cd.get_value('A') , 'A')
    #pos   = B.Parameter(cd.get_value('r0') ,'r0')
    #sig    = B.Parameter(cd.get_value('sig') ,'sig')
Exemplo n.º 7
0
#orbit_dir = './nml_orb_p8_upper_position_high_B/'
orbit_dir = './nml_orb_p8_lower_position_high_B/'

#orbit_dir = './nml_orb_p7_lower_position_high_B/'
#orbit_dir = './nml_orb_p7_bundle_lower_position_high_B/'

#orbit_dir = './nml_orb_p7_mid_position_high_B/'

#orbit_dir = './nml_orb_p6_lower_position/'
#orbit_dir = './orb_ppro_5/'
#orbit_dir = './orb_ppro_8/'
# orbit_dir = './orb_ppro_6/'

# fit parameters

A = B.Parameter(1.16704568137)
r0 = B.Parameter(1.06498326579)
sig_r = B.Parameter(0.116676453845)
z0 = B.Parameter(0.0653756066516)
sig_z = B.Parameter(0.191893739805)

orbit_output = open(orbit_dir + '/orbit_output').readlines()
# find the EQ file used:
eq_file = 'generic'
for d in orbit_output:
    if (d.find('--> EQ File unit, name') >= 0.):
        eq_file = d.split()[-1:][0]

# flux
print 'reading flux data'
fl = gf.flux(orbit_dir + 'flux.data')
Exemplo n.º 8
0
# get the bin width
#dM = d.par.get_value('dx')

# get the histogram data
#M = d['xb']
#C = d['cont']
#dC = d['dcont']
#dC = np.sqrt(C)

# plot the data

B.plot_exp(M, C, dC)

# setup
# simple gaussian
A = B.Parameter(C.max(), 'A')
#x0 = B.Parameter(0.135, 'x0')
#x0 = B.Parameter(0.135, 'x0')
x0 = B.Parameter(0.956, 'x0')
#x01 = B.Parameter(0.545, 'x01')
sig = B.Parameter(.005, 'sigma')


def gaus(x):
    return A() * np.exp(-(x - x0())**2 / (2. * sig()**2))


# second gauss for a doublegauss
D = B.Parameter(100., 'D')
sig1 = B.Parameter(.005, 'sigma1')
Exemplo n.º 9
0
    def __init__(self,
                 A_min=10.,
                 A=10000.,
                 A_max=1e9,
                 x0_min=0.94,
                 x0=0.956,
                 x0_max=0.98,
                 sigma_min=0.005,
                 sigma=0.01,
                 sigma_max=0.30,
                 c0_min=10,
                 c0=1e4,
                 c0_max=5e4,
                 b0_min=10,
                 b0=0.14,
                 b0_max=0.20,
                 db0=0.50,
                 k0_min=10,
                 k0=100.,
                 k0_max=500.,
                 k1_min=10,
                 k1=100.,
                 k1_max=500.,
                 m0=0.86,
                 m1=1.05):
        # peak parameters
        self.A_min = B.Parameter(A_min, 'A_min')
        self.A = B.Parameter(A, 'A')
        self.A_max = B.Parameter(A_max, 'A_max')

        self.x0_min = B.Parameter(x0_min, 'x0_min')
        self.x0 = B.Parameter(x0, 'x0')
        self.x0_max = B.Parameter(x0_max, 'x0_max')

        self.sigma_min = B.Parameter(sigma_min, 'sigma_min')
        self.sigma = B.Parameter(sigma, 'sigma')
        self.sigma_max = B.Parameter(sigma_max, 'sigma_max')

        # back ground parameters

        self.c0_min = B.Parameter(c0_min, 'c0_min')
        self.c0 = B.Parameter(c0, 'c0')
        self.c0_max = B.Parameter(c0_max, 'c0_max')

        self.b0_min = B.Parameter(b0_min, 'b0_min')
        self.b0 = B.Parameter(b0, 'b0')
        self.b0_max = B.Parameter(b0_max, 'b0_max')

        self.db0 = B.Parameter(db0, 'db0')

        self.k0_min = B.Parameter(k0_min, 'k0_min')
        self.k0 = B.Parameter(k0, 'k0')
        self.k0_max = B.Parameter(k0_max, 'k0_max')

        self.k1_min = B.Parameter(k1_min, 'k1_min')
        self.k1 = B.Parameter(k1, 'k1')
        self.k1_max = B.Parameter(k1_max, 'k1_max')

        self.m0 = B.Parameter(m0, 'm0')
        self.m1 = B.Parameter(m1, 'm1')

        #self.b1 = B.Parameter(b1, 'b1')
        # fit list, which parameters are to be varied
        self.fit_par = {
        "A" : self.A,
        "x0" : self.x0, \
        "sigma":  self.sigma, \
        "c0" : self.c0, \
        "b0" : self.b0, \
        "k0" : self.k0, \
        "k1" : self.k1 }

        self.set_fit_list()
        self.fit_list = [
            self.A, self.x0, self.sigma, self.c0, self.b0, self.k0, self.k1
        ]
Exemplo n.º 10
0
model = 'pow'
model = 'zer'
model = 'pow_mod'
model = 'zer2d'

model = 'pol'
model = 'cheb'
model = 'two_gauss'

use_data_set = '2gauss'
use_data_set = 'p8'

if model == 'pow':
    # simple power law
    lam = B.Parameter(11., 'lam')
    alpha = B.Parameter(1., 'alpha')
    Em_func = Em_pow
    Em_func_der = Em_pow_der
    current_fit_par = [alpha, lam]
    print('initial parameters :', alpha, '\n', lam, '\n')
elif model == 'pol':
    # polynomial
    p0 = B.Parameter(.0)
    p1 = B.Parameter(0.1)
    p2 = B.Parameter(0.1)
    p3 = B.Parameter(1)
    #    p4 = B.Parameter(.1)
    #    p5 = B.Parameter(.1)
    #    Em_func = Em_pol
    #    Em_func_der = Em_pol_der
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Mar 23 16:44:29 2021

@author: rupeshdotel
"""

import numpy as np
import LT.box as B
import matplotlib.pyplot as plt
#%%

A = B.Parameter(500., 'A')
x0 = B.Parameter(0.956, 'x0')
sig = B.Parameter(.005, 'sigma')


def gaus(x):
    return A() * np.exp(-(x - x0())**2 / (2. * sig()**2))


a0 = B.Parameter(1., 'a0')
a1 = B.Parameter(1., 'a1')


def lin_bkg(x):
    return a0() + a1() * x


def signal(x):
Exemplo n.º 12
0
use_all_variables = False

model = 'zer'
model = 'cheb'
model = 'pol'
model = 'pow'
model = 'two_gauss'
model = 'pow_mod'

model = 'pow'

use_data_set = 'p7'

if model == 'pow':
    # simple power law
    lam = B.Parameter(11., 'lam')
    alpha = B.Parameter(1., 'alpha')
    Em_func = Em_pow
    Em_func_der = Em_pow_der
    print('initial parameters :', alpha, '\n', lam, '\n')
    current_fit_par = [alpha, lam]
elif model == 'pol':
    # polynomial
    p0 = B.Parameter(.0)
    p1 = B.Parameter(0.1)
    p2 = B.Parameter(0.1)
    p3 = B.Parameter(1)
    #    p4 = B.Parameter(.1)
    #    p5 = B.Parameter(.1)
    #    Em_func = Em_pol
    #    Em_func_der = Em_pol_der
Exemplo n.º 13
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Sep 26 12:40:43 2020

@author: rupeshdotel
"""
from mpl_toolkits import mplot3d
import numpy as np
import LT.box as B
import matplotlib.pyplot as plt

#%%

Ae = B.Parameter(2500., 'Ae')
x0e = B.Parameter(0.956, 'x0e')
se = B.Parameter(.01, 'se')

alpha = B.Parameter(10000., 'alpha')
beta = B.Parameter(10000., 'beta')
gamma = B.Parameter(10., 'gamma')
delta = B.Parameter(1., 'delta')
'''#S17
Ae = B.Parameter(150., 'Ae')
x0e = B.Parameter(0.956, 'x0e')
se = B.Parameter(.01, 'se')
alpha = B.Parameter(50., 'alpha')
beta = B.Parameter(100., 'beta')
gamma = B.Parameter(10., 'gamma')
delta = B.Parameter(1., 'delta')'''
Exemplo n.º 14
0
@author: rupeshdotel
"""

#qfactors with least square fitting

import numpy as np
import matplotlib.pyplot as plt
import LT.box as B
import scipy.spatial as SP
from root_numpy import array2tree, array2root, tree2array
import ROOT as R
from root_numpy import tree2array

#%%

A = B.Parameter(50., 'A')
x0 = B.Parameter(0.956, 'x0')
sigma = B.Parameter(.005, 'sigma')


def gaus(x):
    return A() * np.exp(-(x - x0())**2 / (2. * sigma()**2))


a0 = B.Parameter(1., 'a0')
a1 = B.Parameter(1., 'a1')


def lin_bkg(x):
    return a0() + a1() * x
Exemplo n.º 15
0
    qs = s/t
    qb = 1 - qs
    return qs, qb



qse, qbe = qeta_bkg(meta[sel])

hse = B.histo(meta[sel], bins = 40, weights = qs_sel*qse, title = '$\eta$', xlabel = 'M($\gamma\gamma$)')
plt.figure();he.plot_exp(); hse.plot_exp();  he_ws2d.plot_exp() #

#%%

hep = B.histo(metap[sel], bins = 30, title = "$\eta^{'}$" , xlabel = "$M(\pi^{+}\pi^{-}\eta)$")

A = B.Parameter(17500., 'A') #gluexI
#A = B.Parameter(2500., 'A')
x0 = B.Parameter(0.955, 'x0')
s = B.Parameter(.01, 's')



def gaus_peak(x):
    return A() * np.exp(-(x - x0())**2/(2.*s()**2))


alpha = B.Parameter(3000., 'alpha')
beta = B.Parameter(3000., 'beta')
gamma = B.Parameter(10., 'gamma')
delta = B.Parameter(1., 'delta')