A gamma photon does not release its energy travelling into the material but deposes it into a very local spot when it happens to interact by photoelectric, Compton scattering or pair production (other processes are very rare). The electron that emerges from these interactions typically travels few millimeters inside the material releasing all its energy (and a correlated amount of optical photons) into a single crystal.
The nasty interaction here is the Compton scattering in which also a secondary photon (of quite random energy) comes out. It may interact again into the same crystal but often it escapes taking some of the energy away.
To solve this problem you need the concept of coincidence. If you detect interactions in different crystals in a very narrow time windows you can assume that these comes from the same initial photon and rarely you will be wrong. So looking at coincidences you can reconstruct the energy of the initial gamma by summing all the energy deposed in the crystals. Or also you may go for an anti-Compton shielding which consist of a very heavy material (with high cross section) which surrounds the detector and allow to discard events in which a Compton scattered photon tried to leave the crystal but was stopped by the shielding.
Finally what matters is simply building up some statistics to get an energy spectrum in which every kind of event which is likely to happen will be signed by a nice peak while the unlucky "bad" events when some energy has escaped just fill up some noise background.
What said before is generally valid for gammas coming from nuclear decays/excitation whose energies are around the MeV. If we are talking about energy of GeV like the gammas generated by cosmic rays or by high-energy particle accelerators then the things are pretty different. After the first interaction the products will have enough energy to interact again and again creating a so called electromagnetic shower. You will need a pretty big and heavy (array of) crystal (=calorimeter) to contain all this cascade.
This post imported from StackExchange Physics at 2014-03-24 04:18 (UCT), posted by SE-user DarioP