Back to home page

EIC code displayed by LXR

 
 

    


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

0001 #!/bin/bash
0002 usage(){ cat << EOU
0003 G4CXTest_raindrop.sh : Standalone bi-simulation with G4CXApp::Main
0004 ===================================================================
0005 
0006 Certain special GEOM strings such as "RaindropRockAirWater"
0007 are recognized by U4VolumeMaker::PVS_  which is called by U4VolumeMaker::PV
0008 
0009 For the configuratuin of the raindrop see U4VolumeMaker::RaindropRockAirWater_Configure
0010 
0011 Currently this uses the default torch genstep for the initial photons,
0012 see storch::FillGenstep for how to customize that.
0013 
0014 ::
0015 
0016     ~/opticks/g4cx/tests/G4CXTest_raindrop.sh
0017     ~/opticks/g4cx/tests/G4CXTest_raindrop_CPU.sh
0018 
0019     B_SIMTRACE=1 G4CXTest_raindrop.sh
0020 
0021 
0022 
0023     EYE=0,-400,0 ~/opticks/g4cx/tests/G4CXTest_raindrop.sh ana
0024 
0025     PICK=A MODE=3 SELECT="TO BT BR BR BR BR BT SA" ~/opticks/g4cx/tests/G4CXTest_raindrop.sh
0026     PICK=B MODE=3 SELECT="TO BT BR BR SA"          ~/opticks/g4cx/tests/G4CXTest_raindrop.sh ana
0027 
0028     NUM=1000000 PICK=B MODE=3 SELECT="TO BT BR BR BR BR BT SA" ~/opticks/g4cx/tests/G4CXTest_raindrop.sh
0029 
0030 EOU
0031 }
0032 
0033 cd $(dirname $(realpath $BASH_SOURCE))
0034 vars=""
0035 DIR=$(pwd)
0036 bin=G4CXTest
0037 script=G4CXTest_raindrop.py
0038 simtrace_script=G4CXTest_raindrop_simtrace.py
0039 
0040 
0041 geom=RaindropRockAirWater
0042 
0043 if [ -n "$GEOM" -a "$GEOM" != "$geom" ]; then
0044    echo $BASH_SOURCE - detected different external GEOM $GEOM geom $geom - do some unset
0045    _SScene__initFromTree_addFrames=$SScene__initFromTree_addFrames
0046    _stree__force_triangulate_solid=$stree__force_triangulate_solid
0047    unset SScene__initFromTree_addFrames
0048    unset stree__force_triangulate_solid
0049 fi
0050 
0051 export GEOM=$geom  # GEOM is identifier for a geometry
0052 
0053 vars="$vars BASH_SOURCE PWD DIR bin script GEOM"
0054 
0055 # THESE ARE NOW THE DEFAULTS
0056 export U4VolumeMaker_RaindropRockAirWater_RINDEX=0,0,1,1.333
0057 export U4VolumeMaker_RaindropRockAirWater_MATS=VACUUM,G4_Pb,G4_AIR,G4_WATER
0058 export U4VolumeMaker_RaindropRockAirWater_HALFSIDE=90
0059 export U4VolumeMaker_RaindropRockAirWater_DROPSHAPE=Box  # default:Orb  (Box also impl)
0060 
0061 if [ -n "$KLUDGE" ]; then
0062     export U4Recorder__PreUserTrackingAction_Optical_UseGivenVelocity_KLUDGE=1
0063 fi
0064 
0065 if [ -n "$B_SIMTRACE" ]; then
0066     export U4Recorder__EndOfRunAction_Simtrace=1
0067     #export SEvt__SIMTRACE=1
0068 
0069     export stree__populate_nidx_prim=1
0070 
0071 fi
0072 
0073 
0074 
0075 if [ "$U4Recorder__PreUserTrackingAction_Optical_UseGivenVelocity_KLUDGE" == "1" ]; then
0076     version=1
0077 else
0078     version=0
0079 fi
0080 
0081 export VERSION=$version  # used in the SEvt output directory
0082 vars="$vars VERSION"
0083 
0084 
0085 #export Local_DsG4Scintillation_DISABLE=1
0086 export G4CXOpticks__SaveGeometry_DIR=$HOME/.opticks/GEOM/$GEOM
0087 
0088 
0089 
0090 
0091 #num=1000
0092 #num=5000
0093 #num=H1
0094 num=M1
0095 NUM=${NUM:-$num}
0096 
0097 ## For torch running MUST NOW configure OPTICKS_NUM_PHOTON and OPTICKS_NUM_GENSTEP
0098 ## envvars with the same number of comma delimited values OR just 1 value without comma
0099 
0100 export OPTICKS_NUM_PHOTON=$NUM
0101 export OPTICKS_NUM_GENSTEP=1
0102 
0103 export OPTICKS_RUNNING_MODE="SRM_TORCH"
0104 export OPTICKS_MAX_SLOT=M1
0105 
0106 
0107 vars="$vars OPTICKS_NUM_PHOTON OPTICKS_NUM_GENSTEP OPTICKS_RUNNING_MODE"
0108 
0109 
0110 if [ "$OPTICKS_RUNNING_MODE" == "SRM_TORCH" ]; then
0111     #export SEvent_MakeGenstep_num_ph=$NUM   ## NO LONGER USED ?
0112 
0113     #src="rectangle"
0114     #src="disc"
0115     src="circle_inwards_hemi"
0116 
0117     if [ "$src" == "rectangle" ]; then
0118         export storch_FillGenstep_pos=0,0,0
0119         export storch_FillGenstep_type=rectangle
0120         export storch_FillGenstep_zenith=-20,20
0121         export storch_FillGenstep_azimuth=-20,20
0122     elif [ "$src" == "disc" ]; then
0123         export storch_FillGenstep_type=disc
0124         export storch_FillGenstep_radius=50        # radius
0125         export storch_FillGenstep_zenith=0,1       # radial range scale
0126         export storch_FillGenstep_azimuth=0,1      # phi segment twopi fraction
0127         export storch_FillGenstep_mom=1,0,0
0128         export storch_FillGenstep_pos=-80,0,0
0129     elif [ "$src" == "circle_inwards_hemi" ]; then
0130         export storch_FillGenstep_type=circle
0131         export storch_FillGenstep_radius=-50    # -ve means inwards
0132         export storch_FillGenstep_pos=0,0,50
0133         export storch_FillGenstep_azimuth=0.5,1
0134     fi
0135     vars="$vars src"
0136 fi
0137 
0138 
0139 #oim=2  # CPU only
0140 oim=3  # GPU and CPU optical simulation
0141 export OPTICKS_INTEGRATION_MODE=${OPTICKS_INTEGRATION_MODE:-$oim}
0142 
0143 #mode=Minimal
0144 mode=DebugLite
0145 export OPTICKS_EVENT_MODE=${OPTICKS_EVENT_MODE:-$mode} # configure what to gather and save via SEvt
0146 
0147 
0148 # below directories match those used by SEvt saving
0149 # in order to be able to load SEvt into python analysis script
0150 #
0151 export TMP=${TMP:-/tmp/$USER/opticks}
0152 evtfold=$TMP/GEOM/$GEOM
0153 
0154 ctx=$(TEST=ContextString sbuild_test)   ## eg Debug_Philox
0155 export OPTICKS_EVENT_NAME=${ctx}
0156 reldir=ALL${VERSION}_${OPTICKS_EVENT_NAME}
0157 
0158 export AFOLD=$evtfold/$bin/$reldir/A000
0159 export BFOLD=$evtfold/$bin/$reldir/B000
0160 export TFOLD=$evtfold/$bin/$reldir/M998   # HMM could use zero now
0161 
0162 
0163 #mode=0 # no plotting
0164 #mode=2 # matplotlib
0165 mode=3 # pyvista
0166 export MODE=${MODE:-$mode}
0167 
0168 
0169 vars="$vars OPTICKS_INTEGRATION_MODE OPTICKS_EVENT_MODE TMP evtfold reldir OPTICKS_EVENT_NAME AFOLD BFOLD TFOLD MODE"
0170 
0171 
0172 event_debug()
0173 {
0174     export SEventConfig=INFO
0175     export SEvt__LIFECYCLE=1
0176     export SEvt__MINIMAL=1
0177     export SEvt=INFO
0178     export SEvent=INFO
0179 
0180     type $FUNCNAME
0181 }
0182 [ -n "$EVENT_DEBUG" ] && event_debug
0183 
0184 logging()
0185 {
0186    export U4Recorder=INFO
0187    export U4StepPoint=INFO
0188    export U4Physics=INFO
0189    #export CSGFoundry=INFO
0190    #export CSGTarget=INFO
0191 }
0192 [ -n "$LOG" ] && logging
0193 
0194 defarg="info_run_ana_cf2"
0195 #defarg="info_dbg_ana"
0196 arg=${1:-$defarg}
0197 
0198 [ -n "$BP" ] && echo $BASH_SOURCE : override arg to info_dbg as BP $BP is defined && arg=info_dbg
0199 
0200 if [ -n "$BP" ]; then
0201    DEBUG_GENIDX=10000
0202    export U4VPrimaryGenerator__GeneratePrimaries_From_Photons_DEBUG_GENIDX=$DEBUG_GENIDX
0203    # for DEBUG_GENIDX > -1 will only generate one photon : for debugging purposes
0204    echo $BASH_SOURCE :  DEBUG_GENIDX $DEBUG_GENIDX OPTICKS_NUM_PHOTON $OPTICKS_NUM_PHOTON
0205 fi
0206 
0207 
0208 vars="$vars CUDA_VISIBLE_DEVICES BP defarg arg"
0209 
0210 
0211 
0212 if [ "${arg/info}" != "$arg" ]; then
0213     for var in $vars ; do printf "%30s : %s \n" "$var" "${!var}" ; done
0214 fi
0215 
0216 if [ "${arg/run}" != "$arg" ]; then
0217     $bin
0218     [ $? -ne 0 ] && echo $BASH_SOURCE : run error && exit 1
0219 fi
0220 
0221 if [ "${arg/dbg}" != "$arg" ]; then
0222     source dbg__.sh
0223     dbg__ $bin
0224     [ $? -ne 0 ] && echo $BASH_SOURCE : dbg error && exit 2
0225 fi
0226 
0227 if [ "${arg/grab}" != "$arg" ]; then
0228     source rsync.sh $evtfold
0229     [ $? -ne 0 ] && echo $BASH_SOURCE : grab error && exit 3
0230 fi
0231 
0232 if [ "${arg/ls}" != "$arg" ]; then
0233      ff="AFOLD BFOLD TFOLD"
0234      for f in $ff ; do printf "\n\n%s : ls -alst %s \n\n" "$f" "${!f}" && ls -alst ${!f} ; done
0235 fi
0236 
0237 
0238 if [ "${arg/old}" != "$arg" ]; then
0239     export SAVE_SEL=1
0240 
0241     if command -v ${IPYTHON:-ipython} &> /dev/null
0242     then
0243         ${IPYTHON:-ipython} --pdb -i $script
0244     else
0245         echo $BASH_SOURCE - IPYTHON NOT AVAILABLE - TRY PYTHON
0246         ${PYTHON:-python} -i $script
0247     fi
0248     [ $? -ne 0 ] && echo $BASH_SOURCE : ana error with script $script && exit 4
0249 fi
0250 
0251 if [ "${arg/ana}" != "$arg" ]; then
0252     ${PYTHON:-python} $script
0253     [ $? -ne 0 ] && echo $BASH_SOURCE : ana error with script $script && exit 4
0254 fi
0255 
0256 if [ "${arg/pdb}" != "$arg" ]; then
0257     ${IPYTHON:-ipython} --pdb -i $script
0258     [ $? -ne 0 ] && echo $BASH_SOURCE : pdb error with script $script && exit 4
0259 fi
0260 
0261 if [ "${arg/tra}" != "$arg" ]; then
0262     ${IPYTHON:-ipython} --pdb -i $simtrace_script
0263     [ $? -ne 0 ] && echo $BASH_SOURCE : pdb error with simtrace_script $simtrace_script && exit 4
0264 fi
0265 
0266 
0267 
0268 
0269 if [ "${arg/cf2}" != "$arg" ]; then
0270     sseq_index_test.sh info_run_ana
0271     [ $? -ne 0 ] && echo $BASH_SOURCE : cf2 error && exit 5
0272 fi
0273 
0274 
0275 
0276 exit 0
0277