G4DAE : Export Geant4 Geometry to COLLADA/DAE XML files

http://simoncblyth.bitbucket.io/env/presentation/g4dae_geometry_exporter.html http://simoncblyth.bitbucket.io/env/presentation/gpu_optical_photon_simulation.html

Simon C Blyth, Daya Bay Collaboration, National Taiwan University
19th Geant4 Collaboration Meeting, Okinawa, Sept 2014, Parallel Session B2, Visualization Group (Invited Speaker)


Exports Geant4 Geometry into COLLADA/DAE standard 3D files, based on GDML writer code, same XercesC dependency for XML handling. Export includes:


COLLADA : Standard for 3D Digital Asset Exchange (DAE)


Compare DAE Exports to GDML and VRML2(WRL)

Export validation:

  • Comparison of all vertices/faces reveals boolean solids are discrepant.
  • Perfect [1] DAE WRL agreement achieved by cheating : perform triangulation once and reuse.
  • Boolean solid triangulation sensitivity must be kept in mind as a potential systematic for computational uses
  • DAE not much bigger than GDML, despite including all triangles/vertices [2]
Qty DayaBay Lingao Far Juno x0.5
Volumes 12,229 12,229 18,903 25,000
Triangles 2,448,064 2,448,064 4,189,680 21,886,158
Vertices 1,245,996 1,245,996 2,128,208 10,993,079
DAE/GDML/WRL (MB) 6.9/4.0/98 6.9/4.0/96 8.6/6.0/167 6.1/-/-

VGDX_20140414 counts using g4daeview.py -g 0: --with-chroma, Juno geometry truncated

[1]Maximum DAE WRL offset < 0.13 mm, after patching VRML2 export precision bug (fixed in current G4). Details: http://simoncblyth.bitbucket.io/env/notes/geant4/geometry/collada/dae_cf_wrl/
[2]Geometry is not repeated, instead the COLLADA format uses geometry instancing and a tree of transforms, just like GDML

Tested G4DAE reading applications and frameworks


Open source:


Many more applications and frameworks listed http://en.wikipedia.org/wiki/COLLADA

http://meshlab.sourceforge.net https://bitbucket.org/simoncblyth/meshlab (fork improves COLLADA loading speed)

G4DAE export in OSX Finder, Interactive Quicklook (1)

Coverflow through geometries:


G4DAE export in OSX 10.8+ Finder, Rotate/Pan/Zoom

Rotate/Pan/Zoom in the Finder:


G4DAE export view/edit with OSX Xcode.app (1)

Deep tree makes choice of default appearance problematic. Useful editing.


G4DAE export view/edit with OSX Xcode.app (2)

Bialkali PMT cathode highlighted by Xcode effect edit.


G4DAE export in OSX 10.8+ Preview : Daya Bay Antineutrino Detector


G4DAE export in OSX Sketchup

Available for Windows too.


My Modules/Applications using G4DAE exports (OSX/Linux)

g4daenode.py pycollada based G4DAE parser

g4daeserver.py threejs/WebGL (client) and pycollada/webpy (server) based webapp:

g4daeview.py pyopengl/pycollada/numpy based 3D viewer app

https://bitbucket.org/simoncblyth/env/src/tip/geant4/geometry/collada/g4daenode.py https://bitbucket.org/simoncblyth/env/src/tip/geant4/geometry/g4daeserver/ https://bitbucket.org/simoncblyth/env/src/tip/geant4/geometry/collada/g4daeview/g4daeview.py

g4daeview.py : Fast OpenGL 3D viewer for G4DAE files

G4DAE visualization [3] implemented with PyCollada, PyOpenGL and Glumpy

Also used for testing GPU photon propagation with Chroma project

[4]Implemented with single OpenGL Vertex Buffer Object (VBO) for entire geometry

g4daeview.py : Initial Photon Positions

Initial photon positions of a Geant4 simulated muon that crosses between the Dayabay Near hall ADs. Colors represent photon wavelengths. Optical photons: collected in G4 StackAction, serialized, sent over ZeroMQ, deserialized, presented using OpenGL GLSL shaders.


g4daeview.py : Implementation

Based on glumpy [6] and pyopengl [7]

[6]https://code.google.com/p/glumpy/ many useful examples of pyopengl usage
[7]http://pyopengl.sourceforge.net cross platform Python binding to OpenGL and related APIs

g4daeview.py : Optical Photon (OP) Data Handling

Photon data flow:

When visualizing/debugging:

[9]Would be more efficient to collect OP inside Cerenkov and Scintillation processes, avoiding creating and stacking only to immediately kill.
[10]ROOT TObject (de)serialization, network message queue ZeroMQ

g4daeview.py : Status

Not mature, but intend to facilitate usage anyhow.


Chroma : Ultra-fast Photon MC, Developed by Stan Seibert, University of Pennsylvania

Chroma tracks photons through a triangle-mesh detector geometry, simulating processes like diffuse and specular reflections, refraction, Rayleigh scattering and absorption. Using triangle meshes eliminate geometry code as just one code path.

200x performance claim:

With a CUDA GPU Chroma has propagated 2.5M photons per second in a detector with 29k photomultiplier tubes. This is 200x faster than GEANT4.

BUT Chroma needs : triangles + inside/outside materials


Chroma Raycasting : exercises geometry intersection

Raycasting exercises slowest part of optical photon propagation: geometry intersection.

[11]Boundary Volume Heirarchy, a tree of bounding boxes with triangles inside leaf nodes

Chroma Raycast with entire geometry in view

Render Split into 3x3 CUDA kernel launches, 1 thread per pixel, ~1.8s for 1.23M pixels, 2.4M tris (with [12])

[12]MacBook Pro (2013), NVIDIA GeForce GT 750M 2048 MB ; Workstation GPUs such as NVIDIA Kepler K20 expected at least ~3x faster

g4daeview.py : Dayabay Chroma Photon Propagation (1)

Chroma GPU photon propagation at 12 nanoseconds. The photons are generated by Geant4 simulation of a 100 GeV muon travelling from right to left. Photon colors indicate reemission (green), absorption(red), specular reflection (magenta), scattering(blue), no history (white).


g4daeview.py : Dayabay Chroma Photon Propagation (2)

Chroma GPU photon propagation at 14 nanoseconds. The interface provides interactive control of the propagation time allowing any stage of the propagation to be viewed by scrubbing time backwards/forwards. The speed of this visualization is achieved by interoperation of CUDA kernels and OpenGL shaders accessing the same GPU resident photon propagation data.


G4DAE Exporter Status : almost feature complete

Development started with GDML from geant4.10.00.p01

Remaining tasks:

G4DAE : Conclusion

I propose to contribute the COLLADA/DAE geometry exporter to the Geant4 collaboration, as I believe this can be useful for facilitating:

Links for this presentation and another on GPU optical photon propagation:

Extra slides

g4daeserver.py : View exported geometry in web browser


g4daeserver.py : View exported geometry in web browser, details

Select volume subtree by name or index and recursion depth

Client in browser based on:


Command line access to DAE subtrees:

curl -O http://belle7.nuu.edu.tw/g4dae/tree/3155___2.dae

http://threejs.org http://pycollada.github.io http://webpy.org https://bitbucket.org/simoncblyth/env/src/tip/geant4/geometry/g4daeserver/ https://bitbucket.org/simoncblyth/env/src/tip/geant4/geometry/collada/g4daenode.py

g4daeview.py : Photon Selection Interface

Propagation steps OR photons can be selected by materials, propagation history, or special selection by photon identifier. Photons can be selected by clicking their 3D representations allowing inspection of the propagation history of individual photons.


g4daeview.py : Propagation Step Selection Interface

Photon propagation steps with material pair GdDopedLS,Acrylic. The larger squares represent selected photons, providing access to numerical details of propagation history.