Esempio n. 1
0
def plot_ibd(nu_spec):
    figure = plt.figure()
    e_arr = np.linspace(0., 55e6, 1000)

    # IBD Cross Section
    xsec_ibd_0th = total_XSec_ibd_0th(e_arr)
    plt.plot(e_arr*1e-6,xsec_ibd_0th*1.e42, color='red', linestyle="--", label=r'0$^{th}$ Order')

    xsec_ibd = total_XSec_ibd(e_arr)
    plt.plot(e_arr*1e-6,xsec_ibd*1.e42, color='blue', linestyle=":", label=r'1$^{st}$ Order')

    plt.xlabel("Energy (MeV)")
    plt.ylabel(r'Cross Section ($10^{-42}$ cm$^2$)')
    plt.title("IBD Cross Section")
    plt.legend()
    plt.grid()

    plt.xlim(0., 10.)
    plt.ylim(0., 10.)
    plt.savefig("plots/ibd_xsec.png")

    def f(x, a, b):
        if x<b:
            return 0.
        else:
            return a*(x-b)**2
    f = np.vectorize(f)
    res = curve_fit(f, e_arr, xsec_ibd_0th, [1.e-42, 1.e6])
    print("a*(x-b)^2 Fit Parameters: %s"%res[0])
Esempio n. 2
0
def compare_ibd_cevns(nu_spec):
    figure = plt.figure()
    e_arr = np.linspace(0., 55e6, 1000)

    # CEvNS Cross Sections
    xsec_Cs = total_XSec_cns(0., e_arr, 55., 132.9-55.)
    plt.semilogy(e_arr*1e-6,xsec_Cs*1.e38, color='blue', linestyle="--", label=r'CEvNS Cs')

    xsec_I = total_XSec_cns(0., e_arr, 53., 126.9-53.)
    plt.semilogy(e_arr*1e-6,xsec_I*1.e38, color='blue', linestyle=":", label=r'CEvNS I')

    xsec_Ge = total_XSec_cns(0., e_arr, 32., 72.64-32.)
    plt.semilogy(e_arr*1e-6,xsec_Ge*1.e38, color='green', linestyle="-.", label=r'CEvNS Ge')

    # IBD Cross Section
    xsec_ibd = total_XSec_ibd(e_arr)
    plt.semilogy(e_arr*1e-6,xsec_ibd*1.e38, color='red', linestyle="-", label=r'IBD')

    plt.xlabel("Energy (MeV)")
    plt.ylabel(r'Cross Section ($10^{-38}$ cm$^2$)')
    plt.legend()
    plt.grid()

    plt.xlim(0., 10.)
    plt.ylim(1.e-6, 1.e0)
    plt.savefig("plots/ibd_cevns_xsec.png")
    plt.xlim(5., 55.)
    plt.ylim(4.e-4, 3.e1)
    plt.savefig("plots/ibd_coherent_plot.png")
Esempio n. 3
0
def fit_daya_bay_data():
    fig1, (a0, a1) = plt.subplots(2, 1,
                                  gridspec_kw={'height_ratios': [2, 1],})
    plt.subplots_adjust(bottom=0.075, top=0.95)
    #sharex=True)
    fig1.patch.set_facecolor('white')
    fig1.set_figheight(8.5)

    # Plot data from Daya Bay paper arXiv:1607.05378v2
    db_data = np.loadtxt("data/daya_bay_unfolded_spectrum.csv", delimiter=",")

    bin_low = db_data[:,0]
    bin_high = db_data[:,1]
    xvals = (bin_low+bin_high)/2.
    bin_widths = bin_high-bin_low

    yvals = db_data[:,2]
    yerrs = np.sqrt(db_data[:,3])

    a0.errorbar(xvals, yvals, yerr=yerrs, xerr=bin_widths/2.,
                 color='k', linestyle='None',
                 label="Daya Bay Data")

    # Huber/Mueller Prediction for Daya Bay
        # Mueller spectra
    nu_spec_mueller = NeutrinoSpectrum(nu_spec.distance, nu_spec.power, True,
                                       0.561, 0.076, 0.307, 0.056) # Daya Bay Numbers (arXiv:1607.05378v2)
    nu_spec_mueller.initialize_d_r_d_enu("u235", "txt",
                                         "../../data/huber/U235-anti-neutrino-flux-250keV.dat")
    nu_spec_mueller.initialize_d_r_d_enu("u238", "mueller")
    nu_spec_mueller.initialize_d_r_d_enu("pu239", "txt",
                                         "../../data/huber/Pu239-anti-neutrino-flux-250keV.dat")
    nu_spec_mueller.initialize_d_r_d_enu("pu241", "txt",
                                         "../../data/huber/Pu241-anti-neutrino-flux-250keV.dat")
    nu_spec_mueller.initialize_d_r_d_enu("other", "mueller")

    pred_spectrum = []
    for i in range(len(bin_low)):
        res = spint.quad(lambda e_eV:
                         nu_spec_mueller.d_phi_d_enu_ev(e_eV)*\
                         total_XSec_ibd(e_eV),
                         bin_low[i]*1.e6, bin_high[i]*1.e6)[0]
        res /= (bin_high[i]-bin_low[i])
        res *= 1.e46/nu_spec.nuFlux() # Convert to cm^2/fission/MeV x 10^-46
        pred_spectrum.append(res)
    a0.errorbar(xvals, pred_spectrum, xerr=bin_widths/2.,
                 color='r', linestyle='None',
                 label="Huber/Mueller Prediction")

    # Plot Settings
    a0.legend()
    a0.set_xlim(1.8, 8.4)
    a0.set(ylabel=r'$\phi_{\bar{\nu}_e}*\sigma_{IBD}$ (cm^2/fission/MeV $\times$ 10^-46)')

    a1.errorbar(xvals, yvals/pred_spectrum,
                xerr=bin_widths/2., yerr=yerrs/yvals,
                color='k', linestyle='None')
    a1.plot(xvals, xvals*0.+1., color='k')
    a1.set_xlim(1.8, 8.4)
    a1.set_ylim(0.6, 1.25)
    a1.set(xlabel="Antineutrino Energy (MeV)",
           ylabel="Ratio")
    plt.savefig("plots/fit_daya_bay_plot_reproduction.png")

    # Fit the spectrum
    fig1, (a0, a1) = plt.subplots(2, 1,
                                  gridspec_kw={'height_ratios': [2, 1],})
    plt.subplots_adjust(bottom=0.075, top=0.95)
    #sharex=True)
    fig1.patch.set_facecolor('white')
    fig1.set_figheight(8.5)

    def get_bin(x):
        if(x<bin_low[0]):
            return -1
        for i in range(0, len(bin_low)):
            if(bin_low[i]<=x and
               x<bin_high[i]):
                return i
        return len(bin_low)

    def f(x, k0, b0, mu, sig):
        i = get_bin(x)
        if(i<0 or i>=len(bin_low)):
            return 0.
        else:
            return k0*pred_spectrum[get_bin(x)]+b0*np.exp(-(x-mu)**2/ (2*sig**2))*total_XSec_ibd(x*1.e6)
    f = np.vectorize(f)
    x_fit = xvals[np.logical_and(3.<xvals, xvals<7.5)]
    y_fit = yvals[np.logical_and(3.<xvals, xvals<7.5)]
    res = curve_fit(f, x_fit, y_fit, [1., 1.e44, 5.7, 0.5])
    print("Unfolded Spectrum Fit Parameters: %s"%res[0])
    a0.errorbar(xvals, yvals, yerr=yerrs, xerr=bin_widths/2.,
                 color='k', linestyle='None',
                 label="Daya Bay Data")
    a0.errorbar(xvals, res[0][0]*np.array(pred_spectrum),
                xerr=bin_widths/2.,
                color='red', linestyle='None',
                label="Huber/Mueller Rescaled")
    a0.errorbar(xvals, f(xvals, *res[0]),
                xerr=bin_widths/2.,
                color='blue', linestyle='None',
                label=r'Huber/Mueller+Gaussian*$\sigma_{IBD}$ Fit')
    a0.legend()
    a0.set_xlim(3., 7.5)
    a0.set(ylabel=r'$\phi_{\bar{\nu}_e}*\sigma_{IBD}$ (cm^2/fission/MeV $\times$ 10^-46)',
           title=r'Reactor Spectrum Gaussian Fit: $\mu$=%.2f, $\sigma=$%.3f'%(res[0][2], res[0][3]))

    def g(x, a0, b0, mu, sig):
        i = get_bin(x)
        if(i<0 or i>=len(bin_low)):
           return 1.
        else:
           return a0 + b0*np.exp(-(x-mu)**2/ (2*sig**2))
    g = np.vectorize(g)
    x_fit_ratio = xvals[np.logical_and(3.<xvals, xvals<7.5)]
    y_fit_ratio = np.array(yvals)[np.logical_and(3.<xvals, xvals<7.5)]/np.array(pred_spectrum)[np.logical_and(3.<xvals, xvals<7.5)]
    res = curve_fit(g, x_fit_ratio, y_fit_ratio, [0.9, 0.1, 5.7, 0.5])
    print("Ratio Fit Parameters: %s"%res[0])
    a1.errorbar(xvals, yvals/pred_spectrum,
                xerr=bin_widths/2., yerr=yerrs/yvals,
                color='k', linestyle='None')
    a1.plot(xvals, xvals*0.+1., color='k')
    a1.plot(xvals, xvals*0.+res[0][0], 'r--')
    a1.errorbar(xvals, g(xvals, *res[0]),
                xerr=bin_widths/2.,
                color='blue', linestyle='None')
    a1.set_xlim(3., 7.5)
    a1.set_ylim(0.6, 1.25)
    a1.set(xlabel="Antineutrino Energy (MeV)",
           ylabel="Ratio",
           title=r'Ratio Gaussian Fit: $\mu$=%.2f, $\sigma=$%.3f'%(res[0][2], res[0][3]))
    plt.savefig("plots/fit_daya_bay_gaussian_fits.png")
Esempio n. 4
0
def plot_nu_bump_ibd(nu_spec,
                     bump_fracs=[0.01, 0.05]):
    old_frac = nu_spec.bump_frac

    # Plot unzoomed neutrino flux and ratio
    fig1, (a0, a1) = plt.subplots(2, 1,
                                  gridspec_kw={'height_ratios': [2, 1],})
    plt.subplots_adjust(bottom=0.075, top=0.95)
    #sharex=True)
    fig1.patch.set_facecolor('white')
    fig1.set_figheight(8.5)
    lines_arr = ['b--', 'r-.', 'y:',
                 'c-', 'g--', 'm-.']
    e_arr = np.linspace(0., 1e7, 100000)

    nu_spec.bump_frac = 0.
    spec_tot = nu_spec.d_phi_d_enu_ev(e_arr)*total_XSec_ibd(e_arr)/nu_spec.nuFlux()
    a0.plot(e_arr*1e-6,spec_tot*1e6,'k-',label="No Distortion",linewidth=2)
    ibd_yield_0 = ibd_yield(nu_spec)
    bump_specs = []
    ibd_yields = []
    for i in range(len(bump_fracs)):
        nu_spec.bump_frac = bump_fracs[i]
        spec = nu_spec.d_phi_d_enu_ev(e_arr)*total_XSec_ibd(e_arr)/nu_spec.nuFlux()
        bump_specs.append(spec)
        a0.plot(e_arr*1e-6,spec*1e6,lines_arr[i],
                 label="Bump=%.2f%%"%(100.*bump_fracs[i]),linewidth=2)
        ibd_yields.append(ibd_yield(nu_spec))

    #a0.set_ylim(0., 2e17)
    a0.set_xlim(0., 10.)
    a0.set(ylabel='Reactor Spectrum * IBD xsec, cm^2/fission/MeV')
    a0.set_title('Reactor Spectrum * IBD xsec at Commercial Reactor')

    a1.plot(e_arr*1e-6,spec_tot/spec_tot,'k-',label="No Distortion",linewidth=2)
    for i in range(len(bump_fracs)):
        spec = bump_specs[i]
        plt.plot(e_arr*1e-6,spec/spec_tot,lines_arr[i],
                 label="Bump=%.2f%%"%(100.*bump_fracs[i]),linewidth=2)
        print("Bump=%.2e, Ratio=%s"%(bump_fracs[i], spec/spec_tot))
        print("tot int: %s"%spint.simps(spec_tot*1.e6, e_arr*1e-6))
        print("bump int: %s"%spint.simps(spec*1.e6, e_arr*1e-6))
        print("ibd yield no bump: %.3e cm^2/fission"%ibd_yield_0)
        print("ibd yield bump: %.3e cm^2/fission"%ibd_yields[i])
    a1.legend(loc=2, prop={'size':11})
    a1.set_xlim(0., 10.)
    a1.set_ylim(0.75, 1.25)
    a1.set(xlabel='Neutrino Energy (MeV)', ylabel='Ratio')

    '''axins = inset_axes(a0, width=3.5, height=2.5, loc=3,
                       bbox_to_anchor=(0.24, 0.3),
                       bbox_transform=a0.transAxes)
    axins.plot(e_arr*1e-6,spec_tot*1e6,'k-',label="No Distortion",linewidth=2)
    for i in range(len(bump_fracs)):
        spec = bump_specs[i]
        axins.plot(e_arr*1e-6,spec*1e6,lines_arr[i],
                   label="Bump=%.2f%%"%(100.*bump_fracs[i]),linewidth=2)
    axins.set_xlim(4.5, 7.5)
    #axins.set_ylim(0., 4.e15)'''

    plt.savefig('plots/reactor_bump_ibd_product.png')
    nu_spec.bump_frac = old_frac
Esempio n. 5
0
 def ratio(e):
     nu_spec.bump_frac = 0.0
     rate0 = nu_spec.d_phi_d_enu_ev(e)*total_XSec_ibd(e)
     nu_spec.bump_frac = bump_frac
     rate1 = nu_spec.d_phi_d_enu_ev(e)*total_XSec_ibd(e)
     return rate1/rate0
Esempio n. 6
0
 def f(x, k0, b0, mu, sig):
     i = get_bin(x)
     if(i<0 or i>=len(bin_low)):
         return 0.
     else:
         return k0*pred_spectrum[get_bin(x)]+b0*np.exp(-(x-mu)**2/ (2*sig**2))*total_XSec_ibd(x*1.e6)