diff --git a/.cspell.json b/.cspell.json
index ec942002..15b6b7ab 100644
--- a/.cspell.json
+++ b/.cspell.json
@@ -119,6 +119,7 @@
"bdist",
"bgcolor",
"boldsymbol",
+ "cbff",
"celltoolbar",
"clim",
"cmap",
@@ -136,6 +137,7 @@
"csqrt",
"cstride",
"darkred",
+ "dasharray",
"displaystyle",
"docstrings",
"dotprint",
@@ -156,6 +158,7 @@
"gridspec",
"hasattr",
"heatmap",
+ "histtype",
"imag",
"infty",
"iplt",
@@ -173,11 +176,14 @@
"kutschke",
"lambdifier",
"lambdifygenerated",
+ "linecap",
+ "linejoin",
"linestyle",
"linewidth",
"linkcheck",
"linspace",
"livereveal",
+ "lstrip",
"marangotto",
"markdownlint",
"mathbb",
@@ -193,7 +199,9 @@
"nbformat",
"nbmake",
"ncols",
+ "ndarray",
"nonlocal",
+ "nonumber",
"noqa",
"noreply",
"nrows",
@@ -222,6 +230,7 @@
"richman",
"rpartition",
"rstride",
+ "rstrip",
"rtfd",
"rules's",
"savefig",
@@ -237,6 +246,7 @@
"spflueger",
"startswith",
"subslide",
+ "substack",
"suptitle",
"symplot",
"theano",
@@ -252,6 +262,8 @@
"xlim",
"xlink",
"xreplace",
+ "xtick",
+ "xticklabels",
"xticks",
"ylabel",
"ylim",
diff --git a/.github/workflows/notebooks.yml b/.github/workflows/notebooks.yml
index 1307603c..4bad6ff2 100644
--- a/.github/workflows/notebooks.yml
+++ b/.github/workflows/notebooks.yml
@@ -11,9 +11,9 @@ jobs:
- uses: actions/checkout@master
- uses: actions/setup-python@master
with:
- python-version: "3.7"
+ python-version: "3.8"
- name: Install dependencies
run: |
sudo apt-get -y install graphviz
- pip install -c .constraints/py3.7.txt .[test]
+ pip install -c .constraints/py3.8.txt .[test]
- run: pytest --nbmake
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index fffd607f..2c10fdd9 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -53,7 +53,8 @@ repos:
(?x)^(
docs/report/004.*|
docs/report/005.*|
- docs/report/007.*
+ docs/report/007.*|
+ docs/report/013.*
)$
- id: set-nb-cells
diff --git a/docs/conf.py b/docs/conf.py
index 452119cf..67edbeed 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -271,6 +271,9 @@ def get_minor_version(package_name: str) -> str:
"report/010*",
"report/011*",
"report/012*",
+ "report/013*",
+ "report/014*",
+ "report/015*",
]
nb_output_stderr = "remove"
nb_render_priority = {
diff --git a/docs/report/013.ipynb b/docs/report/013.ipynb
new file mode 100644
index 00000000..7f948a51
--- /dev/null
+++ b/docs/report/013.ipynb
@@ -0,0 +1,10021 @@
+{
+ "cells": [
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "hideCode": true,
+ "hideOutput": true,
+ "hidePrompt": true,
+ "jupyter": {
+ "source_hidden": true
+ },
+ "slideshow": {
+ "slide_type": "skip"
+ },
+ "tags": [
+ "remove-cell"
+ ]
+ },
+ "outputs": [],
+ "source": [
+ "%config InlineBackend.figure_formats = ['svg']\n",
+ "import os\n",
+ "\n",
+ "STATIC_WEB_PAGE = {\"EXECUTE_NB\", \"READTHEDOCS\"}.intersection(os.environ)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "```{autolink-concat}\n",
+ "```"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# [TR-013] Spin alignment with data"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "\n",
+ "```{autolink-skip}\n",
+ "```"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ ":::{seealso}\n",
+ "\n",
+ "- {doc}`/report/014`\n",
+ "- {doc}`/report/015`\n",
+ "\n",
+ ":::"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "jupyter": {
+ "source_hidden": true
+ },
+ "tags": [
+ "hide-cell"
+ ]
+ },
+ "outputs": [],
+ "source": [
+ "%pip install -q ampform==0.13.0 qrules[viz]==0.9.7 tensorwaves[jax,pwa]==0.4.2"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "tags": []
+ },
+ "source": [
+ "In this report, we attempt to check the effect of activating spin alignment ([ampform#245](https://ampform--245.org.readthedocs.build/en/245/usage/helicity/spin-alignment.html)) and compare it with [Figure 2](https://downloads.hindawi.com/journals/ahep/2020/6674595.pdf#page=9) in {cite}`marangottoHelicityAmplitudesGeneric2020`."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "jupyter": {
+ "source_hidden": true
+ },
+ "tags": [
+ "hide-cell"
+ ]
+ },
+ "outputs": [],
+ "source": [
+ "import logging\n",
+ "import warnings\n",
+ "\n",
+ "LOGGER = logging.getLogger()\n",
+ "LOGGER.setLevel(logging.ERROR)\n",
+ "warnings.filterwarnings(\"ignore\")"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "tags": []
+ },
+ "source": [
+ "## Phase space sample"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "jupyter": {
+ "source_hidden": true
+ },
+ "tags": [
+ "hide-cell"
+ ]
+ },
+ "outputs": [],
+ "source": [
+ "import qrules\n",
+ "\n",
+ "PDG = qrules.load_pdg()"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "tags": []
+ },
+ "outputs": [],
+ "source": [
+ "from tensorwaves.data import (\n",
+ " TFPhaseSpaceGenerator,\n",
+ " TFUniformRealNumberGenerator,\n",
+ ")\n",
+ "\n",
+ "phsp_generator = TFPhaseSpaceGenerator(\n",
+ " initial_state_mass=PDG[\"Lambda(c)+\"].mass,\n",
+ " final_state_masses={\n",
+ " 0: PDG[\"p\"].mass,\n",
+ " 1: PDG[\"K-\"].mass,\n",
+ " 2: PDG[\"pi+\"].mass,\n",
+ " },\n",
+ ")\n",
+ "rng = TFUniformRealNumberGenerator(seed=0)\n",
+ "phsp_momenta = phsp_generator.generate(1_000_000, rng)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Generate transitions"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "jupyter": {
+ "source_hidden": true
+ },
+ "tags": [
+ "hide-cell"
+ ]
+ },
+ "outputs": [],
+ "source": [
+ "from qrules.particle import ParticleCollection, create_particle\n",
+ "\n",
+ "particle_db = ParticleCollection()\n",
+ "particle_db.add(PDG[\"Lambda(c)+\"])\n",
+ "particle_db.add(PDG[\"p\"])\n",
+ "particle_db.add(PDG[\"K-\"])\n",
+ "particle_db.add(PDG[\"pi+\"])\n",
+ "\n",
+ "particle_db.add(\n",
+ " create_particle(\n",
+ " PDG[\"K*(892)0\"],\n",
+ " name=\"K*\",\n",
+ " latex=\"K^*\",\n",
+ " )\n",
+ ")\n",
+ "particle_db.add(\n",
+ " create_particle(\n",
+ " PDG[\"Lambda(1405)\"],\n",
+ " name=\"Lambda*\",\n",
+ " latex=R\"\\Lambda^*\",\n",
+ " )\n",
+ ")\n",
+ "particle_db.add(\n",
+ " create_particle(\n",
+ " PDG[\"Delta(1232)++\"],\n",
+ " name=\"Delta*++\",\n",
+ " latex=R\"\\Delta^*\",\n",
+ " )\n",
+ ")"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "tags": []
+ },
+ "outputs": [],
+ "source": [
+ "reaction = qrules.generate_transitions(\n",
+ " initial_state=(\"Lambda(c)+\", [-0.5, +0.5]),\n",
+ " final_state=[\"p\", \"K-\", \"pi+\"],\n",
+ " formalism=\"helicity\",\n",
+ " particle_db=particle_db,\n",
+ ")"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "jupyter": {
+ "source_hidden": true
+ },
+ "tags": [
+ "hide-input",
+ "full-width"
+ ]
+ },
+ "outputs": [
+ {
+ "data": {
+ "image/svg+xml": [
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n"
+ ],
+ "text/plain": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "image/svg+xml": [
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n"
+ ],
+ "text/plain": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "image/svg+xml": [
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n"
+ ],
+ "text/plain": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "import graphviz\n",
+ "\n",
+ "n = len(reaction.transitions)\n",
+ "for t in reaction.transitions[:: n // 3]:\n",
+ " dot = qrules.io.asdot([t], collapse_graphs=True, size=3.5)\n",
+ " graph = graphviz.Source(dot)\n",
+ " display(graph)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Distribution without alignment"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Amplitude model formulated following [Appendix C](https://downloads.hindawi.com/journals/ahep/2020/6674595.pdf#page=13):"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "tags": []
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/latex": [
+ "$\\displaystyle \\sum_{m_{A}=-1/2}^{1/2} \\sum_{m_{0}=-1/2}^{1/2} \\sum_{m_{1}=0} \\sum_{m_{2}=0}{\\left|{{A^{01}}_{m_{A},m_{0},m_{1},m_{2}} + {A^{02}}_{m_{A},m_{0},m_{1},m_{2}} + {A^{12}}_{m_{A},m_{0},m_{1},m_{2}}}\\right|^{2}}$"
+ ],
+ "text/plain": [
+ "PoolSum(Abs(A^01[m_A, m0, m1, m2] + A^02[m_A, m0, m1, m2] + A^12[m_A, m0, m1, m2])**2, (m_A, (1/2, -1/2)), (m0, (1/2, -1/2)), (m1, (0,)), (m2, (0,)))"
+ ]
+ },
+ "execution_count": null,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "import ampform\n",
+ "from ampform.dynamics.builder import RelativisticBreitWignerBuilder\n",
+ "\n",
+ "builder = ampform.get_builder(reaction)\n",
+ "builder.align_spin = False\n",
+ "builder.stable_final_state_ids = list(reaction.final_state)\n",
+ "builder.scalar_initial_state_mass = True\n",
+ "bw_builder = RelativisticBreitWignerBuilder()\n",
+ "for name in reaction.get_intermediate_particles().names:\n",
+ " builder.set_dynamics(name, bw_builder)\n",
+ "standard_model = builder.formulate()\n",
+ "standard_model.intensity"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "jupyter": {
+ "source_hidden": true
+ },
+ "tags": [
+ "hide-input",
+ "full-width"
+ ]
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/latex": [
+ "$\\displaystyle \\begin{eqnarray}\n",
+ "{A^{01}}_{- \\frac{1}{2},- \\frac{1}{2},0,0} & = & \\frac{C_{\\Lambda_{c}^{+} \\to \\Lambda^*_{+1/2} \\pi^{+}_{0}; \\Lambda^* \\to K^{-}_{0} p_{+1/2}} \\Gamma_{\\Lambda^*} m_{\\Lambda^*} D^{\\frac{1}{2}}_{- \\frac{1}{2},\\frac{1}{2}}\\left(- \\phi_{01},\\theta_{01},0\\right) D^{\\frac{1}{2}}_{\\frac{1}{2},- \\frac{1}{2}}\\left(- \\phi^{01}_{0},\\theta^{01}_{0},0\\right)}{- i \\Gamma_{\\Lambda^*} m_{\\Lambda^*} - m_{01}^{2} + \\left(m_{\\Lambda^*}\\right)^{2}} \\nonumber\\\\\n",
+ "& & + \\frac{C_{\\Lambda_{c}^{+} \\to \\Lambda^*_{-1/2} \\pi^{+}_{0}; \\Lambda^* \\to K^{-}_{0} p_{+1/2}} \\Gamma_{\\Lambda^*} m_{\\Lambda^*} D^{\\frac{1}{2}}_{- \\frac{1}{2},- \\frac{1}{2}}\\left(- \\phi_{01},\\theta_{01},0\\right) D^{\\frac{1}{2}}_{- \\frac{1}{2},- \\frac{1}{2}}\\left(- \\phi^{01}_{0},\\theta^{01}_{0},0\\right)}{- i \\Gamma_{\\Lambda^*} m_{\\Lambda^*} - m_{01}^{2} + \\left(m_{\\Lambda^*}\\right)^{2}} \n",
+ "\\end{eqnarray}$"
+ ],
+ "text/plain": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/latex": [
+ "$\\displaystyle \\begin{eqnarray}\n",
+ "{A^{01}}_{- \\frac{1}{2},\\frac{1}{2},0,0} & = & \\frac{C_{\\Lambda_{c}^{+} \\to \\Lambda^*_{+1/2} \\pi^{+}_{0}; \\Lambda^* \\to K^{-}_{0} p_{+1/2}} \\Gamma_{\\Lambda^*} m_{\\Lambda^*} D^{\\frac{1}{2}}_{- \\frac{1}{2},\\frac{1}{2}}\\left(- \\phi_{01},\\theta_{01},0\\right) D^{\\frac{1}{2}}_{\\frac{1}{2},\\frac{1}{2}}\\left(- \\phi^{01}_{0},\\theta^{01}_{0},0\\right)}{- i \\Gamma_{\\Lambda^*} m_{\\Lambda^*} - m_{01}^{2} + \\left(m_{\\Lambda^*}\\right)^{2}} \\nonumber\\\\\n",
+ "& & + \\frac{C_{\\Lambda_{c}^{+} \\to \\Lambda^*_{-1/2} \\pi^{+}_{0}; \\Lambda^* \\to K^{-}_{0} p_{+1/2}} \\Gamma_{\\Lambda^*} m_{\\Lambda^*} D^{\\frac{1}{2}}_{- \\frac{1}{2},- \\frac{1}{2}}\\left(- \\phi_{01},\\theta_{01},0\\right) D^{\\frac{1}{2}}_{- \\frac{1}{2},\\frac{1}{2}}\\left(- \\phi^{01}_{0},\\theta^{01}_{0},0\\right)}{- i \\Gamma_{\\Lambda^*} m_{\\Lambda^*} - m_{01}^{2} + \\left(m_{\\Lambda^*}\\right)^{2}} \n",
+ "\\end{eqnarray}$"
+ ],
+ "text/plain": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/latex": [
+ "$\\displaystyle \\begin{eqnarray}\n",
+ "{A^{01}}_{\\frac{1}{2},- \\frac{1}{2},0,0} & = & \\frac{C_{\\Lambda_{c}^{+} \\to \\Lambda^*_{+1/2} \\pi^{+}_{0}; \\Lambda^* \\to K^{-}_{0} p_{+1/2}} \\Gamma_{\\Lambda^*} m_{\\Lambda^*} D^{\\frac{1}{2}}_{\\frac{1}{2},- \\frac{1}{2}}\\left(- \\phi^{01}_{0},\\theta^{01}_{0},0\\right) D^{\\frac{1}{2}}_{\\frac{1}{2},\\frac{1}{2}}\\left(- \\phi_{01},\\theta_{01},0\\right)}{- i \\Gamma_{\\Lambda^*} m_{\\Lambda^*} - m_{01}^{2} + \\left(m_{\\Lambda^*}\\right)^{2}} \\nonumber\\\\\n",
+ "& & + \\frac{C_{\\Lambda_{c}^{+} \\to \\Lambda^*_{-1/2} \\pi^{+}_{0}; \\Lambda^* \\to K^{-}_{0} p_{+1/2}} \\Gamma_{\\Lambda^*} m_{\\Lambda^*} D^{\\frac{1}{2}}_{- \\frac{1}{2},- \\frac{1}{2}}\\left(- \\phi^{01}_{0},\\theta^{01}_{0},0\\right) D^{\\frac{1}{2}}_{\\frac{1}{2},- \\frac{1}{2}}\\left(- \\phi_{01},\\theta_{01},0\\right)}{- i \\Gamma_{\\Lambda^*} m_{\\Lambda^*} - m_{01}^{2} + \\left(m_{\\Lambda^*}\\right)^{2}} \n",
+ "\\end{eqnarray}$"
+ ],
+ "text/plain": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/latex": [
+ "$\\displaystyle \\dots$"
+ ],
+ "text/plain": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "import sympy as sp\n",
+ "from IPython.display import Math, display\n",
+ "\n",
+ "for i, (symbol, expr) in enumerate(standard_model.amplitudes.items()):\n",
+ " if i == 3:\n",
+ " display(Math(R\"\\dots\"))\n",
+ " break\n",
+ " latex = sp.multiline_latex(symbol, expr, environment=\"eqnarray\")\n",
+ " display(Math(latex))"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Importing the parameter values given by [Table 1](https://downloads.hindawi.com/journals/ahep/2020/6674595.pdf#page=13):"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "jupyter": {
+ "source_hidden": true
+ },
+ "tags": [
+ "full-width",
+ "hide-cell"
+ ]
+ },
+ "outputs": [],
+ "source": [
+ "from ampform.helicity import HelicityModel\n",
+ "\n",
+ "# fmt: off\n",
+ "parameter_table = {\n",
+ " # K*\n",
+ " R\"C_{\\Lambda_{c}^{+} \\to K^*_{0} p_{+1/2}; K^* \\to K^{-}_{0} \\pi^{+}_{0}}\": 1,\n",
+ " R\"C_{\\Lambda_{c}^{+} \\to K^*_{+1} p_{+1/2}; K^* \\to K^{-}_{0} \\pi^{+}_{0}}\": 0.5 + 0.5j,\n",
+ " R\"C_{\\Lambda_{c}^{+} \\to K^*_{-1} p_{-1/2}; K^* \\to K^{-}_{0} \\pi^{+}_{0}}\": 1j,\n",
+ " R\"C_{\\Lambda_{c}^{+} \\to K^*_{0} p_{-1/2}; K^* \\to K^{-}_{0} \\pi^{+}_{0}}\": -0.5 - 0.5j,\n",
+ " \"m_{K^*}\": 0.9, # GeV\n",
+ " R\"\\Gamma_{K^*}\": 0.2, # GeV\n",
+ " # Λ*\n",
+ " R\"C_{\\Lambda_{c}^{+} \\to \\Lambda^*_{-1/2} \\pi^{+}_{0}; \\Lambda^* \\to K^{-}_{0} p_{+1/2}}\": 1j,\n",
+ " R\"C_{\\Lambda_{c}^{+} \\to \\Lambda^*_{+1/2} \\pi^{+}_{0}; \\Lambda^* \\to K^{-}_{0} p_{+1/2}}\": 0.8 - 0.4j,\n",
+ " R\"m_{\\Lambda^*}\": 1.6, # GeV\n",
+ " R\"\\Gamma_{\\Lambda^*}\": 0.2, # GeV\n",
+ " # Δ*\n",
+ " R\"C_{\\Lambda_{c}^{+} \\to \\Delta^*_{+1/2} K^{-}_{0}; \\Delta^* \\to p_{+1/2} \\pi^{+}_{0}}\": 0.6 - 0.4j,\n",
+ " R\"C_{\\Lambda_{c}^{+} \\to \\Delta^*_{-1/2} K^{-}_{0}; \\Delta^* \\to p_{+1/2} \\pi^{+}_{0}}\": 0.1j,\n",
+ " R\"m_{\\Delta^*}\": 1.4, # GeV\n",
+ " R\"\\Gamma_{\\Delta^*}\": 0.2, # GeV\n",
+ "}\n",
+ "# fmt: on\n",
+ "\n",
+ "\n",
+ "def set_coefficients(model: HelicityModel) -> None:\n",
+ " for name, value in parameter_table.items():\n",
+ " model.parameter_defaults[name] = value"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "jupyter": {
+ "source_hidden": true
+ },
+ "tags": [
+ "hide-input"
+ ]
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/latex": [
+ "$\\displaystyle \\begin{array}{lc}\n",
+ " C_{\\Lambda_{c}^{+} \\to K^*_{0} p_{+1/2}; K^* \\to K^{-}_{0} \\pi^{+}_{0}} & 1 \\\\\n",
+ " C_{\\Lambda_{c}^{+} \\to K^*_{+1} p_{+1/2}; K^* \\to K^{-}_{0} \\pi^{+}_{0}} & 0.5+0.5i \\\\\n",
+ " C_{\\Lambda_{c}^{+} \\to K^*_{-1} p_{-1/2}; K^* \\to K^{-}_{0} \\pi^{+}_{0}} & 1i \\\\\n",
+ " C_{\\Lambda_{c}^{+} \\to K^*_{0} p_{-1/2}; K^* \\to K^{-}_{0} \\pi^{+}_{0}} & -0.5-0.5i \\\\\n",
+ " m_{K^*} & 0.9 \\\\\n",
+ " \\Gamma_{K^*} & 0.2 \\\\\n",
+ " C_{\\Lambda_{c}^{+} \\to \\Lambda^*_{-1/2} \\pi^{+}_{0}; \\Lambda^* \\to K^{-}_{0} p_{+1/2}} & 1i \\\\\n",
+ " C_{\\Lambda_{c}^{+} \\to \\Lambda^*_{+1/2} \\pi^{+}_{0}; \\Lambda^* \\to K^{-}_{0} p_{+1/2}} & 0.8-0.4i \\\\\n",
+ " m_{\\Lambda^*} & 1.6 \\\\\n",
+ " \\Gamma_{\\Lambda^*} & 0.2 \\\\\n",
+ " C_{\\Lambda_{c}^{+} \\to \\Delta^*_{+1/2} K^{-}_{0}; \\Delta^* \\to p_{+1/2} \\pi^{+}_{0}} & 0.6-0.4i \\\\\n",
+ " C_{\\Lambda_{c}^{+} \\to \\Delta^*_{-1/2} K^{-}_{0}; \\Delta^* \\to p_{+1/2} \\pi^{+}_{0}} & 0.1i \\\\\n",
+ " m_{\\Delta^*} & 1.4 \\\\\n",
+ " \\Gamma_{\\Delta^*} & 0.2 \\\\\n",
+ "\\end{array}$"
+ ],
+ "text/plain": [
+ ""
+ ]
+ },
+ "execution_count": null,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "set_coefficients(standard_model)\n",
+ "\n",
+ "latex = R\"\\begin{array}{lc}\" + \"\\n\"\n",
+ "for par_name, value in parameter_table.items():\n",
+ " value = str(value).lstrip(\"(\").rstrip(\")\").replace(\"j\", \"i\")\n",
+ " symbol = sp.Symbol(par_name)\n",
+ " latex += Rf\" {sp.latex(symbol)} & {value} \\\\\" + \"\\n\"\n",
+ "latex += R\"\\end{array}\"\n",
+ "Math(latex)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "tags": []
+ },
+ "source": [
+ "### Generate data"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "jupyter": {
+ "source_hidden": true
+ },
+ "tags": [
+ "hide-cell"
+ ]
+ },
+ "outputs": [],
+ "source": [
+ "import matplotlib.pyplot as plt\n",
+ "import numpy as np\n",
+ "from tensorwaves.data import SympyDataTransformer\n",
+ "from tensorwaves.function.sympy import create_function\n",
+ "\n",
+ "\n",
+ "def compute_sub_intensities(\n",
+ " model: HelicityModel, resonance_name: str, phsp, full_expression\n",
+ ") -> np.ndarray:\n",
+ " parameter_values = {}\n",
+ " for symbol, value in model.parameter_defaults.items():\n",
+ " if resonance_name not in symbol.name and symbol.name.startswith(\"C\"):\n",
+ " parameter_values[symbol] = 0\n",
+ " else:\n",
+ " parameter_values[symbol] = value\n",
+ " sub_expression = full_expression.subs(parameter_values)\n",
+ " sub_intensity = create_function(sub_expression, backend=\"jax\")\n",
+ " return np.array(sub_intensity(phsp).real)\n",
+ "\n",
+ "\n",
+ "def plot_distributions(model: HelicityModel) -> None:\n",
+ " helicity_transformer = SympyDataTransformer.from_sympy(\n",
+ " model.kinematic_variables, backend=\"jax\"\n",
+ " )\n",
+ " phsp = helicity_transformer(phsp_momenta)\n",
+ " phsp = {k: v.real for k, v in phsp.items()}\n",
+ "\n",
+ " full_expression = model.expression.doit()\n",
+ " substituted_expression = full_expression.xreplace(model.parameter_defaults)\n",
+ " intensity_func = create_function(substituted_expression, backend=\"jax\")\n",
+ " intensities_all = np.array(intensity_func(phsp).real)\n",
+ " intensities_k = compute_sub_intensities(\n",
+ " model, \"K^*\", phsp, full_expression\n",
+ " )\n",
+ " intensities_delta = compute_sub_intensities(\n",
+ " model, \"Delta^*\", phsp, full_expression\n",
+ " )\n",
+ " intensities_lambda = compute_sub_intensities(\n",
+ " model, \"Lambda^*\", phsp, full_expression\n",
+ " )\n",
+ "\n",
+ " fig, ax = plt.subplots(nrows=2, ncols=3, figsize=(8, 5))\n",
+ " hist_kwargs = dict(\n",
+ " bins=80,\n",
+ " histtype=\"step\",\n",
+ " )\n",
+ "\n",
+ " for x in ax.flatten():\n",
+ " x.set_yticks([])\n",
+ "\n",
+ " ax[0, 0].set_xlabel(\"$m^2(pK^-)$ [GeV$^2/c^4$]\")\n",
+ " ax[0, 1].set_xlabel(R\"$m^2(K^-\\pi^+)$ [GeV$^2/c^4$]\")\n",
+ " ax[0, 2].set_xlabel(R\"$m^2(p\\pi^+)$ [GeV$^2/c^4$]\")\n",
+ " ax[1, 0].set_xlabel(R\"$\\cos\\theta(p)$\")\n",
+ " ax[1, 1].set_xlabel(R\"$\\phi(p)$\")\n",
+ " ax[1, 2].set_xlabel(R\"$\\chi$\")\n",
+ "\n",
+ " for x, xticks in {\n",
+ " ax[0, 0]: [2, 2.5, 3, 3.5, 4, 4.5],\n",
+ " ax[0, 1]: [0.4, 0.6, 0.8, 1, 1.2, 1.4, 1.6, 1.8, 2],\n",
+ " ax[0, 2]: [1, 1.5, 2, 2.5, 3],\n",
+ " ax[1, 0]: [-1, -0.5, 0, 0.5, 1],\n",
+ " ax[1, 1]: [-3, -2, -1, 0, 1, 2, 3],\n",
+ " }.items():\n",
+ " x.set_xticks(xticks)\n",
+ " x.set_xticklabels(xticks)\n",
+ "\n",
+ " for weights, color, label in [\n",
+ " (intensities_all, \"red\", \"Model\"),\n",
+ " (intensities_k, \"orange\", R\"$K^*\\to\\,K^{^-}\\pi^+$\"),\n",
+ " (intensities_delta, \"brown\", R\"$\\Delta^{*^{++}} \\to\\,p\\pi^+$\"),\n",
+ " (intensities_lambda, \"purple\", R\"$\\Lambda^* \\to\\,p K^{^-}$\"),\n",
+ " ]:\n",
+ " kwargs = dict(weights=weights, color=color, **hist_kwargs)\n",
+ " ax[0, 0].hist(np.array(phsp[\"m_01\"] ** 2), **kwargs)\n",
+ " ax[0, 1].hist(np.array(phsp[\"m_12\"] ** 2), **kwargs)\n",
+ " ax[0, 2].hist(np.array(phsp[\"m_02\"] ** 2), **kwargs)\n",
+ " ax[1, 0].hist(np.array(np.cos(phsp[\"theta_01\"])), **kwargs)\n",
+ " ax[1, 1].hist(np.array(phsp[\"phi_01\"]), **kwargs, label=label)\n",
+ "\n",
+ " ax[1, 2].remove()\n",
+ " handles, labels = ax[1, 1].get_legend_handles_labels()\n",
+ " fig.legend(handles, labels, loc=\"lower right\")\n",
+ "\n",
+ " ax[0, 2].set_xlim(1, 3.4)\n",
+ " ax[1, 0].set_xlim(-1, +1)\n",
+ " ax[1, 1].set_xlim(-np.pi, +np.pi)\n",
+ "\n",
+ " fig.tight_layout()\n",
+ "\n",
+ " plt.show()"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "```{autolink-skip}\n",
+ "```"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "tags": [
+ "hide-input"
+ ]
+ },
+ "outputs": [
+ {
+ "data": {
+ "image/svg+xml": [
+ "\n",
+ "\n",
+ "\n"
+ ],
+ "text/plain": [
+ "