Skip to content

Commit 00e676d

Browse files
committed
examples: add CMake build + run.sh for the standalone dRICH example
Gives examples/drich the standalone CMakeLists.txt (find_package eic-opticks + Geant4 gdml) and run.sh that the sibling examples carry, so the no-DD4hep dRICH driver builds the canonical way. Compiling it serves as a build-smoke for the standalone GDML flow; README gains the CMake recipe.
1 parent 5a3c666 commit 00e676d

3 files changed

Lines changed: 84 additions & 0 deletions

File tree

examples/drich/CMakeLists.txt

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
cmake_minimum_required(VERSION 3.20)
2+
3+
project(drich_gdml LANGUAGES CXX)
4+
5+
set(CMAKE_CXX_STANDARD 17)
6+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
7+
set(CMAKE_CXX_EXTENSIONS OFF)
8+
9+
find_package(eic-opticks REQUIRED)
10+
find_package(Geant4 REQUIRED gdml) # gdml component pulls G4GDMLParser + xerces-c
11+
12+
# Standalone (no-DD4hep) Geant4 + Opticks dRICH driver. Builds against an
13+
# installed eic-opticks the same way as the sibling examples; compiling it
14+
# serves as a build-smoke for the standalone GDML flow.
15+
add_executable(drich_gdml_main drich_gdml_main.cc)
16+
target_link_libraries(drich_gdml_main
17+
eic-opticks::gphox
18+
eic-opticks::G4CX
19+
eic-opticks::U4
20+
eic-opticks::QUDARap
21+
eic-opticks::CSG
22+
eic-opticks::CSGOptiX
23+
eic-opticks::SysRap
24+
${Geant4_LIBRARIES}
25+
)
26+
27+
install(TARGETS drich_gdml_main)

examples/drich/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,20 @@ carry, wavelength-linear lookup) live in `__device__` headers compiled into the
2020
PTX, so the PTX must be regenerated — not just the host libraries.
2121

2222
## Build
23+
24+
### CMake (preferred)
25+
This directory is a standalone CMake project, like the other `examples/`:
26+
27+
```
28+
cmake -S examples/drich -B build/drich -DCMAKE_PREFIX_PATH=${OPTICKS_PREFIX}
29+
cmake --build build/drich
30+
```
31+
32+
It builds `drich_gdml_main` against an installed eic-opticks/simphony and Geant4
33+
(gdml component); compiling it doubles as a build-smoke for the standalone flow.
34+
`run.sh` runs it (`./run.sh`, or `GDML_FILE=… MULT=… SEED=… NEVENTS=… ./run.sh`).
35+
36+
### Manual g++
2337
Adjust `-I/-L` to your install layout. NOTE: the project was renamed
2438
`eic-opticks``simphony`, so installed headers may live under
2539
`include/simphony/...` (the recipe below used the old `eic-opticks` prefix).

examples/drich/run.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/bash
2+
# run.sh — run the standalone (no-DD4hep) dRICH GDML example.
3+
#
4+
# Runs the Geant4 + Opticks driver side-by-side and prints per-event
5+
# "gpu_hits=N cpu_hits=M ..." so the GPU/G4 hit ratio can be checked.
6+
# Build first via CMake (find_package(eic-opticks)); see README.md.
7+
#
8+
# Usage:
9+
# ./run.sh # drich_ag02.gdml, 1 event
10+
# GDML_FILE=drich_ag02.gdml MULT=100 SEED=12345 NEVENTS=5 ./run.sh
11+
#
12+
# Env (see drich_gdml_main.cc): GDML_FILE MULT SEED NEVENTS PHI_DEG ETA
13+
# KILL_OPTICAL (1=GPU-only, skips CPU optical transport) CUDA_VISIBLE_DEVICES
14+
set -e
15+
16+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
17+
cd "$SCRIPT_DIR"
18+
19+
GDML_FILE="${GDML_FILE:-drich_ag02.gdml}"
20+
if [ ! -f "$GDML_FILE" ]; then
21+
echo "ERROR: $SCRIPT_DIR/$GDML_FILE not found"
22+
exit 1
23+
fi
24+
25+
# Locate the built binary (installed/on PATH, or a sibling build dir).
26+
BIN="${BIN:-drich_gdml_main}"
27+
if ! command -v "$BIN" >/dev/null 2>&1 && [ ! -x "$BIN" ]; then
28+
echo "ERROR: '$BIN' not found — build it first (see README.md) or set BIN=/path/to/drich_gdml_main"
29+
exit 1
30+
fi
31+
32+
echo "=== standalone dRICH GDML example ==="
33+
echo "GDML: $GDML_FILE"
34+
echo "events: ${NEVENTS:-1} MULT: ${MULT:-1} SEED: ${SEED:-1} PHI_DEG: ${PHI_DEG:-30} ETA: ${ETA:-2.0}"
35+
echo ""
36+
37+
GDML_FILE="$GDML_FILE" \
38+
MULT="${MULT:-1}" SEED="${SEED:-1}" NEVENTS="${NEVENTS:-1}" \
39+
PHI_DEG="${PHI_DEG:-30}" ETA="${ETA:-2.0}" \
40+
"$BIN"
41+
42+
echo ""
43+
echo "=== Done ==="

0 commit comments

Comments
 (0)