Skip to content

Commit

Permalink
draft v2
Browse files Browse the repository at this point in the history
  • Loading branch information
shenvitor committed Aug 30, 2024
1 parent dede7e0 commit 7bced3e
Showing 1 changed file with 196 additions and 18 deletions.
214 changes: 196 additions & 18 deletions docs/eta-pi-p/manual.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"jupyter": {
"source_hidden": true
},
"mystnb": {
"code_prompt_show": "Import Python libraries"
},
Expand Down Expand Up @@ -151,6 +148,22 @@
"A12_l"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# s12, m_a2, gamma_a2, l12 = sp.symbols(r\"s_{12} m_{a_2} \\Gamma_{a_2} l_{12}\")\n",
"# theta1, phi1 = sp.symbols(\"theta_1 phi_1\")\n",
"# a = sp.IndexedBase(\"a\")\n",
"# m = sp.symbols(\"m\", cls=sp.Idx)\n",
"# A12_l = sp.Sum(a[m] * sp.Ynm(l12, m, theta1, phi1), (m, -l12, l12)) / (\n",
"# s12 - m_a2**2 + sp.I * m_a2 * gamma_a2\n",
"# )\n",
"# A12_l"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -221,6 +234,7 @@
"A12_l_func = sp.lambdify(\n",
" [s12, a[-2], a[-1], a[0], a[1], a[2], l12, m_a2, gamma_a2, theta1, phi1],\n",
" A12_l.doit().expand(func=True),\n",
" modules=[\"scipy\"],\n",
")\n",
"A12_l_func"
]
Expand Down Expand Up @@ -266,6 +280,24 @@
"A23_l"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# s23, m_delta, gamma_delta, l23 = sp.symbols(\n",
"# r\"s_{23} m_{\\Delta^+} \\Gamma_{\\Delta^+} l_{23}\"\n",
"# )\n",
"# b = sp.IndexedBase(\"b\")\n",
"# m = sp.symbols(\"m\", cls=sp.Idx)\n",
"# theta2, phi2 = sp.symbols(\"theta_2 phi_2\")\n",
"# A23_l = sp.Sum(b[m] * sp.Ynm(l23, m, theta2, phi2), (m, -l23, l23)) / (\n",
"# s23 - m_delta**2 + sp.I * m_delta * gamma_delta\n",
"# )\n",
"# A23_l"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -288,6 +320,7 @@
"A23_l_func = sp.lambdify(\n",
" [s23, b[-2], b[-1], b[0], b[1], b[2], l23, m_delta, gamma_delta, theta2, phi2],\n",
" A23_l.doit().expand(func=True),\n",
" modules=[\"scipy\"],\n",
")\n",
"A23_l_func"
]
Expand Down Expand Up @@ -348,6 +381,18 @@
"A31_l"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# A31_l = sp.Sum(c[m] * sp.Ynm(l31, m, theta3, phi3), (m, -l31, l31)) / (\n",
"# s31 - m_nstar**2 + sp.I * m_nstar * gamma_nstar\n",
"# )\n",
"# A31_l"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -370,6 +415,7 @@
"A31_l_func = sp.lambdify(\n",
" [s31, c[-2], c[-1], c[0], c[1], c[2], l31, m_nstar, gamma_nstar, theta3, phi3],\n",
" A31_l.doit().expand(func=True),\n",
" modules=[\"scipy\"],\n",
")\n",
"A31_l_func"
]
Expand All @@ -391,6 +437,16 @@
"intensity_expr"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"intensity_expr_l = sp.Abs(A12_l + A23_l + A31_l) ** 2\n",
"intensity_expr_l"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -555,16 +611,6 @@
"### Parameters"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"for i in range(-2, 3):\n",
" print(i)"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -781,9 +827,10 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"jupyter": {
"source_hidden": true
}
"tags": [
"hide-input",
"scroll-input"
]
},
"outputs": [],
"source": [
Expand Down Expand Up @@ -842,6 +889,7 @@
"categorized_sliders_m = defaultdict(list)\n",
"categorized_sliders_gamma = defaultdict(list)\n",
"categorized_cphi_pair = defaultdict(list)\n",
"categorized_sliders_l = defaultdict(list)\n",
"\n",
"for symbol, value in parameters_default.items():\n",
" if symbol.name.startswith(R\"\\Gamma_{\"):\n",
Expand Down Expand Up @@ -909,8 +957,54 @@
" categorized_cphi_pair[0].append(cphi_hbox)\n",
" else:\n",
" raise NotImplementedError(symbol.name)\n",
" # else:\n",
" # raise NotImplementedError(symbol.name)\n",
"\n",
" elif symbol.name.startswith(\"l_{12}\"):\n",
" slider = w.IntSlider(\n",
" value=2,\n",
" min=0,\n",
" max=2,\n",
" step=1,\n",
" description=\"ℓ₁₂\",\n",
" disabled=False,\n",
" continuous_update=False,\n",
" orientation=\"horizontal\",\n",
" readout=True,\n",
" readout_format=\"d\",\n",
" )\n",
" sliders[symbol.name] = slider\n",
" categorized_sliders_l[2].append(slider)\n",
" elif symbol.name.startswith(\"l_{23}\"):\n",
" slider = w.IntSlider(\n",
" value=1,\n",
" min=0,\n",
" max=2,\n",
" step=1,\n",
" description=\"ℓ₂₃\",\n",
" disabled=False,\n",
" continuous_update=False,\n",
" orientation=\"horizontal\",\n",
" readout=True,\n",
" readout_format=\"d\",\n",
" )\n",
" sliders[symbol.name] = slider\n",
" categorized_sliders_l[1].append(slider)\n",
" elif symbol.name.startswith(\"l_{31}\"):\n",
" slider = w.IntSlider(\n",
" value=0,\n",
" min=0,\n",
" max=2,\n",
" step=1,\n",
" description=\"ℓ₃₁\",\n",
" disabled=False,\n",
" continuous_update=False,\n",
" orientation=\"horizontal\",\n",
" readout=True,\n",
" readout_format=\"d\",\n",
" )\n",
" sliders[symbol.name] = slider\n",
" categorized_sliders_l[0].append(slider)\n",
" else:\n",
" raise NotImplementedError(symbol.name)\n",
"tab_contents = []\n",
"resonances_name = [\"N* [pη (31)]\", \"Δ⁺ [π⁰p(23)]\", \"a₂ [ηπ⁰(12)]\"]\n",
"for i in range(len(resonances_name)):\n",
Expand All @@ -919,6 +1013,11 @@
" w.VBox(categorized_cphi_pair[i]),\n",
" ])\n",
" tab_contents.append(tab_content)\n",
"UI_lsliders = w.HBox([\n",
" *categorized_sliders_l[0],\n",
" *categorized_sliders_l[1],\n",
" *categorized_sliders_l[2],\n",
"])\n",
"UI_1 = w.Tab(tab_contents, titles=resonances_name)\n",
"UI = w.VBox([UI_lsliders, UI_1])\n",
"UI"
Expand Down Expand Up @@ -947,6 +1046,29 @@
"intensities = intensity_func(phsp)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"unfolded_expression_l = intensity_expr_l.doit().expand(func=True)\n",
"intensity_func_l = create_parametrized_function(\n",
" expression=unfolded_expression,\n",
" parameters=parameters_default,\n",
" backend=\"jax\",\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"intensities_l = intensity_func_l(phsp)"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -975,6 +1097,62 @@
" return updated_parameters"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# intensity_func_l\n",
"%matplotlib widget\n",
"%config InlineBackend.figure_formats = ['png']\n",
"fig_2d, ax_2d = plt.subplots(dpi=200)\n",
"ax_2d.set_title(\"Model-weighted Phase space Dalitz Plot\")\n",
"ax_2d.set_xlabel(R\"$m^2(\\eta \\pi^0)\\;\\left[\\mathrm{GeV}^2\\right]$\")\n",
"ax_2d.set_ylabel(R\"$m^2(\\pi^0 p)\\;\\left[\\mathrm{GeV}^2\\right]$\")\n",
"\n",
"mesh = None\n",
"\n",
"\n",
"def update_histogram(**parameters):\n",
" global mesh\n",
"\n",
" parameters = insert_phi(parameters)\n",
"\n",
" intensity_func_l.update_parameters(parameters)\n",
" intensity_weights = intensity_func_l(phsp)\n",
" bin_values, xedges, yedges = jnp.histogram2d(\n",
" phsp[\"s_{12}\"],\n",
" phsp[\"s_{23}\"],\n",
" bins=200,\n",
" weights=intensity_weights,\n",
" density=True,\n",
" )\n",
" bin_values = jnp.where(bin_values < 1e-6, jnp.nan, bin_values)\n",
" x, y = jnp.meshgrid(xedges[:-1], yedges[:-1])\n",
" if mesh is None:\n",
" mesh = ax_2d.pcolormesh(x, y, bin_values.T, cmap=\"jet\", vmax=0.15)\n",
" else:\n",
" mesh.set_array(bin_values.T)\n",
" fig_2d.canvas.draw_idle()\n",
"\n",
"\n",
"interactive_plot = w.interactive_output(\n",
" update_histogram,\n",
" {**sliders},\n",
")\n",
"fig_2d.tight_layout()\n",
"fig_2d.colorbar(mesh, ax=ax_2d)\n",
"\n",
"if STATIC_PAGE:\n",
" filename = \"dalitz-plot-man.png\"\n",
" fig_2d.savefig(filename)\n",
" plt.close(fig_2d)\n",
" display(UI, Image(filename))\n",
"else:\n",
" display(UI, interactive_plot)"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down

0 comments on commit 7bced3e

Please sign in to comment.