Performance of the CMS Hadron Calorimeter with Cosmic Ray Muons and LHC Beam Data