Defining Physics Lists#

We need to provide a type to the G4JLApplication that represents the selected physics list. The easiest is to use one of the pre-packaged physics list (e.g. FTFP_BERT, QGS_BIC, QBBC and others can be added on demand). The toolkit will use the provided type to instantiate the physics list at the right moment during the initialization.

using Geant4
using Test

Using Standard Physics Lists#

Lets play a bit one of these pre-packaged physics list

fl = FTFP_BERT()
@test fl isa G4VUserPhysicsList
DumpList(fl)
<<< Geant4 Physics List simulation engine: FTFP_BERT

It is normal that created instance by hand is empty. It needs to be created by the G4RunManager during initialization. Let’s try to do it.

app = G4JLApplication(
    physics_type = FTFP_BERT
)
**************************************************************
 Geant4 version Name: geant4-11-02-patch-01 [MT]   (16-February-2024)
                       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/
**************************************************************
G4JLApplication{Geant4.G4JLEmptyDetector, Geant4.G4JLNoData}(Geant4.G4RunManagerAllocated(Ptr{Nothing} @0x0000000001e91cc0), Geant4.G4JLEmptyDetector(), [Geant4.G4JLNoData()], G4JLGunGenerator("ParticleGun", Geant4.G4JLParticleGunData(nothing, "e-", G4ThreeVector(0.0,0.0,0.0), G4ThreeVector(0.0,0.0,0.0), 10.0), Geant4.var"#init#19"(), Geant4.var"#gen#20"(), G4JLGeneratorAction[]), nothing, nothing, 0, 0, G4RunManager, G4JLDetectorConstruction, FTFP_BERT, G4JLRunAction, G4JLEventAction, G4JLTrackingAction, G4JLSteppingAction, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, Dict{String, Geant4.G4JLProtoSD}(), Dict{String, Vector{G4JLSensitiveDetector}}(), G4JLScoringMesh[], nothing, nothing)
configure(app)
initialize(app)
DumpList(app.physics)
B+, B-, B0, Bc+
Bc-, Bs0, D+, D-
D0, Ds+, Ds-, GenericIon
He3, J/psi, N(1440)+, N(1440)0
N(1520)+, N(1520)0, N(1535)+, N(1535)0
N(1650)+, N(1650)0, N(1675)+, N(1675)0
N(1680)+, N(1680)0, N(1700)+, N(1700)0
N(1710)+, N(1710)0, N(1720)+, N(1720)0
N(1900)+, N(1900)0, N(1990)+, N(1990)0
N(2090)+, N(2090)0, N(2190)+, N(2190)0
N(2220)+, N(2220)0, N(2250)+, N(2250)0
Upsilon, a0(1450)+, a0(1450)-, a0(1450)0
a0(980)+, a0(980)-, a0(980)0, a1(1260)+
a1(1260)-, a1(1260)0, a2(1320)+, a2(1320)-
a2(1320)0, alpha, anti_B0, anti_Bs0
anti_D0, anti_He3, anti_N(1440)+, anti_N(1440)0
anti_N(1520)+, anti_N(1520)0, anti_N(1535)+, anti_N(1535)0
anti_N(1650)+, anti_N(1650)0, anti_N(1675)+, anti_N(1675)0
anti_N(1680)+, anti_N(1680)0, anti_N(1700)+, anti_N(1700)0
anti_N(1710)+, anti_N(1710)0, anti_N(1720)+, anti_N(1720)0
anti_N(1900)+, anti_N(1900)0, anti_N(1990)+, anti_N(1990)0
anti_N(2090)+, anti_N(2090)0, anti_N(2190)+, anti_N(2190)0
anti_N(2220)+, anti_N(2220)0, anti_N(2250)+, anti_N(2250)0
anti_alpha, anti_b_quark, anti_bb1_diquark, anti_bc0_diquark
anti_bc1_diquark, anti_bd0_diquark, anti_bd1_diquark, anti_bs0_diquark
anti_bs1_diquark, anti_bu0_diquark, anti_bu1_diquark, anti_c_quark
anti_cc1_diquark, anti_cd0_diquark, anti_cd1_diquark, anti_cs0_diquark
anti_cs1_diquark, anti_cu0_diquark, anti_cu1_diquark, anti_d_quark
anti_dd1_diquark, anti_delta(1600)+, anti_delta(1600)++, anti_delta(1600)-
anti_delta(1600)0, anti_delta(1620)+, anti_delta(1620)++, anti_delta(1620)-
anti_delta(1620)0, anti_delta(1700)+, anti_delta(1700)++, anti_delta(1700)-
anti_delta(1700)0, anti_delta(1900)+, anti_delta(1900)++, anti_delta(1900)-
anti_delta(1900)0, anti_delta(1905)+, anti_delta(1905)++, anti_delta(1905)-
anti_delta(1905)0, anti_delta(1910)+, anti_delta(1910)++, anti_delta(1910)-
anti_delta(1910)0, anti_delta(1920)+, anti_delta(1920)++, anti_delta(1920)-
anti_delta(1920)0, anti_delta(1930)+, anti_delta(1930)++, anti_delta(1930)-
anti_delta(1930)0, anti_delta(1950)+, anti_delta(1950)++, anti_delta(1950)-
anti_delta(1950)0, anti_delta+, anti_delta++, anti_delta-
anti_delta0, anti_deuteron, anti_doublehyperH4, anti_doublehyperdoubleneutron
anti_hyperH4, anti_hyperHe5, anti_hyperalpha, anti_hypertriton
anti_k(1460)0, anti_k0_star(1430)0, anti_k1(1270)0, anti_k1(1400)0
anti_k2(1770)0, anti_k2_star(1430)0, anti_k2_star(1980)0, anti_k3_star(1780)0
anti_k_star(1410)0, anti_k_star(1680)0, anti_k_star0, anti_kaon0
anti_lambda, anti_lambda(1405), anti_lambda(1520), anti_lambda(1600)
anti_lambda(1670), anti_lambda(1690), anti_lambda(1800), anti_lambda(1810)
anti_lambda(1820), anti_lambda(1830), anti_lambda(1890), anti_lambda(2100)
anti_lambda(2110), anti_lambda_b, anti_lambda_c+, anti_neutron
anti_nu_e, anti_nu_mu, anti_nu_tau, anti_omega-
anti_omega_b-, anti_omega_c0, anti_proton, anti_s_quark
anti_sd0_diquark, anti_sd1_diquark, anti_sigma(1385)+, anti_sigma(1385)-
anti_sigma(1385)0, anti_sigma(1660)+, anti_sigma(1660)-, anti_sigma(1660)0
anti_sigma(1670)+, anti_sigma(1670)-, anti_sigma(1670)0, anti_sigma(1750)+
anti_sigma(1750)-, anti_sigma(1750)0, anti_sigma(1775)+, anti_sigma(1775)-
anti_sigma(1775)0, anti_sigma(1915)+, anti_sigma(1915)-, anti_sigma(1915)0
anti_sigma(1940)+, anti_sigma(1940)-, anti_sigma(1940)0, anti_sigma(2030)+
anti_sigma(2030)-, anti_sigma(2030)0, anti_sigma+, anti_sigma-
anti_sigma0, anti_sigma_b+, anti_sigma_b-, anti_sigma_b0
anti_sigma_c+, anti_sigma_c++, anti_sigma_c0, anti_ss1_diquark
anti_su0_diquark, anti_su1_diquark, anti_t_quark, anti_triton
anti_u_quark, anti_ud0_diquark, anti_ud1_diquark, anti_uu1_diquark
anti_xi(1530)-, anti_xi(1530)0, anti_xi(1690)-, anti_xi(1690)0
anti_xi(1820)-, anti_xi(1820)0, anti_xi(1950)-, anti_xi(1950)0
anti_xi(2030)-, anti_xi(2030)0, anti_xi-, anti_xi0
anti_xi_b-, anti_xi_b0, anti_xi_c+, anti_xi_c0
b1(1235)+, b1(1235)-, b1(1235)0, b_quark
bb1_diquark, bc0_diquark, bc1_diquark, bd0_diquark
bd1_diquark, bs0_diquark, bs1_diquark, bu0_diquark
bu1_diquark, c_quark, cc1_diquark, cd0_diquark
cd1_diquark, chargedgeantino, cs0_diquark, cs1_diquark
cu0_diquark, cu1_diquark, d_quark, dd1_diquark
delta(1600)+, delta(1600)++, delta(1600)-, delta(1600)0
delta(1620)+, delta(1620)++, delta(1620)-, delta(1620)0
delta(1700)+, delta(1700)++, delta(1700)-, delta(1700)0
delta(1900)+, delta(1900)++, delta(1900)-, delta(1900)0
delta(1905)+, delta(1905)++, delta(1905)-, delta(1905)0
delta(1910)+, delta(1910)++, delta(1910)-, delta(1910)0
delta(1920)+, delta(1920)++, delta(1920)-, delta(1920)0
delta(1930)+, delta(1930)++, delta(1930)-, delta(1930)0
delta(1950)+, delta(1950)++, delta(1950)-, delta(1950)0
delta+, delta++, delta-, delta0
deuteron, doublehyperH4, doublehyperdoubleneutron, e+
e-, eta, eta(1295), eta(1405)
eta(1475), eta2(1645), eta2(1870), eta_prime
etac, f0(1370), f0(1500), f0(1710)
f0(500), f0(980), f1(1285), f1(1420)
f2(1270), f2(1810), f2(2010), f2_prime(1525)
gamma, geantino, gluon, h1(1170)
h1(1380), hyperH4, hyperHe5, hyperalpha
hypertriton, k(1460)+, k(1460)-, k(1460)0
k0_star(1430)+, k0_star(1430)-, k0_star(1430)0, k1(1270)+
k1(1270)-, k1(1270)0, k1(1400)+, k1(1400)-
k1(1400)0, k2(1770)+, k2(1770)-, k2(1770)0
k2_star(1430)+, k2_star(1430)-, k2_star(1430)0, k2_star(1980)+
k2_star(1980)-, k2_star(1980)0, k3_star(1780)+, k3_star(1780)-
k3_star(1780)0, k_star(1410)+, k_star(1410)-, k_star(1410)0
k_star(1680)+, k_star(1680)-, k_star(1680)0, k_star+
k_star-, k_star0, kaon+, kaon-
kaon0, kaon0L, kaon0S, lambda
lambda(1405), lambda(1520), lambda(1600), lambda(1670)
lambda(1690), lambda(1800), lambda(1810), lambda(1820)
lambda(1830), lambda(1890), lambda(2100), lambda(2110)
lambda_b, lambda_c+, mu+, mu-
neutron, nu_e, nu_mu, nu_tau
omega, omega(1420), omega(1650), omega-
omega3(1670), omega_b-, omega_c0, opticalphoton
phi, phi(1680), phi3(1850), pi(1300)+
pi(1300)-, pi(1300)0, pi+, pi-
pi0, pi2(1670)+, pi2(1670)-, pi2(1670)0
proton, rho(1450)+, rho(1450)-, rho(1450)0
rho(1700)+, rho(1700)-, rho(1700)0, rho+
rho-, rho0, rho3(1690)+, rho3(1690)-
rho3(1690)0, s_quark, sd0_diquark, sd1_diquark
sigma(1385)+, sigma(1385)-, sigma(1385)0, sigma(1660)+
sigma(1660)-, sigma(1660)0, sigma(1670)+, sigma(1670)-
sigma(1670)0, sigma(1750)+, sigma(1750)-, sigma(1750)0
sigma(1775)+, sigma(1775)-, sigma(1775)0, sigma(1915)+
sigma(1915)-, sigma(1915)0, sigma(1940)+, sigma(1940)-
sigma(1940)0, sigma(2030)+, sigma(2030)-, sigma(2030)0
sigma+, sigma-, sigma0, sigma_b+
sigma_b-, sigma_b0, sigma_c+, sigma_c++
sigma_c0, ss1_diquark, su0_diquark, su1_diquark
t_quark, tau+, tau-, triton
u_quark, ud0_diquark, ud1_diquark, uu1_diquark
xi(1530)-, xi(1530)0, xi(1690)-, xi(1690)0
xi(1820)-, xi(1820)0, xi(1950)-, xi(1950)0
xi(2030)-, xi(2030)0, xi-, xi0
xi_b-, xi_b0, xi_c+, xi_c0

Defining a custom physics list#

The way we can achieve it is by defining a dummy struct inheriting from G4VUserPhysicsList that provides a default constructor. In the constructor we can build the physics list and return an object that inherits from G4VUserPhysicsList to comply with the interface.

Here is an example:

ui`/control/verbose 1`
ui`/run/verbose 1`
/run/verbose 1
0
struct MyPhysicsList <: G4VUserPhysicsList
    function MyPhysicsList(verbose)
        pl = G4VModularPhysicsList()
        RegisterPhysics(pl, move!(G4EmStandardPhysics(verbose)))  # make sure that the ownership is correctly transferred
        RegisterPhysics(pl, move!(G4OpticalPhysics(verbose)))     # by calling move!()
        return pl
    end 
end
app = G4JLApplication(
    physics_type = MyPhysicsList,
    verbose=1,
)
configure(app)
initialize(app)
DumpList(app.physics)
B+, B-, B0, Bc+
Bc-, Bs0, D+, D-
D0, Ds+, Ds-, GenericIon
He3, J/psi, N(1440)+, N(1440)0
N(1520)+, N(1520)0, N(1535)+, N(1535)0
N(1650)+, N(1650)0, N(1675)+, N(1675)0
N(1680)+, N(1680)0, N(1700)+, N(1700)0
N(1710)+, N(1710)0, N(1720)+, N(1720)0
N(1900)+, N(1900)0, N(1990)+, N(1990)0
N(2090)+, N(2090)0, N(2190)+, N(2190)0
N(2220)+, N(2220)0, N(2250)+, N(2250)0
Upsilon, a0(1450)+, a0(1450)-, a0(1450)0
a0(980)+, a0(980)-, a0(980)0, a1(1260)+
a1(1260)-, a1(1260)0, a2(1320)+, a2(1320)-
a2(1320)0, alpha, anti_B0, anti_Bs0
anti_D0, anti_He3, anti_N(1440)+, anti_N(1440)0
anti_N(1520)+, anti_N(1520)0, anti_N(1535)+, anti_N(1535)0
anti_N(1650)+, anti_N(1650)0, anti_N(1675)+, anti_N(1675)0
anti_N(1680)+, anti_N(1680)0, anti_N(1700)+, anti_N(1700)0
anti_N(1710)+, anti_N(1710)0, anti_N(1720)+, anti_N(1720)0
anti_N(1900)+, anti_N(1900)0, anti_N(1990)+, anti_N(1990)0
anti_N(2090)+, anti_N(2090)0, anti_N(2190)+, anti_N(2190)0
anti_N(2220)+, anti_N(2220)0, anti_N(2250)+, anti_N(2250)0
anti_alpha, anti_b_quark, anti_bb1_diquark, anti_bc0_diquark
anti_bc1_diquark, anti_bd0_diquark, anti_bd1_diquark, anti_bs0_diquark
anti_bs1_diquark, anti_bu0_diquark, anti_bu1_diquark, anti_c_quark
anti_cc1_diquark, anti_cd0_diquark, anti_cd1_diquark, anti_cs0_diquark
anti_cs1_diquark, anti_cu0_diquark, anti_cu1_diquark, anti_d_quark
anti_dd1_diquark, anti_delta(1600)+, anti_delta(1600)++, anti_delta(1600)-
anti_delta(1600)0, anti_delta(1620)+, anti_delta(1620)++, anti_delta(1620)-
anti_delta(1620)0, anti_delta(1700)+, anti_delta(1700)++, anti_delta(1700)-
anti_delta(1700)0, anti_delta(1900)+, anti_delta(1900)++, anti_delta(1900)-
anti_delta(1900)0, anti_delta(1905)+, anti_delta(1905)++, anti_delta(1905)-
anti_delta(1905)0, anti_delta(1910)+, anti_delta(1910)++, anti_delta(1910)-
anti_delta(1910)0, anti_delta(1920)+, anti_delta(1920)++, anti_delta(1920)-
anti_delta(1920)0, anti_delta(1930)+, anti_delta(1930)++, anti_delta(1930)-
anti_delta(1930)0, anti_delta(1950)+, anti_delta(1950)++, anti_delta(1950)-
anti_delta(1950)0, anti_delta+, anti_delta++, anti_delta-
anti_delta0, anti_deuteron, anti_doublehyperH4, anti_doublehyperdoubleneutron
anti_hyperH4, anti_hyperHe5, anti_hyperalpha, anti_hypertriton
anti_k(1460)0, anti_k0_star(1430)0, anti_k1(1270)0, anti_k1(1400)0
anti_k2(1770)0, anti_k2_star(1430)0, anti_k2_star(1980)0, anti_k3_star(1780)0
anti_k_star(1410)0, anti_k_star(1680)0, anti_k_star0, anti_kaon0
anti_lambda, anti_lambda(1405), anti_lambda(1520), anti_lambda(1600)
anti_lambda(1670), anti_lambda(1690), anti_lambda(1800), anti_lambda(1810)
anti_lambda(1820), anti_lambda(1830), anti_lambda(1890), anti_lambda(2100)
anti_lambda(2110), anti_lambda_b, anti_lambda_c+, anti_neutron
anti_nu_e, anti_nu_mu, anti_nu_tau, anti_omega-
anti_omega_b-, anti_omega_c0, anti_proton, anti_s_quark
anti_sd0_diquark, anti_sd1_diquark, anti_sigma(1385)+, anti_sigma(1385)-
anti_sigma(1385)0, anti_sigma(1660)+, anti_sigma(1660)-, anti_sigma(1660)0
anti_sigma(1670)+, anti_sigma(1670)-, anti_sigma(1670)0, anti_sigma(1750)+
anti_sigma(1750)-, anti_sigma(1750)0, anti_sigma(1775)+, anti_sigma(1775)-
anti_sigma(1775)0, anti_sigma(1915)+, anti_sigma(1915)-, anti_sigma(1915)0
anti_sigma(1940)+, anti_sigma(1940)-, anti_sigma(1940)0, anti_sigma(2030)+
anti_sigma(2030)-, anti_sigma(2030)0, anti_sigma+, anti_sigma-
anti_sigma0, anti_sigma_b+, anti_sigma_b-, anti_sigma_b0
anti_sigma_c+, anti_sigma_c++, anti_sigma_c0, anti_ss1_diquark
anti_su0_diquark, anti_su1_diquark, anti_t_quark, anti_triton
anti_u_quark, anti_ud0_diquark, anti_ud1_diquark, anti_uu1_diquark
anti_xi(1530)-, anti_xi(1530)0, anti_xi(1690)-, anti_xi(1690)0
anti_xi(1820)-, anti_xi(1820)0, anti_xi(1950)-, anti_xi(1950)0
anti_xi(2030)-, anti_xi(2030)0, anti_xi-, anti_xi0
anti_xi_b-, anti_xi_b0, anti_xi_c+, anti_xi_c0
b1(1235)+, b1(1235)-, b1(1235)0, b_quark
bb1_diquark, bc0_diquark, bc1_diquark, bd0_diquark
bd1_diquark, bs0_diquark, bs1_diquark, bu0_diquark
bu1_diquark, c_quark, cc1_diquark, cd0_diquark
cd1_diquark, chargedgeantino, cs0_diquark, cs1_diquark
cu0_diquark, cu1_diquark, d_quark, dd1_diquark
delta(1600)+, delta(1600)++, delta(1600)-, delta(1600)0
delta(1620)+, delta(1620)++, delta(1620)-, delta(1620)0
delta(1700)+, delta(1700)++, delta(1700)-, delta(1700)0
delta(1900)+, delta(1900)++, delta(1900)-, delta(1900)0
delta(1905)+, delta(1905)++, delta(1905)-, delta(1905)0
delta(1910)+, delta(1910)++, delta(1910)-, delta(1910)0
delta(1920)+, delta(1920)++, delta(1920)-, delta(1920)0
delta(1930)+, delta(1930)++, delta(1930)-, delta(1930)0
delta(1950)+, delta(1950)++, delta(1950)-, delta(1950)0
delta+, delta++, delta-, delta0
deuteron, doublehyperH4, doublehyperdoubleneutron, e+
e-, eta, eta(1295), eta(1405)
eta(1475), eta2(1645), eta2(1870), eta_prime
etac, f0(1370), f0(1500), f0(1710)
f0(500), f0(980), f1(1285), f1(1420)
f2(1270), f2(1810), f2(2010), f2_prime(1525)
gamma, geantino, gluon, h1(1170)
h1(1380), hyperH4, hyperHe5, hyperalpha
hypertriton, k(1460)+, k(1460)-, k(1460)0
k0_star(1430)+, k0_star(1430)-, k0_star(1430)0, k1(1270)+
k1(1270)-, k1(1270)0, k1(1400)+, k1(1400)-
k1(1400)0, k2(1770)+, k2(1770)-, k2(1770)0
k2_star(1430)+, k2_star(1430)-, k2_star(1430)0, k2_star(1980)+
k2_star(1980)-, k2_star(1980)0, k3_star(1780)+, k3_star(1780)-
k3_star(1780)0, k_star(1410)+, k_star(1410)-, k_star(1410)0
k_star(1680)+, k_star(1680)-, k_star(1680)0, k_star+
k_star-, k_star0, kaon+, kaon-
kaon0, kaon0L, kaon0S, lambda
lambda(1405), lambda(1520), lambda(1600), lambda(1670)
lambda(1690), lambda(1800), lambda(1810), lambda(1820)
lambda(1830), lambda(1890), lambda(2100), lambda(2110)
lambda_b, lambda_c+, mu+, mu-
neutron, nu_e, nu_mu, nu_tau
omega, omega(1420), omega(1650), omega-
omega3(1670), omega_b-, omega_c0, opticalphoton
phi, phi(1680), phi3(1850), pi(1300)+
pi(1300)-, pi(1300)0, pi+, pi-
pi0, pi2(1670)+, pi2(1670)-, pi2(1670)0
proton, rho(1450)+, rho(1450)-, rho(1450)0
rho(1700)+, rho(1700)-, rho(1700)0, rho+
rho-, rho0, rho3(1690)+, rho3(1690)-
rho3(1690)0, s_quark, sd0_diquark, sd1_diquark
sigma(1385)+, sigma(1385)-, sigma(1385)0, sigma(1660)+
sigma(1660)-, sigma(1660)0, sigma(1670)+, sigma(1670)-
sigma(1670)0, sigma(1750)+, sigma(1750)-, sigma(1750)0
sigma(1775)+, sigma(1775)-, sigma(1775)0, sigma(1915)+
sigma(1915)-, sigma(1915)0, sigma(1940)+, sigma(1940)-
sigma(1940)0, sigma(2030)+, sigma(2030)-, sigma(2030)0
sigma+, sigma-, sigma0, sigma_b+
sigma_b-, sigma_b0, sigma_c+, sigma_c++
sigma_c0, ss1_diquark, su0_diquark, su1_diquark
t_quark, tau+, tau-, triton
u_quark, ud0_diquark, ud1_diquark, uu1_diquark
xi(1530)-, xi(1530)0, xi(1690)-, xi(1690)0
xi(1820)-, xi(1820)0, xi(1950)-, xi(1950)0
xi(2030)-, xi(2030)0, xi-, xi0
xi_b-, xi_b0, xi_c+, xi_c0