Opticks solves this using GPU ray tracing via NVIDIA OptiX
Huge CPU Memory+Time Expense
Opticks enables Geant4 based simulation to offload optical photon simulation to the GPU
NVIDIA GPU ray tracing of billions[1] of rays per second applied to optical simulation
[1] Actual performance depends on geometry and its modelling, JUNO optical simulation speedups > 1000x Geant4 have been measured
Use Opticks+JUNOSW latest release J25.7.2_Opticks-v0.5.6 by sourcing envset.sh, eg:
source /cvmfs/opticks.ihep.ac.cn/oj/releases/J25.7.2_Opticks-v0.5.6/el9_amd64_gcc11/2026_01_08/envset.sh
l /cvmfs/opticks.ihep.ac.cn/oj/releases/J25.7.2_Opticks-v0.5.6/el9_amd64_gcc11/ lrwxrwxrwx. 1 cvmfs cvmfs 3 Jan 15 17:17 Latest -> Thu drwxr-xr-x. 7 cvmfs cvmfs 181 Jan 15 17:10 Thu drwxr-xr-x. 7 cvmfs cvmfs 181 Jan 14 17:12 Wed drwxr-xr-x. 7 cvmfs cvmfs 181 Jan 13 17:12 Tue drwxr-xr-x. 7 cvmfs cvmfs 181 Jan 12 17:11 Mon drwxr-xr-x. 7 cvmfs cvmfs 181 Jan 11 17:11 Sun drwxr-xr-x. 7 cvmfs cvmfs 181 Jan 10 17:12 Sat drwxr-xr-x. 7 cvmfs cvmfs 181 Jan 9 17:11 Fri lrwxrwxrwx. 1 cvmfs cvmfs 10 Jan 8 17:19 LastRef -> 2026_01_08 drwxr-xr-x. 7 cvmfs cvmfs 181 Jan 8 17:12 2026_01_08
Integration + iteration directed by production experience with Opticks + JUNOSW
Reduced resource simulation using summary "Muon" hits --pmt-hit-type 2
Removed 32-bit max photon limits -> simulation of giga optical photon events
CUDA implementation of PMT hit merging (thrust::sort_by_key,reduce_by_key)
EVT=muon_cxs cxr_min.sh #12 : photons from muon crossing JUNO Scintillator
EVT=muon_cxs cxr_min.sh #13
EVT=muon_cxs cxr_min.sh #14
Large counts motivate merging of hits with same (pmtid,timebucket) : adding counts and keeping earliest time
struct key_functor { // Bitwise-OR (pmtid,timebucket)
float timewindow;
uint64_t operator()(const sphotonlite& p) const // 16+48 = 64
{
return (uint64_t(p.identity()) << 48) | uint64_t(p.time/timewindow);
}
};
Opticks/sysrap SPM::merge_partial_select using CUDA Thrust (higher level C++ way to use CUDA)
| Thrust method | Action | Note |
|---|---|---|
| copy_if | photon -> hit | using flagmask |
| transform | hit -> key | bitwise-OR (pmtid, timebucket) |
| sort_by_key | hit, key -> hit | hit ordered with same (pmtid,timebucket) contiguous |
| reduce_by_key | hit, key -> hitmerged | merge two hit : earlier time, sum hitcount |
https://github.com/simoncblyth/opticks/blob/master/sysrap/SPM.cu
https://github.com/simoncblyth/opticks/blob/master/sysrap/sphotonlite.h
Detsim timings for one double muon event, ~150M photons, 28M hit, 6.4M mergedHit, 1ns bucket merge
| JUNOSW J_Std1,2 | --pmt-hit-type 1 | --pmt-hit-type 2 | Total processing time excluding Initialize |
|---|---|---|---|
| --opticks-mode 0 | 7112 s (118min) | 6904 s (115min) | ]junoSD_PMT_v2::Initialize → [junoSD_PMT_v2::EndOfEvent |
| Opticks+J [1] | (CPUMerge)+Coll.[s] | Kernel [s] PREL→POST |
|
|
|
|---|---|---|---|---|---|
| hit | 190.445 | 22.996 | 1.949 | 215.560 | x32 |
| hitmerged | 6.712 | 22.988 | 0.543 | 30.400 | x233 |
| hitlite | 146.471 | 23.108 | 0.484 | 170.226 | x31 |
| hitlitemerged | 0.403 | 23.097 | 0.181 | 23.835 | x221 |
Opticks+J : overall speedup > x200 [~2 hrs → ~30 s]
[1] : Workstation (Dell Precision 7960), NVIDIA RTX 5000 Ada, 3rd gen. RT cores, 32 GB
https://code.ihep.ac.cn/blyth/j/-/blob/main/zhenning_double_muon/detsim.sh
Opticks+ JUNOSW validations reveal JUNO geometry bugs, including:
Integration of Opticks+JUNOSW with gitlab CI/CD build/test/release
OpticksService : first implementation of HTTP optical server working
OpticksClient : almost test stage [CPU node : collects gensteps, libcurl request, response]
Geant4 + Opticks + NVIDIA OptiX : Hybrid Workflow 4x4?
Production running via "Monolithic" scaling : inefficient use of scarce GPU resources ?
How many clients ? Depends on server, event photon count, network, ... (Experimentation needed)
Two Opticks Bugs Revealed
FIXED:
Both bugs manifested as overlarge bbox
Thank you Peidong
Complex solids, between Water Pool and CD, many R+T transforms, multi-union, long way from origin
Multiple issues:
Branches :
yupd-water-distributor
yupd_bottompipe_adjust
yupd_waterdistributor_heightfix
Lower and Upper WD
WDP 3 : Uppermost Water Distributor in Water Pool
WDP 4 : Water Distributor at top of CD
WDP 5 : mid-CD
WDP 6 : Water Distributor at bottom of CD
WDP 7 : Water Distributor at bottom of pool
Raytrace directly reveals (MR1062):
simtrace boundary wide view at top
simtrace 2D slices
planar raytrace => precise view
simtrace wide bottom view 20251218_100415
MR1062 issues visible
FIXED:
simtrace primtab : snake thru the dead zone with normals
With intersect normals
normals point "outwards", showing:
cxt_min.sh : Simtrace Split Snake
Segmented "Snake" pipe
XZ plane simtrace showing the mis-placed gap
MOI=264.136,-566.442,-20475,1500 # XY:middle-of-pipe Z:middle-of-outer-tyvek
Precise (MOI) control of ray plane
cxt_min.sh : Legs still not segmented at bottom
Peidongs Change
Working with Peidong on MR 1063
- https://code.ihep.ac.cn/JUNO/offline/junosw/-/merge_requests/1063
- branch : yupd-8inch-pmt
MPMT (branch yupd-8inch-pmt)
MPT in context
wide view showing added PMTs
Working with Chen Jing on MR 1086
- https://code.ihep.ac.cn/JUNO/offline/junosw/-/merge_requests/1086
- branch : Chenjing-EMFcoilsgeometry
Currently using G4Polycone with phi ranges
ELV=^s_EMF MOI=/tmp/emf2.npy EYE=0,0,-2 UP=0,1,0 cxr_min.sh ## raytrace
ELV : select solids
MOI : pick frame
View along EMF axis : (theta,phi) (56,-54) degrees
EMF2 3 View from bottom of pool, with very large volumes excluded
Former EMFcoils impl:
348 WP_ATM_LPMT direct inwards not outwards (MR 981)
G4: Photons escape between Lower and UpperChimney
Overlap of Water Distributor with Hama PMTs
Opticks:Geant4 photon history Chi2, reveals bugs:
Chronic lack of manpower working on Opticks (and JUNO Simulation)
Investigations on the side
Get Geometry Changes Merged
Automated Validation/Performance Monitoring
Production Optimization
Improve Opticks User Experience
CI/CD : Continuous Integration/Continuous Deployment
Extra Benefits of Adopting Opticks
=> using Opticks improves CPU simulation too !!
Opticks : state-of-the-art GPU ray traced optical simulation integrated with Geant4, with automated geometry translation into GPU optimized form. GPU hit merging drastically increases hit collection performance.
| https://github.com/simoncblyth/opticks | day-to-day code repository |
| https://simoncblyth.github.io | presentations and videos |
| https://groups.io/g/opticks | forum/mailing list archive |
| email: opticks+subscribe@groups.io | subscribe to mailing list |
| simon.c.blyth@gmail.com | any questions |