Run particles from textfile

Hi

I am trying to get geant to run a list of particles and associated energy from a Text file.
So far I was using macros and aliases for specific particles and energies.
I was thinking of having a generic macro where the particle is defined by getting a shell variable using /control/getenv. This allows me to have the reading of the text file outside of Geant. However, I am not sure how this command works.

I tried:

/control/getEnv PARTICLE
/control/echo PARTICLE
/mycmd/gun/setparticle {PARTICLE}

But I get <PARTICLE> is not defined as a shell variable. Command ignored.
while if I “echo $PARTICLE” in my shell I get it s value printed (in this case it was “proton”).

I would be glad to receive some help on this and I am open to any more practical suggestions for the implementation of it.

Cheers!
Florian

If you are in Bash, did you do PARTICLE=proton or export PARTICLE=proton? You need the export directive to make it an environment variable (which is what gets passed into a child process).

If you are in Csh/Tcsh, the equivalent is setenv PARTICLE proton.

1 Like

Indeed my error was as simple as this. Thank you !!