def getAllowedTotalSpins( L, S, useFactor2Trick=True ):
    """
    Returns a list of allowed J values from summing angular momenta L and S, where
    :math:`\\vec{J}=\\vec{L}+\\vec{S}`
    which implies :math:`|L-S| \\leq J \\leq L+S`

    The useFactor2Trick flag tells the routine whether we are summing real angular momenta or momenta * 2.
    If the useFactor2Trick flag is true, then momenta are really momenta*2, meaning they can be pure integers,
    even if the real momenta refer to 1/2-integer values (e.g. spin).  The default is to useFactor2Trick because
    most C/C++/Fortran codes that compute angular momentum-stuff use the trick so they can use integer math.
    Also, it makes the use of the Python range() function possible.
    """
    if useFactor2Trick: return list( range( abs(L-S), L+S+2, 2 ) )
    else: return [ j/2.0 for j in getAllowedTotalSpins( int(L*2), int(S*2) ) ]