Combining multiple detector objects together

I have a geometry of many cubes randomly positioned on a grid. Many of these cubes are flush with one-an-other (the cubes are identical). With many objects the simulations slows down.

Q: Is there a way to combine adjacent identical geometries into 1 object?
Would this help with the speed of a simulation?
Any ideas?

Thank you.

Combining the adjacent cubes won’t speed things up a lot, unless the vast majority of your cubes are flush.

If you’ve implemented these as individual placements, your slowdown may be due to memory swapping, rather than intrinsic CPU. You could consider implementing your geometry using a G4PVParameterised. Then your memory contains just one single cube instance and one single placement object.

The positions are handled via queries to the G4PVParameterised via copy number. You would need to pre-generate a table of random positions mapped to copy numbers (because you don’t want the position to change at each query!).

That’s great!

Thank you.