trackcut and tesselated solids in 3.06

17 views
Skip to first unread message

Ng Jun Kai

unread,
Dec 27, 2025, 6:08:12 AM12/27/25
to G4Beamline
Helo experts.I am new to g4bl, here are my questions:
1.) can we apply multiple trackcut in g4bl, like first trackcut to keep muon of all energy, 2nd cut to keep gamma>140 MeV
2.) how to convert stl to a file that can be read by g4bl

thanks in advance

Eremey Valetov

unread,
Dec 31, 2025, 3:49:22 AM12/31/25
to G4Beamline, Ng Jun Kai

Hi Jun Kai,

Regarding multiple track cuts:

If the particlefilter command would work for you, you can use its "require" argument, which allows a logical expression to be used to kill tracks. Here as some examples of expressions that would be valid for the require argument:
require='PDGid==-13||PDGid==-11||PDGid==211'
require=(sqrt(x*x+y*y)<250)&&(abs(y)<100

You can also modify the source code for the trackcuts command to suit your needs and recompile G4beamline.

There are several options to use an STL geometry file:
* convert the geometry to G4beamline input file format manually
* write an STL-to-G4beamline conversion utility (e.g., using Python or Mathematica)
* implement an STL import command in G4beamline's source code
Perhaps there are some additional options.

Cheers,
Eremey 

Ng Jun Kai

unread,
Dec 31, 2025, 10:04:01 PM12/31/25
to G4Beamline, Eremey Valetov, Ng Jun Kai

Thanks for replying, but let me be specific...

  1. regarding the multiple track cuts:

I shoot electrons to a copper target. And there are alots of particle generated within the volume. depending on what i want to simulate, i wanted to kill gammas with E<(some threshold) which appear inside the copper.

the most similar stuff i discovered is the trackcut. but it seems can apply only once.

for example, if we write a single line "trackcuts keep=mu+,mu-,pi+,pi-,kaon+,kaon-,kaon0,e+,e-,proton,neutron,gamma", it keep all

but if i we write "trackcuts keep=mu+,mu-,pi+,pi-,kaon+,kaon-,kaon0,e+,e-,proton,neutron", followed with "trackcuts keep=gamma  kineticEnergyCut=(threshold)", the running speed goes from 3e5 ev/s to 5e5 ev/s, which i believe particles other than gamma being killed (not what i wanted). i am new to g4bl, modifying the code (while it offer more flexibility) is something to be considered in the near future.

  1. importing cad into g4bl.

I found that it is derived from g4tessellatedSolid class. so i tested with simple geometry (prism, see attached files), cookup the vertices and facets by hand, and I have checked that the visualization and physics worked. It seem the g4tessellatedSolid class has very strict on the surfaces (all the surfaces must be closed) and the direction of the surface normal to make the shape and physics work.

while this may work (a little bit painful) for simple geometry, i believe the pain level grows with complex CADs. And I see very few discussion on these several options to use an STL geometry file. Maybe somebody can show me around ?


Btw what are the magenta points on the tesselated prism ? (they do not appears when only the prism is present)

Picture1.png

prism_tess.txt
work2.g4bl
Reply all
Reply to author
Forward
0 new messages