Determining the energetics and charge distribution in the mesoporous semiconductor photoanodes used in dye-sensitized solar cells