It's at objects/Block.cpp line 110, the method called Block::recalculate_shares() and here's some simplified pseudo-code to explain it:
sum_scaled_shares = 0
for each account's best deadline (let's call this "deadline") {
// because it's possible, but rare, to have a 0 deadline
// and we don't want a divide by zero error later
deadline += 1
// deadline raised to the power of 1.2 (1.2 is set in pool's config file)
scaled_share = pow(deadline, 1.2)
// SOME_BIG_INT is actually 0x7fffffffffffffff in the code
scaled_share = SOME_BIG_INT / scaled_share
sum_scaled_shares += scaled_share
}
So after this loop, each account's slice of the pie will be their "scaled_share" out of "sum_scaled_shares".
As a dummy run, say you have 3 miners (a, b and c) with 3 deadlines ("0", "123" aka 2 minutes 3 seconds and "8125" aka 2 hours 15 minutes 25 seconds):
a's "scaled_share" would be:
0
+1 = 1
^1.2 = 1
0x7ffffffffffffffff/ = 0x7fffffffffffffff
b's scaled_share would be:
123
+1 = 124
^1.2 = 325.16666
0x7fffffffffffffff/ = 0x0064c5df25dc5f6c
c's scaled_share would be:
8125
+1 = 8126
^1.2 = 49187.2091402907
0x7fffffffffffffff/ = 0x0000aa8b645dc96b
sum_scaled_shares = 0x7fffffffffffffff + 0x0064c5df25dc5f6c + 0x0000aa8b645dc96b = 0x8065706a8a3a28d6
so as percentages:
a: 0x7fffffffffffffff / 0x8065706a8a3a28d6 = 99.6914%
b: 0x0064c5df25dc5f6c / 0x8065706a8a3a28d6 = 0.3066%
c: 0x0000aa8b645dc96b / 0x8065706a8a3a28d6 = 0.0020%
99.6914% + 0.3066% + 0.0020% = 100%