A derivation of masses and total luminosities of galaxy groups and clusters in the maxBCG catalogue