Opticks replaces Geant4 optical photon simulation with an equivalent implementation that benefits from state-of-the-art GPU ray tracing from NVIDIA OptiX. All optically relevant aspects of Geant4 context must be translated+copied to GPU:
- geometry : solids, structure, material+surface properties
- generation : Cerenkov + Scintillation (using Gensteps from Geant4)
- propagation : Rayleigh scattering, absorption, reemission, boundary
Achieving+maintaining equivalence is time consuming, BUT:
- transformative performance benefits >1000x Geant4
EYE=3,0.5,-1 UP=0,0,1 ZOOM=4 TMIN=0 PUB=1 ./cxr_geochain.sh
EYE=-3,0.5,-1 UP=0,0,1 ZOOM=4 TMIN=0 PUB=otherside ./cxr_geochain.sh
EYE=-3,0.5,1 UP=0,0,1 ZOOM=4 TMIN=0 PUB=upper ./cxr_geochain.sh
EYE=-3,0.5,0.8 UP=0,0,1 ZOOM=4 TMIN=2.7 CAM=0 PUB=speckle ./cxr_geochain.sh
NODE:13 PRIM:7 Uni U 9 Uni Uni U U 7 11 Uni Box Box Box U U U U 5 8 10 12 Uni Box U U 3 6 Uni Box U U 1 4 Tub Box U U 0 2 0 0.00 0.00 50.00 -50.00 0.00 0.00 zdelta 6 11.50 11.50 65.00 -35.00 40.00 65.00 az1 -6 -11.50 -11.50 35.00 -65.00 -40.00 -65.00 az0
un 1 0.00 -0.00 un un 2 3 0.00 0.00 -0.00 -0.00 un un in un 4 5 6 7 0.00 0.00 0.00 0.00 -0.00 -0.00 -0.00 -0.00 bo bo bo bo cy !cy bo bo 8 9 10 11 12 13 14 15 6.50 6.50 6.50 6.50 6.50 6.57 -16.50 -6.50 -6.50 -6.50 -6.50 -6.50 -6.50 -6.57 -33.50 -16.50
So many spurious intersects : Easier to start over with fewer constituent solids
Two types of spurious
White internal intersects : sd ~ 0
Yellow internal intersects : abs(sd) > epsilon
Balanced tree spurious intersects
Fix attempts, so far unsuccessful
Single hit CSG intersection Alg
Postorder sequence binary choice of intersects:
Sometimes alg needs to "LOOP" to find "otherside"
Constituent Intersect Classification
Tree intersect is constituent node intersect, which depends on:
Algorithm:
no use of "is this point inside the shape" queries
+-----------------+-----------------+-----------------+-----------------+ UX1 : UNION FROM INSIDE ONE UX2 : UNION FROM OUTSIDE 0,1,2 | UNION | | | | UX3 : UNION FROM INSIDE BOTH 3,4,5 | | B Enter | B Exit | B Miss | | A Closer | | | | +-----------------------+ +-----------------------+ | B Closer | | | | | B | | B | | | | | | +------------------+ | +------------------+ | +-----------------+-----------------+-----------------+-----------------+ | A | | | | A | | | | | | | | | | | | | | | | | A Enter | | | | | | | | | | | | | | RETURN_A | LOOP_A | RETURN_A | | 0- - - 1 - - - 2 - - - - - - -[3] 0 -[1]- - - - 2 | | | | RETURN_B | RETURN_B | RETURN_A | | E X X E E 3 - 4 - - - - - - -[5] | | | | | | | | | | | X X +-----------------+-----------------+-----------------+-----------------+ | +-------|---------------+ | +-------|---------------+ | | | | | | | | | | A Exit | | | | | | | | | | RETURN_A | RETURN_B | RETURN_A | +------------------+ +------------------+ | | LOOP_B | RETURN_A | RETURN_A | | | | | | +-----------------+-----------------+-----------------+-----------------+ 0: origin 0: origin | | | | | 1: B Enter 1: A Enter | A Miss | | | | 2: A Exit 2: B Enter | | RETURN_B | RETURN_B | RETURN_MISS | 1,2: B Closer ==> LOOP_B 1,2: A Closer ==> RETURN_A | | RETURN_B | RETURN_B | RETURN_MISS | 3: B Exit | | | | | 2,3: A closer ==> RETURN_B 3: origin +-----------------+-----------------+-----------------+-----------------+ 4: A Exit 5: B Exit Ordering states (Closer,Further) 4,5 A Closer ==> RETURN_B (A Enter, B Enter) UX4 : DISJOINT UNION 0,[1],2 origin outside both -> return closest +---------------------+ +---------------------+ (A Exit, B Exit) | A | | B | origin inside both -> return furthest | | | | | | | | (A Exit, B Enter) | | | | origin inside A | | | | | 0- - - - - [1] - - - - - - -2 | * if A closer return A (means disjoint) | X E | * if B closer loop B (find otherside of B, then compare again) | | | | | | | | | | | | +---------------------+ +---------------------+ 0: origin 1: A Exit 2: B Enter 1,2: A Closer => RETURN_A [1]
+-----------------+-----------------+-----------------+-----------------+ Ordering states (Closer,Further) | INTERSECTION | | | | | | B Enter | B Exit | B Miss | (Enter, Exit) -> Return Closer One : the Enter | A Closer | | | | | B Closer | | | | (Exit, Exit) -> Return Closer Exit | | | | | +-----------------+-----------------+-----------------+-----------------+ (Exit, Enter) -> Loop Closer (the Exit) | | | | | One might first imagine that having just exited so there will be no otherside ? | A Enter | | | | But that assumes simple convex constituent shapes whereas the alg needs to | | LOOP_A | RETURN_A | RETURN_MISS | handle less simple shapes like torus or annulus | | LOOP_B | LOOP_B | RETURN_MISS | | | | | | (Enter, Enter) -> Loop Closer +-----------------+-----------------+-----------------+-----------------+ Find otherside of Closer Enter | | | | | (by advancing t_min, intersecting that constituent again, comparing again) | A Exit | | | | | | LOOP_A | RETURN_A | RETURN_MISS | | | RETURN_B | RETURN_B | RETURN_MISS | +-------------+ | | | | | | A | +-----------------+-----------------+-----------------+-----------------+ | +------|-------+ 0:Origin | | | | | | | | B | 1:A_Enter | A Miss | | | | 0- - -1 - - [2]- - -3 | 2:B_Enter | | RETURN_MISS | RETURN_MISS | RETURN_MISS | E E X | (1:A_Enter,2:B_Enter) => A_Closer => LOOP_A => 3 | | RETURN_MISS | RETURN_MISS | RETURN_MISS | | | | | 3:A Exit | | | | | +------|------+ | (2:B Enter,3:A Exit) => RETURN_B 2:B_Enter +-----------------+-----------------+-----------------+-----------------+ | | +--------------+
Proceed with Unbalanced Trees ?
Speedup Unbalanced ?
Communicating shape more precisely => better suited alg => less resources => faster
Generalized Opticks CSG into three levels : tree < node < leaf
Three levels avoids recursion in intersect (disallowed by NVIDIA OptiX)
Alg works : but many TODOs
+----------------+ +-------------------+ DISJOINT MUST BE DISQUALIFIED |B | |D | +----|----+ +----|-----|----+ +------|----------+ +-----------+ |A | | |C | | | |E | | | | | | | | | | | | | | | | | 0 E1 X2 E3 X4 E5 X6 E7 X8 [X9] E10 X11 | | | | | | | | | | | | | | | | | | | | | | | | +----|----+ +----|-----|----+ +------|----------+ +-----------+ | | | | +----------------+ +-------------------+ E E E E E X X X X X X
User guarantees : absolutely no overlapping between constituents
+-------+ +-------+ +-------+ +-------+ +-------+ | | | | | | | | | | | | | | | | | | | | +-------+ +-------+ +-------+ +-------+ +-------+ +-------+ +-------+ +-------+ +-------+ +-------+ | | | | | | | | | | | | | | | | | | | | +-------+ +-------+ +-------+ +-------+ +-------+
User guarantees : all constituents overlap => ( farthest_enter or nearest_exit ) with all overlap requirement:
farthest_enter < nearest_exit and max(enter_count, exit_count) == num_sub
1X,2M -> MISS +----------------1X-------------+ | / C | | 0 | +---------------------------------+ | | | B | | +----------------------------+ 0- - -1 - - - 2 2X,1M -> MISS | A | | . ABC | X X | | | . . . | | | 0 - - - -1- - - - - 2- - - - [3]- - - 4 | | E E E . . . X | | | | | . . . | | | | | | .0- -[1]- - - - - - - 2 - - - 3 - - | | | . . . X X X | | +-------------------------------+ | | | | 0 - - 1 - - - - -2 - - - - - - - - 3 - - - - - - - 4 E E (2E,1M)-> M X X (2X,1M) -> M | +---------------------------------+ | | +----------------------------+
Avoid tree overheads for suitable shapes (eg general sphere:inner-radius,phicut,thetacut)
EMM=0, EYE=-0.6,0,0.3 LOOK=0,0,0 ./cxr_overview.sh
EMM=0, EYE=-0.6,0,0.3 LOOK=0,0,0 TMIN=0.5 ./cxr_overview.sh
MOI=sChimneyAcrylic EYE=-10,0,0 TMIN=0 ./cxr_view.sh
struts and part of Chimney mis-placed
MOI=sChimneyAcrylic EYE=-10,0,0 TMIN=0 ./cxr_view.sh
BACK AGAIN AFTER FIX
MOI=sChimneySteel EYE=-10,0,0 TMIN=0 ./cxr_view.sh
MOI=sChimneyLS EYE=-2,0,0 TMIN=0.1 ./cxr_view.sh
part of Chimney in middle of CD
g4ok/G4OKVolumeTest.sh with GEOM=ListJustOrb,BoxMinusOrb
ok/ott.sh OTracerTest OpenGL raster view looks normal
TODO: investigate cause of slowdown
Repeat January checks with current geometry
https://simoncblyth.bitbucket.io/env/presentation/opticks_20220118_juno_collaboration_meeting.html
AltXJfixtureConstruction with CSG_CONTIGUOUS
After Geometry Issues Fixed : port OptiXRap sim to QUDARap (for OptiX 7)
CSGOptix : depends on QUDARap for generation + propagation, adds geometry intersection
Opticks updated for LHCb RICH Simplified geometry:
Added externally set bounding box functionality (CSG_EXBB)
Contributing to UK GPU Hackathon