Exemplo n.º 1
0
def get_1d_root_histo(r_histo):
    # get approriate histogram
    hr = bi.get_histo_data(r_histo)
    # make arrays with the correct shape
    hr.make_arrays()
    # make a histo1d
    hd = B.histo(bin_center=hr.xb, bin_content=hr.cont, bin_error=hr.dcont)
    # transfer the labels and title
    title = r_histo.GetName()
    xl = (r_histo.GetXaxis()).GetTitle()
    hd.xlabel = xl
    hd.title = title
    return hd
Exemplo n.º 2
0
# S0 are the sigma values from the fit
S0 = np.ones_like(M_inv_sel[:])
do_plot = False

#%%
for i, M_inv_loc in enumerate(M_inv_sel[:]):

    # select neghboring events for the current event combine distance of costheta and phi normalized by  pythagorian theorem
    i_near = np.argsort(
        np.sqrt((dcos_theta_etap_gj_m_norm[i]**2 +
                 dphi_etap_gj_m_norm[i]**2)))[:n_near]

    M_inv_neighbor = M_inv_sel[i_near]

    h = B.histo(M_inv_neighbor, bins=22)
    h_sel = h.bin_content > 0
    M = h.bin_center[h_sel]
    C = h.bin_content[h_sel]
    dC = h.bin_error[h_sel]

    A = B.Parameter(C.max(), 'A')
    x0 = B.Parameter(0.956, 'x0')
    sigma = B.Parameter(.005, 'sigma')
    a0 = B.Parameter(1., 'a0')
    a1 = B.Parameter(1., 'a1')

    fit = B.genfit(signal, [A, x0, sigma, a0, a1],
                   x=M,
                   y=C,
                   y_err=dC,
Exemplo n.º 3
0
            else:
                Em_cont = pl.contour(X, Y, Em_mid, v, cmap=colormap)

pl.legend(fontsize=12, loc='upper left')

h_range = (0.6, 1.6)
r0 = []
f2 = pl.figure(2)
for i, PDv in enumerate(PD_views):
    icol = ch[i]
    rr = []
    for v in PDv:
        rr.append(get_zero_crossing(v))
    rr = np.array(rr)
    r = rr.mean()
    h = B.histo(rr, range=h_range, bins=200)
    h.plot(color=colors[icol])
    sig_r = np.sqrt(rr.var())
    r0.append([h, r, sig_r, rr])
# all done
pl.xlabel('R (m)')
pl.ylabel('counts')
pl.title('mid-plane Radius')

# pl.savefig(orbit_dir+'image.png')
pl.show()


def zoom_in(x_lim, y_lim):
    # axes = li.ax1.get_axes()
    axes = li.ax1
Exemplo n.º 4
0
qb_sel = np.abs(bkg_fit(metap, mpi0))
qs_sel = np.abs(peak_fit(metap, mpi0))

q = qs_sel / (qb_sel + qs_sel)
qs = q
qb = 1 - q

#%%

#sel = (mep_min < metap) & (metap < mep_max)
#meta = meta[sel]
#qs_for_eta = qs[sel]
he_ws2d = B.histo(meta,
                  bins=24,
                  weights=qs,
                  title='$\eta$',
                  xlabel='M($\gamma\gamma$)')
he = B.histo(meta, bins=24)
plt.figure()

he_ws2d.show_fit_list()
he_ws2d.set_fit_list(fit=['A', 'mean', 'sigma', 'b0', 'b1', 'b2'])

he_ws2d.fit()
he_ws2d.plot_exp()

he_ws2d.plot_fit()
he_ws2d.title = '$\eta$'
he_ws2d.x_lable = '$M(\gamma\gamma)$'
b0 = he_ws2d.b0.value
Exemplo n.º 5
0
mpipp = d['mpipp']
mpi0p = d['mpi0p']
mpippimpi0 = d['mpippimpi0']

cost_pi0 = d['cost_pi0']
pi0phiGJ = d['pi0phiGJ']

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)
Exemplo n.º 6
0
#d = np.load('/Users/rupeshdotel/analysis/work/pi0pippimeta/data/fitpi0.npz')
#d = np.load('/Users/rupeshdotel/analysis/work/pi0pippimeta/data/qfactor_data/pi0qfactor_0303.npz')

#d = np.load('/Users/rupeshdotel/analysis/work/pi0pippimeta/data/qfactor_data/etapdata.npz')
#mass = d['metap']

#d = np.load('/Users/rupeshdotel/analysis/work/pi0pippimeta/data/qfactor_data/selected_events_18_08_pwa.npz')
d = np.load(
    '/Users/rupeshdotel/analysis/work/pi0pippimeta/data/qfactor_data/cons_17_18_pol_0.npz'
)
mass = d['metap']

#d = np.load('/Users/rupeshdotel/analysis/work/pi0pippimeta/data/qfactor_data/pi0data.npz')
#mass = d['mpi0']

h = B.histo(mass, bins=20, range=[0.85, 1.05])
#%%
#h = B.histo(mass, bins = 20)
M = h.bin_center
C = h.bin_content
dC = h.bin_error
dM = M[1] - M[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)
Exemplo n.º 7
0
h2_ep_cost_ac = B.histo2d(m_etappi0_ac,
                          cost_etap_ac,
                          bins=(bins_metappi0, bins_cost),
                          range=[[metappi0_min, metappi0_max],
                                 [cost_min, cost_max]],
                          title="Angular distribution in GJ Frame")

h2_ep_cost_gen = B.histo2d(m_etappi0_gen,
                           cost_etap_gen,
                           bins=(bins_metappi0, bins_cost),
                           range=[[metappi0_min, metappi0_max],
                                  [cost_min, cost_max]],
                           title="Angular distribution in GJ Frame")
#%%

m_gen = B.histo(m_etappi0_gen, bins=100)
m_ac = B.histo(m_etappi0_ac, bins=100)

m_acceptance = m_ac / m_gen

#%%

cost_etap_gen = B.histo(cost_etap_gen, bins=100)
cost_etap_ac = B.histo(cost_etap_ac, bins=100)

costheta_acceptance = cost_etap_ac / cost_etap_gen

#%%

acceptance_2d = h2_ep_cost_ac / h2_ep_cost_gen
Exemplo n.º 8
0
# script to try out histogramming
import LT.box as B

# get the file
mcf = B.get_file("counts.data")

# see what is in there
mcf.show_keys()

# get some data
ne = B.get_data(mcf, "n")
counts = B.get_data(mcf, "counts")

# make a hisrogram of the values
hh = B.histo(counts, range=(120.0, 180.0), bins=60)

# set the initial values for fitting
hh.A.set(2)
hh.mean.set(140)
hh.sigma.set(10)

# fit the peak
hh.fit()

# plot the histogram
hh.plot()
B.pl.show()

# plot the fit
hh.plot_fit()
B.pl.show()
Exemplo n.º 9
0
#get veto bools
veto_2pi0m = ~ ((pi013m & pi024m) | (pi014m & pi023m)) #choose 2pi0 veto logic
veto_omegam = ~(omegam) #veto omega
veto_deltapm = ~(pi0pm) #veto deltap

#combine veto bools in increasing complexity
#veto = veto_2pi0m & veto_omegam
vetom = veto_2pi0m & veto_omegam & veto_deltapm



selm = sel_winm & vetom
"""
#%%

h_mm2m = B.histo(mm2m, bins=30, title="missing mass squared")

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

h_etap_pi0 = B.histo2d(metap[sel],
                       mpi0[sel],
                       bins=24,
                       title=" pi0 vs etaprime Kinfit variables",
                       xlabel="$M(\pi^{+}\pi^{-}\eta)$",
                       ylabel="$M(\gamma\gamma)$")

h_etappi0 = B.histo(metappi0[sel],
                    bins=40,
Exemplo n.º 10
0
box = []
num = 10000
for ii in range(num):

    x1 = random.random()
    y1 = random.random()
    z1 = np.sqrt(-2 * np.log(x1)) * np.cos(2 * np.pi * y1)

    box.append(z1)
    xbin.append(x1)

mean = np.average(xbin)

SD = np.std(xbin)

graph = B.histo(box, range=(-4, 4), bins=50)
graphx = graph.bin_center
graphy = graph.bin_content

miu = param.Parameter(mean, 'mu')
sigma = param.Parameter(SD, 'sigma')
height = param.Parameter(700., 'height')
factor = len(box) * (8. / 40.)


def gauss(x):

    gaussgraph = stats.norm.pdf((x - miu()) / sigma()) * factor

    return gaussgraph
Exemplo n.º 11
0
    def time_slice_data(self):
        
        # get data
        a_data = analysis_data(self)

        # good data
        tg = a_data.tg
        Ag = a_data.Ag
        
        # all pos. data
        tp = a_data.tp
        Ap = a_data.Ap
        

        # histogram setup
        h_min = self.par['h_min']
        h_max = self.par['h_max']
        h_bins = self.par['h_bins']
        
        h_range = (h_min, h_max)

        #if pulser were added
        add_pulser=self.par['draw_pul']
        # no histo fitting at this time
        fit_histos = False
        


        # time slice the data
        dt = self.par['time_slice_width']*us # step width

        # good slices
        slice_t, slices = slice_array(tg, dt)
        # all slices
        slice_t_a, slices_a = slice_array(tp, dt)
        
        self.slice_t = slice_t
        self.slices = slices
        self.slice_t_a = slice_t_a
        self.slices_a = slices_a
        
        # histogram
        h = []
        hp = []
        h_sum =  B.histo( np.array([]), range = h_range, bins = h_bins)
        hp_sum =  B.histo( np.array([]), range = h_range, bins = h_bins)
        for i,s in enumerate(slices):
            hi = B.histo( Ag[s], range = h_range, bins = h_bins)
            h_time = "{0:6.4f} s".format( slice_t[i]/us )
            hi.title = h_time
            h.append( hi  )
            h_sum += hi

        for i,s in enumerate(slices_a):
            hip = B.histo( Ap[s], range = h_range, bins = h_bins)
            h_time = "{0:6.4f} s".format( slice_t_a[i]/us )
            hip.title = h_time
            hp.append( hip  )
            hp_sum += hip
            
        # store created histograms
        self.h=h
        self.hp=hp
        self.h_tot = h_sum
        self.hp_tot = hp_sum

        print("created ", len(h), " histograms h")

        # calculate rates for protons and tritons
        # proton counts
        A_sp = []
        dA_sp= []
        # triton counts
        A_st = []
        dA_st= []
        # pulser counts
        A_pul = []
        dA_pul = []

        # for protons
        p_min =  self.par['p_min']#cdata.par.get_value('p_min')
        p_max =  self.par['p_max']#cdata.par.get_value('p_max')
        # for tritons
        t_min = self.par['t_min']
        t_max = self.par['t_max']

        # for pulser if selected
        if add_pulser:
            pul_min = self.par['pulser_min']
            pul_max = self.par['pulser_max']

        for i, hi in enumerate(h):
            # proton fit
            # fitting with limits
            if fit_histos:
                pass
                # hi.fit(xmin = p_min, xmax = p_max)
            # sum histograms
            # intgerate proton peak
            sp, dsp = hi.sum(xmin = p_min , xmax = p_max)  
            # integrate triton peaj
            st, dst = hi.sum(xmin = t_min , xmax = t_max)
            # store results
            A_sp.append(sp)
            dA_sp.append(dsp)
            A_st.append(st)
            dA_st.append(dst)
            # integrate pulser
            if add_pulser:
                spul, dspul = hi.sum(xmin = pul_min , xmax = pul_max)
                A_pul.append(spul)
                dA_pul.append(dspul)            

        # proton amplitudes
        self.A_sp = np.array(A_sp)
        self.dA_sp = np.array(dA_sp)
        # tritomn amplitudes
        self.A_st = np.array(A_st)
        self.dA_st = np.array(dA_st)
        # pulser amplitudes
        if add_pulser:
            self.A_pul = np.array(A_pul)
            self.dA_pul = np.array(dA_pul)

        # total
        self.A_t = self.A_sp + self.A_st
        self.dA_t = np.sqrt(self.dA_sp**2 + self.dA_st**2)

        # fitting results
        if fit_histos:
            pass
Exemplo n.º 12
0
    def plot_results(self):

        draw_p = self.par['draw_p']
        draw_t = self.par['draw_t']
        draw_sum = self.par['draw_sum']

        # histogram setup
        h_min = self.par['h_min']
        h_max = self.par['h_max']
        h_bins = self.par['h_bins']
        h_range = (h_min, h_max)

        #if pulser were added
        add_pulser = self.par['add_pulser']
        # no histo fitting at this time
        fit_histos = False
        t_offset = self.par['t_offset']  #cdata.par.get_value('t_offset')*us
        # get directories
        f_name = self.var['f_name']

        # load data (faster loading then from txt)
        d = np.load(f_name)
        tr = d['t'] + t_offset
        Vpr = d['V']  # raw PH
        Ar = d['A']  # fitted PH
        dAr = d['sig_A']
        #        chir = np.zeros_like(tr)

        # positive signals
        pa = Ar > 0.
        r = np.abs(dAr[pa] / Ar[pa])
        # cut on error ratio
        r_cut_off = self.par['sig_ratio']
        # this is for good events
        gr = r < r_cut_off

        # this is to study background
        #gr = r > r_cut_off

        tg = tr[pa][gr]
        A = Ar[pa][gr]
        #        dA = dAr[pa][gr]
        #        chi = chir[pa][gr]

        # simple pulse heights for testing
        ta = tr[pa]
        Ap = Vpr[pa]  # raw data

        # time slice the data
        dt = self.par['time_slice_width'] * us  # step width

        # bin numbers
        i_t = (tg / dt).astype('int')
        i_t_a = (ta / dt).astype('int')
        # time slicing for fitted peaks
        slice_t = []
        slices = []
        i_start = 0
        i_bin = i_t[0]
        for i, ip in enumerate(i_t):
            if ip != i_bin or i == len(i_t) - 1:
                i_end = i
                # print "found slice from : ", i_start, i_end
                slice_t.append(i_bin * dt + 0.5 * dt)
                slices.append(slice(i_start, i_end))
                i_bin = ip
                i_start = i

        # time slicing for all peaks
        slice_t_a = []
        slices_a = []
        i_start_a = 0
        i_bin_a = 0
        for i, ip in enumerate(i_t_a):
            if ip == i_bin_a:
                continue
            else:
                i_end = i
                # print "found slice from : ", i_start, i_end
                slice_t_a.append(i_bin_a * dt + 0.5 * dt)
                slices_a.append(slice(i_start_a, i_end))
                i_bin_a = ip
                i_start_a = i

        # histogram
        h = []
        hp = []

        for i, s in enumerate(slices):
            hi = B.histo(A[s], range=h_range, bins=h_bins)
            h_time = "{0:6.4f} s".format(slice_t[i] / us)
            hi.title = h_time
            h.append(hi)

        for i, s in enumerate(slices_a):
            hip = B.histo(Ap[s], range=h_range, bins=h_bins)
            h_time = "{0:6.4f} s".format(slice_t_a[i] / us)
            hip.title = h_time
            hp.append(hip)

        self.h = h
        self.hp = hp

        print("created ", len(h), " histograms h")

        A_sp = []
        dA_sp = []

        A_st = []
        dA_st = []

        A_pul = []
        dA_pul = []

        # for protons
        p_min = self.par['p_min']  #cdata.par.get_value('p_min')
        p_max = self.par['p_max']  #cdata.par.get_value('p_max')
        # for tritons
        t_min = self.par['t_min']
        t_max = self.par['t_max']
        # fit histograms

        if add_pulser:
            pul_min = self.par['pulser_min']
            pul_max = self.par['pulser_max']

        # inital parameters
        A_init = self.par['A_init']
        sigma_init = self.par['sig_init']

        for i, hi in enumerate(h):
            # proton fit
            # hi.mean.set(p_mean) #check if necessary
            hi.A.set(A_init)
            hi.sigma.set(sigma_init)
            # fitting with limits
            if fit_histos:
                hi.fit(xmin=p_min, xmax=p_max)
            # sum histograms
            sp, dsp = hi.sum(xmin=p_min, xmax=p_max)
            st, dst = hi.sum(xmin=t_min, xmax=t_max)
            spul, dspul = hi.sum(xmin=pul_min, xmax=pul_max)
            A_sp.append(sp)
            dA_sp.append(dsp)
            A_st.append(st)
            dA_st.append(dst)
            A_pul.append(spul)
            dA_pul.append(dspul)
        # proton amplitudes
        A_sp = np.array(A_sp)
        dA_sp = np.array(dA_sp)
        # tritomn amplitudes
        A_st = np.array(A_st)
        dA_st = np.array(dA_st)
        # pulser amplitudes
        A_pul = np.array(A_pul)
        dA_pul = np.array(dA_pul)

        # total
        A_t = A_sp + A_st
        dA_t = np.sqrt(dA_sp**2 + dA_st**2)

        # fitting results
        if fit_histos:
            A_f = []
            dA_f = []
            chi_red = []
            m_f = []
            dm_f = []
            fact = np.sqrt(2. * np.pi)
            for i, hi in enumerate(h):
                bw = hi.bin_width
                sig = np.abs(hi.sigma())
                name, Am, dAm = hi.fit_par['A'].get()
                name, p, dp = hi.fit_par['mean'].get()
                A_f.append(Am * sig * fact / bw)
                dA_f.append(dAm * sig * fact / bw)
                m_f.append(p)
                dm_f.append(dp)
                chi_red.append(hi.F.chi2_red)
            A_f = np.array(A_f)
            dA_f = np.array(dA_f)
            m_f = np.array(m_f)
            dm_f = np.array(dm_f)
            chi_red = np.array(chi_red)

        # proton sum signal
        if draw_p == 'True':
            B.plot_exp(np.array(slice_t) / us,
                       A_sp / dt * us,
                       dA_sp / dt * us,
                       linestyle='-',
                       marker='o',
                       color='b',
                       ecolor='grey',
                       capsize=0.)  #,markeredgecolor='g',

        # triton sum signal
        if draw_t == 'True':
            B.plot_exp(np.array(slice_t) / us,
                       A_st / dt * us,
                       dA_st / dt * us,
                       color='g',
                       ecolor='grey',
                       capsize=0.)

        # pulser sum signal
        if add_pulser == 'True':
            B.plot_exp(np.array(slice_t) / us,
                       A_pul / dt * us,
                       dA_pul / dt * us,
                       color='m',
                       ecolor='grey',
                       capsize=0.)

        # Total signal
        if draw_sum == 'True':
            B.plot_exp(np.array(slice_t) / us,
                       A_t / dt * us,
                       dA_t / dt * us,
                       linestyle='-',
                       ecolor='grey',
                       marker='.',
                       capsize=0.,
                       label='Ch %d' %
                       self.par['channel'])  #color = 'r',ecolor='grey', #

        o_file = self.var['of_name']

        if not os.path.exists(os.path.dirname(o_file)):
            os.makedirs(os.path.dirname(o_file))

        B.pl.xlabel('t [s]')
        B.pl.ylabel('Rate [Hz]')
        B.pl.title('Shot : ' + str(self.par['shot']) + '/ channel: ' +
                   str(self.par['channel']))
        B.pl.xlim((self.par['dtmin'] / us, self.par['dtmax'] / us))
        B.pl.show()
        B.pl.savefig('../Analysis_Results/%d/Rate_Plotting/Rate_%s.png' %
                     (self.par['shot'], self.var['f_name'][-16:-6]))
        # write results

        #        if os.path.isfile(o_file):
        #            inp = raw_input("Do you want to overwrite the results file? (y)es or (n)o: ")
        #            if inp == "yes" or inp == "y":
        #               os.remove(o_file)
        #               print 'Old file removed.'
        #            elif inp == "no" or inp == "n":
        #               return

        np.savez_compressed(o_file,
                            t=np.asarray(slice_t) / us,
                            Ap=np.asarray(A_sp) / dt * us,
                            dAp=np.asarray(dA_sp) / dt * us,
                            At=np.asarray(A_st) / dt * us,
                            dAt=np.asarray(dA_st) / dt * us,
                            A=np.asarray(A_t) / dt * us,
                            dA=np.asarray(dA_t) / dt * us)
Exemplo n.º 13
0
qb_sel = qb[sel]
qs_sel = qs[sel]

qeta = np.load(
    '/Users/rupeshdotel/analysis/work/pi0pippimeta/data/qfactor_data/qvalues_gluexI.npz'
)
qse = qeta['qse']

#%%

#1d histos

#for etaprime mass
hb_ep = B.histo(metap[sel],
                range=(0.86, 1.06),
                bins=xbin,
                weights=qb_sel,
                title="bkg $\eta'$",
                xlabel="$M(\pi^{+}\pi^{-}\eta)$")
hs_ep = B.histo(metap[sel],
                range=(0.86, 1.06),
                bins=xbin,
                weights=qs_sel * qse,
                title="signal $\eta'$",
                xlabel="$M(\pi^{+}\pi^{-}\eta)$")
ht_ep = B.histo(metap[sel],
                range=(0.86, 1.06),
                bins=xbin,
                title='Non-weighted',
                xlabel="$M(\pi^{+}\pi^{-}\eta)$")

# for pi0mass
Exemplo n.º 14
0
import numpy as np
import LT.box as B


#%%
#d = np.load('/Users/rupeshdotel/analysis/work/pi0pippimeta/data/qfactor_data/unique_cons_17_18_pol_0.npz')
d = np.load('/Users/rupeshdotel/analysis/work/pi0pippimeta/data/qfactor_data/gluex_unique_cons_17_18_incamo.npz')


#%%
metap = d['metap']
metappi0 = d['metappi0']
cost_etap = d['cost_etap']


h_etap = B.histo(metap, bins = 32,  title = "$M(\pi^{+}\pi^{-}\eta)$ Kinfit Variables (Mass constrained trees)")


h_etappi0 = B.histo(metappi0,  bins = 40, 
               title = "$M(\eta^{'}\pi^{0})$ Kinfit Variables  (Mass constrianed trees) ")

h2_ep_cost = B.histo2d(metappi0, cost_etap,  bins = ( 25, 25 ),
                       title = "Angular distribution in GJ Frame",
               xlabel = "$M(\eta^{'}\pi^{0})$", ylabel = "$\cos\\theta_{GJ}$" )


#%%
#read the ASCII data file
par = B.LT.parameterfile.pfile('/Users/rupeshdotel/analysis/work/gluexgit/data_files/data/sideband.data')

# load the parameters values
Exemplo n.º 15
0
# S0 are the sigma values from the fit
S0 = np.ones_like(M_inv_sel[:])
do_plot = False

q_err = np.ones_like(M_inv_sel[:])

#%%
for i, M_inv_loc in enumerate(M_inv_sel[2561:2563]):

    # select neghboring events for the current event combine distance of costheta and phi normalized by  pythagorian theorem
    i_near = np.argsort(
        np.sqrt((dcos_theta_etap_gj_m[i]**2 + dphi_etap_gj_m[i]**2)))[:n_near]

    M_inv_neighbor = M_inv_sel[i_near]

    h = B.histo(M_inv_neighbor, bins=15)
    h_sel = h.bin_content > 0
    M = h.bin_center[h_sel]
    C = h.bin_content[h_sel]
    dC = h.bin_error[h_sel]

    A = B.Parameter(C.max(), 'A')
    x0 = B.Parameter(0.956, 'x0')
    sigma = B.Parameter(.005, 'sigma')
    a0 = B.Parameter(1., 'a0')
    a1 = B.Parameter(1., 'a1')

    fit = B.genfit(signal, [A, x0, sigma, a0, a1],
                   x=M,
                   y=C,
                   y_err=dC,
Exemplo n.º 16
0
combo_num = d['combo_number_unique']
dt = d['dt_unique']
event_num = d['event_num_unique']
kinfit_CL = d['kinfit_CL_unique']
chisq_ndf = d['chisq_ndf_unique']


#%%
q = np.load('/Users/rupeshdotel/analysis/work/pi0pippimeta/data/qfactor_data/qvalues_gluexI.npz')

qs_sel = q['qs_sel']; qb_sel = q['qb_sel'];
sel=q['sel']; 

#%%

he_ws2d = B.histo(meta[sel], bins = 40, weights = qs_sel, title = '$\eta$' , xlabel = 'M($\gamma\gamma$)')
he = B.histo(meta[sel], bins = 40)
he_ws2d.plot_exp()
he_ws2d.show_fit_list()
he_ws2d.set_fit_list(['A', 'mean', 'sigma', 'b0', 'b1'])
he_ws2d.fit()
he_ws2d.plot_fit()
he_ws2d.title = '$\eta$'
he_ws2d.x_lable = '$M(\gamma\gamma)$'
b0 = he_ws2d.b0.value
b1 = he_ws2d.b1.value
#b2 = hs.b2.value

def eta_bkg(x):
    return b0 + b1*x