Boolean operation - subtract volumes

Dear all,

I have two geometries: two boxes of different sizes in width and length, same thickness. I want to exclude the smaller box from the larger one to get a box with a “hole” in the middle by using G4SubtractionSolid.

I set both solid volumes and execute the subtraction, but what I get is not exactly what I expected as can be seen in the figure outer_inner.png. The boolean operation is “partially” performed. Also I set the physical volume for the larger box in order to define the coordinate system before performing the boolean operation, but not success neither in getting the geometry I want.

I would appreciate any help.
Best regards,

Dear Manuel,

It is a known problem in Geant4 visualization. You can get a correct image by using the RayTracer, which is based on the tracking algorithms of Geant4. For details please see the Geant4 Book for Application Developers, section Visualization.

However, it should be noted that a better way to define such kind of geometry is to define the smaller box (the hole) as a daughter volumes of the bigger box, instead of a Boolean subtraction.

Alternatively, in this particular case, you can also use G4Polyhedra.


Dear Evgueni,

Thanks for the prompt reply.

In the case of defining the smaller box as daughter of the bigger one, should the daughter volume be filled with a vacuum material? In order to have the “hole” in the middle of the bigger volume. Because the idea is that throughout the “hole” the radiation undergoes little/no interaction.

Best regards,

Yes, the smaller box should have a different material to be a hole. In your example it should be the material of the world volume.


You should also consider, when performing a Boolean subtraction A-B, to define the box B with slightly bigger thickness than A, to avoid effects in subtracting coincident surfaces.