Excited States Population of Fast Heavy Ions at the Exit of Gazeous and Solid Targets