Intersection of Scoring mesh and physical volume

Hi everyone,

I am using GEANT4 to obtain a 3D map of energy density (J/m^3) deposited in a graphite spherical sample.

To obtain a volumetric map I built a mesh with cubic elements that is overlapped to the graphite sample. However, the cells of the grid at the edge of the sample are partially filled with graphite, thus underestimating the energy density once I divide the energy deposited in the cell by the total volume of the cell (when instead I should divide only for the volume of the cell which overlaps the graphite sample).

Is there a way to know through GEANT4 which is the exact fraction of the volume of every element of the mesh that intersects a given physical volume (i.e. the graphite sample in that case)?? Maybe creating a proper primitive scorer?

Thanks for the help,