A Monte Carlo-based treatment-planning tool for ion beam therapy