Skip to content

Commit 022c7f1

Browse files
authored
docs: use Chew-Mandelstam in analytic continuation (#425)
* chore: bump python kernel version * docs: simplify distribution plotting - No need to generate hit-and-miss data - Removed need to import pandas - Merged plotting cells * docs: reduce coupling for sub-threshold resonance * docs: set all resonances in 02 decay chain * docs: switch to Chew-Mandelstam phase space factor
1 parent c82dc3d commit 022c7f1

File tree

1 file changed

+36
-36
lines changed

1 file changed

+36
-36
lines changed

docs/amplitude-analysis/analytic-continuation.ipynb

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,10 @@
8585
"import ampform\n",
8686
"import graphviz\n",
8787
"import matplotlib.pyplot as plt\n",
88-
"import pandas as pd\n",
8988
"import qrules\n",
9089
"from IPython.display import Math\n",
9190
"\n",
9291
"from tensorwaves.data import (\n",
93-
" IntensityDistributionGenerator,\n",
9492
" SympyDataTransformer,\n",
9593
" TFPhaseSpaceGenerator,\n",
9694
" TFUniformRealNumberGenerator,\n",
@@ -120,7 +118,7 @@
120118
"reaction = qrules.generate_transitions(\n",
121119
" initial_state=\"D0\",\n",
122120
" final_state=[\"K-\", \"K+\", \"K0\"],\n",
123-
" allowed_intermediate_particles=[\"a(0)(980)0\", \"a(2)(1320)+\"],\n",
121+
" allowed_intermediate_particles=[\"a(0)(980)0\", \"a(2)(1320)0\"],\n",
124122
" formalism=\"canonical-helicity\",\n",
125123
")\n",
126124
"dot = qrules.io.asdot(\n",
@@ -172,7 +170,7 @@
172170
"cell_type": "markdown",
173171
"metadata": {},
174172
"source": [
175-
"To correctly describe the dynamics for this resonance, we should use make use of {doc}`analytic continuation <ampform:usage/dynamics/analytic-continuation>`. As opposed to {ref}`compwa-step-1`, we now use {func}`~ampform.dynamics.builder.create_analytic_breit_wigner` (a relativistic Breit-Wigner with analytic continuation) instead of {func}`~ampform.dynamics.builder.create_relativistic_breit_wigner_with_ff`:"
173+
"To correctly describe the dynamics for this resonance, we should use make use of {doc}`analytic continuation <ampform:usage/dynamics/analytic-continuation>`. As opposed to {ref}`compwa-step-1`, we now construct a {class}`~ampform.dynamics.builder.RelativisticBreitWignerBuilder` where we set its phase space factor to {class}`~ampform.dynamics.phasespace.PhaseSpaceFactorSWave`:"
176174
]
177175
},
178176
{
@@ -181,23 +179,29 @@
181179
"metadata": {},
182180
"outputs": [],
183181
"source": [
182+
"from ampform.dynamics import PhaseSpaceFactorSWave\n",
184183
"from ampform.dynamics.builder import (\n",
185-
" create_analytic_breit_wigner,\n",
184+
" RelativisticBreitWignerBuilder,\n",
186185
" create_non_dynamic_with_ff,\n",
187186
" create_relativistic_breit_wigner_with_ff,\n",
188187
")\n",
189188
"\n",
190189
"model_builder = ampform.get_builder(reaction)\n",
190+
"analytic_breit_wigner_builder = RelativisticBreitWignerBuilder(\n",
191+
" form_factor=True,\n",
192+
" energy_dependent_width=True,\n",
193+
" phsp_factor=PhaseSpaceFactorSWave,\n",
194+
")\n",
191195
"model_builder.set_dynamics(\n",
192196
" \"J/psi(1S)\",\n",
193197
" create_non_dynamic_with_ff,\n",
194198
")\n",
195199
"model_builder.set_dynamics(\n",
196200
" \"a(0)(980)0\",\n",
197-
" create_analytic_breit_wigner,\n",
201+
" analytic_breit_wigner_builder,\n",
198202
")\n",
199203
"model_builder.set_dynamics(\n",
200-
" \"a(2)(1320)+\",\n",
204+
" \"a(2)(1320)0\",\n",
201205
" create_relativistic_breit_wigner_with_ff,\n",
202206
")\n",
203207
"model = model_builder.formulate()"
@@ -207,6 +211,12 @@
207211
"cell_type": "markdown",
208212
"metadata": {},
209213
"source": [
214+
":::{margin}\n",
215+
"\n",
216+
"Note that we have reduced the coupling for the sub-threshold resonance $a_0(980)^0$, so that it doesn't dominate over $$\n",
217+
"\n",
218+
":::\n",
219+
"\n",
210220
"The effect can be seen once we generate data. Despite the fact that the resonance lies outside phase space, there is still a contribution to the intensity:"
211221
]
212222
},
@@ -216,6 +226,11 @@
216226
"metadata": {},
217227
"outputs": [],
218228
"source": [
229+
"for par in model.parameter_defaults:\n",
230+
" if not par.name.startswith(\"C\") or \"a_{0}(980)^{0}\" not in par.name:\n",
231+
" continue\n",
232+
" model.parameter_defaults[par] = 0.1\n",
233+
"\n",
219234
"intensity = create_parametrized_function(\n",
220235
" expression=model.expression.doit(),\n",
221236
" parameters=model.parameter_defaults,\n",
@@ -229,12 +244,7 @@
229244
" initial_state_mass=reaction.initial_state[-1].mass,\n",
230245
" final_state_masses={i: p.mass for i, p in reaction.final_state.items()},\n",
231246
")\n",
232-
"data_generator = IntensityDistributionGenerator(\n",
233-
" domain_generator=phsp_generator,\n",
234-
" function=intensity,\n",
235-
" domain_transformer=helicity_transformer,\n",
236-
")\n",
237-
"data_momenta = data_generator.generate(2_000, rng)"
247+
"phsp_momenta = phsp_generator.generate(100_000, rng)"
238248
]
239249
},
240250
{
@@ -245,42 +255,32 @@
245255
"source_hidden": true
246256
},
247257
"tags": [
248-
"hide-cell"
258+
"hide-input"
249259
]
250260
},
251261
"outputs": [],
252262
"source": [
253263
"import numpy as np\n",
254264
"from matplotlib import cm\n",
255265
"\n",
266+
"phsp = helicity_transformer(phsp_momenta)\n",
267+
"intensities = np.array(intensity(phsp))\n",
268+
"\n",
256269
"resonances = sorted(\n",
257270
" reaction.get_intermediate_particles(),\n",
258271
" key=lambda p: p.mass,\n",
259272
")\n",
260-
"\n",
261273
"evenly_spaced_interval = np.linspace(0, 1, len(resonances))\n",
262274
"colors = [cm.rainbow(x) for x in evenly_spaced_interval]\n",
263275
"\n",
264-
"\n",
265-
"def indicate_masses():\n",
266-
" plt.xlabel(\"$m_{02}$ [GeV]\")\n",
267-
" for i, p in enumerate(resonances):\n",
268-
" plt.gca().axvline(\n",
269-
" x=p.mass, linestyle=\"dotted\", label=p.name, color=colors[i]\n",
270-
" )"
271-
]
272-
},
273-
{
274-
"cell_type": "code",
275-
"execution_count": null,
276-
"metadata": {},
277-
"outputs": [],
278-
"source": [
279-
"data = helicity_transformer(data_momenta)\n",
280-
"data_frame = pd.DataFrame(data)\n",
281-
"data_frame[\"m_02\"].hist(bins=50, alpha=0.5, density=True)\n",
282-
"indicate_masses()\n",
283-
"plt.legend();"
276+
"fig, ax = plt.subplots()\n",
277+
"ax.set_xlabel(\"$m_{02}$ [GeV]\")\n",
278+
"for p, color in zip(resonances, colors):\n",
279+
" ax.axvline(x=p.mass, linestyle=\"dotted\", label=p.name, color=color)\n",
280+
"ax.set_yticks([])\n",
281+
"ax.hist(phsp[\"m_02\"], bins=100, alpha=0.5, weights=intensities)\n",
282+
"ax.legend()\n",
283+
"plt.show()"
284284
]
285285
}
286286
],
@@ -292,7 +292,7 @@
292292
},
293293
"language_info": {
294294
"name": "python",
295-
"version": "3.8.12"
295+
"version": "3.8.13"
296296
}
297297
},
298298
"nbformat": 4,

0 commit comments

Comments
 (0)