Native .stp/ step file support on GEANT4?

Hello, everyone,

There are many advantages to using CAD software to develop models and prototypes for particle detectors. I use FreeCAD, for example, to design my detector pieces and readily 3D print a prototype.

However, it is challenging to reproduce the CAD model in GEANT4. It is time-consuming and limited to the GEANT4 primitives.

Sometimes I import the CAD model into the simulation with CADMesh. I love it, but converting a detailed CAD geometry into a meshed object seems counterproductive.

As an alternative to mesh, we have the STEP files, supported by nearly all CAD programs on the market. So here is my question. What would be the best way to start developing step-file support in GEANT4? What are the foreseeable challenges of implementing that?

Thanks a lot, and take it easy, everyone!

PS: I know there is GDML, but it is not as widespread as STEP.

I think the major challenge is that Geant4 is optimized to find whether a track crosses a volume, while CAD programs rarely need this knowledge optimized for speed. Timewise, STEP has plenty of things to be implemented, i.e., developer’s time invested, while a conversion STEP to GDML takes a minute, just once per geometry.

FreeCAD is, in my opinion, a great point for CAD-GEANT4 interop because it allows python scripting for shapes, properties and geometry tree manipulations, it’s not a very complicated interface and primitive solids have good support (plus you can create your own with chords and faces).

There is a project for GDML support in FreeCAD which is slow but maintained.

I also see the advantages of using CAD models to develop geometries:

  • Rapid iteration due to immediate visual feedback
  • Support for parametrization and dependencies between objects
  • Separation of concerns: data(geometry description) should not contain logic (looking at you GDML for loop) and logic (simulation code) should not harcode state and data.
  • I don’t need to learn how to read sketches and my engineers coworkers don’t need to learn how to program in c++… win win

I agree that the GDML framework for FreeCAD is now quite usable. One could add shapes to existing models and also create new ones from a selection of CAD formats. It is still unclear how to quickly transform STEP into GDML, as the conversion often rotates volumes when tessellated.

Tessellated volumes are a general solution, but it diverges from the main idea of geant4 (and step) geometry construction which is compositions of primitive volumes.

Of course is easier to rely on a STEP Tessellation tool and focus on figure out materials and transformations, but I think it would be better for adoption if a proper conversion solids was made (to which I’m committed) 'cause it’ll clear performance concerns and the safety of translating the author’s intent rather than an interpretation based on triangular facets.

Doing so is not trivial task of course, FreeCAD has the concept of FeaturePython objects on which the GDML workbench is based, but that ties the implementation to FreeCAD only. A more general conversion from step to gdml solids is desirable, that said there is a caviat: step describes geometry and we need metadata related to volmes e.g. materials and sensitive information.