Skip to content

Generic GDML raytrace example for the surface model

Andrei Gheata requested to merge raytrace_surf into surface_model

This example implements a simple ray tracing after loading a generic GDML. Currently, this works for geometries having only box/tube/trd solids, such as persistency/gdml/gdmls/trackML.gdml

The procedure follows: the world volume bounding box is sampled with points/directions. For each point, the location and safety distance get computed using NewSimpleNavigator and SimpleSafetyEstimator respectively. These values are used as references and compared with the same functionality provided by the surface model. Then, for each ray, the geometry setup is traversed, doing relocation at each boundary crossing and comparing the average between the two models. The time for locating, safety computation and complete traversal is compared between the two models in non-debug mode.

I added now for reference the BVH time for safety and traversal. Also added support on GPU. NOTE: The geometry must be overlap-free in the current implementation of the surface model, otherwise complete volume branches become invisible for traversal.

The executable is: build/test/testRaytracing -gdml_name default.gdml [-nrays N] [-debug D]

The output on my E5-2630 CPU: testRaytracing -gdml_name trackML.gdml -nrays 1000000

Geometry loading and GPU transfer: 1.93892 [s]
___________________________________________________________________________________
 Surface model info:  18790 touchables
    volume shells          = 145 [0.00507355 MB]
    local transformations  = 750 [0.0743866 MB]
    global transformations = 112615 [11.1694 MB]
    local surfaces         = 750 [0.0228882 MB]
    global surfaces        = 112614 [3.43671 MB]
    common surfaces        = 25412 [1.98061 MB]
    candidates             = 276046 [1.05303 MB]
    window masks           = 25774 [0.78656 MB]
    cyl/sph masks          = 120 [0.00366211 MB]
    ring masks             = 120 [0.00640869 MB]
    Z/phi masks            = 147 [0.00785065 MB]
    triangle masks         = 0 [0 MB]
    quad masks             = 120 [0.0146484 MB]
 Total: 18.5612[MB]
___________________________________________________________________________________
Conversion time to surface model: 1.31433 [s]
HOST: locate_solids: 0.543724  locate_surf: 2.01383
HOST: safety_solids: 0.44076 safety_solids_BVH: 0.112631  safety_surf: 0.649364
HOST:    number of better safety values: 211460
HOST: traverse_solids: 167.857 traverse_solids_bvh: 55.4039  traverse_surf: 59.4386  num_errors = 0
CUDA: locate_solids: 0.190508  locate_surf: 0.244651
CUDA: safety_solids: 0.143984 safety_solids_BVH: 0.00413846  safety_surf: 0.0682511
CUDA:    number of better safety values: 211460
CUDA: traverse_solids: 52.8683 traverse_solids_bvh: 15.0613  traverse_surf: 8.2746
Edited by Andrei Gheata

Merge request reports