Back to home page

EIC code displayed by LXR

 
 

    


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

0001 #!/bin/bash
0002 usage(){ cat << EOU
0003 cxs_min.sh : minimal executable and script for shakedown
0004 ============================================================
0005 
0006 Uses ~oneline main::
0007 
0008      CSGOptiX::SimulateMain();
0009 
0010 Usage::
0011 
0012     ~/o/cxs_min.sh
0013     ~/o/cxs_min.sh info
0014     ~/o/cxs_min.sh run       ## create SEvt
0015     ~/o/cxs_min.sh report    ## summarize SEvt metadata
0016 
0017 
0018 
0019 This script is used for many purposes in development and testing
0020 making it require understanding and often editing before use,
0021 plus the setting of the TEST envvar to select the type of
0022 test to perform.
0023 
0024 This script runs the CSGOptiXSMTest executable which has no Geant4 dependency,
0025 so it is restricted to purely optical running and loads the persisted CSGFoundry
0026 from ~/.opticks/GEOM/$GEOM/CSGFoundry using GEOM envvar
0027 set by ~/.opticks/GEOM/GEOM.sh
0028 
0029 This script is most commonly used for "torch" running where initial photons
0030 are generated in simple patterns and with numbers of photons configured by the
0031 script. Input photons and input gensteps can also be configured. Small scans
0032 simulating multiple events with varying numbers of photons can also be configured,
0033 often simply by selecting a TEST envvar value.
0034 
0035 
0036 Examples::
0037 
0038     TEST=vvlarge_evt ~/o/cxs_min.sh
0039          ## caution tries to simulate a billion photons
0040          ## for JUNO writes ~12GB of hits
0041 
0042 
0043 
0044 Debug::
0045 
0046     BP=SEvt::SEvt               ~/opticks/CSGOptiX/cxs_min.sh
0047     BP=SEvent::MakeTorchGenstep ~/opticks/CSGOptiX/cxs_min.sh
0048 
0049 Analysis/Plotting::
0050 
0051     ~/o/cxs_min.sh grab
0052     EVT=A000 ~/o/cxs_min.sh ana
0053 
0054     MODE=2 SEL=1 ~/o/cxs_min.sh ana
0055     EVT=A005     ~/o/cxs_min.sh ana
0056     EVT=A010     ~/o/cxs_min.sh ana
0057 
0058     PLOT=scatter MODE=3 ~/o/cxs_min.sh pvcap
0059 
0060 Monitor for GPU memory leaks::
0061 
0062     ~/o/sysrap/smonitor.sh build_run  # start monitor
0063 
0064     TEST=large_scan ~/o/cxs_min.sh
0065 
0066     # CTRL-C smonitor.sh session sending SIGINT to process which saves smonitor.npy
0067 
0068     ~/o/sysrap/smonitor.sh grab  ## back to laptop
0069     ~/o/sysrap/smonitor.sh ana   ## plot
0070 
0071 
0072 pdb1
0073    ipython cxs_min.py
0074 
0075 pdb0
0076    as pdb1 with MODE=0 for no pyvista or matplotlib usage
0077    useful for loading/examining the SEvt with ipython
0078    from anywhere
0079 
0080 EOU
0081 }
0082 
0083 vars=""
0084 SDIR=$(dirname $(realpath $BASH_SOURCE))
0085 
0086 vars="$vars BASH_SOURCE SDIR"
0087 
0088 case $(uname) in
0089    Linux) defarg=run_report_info ;;
0090    Darwin) defarg=ana ;;
0091 esac
0092 
0093 [ -n "$BP" ] && defarg=dbg
0094 [ -n "$PLOT" ] && defarg=ana
0095 
0096 arg=${1:-$defarg}
0097 allarg=info_env_fold_run_dbg_meta_report_grab_grep_gevt_du_pdb1_pdb0_AB_ana_pvcap_pvpub_mpcap_mppub
0098 vars="$vars defarg arg allarg"
0099 
0100 
0101 bin=CSGOptiXSMTest
0102 script=$SDIR/cxs_min.py
0103 script_AB=$SDIR/cxs_min_AB.py
0104 vars="$vars bin script script_AB"
0105 
0106 
0107 External_CFBaseFromGEOM=${GEOM}_CFBaseFromGEOM
0108 if [ -n "$GEOM" -a -n "${!External_CFBaseFromGEOM}" -a -d "${!External_CFBaseFromGEOM}" -a -f "${!External_CFBaseFromGEOM}/CSGFoundry/prim.npy" ]; then
0109     echo $BASH_SOURCE - External GEOM setup detected
0110     vv="External_CFBaseFromGEOM ${External_CFBaseFromGEOM}"
0111     for v in $vv ; do printf "%40s : %s \n" "$v" "${!v}" ; done
0112 else
0113     ## development source tree usage : where need to often switch between geometries
0114     source ~/.opticks/GEOM/GEOM.sh   # sets GEOM envvar, use GEOM bash function to setup/edit
0115     #export ${GEOM}_CFBaseFromGEOM=$HOME/.opticks/GEOM/$GEOM
0116 fi
0117 
0118 vars="$vars GEOM"
0119 
0120 tmp=/tmp/$USER/opticks
0121 export TMP=${TMP:-$tmp}
0122 export EVT=${EVT:-A000}
0123 export BASE=$TMP/GEOM/$GEOM
0124 export BINBASE=$BASE/$bin
0125 export SCRIPT=$(basename $BASH_SOURCE)
0126 
0127 vars="$vars TMP EVT BASE BINBASE SCRIPT"
0128 
0129 vars="$vars ${GEOM}_CFBaseFromGEOM ${GEOM}_GDMLPathFromGEOM"
0130 
0131 # pulled out complicated Resolve_CFBaseFromGEOM.sh from here
0132 # instead rely on user to setup geometry access envvar
0133 # in GEOM.sh or elsewhere
0134 
0135 knobs()
0136 {
0137    type $FUNCNAME
0138 
0139    local exceptionFlags
0140    local debugLevel
0141    local optLevel
0142 
0143    #exceptionFlags=STACK_OVERFLOW
0144    exceptionFlags=NONE
0145 
0146    #debugLevel=DEFAULT
0147    debugLevel=NONE
0148    #debugLevel=FULL
0149 
0150    #optLevel=DEFAULT
0151    #optLevel=LEVEL_0
0152    optLevel=LEVEL_3
0153 
0154 
0155    #export PIP__max_trace_depth=1
0156    export PIP__CreatePipelineOptions_exceptionFlags=$exceptionFlags # NONE/STACK_OVERFLOW/TRACE_DEPTH/USER/DEBUG
0157    export PIP__CreateModule_debugLevel=$debugLevel  # DEFAULT/NONE/MINIMAL/MODERATE/FULL   (DEFAULT is MINIMAL)
0158    export PIP__linkPipeline_debugLevel=$debugLevel  # DEFAULT/NONE/MINIMAL/MODERATE/FULL
0159    export PIP__CreateModule_optLevel=$optLevel      # DEFAULT/LEVEL_0/LEVEL_1/LEVEL_2/LEVEL_3
0160 
0161    #export Ctx=INFO
0162    #export PIP=INFO
0163    #export CSGOptiX=INFO
0164 
0165 
0166    #export NPFold__substamp_DUMP=1
0167 
0168 
0169 }
0170 
0171 
0172 #version=0
0173 #version=1
0174 version=98   ## set to 98 for low stats debugging
0175 
0176 export VERSION=${VERSION:-$version}   ## see below currently using VERSION TO SELECT OPTICKS_EVENT_MODE
0177 ## VERSION CHANGES OUTPUT DIRECTORIES : SO USEFUL TO ARRANGE SEPARATE STUDIES
0178 
0179 vars="$vars version VERSION"
0180 
0181 
0182 #test=debug
0183 #test=ref1
0184 #test=ref5
0185 #test=ref8
0186 #test=ref10
0187 #test=ref10_multilaunch
0188 #test=input_genstep
0189 #test=input_genstep_muon
0190 
0191 #test=input_photon_chimney
0192 #test=input_photon_nnvt
0193 #test=input_photon_target
0194 #test=input_photon_wp_pmt
0195 #test=input_photon_wp_pmt_side
0196 #test=input_photon_wp_pmt_semi
0197 #test=input_photon_s_pmt
0198 #test=input_photon_poolcover
0199 test=input_photon_poolcover_refine
0200 
0201 #test=large_evt
0202 #test=vlarge_evt
0203 #test=vvlarge_evt
0204 #test=medium_scan
0205 
0206 export TEST=${TEST:-$test}
0207 
0208 
0209 #ctx=Debug_XORWOW
0210 #ctx=Debug_Philox
0211 
0212 case $(uname) in
0213    Darwin) ctx=Debug_Philox ;;
0214     Linux) ctx=$(TEST=ContextString sbuild_test) ;;
0215 esac
0216 
0217 export OPTICKS_EVENT_NAME=${ctx}_${TEST}
0218 ## SEventConfig::Initialize_EventName asserts OPTICKS_EVENT_NAME sbuild::Matches config of the build
0219 
0220 
0221 opticks_event_reldir=ALL${VERSION:-0}_${OPTICKS_EVENT_NAME:-none}   ## matches SEventConfig::_DefaultEventReldir OPTICKS_EVENT_RELDIR
0222 export OPTICKS_EVENT_RELDIR='ALL${VERSION:-0}_${OPTICKS_EVENT_NAME:-none}'  ## this is the default in SEventConfig
0223 # opticks_event_reldir is resolved here, OPTICKS_EVENT_RELDIR resolved by SEvt/SEventConfig
0224 
0225 vars="$vars test TEST opticks_event_reldir OPTICKS_EVENT_RELDIR"
0226 
0227 case $TEST in
0228 ref10_multilaunch) alt_TEST=ref10_onelaunch ;;
0229 ref10_onelaunch)   alt_TEST=ref10_multilaunch ;;
0230 esac
0231 
0232 alt_opticks_event_reldir=ALL${VERSION:-0}_${alt_TEST}
0233 vars="$vars alt_TEST alt_opticks_event_reldir"
0234 
0235 
0236 
0237 export LOGDIR=$BINBASE/$opticks_event_reldir
0238 export AFOLD=$BINBASE/$opticks_event_reldir/$EVT
0239 export STEM=${opticks_event_reldir}_${PLOT}
0240 
0241 #export BFOLD=$BASE/G4CXTest/ALL0/$EVT
0242 #export BFOLD=$BASE/jok-tds/ALL0/A001
0243 #BFOLD_NOTE="comparison with A from another executable"
0244 
0245 #export BFOLD=$BINBASE/$alt_opticks_event_reldir/$EVT   # comparison with alt_TEST
0246 #BFOLD_NOTE="comparison with alt_TEST:$alt_TEST"
0247 BFOLD_NOTE="defining BFOLD makes python script do SAB comparison"
0248 
0249 mkdir -p $LOGDIR
0250 cd $LOGDIR
0251 LOGFILE=$bin.log
0252 
0253 vars="$vars LOGDIR AFOLD BFOLD BFOLD_NOTE STEM LOGFILE"
0254 
0255 
0256 case $VERSION in
0257  0) opticks_event_mode=Minimal ;;
0258  1) opticks_event_mode=Hit ;;
0259  2) opticks_event_mode=HitPhoton ;;
0260  3) opticks_event_mode=HitPhoton ;;
0261  4) opticks_event_mode=HitPhotonSeq ;;
0262  5) opticks_event_mode=HitSeq ;;
0263 98) opticks_event_mode=DebugLite ;;
0264 99) opticks_event_mode=DebugHeavy ;;  # formerly StandardFullDebug
0265 esac
0266 
0267 vars="$vars opticks_event_mode"
0268 
0269 
0270 if [ "$TEST" == "debug" ]; then
0271 
0272    opticks_num_event=1
0273    opticks_num_genstep=1
0274    opticks_num_photon=100
0275    opticks_running_mode=SRM_TORCH
0276    #opticks_max_photon=M1
0277 
0278 elif [ "$TEST" == "ref1" ]; then
0279 
0280    opticks_num_event=1
0281    opticks_num_genstep=10
0282    opticks_num_photon=M1
0283    opticks_running_mode=SRM_TORCH
0284    opticks_max_slot=M1
0285 
0286 elif [ "$TEST" == "ref5" -o "$TEST" == "ref6" -o "$TEST" == "ref7" -o "$TEST" == "ref8" -o "$TEST" == "ref9" -o "$TEST" == "ref10" ]; then
0287 
0288    opticks_num_event=1
0289    opticks_num_genstep=1
0290    opticks_num_photon=M${TEST:3}
0291    opticks_running_mode=SRM_TORCH
0292    opticks_max_slot=M${TEST:3}
0293 
0294 elif [ "$TEST" == "refX" ]; then
0295 
0296    opticks_num_event=1
0297    opticks_num_genstep=1
0298    opticks_num_photon=${X:-7500000}
0299    opticks_running_mode=SRM_TORCH
0300    opticks_max_slot=$opticks_num_photon
0301 
0302 elif [ "$TEST" == "ref10_multilaunch" -o "$TEST" == "ref10_onelaunch" ]; then
0303 
0304    opticks_num_event=1
0305    opticks_num_genstep=10
0306    opticks_num_photon=M10
0307    opticks_running_mode=SRM_TORCH
0308 
0309    #opticks_max_photon=M10
0310    #opticks_max_curand=0    # zero loads all states : ready for whopper XORWOW running
0311    #opticks_max_curand=M10  # non-zero loads the specified number : this not relevant for PHILOX with default G1 1billion states
0312 
0313    case $TEST in
0314       *multilaunch) opticks_max_slot=M1 ;;     ## causes M10 to be done in 10 launches
0315         *onelaunch) opticks_max_slot=M10 ;;
0316    esac
0317    ## Normally leave max_slot as default zero indicating to pick max_slot according to VRAM.
0318    ## Are specifying here to compare multilaunch and onelaunch running of the same photons.
0319 
0320 elif [ "$TEST" == "tiny_scan" ]; then
0321 
0322    opticks_num_event=10
0323    opticks_num_genstep=1x10
0324    opticks_num_photon=K1:10
0325    opticks_running_mode=SRM_TORCH
0326    #opticks_max_photon=M1
0327 
0328 elif [ "$TEST" == "large_scan" ]; then
0329 
0330    opticks_num_event=20
0331    opticks_num_genstep=1x20
0332    opticks_num_photon=H1:10,M2,3,5,7,10,20,40,60,80,100
0333    opticks_running_mode=SRM_TORCH
0334    #opticks_max_photon=M100
0335 
0336 elif [ "$TEST" == "medium_scan" ]; then
0337 
0338    opticks_num_event=12
0339    opticks_num_genstep=1x12
0340    opticks_num_photon=M1,1,10,20,30,40,50,60,70,80,90,100  # duplication of M1 is to workaround lack of metadata
0341    opticks_running_mode=SRM_TORCH
0342    #opticks_max_photon=M100
0343 
0344    # Remember multi-launch needs multiple gensteps in order to slice them up
0345    # such that each slice fits into VRAM.
0346    # So for big photon counts its vital to use multiple genstep.
0347 
0348 
0349 elif [ "$TEST" == "larger_scan" ]; then
0350 
0351    opticks_num_event=22
0352    opticks_num_genstep=1x22
0353    opticks_num_photon=M1,1,10,20,30,40,50,60,70,80,90,100,110,120,130,140,150,160,170,180,190,200  # duplication of M1 is to workaround lack of metadata
0354    opticks_running_mode=SRM_TORCH
0355 
0356    #opticks_max_photon=M200
0357 
0358 
0359 elif [ "$TEST" == "large_evt" ]; then
0360 
0361    opticks_num_event=1
0362    opticks_num_genstep=10
0363    opticks_num_photon=M200         ## OOM with TITAN RTX 24G, avoided by multi-launch sliced genstep running
0364    opticks_running_mode=SRM_TORCH
0365 
0366    #opticks_max_photon=M200
0367    #opticks_max_slot=0              ## zero -> SEventConfig::SetDevice determines MaxSlot based on VRAM
0368 
0369 elif [ "$TEST" == "vlarge_evt" ]; then
0370 
0371    opticks_num_event=1
0372    opticks_num_genstep=20
0373    opticks_num_photon=M500
0374    opticks_running_mode=SRM_TORCH
0375    #opticks_max_photon=M200        ## G1 default so no need to set
0376    #opticks_max_slot=0              ## zero -> SEventConfig::SetDevice determines MaxSlot based on VRAM
0377 
0378 elif [ "$TEST" == "vvlarge_evt" ]; then
0379 
0380    opticks_num_event=1
0381    opticks_num_genstep=40
0382    opticks_num_photon=G1
0383    opticks_running_mode=SRM_TORCH
0384 
0385 elif [ "$TEST" == "input_genstep" ]; then
0386 
0387    opticks_num_event=1000
0388    opticks_num_genstep=    # ignored
0389    opticks_num_photon=     # ignored ?
0390    opticks_running_mode=SRM_INPUT_GENSTEP
0391 
0392    #opticks_max_photon=M1
0393 
0394 elif [ "$TEST" == "input_genstep_muon" ]; then
0395 
0396    opticks_num_event=1
0397    opticks_num_genstep=    # ignored
0398    opticks_num_photon=     # ignored ?
0399    opticks_running_mode=SRM_INPUT_GENSTEP
0400 
0401    #opticks_max_slot=H1     ##
0402    opticks_max_slot=M1     ##
0403    #opticks_max_slot=M5    ##
0404    #opticks_max_slot=M10   ## 3 launches
0405    #opticks_max_slot=M1    ## ~34 launches
0406    #opticks_max_slot=0     ## whole-in-one
0407 
0408 
0409 elif [ "${TEST:0:12}" == "input_photon" ]; then
0410 
0411    opticks_num_event=1
0412    opticks_num_genstep=    # ignored
0413    opticks_num_photon=     # ignored ?
0414    opticks_running_mode=SRM_INPUT_PHOTON
0415    opticks_max_slot=M3
0416 
0417    if [ "${TEST:12}" == "_chimney" ]; then
0418 
0419       sevt__input_photon_dir=$TMP/SGenerate__test
0420 
0421       opticks_input_photon=SGenerate_ph_disc_K1.npy
0422 
0423       opticks_input_photon_frame=sChimneyLS:0:-2
0424       #opticks_input_photon_frame=sChimneyAcrylic
0425 
0426    elif [ "${TEST:12}" == "_nnvt" ]; then
0427 
0428       #sevt__input_photon_dir=/cvmfs/opticks.ihep.ac.cn/.opticks/InputPhotons
0429       sevt__input_photon_dir=$HOME/.opticks/InputPhotons
0430 
0431       opticks_input_photon=RainXZ_Z230_100k_f8.npy
0432       #opticks_input_photon=RainXZ_Z230_1000_f8.npy      ## ok
0433       #opticks_input_photon=RainXZ_Z230_10k_f8.npy       ## ok
0434       #opticks_input_photon=RainXZ_Z230_X700_10k_f8.npy  ## X700 to illuminate multiple PMTs
0435 
0436       opticks_input_photon_frame=NNVT:0:0
0437       #opticks_input_photon_frame=NNVT:0:50
0438       #opticks_input_photon_frame=NNVT:0:1000
0439 
0440    elif [ "${TEST:12}" == "_wp_pmt" ]; then
0441 
0442       sevt__input_photon_dir=$HOME/.opticks/InputPhotons
0443       opticks_input_photon=RainXZ_Z230_100k_f8.npy
0444       opticks_input_photon_frame=PMT_20inch_veto:0:1000
0445 
0446       #export PIDX=99999
0447 
0448    elif [ "${TEST:12}" == "_wp_pmt_side" ]; then
0449 
0450       sevt__input_photon_dir=$HOME/.opticks/InputPhotons
0451       opticks_input_photon=SideZX_X300_100k_f8.npy
0452       opticks_input_photon_frame=PMT_20inch_veto:0:1000
0453 
0454    elif [ "${TEST:12}" == "_wp_pmt_semi" ]; then
0455 
0456       sevt__input_photon_dir=$HOME/.opticks/InputPhotons
0457       opticks_input_photon=SemiCircleXZ_R-500_100k_f8.npy
0458       opticks_input_photon_frame=PMT_20inch_veto:0:1000
0459 
0460    elif [ "${TEST:12}" == "_poolcover" -o "${TEST:12}" == "_poolcover_refine" ]; then
0461 
0462       sevt__input_photon_dir=$HOME/.opticks/InputPhotons
0463       #opticks_input_photon=UpXZ1000_f8.npy
0464       opticks_input_photon=CircleXZ_R500_100k_f8.npy
0465       #opticks_input_photon=CircleXZ_R10_361_f8.npy
0466       #opticks_input_photon_frame=3345.569,20623.73,21500
0467       opticks_input_photon_frame=3345.569,20623.73,21000
0468       #export PIDX=99999
0469 
0470       export SEvt__transformInputPhoton_VERBOSE=1
0471       export CSGFoundry__getFrame_VERBOSE=1
0472       export CSGFoundry__getFrameE_VERBOSE=1
0473 
0474       if [ "${TEST/refine}" != "$TEST" ]; then
0475          export OPTICKS_PROPAGATE_REFINE=1
0476       else
0477          unset OPTICKS_PROPAGATE_REFINE
0478       fi
0479 
0480 
0481    elif [ "${TEST:12}" == "_s_pmt" ]; then
0482 
0483       sevt__input_photon_dir=$HOME/.opticks/InputPhotons
0484       opticks_input_photon=RainXZ_Z230_X25_100k_f8.npy
0485       opticks_input_photon_frame=PMT_3inch:0:0
0486 
0487    elif [ "${TEST:12}" == "_target" ]; then
0488 
0489        #opticks_input_photon=GridXY_X700_Z230_10k_f8.npy
0490        #opticks_input_photon=GridXY_X1000_Z1000_40k_f8.npy
0491 
0492        #opticks_input_photon_frame=-1
0493        #opticks_input_photon_frame=sWorld:0:0
0494        opticks_input_photon_frame=sTarget
0495 
0496    else
0497        echo $BASH_SOURCE : ERROR TEST [$TEST] SUFFIX AFTER input_photon [${TEST:12}] IS NOT HANDLED
0498        exit 1
0499    fi
0500 
0501 else
0502 
0503    echo $BASH_SOURCE : ERROR TEST $TEST IS NOT HANDLED
0504    exit 1
0505 
0506 fi
0507 
0508 vars="$vars opticks_num_event opticks_num_genstep opticks_num_photon opticks_running_mode opticks_max_slot"
0509 
0510 
0511 #opticks_running_mode=SRM_DEFAULT
0512 #opticks_running_mode=SRM_INPUT_PHOTON
0513 #opticks_running_mode=SRM_GUN
0514 
0515 
0516 opticks_start_index=0
0517 #opticks_max_bounce=31
0518 opticks_max_bounce=63
0519 opticks_integration_mode=1
0520 
0521 
0522 
0523 #opticks_hit_mask=SD
0524 opticks_hit_mask=EC
0525 export OPTICKS_HIT_MASK=${OPTICKS_HIT_MASK:-$opticks_hit_mask}
0526 
0527 export OPTICKS_NUM_EVENT=${OPTICKS_NUM_EVENT:-$opticks_num_event}
0528 export OPTICKS_NUM_GENSTEP=${OPTICKS_NUM_GENSTEP:-$opticks_num_genstep}
0529 export OPTICKS_NUM_PHOTON=${OPTICKS_NUM_PHOTON:-$opticks_num_photon}
0530 
0531 export OPTICKS_RUNNING_MODE=${OPTICKS_RUNNING_MODE:-$opticks_running_mode}   # SRM_TORCH/SRM_INPUT_PHOTON/SRM_INPUT_GENSTEP
0532 export OPTICKS_EVENT_MODE=${OPTICKS_EVENT_MODE:-$opticks_event_mode}         # what arrays are saved eg Hit,HitPhoton,HitPhotonSeq
0533 
0534 export OPTICKS_MAX_PHOTON=${OPTICKS_MAX_PHOTON:-$opticks_max_photon}         # no needed much now with PHILOX and multi-launch
0535 
0536 export OPTICKS_MAX_BOUNCE=${OPTICKS_MAX_BOUNCE:-$opticks_max_bounce}
0537 export OPTICKS_START_INDEX=${OPTICKS_START_INDEX:-$opticks_start_index}
0538 export OPTICKS_INTEGRATION_MODE=${OPTICKS_INTEGRATION_MODE:-$opticks_integration_mode}
0539 
0540 
0541 vars="$vars version VERSION opticks_event_mode OPTICKS_EVENT_MODE OPTICKS_NUM_PHOTON OPTICKS_NUM_GENSTEP OPTICKS_MAX_PHOTON OPTICKS_NUM_EVENT OPTICKS_RUNNING_MODE"
0542 
0543 export OPTICKS_MAX_CURAND=$opticks_max_curand  ## SEventConfig::MaxCurand only relevant to XORWOW
0544 export OPTICKS_MAX_SLOT=$opticks_max_slot      ## SEventConfig::MaxSlot
0545 vars="$vars OPTICKS_MAX_CURAND OPTICKS_MAX_SLOT"
0546 
0547 
0548 if [ "$OPTICKS_RUNNING_MODE" == "SRM_INPUT_GENSTEP" ]; then
0549 
0550     #igs=$BASE/jok-tds/ALL0/A000/genstep.npy
0551     #igs=$BASE/jok-tds/ALL0/A%0.3d/genstep.npy
0552     igs=$HOME/.opticks/crash_muon_igs.npy
0553 
0554     if [ "${igs/\%}" != "$igs" ]; then
0555         igs0=$(printf "$igs" 0)
0556     else
0557         igs0=$igs
0558     fi
0559     [ ! -f "$igs0" ] && echo $BASH_SOURCE : FATAL : NO SUCH PATH : igs0 $igs0 igs $igs && exit 1
0560     export OPTICKS_INPUT_GENSTEP=$igs
0561     export OPTICKS_START_INDEX=6   ## enabled reproducing photons from original eventID 6 from the igs
0562 
0563 
0564 elif [ "$OPTICKS_RUNNING_MODE" == "SRM_INPUT_PHOTON" ]; then
0565 
0566     ## cf with ipcv : ~/j/InputPhotonsCheck/InputPhotonsCheck.sh
0567     # SEventConfig
0568     export SEvt__INPUT_PHOTON_DIR=${SEvt__INPUT_PHOTON_DIR:-$sevt__input_photon_dir}
0569     export OPTICKS_INPUT_PHOTON=${OPTICKS_INPUT_PHOTON:-$opticks_input_photon};
0570     export OPTICKS_INPUT_PHOTON_FRAME=${OPTICKS_INPUT_PHOTON_FRAME:-$opticks_input_photon_frame}
0571 
0572     ippath=${SEvt__INPUT_PHOTON_DIR}/${OPTICKS_INPUT_PHOTON}
0573     if [ ! -f "$ippath" ]; then
0574         echo $BASH_SOURCE - ERROR ippath [$ippath] DOES NOT EXIST
0575         exit 1
0576     fi
0577 
0578 
0579 
0580     vars="$vars SEvt__INPUT_PHOTON_DIR OPTICKS_INPUT_PHOTON OPTICKS_INPUT_PHOTON_FRAME"
0581 
0582 elif [ "$OPTICKS_RUNNING_MODE" == "SRM_TORCH" ]; then
0583 
0584     #export SEvent_MakeGenstep_num_ph=100000  OVERRIDEN BY OPTICKS_NUM_PHOTON
0585     #export SEvent__MakeGenstep_num_gs=10     OVERRIDEN BY OPTICKS_NUM_GENSTEP
0586 
0587     #src="rectangle"
0588     #src="disc"
0589     src="sphere"
0590 
0591     if [ "$src" == "rectangle" ]; then
0592         export storch_FillGenstep_pos=0,0,0
0593         export storch_FillGenstep_type=rectangle
0594         export storch_FillGenstep_zenith=-20,20
0595         export storch_FillGenstep_azimuth=-20,20
0596     elif [ "$src" == "disc" ]; then
0597         export storch_FillGenstep_type=disc
0598         export storch_FillGenstep_radius=50
0599         export storch_FillGenstep_zenith=0,1       # radial range scale
0600         export storch_FillGenstep_azimuth=0,1      # phi segment twopi fraction
0601         export storch_FillGenstep_mom=1,0,0
0602         export storch_FillGenstep_pos=-80,0,0
0603     elif [ "$src" == "sphere" ]; then
0604         export storch_FillGenstep_type=sphere
0605         export storch_FillGenstep_radius=100    # +ve for outwards
0606         export storch_FillGenstep_pos=0,0,0
0607         export storch_FillGenstep_distance=1.00 # frac_twopi control of polarization phase(tangent direction)
0608     fi
0609 
0610 
0611 
0612 elif [ "$OPTICKS_RUNNING_MODE" == "SRM_GUN" ]; then
0613 
0614     echo -n
0615 
0616 fi
0617 
0618 
0619 
0620 
0621 logging(){
0622     export CSGFoundry=INFO
0623     export CSGOptiX=INFO
0624     export QEvt=INFO
0625     export QSim=INFO
0626     #export SEvt__LIFECYCLE=1
0627     export SEvt__GATHER=1
0628     export SEvt__SAVE=1
0629 }
0630 [ -n "$LOG" ] && logging
0631 [ -n "$LIFECYCLE" ] && export SEvt__LIFECYCLE=1
0632 [ -n "$MEMCHECK" ] && export QU__MEMCHECK=1
0633 [ -n "$MINIMAL"  ] && export SEvt__MINIMAL=1
0634 [ -n "$MINTIME"  ] && export SEvt__MINTIME=1
0635 [ -n "$INDEX"  ] && export SEvt__INDEX=1
0636 [ -n "$RUNMETA"  ] && export SEvt__RUNMETA=1
0637 [ -n "$CRASH" ] && export CSGOptiX__optixpath=$OPTICKS_PREFIX/ptx/objects-Debug/CSGOptiXOPTIX/CSGOptiX7.ptx
0638 
0639 export QRng__init_VERBOSE=1
0640 export SEvt__MINIMAL=1  ## just output dir
0641 export SEvt__MINTIME=1  ## minimal timing info from QSim::simulate
0642 
0643 #export SEvt__DIRECTORY=1  ## getDir dumping
0644 #export SEvt__NPFOLD_VERBOSE=1
0645 #export QSim__simulate_KEEP_SUBFOLD=1
0646 #export SEvt__transformInputPhoton_VERBOSE=1
0647 #export CSGFoundry__getFrameE_VERBOSE=1
0648 #export CSGFoundry__getFrame_VERBOSE=1
0649 
0650 
0651 
0652 
0653 if [ "${arg/info}" != "$arg" ]; then
0654    for var in $vars ; do printf "%-30s : %s \n" "$var" "${!var}" ; done
0655 fi
0656 
0657 if [ "${arg/env}" != "$arg" ]; then
0658     env | grep OPTICKS | perl -n -e 'm/(\S*)=(\S*)/ && printf("%50s : %s\n", $1, $2) ' -
0659 fi
0660 
0661 if [ "${arg/fold}" != "$arg" ]; then
0662     echo $AFOLD
0663     du -hs $AFOLD/*
0664 fi
0665 
0666 if [ "${arg/run}" != "$arg" -o "${arg/dbg}" != "$arg" ]; then
0667 
0668    knobs
0669 
0670    if [ -f "$LOGFILE" ]; then
0671        echo $BASH_SOURCE : run : delete prior LOGFILE $LOGFILE
0672        rm "$LOGFILE"
0673    fi
0674 
0675    if [ "${arg/run}" != "$arg" ]; then
0676        date +"%Y-%m-%d %H:%M:%S.%3N  %N : [$BASH_SOURCE "
0677        $bin
0678        [ $? -ne 0 ] && echo $BASH_SOURCE run error && exit 1
0679        date +"%Y-%m-%d %H:%M:%S.%3N  %N : ]$BASH_SOURCE "
0680    elif [ "${arg/dbg}" != "$arg" ]; then
0681        source dbg__.sh
0682        dbg__ $bin
0683        [ $? -ne 0 ] && echo $BASH_SOURCE dbg error && exit 1
0684    fi
0685 fi
0686 
0687 if [ "${arg/meta}" != "$arg" ]; then
0688    if [ -f "run_meta.txt" -a -n "$OPTICKS_SCAN_INDEX"  -a -d "$OPTICKS_SCAN_INDEX" ] ; then
0689        cp run_meta.txt $OPTICKS_SCAN_INDEX/run_meta.txt
0690    fi
0691    [ $? -ne 0 ] && echo $BASH_SOURCE meta error && exit 1
0692 fi
0693 
0694 
0695 if [ "${arg/report}" != "$arg" ]; then
0696    sreport
0697    [ $? -ne 0 ] && echo $BASH_SOURCE sreport error && exit 1
0698 fi
0699 
0700 if [ "${arg/grab}" != "$arg" ]; then
0701     source $OPTICKS_HOME/bin/rsync.sh $LOGDIR
0702 fi
0703 
0704 if [ "${arg/grep}" != "$arg" ]; then
0705     source $OPTICKS_HOME/bin/rsync.sh ${LOGDIR}_sreport
0706 fi
0707 
0708 if [ "${arg/gevt}" != "$arg" ]; then
0709     source $OPTICKS_HOME/bin/rsync.sh $LOGDIR/$EVT
0710 fi
0711 
0712 
0713 if [ "${arg/du}" != "$arg" ]; then
0714     du -hs $AFOLD/*
0715 fi
0716 
0717 
0718 if [ "${arg/pdb}" != "$arg" ]; then
0719     ${IPYTHON:-ipython} --pdb -i $script
0720 fi
0721 
0722 if [ "${arg/pdz}" != "$arg" ]; then
0723     MODE=0 ${IPYTHON:-ipython} --pdb -i $script
0724 fi
0725 
0726 if [ "${arg/AB}" != "$arg" ]; then
0727     MODE=0 ${IPYTHON:-ipython} --pdb -i $script_AB
0728 fi
0729 
0730 if [ "${arg/ana}" != "$arg" ]; then
0731     MODE=0 ${PYTHON:-python} $script
0732 fi
0733 
0734 
0735 
0736 if [ "$arg" == "pvcap" -o "$arg" == "pvpub" -o "$arg" == "mpcap" -o "$arg" == "mppub" ]; then
0737     export CAP_BASE=$AFOLD/figs
0738     export CAP_REL=cxs_min
0739     export CAP_STEM=$STEM
0740     case $arg in
0741        pvcap) source pvcap.sh cap  ;;
0742        mpcap) source mpcap.sh cap  ;;
0743        pvpub) source pvcap.sh env  ;;
0744        mppub) source mpcap.sh env  ;;
0745     esac
0746     if [ "$arg" == "pvpub" -o "$arg" == "mppub" ]; then
0747         source epub.sh
0748     fi
0749 fi
0750