Getting StartedDocumentationSupportDownload

G4beamline Release 3.06 is available (January 2019) Download

G4beamline is a particle tracking simulation program based on Geant4(external link). It is optimized for simulating beamlines, and is especially useful for muon facilities in which decays and/or interactions with matter are important. It can also simulate systems not organized as a beamline, and has a cosmic-ray "beam". G4beamline is an open-source program distributed for Linux, Mac OS X, and Windows; it can also be built from source.

{G4beamline 3.02

G4beamline is designed to be very user friendly:
  • No C++ programming is required to use it.
  • The system and simulation are described in a single ASCII file
  • The system description uses a self-describing language which can be easily understood by anyone familiar with beamline simulations.
  • Advanced visualization capabilities are available out-of-the-box.
  • Plots and histograms are easily generated using G4beamline commands to write NTuples, and external programs to plot them, such as HistoRoot, Root(external link), and Gnuplot(external link).
  • All common beamline elements are implemented, such as dipole and quadrupole magnets, RF cavities, absorbers and targets, etc.
G4beamline is designed to be versatile and flexible:
  • General objects are implemented, such as boxes, cylinders, polycones and extruded polygons.
  • The NIST database of common materials is implemented; users can also define their own materials.
  • Electromagnetic fields generated by different elements can overlap without restriction, including fringe fields.
  • Objects can easily be placed along the centerline of a beamline, with or without offsets; they can also be placed anywhere within the simulated world without restrictions other than the obvious inability of two objects to occupy the same place.
  • Users can add their own components, using combinations of geometric shapes with different materials, plus electromagnetic fields specified by equations or field maps.
  • Users can add their own C++ code to implement more complex objects (requires building from source).
G4beamline is designed to permit highly realistic simulations:
  • The full power and accuracy of Geant4 can be used.
  • Any Geant4 physics list can be used.
  • Additional collective computations are implemented, such as space charge.
  • While generic components are available, users can implement specific beamline elements in considerable detail.
  • A document describing the physics validation of G4beamline is available here.
G4beamline is used by many accelerator physicists
  • Over 200 people have used it, making it one of the more popular accelerator simulation codes.
  • G4beamline has become one of the primary tools of the Muon Accelerator Program(external link).
  • The range of systems modeled by users is very diverse:
    • The MICE beamline and cooling channel at RAL
    • Muon cooling in a Helical Cooling Channel
    • Muon cooling in a Guggenheim cooling channel
    • Muon cooling in an Epicyclic PIC cooling channel
    • Muon production, capture, and phase rotation in the front end of a neutrino factory or muon collider
    • Neutrino production in several versions of a neutrino factory
    • Neutrino backgrounds and radiation in a muon collider.
    • Muon beam manipulations for several Fermilab experiments, including Mu2E and g-2
    • A large number of speculative muon generation or cooling schemes, including an inverse cyclotron, a particle refrigerator, dipole plus wedge cooling and capture, etc.; its ease of use makes it particularly well suited for quick simulations of "out of the box" ideas
    • Models of CEBAF experimental halls at Jefferson Lab
    • Potential anti-proton experiment(s) at Fermilab
    • Narrowband gamma generation via e+ e- annihilation
    • Cosmic-ray tomography of transportation containers for national security
    • And many more...
Binary distributions are available for:
  • Linux(Scientific Linux 7.8 and later, Ubuntu 16.04 and later)
  • Mac OS X (High Sierra and later)
  • Windows 10 and later
G4beamline can also be built from source:
  • To build with MPI enabled (enables use of many cores)
  • To run on other systems
  • To add user code
  • To improve performance via system-specific optimization
G4beamline is open source and is freely available for download.


G4beamline is a single-particle tracking program based on the Geant4(external link) simulation toolkit. It is specifically designed for the simulation of beamlines.

The key aspect of g4beamline is that the input file defining the simulation is not significantly more complicated than the problem being simulated (by contrast, any C++ simulation program will inherently be significantly more complicated than the problem) — G4beamline isolates the user from programming complexities. To make this possible, g4beamline does not give the user all of the power and flexibility of the underlying Geant4 toolkit; it does, however, provide enough flexibility to simulate many different systems that can be considered "beamlines" one way or another. For instance, there is a "cosmic-ray beam", and the notion of "beamline" is rather flexible. In use, one normally just lays out the beamline elements along the beam centerline, using "centerline coordinates" that rotate appropriately whenever needed (e.g. when a bending magnet is placed, or at a target to take a secondary beam off at an angle).

Note that no programming at all is required to simulate systems that use beamline elements already in g4beamline's repertoire. This includes bending magnets, quadrupoles, solenoids, materials of all types in the shape of boxes, cylinders, tubes, spheres, and polycones, pillbox RF cavities, and a few specialized elements for muon cooling. The distribution includes an executable program that runs on Windows Xp, Mac OS X (Intel), or on most modern versions of Linux (it has been tested to run on all RedHat-drived distributions since 7.1, including Fedora Core 1-8). Moreover, the visualization capabilities of Geant4 are available with no further effort, including visualization using OpenInventor, OpenGL, HepRep, DAWN, VRML, and other viewers (as long as your system supports X-windows with the GLX extension). The internal design of the program makes it relatively simple to add new commands and beamline elements to its repertoire (this does, however, require C++ programming).

A major limitation of g4beamline is that at present it does not simulate the performance of real-world detectors. It implements "virtual" detectors which sample the tracks that intersect them with the precision of a float, and measure all tracking variables (X,Y,Z,Px,Py,Pz,t,PDGid). Each virtualdetector generates an NTuple in the output file, which can be histogrammed with the appropriate program. NTuples can be written to Root or ASCII files, and the historoot program is included to make it easy o generate plots using Root. So g4beamline will tell you where the particles go, but won't give details of real-world detector outputs.

Another limitation of g4beamline is that at present it does not implement parameterized placements of volumes. These are required for a practical implementation of the many segments of modern detectors.

Getting Started

G4beamline is available for Mac OS X, Windows, and Linux. It is distributed as an application for each OS, and also as source. All are available here.

More details are contained in the G4beamline User's Guide, and in the README files in the distributions.

G4beamline is an open-source program distributed for Linux, Mac OS X, and Windows; it can also be built from source.


G4beamline documentation is contained in the G4beamline User's Guide. It is updated for each release and included in the installers.

As a physics code, it is important to know how accurately G4beamline models physical processes, and to validate their behavior. Here is the G4beamline Validation document. It is included in the installers.


G4beamline support is handled via our Forum. This includes general discussions about G4beamline, bug reports, net feature requests, etc.

You may request to join the forum: mailto:g4beamline+subscribe@muonsinc.com

After verifying your email address, your request must be approved by an administrator (this is a Google Group, which should not have the serious spam problems that closed down our old forum).


In order to justify funding for continued G4beamline support, we need to know how many users are using G4beamline, what they are doing with it, and how much time and effort they have devoted to using the program. So before downloading G4beamline, we will ask you to take a minute or two to answer our survey. (The website keeps track of your email and when you answered the survey, and won't ask again for a year.)

Muons, Inc. now requires a valid email address before downloading G4beamline. We will use your email only to keep track of your survey response and downloads, and for occasional G4beamline-related announcements. It will not be used for any marketing or other purposes.

Clicking on this link will permit you to submit your email address; an email will be sent to this address with a link that permits you to fill our our survey and then download G4beamline:

G4beamline Download

G4beamline is an open-source program distributed for Linux, Mac OS X, and Windows; it can also be built from source.