TREDI simulations for high-brilliance photoinjectors and magnetic chicanes