Skip to content

Commit

Permalink
ENH: add charge to PID and identify particle b
Browse files Browse the repository at this point in the history
  • Loading branch information
redeboer committed Sep 9, 2023
1 parent 6fd534e commit 559a662
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 15 deletions.
1 change: 1 addition & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"editorconfig.editorconfig",
"esbenp.prettier-vscode",
"executablebookproject.myst-highlight",
"github.vscode-github-actions",
"github.vscode-pull-request-github",
"mhutchie.git-graph",
"ms-python.python",
Expand Down
52 changes: 37 additions & 15 deletions lecture2.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@
"outputs": [],
"source": [
"n_final_state = 3\n",
"pa, p1, p2, p3 = (data[i::4].T for i in range(n_final_state + 1))"
"pa, p1, p2, p3 = (data[i::4].T for i in range(n_final_state + 1))\n",
"p0 = p1 + p2 + p3\n",
"pb = p0 - pa"
]
},
{
Expand All @@ -120,6 +122,9 @@
"id": "a0b70dc7-a087-4b43-a08c-f48840a2c6a3",
"metadata": {
"editable": true,
"jupyter": {
"source_hidden": true
},
"slideshow": {
"slide_type": ""
},
Expand All @@ -135,7 +140,6 @@
" return p[0] ** 2 - np.sum(p[1:] ** 2, axis=0)\n",
"\n",
"\n",
"p0 = p1 + p2 + p3\n",
"m0 = mass(p0)\n",
"print(f\"{m0.mean():.4g} +/- {m0.std():.4g}\")"
]
Expand All @@ -160,10 +164,10 @@
"source": [
"from IPython.display import Math\n",
"\n",
"display(Math(Rf\"m_a = {mass(pa).mean():.3g}\\text{{ GeV}}\"))\n",
"display(Math(Rf\"m_b = {mass(pb).mean():.3g}\\text{{ GeV}}\"))\n",
"for i, p in enumerate([p0, p1, p2, p3]):\n",
" display(Math(Rf\"m_{i} = {mass(p).mean():.3g}\\text{{ GeV}}\"))\n",
"\n",
"display(Math(Rf\"m_{{a}} = {mass(pa).mean():.3g}\\text{{ GeV}}\"))"
" display(Math(Rf\"m_{i} = {mass(p).mean():.3g}\\text{{ GeV}}\"))"
]
},
{
Expand All @@ -190,17 +194,35 @@
"from particle import Particle\n",
"\n",
"\n",
"def find_candidates(m: float, delta: float = 0.001) -> list[Particle]:\n",
" return Particle.findall(lambda p: (m - delta) < 1e-3 * p.mass < (m + delta))\n",
"def find_candidates(\n",
" mass: float, delta: float = 0.001, charge: float | None = None\n",
") -> list[Particle]:\n",
" def identify(p) -> bool:\n",
" if p.pdgid in {21}:\n",
" return\n",
" if charge is not None and p.charge != charge:\n",
" return False\n",
" if (mass - delta) < 1e-3 * p.mass < (mass + delta):\n",
" return True\n",
" return False\n",
"\n",
" return Particle.findall(identify)\n",
"\n",
"\n",
"ma = mass(pa).mean()\n",
"mb = mass(pb).mean()\n",
"m1 = mass(p1).mean()\n",
"m2 = mass(p2).mean()\n",
"m3 = mass(p3).mean()\n",
"particles = tuple(find_candidates(m.mean())[0] for m in [m1, m2, m3])\n",
"\n",
"src = R\"\\text{Final state: }\" + \", \".join(f\"{p.latex_name}\" for p in particles)\n",
"Math(src)"
"initial_state = (\n",
" find_candidates(ma.mean(), delta=1e-4)[0],\n",
" find_candidates(mb.mean())[0],\n",
")\n",
"final_state = tuple(find_candidates(m.mean())[0] for m in [m1, m2, m3])\n",
"display(\n",
" Math(R\"\\text{Incoming: }\" + \", \".join(f\"{p.latex_name}\" for p in initial_state)),\n",
" Math(R\"\\text{Outgoing: }\" + \", \".join(f\"{p.latex_name}\" for p in final_state)),\n",
")"
]
},
{
Expand All @@ -214,7 +236,7 @@
"tags": []
},
"source": [
"So this is probably some photon&nbsp;$\\gamma$ hitting a target that produces a meson&nbsp;$\\eta$, pion&nbsp;$\\pi^0$, and proton&nbsp;$p$."
"So this is a photon&nbsp;$\\gamma$ hitting a proton&nbsp;$p$ and producing a meson&nbsp;$\\eta$, pion&nbsp;$\\pi^0$, and proton&nbsp;$p$."
]
},
{
Expand Down Expand Up @@ -457,7 +479,7 @@
},
"outputs": [],
"source": [
"find_candidates(m=np.sqrt(R12), delta=0.01)"
"find_candidates(mass=np.sqrt(R12), delta=0.01, charge=0)"
]
},
{
Expand All @@ -473,7 +495,7 @@
},
"outputs": [],
"source": [
"find_candidates(m=np.sqrt(R23), delta=0.01)"
"find_candidates(mass=np.sqrt(R23), delta=0.01, charge=+1)"
]
},
{
Expand All @@ -489,7 +511,7 @@
},
"outputs": [],
"source": [
"find_candidates(m=np.sqrt(R31), delta=0.01)"
"find_candidates(mass=np.sqrt(R31), delta=0.01, charge=+1)"
]
},
{
Expand Down

0 comments on commit 559a662

Please sign in to comment.