Analysis of Particles Resulting From Initial Interactions

All,

The research group I am working with is interested in the particles that result from an initial interaction with a thin layer of material. The GEANT4 Basic Examples that I have looked at so far seem to focus on the energy deposited in the material itself. Is there a way output information on the particles that are emitted as a result of the initial interaction?

For example, say we have a stream of gamma rays that strike a thin layer of hydrogen ice. I am interested in seeing if I can get the momentum of the particles that are produced from that interaction and are emitted on the other side of the hydrogen ice from where the gamma rays strike.

You could do this with a SteppingAction. Look for steps that are exiting the target volume (i.e., post-step status of fGeomBoundary) and are not your primary (ParentID != 0). Now you’ve got full access to the G4Step and you can get the momentum, kinetic energy, direction vector, whatever.

mkelsey,

I am finally getting back to this after several days with my attention focused elsewhere. I looked at the examples as you suggested above. I found that example “extended/electromagnetic/TestEm1” might have steps that are exiting the target volume in the SteppingAction. However, when I ran it, the following happened:

“”"
Jamess-MBP:TestEm1-build jamesbowen$ ./TestEm1
Available UI session types: [ tcsh, csh ]

      ################################
      !!! G4Backtrace is activated !!!
      ################################

Geant4 version Name: geant4-11-00 [MT] (10-December-2021)
<< in Multi-threaded mode >>
Copyright : Geant4 Collaboration
References : NIM A 506 (2003), 250-303
: IEEE-TNS 53 (2006), 270-278
: NIM A 835 (2016), 186-225
WWW : http://geant4.org/


PhysicsList::AddPhysicsList: <emstandard_opt3>
Visualization Manager instantiating with verbosity “warnings (3)”…
Visualization Manager initialising…
Registering graphics systems…

You have successfully registered the following graphics systems.
Registered graphics systems are:
ASCIITree (ATree)
DAWNFILE (DAWNFILE)
G4HepRepFile (HepRepFile)
RayTracer (RayTracer)
VRML2FILE (VRML2FILE)
gMocrenFile (gMocrenFile)
OpenGLImmediateX (OGLIX, OGLI)
OpenGLStoredX (OGLSX, OGL, OGLS)

Registering model factories…

You have successfully registered the following model factories.
Registered model factories:
generic
drawByAttribute
drawByCharge
drawByOriginVolume
drawByParticleID
drawByEncounteredVolume

Registered models:
None

Registered filter factories:
attributeFilter
chargeFilter
originVolumeFilter
particleFilter
encounteredVolumeFilter

Registered filters:
None

You have successfully registered the following user vis actions.
Run Duration User Vis Actions: none
End of Event User Vis Actions: none
End of Run User Vis Actions: none

Some /vis commands (optionally) take a string to specify colour.
“/vis/list” to see available colours.
PreInit>
“”"

I have not had the PreInit line come up in the previous examples I have run. What do I need to do in order to continue running this example?

PreInit>” or the other state prompts are what you get if you want to interact with G4 by typing commands in directly. It can be useful for debugging, or getting information about command syntax, etc.

Most of the examples are written so that if you specify the name of a macro file on the command line (e.g., testEm1 run.mac) it reads that file in and runs the job. If you specify nothing on the command line, it gives you the prompt.

I know there are some examples that will run some macro (like “vis.mac”) automatically, even if you don’t specify anything.

1 Like

Thanks mkelsey. I used the “… run.mac” option, and it worked.

mkelsey,

To run an example in interactive mode, is there something specific I need to input on the “PreInit” line before I proceed? I tried the command “/run/beamOn 10”, and it did not work. This is what happened:

“”"
PreInit> /run/beamOn 10
Geant4 kernel should be initialized
before the first BeamOn(). - BeamOn ignored.
PreInit>
“”"

(By the way, put three backquotes/accent grave on the line by themselves, no double quotes, to get the plain-text quoting).

The job configuration isn’t set up yet at that first PreInit> prompt (“PreInit” is an abbreviation for “pre-initialize”). If you look at the run.mac file, you’ll see that there are a lot of macro commands before the /run/beamOn.

If you want to run the macro from the prompt, you can do

PreInit> /control/execute run.mac

You might find the “Getting Started” chapter of the Developer’s Guide useful. This particular question is part of How to Execute a Program — Book For Application Developers 11.0 documentation

Sorry about that, I will use ‘’’ to paste lines from the terminal from now on.

On all of the basic examples, the command line begins with “Idle>” while in interactive mode. From what I can tell, the link you posted only covers that case. Is interactive mode not an option when I am dealing with “PreInit>”?

To get from PreInit to Idle, you need to initialize, which tells Geant4 to go ahead and build your geometry and build your physics lists.

This example (and most “real” applications) start at the PreInit state so that you can use macro commands to define or modify your geometry, adjust your physics list, and so forth, before running events.

To do the initialization, use the command /run/initialize. If you look in run.mac, you should see this command in there.

1 Like

mkelsey,

“/run/initialize” worked, thank you. I also looked in the runs.mac file. I see that “/run/initialize” is in there too.

One thing that does not appear to be working in this example, however, is the graphic. The runs.mac file does not appear to say anything about it. Does this example, extended/electromagnetic/TestEm1, have no graphic?

If you look in the TestEm1 directory, you’ll see about a dozen macro files there, each one for a different purpose. I’m pretty sure that vis.mac is the one for visualization. If you look in it, you should see a “/vis/open” command that would create a graphics window.

1 Like

mkelsey,

Thanks for this info. Using this as a starting point, I think I have figured out how to do it now.