JuliaPhysics / SolidStateDetectors.jl

Solid state detector field and charge drift simulation in Julia
Other
77 stars 29 forks source link

Add SSD --> GDML #384

Closed bene73 closed 2 months ago

bene73 commented 2 months ago

Added functionality to the Geant4 extension for the Geant4.G4JLDetector() function, which creates a Geant4 detector object (Geant4.G4JLDetectorGDML) from SSD simulation object by translating the given CSG geometry to GDML.

There are two methods for the function Geant4.G4JLDetector(), which makes it possible to specify the SolidStateDetectors.Simulation object explicitly or through a corresponding YAML configuration file:

function Geant4.G4JLDetector(sim::SolidStateDetectors.Simulation, output_filename::String = "tmp.gdml"; verbose::Bool = true)
function Geant4.G4JLDetector(input_filename::String, output_filename::String = "tmp.gdml"; verbose::Bool = true)

The following CSG geometry types are covered in the SSD to GDML translation:

Displacements in the $x, y, z$-axes work fine, but rotations are currently not parsed correctly and are thus still considered an experimental feature.

Calling the function on a SolidStateDetectors.Simulation object, the following volumes are created:

Geometrical objects that have zero volume are omitted in the GDML file, since the simulation algorithm of Geant4 requires all objects to have nonzero volume.

The predefined list of materials (with their physical characteristics) saved in the file materials.xml is internally referenced by the names given in the SSD simulation object and gives each physical volume its properties needed for the Geant4 simulation. Currently, the list only includes:

Example usage

Creates a Geant4 detector object from the InvertedCoax example file.

using SolidStateDetectors
using Geant4

g4_detector = Geant4.G4JLDetector(SSD_examples[:InvertedCoax], output_filename = "inverted_coax.gdml", verbose = false)
typeof(g4_detector) # G4JLDetectorGDML

Needs to be implemented