Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-09 07:48:58

0001 #!/bin/bash
0002 usage(){ cat << EOU
0003 ct.sh : using CSGSimtraceTest for CPU side testing intersect testing
0004 ======================================================================
0005 
0006 This uses the CSG intersection headers to get intersect positions using CUDA
0007 compatible code runing on the CPU, not the GPU where usually deployed.
0008 The advantage of testing GPU code on CPU is ease of debugging.
0009 
0010 Workflow:
0011 
0012 1. config GEOM evvvar with bash function GEOM
0013 
0014 2. the GEOM envvar and ${GEOM}_CFBaseFromGEOM evvar config where to load CSGFoundry from,
0015    the customary directory is::
0016 
0017     $HOME/.opticks/GEOM/$GEOM
0018 
0019 3. run the CSG intersection, using CSGSimtraceTest::
0020 
0021    ~/opticks/CSG/ct.sh run
0022    LOG=1 ~/opticks/CSG/ct.sh run
0023 
0024    SOPR=0:0 ~/o/CSG/ct.sh     ## default first CSGPrim from first CSGSolid
0025    SOPR=1:0 ~/o/CSG/ct.sh     ## first prim from second CSGSolid, see CSGQuery
0026 
0027    SOPR=2:0 ~/o/CSG/ct.sh     ## check the first few CSGPrim in CSGSolid 2
0028    SOPR=2:1 ~/o/CSG/ct.sh
0029    SOPR=2:2 ~/o/CSG/ct.sh
0030    SOPR=2:3 ~/o/CSG/ct.sh
0031    SOPR=2:4 ~/o/CSG/ct.sh
0032 
0033 
0034    ## TODO: adopt MOI triplets for simpler prim selection
0035 
0036 
0037 4. present the CSG intersections with python plots::
0038 
0039    ~/opticks/CSG/ct.sh ana
0040 
0041 5. screencapture displayed plots into png::
0042 
0043    ~/opticks/CSG/ct.sh mpcap
0044 
0045 6. copy captured png into publish repository for inclusion into presentations::
0046 
0047    PUB=example_distinguishing_string ~/opticks/CSG/ct.sh mppub
0048 
0049 
0050 Control plot presentation with envvars::
0051 
0052    MPPLT_SIMTRACE_SELECTION_LINE=o2i ~/opticks/CSG/ct.sh ana
0053 
0054    GEOM=nmskSolidMaskTail__U1 FOCUS=-257,-39,7 ~/opticks/CSG/ct.sh ana
0055 
0056    ct
0057    FOCUS=-257,-39,7  ./ct.sh ana   # show intersects from a portion of the geometry
0058 
0059 
0060 EOU
0061 }
0062 
0063 cd $(dirname $(realpath $BASH_SOURCE))
0064 
0065 
0066 logging()
0067 {
0068     type $FUNCNAME
0069     export CSGSimtrace=INFO
0070     export SEvt__LIFECYCLE=INFO
0071     #export SEvt=INFO
0072 }
0073 [ -n "$LOG" ] && logging
0074 
0075 
0076 defarg=info_run_ana
0077 [ -n "$BP" ] && defarg="info_dbg"
0078 arg=${1:-$defarg}
0079 
0080 
0081 bin=CSGSimtraceTest
0082 log=$bin.log
0083 
0084 source $HOME/.opticks/GEOM/GEOM.sh  # sets GEOM envvar
0085 export ${GEOM}_CFBaseFromGEOM=$HOME/.opticks/GEOM/$GEOM
0086 
0087 tmp=/tmp/$USER/opticks
0088 export TMP=${TMP:-$tmp}
0089 export FOLD=$TMP/GEOM/$GEOM/CSGSimtraceTest/ALL0_none/B000
0090 
0091 
0092 export TOPLINE="CSG/ct.sh GEOM $GEOM FOCUS $FOCUS"
0093 
0094 if [ "${arg/info}" != "$arg" ]; then
0095     vars="BASH_SOURCE arg bin GEOM ${GEOM}_CFBaseFromGEOM FOLD"
0096     for var in $vars ; do printf "%30s : %s \n" $var ${!var} ; done
0097 fi
0098 
0099 if [ "${arg/run}" != "$arg" ]; then
0100     [ -f "$log" ] && rm $log
0101     $bin
0102     [ $? -ne 0 ] && echo $BASH_SOURCE run error && exit 1
0103 fi
0104 
0105 if [ "${arg/dbg}" != "$arg" ]; then
0106     source ../bin/dbg__.sh
0107     dbg__ $bin
0108     [ $? -ne 0 ] && echo $BASH_SOURCE dbg error && exit 2
0109 fi
0110 
0111 if [ "${arg/ana}"  != "$arg" ]; then
0112     ${IPYTHON:-ipython} --pdb -i tests/$bin.py
0113     [ $? -ne 0 ] && echo $BASH_SOURCE ana interactive error && exit 3
0114 fi
0115 
0116 if [ "$arg" == "mpcap" -o "$arg" == "mppub" ]; then
0117     export CAP_BASE=$FOLD/figs
0118     export CAP_REL=ct
0119     export CAP_STEM=${GEOM}
0120     case $arg in
0121        mpcap) source mpcap.sh cap  ;;
0122        mppub) source mpcap.sh env  ;;
0123     esac
0124 
0125     if [ "$arg" == "mppub" ]; then
0126         source epub.sh
0127     fi
0128 fi
0129 
0130 exit 0
0131