Very basic question: material scan of an external GDML input

Dear all,

i am a very new user of Geant4 and i would like to apologise if my question is very naive.
Is there an example available which is using a loader of a GDML file and perform a detailed study of the material budget ? [ x/x0 and l/Lint?] Basically from official simulations i got GDMLs files and i want to understand what geant4 is seeing when using those files.

Anyone know how to do it?

Thanks in advance


Geant4 Version:
Operating System:
CMake Version:


I’ve not done this myself, but it should be quite straightforward, I would have thought, to read in a GDML file (see examples/extended/persistency/gdml/G01) and use the particle gun or a General Particle source to fire a geantino (a non-interaction imaginary particle) in a series of directions. In your SteppingAction you could query the material and, knowing the step length, accumulate radiation lengths and hadronic (what particle?) interaction lengths. (To be honest, not sure how to get the radiation length and hadronic interaction length for a given material, so maybe someone else can help there.)

Hope that helps


1 Like

In SteppingAction :
material = step → GetPreStepPoint() → GetMaterial();

X0 = material → GetRadlen();
lambda = material → GetNuclearInterLength();

Thanks a lot @maire , since i am pretty new to geant4, if i start from gdml/G01 example , is it enough to add the C++ code with the scanned values?

I far as I can understand, G01 read and write gdml geometry, and shoot geantinos in it.
If you want to compute and plot the number of interactionLength that these geantinos ‘see’ along their trajectory, you need, at least, a SteppingAction and a TrackingAction classes.