G4ParticleGun with root files as input

_Geant4 Version:_10.07.p03
_Operating System:_Ubuntu 22.04 LTS
_CMake Version:_3.22.1

Hello experts,

I want to generate particles using G4ParticleGun. All the information of the particles, energy, position(p_x, p_y, p_z) and momentum(m_x, m_y, m_z) are stored in a root file as columns in a branch.
Each row represents an individual particle. How could I generate particles from a root file?

I appreciate any useful links, code snippets or examples.

Thank you in advance!

1 Like

Unless there’s something new in 11.2, Geant4 doesn’t provide this functionality in the toolkit. You can write your own PrimaryGeneratorAction to open and read the ROOT file using the structure you know is in there. You will need to be a bit careful about doing this is a thread-safe way.