Measurement of steam locomotive power was never a reliable pursuit because they had different measures: boiler HP, cylinder HP, and drawbar HP. The best measure that most closely described how much power the locomotive was putting out was drawbar HP, which is measured by a dynamometer car. This was a railroad car that was placed behind the tender and had accurate instruments to measure drawbar force and road speed.
Since power is a generic measurement of the rate at which work is being done, if you know the amount of effort being applied in the direction of motion, and the rate of motion, you can calculate power. James Watt is the man who actually defined the unit "Horsepower" when he was developing steam engines in the early 1800's. He defined it by measuring the amount of continuous pull that a horse could exert (181 lbs) and how fast the horse could travel while applying it (180 ft/min). Multiplying these quantities, Watt defined a Horsepower as being 32580 ft*lbs/min, which he rounded to 33000 ft*lbs/min. (Or since there is 60 seconds in a minute, a Horsepower can also be defined as 550 ft*lbs/sec.)
So taking Shannow's example of engine 4960 being able to exert a drawbar pull of 52300 lbs, and assuming it can exert that pull at a speed of 30 mph (equal to 44 ft/sec), you can calculate Horsepower:
52300 lbs * 44 ft/sec * (1 HP / 550 ft*lbs/sec) = 4184 Horsepower