Note
Go to the end to download the full example code
Particle and amplitude
Amplitude = DecayGroup + Variable
We will use following parameters for a toy model
11 from tf_pwa.amp import DecayChain, DecayGroup, get_decay, get_particle
12
13 resonances = {
14 "R0": {"J": 0, "P": 1, "mass": 1.0, "width": 0.07},
15 "R1": {"J": 0, "P": 1, "mass": 1.0, "width": 0.07},
16 "R2": {"J": 1, "P": -1, "mass": 1.225, "width": 0.08},
17 }
18
19 a, b, c, d = [get_particle(i, J=0, P=-1) for i in "ABCD"]
20 r1, r2, r3 = [get_particle(i, **resonances[i]) for i in resonances.keys()]
21
22
23 decay_group = DecayGroup(
24 [
25 DecayChain([get_decay(a, [r1, c]), get_decay(r1, [b, d])]),
26 DecayChain([get_decay(a, [r2, b]), get_decay(r2, [c, d])]),
27 DecayChain([get_decay(a, [r3, b]), get_decay(r3, [c, d])]),
28 ]
29 )
The above parts can be represented as config.yml used by ConfigLoader.
We can get AmplitudeModel form decay_group and a optional Variables Managerager. It has parameters, so we can get and set parameters for the amplitude model
36 from tf_pwa.amp import AmplitudeModel
37 from tf_pwa.variable import VarsManager
38
39 vm = VarsManager()
40 amp = AmplitudeModel(decay_group, vm=vm)
41
42 print(amp.get_params())
43 amp.set_params(
44 {
45 "A->R0.CR0->B.D_total_0r": 1.0,
46 "A->R1.BR1->C.D_total_0r": 1.0,
47 "A->R2.BR2->C.D_total_0r": 7.0,
48 }
49 )
{'R0_mass': 1.0, 'R0_width': 0.07, 'R1_mass': 1.0, 'R1_width': 0.07, 'R2_mass': 1.225, 'R2_width': 0.08, 'A->R0.CR0->B.D_total_0r': 1.5267913726088826, 'A->R0.CR0->B.D_total_0i': 1.6007037254093834, 'A->R0.C_g_ls_0r': 1.0, 'A->R0.C_g_ls_0i': 0.0, 'R0->B.D_g_ls_0r': 1.0, 'R0->B.D_g_ls_0i': 0.0, 'A->R1.BR1->C.D_total_0r': 1.265649500299637, 'A->R1.BR1->C.D_total_0i': -0.9887225171831009, 'A->R1.B_g_ls_0r': 1.0, 'A->R1.B_g_ls_0i': 0.0, 'R1->C.D_g_ls_0r': 1.0, 'R1->C.D_g_ls_0i': 0.0, 'A->R2.BR2->C.D_total_0r': 0.43149508905352363, 'A->R2.BR2->C.D_total_0i': -1.4064771049968967, 'A->R2.B_g_ls_0r': 1.0, 'A->R2.B_g_ls_0i': 0.0, 'R2->C.D_g_ls_0r': 1.0, 'R2->C.D_g_ls_0i': 0.0}
For the calculation, we generate some phase space data.
and the calculate helicity angle from the data
62 from tf_pwa.cal_angle import cal_angle_from_momentum
63
64 data = cal_angle_from_momentum({b: p1, c: p2, d: p3}, decay_group)
we can index mass from data as
69 from tf_pwa.data import data_index
70
71 m_bd = data_index(data, ("particle", "(B, D)", "m"))
72 # m_bc = data_index(data, ("particle", "(B, C)", "m"))
73 m_cd = data_index(data, ("particle", "(C, D)", "m"))
Note
If DecayGroup do not include resonant of (B, C), the data will not include its mass too. We can use different DecayGroup for cal_angle and AmplitudeModel when they have the same initial and final particle.
The amplitde square is calculated by amplitude model simply as
83 amp_s2 = amp(data)
/home/docs/checkouts/readthedocs.org/user_builds/tf-pwa/checkouts/latest/docs/../tf_pwa/amp/core.py:822: UserWarning: no mass for particle A, set it to 1.8000000229221869
warnings.warn(
/home/docs/checkouts/readthedocs.org/user_builds/tf-pwa/checkouts/latest/docs/../tf_pwa/amp/core.py:822: UserWarning: no mass for particle C, set it to 0.17999999999999977
warnings.warn(
/home/docs/checkouts/readthedocs.org/user_builds/tf-pwa/checkouts/latest/docs/../tf_pwa/amp/core.py:822: UserWarning: no mass for particle B, set it to 0.17999999999999977
warnings.warn(
/home/docs/checkouts/readthedocs.org/user_builds/tf-pwa/checkouts/latest/docs/../tf_pwa/amp/core.py:822: UserWarning: no mass for particle D, set it to 0.17999999999999977
warnings.warn(
Now by using matplotlib we can get the Dalitz plot as
88 import matplotlib.pyplot as plt
89
90 plt.clf()
91 plt.hist2d(
92 m_bd.numpy() ** 2,
93 m_cd.numpy() ** 2,
94 weights=amp_s2.numpy(),
95 bins=60,
96 cmin=1,
97 cmap="jet",
98 )
99 plt.colorbar()
100 plt.xlabel("$m^2(BD)$")
101 plt.ylabel("$m^2(CD)$")
102 plt.show()
Total running time of the script: (0 minutes 2.843 seconds)