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.

1 Like

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.

Hi mkelsey,

is there an example on how to use G4PVParameterised, especially w.r.t. to the copy number and positioning?

cd <my-geant4-dir>/examples
find . -type f | xargs grep G4PVParameterised

There are lots of examples of differing complexity. You may want to start with basic/B2/B2b.