09-22-2015 11:56 AM
For Canon lenses you simply have to look it up.
Go to the Canon EOS lens page, check their "Accessories" link, and they'll tell you what hood to use.
For example, here's a link to the 50mm f/1.4 page: http://usa.canon.com/cusa/consumer/products/cameras/ef_lens_lineup/ef_50mm_f_1_4_usm#SuppliesAndAcce...
For that paritcular lens (just to pick on it as an example) the hood is the ES-71II. Unfortunately there is no formula that matches the hood to the lens... while they call this the ES-71II they may as well have called it "charlie" for all the meaning in the model number.
The lenses have a bayonet style mount and it has to fit the hood... but also the hood has to be designed so that the walls of the hood do not interfer with the angle of view of the lens (especially if it's a zoom lens -- in which case you have to make sure it wont interfere at any focal length in the zoom range.) This is why some hoods have a "tulip" type design... if not for the cut out sections of the hood (giving it the tulip petal shape) the hood would be visible in the corners of the image. Those missing sections of hood are designed to exactly work with the focal length of the specific lens for which that hood was designed.