Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
4.33e-10
>>>
>>> lifetime_to_width(1.520119980246514*ps) # result again returned in MeV
4.33e-10
>>>
>>> lifetime_to_width(1.520119980246514*ps)/eV # result converted to eV
0.000433
"""
if tau < 0:
raise ValueError("Input provided, {0} <= 0!".format(tau))
elif tau == 0:
return float("inf")
# Just need to first make sure that the lifetime is in the standard unit ns
return hbar / float(tau / ns)
Parameters
-----------
tau : float > 0
Particle lifetime, typically in picoseconds (any HEP time unit is OK).
Returns
-------
Particle decay width, in the HEP standard energy unit MeV.
"""
if tau <= 0:
raise ValueError( 'Input provided, %s <= 0!'.format(tau) )
# Just need to first make sure that the lifetime is in the standard unit ns
return hbar / float(tau / ns)