Public API

Documentation for Geant4.jl public interface.

Index - Types

Index - Functions

Types

Geant4.G4JLApplication — Method
G4JLApplication(<keyword arguments>)

Create a Geant4 application with its detector, physics list, primary generator, user actions, sensitive detectors and scoring meshes.

Arguments

  • detector::G4JLDetector: detector description object
  • simdata=G4JLNoData(): simulation data object
  • generator=G4JLGunGenerator(): primary particle generator
  • field=nothing: magnetic or electric field
  • evtdisplay=nothing: event display (visualization)
  • nthreads=0: number of Geant4 worker threads ( >0 implies MT)
  • verbose=0: default verbosity level (physics, ...)
  • runmanager_type=G4RunManager: run manager type
  • builder_type=G4JLDetectorConstruction: detector builder type (the default should be fine most cases)
  • physics_type=FTFP_BERT: physics list type
  • stepaction_type=G4JLSteppingAction: stepping action type (the default should be fine most cases)
  • trackaction_type=G4JLTrackingAction: tracking action type (the default should be fine most cases)
  • runaction_type=G4JLRunAction: run action type (the default should be fine most cases)
  • eventaction_type=G4JLEventAction: event action type (the default should be fine most cases)
  • stepaction_method=nothing: stepping action method with signature (::G4Step, ::G4JLApplication)::Nothing
  • pretrackaction_method=nothing: pre-tracking action method with signature (::G4Track, ::G4JLApplication)::Nothing
  • posttrackaction_method=nothing: post-tracking action method with signature (::G4Track, ::G4JLApplication)::Nothing
  • beginrunaction_method=nothing: begin run action method with signature (::G4Run, ::G4JLApplication)::Nothing
  • endrunaction_method=nothing: end run action method with signature (::G4Run, ::G4JLApplication)::Nothing
  • begineventaction_method=nothing: begin event action method with signature (::G4Event, ::G4JLApplication)::Nothing
  • endeventaction_method=nothing: end event action method with signature (::G4Event, ::G4JLApplication)::Nothing
  • stackaction_method=nothing: stacking classification of new track with signature (::G4Track, ::G4JLApplication)::G4ClassificationOfNewTrack
  • statechange_method=nothing: state change notification method with signature (from::G4ApplicationState, to::G4ApplicationState, ::G4JLApplication)::Bool
  • sdetectors::Vector{}=[]: vector of pairs lv::String => sd::G4JLSensitiveDetector to associate logical volumes to sensitive detectors. A trailing + in lv attaches the detector to all logical volumes with that name
  • scorers::Vector{}=[]: vector of G4JLScoringMeshs
source
Geant4.G4JLDetectorGDML — Method
G4JLDetectorGDML(gdmlfile::String; check_overlap::Bool, validate_schema::Bool, init_method::Union{Function,Nothing})

Initialize a G4JLDetector from a GDML file. The GDML file is parsed at this moment.

Arguments

  • gdmlfile::String: GDML file name
  • check_overlap::Bool=false: check for overlaps
  • validate_schema::Bool=true: validate the schema
  • init_method::Union{Function,Nothing}=nothing: initialization method to be called when the detector is constructed
source
Geant4.G4JLElectricField — Method
G4JLElectricField(name::String, data::DATA; <keyword arguments>) where DATA<:G4JLFieldData

Create a custom electric field with its name and associated DATA structure.

Arguments

  • name::String: electric field name
  • data::DATA: data structure associated to the electric field
  • getfield_method: user provided function with signature (result::G4ThreeVector, position::G4ThreeVector, ::DATA)::Nothing. It must set the field value in result, for example with assign(result, G4ThreeVector(...)). Mandatory.
source
Geant4.G4JLGeneralParticleSource — Type
G4JLGeneralParticleSource(; sources, multiplevertex=false, flatsampling=false)
G4JLGeneralParticleSource(; particle, energy, direction, position, ...)

Create a generator based on the Geant4 G4GeneralParticleSource.

With sources, each element of the vector is a NamedTuple describing one source: particle, intensity, and the energy (ene), position (pos) and angular (ang) distributions, each given as a NamedTuple whose fields correspond to the /gps/ene/..., /gps/pos/... and /gps/ang/... UI commands. Without sources, the keyword arguments describe a single source.

Example

src = (particle="e+", intensity=1.0,
       ene=(type="Exp", min=2MeV, max=10MeV, ezero=2.),
       pos=(type="Plane", shape="Circle", centre=G4ThreeVector(1cm,2cm,0cm), radius=3cm),
       ang=(type="cos", mintheta=0deg, maxtheta=180deg))
gps = G4JLGeneralParticleSource(sources = [src])
source
Geant4.G4JLGunGenerator — Type
G4JLGunGenerator(; particle="e-", energy=10., direction=G4ThreeVector(), position=G4ThreeVector())

Create a particle gun generator (a G4ParticleGun) with the given particle type, energy, direction and position.

Arguments

  • particle::String="e-": The name of the particle to be generated (default is electron).
  • energy::Float64=10.: The kinetic energy of the particle (default is 10 MeV).
  • direction::G4ThreeVector=G4ThreeVector(): The momentum direction of the particle (default is zero vector).
  • position::G4ThreeVector=G4ThreeVector(): The position of the particle (default is zero vector).
source
Geant4.G4JLMagneticField — Method
G4JLUniformMagField(field::G4ThreeVector)

Create a Uniform magnetic field

Arguments

  • field::G4ThreeVector: magnetic field vector
source
Geant4.G4JLMagneticField — Method
G4JLMagneticField(name::String, data::DATA; <keyword arguments>) where DATA<:G4JLFieldData

Create a custom magnetic field with its name and associated DATA structure.

Arguments

  • name::String: magnetic field name
  • data::DATA: data structure associated to the magnetic field
  • getfield_method: user provided function with signature (result::G4ThreeVector, position::G4ThreeVector, ::DATA)::Nothing. It must set the field value in result, for example with assign(result, G4ThreeVector(...)). Mandatory.
source
Geant4.G4JLPrimaryGenerator — Method
G4JLPrimaryGenerator(name::String, data::DATA; <keyword arguments>) where DATA<:G4JLGeneratorData

Create a custom primary particle generator with its name and associated DATA structure.

Arguments

  • name::String: generator name
  • data::DATA: data structure with the generator parameters
  • init_method=nothing: initialization function with signature (data::DATA, app::G4JLApplication), called once in each thread
  • generate_method: generation function with signature (evt::G4Event, data::DATA)::Nothing, called for each event. Mandatory.
source
Geant4.G4JLScoringMesh — Method
G4JLScoringMesh(name, mesh; <keyword arguments>)

Create a scoring mesh to be added to the Geant4 application.

Arguments

  • name::String: scoring mesh name
  • mesh::AbstractMesh: mesh instance. Either a BoxMesh or CylinderMesh
  • bins::Tuple: tuple with number on bins in x, y, z (default 30, 30, 30)
  • translation::Tuple: position (x,y,z) with respect the mesh respect to the world volume. Default is (0,0,0).
  • rotation::Tuple: rotation of the mesh with respect the world volume. Default (0,0,0)
  • quantities::Vector: vector of quantities to be scored (e.g. energyDeposit, doseDeposit, nOfStep)
source
Geant4.G4JLSensitiveDetector — Method
G4JLSensitiveDetector(name::String, data::DATA; <keyword arguments>) where DATA<:G4JLSDData

Initialize a G4JLSensitiveDetector with its name and associated DATA structure.

Arguments

  • name::String: Sensitive detector name
  • data::DATA: Data structure associted to the sensitive detector
  • processhits_method: function called for each step in the sensitive volumes, with signature (step::G4Step, ::G4TouchableHistory, data::DATA)::Bool. It returns true if a hit was produced. Mandatory.
  • initialize_method=nothing: function called at the start of each event, with signature (::G4HCofThisEvent, data::DATA)::Nothing
  • endofevent_method=nothing: function called at the end of each event, with signature (::G4HCofThisEvent, data::DATA)::Nothing
source
Geant4.G4PVParameterised — Method
G4PVParameterised(name::String, lv::G4LogicalVolume, mother::G4LogicalVolume, axis::EAxis, n::Int,
                  transform::Function; data=nothing, checkOverlaps=false)

Create n copies of the logical volume lv inside mother, positioned by the user function transform(copyNo::Int32, pv::G4VPhysicalVolume, data)::Nothing, which must set the translation (and the rotation) of the copy copyNo with SetTranslation(pv, ...) (and SetRotation(pv, ...)). The rotation is kept by pointer, so it must not be garbage collected. The function is called by the navigation from all the worker threads, so it must not modify data.

source

Functions

Geant4.G4JL_println — Function
G4JL_println(::AbstractString)

Print the string to the Geant4 output in a thread safe manner prefixing the string with the thread ID.

Arguments

  • s::AbstractString: string to be printed
source
Geant4.GetVolume — Method
GetVolume(name::String)

Get the G4LogicalVolume with this name.

Arguments

  • name::String: logical volume name
source
Geant4.beamOn — Method
beamOn(app::G4JLApplication, nevents::Int)

Start a new run with nevents events. In case of multi-threading, the function enters a GC safe state before starting the run.

Arguments

  • app::G4JLApplication: Geant4 application
  • nevents::Int: number of events
source
Geant4.configure — Method
configure(app::G4JLApplication)

Configure the Geant4 application. It sets the declared user actions, event generator, and physics list.

Arguments

  • app::G4JLApplication: Geant4 application
source
Geant4.getSDdata — Method
getSDdata(app::G4JLApplication, name::String)

Get the data associated to the Sensitive Detector with a given name taking into account the current worker thread ID

Arguments

  • app::G4JLApplication: Geant4 application
  • name::String: sensitive detector name
source
Geant4.getSIMdata — Method
getSIMdata(app::G4JLApplication)

Get the Simulation Data taking into account the current worker thread ID

Arguments

  • app::G4JLApplication: Geant4 application
source
Geant4.getfield — Method
getfield(pos::G4ThreeVector, bfield::G4JLMagneticField)

Function to exercise a custom magnetic field

Arguments

  • pos::G4ThreeVector: position
  • bfield::G4JLMagneticField: magnetic field object
source
Geant4.initialize — Method
initialize(app::G4JLApplication)

Initialize the Geant4 application. It initializes the G4RunManager, which constructs the detector geometry, and sets the declared sensitive detectors. In case of multi-threading, the function enters a GC safe state before initializing the application, which will be calling thebuild()` functions by the worker threads.

Arguments

  • app::G4JLApplication: Geant4 application
source
Geant4.move! — Method
move!(o)

Move ownership of the C++ object to the receiver, so that it is not deleted by the Julia garbage collector. The Julia object cannot be used anymore after this call.

source
Geant4.reinitialize — Method
reinitialize(app::G4JLApplication, det::G4JLDetector)

Re-initialize the Geant4 application with a new detector definition.

Arguments

  • app::G4JLApplication: Geant4 application
  • det::G4JLDetector: new detector definition
source