Determination of ion recombination and polarity effects for the PTW Advanced Markus ionization chamber in synchrotron based scanned proton and carbon ion beams