Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-09 07:49:03

0001 #!/bin/bash
0002 usage(){ cat << EOU
0003 G4CXTest.sh : Standalone bi-simulation with G4CXApp::Main
0004 ===========================================================
0005 
0006 ::
0007 
0008     ~/opticks/g4cx/tests/G4CXTest.sh run
0009 
0010     PIDX=552 ~/opticks/g4cx/tests/G4CXTest.sh run ## run with single photon debug
0011 
0012     ~/opticks/g4cx/tests/G4CXTest.sh grab
0013 
0014 
0015     PICK=B MODE=2 ~/opticks/g4cx/tests/G4CXTest.sh ana
0016          2D (matplotlib) plot Geant4 photon histories
0017 
0018 
0019 
0020     MODE=2 ./G4CXTest.sh ana
0021 
0022     MODE=2 APID=62 ./G4CXTest.sh tra
0023 
0024 
0025 
0026 Screen captures
0027 -----------------
0028 
0029 ::
0030 
0031     ~/opticks/g4cx/tests/G4CXTest.sh grab  # from remote
0032     PICK=A MODE=2 APID=1000 FOCUS=0,0,80                  ~/opticks/g4cx/tests/G4CXTest.sh ana
0033     PICK=A MODE=2 APID=1000 FOCUS=0,0,80                  ~/opticks/g4cx/tests/G4CXTest.sh mpcap
0034     PICK=A MODE=2 APID=1000 FOCUS=0,0,80 PUB=Tub3_delta_1 ~/opticks/g4cx/tests/G4CXTest.sh mppub
0035 
0036 Input scripts
0037 ---------------
0038 
0039 
0040 ~/opticks/u4/tests/FewPMT.sh
0041     configure geometry
0042 
0043 ~/opticks/u4/tests/storch_FillGenstep.sh
0044     configure torch photons, controlled via LAYOUT and CHECK envvars
0045 
0046 
0047 
0048 
0049 
0050 EOU
0051 }
0052 
0053 SDIR=$(dirname $(realpath $BASH_SOURCE))
0054 U4TDIR=$(realpath $SDIR/../../u4/tests)
0055 BINDIR=$(realpath $SDIR/../../bin)
0056 
0057 bin=G4CXTest
0058 ana=$SDIR/G4CXTest.py
0059 tra=$SDIR/G4CXSimtraceMinTest.py
0060 
0061 
0062 #defarg="info_dbg_ana"
0063 defarg="info_run_ana"
0064 [ -n "$BP" ] && defarg="info_dbg_ana"
0065 arg=${1:-$defarg}
0066 
0067 source $HOME/.opticks/GEOM/GEOM.sh
0068 
0069 geomscript=$U4TDIR/$GEOM.sh
0070 if [ -f "$geomscript" ]; then
0071     source $geomscript
0072 else
0073     echo $BASH_SOURCE : no geomscript $geomscript
0074 fi
0075 
0076 
0077 export VERSION=0
0078 
0079 tmp=/tmp/$USER/opticks
0080 export TMP=${TMP:-$tmp}
0081 
0082 export OPTICKS_EVENT_NAME=DebugPhiloxShakedownIPH
0083 export BASE=$TMP/GEOM/$GEOM/$bin
0084 export EVT=000
0085 export AFOLD=$BASE/ALL${VERSION}_${OPTICKS_EVENT_NAME}/A${EVT}
0086 export BFOLD=$BASE/ALL${VERSION}_${OPTICKS_EVENT_NAME}/B${EVT}
0087 export TFOLD=$BASE/0/p999
0088 
0089 if [ -z "$APID" -a -z "$BPID" -a -n "$PIDX" ]; then
0090     echo $BASH_SOURCE : PIDX $PIDX is defined and APID BPID are both not defined so setting them to PIDX
0091     export APID=$PIDX
0092     export BPID=$PIDX
0093 fi
0094 
0095 
0096 
0097 #num_photons=1
0098 #num_photons=10
0099 #num_photons=100
0100 #num_photons=1000      # 1k
0101 #num_photons=10000    # 10k
0102 #num_photons=50000    # 50k
0103 num_photons=100000    # 100k
0104 #num_photons=1000000  # 1M
0105 
0106 NUM_PHOTONS=${NUM_PHOTONS:-$num_photons}
0107 
0108 export G4CXOpticks__setGeometry_saveGeometry=$HOME/.opticks/GEOM/$GEOM
0109 
0110 export OPTICKS_RUNNING_MODE=SRM_TORCH
0111 export OPTICKS_MAX_BOUNCE=31
0112 export OPTICKS_EVENT_MODE=DebugLite
0113 export OPTICKS_INTEGRATION_MODE=3
0114 
0115 export OPTICKS_MAX_PHOTON=${NUM_PHOTONS}
0116 #export OPTICKS_MAX_PHOTON=100000
0117 
0118 export SEvent_MakeGenstep_num_ph=${NUM_PHOTONS}
0119 
0120 #check=rain_point_xpositive_100
0121 #check=rain_line
0122 #check=tub3_side_line
0123 #check=circle_inwards_100
0124 #check=circle_outwards_1
0125 #check=rain_line_205
0126 #check=rain_down_100
0127 check=rectangle_inwards
0128 
0129 export LAYOUT=one_pmt
0130 export CHECK=${CHECK:-$check}
0131 source $U4TDIR/storch_FillGenstep.sh
0132 echo $BASH_SOURCE : CHECK $CHECK
0133 env | grep storch
0134 
0135 if [ "$storch_FillGenstep_type" == "" ]; then
0136     echo $BASH_SOURCE : FATAL : for CHECK $CHECK LAYOUT $LAYOUT GEOM $GEOM
0137     exit 1
0138 fi
0139 
0140 
0141 export U4SensorIdentifierDefault__GLOBAL_SENSOR_BOUNDARY_LIST=$(cat << EOL
0142 
0143     Pyrex/HamamatsuR12860_PMT_20inch_photocathode_mirror_logsurf/HamamatsuR12860_PMT_20inch_photocathode_mirror_logsurf/Vacuum
0144     Pyrex/NNVTMCPPMT_PMT_20inch_photocathode_mirror_logsurf/NNVTMCPPMT_PMT_20inch_photocathode_mirror_logsurf/Vacuum
0145     Pyrex/PMT_3inch_photocathode_logsurf2/PMT_3inch_photocathode_logsurf1/Vacuum
0146     Pyrex/PMT_20inch_veto_photocathode_logsurf2/PMT_20inch_veto_photocathode_logsurf1/Vacuum
0147 
0148     Pyrex/nnvt_photocathode_mirror_logsurf/nnvt_photocathode_mirror_logsurf/Vacuum
0149 
0150 EOL
0151 )
0152 
0153 
0154 
0155 
0156 logging(){
0157    export Dummy=INFO
0158    #export G4CXOpticks=INFO
0159    #export X4PhysicalVolume=INFO   # look into sensor boundary to understand lpmtid -1
0160    #export QSim=INFO
0161    #export QEvt=INFO
0162    #export SSim__stree_level=2    # U4Tree/stree level   debugging U4Tree::identifySensitiveGlobals
0163    #export SEvt=INFO
0164 
0165    export U4Recorder__PIDX_ENABLED=1
0166    export C4OpBoundaryProcess__PIDX_ENABLED=1
0167 
0168 }
0169 logging
0170 
0171 # dont need to redo the simtrace until geometry changed
0172 #export U4Recorder__EndOfRunAction_Simtrace=1
0173 #export CEGS=16:0:9:100
0174 
0175 
0176 vars="BASH_SOURCE SDIR U4TDIR BINDIR GEOM bin ana tra geomscript BASE FOLD AFOLD BFOLD TFOLD PMTSimParamData_BASE"
0177 
0178 if [ "${arg/info}" != "$arg" ]; then
0179     for var in $vars ; do printf "%20s : %s \n" "$var" "${!var}" ; done
0180 fi
0181 
0182 if [ "${arg/run}" != "$arg" ]; then
0183     $bin
0184     [ $? -ne 0 ] && echo $BASH_SOURCE : run error && exit 1
0185 fi
0186 
0187 if [ "${arg/dbg}" != "$arg" ]; then
0188     source dbg__.sh
0189     dbg__  $bin
0190     [ $? -ne 0 ] && echo $BASH_SOURCE : dbg error && exit 2
0191 fi
0192 
0193 if [ "${arg/grab}" != "$arg" ]; then
0194     source rsync.sh $BASE
0195     [ $? -ne 0 ] && echo $BASH_SOURCE : grab error && exit 3
0196 fi
0197 
0198 if [ "${arg/ana}" != "$arg" ]; then
0199     ${IPYTHON:-ipython} --pdb -i $ana
0200     [ $? -ne 0 ] && echo $BASH_SOURCE : ana error && exit 4
0201 fi
0202 
0203 if [ "${arg/pdb}" != "$arg" ]; then
0204     ${IPYTHON:-ipython} --pdb -i $tra
0205     [ $? -ne 0 ] && echo $BASH_SOURCE : tra error && exit 4
0206 fi
0207 
0208 
0209 if [ "$arg" == "pvcap" -o "$arg" == "pvpub" -o "$arg" == "mpcap" -o "$arg" == "mppub" ]; then
0210     cap_ctx=G4CXTest_${GEOM}_${LAYOUT}_${CHECK}
0211     case $PICK in
0212       A) cap_base=$AFOLD/figs ; cap_stem=${cap_ctx}_A${APID} ;;
0213       B) cap_base=$BFOLD/figs ; cap_stem=${cap_ctx}_B${BPID} ;;
0214     esac
0215     if [ -z "$cap_base" -o -z "$cap_stem" ]; then
0216        echo $BASH_SOURCE : ERROR :  pvcap/pvpub/mpcap/mppub require PICK=A or PICK=B : AB OR BA are not allowed
0217        exit 2
0218     fi
0219     export CAP_STEM=$cap_stem   # stem of the .png screencapture
0220     export CAP_BASE=$cap_base
0221     export CAP_REL=ntds3
0222     case $arg in
0223        pvcap) source pvcap.sh cap  ;;
0224        mpcap) source mpcap.sh cap  ;;
0225        pvpub) source pvcap.sh env  ;;
0226        mppub) source mpcap.sh env  ;;
0227     esac
0228     if [ "$arg" == "pvpub" -o "$arg" == "mppub" ]; then
0229         source epub.sh
0230     fi
0231 fi
0232 
0233 exit 0
0234