Sensor simulation and position calibration for the CMS pixel detector