At the carbon ion therapy facility of GSI Darmstadt in-beam positron emission tomography (PET) is used for imaging the beta+-activity distributions which are produced via nuclear fragmentation reactions between the carbon ions and the atomic nuclei of the irradiated tissue. On the basis of these PET images the quality of the irradiation, i.e. the position of the field, the particle range in vivo and even local deviations between the planned and the applied dose distribution, can be evaluated. However, for such an evaluation the measured beta+-activity distributions have to be compared with those predicted from the treatment plan. The predictions are calculated as follows: a Monte Carlo event generator produces list mode data files of the same format as the PET scanner in order to be processed like the measured ones for tomographic reconstruction. The event generator models the whole chain from the interaction of the projectiles with the target, i.e. their stopping and nuclear reactions, the production and the decay of positron emitters, the motion of the positrons as well as the propagation and the detection of the annihilation photons. The steps of the modelling, the experimental validation and clinical implementation are presented.