You should count each share as valuable as the difficulty of the pre-determined target for that miner. If you count the actual value of the hash it found itself, either the math won't work, or you'll introduce massive variance instead of reducing it (which a pool is intended to do).

When you choose a particular share difficulty D, you are restricting the set of valid hashes to a set that is D times smaller than the set of valid hashes for difficulty 1. Given that each of such results is D times less likely to be found, it is fair to count it as D shares of difficulty. However, each hash is either good or not good, and each has a fixed probability of being good.

If you're going to use the actual hash value obtained to calculate share value, most hashes won't be valid, but those that do will introduce extra variance: some (unlikely) ones will result in a very high score, and some won't. There is no need for this: just giving each hash the same score is just as well a...