Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-15 07:41:50

0001 #!/usr/bin/env bash
0002 # MC_Truth example: standalone build of GPUMCTruth that demonstrates
0003 # appending the G4 Track ID of the creating particle to each hit line in
0004 # opticks_hits_output.txt when OPTICKS_MC_TRUTH is set.
0005 #
0006 # Setting OPTICKS_MC_TRUTH_BENCH prints an extra "Bench baseline /
0007 # mctruth / delta" block that isolates the MC-truth lookup cost from
0008 # the file I/O dominating the regular hit-write loop.
0009 #
0010 # Build (once):
0011 #     cd examples/MC_Truth
0012 #     cmake -S . -B build -DCMAKE_PREFIX_PATH=/opt/eic-opticks
0013 #     cmake --build build --parallel
0014 #
0015 # Run (this script):
0016 #     ./run.sh
0017 
0018 set -euo pipefail
0019 
0020 REPO=${REPO:-/workspaces/eic-opticks}
0021 BIN=${BIN:-$(dirname "$(realpath "$0")")/build/GPUMCTruth}
0022 GDML=${GDML:-$REPO/tests/geom/opticks_raindrop.gdml}
0023 MACRO=${MACRO:-$REPO/tests/run.mac}
0024 SEED=${SEED:-42}
0025 OUTDIR=${OUTDIR:-$(pwd)}
0026 
0027 export USER=${USER:-fakeuser}
0028 export GEOM=${GEOM:-fakegeom}
0029 export OPTICKS_MC_TRUTH=1
0030 export OPTICKS_MC_TRUTH_BENCH=1
0031 
0032 cd "$OUTDIR"
0033 rm -f opticks_hits_output.txt g4_hits_output.txt
0034 
0035 "$BIN" -g "$GDML" -m "$MACRO" -s "$SEED"
0036 
0037 echo
0038 echo "=== TrackID distribution in opticks_hits_output.txt ==="
0039 awk -F'TrackID=' 'NF>1 {print $2}' opticks_hits_output.txt | sort | uniq -c | sort -rn
0040 echo
0041 echo "First 3 hits:"
0042 head -3 opticks_hits_output.txt