Treatment planning system for carbon ion therapy: optimization of the dose delivery