Ejemplo n.º 1
0
def getdpispec(emin=-2, emax=3):
    """ """
    N = 512
    bins = 256
    bins2 = 512
    E = np.linspace(emin, emax, N) * 10**-3
    pdf = [
        DnDnPip(gs, gt, E[-1]),
        DnDnPip(gs, gt, E[-1]),
    ]

    grids = [
        pdf[0].mgridABAC(bins, bins2)[0],
        pdf[0].mgridABAC(bins, bins2)[0],
    ]

    I = [np.zeros(bins2) for _ in grids]

    fcn = [
        lambda: pdf[0].mdpihspec(grid=grids[0]),
        lambda: pdf[0].mdpilspec(grid=grids[0]),
    ]

    labels = [
        r'$D^0\pi^+$ high',
        r'$D^0\pi^+$ low',
    ]

    for idx, energy in enumerate(E):
        print(f'E = {energy*10**3:.3f} MeV ({idx}/{E.shape[0]})')
        for p in pdf:
            p.setE(energy)
        for i, f in zip(I, fcn):
            i += f()

    mdpi = [np.sqrt(g[1][:, 0]) for g in grids]
    I = [i * m for i, m in zip(I, mdpi)]  # Jacobian d(m^2) = 2m*dm
    norm = [np.sum(i) * (m[-1] - m[0]) / bins2 for i, m in zip(I, mdpi)]
    I = [i / n for i, n in zip(I, norm)]
    plt.figure(figsize=(8, 6))
    for x, y, l in zip(mdpi, I, labels):
        plt.plot(x, y, label=l)
        plt.plot(*smear_mdpi(x, y, 1024), label=l + ' smeared')
    plt.ylim(0, 1.01 * max([np.max(i) for i in I]))
    plt.xlim(2.00, 2.015)
    plt.xlabel(r'$m(D^0\pi^+)$ (GeV)', fontsize=18)
    plt.legend(loc='best', fontsize=20)
    plt.tight_layout()
    plt.grid()
    plt.show()
Ejemplo n.º 2
0
def run(elo=-0.5, ehi=0.0):
    """ """
    nEbins = 512
    nABbins = 512
    nACbins = 512

    E = np.linspace(elo, ehi, nEbins) * 10**-3
    I = np.zeros(nEbins)
    pdf = DnDnPip(gs, gt, E[-1])
    gridABAC, ds = pdf.mgridABAC(nABbins, nACbins)

    for idx, energy in enumerate(E):
        print(f'E {energy*10**3:.3f} MeV ({idx}/{E.shape[0]})')
        pdf.setE(energy)
        I[idx] = ds * np.sum(pdf(*gridABAC)[0])

    E *= 10**3

    r = UnivariateSpline(E, I - np.max(I) / 2, s=0).roots()
    if len(r) > 1:
        r1, r2 = r[:2]
    else:
        r1 = r[0]
        r2 = 0

    print(
        f'gs {gs.real*10**3:.1f} + i{gs.imag*10**3:.1f} MeV, gs {gt.real*10**3:.1f} + i{gt.imag*10**3:.1f} MeV, fwhw = {(r2-r1)*10**3:.3f} keV'
    )
    print(f'Maximum at {E[np.argmax(I)]:.2f} MeV')
    print(
        f'gs {gs.real*10**3:.1f} + i{gs.imag*10**3:.1f} MeV, gs {gt.real*10**3:.1f} + i{gt.imag*10**3:.1f} MeV, fwhw = {(r2-r1)*10**3:.3f} keV'
    )

    plt.figure(figsize=(8, 5))
    plt.plot(E, I / np.max(I))
    plt.axvspan(r1, r2, facecolor='orange', alpha=0.2)
    plt.xlabel(r'$E$ (MeV)', fontsize=16)
    plt.ylim(0, 1.01)
    plt.xlim(E[0], E[-1])
    plt.minorticks_on()
    plt.axes().xaxis.grid(True, which='minor', linestyle='--')
    plt.grid()
    plt.tight_layout()

    for ext in ['png', 'pdf']:
        plt.savefig(f'plots/peak.{ext}')

    plt.show()
Ejemplo n.º 3
0
def getespec(emin=-2, emax=4):
    """ """
    N = 1024
    bins = 512
    E = np.linspace(emin, emax, N) * 10**-3

    pdf = [
        DnDpPin(gs, gt, E[-1]),
        DnDnPip(gs, gt, E[-1]),
        DnDpGam(gs, gt, E[-1])
    ]

    labels = [r'$D^0D^+\pi^0$', r'$D^0D^0\pi^+$', r'$D^0D^+\gamma$']

    grid = [p.mgridABAC(bins, bins)[0] for p in pdf]
    I = [np.empty(E.shape) for _ in pdf]

    for idx, energy in enumerate(E):
        print(f'E = {energy*10**3:.3f} ({idx}/{E.shape[0]})')
        for i, p, g in zip(I, pdf, grid):
            p.setE(energy)
            i[idx] = p.integral(grid=g)

    E *= 10**3
    plt.figure(figsize=(8, 6))
    for i, l in zip(I, labels):
        plt.plot(E, i, label=l)
    plt.xlim(E[0], E[-1])
    plt.ylim(0, 1.05 * max([np.max(i) for i in I]))
    plt.legend(loc='best', fontsize=20)
    plt.xlabel(r'$E$ (MeV)', fontsize=18)
    plt.tight_layout()
    plt.grid()
    plt.show()
Ejemplo n.º 4
0
def fit_model():
    gs = 42 + 1.3j
    gt = 25000 + 1.3j
    ch = 5
    smeared = False

    # sample_path = 'mcsamples'
    sample_path = '.'
    sample_file = f'mc_ddpip_3d_gs{gs.real:.2f}_{gs.imag:.2f}_ch{ch}'
    if smeared:
        sample_file += '_smeared'
    sample_raw = np.load(os.path.join(
        sample_path,
        '.'.join([sample_file, 'npy'])))
    print(sample_raw[:3] / prm.scale**2)
    print(sample_raw.shape)
    
    # pd, md1pi = vartools.generated_to_observables(
    #     sample_raw[:,1], sample_raw[:,2])

    # sample = np.column_stack((sample_raw[:,0], pd, md1pi))
    # eps = 1e-3
    # sample = sample[(sample[:,1] > eps) & (sample[:,0] < 9) & (sample[:,1] < 120)]
    # print(sample.shape)

    data_box = cnv.build_box(sample_raw)
    print(data_box)
    bins = np.ones(data_box.shape[0], dtype=np.int32) * 256
    box_ticks = list(map(lambda x: x / prm.scale**2, cnv.ticks_in_box(data_box, bins)))
    box_grid = cnv.grid_in_box(data_box, bins)

    pdf = DnDnPip(gs, gt)
    f = pdf.pdf(s=box_grid[0], mddsq=box_grid[1], md1pisq=box_grid[2])
    print(f.shape)
    pdf_norm = mc_integral(lambda x: pdf.pdf(s=x[0], mddsq=x[1], md1pisq=x[2]), data_box)
    print(f'pdf_norm: {pdf_norm:3f}')

    fig, ax = plt.subplots(ncols=3, nrows=2, figsize=(14.5, 9))
    nbins = 256
    f *= sample_raw.shape[0] / pdf_norm
    proj_plots(ax, sample_raw / prm.scale**2, bins=nbins)
    plots.draw_pdf_projections(ax[0], box_ticks, f)
    fig.tight_layout()
    plt.show()
Ejemplo n.º 5
0
def getddspec(emin=-2, emax=3):
    """ """
    N = 512
    bins=1024
    bins2=512
    E = np.linspace(emin, emax, N)*10**-3
    tfcn = [
        lambda x: tdd(x, mdn, mdn),
        lambda x: tdd(x, mdn, mdp),
        lambda x: tdd(x, mdn, mdp)
    ]
    pdf = [
        DnDnPip(gs, gt, E[-1]),
        DnDpPin(gs, gt, E[-1]),
        DnDpGam(gs, gt, E[-1])
    ]
    I = [np.zeros(bins) for _ in pdf]
    grids = [p.mgridABAC(bins, bins2)[0] for p in pdf]
    mddSq = [p.linspaceAB(bins) for p in pdf]
    labels = [
        r'$D^0D^0(\pi^+)$',
        r'$D^0D^+(\pi^0)$',
        r'$D^0D^+(\gamma)$',
    ]
    print(mddSq)
    for energy in E:
        for i, p, g in zip(I, pdf, grids):
            p.setE(energy)
            i += p.mddspec(grid=g)

    I = [i*np.sqrt(m) for i,m in zip(I, mddSq)]  # Jacobian d(m^2) = 2m*dm
    mdd = [t(np.sqrt(m))*10**3 for m, t in zip(mddSq, tfcn)]
    # norm = [np.sum(i) * (m[-1] - m[0]) / bins for i,m in zip(I, mdd)]
    norm = [p.linspaceAB(bins)[1]-p.linspaceAB(bins)[0] for p in pdf]
    I = [i / n for i,n in zip(I, norm)]
    plt.figure(figsize=(8,6))
    for m, i, l in zip(mdd, I, labels):
        plt.plot(m, i, label=l)
    plt.xlim(0, min(15, 1.05*max([i[-1] for i in mdd])))
    plt.ylim(0, 1.01*max([np.max(i) for i in I]))
    plt.xlabel(r'$E(DD)$ (MeV)', fontsize=18)
    plt.legend(loc='best', fontsize=20)
    plt.tight_layout()
    plt.grid()
    plt.show()
Ejemplo n.º 6
0
def getddspec(emin=-0.5, emax=0.2):
    """ """
    N = 512
    bins = 1024
    bins2 = 512
    E = np.linspace(emin, emax, N) * 10**-3
    tfcn = [
        lambda x: tdd(x, mdn, mdn), lambda x: tdd(x, mdn, mdp),
        lambda x: tdd(x, mdn, mdp)
    ]
    pdf = [
        DnDnPip(gs, gt, E[-1]),
        DnDpPin(gs, gt, E[-1], [True, False], False),
        DnDpPin(gs, gt, E[-1], [False, True], False)
    ]
    I = [np.zeros(bins) for _ in pdf]
    grids = [p.mgridABAC(bins, bins2)[0] for p in pdf]
    mddSq = [g[0][0] for g in grids]
    labels = [
        r'$D^0[D^{*+}\to D^0\pi^+$', r'$D^0[D^{*+}\to D^+\pi^0]$',
        r'$D^+[D^{*0}\to D^0\pi^0]$'
    ]
    print(mddSq)
    for energy in E:
        for idx, p in enumerate(pdf):
            p.setE(energy)
            I[idx] += np.sum(p(*grids[idx])[0], axis=0)

    I = [i * np.sqrt(m) for i, m in zip(I, mddSq)]  # Jacobian d(m^2) = 2m*dm
    mdd = [t(np.sqrt(m)) * 10**3 for m, t in zip(mddSq, tfcn)]
    norm = [np.sum(i) * (m[-1] - m[0]) / bins for i, m in zip(I, mdd)]
    I = [i / n for i, n in zip(I, norm)]
    plt.figure(figsize=(8, 6))
    for m, i, l in zip(mdd, I, labels):
        plt.plot(m, i, label=l)
    plt.xlim(0, min(15, 1.05 * max([i[-1] for i in mdd])))
    plt.ylim(0, 1.01 * max([np.max(i) for i in I]))
    plt.xlabel(r'$E(DD)$ (MeV)', fontsize=18)
    plt.legend(loc='best', fontsize=20)
    plt.tight_layout()
    plt.grid()
    plt.show()
Ejemplo n.º 7
0
def run(elo=-1, ehi=1):
    """ """
    nEbins = 256
    nABbins = 512
    nACbins = 256

    E = np.linspace(elo, ehi, nEbins) * 10**-3
    pdf = DnDnPip(gs, gt, E[-1], [True, False])

    gridABAC = pdf.mgridABAC(nABbins, nACbins)[0]
    abspace = pdf.linspaceAB(nABbins)
    sqrtABspace = np.sqrt(abspace)
    E = np.linspace(elo, ehi, nEbins) * 10**-3
    I = np.empty((nABbins, nEbins))

    for idx, energy in enumerate(E):
        print(f'E {energy*10**3:.3f} MeV ({idx}/{E.shape[0]})')
        pdf.setE(energy)
        I[:, idx] = np.sum(pdf(*gridABAC)[0], axis=0) * sqrtABspace

    tdd = (sqrtABspace - 2 * mdn)

    print('Applying energy resolution...')
    for idx, x in enumerate(tdd):
        I[idx, :] = smear_e_fixed_tdd(E, I[idx, :], x)

    tdd *= 10**3
    E *= 10**3
    x, y = np.meshgrid(tdd, E)

    label_size = 16
    plt.figure(figsize=(7, 7))
    plt.contourf(x, y, I.T, levels=25)
    plt.xlabel('T(DD) (MeV)', fontsize=label_size)
    plt.ylabel('E (MeV)', fontsize=label_size)
    plt.tight_layout()

    for ext in ['png', 'pdf']:
        plt.savefig(f'plots/e_vs_tdd.{ext}')

    plt.figure(figsize=(7, 7))
    plt.contourf(x, y, np.log(1. + I.T + 1.e-6), levels=25)
    plt.xlabel('T(DD) (MeV)', fontsize=label_size)
    plt.ylabel('E (MeV)', fontsize=label_size)
    plt.tight_layout()
    for ext in ['png', 'pdf']:
        plt.savefig(f'plots/e_vs_tdd_log.{ext}')

    plt.show()
Ejemplo n.º 8
0
def dndnpip(E):
    """ D0 D0 pi+ Dalitz plot and projections """
    E *= 1e-3

    swave = False
    resonance = True

    pdf = DnDnPip(gs, gt, E, [resonance, swave])
    _, axs = plt.subplots(1, 4, figsize=(16, 4))

    dnpi_dnpi_plot(axs[0], pdf, logplot=True)
    dd_plot(axs[1], pdf, lbl='D^0D^0', sqrt=True)
    dpi_lo_plot(axs[2], pdf, sqrt=True)
    dpi_hi_plot(axs[3], pdf, sqrt=True)

    plt.tight_layout()

    for ext in ['png', 'pdf']:
        plt.savefig(
            f'plots/dp_dndnpip_{E*10**3:.1f}_{resonance}_{swave}.{ext}')

    plt.show()
Ejemplo n.º 9
0
def getespec(emin=-2, emax=4):
    """ """
    N = 512
    bins = 512
    E = np.linspace(emin, emax, N) * 10**-3

    pdf = [
        # DnDpPin(gs, gt, E[-1]),
        DnDnPip(gs, gt, E[-1]),
        # DnDpGam(gs, gt, E[-1])
    ]

    labels = [
        # r'$D^0D^+\pi^0$',
        r'$D^0D^0\pi^+$',
        # r'$D^0D^+\gamma$'
    ]

    thr = [
        # mdn + mdp,
        mdn + mdn,
        # mdn + mdp
    ]

    grid = [p.mgridABAC(bins // 2, bins) for p in pdf]
    tdds = [np.sqrt(g[0][0][0]) - th for g, th in zip(grid, thr)]
    I = [np.empty(E.shape) for _ in pdf]
    I_smeared = [np.zeros(E.shape) for _ in pdf]
    sigmas = [np.zeros(E.shape) for _ in pdf]

    for idx, energy in enumerate(E):
        print(f'{energy*10**3:.3f} ({idx}/{E.shape[0]})')
        for i, ism, p, g, tdd, sig in zip(I, I_smeared, pdf, grid, tdds,
                                          sigmas):
            p.setE(energy)
            (mdd, mdh), ds = g
            dens = p(mdd, mdh)[0]
            ptdd = ds * np.sum(dens, axis=0)
            i[idx] = np.sum(ptdd)
            ism_j, sigma = smear_e(energy, E, tdd, ptdd)
            sig[idx] = sigma * 10**3
            ism += ism_j

    E *= 10**3
    norm = [np.sum(i) * (E[-1] - E[0]) / N for i in I]
    I = [i / n for i, n in zip(I, norm)]
    # I_smeared = [i/n for i,n in zip(I_smeared, norm)]
    plt.figure(figsize=(8, 6))
    for i, ism, l in zip(I, I_smeared, labels):
        ism = ism / np.sum(ism) * np.sum(i)
        plt.plot(E, i, label=l)
        plt.plot(E, ism, label=l + ' smeared')
        print(f'    Raw: {np.sum(i):.3f}')
        print(f'Smeared: {np.sum(ism):.3f}')
    plt.xlim(E[0], E[-1])
    plt.ylim(0, 1.05 * max([np.max(i) for i in I]))
    plt.legend(loc='best', fontsize=20)
    plt.xlabel(r'$E$ (MeV)', fontsize=18)
    plt.tight_layout()
    plt.grid()

    plt.figure(figsize=(6, 4))
    plt.plot(E, sigmas[0])
    plt.xlim(E[0], E[-1])
    plt.ylim(0, 1.05 * np.max(sigmas[0]))
    plt.xlabel(r'$E$ (MeV)', fontsize=18)
    plt.ylabel(r'$\sigma(E), MeV$', fontsize=18)
    plt.tight_layout()
    plt.grid()

    plt.show()
Ejemplo n.º 10
0
def getespec(emin=3, emax=10):
    """ """
    N = 128
    bins = 2048

    E = np.linspace(emin, emax, N) * 10**-3

    pdf = [
        DnDnPip(gs, gt, E[-1], channels=[True, False]),
        DnDpPin(gs, gt, E[-1], channels=[True, False, False]),
        DnDpPin(gs, gt, E[-1], channels=[False, True, False]),
        DnDpGam(gs, gt, E[-1])
    ]

    grid = [p.mgridABAC(bins, bins)[0] for p in pdf]
    I = [np.zeros(N) for _ in pdf]

    for idx, energy in enumerate(E):
        print(f'E {energy*10**3:.3f} MeV ({idx}/{E.shape[0]})')
        for i, p, g in zip(I, pdf, grid):
            p.setE(energy)
            p.t1, p.t2, p.t, p.tin = 1, 1, 1, 1
            i[idx] = p.integral(grid=g)

    gam_over_pi0 = I[3][-1] / I[2][-1]
    scale = (br_dstn_dngam / br_dstn_dnpin) / gam_over_pi0
    print(f'gam / pi0 = {gam_over_pi0:.3f}')
    print(f'compare to {br_dstn_dngam / br_dstn_dnpin:.3f}')
    print(f'scaling: {scale:.3f}')

    E *= 10**3
    figax1 = plt.subplots(figsize=(8, 6))
    put_plot_on_axis(
        figax=figax1,
        xlabel=r'$E$ (MeV)',
        xlim=(E[0], E[-1]),
        saveas='gammanorm',
        data=[[
            E, I[0] / I[1], r'$D^{*+}\to D^0\pi^+$ / $D^{*+}\to D^+\pi^0$', {}
        ],
              [[E[0], E[-1]],
               [[br_dstp_dnpip / br_dstp_dppin] for _ in range(2)],
               r'BF($D^{*+}\to D^0\pi^+$) / BF($D^{*+}\to D^+\pi^0$)', {
                   'linestyle': '--'
               }],
              [
                  E, I[3] / I[2],
                  r'$D^{*0}\to D^0\gamma$ / $D^{*0}\to D^0\pi^0$', {}
              ],
              [[E[0], E[-1]],
               [[br_dstn_dngam / br_dstn_dnpin] for _ in range(2)],
               r'BF($D^{*0}\to D^0\gamma$) / BF($D^{*0}\to D^0\pi^0$)', {
                   'linestyle': '--'
               }],
              [
                  E, I[2] / I[0],
                  r'$D^{*0}\to D^0\pi^0$ / $D^{*+}\to D^0\pi^+$', {}
              ]])

    figax2 = plt.subplots(figsize=(8, 6))
    put_plot_on_axis(figax=figax2,
                     xlabel=r'$E$ (MeV)',
                     xlim=(E[0], E[-1]),
                     saveas='gammanorm_pi0_gam',
                     data=[[E, I[2], r'$\Gamma(D^{*0}\to D^0\pi^0)$', {}],
                           [E, I[3], r'$\Gamma(D^{*0}\to D^0\gamma)$', {}]])

    plt.show()
Ejemplo n.º 11
0
def run(elo=-2, ehi=8):
    """ """
    nEbins = 1024
    nABbins = 1024
    nACbins = 1024
    nBCbins = 1024

    E = np.linspace(elo, ehi, nEbins) * 10**-3
    pdf = [
        DnDnPip(gs, gt, E[-1], [True, include_swave]),
        DnDpPin(gs, gt, E[-1], [True, True, include_pwave]),
        DnDpGam(gs, gt, E[-1]),
        DnDpPin(gs, gt, E[-1], [False, False, True]),  # P-wave amplitude
        DnDnPip(gs, gt, E[-1], [False, True]),  # S-wave amplitude
    ]

    I = {
        'Pwave': np.zeros(nEbins),
        'Swave': np.zeros(nEbins),
        'DDpi': np.zeros(nEbins),
        'DDpi0': np.zeros(nEbins),
        'DDgam': np.zeros(nEbins),
        'DDpiS': np.zeros(nEbins),
        'DDpi0S': np.zeros(nEbins),
        'DDgamS': np.zeros(nEbins),
        'PwaveS': np.zeros(nEbins),
        'SwaveS': np.zeros(nEbins),
        'D0D+Pw': np.zeros(nABbins),
        'D0D0Sw': np.zeros(nABbins),
        'D0D+pi': np.zeros(nABbins),
        'D0D+ga': np.zeros(nABbins),
        'D0D0': np.zeros(nABbins),
        'D0piBelow': np.zeros(nACbins),
        'D0piAbove': np.zeros(nACbins),
    }

    gridsABAC = [p.mgridABAC(nABbins, nACbins)[0] for p in pdf]
    gridsACBC = [p.mgridACBC(nACbins, nBCbins)[0] for p in pdf]
    abspace = [p.linspaceAB(nABbins) for p in pdf]
    acspace = [p.linspaceAC(nACbins) for p in pdf]
    bcspace = [p.linspaceBC(nBCbins) for p in pdf]
    thrs = [mdn + mdn, mdn + mdp, mdn + mdp, mdn + mdp, mdn + mdn]
    tddspace = [np.sqrt(x) - thr for x, thr in zip(abspace, thrs)]
    dab = [x[1] - x[0] for x in abspace]
    dac = [x[1] - x[0] for x in acspace]
    dbc = [x[1] - x[0] for x in bcspace]

    ddpi_mask = (gridsACBC[0][1] > gridsACBC[0][0])

    for idx, energy in enumerate(E):
        print('E {:.3f} MeV'.format(energy * 10**3))
        for p in pdf:
            p.setE(energy)
        dens = [p(*g)[0] for p, g in zip(pdf, gridsABAC)]
        mab = [dx * np.sum(x, axis=0) for x, dx in zip(dens, dac)]
        I['DDpi'][idx] = np.sum(mab[0]) * dab[0]
        I['DDpi0'][idx] = np.sum(mab[1]) * dab[1]
        I['DDgam'][idx] = np.sum(mab[2]) * dab[2]
        if include_pwave:
            I['Pwave'][idx] = np.sum(mab[3]) * dab[3]
        I['Swave'][idx] = np.sum(mab[4]) * dab[4]

        I['D0D0'] += mab[0]
        I['D0D+pi'] += mab[1]
        I['D0D+ga'] += mab[2]
        I['D0D+Pw'] += mab[3]
        I['D0D0Sw'] += mab[4]

        densACBC = pdf[0](pdf[0].mZsq(*gridsACBC[0]), gridsACBC[0][1])[0]
        densACBC[ddpi_mask] = 0
        if energy > 0:
            I['D0piAbove'] += dbc[0] * np.sum(densACBC, axis=0)
        else:
            I['D0piBelow'] += dbc[0] * np.sum(densACBC, axis=0)

        # eddpi_smeared, meanres = smear_e(energy, E, tddspace[0], mab[0])
        # print(f'sigma(E) = {meanres*10**3:.3} MeV')
        # I['DDpiS']  += I['DDpi'][idx]*eddpi_smeared
        # I['DDpiS']  += I['DDpi'][idx]*smear_e_const(energy, E, tddspace[0], mab[0])[0]
        I['DDpiS'] += smear_e(energy, E, tddspace[0], mab[0])[0]
        I['DDpi0S'] += smear_e(energy, E, tddspace[1], mab[1])[0]
        # I['DDpi0S'] += I['DDpi0'][idx]*smear_e_const(energy, E, tddspace[1], mab[1])[0]
        # I['DDgamS'] += smear_e(energy, E, tddspace[2], mab[2])[0]
        # if include_pwave:
        # I['PwaveS'] += smear_e(energy, E, tddspace[3], mab[3])[0]
        # I['SwaveS'] += smear_e(energy, E, tddspace[4], mab[4])[0]

    _, ax = plt.subplots(2, 3, figsize=(18, 12))
    E *= 10**3
    # Energy w/o smearing
    cax = ax[0, 0]
    print('Pwave integral {:.0f}'.format(np.sum(I['Pwave'])))
    print('Swave integral {:.0f}'.format(np.sum(I['Swave'])))
    print(' DDpi integral {:.0f}'.format(np.sum(I['DDpi'])))
    print(' Pwave fraction {:.2f}'.format(
        np.sum(I['Pwave']) / np.sum(I['DDpi'])))
    print(' Swave fraction {:.2f}'.format(
        np.sum(I['Swave']) / np.sum(I['DDpi'])))
    ymax = np.max(I['DDpi'])
    # cax.set(xlabel=r'$E$ (MeV)', ylim=(0, 1.01), xlim=(E[0], E[-1]))
    cax.set(xlabel=r'$E$ (MeV)', ylim=(0, 1.01), xlim=(E[0], 15))
    cax.grid()
    cax.plot(E, I['DDpi'] / ymax, label=r'$D^0D^0\pi^+$')
    cax.plot(E, I['DDpi0'] / ymax, label=r'$D^0D^+\pi^0$')
    cax.plot(E, I['DDgam'] / ymax, label=r'$D^0D^+\gamma$')
    # if not hide_invisible:
    #     cax.plot(E, I['Swave'] / ymax, label=r'$D^0D^0$ $S$-wave')
    #     if include_pwave:
    #         cax.plot(E, I['Pwave'] / ymax, label=r'$D^0D^+$ $P$-wave')
    cax.legend(loc='best', fontsize=16)

    # Energy w/ smearing
    cax = ax[1, 0]
    ymax = np.max(I['DDpiS'])
    # cax.set(xlabel=r'$E$ (MeV)', ylim=(0, 1.01), xlim=(E[0], E[-1]))
    cax.set(xlabel=r'$E$ (MeV)', ylim=(0, 1.01), xlim=(E[0], 15))
    cax.grid()
    cax.plot(E, I['DDpiS'] / ymax, label=r'$D^0D^0\pi^+$')
    cax.plot(E, I['DDpi0S'] / ymax, label=r'$D^0D^+\pi^0$')
    if not hide_invisible:
        # cax.plot(E, I['DDgamS'] / ymax, label=r'$D^0D^+\gamma$')
        cax.plot(E, I['SwaveS'] / ymax, label=r'$D^0D^0$ $S$-wave')
        if include_pwave:
            cax.plot(E, I['PwaveS'] / ymax, label=r'$D^0D^+$ $P$-wave')
    cax.legend(loc='best', fontsize=16)

    # m(DD) w/o smearing
    cax = ax[0, 1]
    tddspace = [x * 10**3 for x in tddspace]
    pdndn = I['D0D0'] * 2 * np.sqrt(abspace[0])
    pdndppi = I['D0D+pi'] * 2 * np.sqrt(abspace[1])
    pdndpga = I['D0D+ga'] * 2 * np.sqrt(abspace[2])
    pdndppw = I['D0D+Pw'] * 2 * np.sqrt(abspace[3])
    pdndnsw = I['D0D0Sw'] * 2 * np.sqrt(abspace[4])
    x, y = merge(tddspace[1], pdndppi, tddspace[2], pdndpga)
    ymax = max(np.max(pdndn), np.max(y))

    # cax.set(xlabel=r'$T(DD)$ (MeV)', ylim=(0, 1.01), xlim=(0, ehi*2))
    cax.set(xlabel=r'$T(DD)$ (MeV)', ylim=(0, 1.01), xlim=(0, 15))
    cax.plot(tddspace[0], pdndn / ymax, label=r'$D^0D^0$')
    cax.plot(tddspace[1], pdndppi / ymax, ':', label=r'$D^0D^+(\pi^0)$')
    cax.plot(tddspace[2], pdndpga / ymax, '--', label=r'$D^0D^+(\gamma)$')
    cax.plot(tddspace[3], pdndppw / ymax, '--', label=r'$D^0D^+$ $P$-wave')
    cax.plot(tddspace[4], pdndnsw / ymax, '--', label=r'$D^0D^0$ $S$-wave')
    cax.plot(x, y / ymax, label=r'$D^0D^+ total$')

    cax.grid()
    cax.legend(loc='best', fontsize=16)

    # m(DD) w/ smearing
    cax = ax[1, 1]
    for x in tddspace:
        x[0] += 1.e-6
    dndns = smear_tdd(tddspace[0] / 10**3, pdndn, dots=1000)
    pdndppis = smear_tdd(tddspace[1] / 10**3, pdndppi, dots=1000)
    pdndpgas = smear_tdd(tddspace[2] / 10**3, pdndpga, dots=1000)
    pdndppws = smear_tdd(tddspace[3] / 10**3, pdndppw, dots=1000)
    x, y = merge(*pdndppis, *pdndpgas)
    # x, y = merge(*pdndppws, x, y)
    ymax = max(np.max(dndns[1]), np.max(y))

    # cax.set(xlabel=r'$T(DD)$ (MeV)', ylim=(0, 1.01), xlim=(0, ehi*2))
    cax.set(xlabel=r'$T(DD)$ (MeV)', ylim=(0, 1.01), xlim=(0, 15))
    cax.plot(dndns[0] * 10**3, dndns[1] / ymax, label=r'$D^0D^0$')
    cax.plot(pdndppis[0] * 10**3,
             pdndppis[1] / ymax,
             ':',
             label=r'$D^0D^+(\pi^0)$')
    cax.plot(pdndpgas[0] * 10**3,
             pdndpgas[1] / ymax,
             '--',
             label=r'$D^0D^+(\gamma)$')
    if include_pwave:
        cax.plot(pdndppws[0] * 10**3,
                 pdndppws[1] / ymax,
                 '--',
                 label=r'$D^0D^+$ $P$-wave')
    cax.plot(x * 10**3, y / ymax, label=r'$D^0D^+ total$')

    cax.grid()
    cax.legend(loc='best', fontsize=16)

    # m(Dpi) w/o smearing
    cax = ax[0, 2]
    pdnpiAbove = I['D0piAbove'] * 2 * np.sqrt(acspace[0])
    pdnpiBelow = I['D0piBelow'] * 2 * np.sqrt(acspace[0])
    x = np.sqrt(acspace[0])
    ytotal = pdnpiAbove + pdnpiBelow
    ymax = max(ytotal)
    # cax.set(xlabel=r'$m(D^0\pi^+)$ (GeV)', ylim=(0, 1.01), xlim=(x[0], x[-1]))
    cax.set(xlabel=r'$m(D^0\pi^+)$ (GeV)', ylim=(0, 1.01), xlim=(x[0], 2.02))
    cax.plot(x, ytotal / ymax, label=r'$D^0\pi^+$ high')
    cax.plot(x, pdnpiAbove / ymax, '--', label=r'$D^0\pi^+$ high, $E>0$')
    cax.plot(x, pdnpiBelow / ymax, ':', label=r'$D^0\pi^+$ high, $E<0$')
    cax.grid()
    cax.legend(loc='best', fontsize=16)

    # m(Dpi) w/ smearing
    cax = ax[1, 2]
    # cax.set(xlabel=r'$m(D^0\pi^+)$ (GeV)', ylim=(0, 1.01), xlim=(x[0], x[-1]))
    cax.set(xlabel=r'$m(D^0\pi^+)$ (GeV)', ylim=(0, 1.01), xlim=(x[0], 2.02))
    x0, y0 = smear_mdpi(x, pdnpiAbove, 1024)
    xp, yp = smear_mdpi(x, pdnpiBelow, 1024)
    ytotal = y0 + yp
    ymax = max(ytotal)
    cax.plot(x0, ytotal / ymax, label=r'$D^0\pi^+$ high')
    cax.plot(x0, y0 / ymax, '--', label=r'$D^0\pi^+$ high, $E>0$')
    cax.plot(xp, yp / ymax, ':', label=r'$D^0\pi^+$ high, $E<0$')
    cax.grid()
    cax.legend(loc='best', fontsize=16)

    plt.tight_layout()
    plt.savefig('plots/obs.png')
    plt.savefig('plots/obs.pdf')
    plt.show()