-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopticks.bash
More file actions
4403 lines (3221 loc) · 108 KB
/
opticks.bash
File metadata and controls
4403 lines (3221 loc) · 108 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
##
## Copyright (c) 2019 Opticks Team. All Rights Reserved.
##
## This file is part of Opticks
## (see https://bitbucket.org/simoncblyth/opticks).
##
## Licensed under the Apache License, Version 2.0 (the "License");
## you may not use this file except in compliance with the License.
## You may obtain a copy of the License at
##
## http://www.apache.org/licenses/LICENSE-2.0
##
## Unless required by applicable law or agreed to in writing, software
## distributed under the License is distributed on an "AS IS" BASIS,
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
## See the License for the specific language governing permissions and
## limitations under the License.
##
opticks-(){ source $(opticks-source) && opticks-env $* ; }
GEOM_TEMPLATE(){ cat << EOT
#!/bin/bash
notes(){ cat << EON
~/.opticks/GEOM/GEOM.sh
=========================
* GEOM.sh IS NOT UNDER SOURCE CONTROL BECAUSE IT IDENTIFIES A SPECIFIC GEOM
* associated utility functions such as scp/grab/vi
are kept under source control in the opticks.bash GEOM bash function
EON
}
#geom=V0J008
#geom=V1J008
geom=V1J009
export GEOM=\$geom
#
EOT
}
CTX_TEMPLATE(){ cat << EOT
#!/bin/bash
notes(){ cat << EON
~/.opticks/CTX/CTX.sh
=========================
* CTX.sh IS NOT UNDER SOURCE CONTROL BECAUSE IT IS OFTEN USER+GEOMETRY SPECIFIC
EON
}
ctx=Debug_Philox
export CTX=\$ctx
#
EOT
}
TEST_TEMPLATE(){ cat << EOT
#!/bin/bash
notes(){ cat << EON
~/.opticks/TEST/TEST.sh
=========================
* TEST.sh IS NOT UNDER SOURCE CONTROL BECAUSE IT IS OFTEN USER+GEOMETRY SPECIFIC
EON
}
#test=GUN0
test=GUN1
#test=GUN2
export TEST=\$test
#
EOT
}
MOI_TEMPLATE(){ cat << EOT
#!/bin/bash
notes(){ cat << EON
~/.opticks/GEOM/MOI.sh : exports MOI midx:mord:gord configuring a frame in a geometry
======================================================================================
* MOI.sh IS NOT UNDER SOURCE CONTROL BECAUSE IT IS GEOMETRY SPECIFIC
The MOI envvar is used to pick a frame within a geometry.
MOI enables targeted 3D ray trace rendering and 2D simtrace slicing
to be oriented with respect to the chosen frame.
The closely related OPTICKS_INPUT_PHOTON_FRAME envvar uses the same
implementation to orient input photons within the chosen frame.
The colon delimited fields of the MOI variable are:
midx
mesh index (aka lvid) that can be specified by solid name
mord
mesh ordinal (usually 0) to pick between multiple occurrences
gord
GAS ordinal to pick between instances of instanced geometry,
and with global volumes to configure how to conjure the frame
transforms from the global center-extent CE of the solid
(as global volumes do not have individual transforms, unlike
instanced volumes)
+-----------+------------------------------------------------------------------------+
| gord | notes, see CSGTarget::getFrameComponents for impl |
+===========+========================================================================+
| 0,1,2,.. | for instanced volumes this picks the instance and uses its frame |
+-----------+------------------------------------------------------------------------+
| -1 | |
+-----------+------------------------------------------------------------------------+
| -2 | XYZ frame constructed from CE using SCenterExtentFrame.h |
+-----------+------------------------------------------------------------------------+
| -3 | RTP tangential frame constructed from CE using SCenterExtentFrame.h |
| | (this is useful for orienting wrt volumes placed on a sphere) |
+-----------+------------------------------------------------------------------------+
* see CSGTarget::getFrameComponents to follow the gord:-2:XYZ gord:-3:RTP branching
EON
}
moi=ALL
#moi=sWorld:0:0
#moi=NNVT:0:0
#moi=NNVT:0:50
#moi=NNVT:0:1000
#moi=PMT_20inch_veto:0:1000 # gord:1000 [0...] GAS-ordinal selection of the instance transform to use
#moi=sChimneyAcrylic:0:-2 # gord:-2/-3 are appropriate for global (non-instanced) geometry
#export MOI=\${MOI:-\$moi}
export MOI=\$moi
EOT
}
EVT_TEMPLATE(){ cat << EOT
#!/bin/bash
usage(){ cat << EON
~/.opticks/GEOM/EVT.sh
========================
Export event related config such as AFOLD and BFOLD.
Typically these need to be tied to a particular GEOM.
EON
}
if [ "\$GEOM" == "J25_3_0_opticks_Debug" ]; then
afold=/tmp/blyth/opticks/GEOM/\$GEOM/InputPhotonsCheck/ALL1_DebugPhilox_sChimneyLS:0:-2_SGenerate_ph_disc_M1/A000
bfold=/tmp/blyth/opticks/GEOM/\$GEOM/InputPhotonsCheck/ALL1_DebugPhilox_sChimneyLS:0:-2_SGenerate_ph_disc_M1/B000
export AFOLD=\${AFOLD:-\$afold}
export BFOLD=\${BFOLD:-\$bfold}
fi
EOT
}
ELV_TEMPLATE(){ cat << EOT
#!/bin/bash
usage(){ cat << EON
~/.opticks/GEOM/ELV.sh
========================
Export ELV envvar configuring vizualized inclusions/exclusions.
These are clearly tied to a particular GEOM.
EON
}
if [ "\$GEOM" == "J25_4_0_opticks_Debug" ]; then
export ELV=t:sWorld,sBottomRock,sTopRock,sExpHall,sExpRockBox,sDomeRockBox,sAirGap,sDeadWater_shell,sTyvek_shell,sOuterWaterPool,sPoolLining
## CAUTION THAT MOI is not excluded
fi
EOT
}
ENVSET_TEMPLATE(){ cat << EOT
#!/bin/bash
usage(){ cat << EON
~/.opticks/GEOM/ENVSET.sh
==========================
Export ENVSET envvar configuring path to setup script, use this
from bash function like::
oj_envset()
{
: ~/local.sh
source ~/.opticks/GEOM/ENVSET.sh
if [ -n "\$ENVSET" -a -f "\$ENVSET" ]; then
source \$ENVSET
else
echo \$BASH_SOURCE - ERROR - MISSING ENVSET \$ENVSET
fi
}
EON
}
envset=/cvmfs/opticks.ihep.ac.cn/oj/releases/J25.4.0_Opticks-v0.5.6/el9_amd64_gcc11/2025_10_29/envset.sh
export ENVSET=\$envset
EOT
}
VUE_TEMPLATE(){ cat << "EOT"
#!/bin/bash
usage(){ cat << EON
~/.opticks/GEOM/VUE.sh
========================
Configure SGLM.h viewpoint
EON
}
#eye=1000,1000,1000
#eye=3.7878,3.7878,3.7878
#eye=-1,-1,0
#eye=-1,0,0
#eye=1,0,0
eye=0,1,0
#eye=3,0,0
#eye=3,0,-1.5
#eye=0,3,-1.5
#eye=0,-1,0
#eye=-1,-1,3
#eye=-1,-1,3
look=0,0,0
up=0,0,1
#up=0,0,-1
wh=2560,1440
fullscreen=1
zoom=1
tmin=0.5
cam=perspective
#cam=orthographic # needs work to set param to make view start closer to perspective
#escale=asis
escale=extent
traceyflip=0
export WH=${WH:-$wh}
export FULLSCREEN=${FULLSCREEN:-$fullscreen}
export ESCALE=${ESCALE:-$escale}
export EYE=${EYE:-$eye}
export LOOK=${LOOK:-$look}
export UP=${UP:-$up}
export ZOOM=${ZOOM:-$zoom}
export TMIN=${TMIN:-$tmin}
export CAM=${CAM:-$cam}
nameprefix=${SCRIPT}_
nameprefix=${nameprefix}_eye_${EYE}_
nameprefix=${nameprefix}_zoom_${ZOOM}_
nameprefix=${nameprefix}_tmin_${TMIN}_
# moi appended within CSGOptiX::render_snap ?
export NAMEPREFIX=$nameprefix
## NAMEPREFIX used in CSGOptiX::getRenderStemDefault
topline="ESCALE=$ESCALE EYE=$EYE TMIN=$TMIN MOI=$MOI ZOOM=$ZOOM CAM=$CAM $SCRIPT.sh "
botline="$(date)"
export TOPLINE=${TOPLINE:-$topline}
export BOTLINE=${BOTLINE:-$botline}
#export CSGOptiXRenderInteractiveTest__SGLM_DESC=1
#export SGLFW__DEPTH=1 # dump _depth.jpg together with screenshots
soptix__handle=-1 # default, full geometry
#soptix__handle`=0 # only non-instanced global geometry
#soptix__handle=1 # single CSGSolid
#soptix__handle=2 #
export SOPTIX__HANDLE=${SOPTIX__HANDLE:-$soptix__handle}
#export SOPTIX_Options__LEVEL=1
EOT
}
SDR_TEMPLATE(){ cat << EOT
#!/bin/bash
usage(){ cat << EON
~/.opticks/GEOM/SDR.sh
========================
Configure OpenGL shader
EON
}
shader_name=rec_flying_point
#shader_name=rec_flying_point_persist
#shader_name=rec_line_strip
export SGLFW_Evt__shader_name=\${SGLFW_Evt__shader_name:-\$shader_name}
sglfw_evt_level=2
export SGLFW_Evt__level=\${SGLFW_Evt__level:-\$sglfw_evt_level}
EOT
}
CUR_TEMPLATE(){ cat << EOT
#!/bin/bash
usage(){ cat << EON
~/.opticks/GEOM/CUR.sh
========================
Define CUR_ bash functions for context control
CUR_path
emits path of context file ~/.opticks/CUR.sh
CUR_open
writes current context file with info exports
CUR_close
deletes current context file
::
local t=\$(date +"%s")
local d=\$(date -d @\$t +"%Y%m%d_%H%M%S")
EON
}
CUR_(){
local arg=\${1:-dummy_no_CUR_arg}
cat << EOC
# generated by \$BASH_SOURCE \$FUNCNAME
export CUR=\$arg
EOC
}
CUR_source(){ [ -f \$(CUR_path) ] && source \$(CUR_path) ; }
CUR_path(){ echo ~/.opticks/CUR.sh ; }
CUR_open(){ CUR_ \$* > \$(CUR_path) ; }
CUR_close(){ rm \$(CUR_path) ; }
CUR_t(){ [ -f \$(CUR_path) ] && stat --format=%Y \$(CUR_path) ; }
CUR_d(){ local t=\$(CUR_t) ; [ "\$t" != "" ] && date -d @\$t +"%Y%m%d_%H%M%S" ; }
CUR_touch(){
local date="\$*"
: eg "20250702 17:56:20" OR 17:56
if [ "\$date" != "" ]; then
touch --date="\$date" \$(CUR_path)
else
touch \$(CUR_path)
fi
}
CUR_info(){ cat <<EOI
CUR_path : \$(CUR_path)
CUR_t : \$(CUR_t)
CUR_d : \$(CUR_d)
CUR : \$CUR
EOI
}
EOT
}
GEOM_help(){ cat << EOH
GEOM_help : bash function help
================================
NB the GEOM.sh script is distinct from the bash function.
The GEOM.sh script is not keep in a repository as the
GEOM envvar is private to each user.
GEOM vi
edit GEOM.sh script that sets GEOM envvar
GEOM ex
source the GEOM.sh script which exports GEOM envvar
GEOM grab
rsync remote GEOM directory to local
GEOM get
synonym for grab
GEOM tmpget
when TMP is undefined : rsync remote /tmp/$USER/opticks/GEOM/$GEOM dir to local
when TMP is defined : rsync remote $TMP/GEOM/$GEOM dir to local
GEOM tmp
change directory to /tmp/$USER/opticks/GEOM/$GEOM
or $TMP/GEOM/$GEOM when TMP is defined
GEOM scp
scp GEOM.sh script to remote
GEOM base
change directory to GEOM base directory above all the \$GEOM dir
GEOM top
change directory to : \$GEOM dir
GEOM lock
make \$GEOM dir tree readonly
GEOM unlock
make \$GEOM dir tree writable
GEOM cf
change directory to : \$GEOM/CSGFoundry
GEOM ss
change directory to : \$GEOM/CSGFoundry/SSim
GEOM st
change directory to : \$GEOM/CSGFoundry/SSim/stree
GEOM std
change directory to : \$GEOM/CSGFoundry/SSim/stree/standard
GEOM origin
vim -R origin.gdml on top dir
GEOM source
source the $HOME/.opticks/GEOM/GEOM.sh
its kinda dirty to do this but handy for some debugging,
remember to exit sessions after doing this
GEOM info
dump variables of the GEOM bash function
GEOM help
show this usage message
EOH
}
TMP(){
cd ${TMP:-/tmp/$USER/opticks}
pwd
}
MOI(){
: opticks/opticks.bash
local script=.opticks/GEOM/MOI.sh
if [ ! -f "$HOME/$script" ]; then
echo $BASH_SOURCE $FUNCNAME : GENERATE $HOME/$script
MOI_TEMPLATE > $HOME/$script
fi
local defarg="vi"
local arg=${1:-$defarg}
if [ "$arg" == "vi" ]; then
cmd="vi $HOME/$script"
fi
echo $cmd
eval $cmd
}
EVT(){
: opticks/opticks.bash
local script=.opticks/GEOM/EVT.sh
if [ ! -f "$HOME/$script" ]; then
echo $BASH_SOURCE $FUNCNAME : GENERATE $HOME/$script
EVT_TEMPLATE > $HOME/$script
fi
local defarg="vi"
local arg=${1:-$defarg}
if [ "$arg" == "vi" ]; then
cmd="vi $HOME/$script"
fi
echo $cmd
eval $cmd
}
ELV(){
: opticks/opticks.bash
local script=.opticks/GEOM/ELV.sh
if [ ! -f "$HOME/$script" ]; then
echo $BASH_SOURCE $FUNCNAME : GENERATE $HOME/$script
ELV_TEMPLATE > $HOME/$script
fi
local defarg="vi"
local arg=${1:-$defarg}
if [ "$arg" == "vi" ]; then
cmd="vi $HOME/$script"
fi
echo $cmd
eval $cmd
}
ENVSET(){
: opticks/opticks.bash
local script=.opticks/GEOM/ENVSET.sh
if [ ! -f "$HOME/$script" ]; then
echo $BASH_SOURCE $FUNCNAME : GENERATE $HOME/$script
ENVSET_TEMPLATE > $HOME/$script
fi
local defarg="vi"
local arg=${1:-$defarg}
if [ "$arg" == "vi" ]; then
cmd="vi $HOME/$script"
fi
echo $cmd
eval $cmd
}
VUE(){
: opticks/opticks.bash
local script=.opticks/GEOM/VUE.sh
if [ ! -f "$HOME/$script" ]; then
echo $BASH_SOURCE $FUNCNAME : GENERATE $HOME/$script
VUE_TEMPLATE > $HOME/$script
fi
local defarg="vi"
local arg=${1:-$defarg}
if [ "$arg" == "vi" ]; then
cmd="vi $HOME/$script"
fi
echo $cmd
eval $cmd
}
SDR(){
: opticks/opticks.bash
local script=.opticks/GEOM/SDR.sh
if [ ! -f "$HOME/$script" ]; then
echo $BASH_SOURCE $FUNCNAME : GENERATE $HOME/$script
SDR_TEMPLATE > $HOME/$script
fi
local defarg="vi"
local arg=${1:-$defarg}
if [ "$arg" == "vi" ]; then
cmd="vi $HOME/$script"
fi
echo $cmd
eval $cmd
}
CUR(){
: opticks/opticks.bash
local script=.opticks/GEOM/CUR.sh
if [ ! -f "$HOME/$script" ]; then
echo $BASH_SOURCE $FUNCNAME : GENERATE $HOME/$script
CUR_TEMPLATE > $HOME/$script
fi
local defarg="vi"
local arg=${1:-$defarg}
if [ "$arg" == "vi" ]; then
cmd="vi $HOME/$script"
fi
echo $cmd
eval $cmd
}
ALL(){
vi $HOME/.opticks/GEOM/*.sh
}
CTX(){
: opticks/opticks.bash
local script=$HOME/.opticks/CTX/CTX.sh
if [ ! -f "$script" ]; then
echo $BASH_SOURCE $FUNCNAME : GENERATE $script
mkdir -p $(dirname $script)
CTX_TEMPLATE > $script
fi
source $script
local defarg="vi"
local arg=${1:-$defarg}
local vars="FUNCNAME defarg arg args script CTX"
if [ "$arg" == "vi" ]; then
cmd="vi $script"
elif [ "$arg" == "info" ]; then
for var in $vars ; do printf "%30s : %s \n" "$var" "${!var}" ; done
cmd="echo -n"
else
cmd="echo expecting arg to be one of $args not $arg"
fi
echo $cmd
eval $cmd
}
TEST(){
: opticks/opticks.bash
local script=$HOME/.opticks/TEST/TEST.sh
if [ ! -f "$script" ]; then
echo $BASH_SOURCE $FUNCNAME : GENERATE $script
mkdir -p $(dirname $script)
TEST_TEMPLATE > $script
fi
source $script
local defarg="vi"
local arg=${1:-$defarg}
local vars="FUNCNAME defarg arg args script TEST"
if [ "$arg" == "vi" ]; then
cmd="vi $script"
elif [ "$arg" == "info" ]; then
for var in $vars ; do printf "%30s : %s \n" "$var" "${!var}" ; done
cmd="echo -n"
else
cmd="echo expecting arg to be one of $args not $arg"
fi
echo $cmd
eval $cmd
}
GEOM(){
: opticks/opticks.bash GEOM vi/grab/scp
local script=.opticks/GEOM/GEOM.sh
if [ ! -f "$HOME/$script" ]; then
echo $BASH_SOURCE $FUNCNAME : GENERATE $HOME/$script
GEOM_TEMPLATE > $HOME/$script
fi
source $HOME/$script
#base=.opticks/GEOM/$GEOM
local _CFB=${GEOM}_CFBaseFromGEOM
local CFB=${!_CFB}
local args="vi/grab/get/tmpget/tmp/scp/top/lock/unlock/cf/ss/st/std/ppd/psd/origin/source/help/info"
local GEOMDIR
if [ -n "$CFB" ]; then
GEOMDIR=$CFB
else
local geombase=$HOME/.opticks/GEOM
local GEOMBASE=${GEOMBASE:-$geombase}
GEOMDIR=$HOME/.opticks/GEOM/$GEOM
fi
local CFDIR=$GEOMDIR/CSGFoundry
local ggeo=/tmp/$USER/opticks/GGeo
local tmpbase=${TMP:-/tmp/$USER/opticks}
local tmp=$tmpbase/GEOM/$GEOM
local defarg="vi"
local arg=${1:-$defarg}
local vars="FUNCNAME defarg arg args script geombase GEOMBASE GEOM GEOMDIR CFDIR tmpbase tmp"
if [ "$arg" == "vi" ]; then
cmd="vi $HOME/$script"
elif [ "$arg" == "ex" ]; then
cmd="source $HOME/$script"
elif [ "$arg" == "grab" -o "$arg" == "get" ]; then
cmd="source $OPTICKS_HOME/bin/rsync.sh $GEOMDIR"
elif [ "$arg" == "tmpget" ]; then
cmd="source $OPTICKS_HOME/bin/rsync.sh $tmp"
elif [ "$arg" == "tmp" ]; then
cmd="cd $tmp"
elif [ "$arg" == "scp" ]; then
cmd="scp $HOME/$script P:$script"
elif [ "$arg" == "base" ]; then
cmd="cd $GEOMBASE"
elif [ "$arg" == "top" ]; then
cmd="cd $GEOMDIR"
elif [ "$arg" == "lock" ]; then
cmd="chmod -R ugo-w $GEOMDIR"
elif [ "$arg" == "unlock" ]; then
cmd="chmod -R u+w $GEOMDIR"
elif [ "$arg" == "cf" ]; then
cmd="cd $GEOMDIR/CSGFoundry"
elif [ "$arg" == "ss" ]; then
cmd="cd $GEOMDIR/CSGFoundry/SSim"
elif [ "$arg" == "st" ]; then
cmd="cd $GEOMDIR/CSGFoundry/SSim/stree"
elif [ "$arg" == "std" ]; then
cmd="cd $GEOMDIR/CSGFoundry/SSim/stree/standard"
elif [ "$arg" == "ppd" ]; then
cmd="cd $GEOMDIR/CSGFoundry/SSim/extra/jpmt/PMTParamData"
elif [ "$arg" == "psd" ]; then
cmd="cd $GEOMDIR/CSGFoundry/SSim/extra/jpmt/PMTSimParamData"
elif [ "$arg" == "origin" ]; then
cmd="cd $GEOMDIR ; vim -R origin.gdml"
elif [ "$arg" == "source" ]; then
cmd="source $HOME/.opticks/GEOM/GEOM.sh"
elif [ "$arg" == "help" ]; then
cmd="GEOM_help"
elif [ "$arg" == "info" ]; then
for var in $vars ; do printf "%30s : %s \n" "$var" "${!var}" ; done
cmd="echo -n"
else
cmd="echo expecting arg to be one of $args not $arg"
fi
echo $cmd
eval $cmd
}
o(){ opticks- ; cd $(opticks-home) ; git status ; : opticks.bash ; }
oo(){ opticks- ; cd $(opticks-home) ; om- ; om-- ; : opticks.bash ; }
os(){ opticks- ; cd $(opticks-home) ; ls -alst *.sh ; : opticks.bash ; }
on(){ cd $(opticks-home)/notes ; ls -lt | head -10 ; echo https://bitbucket.org/simoncblyth/opticks/src/master/notes/$(ls -t | head -1) ; }
onn(){ cd $(opticks-home)/notes ; ls -lt | head -100 ; }
on1(){ : opticks.bash ; opticks-;opticks-notes-cd ; ls -lt *.rst | head -30 ; vi $(ls -1t *.rst | head -1) ; }
on2(){ : opticks.bash ; opticks-;opticks-notes-cd ; ls -lt *.rst | head -30 ; vi $(ls -1t *.rst | head -2 | tail -1) ; }
on100(){ : opticks.bash ; opticks-;opticks-notes-cd ; ls -lt *.rst | head -100 ; }
oi(){ cd $(opticks-home)/notes/issues ; ls -lt | head -10 ; echo https://bitbucket.org/simoncblyth/opticks/src/master/notes/issues/$(ls -t | head -1) ; }
oii(){ cd $(opticks-home)/notes/issues ; ls -lt | head -100 ; }
oi1(){ : opticks.bash ; opticks-;opticks-issues-cd ; ls -lt *.rst | head -30 ; vi $(ls -1t *.rst | head -1) ; }
oi2(){ : opticks.bash ; opticks-;opticks-issues-cd ; ls -lt *.rst | head -30 ; vi $(ls -1t *.rst | head -2 | tail -1) ; }
oi100(){ : opticks.bash ; opticks-;opticks-issues-cd ; ls -lt *.rst | head -100 ; }
cu(){ local cu ; date ; for cu in *.cu ; do echo touch $cu && touch $cu ; done ; ls -l *.cu ; }
bst(){ cd $(opticks-home)/examples/Geant4/BoundaryStandalone ; }
sgs(){ cd $(opticks-home)/examples/Geant4/ScintGenStandalone ; }
yst(){ cd $(opticks-home)/examples/Geant4/RayleighStandalone ; }
oot(){ oo ; opticks-t ; : opticks.bash ; }
t(){ typeset -f $* ; : opticks.bash ; }
rc(){ local RC=$?; echo RC $RC; return $RC ; : opticks.bash ; }
eo(){ env | grep =INFO ; }
geom(){
: opticks/opticks.bash
: NB this is distinct from geom_ bash function
local path=$HOME/.opticks/GEOM.txt
local script=$HOME/opticks/bin/GEOM.sh
if [ "$1" == "scp" ]; then
scp $path P:.opticks/
else
vi $path $script ;
fi
}
com_(){
: opticks/opticks.bash
local path0=$(opticks-home)/bin/COMMON.sh
local path1=$(opticks-home)/bin/GEOM_.sh
local path2=$(opticks-home)/bin/OPTICKS_INPUT_PHOTON.sh
local path3=$(opticks-home)/bin/OPTICKS_INPUT_PHOTON_.sh
vi $path0 $path1 $path2 $path3
}
geom_(){
: opticks/opticks.bash
local path=$(opticks-home)/bin/GEOM_.sh
if [ "$1" == "scp" ]; then
scp $path P:opticks/bin/
elif [ "$1" == "source" ]; then
source $path
else
vi $path ;
fi
}
geomlist_(){
: opticks/opticks.bash
local path=$(opticks-home)/bin/geomlist.sh
if [ "$1" == "scp" ]; then
scp $path P:opticks/bin/
elif [ "$1" == "source" ]; then
source $path
else
vi $path ;
fi
}
oip(){
: opticks/opticks.bash
local path=$(opticks-home)/bin/OPTICKS_INPUT_PHOTON.sh
local path_=$(opticks-home)/bin/OPTICKS_INPUT_PHOTON_.sh
if [ "$1" == "scp" ]; then
scp ${path} P:opticks/bin/
scp ${path_} P:opticks/bin/
elif [ "$1" == "source" ]; then
source $path
else
vi ${path_} ${path} ;
fi
}
fold(){
: opticks/opticks.bash
local path=$(opticks-home)/bin/AB_FOLD.sh
vi $path
}
opticks-hash(){ git -C $(dirname $BASH_SOURCE) rev-parse --short HEAD ; }
opticks-source(){ echo $BASH_SOURCE ; }
opticks-ldir(){ echo $(dirname $BASH_SOURCE) ; }
opticks-vi(){ vi $(opticks-source) ; }
opticks-help(){ opticks-usage ; }
opticks-usage(){ cat << \EOU
OPTICKS BASH FUNCTIONS
========================
*opticks-docs-remote*
open browser on the remote html documentation
https://simoncblyth.bitbucket.io/opticks/index.html
*opticks-docs*
open browser on the local html documentation
*opticks-docs-make*
sphinx-build the docs
*opticks-notes*
open browser on the local html development notes
*opticks-notes-make*
sphinx-build the notes
Most Opticks development notes are kept in the env repository,
use start from
env-;opticksdev-;opticksdev-vi
EOU
}
opticks-env(){
: opticks.bash
# dont pollute : otherwise will get infinite loops : as opticks is used in many other -env
. $(opticks-ldir)/externals/externals.bash ## just precursors
. $(opticks-ldir)/integration/integration.bash ## just precursors
}
opticks-env-info(){
cat << EOI
uname : $(uname -a)
HOME : $HOME
VERBOSE : $VERBOSE
USER : $USER
EOI
env | grep OPTICKS
}
opticks-metadata-export()
{
onvidia-
onvidia-export
}
olocal-()
{
echo -n # transitional standin for olocal-
}
opticks-home-default(){ echo $(dirname $(opticks-source)) ; }
opticks-home(){ echo ${OPTICKS_HOME:-$(opticks-home-default)} ; } ## input from profile
opticks-name(){ basename $(opticks-home) ; }
opticks-fold(){ echo $(dirname $(opticks-home)) ; }
opticks-tboolean-shortcuts(){
: **simulate** : aligned bi-simulation creating OK+G4 events
ts(){ LV=$1 tboolean.sh ${@:2} ; }
: **visualize** : load events and visualize the propagation
tv(){ LV=$1 tboolean.sh --load ${@:2} ; }
: **visualize** the geant4 propagation
tv4(){ LV=$1 tboolean.sh --load --vizg4 ${@:2} ; }
: **analyse interactively** : load events and analyse the propagation in ipython
ta(){ LV=$1 tboolean.sh --ip ${@:2} ; }
: **analyse** : load events and run python analysis script the propagation
tp(){ LV=$1 tboolean.sh --py ${@:2} ; }
}
opticks-user-home(){ echo ${OPTICKS_USER_HOME:-$HOME} ; }
opticks-sharedcache-prefix-default(){ echo $(opticks-user-home)/.opticks ; }
opticks-usercache-prefix-default(){ echo $(opticks-user-home)/.opticks ; }
opticks-geocache-prefix(){ echo ${OPTICKS_GEOCACHE_PREFIX:-$(opticks-sharedcache-prefix-default)} ; }
opticks-rngcache-prefix(){ echo ${OPTICKS_RNGCACHE_PREFIX:-$(opticks-sharedcache-prefix-default)} ; }
opticks-usercache-prefix(){ echo ${OPTICKS_USERCACHE_PREFIX:-$(opticks-usercache-prefix-default)} ; }
opticks-geocachedir(){ echo $(opticks-geocache-prefix)/geocache ; }
opticks-rngcachedir(){ echo $(opticks-rngcache-prefix)/rngcache ; }
opticks-rngdir(){ echo $(opticks-rngcachedir)/RNG ; }
opticks-rngdir-cd(){ cd $(opticks-rngdir) ; }
opticks-cache-info(){ cat << EON
$FUNCNAME
=====================
opticks-prefix : $(opticks-prefix)
opticks-installcachedir : $(opticks-installcachedir)
OPTICKS_GEOCACHE_PREFIX : $OPTICKS_GEOCACHE_PREFIX
OPTICKS_RNGCACHE_PREFIX : $OPTICKS_RNGCACHE_PREFIX
OPTICKS_USERCACHE_PREFIX : $OPTICKS_USERCACHE_PREFIX
opticks-sharedcache-prefix-default : $(opticks-sharedcache-prefix-default)
opticks-geocache-prefix : $(opticks-geocache-prefix)
opticks-rngcache-prefix : $(opticks-rngcache-prefix)