Trouble with High-Res 3D Histogram

Hello Geant4 Users,

I am facing an issue while creating a high-resolution 3D histogram in my Geant4 simulation. I require a resolution of at least 1000x1000x1000 voxels.
So far, I’ve achieved a resolution of 200x200x200 voxels using 40 threads; however, increasing the number of bins causes the simulation to crash (due to memory constraints).

Any tips or workarounds for handling high-resolution histograms?

I would appreciate any suggestions or tools that integrate well with Geant4 for managing large datasets.

Best regards,

Increasing the number of threads won’t help. If you’re trying to create that histogram, and add entries to it in each event, then each thread will have a copy of it in memory. So the more threads, the more memory.

You would be much better off writing an SD (or using something built-in from G4), and create an N-tuple. For each of your hits, record the x,y,z coordinates and the voxel number (which I think you can get by interrogating the PV associated with the step).

Then you’re storing just four values per hit, and you’re not occupying a massive amount of memory with all of the empty voxels. Create your histogram offline in your analysis.