Public API
Documentation for Geant4.jl public interface.
Index - Types
Geant4.G4JLApplicationGeant4.G4JLDetectorGDMLGeant4.G4JLElectricFieldGeant4.G4JLElectricFieldGeant4.G4JLGeneralParticleSourceGeant4.G4JLGunGeneratorGeant4.G4JLMagneticFieldGeant4.G4JLMagneticFieldGeant4.G4JLMagneticFieldGeant4.G4JLPrimaryGeneratorGeant4.G4JLScoringMeshGeant4.G4JLSensitiveDetectorGeant4.G4PVParameterised
Index - Functions
Geant4.G4JL_printlnGeant4.GetVolumeGeant4.GetWorldVolumeGeant4.beamOnGeant4.configureGeant4.getSDdataGeant4.getSIMdataGeant4.getfieldGeant4.initializeGeant4.move!Geant4.reinitialize
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 objectsimdata=G4JLNoData(): simulation data objectgenerator=G4JLGunGenerator(): primary particle generatorfield=nothing: magnetic or electric fieldevtdisplay=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 typebuilder_type=G4JLDetectorConstruction: detector builder type (the default should be fine most cases)physics_type=FTFP_BERT: physics list typestepaction_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)::Nothingpretrackaction_method=nothing: pre-tracking action method with signature(::G4Track, ::G4JLApplication)::Nothingposttrackaction_method=nothing: post-tracking action method with signature(::G4Track, ::G4JLApplication)::Nothingbeginrunaction_method=nothing: begin run action method with signature(::G4Run, ::G4JLApplication)::Nothingendrunaction_method=nothing: end run action method with signature(::G4Run, ::G4JLApplication)::Nothingbegineventaction_method=nothing: begin event action method with signature(::G4Event, ::G4JLApplication)::Nothingendeventaction_method=nothing: end event action method with signature(::G4Event, ::G4JLApplication)::Nothingstackaction_method=nothing: stacking classification of new track with signature(::G4Track, ::G4JLApplication)::G4ClassificationOfNewTrackstatechange_method=nothing: state change notification method with signature(from::G4ApplicationState, to::G4ApplicationState, ::G4JLApplication)::Boolsdetectors::Vector{}=[]: vector of pairslv::String => sd::G4JLSensitiveDetectorto associate logical volumes to sensitive detectors. A trailing+inlvattaches the detector to all logical volumes with that namescorers::Vector{}=[]: vector ofG4JLScoringMeshs
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 namecheck_overlap::Bool=false: check for overlapsvalidate_schema::Bool=true: validate the schemainit_method::Union{Function,Nothing}=nothing: initialization method to be called when the detector is constructed
Geant4.G4JLElectricField — Type
Custom Electric FieldGeant4.G4JLElectricField — Method
G4JLElectricField(name::String, data::DATA; <keyword arguments>) where DATA<:G4JLFieldDataCreate a custom electric field with its name and associated DATA structure.
Arguments
name::String: electric field namedata::DATA: data structure associated to the electric fieldgetfield_method: user provided function with signature(result::G4ThreeVector, position::G4ThreeVector, ::DATA)::Nothing. It must set the field value inresult, for example withassign(result, G4ThreeVector(...)). Mandatory.
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])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).
Geant4.G4JLMagneticField — Type
Custom Magnetic FieldGeant4.G4JLMagneticField — Method
G4JLUniformMagField(field::G4ThreeVector)Create a Uniform magnetic field
Arguments
field::G4ThreeVector: magnetic field vector
Geant4.G4JLMagneticField — Method
G4JLMagneticField(name::String, data::DATA; <keyword arguments>) where DATA<:G4JLFieldDataCreate a custom magnetic field with its name and associated DATA structure.
Arguments
name::String: magnetic field namedata::DATA: data structure associated to the magnetic fieldgetfield_method: user provided function with signature(result::G4ThreeVector, position::G4ThreeVector, ::DATA)::Nothing. It must set the field value inresult, for example withassign(result, G4ThreeVector(...)). Mandatory.
Geant4.G4JLPrimaryGenerator — Method
G4JLPrimaryGenerator(name::String, data::DATA; <keyword arguments>) where DATA<:G4JLGeneratorDataCreate a custom primary particle generator with its name and associated DATA structure.
Arguments
name::String: generator namedata::DATA: data structure with the generator parametersinit_method=nothing: initialization function with signature(data::DATA, app::G4JLApplication), called once in each threadgenerate_method: generation function with signature(evt::G4Event, data::DATA)::Nothing, called for each event. Mandatory.
Geant4.G4JLScoringMesh — Method
G4JLScoringMesh(name, mesh; <keyword arguments>)Create a scoring mesh to be added to the Geant4 application.
Arguments
name::String: scoring mesh namemesh::AbstractMesh: mesh instance. Either aBoxMeshorCylinderMeshbins::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)
Geant4.G4JLSensitiveDetector — Method
G4JLSensitiveDetector(name::String, data::DATA; <keyword arguments>) where DATA<:G4JLSDDataInitialize a G4JLSensitiveDetector with its name and associated DATA structure.
Arguments
name::String: Sensitive detector namedata::DATA: Data structure associted to the sensitive detectorprocesshits_method: function called for each step in the sensitive volumes, with signature(step::G4Step, ::G4TouchableHistory, data::DATA)::Bool. It returnstrueif a hit was produced. Mandatory.initialize_method=nothing: function called at the start of each event, with signature(::G4HCofThisEvent, data::DATA)::Nothingendofevent_method=nothing: function called at the end of each event, with signature(::G4HCofThisEvent, data::DATA)::Nothing
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.
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
Geant4.GetVolume — Method
GetVolume(name::String)Get the G4LogicalVolume with this name.
Arguments
name::String: logical volume name
Geant4.GetWorldVolume — Method
GetWorldVolume()Get the world volume of the currently instantiated detector geometry.
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 applicationnevents::Int: number of events
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
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 applicationname::String: sensitive detector name
Geant4.getSIMdata — Method
getSIMdata(app::G4JLApplication)Get the Simulation Data taking into account the current worker thread ID
Arguments
app::G4JLApplication: Geant4 application
Geant4.getfield — Method
getfield(pos::G4ThreeVector, bfield::G4JLMagneticField)Function to exercise a custom magnetic field
Arguments
pos::G4ThreeVector: positionbfield::G4JLMagneticField: magnetic field object
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
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.
Geant4.reinitialize — Method
reinitialize(app::G4JLApplication, det::G4JLDetector)Re-initialize the Geant4 application with a new detector definition.
Arguments
app::G4JLApplication: Geant4 applicationdet::G4JLDetector: new detector definition