Back to home page

EIC code displayed by LXR

 
 

    


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

0001 ##
0002 ## Copyright (c) 2019 Opticks Team. All Rights Reserved.
0003 ##
0004 ## This file is part of Opticks
0005 ## (see https://bitbucket.org/simoncblyth/opticks).
0006 ##
0007 ## Licensed under the Apache License, Version 2.0 (the "License"); 
0008 ## you may not use this file except in compliance with the License.  
0009 ## You may obtain a copy of the License at
0010 ##
0011 ##   http://www.apache.org/licenses/LICENSE-2.0
0012 ##
0013 ## Unless required by applicable law or agreed to in writing, software 
0014 ## distributed under the License is distributed on an "AS IS" BASIS, 
0015 ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  
0016 ## See the License for the specific language governing permissions and 
0017 ## limitations under the License.
0018 ##
0019 
0020 geocache-source(){ echo $BASH_SOURCE ; }
0021 geocache-vi(){ vi $(geocache-source) ; geocache- ; }
0022 geocache-sdir(){ echo $(dirname $(geocache-source)) ; }
0023 geocache-scd(){  cd $(geocache-dir) ; }
0024 geocache-usage(){ cat << EOU
0025 
0026 
0027 Geocache : THIS IS NOT PART OF THE NEW WORKFLOW
0028 ==================================================
0029 
0030 
0031 Directories
0032 -------------
0033 
0034 laptop::
0035 
0036 
0037     epsilon:boostrap blyth$ opticks-geocachedir
0038     /Users/blyth/.opticks/geocache
0039 
0040     opticks-geocachedir () 
0041     { 
0042         echo $(opticks-geocache-prefix)/geocache
0043     }
0044 
0045     opticks-geocache-prefix () 
0046     { 
0047         echo ${OPTICKS_GEOCACHE_PREFIX:-$(opticks-sharedcache-prefix-default)}
0048     }
0049 
0050     epsilon:boostrap blyth$ echo ${OPTICKS_GEOCACHE_PREFIX}
0051 
0052     opticks-sharedcache-prefix-default () 
0053     { 
0054         echo $HOME/.opticks
0055     }
0056 
0057 
0058 Used to be:
0059 
0060     /usr/local/opticks/geocache
0061 
0062 
0063 
0064 Screen Capture Movies 
0065 --------------------------
0066 
0067 Avoiding White Flicker in movies
0068 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0069 
0070 * make sure all executable logging (including obs) is 
0071   redirected to file, otherwise get white line flicker in the screen captures 
0072 
0073 Window placement tip
0074 ~~~~~~~~~~~~~~~~~~~~~
0075 
0076 * position the obs window with "start recording" button 
0077   to the right of the bottom right of the viz window, so 
0078   initial near scanning can work more smoothing  
0079 
0080 Script
0081 ~~~~~~~~~~
0082 
0083 1. obs-;obs-run
0084 2. generate flightpath with ana/mm0prim2.py  
0085 3. before starting the recording  
0086 
0087    a) run the viz geocache-;geocache-movie leaving window in orginal position, so screen recording gets it all 
0088    b) press O (wait) then O again # switch to composite raytrace render, then back to normal rasterized  
0089    c) make sure nothing obscuring the viz window 
0090    d) press alt-Y and adjust standard view 
0091 
0092 4. starting recording 
0093 
0094    a) make sure obs "Start Recording" button is visible, and cursor is nearby
0095    b) press U : start the flightpath interpolated view
0096    c) press "Start Recording" in obs interface
0097   
0098 4. during the recording : things to do 
0099 
0100    a) press Q, to switch off global a few times
0101    b) press X, and drag up/down to show the view along some parallel paths
0102       while doing this press O to switch to raytrace 
0103    c) press D, for orthographic view
0104    d) when photons are visible : press G and show the history selection 
0105    e) press . to stop event and geometry animations, take a look around, 
0106       press H to return to home for resumption of animation
0107 
0108 5. ending the recording
0109 
0110    a) pick a good area to end with, eg chimney region
0111 
0112 
0113 
0114 Choreography : 2018-10-29_13-24-36  ~6 min
0115 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0116 
0117 Movie is good enough if dont have time 
0118 to try and record a better one.::
0119 
0120     epsilon:Movies blyth$ du -h 2018-10-29_13-24-36.mp4
0121     212M        2018-10-29_13-24-36.mp4
0122 
0123 What can be improved:
0124 
0125 * a few minutes shorter would be good
0126 * forgot to use Q to switch off global during the flight, 
0127   this would have been particularly useful when R:rotating 
0128   view to look at PMTs 
0129 
0130 
0131 ::
0132 
0133     O: raytrace "eye" 1st frame
0134 
0135     [START RECORDING]
0136 
0137     click bottom right frame
0138 
0139     N: perspective near scan in/out
0140     D: ortho near scan in/out -> back to "eye"
0141     O: rasterized ortho, near scan in/out -> back to "eye"
0142     D: rasterized perspective, near scan in/out with raytrace flips 
0143 
0144     U: start flight 
0145     P: photon style
0146 
0147     .: pause when reach chimney region
0148     N: adjust near
0149     X: pan up with O flips to see chimney and TT
0150     H: home (back to flightpath)
0151     .: resume flight  
0152 
0153     on way down, X: out to see pool PMTs
0154     H: home (back to flightpath)
0155 
0156     on way up, D: ortho flip and back to see photons
0157 
0158     .: pause again when reach chimney region
0159     R: rotate and look up at PMTs,  N:scanning 
0160     H: home to flightpath 
0161     .:  resume
0162     .: pause once back outside
0163     D:ortho O:raytrace N:near scan to half G:photon select 
0164 
0165 
0166 Issues 
0167 --------
0168 
0169 FIXED : awkward raytrace composite requiring hiding of rasterized geometry
0170 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0171 
0172 Formerly O was a 3 way: raster/raytrace/composite
0173 composite is good to showing photons together with raytrace geometry :
0174 but that requires to switch off rasterized geometry
0175 
0176 Fixed the awkwardness by making it a 2-way raster/composite and 
0177 always switching off rasterized geometry within composite mode
0178 
0179 
0180 
0181 EOU
0182 }
0183 
0184 geocache-env(){ echo -n ; }
0185 
0186 geocache-paths(){  echo $IDPATH/$1 $IDPATH2/$1 ; }
0187 geocache-diff-(){  printf "\n======== $1 \n\n" ; diff -y $(geocache-paths $1) ; }
0188 geocache-diff()
0189 {
0190    export IDPATH2=/usr/local/opticks-cmake-overhaul/geocache/CX4GDMLTest_World0xc15cfc0_PV_g4live/g4ok_gltf/828722902b5e94dab05ac248329ffebe/1
0191    geocache-diff- GItemList/GMaterialLib.txt 
0192    geocache-diff- GItemList/GSurfaceLib.txt 
0193    geocache-diff- GNodeLib/PVNames.txt
0194    geocache-diff- GNodeLib/LVNames.txt
0195 }
0196 
0197 
0198 geocache-paths-pv(){ geocache-paths GNodeLib/PVNames.txt ; }
0199 geocache-diff-pv(){ geocache-diff- GNodeLib/PVNames.txt ; }
0200 geocache-diff-lv(){ geocache-diff- GNodeLib/LVNames.txt ; }
0201 
0202 geocache-py()
0203 {
0204    geocache-scd
0205    ipython -i geocache.py 
0206 }
0207 
0208 geocache-info(){ cat << EOI
0209 $FUNCNAME
0210 ===============
0211 
0212   IDPATH  : $IDPATH
0213   IDPATH2 : $IDPATH2
0214        dependency on IDPATH on way out 
0215 
0216   (input)   OPTICKS_KEY        :  ${OPTICKS_KEY}
0217   (derived) OPTICKS_KEYDIR     :  ${OPTICKS_KEYDIR}    
0218 
0219   geocache-keydir    : $(geocache-keydir)
0220   geocache-keyfunc   : $(geocache-keyfunc)
0221   geocache-keydir-py : $(geocache-keydir-py)
0222       above two directories should match 
0223 
0224   geocache-tstdir    : $(geocache-tstdir)
0225       directory derived from the OPTICKS_KEY envvar 
0226 
0227   geocache-dir       : $(geocache-dir) 
0228      formerly placed in install location $LOCAL_BASE/opticks/geocache 
0229 
0230 
0231 
0232 
0233   (default)  opticks-sharedcache-prefix-default : $(opticks-sharedcache-prefix-default) 
0234   (override) OPTICKS_GEOCACHE_PREFIX            : $OPTICKS_GEOCACHE_PREFIX   
0235   (result)   opticks-geocache-prefix            : $(opticks-geocache-prefix) 
0236 
0237   (result)   opticks-geocachedir                : $(opticks-geocachedir)
0238   
0239 
0240    
0241  
0242 
0243 
0244 
0245 
0246 EOI
0247 
0248   geocache-keydir-test 
0249 }
0250 
0251 geocache-keydir-test()
0252 {
0253    local a=$(geocache-keydir)
0254    local b=$(geocache-keydir-py)
0255    [ "$a" != "$b" ] && echo $msg MISMATCH $a $b && sleep 1000000000000
0256 }
0257 geocache-keyfunc(){ echo ${OPTICKS_KEYFUNC:-geocache_keyfunc_default} ; }
0258 
0259 geocache-keydir-()
0260 {
0261     local var=${1:-OPTICKS_KEY}
0262     local k=${!var}
0263     local arr=(${k//./ })
0264     [ "${#arr[@]}" != "4" ] && echo $msg expecting OPTICKS_KEY envvar with four fields separate by dot && sleep 100000
0265     local exe=${arr[0]}
0266     local cls=${arr[1]}
0267     local top=${arr[2]}
0268     local dig=${arr[3]}
0269     echo ${exe}_${top}_g4live/g4ok_gltf/$dig/1 
0270 }
0271 
0272 geocache-keydir(){        echo $(geocache-dir)/$(geocache-keydir-) ; }
0273 geocache-keydir-shared(){ echo $(geocache-dir-shared)/$(geocache-keydir-) ; }
0274 
0275 geocache-dir-shared(){ echo /cvmfs/opticks.ihep.ac.cn/ok/shared/geocache ; }
0276 
0277 geocache-keydir-copy-to-shared(){
0278     local src=$(geocache-keydir)
0279     local dst=$(geocache-keydir-shared)
0280 
0281     [ ! -d "$src" ] && echo $msg src $src does not exist && return 1 
0282     [ -d "$dst" ] && echo $msg dst $dst exists already && return 1
0283 
0284     mkdir -p $(dirname $dst)
0285     echo cp -r $src $(dirname $dst)/ 
0286 }
0287 
0288 
0289 
0290 
0291 
0292 geocache-keydir-py(){ key.py ; }
0293 
0294 
0295 geocache-dir(){ echo $(opticks-geocachedir) ; }
0296 geocache-cd(){ cd $(geocache-dir) ; }
0297 geocache-tstdir(){ echo $(geocache-keydir)/g4codegen/tests ; }
0298 geocache-kcd(){ 
0299    local msg="=== $FUNCNAME :"
0300    local rel=$1
0301 
0302    if [ -z "$OPTICKS_KEY" ] ; then 
0303       echo $msg OPTICKS_KEY is not defined  
0304    else
0305       echo $msg OPTICKS_KEY $OPTICKS_KEY 
0306       local keydir=$(geocache-keydir)
0307       if [ -d "$keydir" ]; then  
0308           cd $keydir
0309           pwd 
0310           cat runcomment.txt 
0311           if [ -d "$rel" ]; then 
0312               cd $rel 
0313               pwd
0314           else
0315               echo $msg rel $rel does not exist in keydir $keydir
0316           fi 
0317       else
0318           echo $msg keydir $keydir does not exist
0319       fi 
0320    fi 
0321 
0322  }
0323 geocache-tcd(){ cd $(geocache-tstdir) ; pwd ; }
0324 
0325 geocache-tmp(){ echo /tmp/$USER/opticks/$1 ; }  
0326 
0327 
0328 geocache-create-()
0329 {
0330     local msg="=== $FUNCNAME :"
0331     local iwd=$PWD
0332     local tmp=$(geocache-tmp $FUNCNAME)
0333     mkdir -p $tmp && cd $tmp
0334          
0335     #$(opticks-prefix)/bin/o.sh --okx4test --g4codegen --deletegeocache $*
0336 
0337     if [ -n "$DEBUG" ]; then 
0338        lldb__ OKX4Test  --deletegeocache $* 
0339     else
0340         OKX4Test --deletegeocache $* 
0341     fi 
0342 
0343     echo $msg logs are in tmp:$tmp
0344     cd $iwd
0345 }
0346 
0347 geocache-sh-notes(){ cat << EON
0348 geocache-sh-notes
0349 ===================
0350 
0351 The OKX4Test executable that is invoked by geocache-create- writes the geocacheScript 
0352 using Opticks::writeGeocacheScript
0353 
0354 
0355 EON
0356 }
0357 
0358 geocache-sh-path(){ 
0359     local opticks_geocache_prefix=~/.opticks 
0360     echo ${OPTICKS_GEOCACHE_PREFIX:-$opticks_geocache_prefix}/geocache/geocache.sh 
0361 }
0362 
0363 geocache-sh-cat(){
0364     local geocache_sh=$(geocache-sh-path)
0365     cat $geocache_sh 
0366 } 
0367 
0368 geocache-sh()
0369 {
0370     local msg="=== $FUNCNAME :"
0371     local geocache_sh=$(geocache-sh-path)
0372 
0373     if [ -f "$geocache_sh" ]; then
0374         echo $msg geocache_sh $geocache_sh : sourcing  
0375         source $geocache_sh 
0376     else
0377         echo $msg geocache_sh $geocache_sh : does not exist 
0378     fi 
0379 
0380 }
0381 
0382 
0383 
0384 geocache-create-notes(){ cat << EON
0385 $FUNCNAME
0386 ----------------------
0387 
0388 This parses the gdml, creates geocache, pops up OpenGL gui, 
0389 
0390 EON
0391 }
0392 
0393 
0394 # comment 5 constant property that fail to parse 
0395 
0396 #geocache-gdml-constant-fix(){ perl -pi -e 's,^\s*(<constant.*/>),<!-- $1  -->,g' $1 ; }
0397 geocache-gdml-kludge(){        perl -pi -e 's,^(\s*<property name="(\S*)" ref="\2"/>),<!-- $1  -->,g' $1 ; }
0398 geocache-gdml-kludge-dump(){   perl -n -e 'm,<property name="(\S*)" ref="\1"/>, && print ' $1 ; }  ## dump property with same @name @ref 
0399 geocache-gdml-kludge-notes(){ cat << EON
0400 
0401 Five props with name and ref the same, causing parse problem::
0402 
0403       <property name="SCINTILLATIONYIELD" ref="SCINTILLATIONYIELD"/>
0404       <property name="RESOLUTIONSCALE" ref="RESOLUTIONSCALE"/>
0405       <property name="FASTTIMECONSTANT" ref="FASTTIMECONSTANT"/>
0406       <property name="SLOWTIMECONSTANT" ref="SLOWTIMECONSTANT"/>
0407       <property name="YIELDRATIO" ref="YIELDRATIO"/>
0408 
0409 In opticks/examples/UseXercesC/GDMLKludgeFixMatrixTruncation.cc fix truncations 
0410 and convert the constant that the above fail to reference into matrix.
0411 
0412 EON
0413 }
0414 
0415 
0416 
0417 
0418 geocache-dbg-key(){ echo OKX4Test.X4PhysicalVolume.lWorld0x61ee3b0_PV.d462ec558d40795c0ba134102c68a8b4 ; }
0419 geocache-dbg-gdmlpath(){ echo $HOME/origin2_GDMLKludgeFix.gdml ; }
0420 geocache-dbg(){
0421     local msg="=== $FUNCNAME :"
0422     local path=$(geocache-dbg-gdmlpath)
0423     GInstancer=INFO geocache-create- --gdmlpath $path -D --noviz $*
0424 }
0425 
0426 
0427 geocache-apr23-key(){ echo OKX4Test.X4PhysicalVolume.lWorld0x33e33d0_PV.e33b2270395532f5661fde4c61889844 ;  }
0428 geocache-apr23-gdmlpath(){ echo $HOME/apr23_origin_CGDMLKludge.gdml ; }
0429 geocache-apr23(){
0430     local msg="=== $FUNCNAME :"
0431     local path=$(geocache-apr23-gdmlpath)
0432     
0433     local skipsolidname="NNVTMCPPMTsMask_virtual,HamamatsuR12860sMask_virtual,mask_PMT_20inch_vetosMask_virtual"
0434     local csgskiplv="103,109,126"
0435     GTree=INFO OpticksDbg=INFO GInstancer=INFO geocache-create- --gdmlpath $path -D --noviz  --csgskiplv $csgskiplv $*  
0436     #--skipsolidname $skipsolidname $*
0437 }
0438 
0439 
0440 
0441 geocache-29aug2021-key(){ echo OKX4Test.X4PhysicalVolume.lWorld0x5fcd000_PV.04c9a88e50ace00f570fd33b404f181e ; }
0442 geocache-29aug2021-gdmlpath(){ echo $(opticks-prefix)/origin_CGDMLKludge_29aug2021.gdml ; }
0443 geocache-29aug2021(){
0444     local path=$(geocache-29aug2021-gdmlpath)
0445     # skips from current jvi:tds-skipsolidname 
0446     local skipsolidname="mask_PMT_20inch_vetosMask_virtual,NNVTMCPPMT_body_solid,HamamatsuR12860_body_solid_1_9,PMT_20inch_veto_body_solid_1_2"
0447     GScintillatorLib=INFO GPropertyLib=INFO geocache-create- --gdmlpath $path -D --noviz  --skipsolidname $skipsolidname $*  
0448 }
0449 geocache-29aug2021-notes(){ cat << EON
0450 
0451 Using skipsolidname is more future safe than using indices. 
0452 
0453 O[blyth@localhost GItemList]$ cat.py GMeshLib.txt -s 103,109,126
0454 103  104  NNVTMCPPMTsMask_virtual
0455 109  110  HamamatsuR12860sMask_virtual
0456 126  127  mask_PMT_20inch_vetosMask_virtual
0457 
0458 EON
0459 }
0460 
0461 
0462 
0463 geocache-11dec2021-gdmlpath(){ echo $(opticks-prefix)/origin_CGDMLKludge_11dec2021.gdml ; }
0464 geocache-11dec2021(){  geocache-create- --gdmlpath $(geocache-11dec2021-gdmlpath) -D --noviz  ; }
0465 
0466 geocache-12dec2021-key(){ echo OKX4Test.X4PhysicalVolume.lWorld0x574e7f0_PV.f65f5cd1a197e3a0c9fe55975ff2c7a7 ; }
0467 geocache-12dec2021-gdmlpath(){ echo $(opticks-prefix)/origin_CGDMLKludge_12dec2021.gdml ; }
0468 geocache-12dec2021(){  geocache-create- --gdmlpath $(geocache-12dec2021-gdmlpath) -D --noviz  ; }
0469 
0470 geocache-02mar2022-key(){ echo OKX4Test.X4PhysicalVolume.lWorld0x5780b30_PV.5303cd587554cb16682990189831ae83 ; }
0471 geocache-02mar2022-gdmlpath(){ echo $(opticks-prefix)/origin_CGDMLKludge_02mar2022.gdml ; }
0472 geocache-02mar2022(){  geocache-create- --gdmlpath $(geocache-02mar2022-gdmlpath) -D --noviz  ; }
0473 
0474 
0475 geocache-02mar2022-dbg(){
0476    export X4PhysicalVolume=INFO
0477    geocache-02mar2022
0478 }
0479 
0480 
0481 
0482 geocache-gdml-scp(){ 
0483    #local digest=${1:-fe48b4d359786b95505117280fb5aac1}
0484    #local label=${2:-jun28}
0485 
0486    #local digest=${1:-50859f8d4163ea73814016bc7008ec4d}
0487    #local label=${2:-29aug2021} 
0488 
0489    #local digest=${1:-3dbec4dc3bdef47884fe48af781a179d}
0490    #local label=${2:-30oct2021}
0491 
0492    local digest=${1:-1ad3e6c8947a2b32dea175bc67816952}
0493    local label=${2:-02mar2022}
0494 
0495    local cmd="scp P:.opticks/geocache/DetSim0Svc_pWorld_g4live/g4ok_gltf/$digest/1/origin_CGDMLKludge.gdml  $(opticks-prefix)/origin_CGDMLKludge_$label.gdml"
0496    echo $cmd
0497    eval $cmd
0498 }
0499 
0500 geocache-jun28-key(){ echo OKX4Test.X4PhysicalVolume.lWorld0x32a9d10_PV.5be60660c4368a7f59ce05cc3aa827df ; }
0501 geocache-jun28-gdmlpath(){ echo $(opticks-prefix)/origin_CGDMLKludge_jun28.gdml ; }
0502 geocache-jun28(){
0503     local msg="=== $FUNCNAME :"
0504     local path=$(geocache-jun28-gdmlpath)
0505     # get skips from current tds3
0506     local skipsolidname="mask_PMT_20inch_vetosMask_virtual,NNVTMCPPMT_body_solid,HamamatsuR12860_body_solid_1_9,PMT_20inch_veto_body_solid_1_2"
0507     #GTree=INFO OpticksDbg=INFO GInstancer=INFO 
0508     #GScintillatorLib=INFO GPropertyLib=INFO 
0509     geocache-create- --gdmlpath $path -D --noviz  --skipsolidname $skipsolidname $*  
0510 }
0511 
0512 
0513 geocache-jun15-key(){ echo OKX4Test.X4PhysicalVolume.lWorld0x32a96e0_PV.a3cbac8189a032341f76682cdb4f47b6 ; }
0514 geocache-jun15-gdmlpath(){ echo /usr/local/opticks/origin_CGDMLKludge_jun15.gdml ; }
0515 geocache-jun15(){
0516     local msg="=== $FUNCNAME :"
0517     local path=$(geocache-jun15-gdmlpath)
0518     
0519     local skipsolidname="NNVTMCPPMTsMask_virtual,HamamatsuR12860sMask_virtual,mask_PMT_20inch_vetosMask_virtual"
0520     local csgskiplv="103,109,126"
0521     GTree=INFO OpticksDbg=INFO GInstancer=INFO geocache-create- --gdmlpath $path -D --noviz  --csgskiplv $csgskiplv $*  
0522     #--skipsolidname $skipsolidname $*
0523 }
0524 
0525 
0526 
0527 
0528 
0529 geocache-tds-gdmlpath()
0530 {
0531    #local label=tds
0532    #local label=tds_ngt_pcnk
0533    local label=tds_ngt_pcnk_sycg
0534    local gdml=$(opticks-prefix)/$label.gdml
0535    echo $gdml
0536 }
0537 
0538 geocache-tds(){     
0539     local msg="=== $FUNCNAME :"
0540 
0541     #export GMaterialLib=INFO
0542     #export GSurfaceLib=INFO
0543     #export X4Solid=INFO
0544     #export X4PhysicalVolume=INFO
0545     #export GMesh=INFO
0546     #export OGeo=INFO
0547     export GGeo=INFO
0548 
0549     local gdml=$(geocache-tds-gdmlpath)
0550     echo $msg gdml $gdml
0551     geocache-gdml-kludge      $gdml
0552     geocache-gdml-kludge-dump $gdml
0553 
0554     geocache-create- --gdmlpath $gdml -D $*
0555 
0556 } 
0557 
0558 geocache-g4ok(){
0559     local msg="=== $FUNCNAME :"
0560     export GGeo=INFO
0561 
0562     local gdml=$(geocache-tds-gdmlpath)
0563     echo $msg gdml $gdml
0564 
0565     geocache-gdml-kludge      $gdml
0566     geocache-gdml-kludge-dump $gdml
0567 
0568     local iwd=$PWD
0569     local tmp=$(geocache-tmp $FUNCNAME)
0570     mkdir -p $tmp && cd $tmp
0571          
0572     $(opticks-prefix)/bin/o.sh --g4oktest --g4codegen --deletegeocache --gdmlpath $gdml -D $*
0573 
0574     cd $iwd
0575 }
0576  
0577 
0578 geocache-j1808-todo(){ cat << EOT
0579 
0580    opticksdata- needs to be replaced with opticksaux-
0581 
0582 EOT
0583 }
0584 
0585 
0586 ## opticksdata- is no longer in use ...
0587 
0588 
0589 geocache-j1808(){     opticksdata- ; geocache-create- --gdmlpath $(opticksdata-j)  --X4 debug --NPY debug $*  ; }
0590 geocache-j1808-v2(){  opticksdata- ; geocache-create- --gdmlpath $(opticksdata-jv2) --csgskiplv 22  ; }
0591 geocache-j1808-v3(){  opticksdata- ; geocache-create- --gdmlpath $(opticksdata-jv3) --csgskiplv 22  ; }
0592 geocache-j1808-v3(){  opticksdata- ; geocache-create- --gdmlpath $(opticksdata-jv3) --csgskiplv 22  ; }
0593 geocache-j1808-v4-(){ opticksdata- ; geocache-create- --gdmlpath $(opticksdata-jv4) $* ; }
0594 geocache-j1808-v5-(){ opticksdata- ; geocache-create- --gdmlpath $(opticksdata-jv5) $* ; }
0595 
0596 geocache-j1808-v6-(){ opticksdata- ; geocache-create- --gdmlpath $(opticksdata-jv5) --digestextra v6  $* ; }   
0597 geocache-j1808-vt-(){ opticksdata- ; geocache-create- --gdmlpath $(opticksdata-jv5) --digestextra vt  $* ; }   
0598 
0599 
0600 geocache-j1808-v4-comment(){ echo torus-less-skipping-just-lv-22-maskVirtual ; }
0601 geocache-j1808-v4-key(){     echo OKX4Test.X4PhysicalVolume.lWorld0x4bc2710_PV.f6cc352e44243f8fa536ab483ad390ce ; }
0602 geocache-j1808-v4-export(){  geocache-export ${FUNCNAME/-export} ; }
0603 geocache-j1808-v4(){  geocache-j1808-v4- --csgskiplv 22 --runfolder $FUNCNAME --runcomment $(${FUNCNAME}-comment) $* ; }  
0604 
0605 geocache-j1808-v4-t1-comment(){ echo leave-just-21-see-notes/issues/review-analytic-geometry.rst ; }
0606 geocache-j1808-v4-t1-key(){     echo OKX4Test.X4PhysicalVolume.lWorld0x4bc2710_PV.5cc3de75a98f405a4e483bad34be348f ; }
0607 geocache-j1808-v4-t1-export(){  geocache-export ${FUNCNAME/-export} ; }
0608 geocache-j1808-v4-t1(){ geocache-j1808-v4- --csgskiplv 22,17,20,18,19 --runfolder $FUNCNAME --runcomment $(${FUNCNAME}-comment) $* ; }
0609 
0610 geocache-j1808-v4-t2-comment(){ echo skip-22-virtualMask+20-almost-degenerate-inner-pyrex-see-notes/issues/review-analytic-geometry.rst ; }
0611 geocache-j1808-v4-t2-key(){     echo OKX4Test.X4PhysicalVolume.lWorld0x4bc2710_PV.781dc285412368f18465809232634d52 ; }
0612 geocache-j1808-v4-t2-export(){  geocache-export ${FUNCNAME/-export} ; }
0613 geocache-j1808-v4-t2(){ geocache-j1808-v4- --csgskiplv 22,20 --runfolder $FUNCNAME --runcomment $(${FUNCNAME}-comment) $* ; }
0614 
0615 geocache-j1808-v4-t3-comment(){ echo skip-22-virtualMask+17-mask+20-almost-degenerate-inner-pyrex-see-notes/issues/review-analytic-geometry.rst ; }
0616 geocache-j1808-v4-t3-key(){     echo OKX4Test.X4PhysicalVolume.lWorld0x4bc2710_PV.52e273e4ad5423fe2fc8aa44bbf055ec ; }
0617 geocache-j1808-v4-t3-export(){  geocache-export ${FUNCNAME/-export} ; }
0618 geocache-j1808-v4-t3(){ geocache-j1808-v4- --csgskiplv 22,17,20 --runfolder $FUNCNAME --runcomment $(${FUNCNAME}-comment) $*  ; }
0619 
0620 geocache-j1808-v4-t4-comment(){ echo skip-22-virtualMask+17-mask+20-almost-degenerate-inner-pyrex+19-remainder-vacuum-see-notes/issues/review-analytic-geometry.rst ; }
0621 geocache-j1808-v4-t4-key(){     echo OKX4Test.X4PhysicalVolume.lWorld0x4bc2710_PV.078714e5894f31953fc9afce731c77f3 ; }
0622 geocache-j1808-v4-t4-export(){  geocache-export ${FUNCNAME/-export} ; }
0623 geocache-j1808-v4-t4(){ geocache-j1808-v4- --csgskiplv 22,17,20,19 --runfolder $FUNCNAME --runcomment $(${FUNCNAME}-comment) $* ; }
0624 
0625 geocache-j1808-v4-t5-comment(){ echo just-18-hemi-ellipsoid-cathode-cap-see-notes/issues/review-analytic-geometry.rst ; }
0626 geocache-j1808-v4-t5-key(){     echo OKX4Test.X4PhysicalVolume.lWorld0x4bc2710_PV.732c52dd2f92338b4c570163ede44230 ; }
0627 geocache-j1808-v4-t5-export(){  geocache-export ${FUNCNAME/-export} ; }
0628 geocache-j1808-v4-t5(){ geocache-j1808-v4- --csgskiplv 22,17,21,20,19 --runfolder $FUNCNAME --runcomment $(${FUNCNAME}-comment) $* ; }
0629 
0630 geocache-j1808-v4-t6-comment(){ echo just-19-vacuum-remainder-see-notes/issues/review-analytic-geometry.rst ; }
0631 geocache-j1808-v4-t6-key(){     echo OKX4Test.X4PhysicalVolume.lWorld0x4bc2710_PV.d4157cb873000b4e19f77654134c3196 ; }
0632 geocache-j1808-v4-t6-export(){  geocache-export ${FUNCNAME/-export} ; }
0633 geocache-j1808-v4-t6(){ geocache-j1808-v4- --csgskiplv 22,17,21,20,18 --runfolder $FUNCNAME --runcomment $(${FUNCNAME}-comment) $* ; }
0634 
0635 geocache-j1808-v4-t7-comment(){ echo just-18-19-vacuum-cap-and-remainder-see-notes/issues/review-analytic-geometry.rst ; }
0636 geocache-j1808-v4-t7-key(){     echo OKX4Test.X4PhysicalVolume.lWorld0x4bc2710_PV.e13cbdbe8782ca4ca000b735f0c4d61a ; }
0637 geocache-j1808-v4-t7-export(){  geocache-export ${FUNCNAME/-export} ; }
0638 geocache-j1808-v4-t7(){ geocache-j1808-v4- --csgskiplv 22,17,21,20 --runfolder $FUNCNAME --runcomment $(${FUNCNAME}-comment) $* ; }
0639 
0640 geocache-j1808-v4-t8-comment(){ echo just-21-18-19-outer-pyrex+vacuum-cap-and-remainder-see-notes/issues/review-analytic-geometry.rst ; }
0641 geocache-j1808-v4-t8-key(){     echo OKX4Test.X4PhysicalVolume.lWorld0x4bc2710_PV.52e273e4ad5423fe2fc8aa44bbf055ec ; }       ## NB this matches geocache-j1808-v4-t3
0642 geocache-j1808-v4-t8-export(){  geocache-export ${FUNCNAME/-export} ; }
0643 geocache-j1808-v4-t8(){ geocache-j1808-v4- --csgskiplv 22,17,20 --runfolder $FUNCNAME --runcomment $(${FUNCNAME}-comment) ; }
0644 
0645 geocache-j1808-v4-notes(){ cat << EON
0646 
0647 $FUNCNAME : varying the volumes of the 20-inch PMT
0648 ==================================================================
0649 
0650 The above geocache-j1808-v4-.. functions use the v4 (torus-less) JUNO j1808 GDML geometry
0651 using OKX4Test to directly create the geocache from the GDML.
0652 The t1,t2 etc functions vary the volumes of the 20inch PMT by using different csgskiplv, 
0653 allowing benchmark checks of RTX mode on TITAN V and TITAN RTX with different geometry.  
0654 
0655 NB geo digests still not trusted here, so that means rerun geocache conversions 
0656 
0657 
0658 ======================    ====================  ===============   ============================================================ 
0659  func                       --csgskiplv           leaving 
0660 ======================    ====================  ===============   ============================================================ 
0661 geocache-j1808-v4           22                                      full 5 volumes   
0662 geocache-j1808-v4-t1        22,17,20,18,19         21               outer pyrex
0663 geocache-j1808-v4-t2        22,20                  17,21,18,19      acrylic mask + outer pyrex + vacuum cap + remainder  
0664 geocache-j1808-v4-t3        22,17,20               21,18,19         outer pyrex + cathode cap + remainder 
0665 geocache-j1808-v4-t4        22,17,20,19            21,18            outer pyrex + cathode cap
0666 geocache-j1808-v4-t5        22,17,21,20,19         18               just-18-hemi-ellipsoid-cathode-cap
0667 geocache-j1808-v4-t6        22,17,21,20,18         19               just-19-vacuum-remainder
0668 geocache-j1808-v4-t7        22,17,21,20            18,19            just-18-19-vacuum-cap-and-remainder 
0669 geocache-j1808-v4-t8        22,17,20               21,18,19         just-21-18-19-outer-pyrex+vacuum-cap-and-remainder
0670 ======================    ====================  ===============   ============================================================ 
0671 
0672 
0673 GNodeLib/PVNames.txt 1-based index from vim, first 20inch::
0674 
0675      63555 lFasteners_phys0x4c31eb0
0676 
0677      63556 lMaskVirtual_phys0x4c9a510          22      csgskipped
0678      63557 pMask0x4c3bf20                      17 *   7 parts : difference of two ellipsoid cylinder unions 
0679 
0680      63558 PMT_20inch_log_phys0x4ca16b0        21 *   7 parts : union of el+co+cy  (5 parts, but seven as complete tree)
0681      63559 PMT_20inch_body_phys0x4c9a7f0       20 *   7 parts : union of el+co+cy  (ditto)
0682                  
0683      63560 PMT_20inch_inner1_phys0x4c9a870     18 *   1 part  : el                               cathode vacuum cap
0684      63561 PMT_20inch_inner2_phys0x4c9a920     19 *   7 parts : union of el+co+cy  (ditto)       remainder vacuum 
0685                                                    -----------------------------------
0686                                                       29 parts 
0687                                                    ------------------------------------
0688 
0689 geocache-j1808-v4-t8
0690      for a while used this t8 geometry to put back a bug : --dbg_with_hemi_ellipsoid_bug 
0691      in order see its performance impact
0692 
0693 
0694 The export functions setup the OPTICKS_KEY envvar in order to use the geometry. 
0695 To switch geometry edit the below geocache-bashrc-export function and start a new shell
0696 by opening a tab. 
0697 
0698 See:
0699 
0700     notes/issues/review-analytic-geometry.rst 
0701     notes/issues/benchmarks.rst 
0702 
0703 EON
0704 }
0705 
0706 
0707 
0708 geocache-j1808-v5-comment(){ echo fix-lv10-coincidence-speckle ; }
0709 geocache-j1808-v5-key(){     
0710    case $(uname) in 
0711        Linux)  echo OKX4Test.X4PhysicalVolume.lWorld0x4bc2710_PV.f6cc352e44243f8fa536ab483ad390ce  ;;
0712        Darwin) echo OKX4Test.X4PhysicalVolume.lWorld0x4bc2710_PV.a717fae122a5eda2027f6cec1d4a3f67  ;;
0713    esac 
0714 }
0715 geocache-j1808-v5-export(){  geocache-export ${FUNCNAME/-export} ; }
0716 geocache-j1808-v5(){  geocache-j1808-v5- --csgskiplv 22 --runfolder $FUNCNAME --runcomment $(${FUNCNAME}-comment) $* ; }  
0717 
0718 
0719 geocache-j1808-v6-key(){ echo OKX4Test.X4PhysicalVolume.lWorld0x4bc2710_PV.41b09364643f9479b9ab4f31451ce538 ; }
0720 geocache-j1808-v6-comment(){ echo same-gdml-as-v5-but-fixes-lack-of-SD-with-isSensor-based-on-surface-EFFICIENCY ; }
0721 geocache-j1808-v6(){  geocache-j1808-v6- --csgskiplv 22 --runfolder $FUNCNAME --runcomment $(${FUNCNAME}-comment) $* ; }  
0722 geocache-j1808-v6-notes(){ cat << EON
0723 
0724 v6 uses same gdml as v5, but 
0725 
0726 1. initally changed conversion arguments such as adding --lvsdname inch_inner1_log
0727    but this old world approach is not appropriate when GDML is succeeding to persist surface props
0728 
0729 2. instead changed to base GPropertyMap::isSensor on the existance of an EFFICIENCY property, this
0730    avoids the need to add kludge SensorSurfaces : regaining SD 
0731 
0732 See notes/issues/missing-SD-again.rst
0733 
0734 EON
0735 }
0736 
0737 
0738 
0739 geocache-j1808-vt-key(){ echo -n ; }
0740 geocache-j1808-vt-comment(){ echo for-technical-tests-of-geocache-creation-with-no-expectation-of-longevity ; }
0741 geocache-j1808-vt(){  X4PhysicalVolume=FATAL geocache-j1808-vt- --csgskiplv 22 --runfolder $FUNCNAME --runcomment $(${FUNCNAME}-comment) $* ; }  
0742 geocache-j1808-vt-notes(){ cat << EON
0743 
0744 vt uses same gdml as v6,v5, but its intended to be used for tests of geocache conversion after code changes, 
0745 eg the restriction on balanced solids exports
0746 
0747 See notes/issues/investigate-sams-x375-a-solid-that-breaks-balancing.rst
0748 
0749 EON
0750 }
0751 
0752 
0753 
0754 geocache-fan-gdmlpath(){ echo /Users/blyth/Documents/fan_hu.gdml ; }
0755 geocache-fan-comment(){ echo testing a user geometry for oceanic neutrino telescope ; }
0756 geocache-fan-(){ geocache-create- --gdmlpath $(geocache-fan-gdmlpath) --geocenter --noviz $* ; }
0757 geocache-fan(){ geocache-fan- --runfolder $FUNCNAME --runcomment $(${FUNCNAME}-comment) $* ; }
0758 
0759 
0760 
0761 
0762 geocache-dx0-notes(){ cat << EON
0763 
0764 --x4polyskip 211,232
0765      to avoid ~infinite loops in G4SubtractionSolid::CreatePolyhedron called from X4Mesh::polygonize
0766 
0767 EON
0768 }
0769 
0770 
0771 geocache-dx0-(){  opticksaux- ; geocache-create- --gdmlpath $(opticksaux-dx0) --x4polyskip 211,232  --geocenter --noviz $* ; }     
0772 geocache-dx0-comment(){ echo export-dyb-gdml-from-g4-10-4-2-to-support-geocache-creation.rst ; }     
0773 geocache-dx0(){   geocache-dx0- --runfolder $FUNCNAME --runcomment $(${FUNCNAME}-comment) $* ; } 
0774 geocache-dx0-key(){ 
0775    case $(uname) in 
0776       Linux)  echo OKX4Test.X4PhysicalVolume.World0xc15cfc00x40f7000_PV.5aa828335373870398bf4f738781da6c ;;
0777       Darwin) echo OKX4Test.X4PhysicalVolume.World0xc15cfc00x40f7000_PV.50a18baaf29b18fae8c1642927003ee3 ;;
0778    esac
0779 }
0780 geocache-dx0-keydir(){ OPTICKS_KEY=$(geocache-dx0-key) geocache-keydir ; }
0781 
0782 
0783 
0784 geocache-dx1-notes(){ cat << EON
0785 
0786 Manually modified dx0 GDML to make dx1, with addition of bordersurface with non-zero associated efficiency.
0787 
0788 2022 Mar 
0789     find need to add --x4nudgeskip 100,103,105,111,112,132 ro avoid asserts in NNodeNudger
0790     and define OPTICKS_SGDML_PREFIX_G4Material=/dd/Materials/ to avoid addBoundary assert
0791 
0792 EON
0793 }
0794 geocache-dx1-(){  opticksaux- ; 
0795     export OPTICKS_SGDML_PREFIX_G4Material=/dd/Materials/
0796     geocache-create- --gdmlpath $(opticksaux-dx1) --x4polyskip 211,232  --x4nudgeskip 100,103,105,111,112,132 --geocenter --noviz $* ; }     
0797 geocache-dx1-comment(){ echo sensors-gdml-review.rst ; }     
0798 geocache-dx1(){   geocache-dx1- --runfolder $FUNCNAME --runcomment $(${FUNCNAME}-comment) $* ; } 
0799 geocache-dx1-key(){ 
0800    case $(uname) in 
0801       Linux)  echo OKX4Test.X4PhysicalVolume.World0xc15cfc00x40f7000_PV.5aa828335373870398bf4f738781da6c ;;
0802       #Darwin) echo OKX4Test.X4PhysicalVolume.World0xc15cfc00x40f7000_PV.50a18baaf29b18fae8c1642927003ee3 ;;
0803       Darwin) echo OKX4Test.X4PhysicalVolume.World0xc15cfc00x40f7000_PV.f9225f882628d01e0303b3609013324e ;; 
0804    esac
0805 }
0806 geocache-dx1-keydir(){ OPTICKS_KEY=$(geocache-dx1-key) geocache-keydir ; }
0807 
0808 geocache-j21-env()
0809 {
0810    #unset GParts 
0811    #unset GGeo
0812    export GParts=INFO
0813    export GGeo=INFO
0814    export OPTICKS_GGEO_SAVE_MISMATCH_PLACEMENTS=1
0815 }
0816 
0817 geocache-j21-(){  opticksaux- ; geocache-create- --gdmlpath $(opticksaux-j21) --geocenter --noviz $* ; }     
0818 geocache-j21-comment(){ echo shakedown ; }     
0819 geocache-j21(){   geocache-j21-env ; geocache-j21- --runfolder $FUNCNAME --runcomment $(${FUNCNAME}-comment) $* ; } 
0820 geocache-j21-key(){  echo OKX4Test.X4PhysicalVolume.lWorld0x344f8d0_PV.732a5daf83a7153b316a2013fcfb1fc2 ; }
0821 
0822 
0823 
0824 
0825 
0826 geocache-create-notes(){ cat << EON
0827 
0828 Default geocache geometry is now Dayabay Near site detector (dx1)
0829 which is a lot smaller geometry than the JUNO detector (j1808-v5)
0830 
0831 
0832 Oct 02, 2020
0833    change default to geocache-dx0 : DayaBay Near Site a much smaller geometry than the previous JUNO geocache-jv5  
0834 
0835 Oct 23, 2020
0836    change default to geocache-dx1 using opticksaux-dx1 with sensors manually added (testing with G4OKTest)
0837 
0838 
0839 EON
0840 }
0841 
0842 #geocache-create(){ geocache-j1808-v5 $* ; }  
0843 #geocache-create(){ geocache-dx0 $* ; }     
0844 geocache-create(){ geocache-dx1 $* ; }     
0845 
0846 
0847 
0848 geocache-key-export(){   geocache-j1808-v5-export ; }
0849 
0850 
0851 geocache-j1808-v5-notes(){ cat << EON
0852 $FUNCNAME : avoiding a coincidence speckle in box subtract cylinder
0853 ============================================================================
0854 
0855 See notes/issues/tboolean-proxy-scan-LV10-coincidence-speckle.rst for ascii art explaining the change.
0856 
0857 v4::
0858 
0859        555   <solids>
0860        556     <tube aunit="deg" deltaphi="360" lunit="mm" name="Upper_LS_tube0x5b2e9f0" rmax="400" rmin="0" startphi="0" z="3500"/>
0861        557     <opticalsurface finish="3" model="1" name="UpperChimneyTyvekOpticalSurface" type="0" value="0.2">
0862        558       <property name="REFLECTIVITY" ref="REFLECTIVITY0x5b300c0"/>
0863        559     </opticalsurface>
0864        560     <tube aunit="deg" deltaphi="360" lunit="mm" name="Upper_Steel_tube0x5b2eb10" rmax="407" rmin="402" startphi="0" z="3500"/>
0865        561     <tube aunit="deg" deltaphi="360" lunit="mm" name="Upper_Tyvek_tube0x5b2ec30" rmax="402" rmin="400" startphi="0" z="3500"/>
0866        562     <tube aunit="deg" deltaphi="360" lunit="mm" name="Upper_Chimney0x5b2e8e0" rmax="412" rmin="0" startphi="0" z="3500"/>
0867        563     <box lunit="mm" name="sBar0x5b34ab0" x="6860" y="26" z="10"/>
0868        564     <box lunit="mm" name="sBar0x5b34920" x="6860" y="26.3" z="10.3"/>
0869        565     <box lunit="mm" name="sModuleTape0x5b34790" x="6860" y="1691.3" z="12.1"/>
0870        566     <box lunit="mm" name="sModule0x5b34600" x="6861.2" y="1692.5" z="13.3"/>
0871        567     <box lunit="mm" name="sPlane0x5b34470" x="6861.2" y="6770.3" z="13.3"/>
0872        568     <box lunit="mm" name="sWall0x5b342e0" x="6861.2" y="6861.2" z="27.6"/>
0873        569     <box lunit="mm" name="BoxsAirTT0x5b33e60" x="48000" y="48000" z="5000"/>
0874        570     <tube aunit="deg" deltaphi="360" lunit="mm" name="Cylinder0x5b33ef0" rmax="500" rmin="0" startphi="0" z="4000"/>
0875                                                                                                                   ^^^^^^^^^^^^^^^
0876        571     <subtraction name="sAirTT0x5b34000">
0877        572       <first ref="BoxsAirTT0x5b33e60"/>
0878        573       <second ref="Cylinder0x5b33ef0"/>
0879        574       <position name="sAirTT0x5b34000_pos" unit="mm" x="0" y="0" z="-500"/>
0880                                                                               ^^^^^^^^^
0881        575     </subtraction>
0882        576     <box lunit="mm" name="sExpHall0x4bcd390" x="48000" y="48000" z="18600"/>
0883        577     <box lunit="mm" name="sTopRock0x4bccfc0" x="54000" y="54000" z="21600"/>
0884        578     <sphere aunit="deg" deltaphi="360" deltatheta="180" lunit="mm" name="sTarget_bottom_ball0x4bd40d0" rmax="17700" rmin="0" startphi="0" starttheta="0"/>
0885        579     <tube aunit="deg" deltaphi="360" lunit="mm" name="sTarget_top_tube0x4bd4260" rmax="400" rmin="0" startphi="0" z="124.520351230938"/>
0886 
0887 
0888 v5::
0889 
0890        569     <box lunit="mm" name="BoxsAirTT0x5b33e60" x="48000" y="48000" z="5000"/>
0891        570     
0892        571     <!-- see notes/issues/tboolean-proxy-scan-LV10-coincidence-speckle.rst -->
0893        572     <!--tube aunit="deg" deltaphi="360" lunit="mm" name="Cylinder0x5b33ef0" rmax="500" rmin="0" startphi="0" z="4000"/-->
0894        573     <tube aunit="deg" deltaphi="360" lunit="mm" name="Cylinder0x5b33ef0" rmax="500" rmin="0" startphi="0" z="4002"/>
0895        574     
0896        575     <subtraction name="sAirTT0x5b34000">
0897        576       <first ref="BoxsAirTT0x5b33e60"/>
0898        577       <second ref="Cylinder0x5b33ef0"/>
0899        578       <!--position name="sAirTT0x5b34000_pos" unit="mm" x="0" y="0" z="-500"/-->
0900        579       <position name="sAirTT0x5b34000_pos" unit="mm" x="0" y="0" z="-501"/>
0901        580     </subtraction>
0902        581 
0903 
0904 ::
0905 
0906     [blyth@localhost issues]$ opticksdata-j-info
0907 
0908        opticksdata-j   : /home/blyth/local/opticks/opticksdata/export/juno1808/g4_00.gdml
0909        opticksdata-jv2 : /home/blyth/local/opticks/opticksdata/export/juno1808/g4_00_v2.gdml
0910        opticksdata-jv3 : /home/blyth/local/opticks/opticksdata/export/juno1808/g4_00_v3.gdml     
0911        opticksdata-jv4 : /home/blyth/local/opticks/opticksdata/export/juno1808/g4_00_v4.gdml     opticksdata-jv4-vi
0912        opticksdata-jv5 : /home/blyth/local/opticks/opticksdata/export/juno1808/g4_00_v5.gdml     opticksdata-jv5-vi 
0913 
0914     [blyth@localhost issues]$ cp /home/blyth/local/opticks/opticksdata/export/juno1808/g4_00_v4.gdml /home/blyth/local/opticks/opticksdata/export/juno1808/g4_00_v5.gdml
0915 
0916 
0917 
0918 
0919 EON
0920 }
0921 
0922 
0923 
0924 
0925 
0926 geocache-export()
0927 {
0928     local geofunc=$1
0929     export OPTICKS_GEOFUNC=$geofunc
0930     export OPTICKS_KEY=$(${geofunc}-key)
0931     export OPTICKS_COMMENT=$(${geofunc}-comment)
0932 
0933     #[ -t 1 ] && geocache-desc     ## only when connected to terminal 
0934 }
0935 geocache-desc()
0936 {
0937     printf "%-16s : %s \n" "OPTICKS_GEOFUNC" $OPTICKS_GEOFUNC
0938     printf "%-16s : %s \n" "OPTICKS_KEY"     $OPTICKS_KEY
0939     printf "%-16s : %s \n" "OPTICKS_COMMENT" $OPTICKS_COMMENT
0940 }
0941 
0942 
0943 
0944 geocache-target(){ echo 352854 ; }
0945 geocache-target-notes(){ cat << EON
0946 
0947 Find targets by geocache-kcd and looking at GNodeLib/GTreePresent.txt eg::
0948 
0949     62588     62587 [  9:   0/   1]    0 ( 3)            pBar0x5b3a400  sBar0x5b34ab0
0950     62589     62588 [  1:   1/   2]    1 ( 0)    pBtmRock0x4bd2650  sBottomRock0x4bcd770
0951     62590     62589 [  2:   0/   1]    1 ( 0)     pPoolLining0x4bd25b0  sPoolLining0x4bd1eb0
0952     62591     62590 [  3:   0/   1] 2308 ( 0)      pOuterWaterPool0x4bd2b70  sOuterWaterPool0x4bd2960
0953     62592     62591 [  4:   0/2308]    1 ( 0)       pCentralDetector0x4bd4930  sReflectorInCD0x4bd3040
0954     62593     62592 [  5:   0/   1] 55274 ( 0)        pInnerWater0x4bd4700  sInnerWater0x4bd3660
0955     62594     62593 [  6:   0/55274]    1 ( 0)         pAcylic0x4bd47a0  sAcrylic0x4bd3cd0
0956     62595     62594 [  7:   0/   1]    0 ( 0)          pTarget0x4bd4860  sTarget0x4bd4340
0957     62596     62595 [  6:   1/55274]    0 ( 4)         lSteel_phys0x4bd4d60  sStrut0x4bd4b80
0958     62597     62596 [  6:   2/55274]    0 ( 4)         lSteel_phys0x4bd4ec0  sStrut0x4bd4b80
0959     62598     62597 [  6:   3/55274]    0 ( 4)         lSteel_phys0x4bd4fe0  sStrut0x4bd4b80
0960     62599     62598 [  6:   4/55274]    0 ( 4)         lSteel_phys0x4bd50d0  sStrut0x4bd4b80
0961     ...
0962     65589    352852 [  7:   2/   3]    0 ( 0)          pLowerChimneySteel0x5b318b0  sChimneySteel0x5b314f0
0963     65590    352853 [  6:55273/55274]    1 ( 0)         lSurftube_phys0x5b3c810  sSurftube0x5b3ab80
0964     65591    352854 [  7:   0/   1]    0 ( 0)          pvacSurftube0x5b3c120  svacSurftube0x5b3bf50
0965     65592    352855 [  4:   1/2308]    2 ( 2)       lMaskVirtual_phys0x5cc1ac0  sMask_virtual0x4c36e10
0966     65593    352856 [  5:   0/   2]    0 ( 2)        pMask0x4c3bf20  sMask0x4ca38d0
0967     65594    352857 [  5:   1/   2]    1 ( 2)        PMT_20inch_log_phys0x4ca16b0  PMT_20inch_pmt_solid0x4c81b40
0968 
0969 
0970 
0971 ::
0972 
0973     OKTest --target 62590 --xanalytic    
0974     ## 62590 : pOuterWaterPool0x4bd2b70  sOuterWaterPool0x4bd2960  
0975     ## with this target calib photons appear at center (by eye with orthographic view anyhow)
0976 
0977 
0978     OKTest --target 62590 --xanalytic --eye -0.9,0,0
0979     ## canonical position
0980 
0981 
0982 
0983 EON
0984 }
0985 
0986 
0987 geocache-view()
0988 {
0989     type $FUNCNAME
0990     env | grep OPTICKS_KEY
0991     env | grep CUDA
0992     #OKTest --envkey --xanalytic  --tracer --target $(geocache-target)
0993     OKTest --envkey --xanalytic 
0994 }
0995 
0996 geocache-movie-()
0997 {
0998     # with --scintillation tried kludge symbolic link in opticksdata/gensteps g4live -> juno1707
0999     # but that gives applyLookup fails 
1000     #   --near 1000    not working, presumably overridden by basis aim  
1001     # --rendermode +global,+in0,+in1,+in2,+in3,+in4,+axis
1002     #
1003     # B2:viz instances
1004     # Q0:viz global
1005 
1006     env | grep OPTICKS_KEY
1007     OKTest --envkey \
1008             --xanalytic \
1009             --timemax 400 \
1010             --animtimemax 400 \
1011             --target $(geocache-target) \
1012             --eye -2,0,0 \
1013             --rendercmd B2,Q0 
1014 }
1015 
1016 geocache-movie(){ $FUNCNAME- 2>&1 > /tmp/$FUNCNAME.log ; }
1017 
1018 
1019 geocache-gui()
1020 {
1021    local dbg
1022    [ -n "$DBG" ] && dbg="gdb --args" || dbg=""
1023 
1024    ## NB cvd slots can change between reboots
1025    ## for interop to work have to see only the GPU being used for display (TITAN RTX)
1026    ## BUT beware nvidia-smi and UseOptiX sometimes disagree on the slots : its UseOptiX that matters
1027 
1028    local cvd=1
1029    UseOptiX --cvd $cvd 
1030 
1031    $dbg OKTest \
1032                 --cvd $cvd \
1033                 --rtx 1 \
1034                 --envkey \
1035                 --xanalytic \
1036                 --timemax 400 \
1037                 --animtimemax 400 \
1038                 --target 352851 \
1039                 --eye -1,-1,-1  \
1040                  $*   
1041 }
1042 
1043 
1044 
1045 
1046 geocache-simple-emm(){ ls -1 $(geocache-keydir)/GMergedMesh ; } 
1047 
1048 geocache-simple-cmd(){ 
1049    local pvn=${PVN:-lLowerChimney_phys}
1050    local eye=${EYE:--1,-1,-1} 
1051    local emm="${EMM:-~0}"
1052 
1053 cat << EOC
1054 OpSnapTest --targetpvn $pvn --eye $eye -e "$emm" --snapoverrideprefix geocache-simple-$pvn-emm-$mm- $*
1055 EOC
1056 }
1057 
1058 geocache-simple()
1059 {
1060     local emm
1061     local cmd 
1062     for emm in $(geocache-simple-emm) ; do  
1063         cmd=$(EMM=$emm geocache-simple-cmd $*)
1064         echo $cmd
1065         eval $cmd
1066     done 
1067 }
1068 
1069 
1070 
1071 
1072 
1073 geocache-360()
1074 {
1075    local dbg
1076    [ -n "$DBG" ] && dbg="gdb --args" || dbg=""
1077 
1078    local cvd=1
1079    UseOptiX --cvd $cvd 
1080 
1081    local cameratype=2  # EQUIRECTANGULAR
1082 
1083    $dbg OKTest \
1084                 --cvd $cvd \
1085                 --xanalytic \
1086                 --target 62594  \
1087                 --eye 0,0,0  \
1088                 --tracer \
1089                 --look 0,0,1  \
1090                 --up 1,0,0 \
1091                 --cameratype $cameratype \
1092                 --enabledmergedmesh 1,2,3,4,5 \
1093                 --rendercmd O1 \
1094                 --rtx 1 \
1095                  $*   
1096 }
1097 
1098 geocache-360-notes(){ cat << EON
1099 
1100      --enabledmergedmesh 1,2,3,4,5 \
1101            list of mesh indices to include : note that global 0 is excluded in order to see PMTs
1102 
1103      --fullscreen \
1104 
1105      --rendercmd O1 \
1106            directly to composite : but actually there is is no projective for EQUIRECTANGULAR
1107 
1108 
1109 360 degree view of all PMTs from the center of the 
1110 scintillator (raytrace only as distinctly non-trivial to do 
1111 using the rasterization pipeline).
1112 
1113 Uses an equirectangular "projection" : actually 
1114 just a mapping from pixels (x,y) to 
1115 azimuthal (-pi:pi) and polar(-pi/2:pi/2) angles. 
1116 
1117 Default frame size is 1920x1080 
1118 Typical presentation size is 1280x720    --size 1280,720,1
1119 Double that 2560x1440
1120 
1121 To take a frame snap press TAB, which saves to /tmp/Frame.ppm
1122 
1123 ::
1124 
1125     geocache-360 --size 2560,1440,1
1126 
1127 Hmm doing this, end up with 2560x1340 seems to be constrained by monitor size
1128 
1129 
1130 Convert to png with 
1131 
1132    env-;libpng-;libpng-- Frame.ppm
1133 
1134 
1135 
1136 
1137 EON
1138 }
1139 
1140 geocache-size-notes(){ cat << EON
1141 
1142    factor 4: 58.98 M pixels
1143    factor 2: 14.75 M pixels
1144 
1145 EON
1146 }
1147 
1148 geocache-size()
1149 { 
1150    local factor=${1:-2}
1151    local width=$((  2560*factor ))
1152    local height=$(( 1440*factor ))
1153    echo $width,$height,1
1154 }
1155 geocache-pixels()
1156 {
1157    local factor=${1:-2}
1158    local width=$((  2560*factor ))
1159    local height=$(( 1440*factor ))
1160    echo $(( $width * $height / 1000000 ))
1161 }
1162 
1163 
1164 geocache-bench360(){ OPTICKS_GROUPCOMMAND="$FUNCNAME $*" geocache-rtxcheck $FUNCNAME $* ; }
1165 geocache-bench360-()
1166 {
1167    type $FUNCNAME
1168    UseOptiX $*
1169 
1170    local factor=4
1171    local cameratype=2  # EQUIRECTANGULAR : all PMTs in view 
1172    local dbg
1173    [ -n "$DBG" ] && dbg="gdb --args" || dbg=""
1174    $dbg OpSnapTest --envkey \
1175                    --target 62594  \
1176                    --eye 0,0,0  \
1177                    --look 0,0,1  \
1178                    --up 1,0,0 \
1179                    --snapconfig "steps=5,eyestartx=0.25,eyestopx=0.25,eyestarty=0.25,eyestopy=0.25,eyestartz=0.25,eyestopz=0.25" \
1180                    --size $(geocache-size $factor) \
1181                    --enabledmergedmesh 1,2,3,4,5 \
1182                    --cameratype $cameratype \
1183                    --embedded \
1184                    $* 
1185 }
1186 
1187 geocache-bench360-notes(){ cat << EON
1188 
1189  geocache-rtxcheck 
1190        feeds in arguments : --cvd  --rtx  --run*  
1191 
1192 EON
1193 }
1194 
1195 geocache-snap360()
1196 {
1197    local cvd=1
1198    UseOptiX --cvd $cvd 
1199 
1200    local cameratype=2  # EQUIRECTANGULAR : all PMTs in view 
1201    #local factor=4     # 4: 58.98 M pixels
1202    #local factor=2     # 2: 14.75 M pixels
1203    local factor=1      # 1: 2560x1440 : twice typical presentation resolution
1204 
1205    local dbg
1206    [ -n "$DBG" ] && dbg="gdb --args" || dbg=""
1207    $dbg OpSnapTest \
1208                    --cvd $cvd \
1209                    --rtx 1 \
1210                    --envkey \
1211                    --target 62594  \
1212                    --xanalytic \
1213                    --eye 0,0,0  \
1214                    --look 0,0,1  \
1215                    --up 1,0,0 \
1216                    --enabledmergedmesh 2 \
1217                    --cameratype $cameratype \
1218                    --snapconfig "steps=5,eyestartx=0.25,eyestopx=0.25,eyestarty=0.25,eyestopy=0.25,eyestartz=0.25,eyestopz=0.25" \
1219                    --size $(geocache-size $factor) \
1220                    --embedded \
1221                    $* 
1222 
1223 }
1224 
1225 
1226 
1227 
1228 geocache-save()
1229 {
1230    local dbg
1231    [ -n "$DBG" ] && dbg="gdb --args" || dbg=""
1232    $dbg OKTest \
1233        --cvd 0,1 \
1234        --envkey \
1235        --xanalytic \
1236        --compute \
1237        --save
1238 }
1239 
1240 geocache-load()
1241 {
1242    local dbg
1243    [ -n "$DBG" ] && dbg="gdb --args" || dbg=""
1244 
1245    local cvd=1
1246    UseOptiX --cvd $cvd 
1247 
1248    $dbg OKTest \
1249         --cvd $cvd \
1250         --rtx 0 \
1251         --envkey \
1252         --xanalytic \
1253         --timemax 400 \
1254         --animtimemax 400 \
1255         --load
1256 }
1257 
1258 
1259 
1260 
1261 geocache-gui-notes(){ cat << EON
1262 
1263 
1264 Adding --save option fails even after setting CUDA_VISIBLE_DEVICES=1::
1265 
1266     2019-05-09 15:26:57.701 INFO  [67138] [OpEngine::downloadEvent@149] .
1267     2019-05-09 15:26:57.701 INFO  [67138] [OContext::download@587] OContext::download PROCEED for sequence as OPTIX_NON_INTEROP
1268     terminate called after throwing an instance of 'optix::Exception'
1269       what():  Invalid value (Details: Function "RTresult _rtBufferGetDevicePointer(RTbuffer, int, void**)" caught exception: Cannot get device pointers from non-CUDA interop buffers.)
1270     Aborted (core dumped)
1271     [blyth@localhost opticks]$ 
1272 
1273 
1274 Adding "--compute" with the "--save" succeeds to save 
1275 
1276 
1277 
1278 EON
1279 }
1280 
1281 
1282 
1283 
1284 geocache-tour-()
1285 {
1286    type $FUNCNAME
1287    local dbg
1288    [ -n "$DBG" ] && dbg="gdb --args" || dbg=""
1289    $dbg OpSnapTest --envkey --target 352851 --eye -1,-1,-1 --snapconfig "steps=10,eyestartz=-1,eyestopz=5" --size 2560,1440,1 --embedded  $* 
1290 }
1291 
1292 
1293 # preserving spaces through multiple levels of argument passing is painful but its trivial to do via envvar 
1294 geocache-bench(){  OPTICKS_GROUPCOMMAND="$FUNCNAME $*" geocache-rtxcheck $FUNCNAME $* ; } 
1295 geocache-bench-()
1296 {
1297    type $FUNCNAME
1298    UseOptiX $*
1299    local dbg
1300    [ -n "$DBG" ] && dbg="gdb --args" || dbg=""
1301    $dbg OpSnapTest --envkey --target $(geocache-bench-target) --eye -1,-1,-1 --snapconfig "steps=5,eyestartz=-1,eyestopz=-0.5" --size 5120,2880,1 --embedded  $* 
1302 }
1303 geocache-bench-target(){ echo ${GEOCACHE_BENCH_TARGET:-352851} ; }   # chimney region default
1304 geocache-bench-check(){  geocache-bench- --cvd 1 --rtx 0 --runfolder $FUNCNAME --runstamp $(date +%s)  --xanalytic ; }
1305 
1306 
1307 geocache-machinery-notes(){ cat << EON
1308 
1309 Check the bach function preparation of arguments for a 
1310 group of runs using and with the UseOptiX executable.
1311 
1312 EON
1313 }
1314 
1315 geocache-machinery(){ geocache-rtxcheck $FUNCNAME $* ; }
1316 geocache-machinery-()
1317 {
1318    UseOptiX $* --cmdline 
1319 }
1320 
1321 
1322 geocache-rtxcheck-notes(){ cat << EON
1323 $FUNCNAME
1324 ========================
1325 
1326 0. used by functions such as geocache-bench360 which pass their FUNCNAME
1327    as the first argument, this funcname with a dash appended is then
1328    invoked with additional arguments that vary the RTX settings 
1329 
1330 1. arguments after the first are passed to the function, this is typically
1331    used to switch to analytic with --xanalytic 
1332 
1333 2. depends on UseOptiX that is now always built in optixrap/tests
1334 
1335 3. UseOptiX --uniqrec returns eg Quadro_RTX_8000/0
1336 
1337 EON
1338 }
1339 
1340 
1341 geocache-rtxcheck()
1342 {
1343    local name=${1:-geocache-bench}
1344    shift
1345 
1346    local stamp=$(date +%s)
1347    local ndev=$(UseOptiX --num)
1348 
1349    local uniqrec
1350    local uniqname
1351    local ordinal
1352 
1353    local scan=1
1354    if [ $scan -eq 1 ] 
1355    then
1356        UseOptiX --uniqrec | while read uniqrec ; do 
1357            ordinal=$(basename $uniqrec)
1358            uniqname=$(dirname $uniqrec)
1359 
1360            $name- --cvd $ordinal --rtx 0 --runfolder $name --runstamp $stamp --runlabel "R0_$uniqname" $*
1361            $name- --cvd $ordinal --rtx 1 --runfolder $name --runstamp $stamp --runlabel "R1_$uniqname" $*
1362            $name- --cvd $ordinal --rtx 2 --runfolder $name --runstamp $stamp --runlabel "R2_$uniqname" $*
1363        done
1364    fi
1365 
1366    if [ $ndev -eq 2 ]
1367    then
1368        local dev0=$(dirname $(UseOptiX --cvd 0 --uniqrec))
1369        local dev1=$(dirname $(UseOptiX --cvd 1 --uniqrec))
1370        $name- --cvd 0,1 --rtx 0 --runfolder $name --runstamp $stamp --runlabel "R0_${dev0}_AND_${dev1}" $*
1371    fi 
1372 
1373    if [ $ndev -gt 2 ]
1374    then
1375        local cvd
1376        geocache-cvd $ndev | while read cvd ; do
1377            $name- --cvd $cvd --rtx 0 --runfolder $name --runstamp $stamp $*
1378            $name- --cvd $cvd --rtx 1 --runfolder $name --runstamp $stamp $*
1379        done 
1380    fi 
1381 
1382    bench.py --name $name
1383 }
1384 
1385 
1386 
1387 geocache-cvd(){ geocache-cvd-even ; }
1388 
1389 geocache-cvd-even(){  cat << EOC
1390 0
1391 0,1
1392 0,1,2
1393 0,1,2,3
1394 4
1395 4,5
1396 4,5,6
1397 4,5,6,7
1398 EOC
1399 }
1400 
1401 geocache-cvd-linear()
1402 {
1403    local ndev=${1:-8}
1404    local cvd
1405    local i=0
1406    while [ $i -lt $ndev ]; do
1407       [ -n "$cvd" ] &&  cvd=${cvd},$i || cvd=$i
1408       echo $cvd
1409       i=$(( $i + 1 )) 
1410    done
1411 }
1412 
1413 
1414 
1415 geocache-bench-results()
1416 {
1417    bench.py $*
1418 }
1419 
1420 
1421 geocache-runfolder-names(){ cat << EON
1422 geocache-bench
1423 geocache-bench360
1424 EON
1425 }
1426 
1427 geocache-runfolder-collect()
1428 {
1429    local rnode=${1:-L7}
1430    local rdir=$OPTICKS_RESULTS_PREFIX/results
1431    [ ! -d "$rdir" ] && echo $msg missing rdir $rdir && return 
1432 
1433    local rfn
1434    local gdir
1435    geocache-runfolder-names | while read rfn 
1436    do 
1437       gdir=$rdir/$rfn  
1438       [ ! -d "$gdir" ] && echo $msg missing $gdir && return 
1439       cd 
1440       scp -r $rnode:g/local/opticks/results/$rfn/* $gdir
1441    done
1442    ## hmm simple when no name overlap between the cluster and workstation rungroup names  
1443    ## hmm better to rsync
1444 }
1445 
1446 
1447 
1448 geocache-bench-notes(){ cat << EON
1449 $FUNCNAME
1450 =======================
1451 
1452 ========  ====================================
1453   rtx       action 
1454 ========  ====================================
1455    -1       ASIS
1456     0       OFF
1457     1       ON  
1458     2       ON with optix::GeometryTriangles
1459 ========  ====================================
1460 
1461 
1462 * cannot enable RTX when simultaneously using both TITAN V(Volta) 
1463   and TITAN RTX(Turing) as only Turing has the RT Cores.
1464 
1465 * it is possible to enable RTX on Volta, sometimes resulting in a small speedup
1466   see notes/issues/benchmarks.rst
1467 
1468 ::
1469 
1470     geocache-bench-results --include xanalytic
1471     geocache-bench-results --exclude xanalytic
1472 
1473 Former default location to write results was $LOCAL_BASE/opticks/results
1474 but that doesnt make sense for multiple users running from the same 
1475 install, so shift default to $TMP/results ie /tmp/$USER/opticks/results
1476 
1477 Can write results elsewhere by setting envvar OPTICKS_RESULTS_PREFIX 
1478 see BOpticksResource::ResolveResultsPrefix
1479 
1480 
1481 EON
1482 }
1483 
1484 
1485 geocache-create-cfbase-tarball(){
1486    local msg="=== $FUNCNAME :"
1487    local keydir=$(geocache-keydir) 
1488    local keyfunc=$(geocache-keyfunc)
1489  
1490    cd $keydir
1491    [ ! -d "CSG_GGeo" ] && echo $msg ERROR CSG_GGeo does not exist && return 1 
1492 
1493    cd $keydir/CSG_GGeo
1494    [ ! -d "CSGFoundry" ] && echo $msg ERROR CSG_GGeo/CSGFoundry does not exist && return 2
1495 
1496    mkdir -p $keyfunc
1497 
1498    cd $keydir/CSG_GGeo/$keyfunc
1499    ln -svf ../CSGFoundry 
1500 
1501    cd $keydir/CSG_GGeo
1502 
1503    local tgz=$keyfunc.tar.gz
1504    echo $msg creating tgz $tgz into directory $PWD containing the CSGFoundry directory  
1505    local ans 
1506 
1507    read -p "$msg proceed to create tgz $tgz into $PWD ? Enter YES to continue : " ans 
1508   
1509    if [ "$ans" == "YES" ]; then 
1510 
1511        case $(uname) in 
1512            Darwin) tar -L -czvf $tgz $keyfunc ;;
1513            Linux)  tar -h -czvf $tgz $keyfunc ;;   
1514        esac
1515    else
1516        echo $msg SKIPPED
1517    fi 
1518 
1519    return 0 
1520 }
1521 
1522 geocache-use-cfbase-tarball-notes(){ cat << EON
1523 
1524 Hmm could consider reading archive without untarring, eg 
1525    
1526    http://www.libarchive.org
1527 
1528 
1529 * https://github.com/simoncblyth/cfbase
1530 
1531 
1532     epsilon:~ blyth$ mv tds3_mar_2022.tar.gz  /tmp/
1533     epsilon:~ blyth$ cd /tmp
1534     epsilon:tmp blyth$ tar zxvf tds3_mar_2022.tar.gz
1535     x tds3_mar_2022/
1536     x tds3_mar_2022/CSGFoundry/
1537     x tds3_mar_2022/CSGFoundry/meshname.txt
1538     x tds3_mar_2022/CSGFoundry/mmlabel.txt
1539     x tds3_mar_2022/CSGFoundry/solid.npy
1540     x tds3_mar_2022/CSGFoundry/prim.npy
1541     x tds3_mar_2022/CSGFoundry/node.npy
1542     x tds3_mar_2022/CSGFoundry/tran.npy
1543     x tds3_mar_2022/CSGFoundry/itra.npy
1544     x tds3_mar_2022/CSGFoundry/inst.npy
1545     x tds3_mar_2022/CSGFoundry/bnd.npy
1546     x tds3_mar_2022/CSGFoundry/bnd_meta.txt
1547     x tds3_mar_2022/CSGFoundry/icdf.npy
1548     x tds3_mar_2022/CSGFoundry/icdf_meta.txt
1549     x tds3_mar_2022/CSGFoundry/meta.txt
1550     epsilon:tmp blyth$ l 
1551 
1552 
1553 
1554 Set CFBASE envvar and run render::
1555 
1556     export CFBASE=/tmp/tds3_mar_2022
1557     cx  ## cd ~/opticks/CSGOptiX
1558     source ./cxr.sh 
1559 
1560 OR::
1561 
1562    CFBASE=/tmp/tds3_mar_2022 source ./cxr.sh 
1563 
1564 
1565 EON
1566 }
1567 
1568 
1569 
1570 
1571