From c658bd15274a223d998fefb2a1c45c6c83f3d5e1 Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Thu, 23 May 2024 13:42:41 +0200 Subject: [PATCH] FIX: filter with `\\beta` instead of `Dummy` * DOC: reorganize plotting code --- docs/report/031.ipynb | 313 +++++++++++++++++++----------------------- 1 file changed, 142 insertions(+), 171 deletions(-) diff --git a/docs/report/031.ipynb b/docs/report/031.ipynb index bd42c814..04fae33b 100644 --- a/docs/report/031.ipynb +++ b/docs/report/031.ipynb @@ -788,10 +788,10 @@ ")\n", "phsp_momenta = phsp_generator.generate(500_000, rng)\n", "\n", - "epsilon = 1e-8\n", + "ε = 1e-8\n", "transformer = SympyDataTransformer.from_sympy(model.kinematic_variables, backend=\"jax\")\n", "phsp = transformer(phsp_momenta)\n", - "phsp = {k: v + epsilon * 1j if re.match(r\"^m_\\d\\d$\", k) else v for k, v in phsp.items()}" + "phsp = {k: v + ε * 1j if re.match(r\"^m_\\d\\d$\", k) else v for k, v in phsp.items()}" ] }, { @@ -1022,7 +1022,7 @@ "tags": [] }, "source": [ - "### Phase" + "### Argand plots" ] }, { @@ -1033,9 +1033,9 @@ }, "outputs": [], "source": [ - "epsilon = 1e-8\n", + "ε = 1e-8\n", "x = np.linspace(2, 5, num=400)\n", - "plot_data = {\"m_01\": np.sqrt(x + epsilon * 1j)}" + "plot_data = {\"m_01\": np.sqrt(x) + ε * 1j}" ] }, { @@ -1046,16 +1046,16 @@ }, "outputs": [], "source": [ - "total_phase_bw = np.angle(dynamics_func_bw(plot_data))\n", - "sub_phase_bw = {\n", - " p: np.angle(\n", - " compute_sub_intensity(\n", - " dynamics_func_bw,\n", - " plot_data,\n", - " resonances=[p.latex],\n", - " coupling_pattern=r\"Dummy_\",\n", - " )\n", - " )\n", + "total_dynamics_bw = dynamics_func_bw(plot_data)\n", + "sub_dynamics_bw = {\n", + " p: compute_sub_intensity(dynamics_func_bw, plot_data, resonances=[p.latex])\n", + " for symbol, resonances in create_dynamics_symbol.collected_symbols.items()\n", + " for p, _ in resonances\n", + "}\n", + "total_dynamics_fvector = dynamics_func_fvector(plot_data)\n", + "sub_dynamics_fvector = {\n", + " p: compute_sub_intensity(dynamics_func_fvector, plot_data, resonances=[p.latex])\n", + " for symbol, resonances in create_dynamics_symbol.collected_symbols.items()\n", " for p, _ in resonances\n", "}" ] @@ -1068,18 +1068,134 @@ }, "outputs": [], "source": [ - "total_phase_fvector = np.angle(dynamics_func_fvector(plot_data))\n", - "sub_phase_fvector = {\n", - " p: np.angle(\n", - " compute_sub_intensity(\n", - " dynamics_func_fvector,\n", - " plot_data,\n", - " resonances=[p.latex],\n", - " coupling_pattern=r\"\\\\beta\",\n", - " )\n", + "x1 = np.linspace(2.0, (m_res1**2 + m_res2**2) / 2, num=500)\n", + "x2 = np.linspace((m_res1**2 + m_res2**2) / 2, 5.0, num=500)\n", + "plot_data1 = {\"m_01\": np.sqrt(x1) + ε * 1j}\n", + "plot_data2 = {\"m_01\": np.sqrt(x2) + ε * 1j}" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "jupyter": { + "source_hidden": true + }, + "tags": [ + "hide-input", + "scroll-input" + ] + }, + "outputs": [], + "source": [ + "y1 = dynamics_func_fvector(plot_data1)\n", + "y2 = dynamics_func_fvector(plot_data2)\n", + "\n", + "fig, axes = plt.subplots(1, 2, figsize=(10, 5))\n", + "ax1, ax2 = axes\n", + "for ax in axes:\n", + " ax.axhline(0, color=\"black\", linewidth=0.5)\n", + " ax.axvline(0, color=\"black\", linewidth=0.5)\n", + "\n", + "colors = [\"red\", \"blue\"]\n", + "for i, (k, v) in enumerate(sub_dynamics_fvector.items()):\n", + " ax2.plot(\n", + " v.real,\n", + " v.imag,\n", + " color=colors[i % len(colors)],\n", + " label=f\"Resonance at {k.mass} GeV $F$-vector\",\n", " )\n", - " for p, _ in resonances\n", - "}" + "\n", + "ax1.plot(\n", + " y1.real,\n", + " y1.imag,\n", + " label=Rf\"$\\text{{Im}}\\,F(s)$ in domain of {m_res1}-GeV resonance \",\n", + " color=\"red\",\n", + ")\n", + "ax1.plot(\n", + " y2.real,\n", + " y2.imag,\n", + " label=Rf\"$\\text{{Im}}\\,F(s)$ in domain of {m_res2}-GeV resonance \",\n", + " color=\"blue\",\n", + ")\n", + "ax1.set_xlabel(R\"$\\text{Re}\\,F$\", fontsize=14)\n", + "ax1.set_ylabel(R\"$\\text{Im}\\,F$\", fontsize=14)\n", + "fig.tight_layout()\n", + "ax1.legend(loc=\"upper left\")\n", + "fig.show()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "jupyter": { + "source_hidden": true + }, + "tags": [ + "hide-input", + "scroll-input" + ] + }, + "outputs": [], + "source": [ + "y1 = dynamics_func_bw(plot_data1)\n", + "y2 = dynamics_func_bw(plot_data2)\n", + "\n", + "fig, axes = plt.subplots(1, 2, figsize=(10, 5))\n", + "fig.suptitle(\"Breit-Wigner\")\n", + "ax1, ax2 = axes\n", + "for ax in axes:\n", + " ax.axhline(0, color=\"black\", linewidth=0.5)\n", + " ax.axvline(0, color=\"black\", linewidth=0.5)\n", + "\n", + "colors = [\"red\", \"blue\"]\n", + "for i, (k, v) in enumerate(sub_dynamics_bw.items()):\n", + " ax2.plot(\n", + " v.real,\n", + " v.imag,\n", + " color=colors[i % len(colors)],\n", + " label=f\"Resonance at {k.mass} GeV $F$-vector\",\n", + " )\n", + "\n", + "ax1.plot(\n", + " y1.real,\n", + " y1.imag,\n", + " label=Rf\"$\\text{{Im}}\\,F(s)$ in domain of {m_res1}-GeV resonance \",\n", + " color=\"red\",\n", + ")\n", + "ax1.plot(\n", + " y2.real,\n", + " y2.imag,\n", + " label=Rf\"$\\text{{Im}}\\,F(s)$ in domain of {m_res2}-GeV resonance \",\n", + " color=\"blue\",\n", + ")\n", + "ax1.set_xlabel(r\"$Re(F)$\", fontsize=14)\n", + "ax1.set_ylabel(r\"$Im(F)$\", fontsize=14)\n", + "plt.tight_layout()\n", + "ax1.legend(loc=\"upper left\")\n", + "fig.show()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Phase" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "total_phase_bw = np.angle(total_dynamics_bw)\n", + "total_phase_fvector = np.angle(total_dynamics_fvector)\n", + "sub_phase_bw = {p: np.angle(v) for p, v in sub_dynamics_bw.items()}\n", + "sub_phase_fvector = {p: np.angle(v) for p, v in sub_dynamics_fvector.items()}" ] }, { @@ -1162,101 +1278,6 @@ "fig.show()" ] }, - { - "cell_type": "markdown", - "metadata": { - "tags": [] - }, - "source": [ - "### Dynamics" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "tags": [] - }, - "outputs": [], - "source": [ - "total_dynamics_bw = dynamics_func_fvector(plot_data)\n", - "sub_dynamics_bw = {\n", - " p: compute_sub_intensity(\n", - " dynamics_func_bw,\n", - " plot_data,\n", - " resonances=[p.latex],\n", - " coupling_pattern=r\"Dummy_\",\n", - " )\n", - " for p, _ in resonances\n", - "}\n", - "total_dynamics_fvector = dynamics_func_fvector(plot_data)\n", - "sub_dynamics_fvector = {\n", - " p: compute_sub_intensity(\n", - " dynamics_func_fvector,\n", - " plot_data,\n", - " resonances=[p.latex],\n", - " coupling_pattern=r\"\\\\beta\",\n", - " )\n", - " for p, _ in resonances\n", - "}" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "jupyter": { - "source_hidden": true - }, - "tags": [ - "hide-input", - "scroll-input" - ] - }, - "outputs": [], - "source": [ - "x1 = np.linspace(2.0, (m_res1**2 + m_res2**2) / 2, num=500)\n", - "x2 = np.linspace((m_res1**2 + m_res2**2) / 2, 5.0, num=500)\n", - "\n", - "plot_data1 = {\"m_01\": np.sqrt(x1 + epsilon * 1j)}\n", - "plot_data2 = {\"m_01\": np.sqrt(x2 + epsilon * 1j)}\n", - "\n", - "y1 = dynamics_func_fvector(plot_data1).imag\n", - "y2 = dynamics_func_fvector(plot_data2).imag\n", - "fig, axes = plt.subplots(1, 2, figsize=(10, 5))\n", - "colors = [\"red\", \"blue\"]\n", - "ax1, ax2 = axes\n", - "for i, (k, v) in enumerate(sub_dynamics_fvector.items()):\n", - " ax2.plot(\n", - " v.real,\n", - " v.imag,\n", - " color=colors[i % len(colors)],\n", - " label=f\"Resonance at {k.mass} GeV $F$-vector\",\n", - " )\n", - "\n", - "ax1.plot(\n", - " y1.real,\n", - " y1.imag,\n", - " label=rf\"$Im(F)$ $s$ in domain of {{{m_res1}}} [GeV] resonance \",\n", - " color=\"red\",\n", - ")\n", - "ax1.plot(\n", - " y2.real,\n", - " y2.imag,\n", - " label=rf\"$Im(F)$ $s$ in domain of {{{m_res2}}} [GeV] resonance \",\n", - " color=\"blue\",\n", - ")\n", - "ax1.set_xlabel(r\"$Re(F)$\", fontsize=14)\n", - "ax1.set_ylabel(r\"$Im(F)$\", fontsize=14)\n", - "ax1.axhline(0, color=\"black\")\n", - "ax1.axvline(0, color=\"black\")\n", - "ax2.axhline(0, color=\"black\")\n", - "ax2.axvline(0, color=\"black\")\n", - "fig.tight_layout()\n", - "ax1.legend(loc=\"upper left\")\n", - "fig.show()" - ] - }, { "cell_type": "code", "execution_count": null, @@ -1330,56 +1351,6 @@ "plt.tight_layout()\n", "plt.show()" ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "jupyter": { - "source_hidden": true - }, - "tags": [ - "hide-input", - "scroll-input" - ] - }, - "outputs": [], - "source": [ - "y1_bw = dynamics_func_bw(plot_data1)\n", - "y2_bw = dynamics_func_bw(plot_data2)\n", - "fig, axes = plt.subplots(1, 2, figsize=(10, 5))\n", - "colors = [\"red\", \"blue\"]\n", - "ax1, ax2 = axes\n", - "for i, (k, v) in enumerate(sub_dynamics_bw.items()):\n", - " ax2.plot(\n", - " v.real,\n", - " v.imag,\n", - " color=colors[i % len(colors)],\n", - " label=f\"Resonance at {k.mass} GeV $F$-vector\",\n", - " )\n", - "\n", - "ax1.plot(\n", - " y1_bw.real,\n", - " y1_bw.imag,\n", - " label=rf\"$Im(F)$ $s$ in domain of {m_res1}-GeV resonance \",\n", - " color=\"red\",\n", - ")\n", - "ax1.plot(\n", - " y2_bw.real,\n", - " y2_bw.imag,\n", - " label=rf\"$Im(F)$ $s$ in domain of {m_res2}-GeV resonance \",\n", - " color=\"blue\",\n", - ")\n", - "ax1.set_xlabel(r\"$Re(F)$\", fontsize=14)\n", - "ax1.set_ylabel(r\"$Im(F)$\", fontsize=14)\n", - "ax1.axhline(0, color=\"black\")\n", - "ax1.axvline(0, color=\"black\")\n", - "ax2.axhline(0, color=\"black\")\n", - "ax2.axvline(0, color=\"black\")\n", - "plt.tight_layout()\n", - "ax1.legend(loc=\"upper left\")\n", - "fig.show()" - ] } ], "metadata": {