How to use Boolean Solid

Hi experts,

How to use Boolean Solid for cutting this part of geometry in picture?

I made it like this but, doesn’t work:
G4UnionSolid* Union =
new G4UnionSolid(“Vacuum+Cavity”, cylinderSolid4, cylinderSolid5);
G4IntersectionSolid* intersection =
new G4IntersectionSolid(“Cavity intersect Vacuum”, cylinderSolid5, cylinderSolid4);
G4SubtractionSolid* subtraction =
new G4SubtractionSolid(“Cavity-Vacuum”, cylinderSolid4, cylinderSolid5);

White cylinder is Vacuum (cylinderSolid4), and blue is Cavity (cylinderSolid5)…

Best regards…

2022-03-13 at 00.06.39

As a result of looking at your GDML model wondering if you have any spare time to look at some enhancements to our FreeCAD GDML workbench
Thanks to some great work by Munther Hindi in implementing a suggestion of mine it now supports creating GDML Models from Extruded and Revolve FreeCAD Sketches see

As it involves a lot of new code it is currently available in the beta2 branch rather than the main branch.
We would be really interested in any feedback and would like to know if it made creating your model any easier etc.


Creating a Boolean solid in Geant4 requires two solids and a transformation for the second solid. The transformation specifies the position of the second solid relative to the first one, in your case it is necessary.

Please, read the section Solids made by Boolean operation

Thank You so much Mr. Evgueni, I know and I used for two solids… But, doesn’t work(

There is no transformation in the parameters of the Boolean operations in your code.

Below is what has been done in your code:

Construction of a solid cylinderSolid4
Construction of a logical volume cylinderSolid4
Construction of a physical volume (first G4PVPlacement, no rotation)

Construction of a solid cylinderSolid5
Construction of a logical volume cylinderSolid5
Construction of a physical volume (second G4PVPlacement, no rotation)

Construction of a solid Union (cylinderSolid4 + cylinderSolid5, no transformation)
Construction of a solid intersection (cylinderSolid5 - cylinderSolid5, no transformation)
Construction of a solid subtraction (cylinderSolid4 ^ cylinderSolid5, no transformation)

Last three solids have not been used to construct any logical and physical volumes, so they will not participate in the simulation and even will not be seen at visualisation.

1 Like

It looks that the model on the image consists only of cylinders. If so, then I would suggest to define it as follows:


Create 4 solids:
solid1, solid3, solid4 - cylinders
solid2 - hollow cylinder

Create a Boolean solid:
solid234 = solid2 + solid3 - solid4

As result there will two solids, solid1 and solid234, which should be used to create logical volumes (assigning material) and then physical volumes (placement logical volumes in the World volume)

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.