Determination of the electronic structure of grain boundaries by energy-resolved photoconductivity measurements