Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'p_{i}', where i is given by their ordering in the `masses` list.
Return:
`GenParticle`: Particle decay.
Raise:
ValueError: If the length of `masses` and `names` doesn't match.
"""
if not top_name:
top_name = 'top'
if not names:
names = [f"p_{num}" for num in range(len(masses))]
if len(names) != len(masses):
raise ValueError("Mismatch in length between children masses and their names.")
return GenParticle(top_name, mass_top).set_children(*[GenParticle(names[num], mass=mass)
for num, mass in enumerate(masses)])