G4python -- how to get additional public functions?

Geant4 Version: 11.2+ (10.7.4)
Operating System: CentOS 7
Compiler/Version: Python 3.10.8 (foss/2022b toolchain)
CMake Version: 3.21


We have just started trying out the G4Python environment. We built it from G4 10.7.4, because that’s what we’re using for our experiment (SuperCDMS), but I understand that it’s a separate repository now.

Our interest in G4Python is understanding aspects of the geometry and doing some rapid prototyping. We are specifically interested in geometry queries like SurfaceNormal(), DistanceToIn(), DistanceToOut(), and so on. None of these public member functions are available in G4Python.

Is there a well-defined procedure for adding them, or requesting that they be added? Is there an expectation that such requests will be addressed, or is the package essentially frozen?

In terms of additions to the geant4py version that’s in 10.7.4, then that version isn’t getting patches anymore, so the only course here would be to request these on

There’s a more modern implementation here:

that provides a more complete binding, and is more actively developed. For geometry, though it’s slightly at a tangent:

might also be interesting to you.

For completeness, it’s also worth mentioning that the are also Julia bindings:

if use from that language is of interest/possible.

Thanks, Ben!

Yes, we understand that. I haven’t tried using Koichi’s separate repository with 10.7.4 (it may not work), but we could as easily build a standalone G4 11+Python for this purpose.

When I did a Google search, I did come across other developments, but I was hoping to stick with an “officially blessed” version.

What we’re most interested in is both mocking up new code/algorithms in Python, and understanding some strange “edge cases” (literally!) involving solids and surface functions. The geant4_pybind looks like it has everything we need, so that could be a good option.

I saw that in the G4 documentation. We aren’t using Julia in CDMS – all our analysis is Python/Jupyter based. I’m sure there are going to be students who say we should switch, but that’s not on our horizon :slight_smile:

Thank you again for all of this information, Ben!

You’re most welcome Mike! Please do let us know how you get on - there’s of course a range in interest in Python bindings (I believe EIC/ePIC are looking at this, alongside Julia, and GATE have their own implementation).

There was some discussion/presentations at the 2023 Collaboration Meeting on how best to support bindings to other languages, so it is on the radar. I planned to do some follow ups through last year, but I’ve been swamped with other tasks :slightly_frowning_face:

We will! I gave our student a really trivial standalone program, and he’s been able to adapt that (using the old-style binmake.gmk) to quickly build and run the geometry tests we need in C++. I plan to mention this at our next Simuations WG meeting; if others are interested in it, we’ll push it a bit more, and probably try geant4_pybind.