Measurements and calculations of cascades produced by 300 GeV protons incident on a target inside a magnet