-
Notifications
You must be signed in to change notification settings - Fork 5
/
lorentz.py
618 lines (489 loc) · 20.2 KB
/
lorentz.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
"""Symbolic implementations for Lorentz vectors and boosts."""
from __future__ import annotations
from typing import TYPE_CHECKING, Any, Callable, Dict
import sympy as sp
from ampform.helicity.decay import determine_attached_final_state, list_decay_chain_ids
from ampform.sympy import ExprClass, NumPyPrintable, unevaluated
from ampform.sympy._array_expressions import (
ArrayAxisSum,
ArrayMultiplication,
ArraySlice,
ArraySum,
ArraySymbol,
)
from ampform.sympy.math import ComplexSqrt
if TYPE_CHECKING:
from qrules.topology import Topology
from sympy.printing.latex import LatexPrinter
from sympy.printing.numpy import NumPyPrinter
def create_four_momentum_symbols(topology: Topology) -> FourMomenta:
"""Create a set of array-symbols for a `~qrules.topology.Topology`.
>>> from qrules.topology import create_isobar_topologies
>>> topologies = create_isobar_topologies(3)
>>> create_four_momentum_symbols(topologies[0])
{0: p0, 1: p1, 2: p2}
"""
final_state_ids = sorted(topology.outgoing_edge_ids)
return {i: create_four_momentum_symbol(i) for i in final_state_ids}
def create_four_momentum_symbol(index: int) -> FourMomentumSymbol:
return FourMomentumSymbol(f"p{index}", shape=[])
FourMomenta = Dict[int, "FourMomentumSymbol"]
"""A mapping of state IDs to their corresponding `.FourMomentumSymbol`.
It's best to create a `dict` of `.FourMomenta` with
:func:`create_four_momentum_symbols`.
"""
FourMomentumSymbol = ArraySymbol
r"""Array-`~sympy.core.symbol.Symbol` that represents an array of four-momenta.
The array is assumed to be of shape :math:`n\times 4` with :math:`n` the number of
events. The four-momenta are assumed to be in the order :math:`\left(E,\vec{p}\right)`.
See also `Energy`, `FourMomentumX`, `FourMomentumY`, and `FourMomentumZ`.
"""
@unevaluated
class Energy(sp.Expr):
"""Represents the energy-component of a `.FourMomentumSymbol`."""
momentum: sp.Basic
_latex_repr_ = R"E\left({momentum}\right)"
def evaluate(self) -> ArraySlice:
return ArraySlice(self.momentum, (slice(None), 0))
def _implement_latex_subscript( # pyright: ignore[reportUnusedFunction]
subscript: str,
) -> Callable[[type[ExprClass]], type[ExprClass]]:
def decorator(decorated_class: type[ExprClass]) -> type[ExprClass]:
def _latex_repr_(self: sp.Expr, printer: LatexPrinter, *args) -> str:
momentum = printer._print(self.momentum) # type: ignore[attr-defined]
if printer._needs_mul_brackets(self.momentum): # type: ignore[attr-defined]
momentum = Rf"\left({momentum}\right)"
else:
momentum = Rf"{{{momentum}}}"
return f"{momentum}_{subscript}"
decorated_class._latex_repr_ = _latex_repr_ # type: ignore[assignment,attr-defined]
return decorated_class
return decorator
@unevaluated
@_implement_latex_subscript(subscript="x")
class FourMomentumX(sp.Expr):
"""Component :math:`x` of a `.FourMomentumSymbol`."""
momentum: sp.Basic
def evaluate(self) -> ArraySlice:
return ArraySlice(self.momentum, (slice(None), 1))
@unevaluated
@_implement_latex_subscript(subscript="y")
class FourMomentumY(sp.Expr):
"""Component :math:`y` of a `.FourMomentumSymbol`."""
momentum: sp.Basic
def evaluate(self) -> ArraySlice:
return ArraySlice(self.momentum, (slice(None), 2))
@unevaluated
@_implement_latex_subscript(subscript="z")
class FourMomentumZ(sp.Expr):
"""Component :math:`z` of a `.FourMomentumSymbol`."""
momentum: sp.Basic
def evaluate(self) -> ArraySlice:
return ArraySlice(self.momentum, (slice(None), 3))
@unevaluated
class ThreeMomentum(NumPyPrintable):
"""Spatial components of a `.FourMomentumSymbol`."""
momentum: sp.Basic
_latex_repr_ = R"\vec{{{momentum}}}"
def evaluate(self) -> ArraySlice:
return ArraySlice(self.momentum, (slice(None), slice(1, None)))
def _numpycode(self, printer: NumPyPrinter, *args) -> str:
return printer._print(self.evaluate())
@unevaluated
class EuclideanNorm(NumPyPrintable):
"""Take the euclidean norm of an array over axis 1."""
vector: sp.Basic
_latex_repr_ = R"\left|{vector}\right|"
def evaluate(self) -> ArraySlice:
return sp.sqrt(EuclideanNormSquared(self.vector))
def _numpycode(self, printer: NumPyPrinter, *args) -> str:
return printer._print(self.evaluate(), *args)
@unevaluated
class EuclideanNormSquared(sp.Expr):
"""Take the squared euclidean norm of an array over axis 1."""
vector: sp.Basic
_latex_repr_ = R"\left|{vector}\right|^{{2}}"
def evaluate(self) -> ArrayAxisSum:
return ArrayAxisSum(self.vector**2, axis=1) # type: ignore[operator]
def _numpycode(self, printer: NumPyPrinter, *args) -> str:
return printer._print(self.evaluate(), *args)
def three_momentum_norm(momentum: sp.Basic) -> EuclideanNorm:
return EuclideanNorm(ThreeMomentum(momentum))
@unevaluated
class InvariantMass(sp.Expr):
"""Invariant mass of a `.FourMomentumSymbol`."""
momentum: sp.Basic
_latex_repr_ = "m_{{{momentum}}}"
def evaluate(self) -> ComplexSqrt:
p = self.momentum
p_xyz = ThreeMomentum(p)
return ComplexSqrt(Energy(p) ** 2 - EuclideanNorm(p_xyz) ** 2)
@unevaluated
class NegativeMomentum(sp.Expr):
r"""Invert the spatial components of a `.FourMomentumSymbol`."""
momentum: sp.Basic
_latex_repr_ = R"-\left({momentum}\right)"
def evaluate(self) -> sp.Expr:
p = self.momentum
eta = MinkowskiMetric(p)
return ArrayMultiplication(eta, p)
@unevaluated(implement_doit=False)
class MinkowskiMetric(NumPyPrintable):
r"""Minkowski metric :math:`\eta = (1, -1, -1, -1)`."""
momentum: sp.Basic
_latex_repr_ = R"\boldsymbol{\eta}"
def as_explicit(self) -> sp.MutableDenseMatrix: # noqa: PLR6301
return sp.Matrix([
[1, 0, 0, 0],
[0, -1, 0, 0],
[0, 0, -1, 0],
[0, 0, 0, -1],
])
def _numpycode(self, printer: NumPyPrinter, *args) -> str:
printer.module_imports[printer._module].update({"array", "ones", "zeros"})
momentum = printer._print(self.momentum)
n_events = f"len({momentum})"
zeros = f"zeros({n_events})"
ones = f"ones({n_events})"
return f"""array(
[
[{ones}, {zeros}, {zeros}, {zeros}],
[{zeros}, -{ones}, {zeros}, {zeros}],
[{zeros}, {zeros}, -{ones}, {zeros}],
[{zeros}, {zeros}, {zeros}, -{ones}],
]
).transpose((2, 0, 1))"""
@unevaluated(commutative=False)
class BoostZMatrix(sp.Expr):
r"""Represents a Lorentz boost matrix in the :math:`z`-direction.
Args:
beta: Velocity in the :math:`z`-direction, :math:`\beta=p_z/E`.
n_events: Number of events :math:`n` for this matrix array of shape
:math:`n\times4\times4`. Defaults to the `len` of :code:`beta`.
"""
beta: sp.Basic
n_events: sp.Basic
def as_explicit(self) -> sp.MutableDenseMatrix:
beta = self.beta
gamma = 1 / ComplexSqrt(1 - beta**2) # type: ignore[operator]
return sp.Matrix([
[gamma, 0, 0, -gamma * beta],
[0, 1, 0, 0],
[0, 0, 1, 0],
[-gamma * beta, 0, 0, gamma],
])
def evaluate(self) -> _BoostZMatrixImplementation:
beta = self.beta
gamma = 1 / sp.sqrt(1 - beta**2) # type: ignore[operator]
n_events = self.n_events
return _BoostZMatrixImplementation(
beta=beta,
gamma=gamma,
gamma_beta=gamma * beta,
ones=_OnesArray(n_events),
zeros=_ZerosArray(n_events),
)
def _latex_repr_(self, printer: LatexPrinter, *args) -> str:
return printer._print(self.evaluate(), *args)
@unevaluated(implement_doit=False)
class _BoostZMatrixImplementation(NumPyPrintable):
beta: sp.Basic
gamma: sp.Basic
gamma_beta: sp.Basic
ones: _OnesArray
zeros: _ZerosArray
_latex_repr_ = R"\boldsymbol{{B_z}}\left({beta}\right)"
def _numpycode(self, printer: NumPyPrinter, *args) -> str:
printer.module_imports[printer._module].add("array")
_, gamma, gamma_beta, ones, zeros = map(printer._print, self.args)
return f"""array(
[
[{gamma}, {zeros}, {zeros}, -{gamma_beta}],
[{zeros}, {ones}, {zeros}, {zeros}],
[{zeros}, {zeros}, {ones}, {zeros}],
[-{gamma_beta}, {zeros}, {zeros}, {gamma}],
]
).transpose((2, 0, 1))"""
@unevaluated(commutative=False)
class BoostMatrix(sp.Expr):
r"""Compute a rank-3 Lorentz boost matrix from a `.FourMomentumSymbol`."""
momentum: sp.Basic
_latex_repr_ = R"\boldsymbol{{B}}\left({momentum}\right)"
def as_explicit(self) -> sp.MutableDenseMatrix:
momentum = self.momentum
energy = Energy(momentum)
beta_sq = EuclideanNormSquared(ThreeMomentum(momentum)) / energy**2
beta_x = FourMomentumX(momentum) / energy
beta_y = FourMomentumY(momentum) / energy
beta_z = FourMomentumZ(momentum) / energy
g = 1 / sp.sqrt(1 - beta_sq)
return sp.Matrix([
[g, -g * beta_x, -g * beta_y, -g * beta_z],
[
-g * beta_x,
1 + (g - 1) * beta_x**2 / beta_sq,
(g - 1) * beta_y * beta_x / beta_sq,
(g - 1) * beta_z * beta_x / beta_sq,
],
[
-g * beta_y,
(g - 1) * beta_x * beta_y / beta_sq,
1 + (g - 1) * beta_y**2 / beta_sq,
(g - 1) * beta_z * beta_y / beta_sq,
],
[
-g * beta_z,
(g - 1) * beta_x * beta_z / beta_sq,
(g - 1) * beta_y * beta_z / beta_sq,
1 + (g - 1) * beta_z**2 / beta_sq,
],
])
def evaluate(self) -> _BoostMatrixImplementation:
p = self.momentum
energy = Energy(p)
beta_sq = EuclideanNormSquared(ThreeMomentum(p)) / energy**2
beta_x = FourMomentumX(p) / energy
beta_y = FourMomentumY(p) / energy
beta_z = FourMomentumZ(p) / energy
gamma = 1 / sp.sqrt(1 - beta_sq)
return _BoostMatrixImplementation(
momentum=p,
b00=gamma,
b01=-gamma * beta_x,
b02=-gamma * beta_y,
b03=-gamma * beta_z,
b11=1 + (gamma - 1) * beta_x**2 / beta_sq,
b12=(gamma - 1) * beta_x * beta_y / beta_sq,
b13=(gamma - 1) * beta_x * beta_z / beta_sq,
b22=1 + (gamma - 1) * beta_y**2 / beta_sq,
b23=(gamma - 1) * beta_y * beta_z / beta_sq,
b33=1 + (gamma - 1) * beta_z**2 / beta_sq,
)
@unevaluated(commutative=False, implement_doit=False)
class _BoostMatrixImplementation(NumPyPrintable):
momentum: sp.Basic
b00: sp.Basic
b01: sp.Basic
b02: sp.Basic
b03: sp.Basic
b11: sp.Basic
b12: sp.Basic
b13: sp.Basic
b22: sp.Basic
b23: sp.Basic
b33: sp.Basic
_latex_repr_ = R"\boldsymbol{{B}}\left({momentum}\right)"
def _numpycode(self, printer: NumPyPrinter, *args) -> str:
_, b00, b01, b02, b03, b11, b12, b13, b22, b23, b33 = self.args
return f"""array(
[
[{b00}, {b01}, {b02}, {b03}],
[{b01}, {b11}, {b12}, {b13}],
[{b02}, {b12}, {b22}, {b23}],
[{b03}, {b13}, {b23}, {b33}],
]
).transpose((2, 0, 1))"""
@unevaluated(commutative=False)
class RotationYMatrix(sp.Expr):
r"""Rotation matrix around the :math:`y`-axis for a `.FourMomentumSymbol`.
Args:
angle: Angle with which to rotate, see e.g. `.Phi` and `.Theta`.
n_events: Number of events :math:`n` for this matrix array of shape
:math:`n\times4\times4`. Defaults to the `len` of :code:`angle`.
"""
angle: sp.Basic
n_events: sp.Basic
def as_explicit(self) -> sp.MutableDenseMatrix:
angle = self.angle
return sp.Matrix([
[1, 0, 0, 0],
[0, sp.cos(angle), 0, sp.sin(angle)],
[0, 0, 1, 0],
[0, -sp.sin(angle), 0, sp.cos(angle)],
])
def evaluate(self) -> _RotationYMatrixImplementation:
return _RotationYMatrixImplementation(
angle=self.angle,
cos_angle=sp.cos(self.angle),
sin_angle=sp.sin(self.angle),
ones=_OnesArray(self.n_events),
zeros=_ZerosArray(self.n_events),
)
def _latex_repr_(self, printer: LatexPrinter, *args) -> str:
return printer._print(self.evaluate(), *args)
@unevaluated(commutative=False, implement_doit=False)
class _RotationYMatrixImplementation(NumPyPrintable):
angle: sp.Basic
cos_angle: sp.Basic
sin_angle: sp.Basic
ones: _OnesArray
zeros: _ZerosArray
_latex_repr_ = R"\boldsymbol{{R_y}}\left({angle}\right)"
def _numpycode(self, printer: NumPyPrinter, *args) -> str:
printer.module_imports[printer._module].add("array")
_, cos_angle, sin_angle, ones, zeros = map(printer._print, self.args)
return f"""array(
[
[{ones}, {zeros}, {zeros}, {zeros}],
[{zeros}, {cos_angle}, {zeros}, {sin_angle}],
[{zeros}, {zeros}, {ones}, {zeros}],
[{zeros}, -{sin_angle}, {zeros}, {cos_angle}],
]
).transpose((2, 0, 1))"""
@unevaluated(commutative=False)
class RotationZMatrix(sp.Expr):
r"""Rotation matrix around the :math:`z`-axis for a `.FourMomentumSymbol`.
Args:
angle: Angle with which to rotate, see e.g. `.Phi` and `.Theta`.
n_events: Number of events :math:`n` for this matrix array of shape
:math:`n\times4\times4`. Defaults to the `len` of :code:`angle`.
"""
angle: sp.Basic
n_events: sp.Basic
def as_explicit(self) -> sp.MutableDenseMatrix:
angle = self.angle
return sp.Matrix([
[1, 0, 0, 0],
[0, sp.cos(angle), -sp.sin(angle), 0],
[0, sp.sin(angle), sp.cos(angle), 0],
[0, 0, 0, 1],
])
def evaluate(self) -> _RotationZMatrixImplementation:
return _RotationZMatrixImplementation(
angle=self.angle,
cos_angle=sp.cos(self.angle),
sin_angle=sp.sin(self.angle),
ones=_OnesArray(self.n_events),
zeros=_ZerosArray(self.n_events),
)
def _latex_repr_(self, printer: LatexPrinter, *args) -> str:
return printer._print(self.evaluate(), *args)
@unevaluated(commutative=False, implement_doit=False)
class _RotationZMatrixImplementation(NumPyPrintable):
angle: sp.Basic
cos_angle: sp.Basic
sin_angle: sp.Basic
ones: _OnesArray
zeros: _ZerosArray
_latex_repr_ = R"\boldsymbol{{R_z}}\left({angle}\right)"
def _numpycode(self, printer: NumPyPrinter, *args) -> str:
printer.module_imports[printer._module].add("array")
_, cos_angle, sin_angle, ones, zeros = map(printer._print, self.args)
return f"""array(
[
[{ones}, {zeros}, {zeros}, {zeros}],
[{zeros}, {cos_angle}, -{sin_angle}, {zeros}],
[{zeros}, {sin_angle}, {cos_angle}, {zeros}],
[{zeros}, {zeros}, {zeros}, {ones}],
]
).transpose((2, 0, 1))"""
@unevaluated(implement_doit=False)
class _OnesArray(NumPyPrintable):
shape: Any
def _numpycode(self, printer: NumPyPrinter, *args) -> str:
printer.module_imports[printer._module].add("ones")
shape = printer._print(self.shape)
return f"ones({shape})"
@unevaluated(implement_doit=False)
class _ZerosArray(NumPyPrintable):
shape: Any
def _numpycode(self, printer: NumPyPrinter, *args) -> str:
printer.module_imports[printer._module].add("zeros")
shape = printer._print(self.shape)
return f"zeros({shape})"
@unevaluated(implement_doit=False)
class ArraySize(NumPyPrintable):
"""Symbolic expression for getting the size of a numerical array."""
array: Any
_latex_repr_ = "N_{{{array}}}"
def _numpycode(self, printer: NumPyPrinter, *args) -> str:
array = printer._print(self.array)
return f"len({array})"
def compute_boost_chain(
topology: Topology, momenta: FourMomenta, state_id: int
) -> list[BoostMatrix]:
boost_matrices = []
decay_chain_state_ids = __get_boost_chain_ids(topology, state_id)
boosted_momenta: dict[int, sp.Expr] = {
i: get_four_momentum_sum(topology, momenta, i) for i in decay_chain_state_ids
}
for current_state_id in decay_chain_state_ids:
current_momentum = boosted_momenta[current_state_id]
boost = BoostMatrix(current_momentum)
boosted_momenta = {
i: ArrayMultiplication(boost, p) for i, p in boosted_momenta.items()
}
boost_matrices.append(boost)
return boost_matrices
def __get_boost_chain_ids(topology: Topology, state_id: int) -> list[int]:
"""Get the state IDs from first resonance to this final state.
>>> from qrules.topology import create_isobar_topologies
>>> topology = create_isobar_topologies(3)[0]
>>> __get_boost_chain_ids(topology, state_id=0)
[0]
>>> __get_boost_chain_ids(topology, state_id=1)
[3, 1]
>>> __get_boost_chain_ids(topology, state_id=2)
[3, 2]
"""
decay_chain_state_ids = list(reversed(list_decay_chain_ids(topology, state_id)))
initial_state_id = next(iter(topology.incoming_edge_ids))
decay_chain_state_ids.remove(initial_state_id)
return decay_chain_state_ids
def get_four_momentum_sum(
topology: Topology, momenta: FourMomenta, state_id: int
) -> ArraySum | FourMomentumSymbol:
"""Get the `.FourMomentumSymbol` or sum of momenta for **any** edge ID.
If the edge ID is a final state ID, return its `.FourMomentumSymbol`. If it's an
intermediate edge ID, return the sum of the momenta of the final states to which it
decays.
>>> from qrules.topology import create_isobar_topologies
>>> topology = create_isobar_topologies(3)[0]
>>> momenta = create_four_momentum_symbols(topology)
>>> get_four_momentum_sum(topology, momenta, state_id=0)
p0
>>> get_four_momentum_sum(topology, momenta, state_id=3)
p1 + p2
"""
if state_id in topology.outgoing_edge_ids:
return momenta[state_id]
sub_momenta_ids = determine_attached_final_state(topology, state_id)
return ArraySum(*[momenta[i] for i in sub_momenta_ids])
def compute_invariant_masses(
four_momenta: FourMomenta, topology: Topology
) -> dict[sp.Symbol, sp.Expr]:
"""Compute the invariant masses for all final state combinations."""
if topology.outgoing_edge_ids != set(four_momenta):
msg = (
f"Momentum IDs {set(four_momenta)} do not match final state edge IDs"
f" {set(topology.outgoing_edge_ids)}"
)
raise ValueError(msg)
invariant_masses: dict[sp.Symbol, sp.Expr] = {}
for state_id in topology.edges:
attached_state_ids = determine_attached_final_state(topology, state_id)
total_momentum = ArraySum(*[four_momenta[i] for i in attached_state_ids])
expr = InvariantMass(total_momentum)
symbol = get_invariant_mass_symbol(topology, state_id)
invariant_masses[symbol] = expr
return invariant_masses
def get_invariant_mass_symbol(topology: Topology, state_id: int) -> sp.Symbol:
"""Generate an invariant mass label for a state (edge on a topology).
Example
-------
In the case shown in Figure :ref:`one-to-five-topology-0`, the invariant mass of
state :math:`5` is :math:`m_{034}`, because :math:`p_5=p_0+p_3+p_4`:
>>> from qrules.topology import create_isobar_topologies
>>> from ampform._qrules import get_qrules_version
>>> topologies = create_isobar_topologies(5)
>>> topology = topologies[0 if get_qrules_version() < (0, 10) else 3]
>>> get_invariant_mass_symbol(topology, state_id=5)
m_034
Naturally, the 'invariant' mass label for a final state is just the mass of the
state itself:
>>> get_invariant_mass_symbol(topologies[0], state_id=1)
m_1
"""
final_state_ids = determine_attached_final_state(topology, state_id)
mass_name = f"m_{''.join(map(str, sorted(final_state_ids)))}"
return sp.Symbol(mass_name, nonnegative=True)