I want to simulate some particles and then look, what for a spectrum they create in a volume (the deposited energy of the particles). Is there an easy way for craeting such a spectrum (in the Geant4-code) and save it to disk?
This is not a problem of Geant4. Geant4 itself does not have any histogramming capability or any persistency mechanism for histograms. You can find an example of connecting Geant4 and JAS to get histograms from http://csc.web.cern.ch/CSC/2000/csc2000/ Scientific_Programme/OO_Design_Exercices/