File indexing completed on 2026-04-09 07:48:46
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 ana-rel(){ echo ana ; }
0021 ana-src(){ echo ana/ana.bash ; }
0022 ana-source(){ echo ${BASH_SOURCE:-$(opticks-home)/$(ana-src)} ; }
0023 ana-vi(){ vi $(ana-source) ; }
0024 ana-usage(){ cat << \EOU
0025
0026 ana : Opticks Analysis Scripts
0027 =================================
0028
0029
0030 Issue : analysis machinery expects a geocache
0031 ---------------------------------------------------
0032
0033 ::
0034
0035 simon:analytic blyth$ ip
0036 Python 2.7.11 (default, Dec 5 2015, 23:51:51)
0037 ...
0038 IPython profile: g4opticks
0039 args: /opt/local/bin/ipython
0040 Invalid/missing IDPATH envvar /usr/local/opticks/opticksdata/export/DayaBay_VGDX_20140414-1300/g4_00.96ff965744a2f6b78c24e33c80d3a4cd.dae
0041 An exception has occurred, use %tb to see the full traceback.
0042
0043 SystemExit: 1
0044
0045 To exit: use 'exit', 'quit', or Ctrl-D.
0046
0047 In [1]:
0048
0049
0050
0051 FUNCTION `ana-t`
0052 ------------------
0053
0054 After running `tests-t` all the below "MISSING EVT" should become "OK"::
0055
0056 simon:ana blyth$ ana-t
0057 == __init__.py == -> 0 OK
0058 == ana.py == -> 101 MISSING EVT
0059 == base.py == -> 0 OK
0060 == boundary.py == -> 0 OK
0061 == cfg4_speedplot.py == -> 0 OK
0062 == cfplot.py == -> 0 OK
0063 == cie.py == SKIP
0064 == dbgseed.py == -> 101 MISSING EVT
0065 == droplet.py == -> 0 OK
0066 == evt.py == -> 0 OK
0067 == fresnel.py == -> 0 OK
0068 == g4gun.py == -> 101 MISSING EVT
0069 == genstep.py == -> 0 OK
0070 == geometry.py == -> 0 OK
0071 == histype.py == -> 0 OK
0072 == material.py == -> 0 OK
0073 == mattype.py == -> 0 OK
0074 == mergedmesh.py == -> 0 OK
0075 == metadata.py == -> 0 OK
0076 == nbase.py == -> 0 OK
0077 == ncensus.py == -> 0 OK
0078 == nload.py == -> 0 OK
0079 == ox.py == -> 0 OK
0080 == planck.py == -> 0 OK
0081 == prism_spectrum.py == -> 101 MISSING EVT
0082 == proplib.py == -> 0 OK
0083 == seq.py == -> 0 OK
0084 == sphere.py == -> 101 MISSING EVT
0085 == tbox.py == -> 101 MISSING EVT
0086 == tevt.py == -> 101 MISSING EVT
0087 == tmeta.py == -> 0 OK
0088 == tpmt.py == -> 101 MISSING EVT
0089 == tpmt_distrib.py == -> 101 MISSING EVT
0090 == tpmt_skimmer.py == -> 101 MISSING EVT
0091 == tprism.py == -> 101 MISSING EVT
0092 == trainbow.py == -> 101 MISSING EVT
0093 == treflect.py == -> 101 MISSING EVT
0094 == twhite.py == -> 101 MISSING EVT
0095 == xrainbow.py == -> 0 OK
0096
0097
0098
0099 PMT Tests
0100 ------------
0101
0102 :doc:`tpmt`
0103 Compare Opticks and Geant4 photon bounce histories for simple PMT in box of mineral oil geometry,
0104 see :doc:`../tests/tpmt`
0105
0106 :doc:`tpmt_distrib`
0107 Compare Opticks and Geant4 photon distributions for simple PMT in box of mineral oil geometry
0108
0109 :doc:`tpmt_skimmer`
0110 Plotting and tabulating mean step by step positions of all photons with specific step histories
0111 such as "TO BT BT SA"
0112
0113
0114 BoxInBox tests
0115 ------------------
0116
0117 :doc:`tbox`
0118 BoxInBox Opticks vs Geant4 history sequence comparisons analogous to **tpmt.py**
0119 see :doc:`../tests/tbox`
0120
0121 **tboxlaser.py**
0122 Looks like simple event comparison, without using AB/CF etc..
0123 TODO: use the generic AB machinery to do the same
0124
0125
0126 Rainbow Tests
0127 ---------------
0128
0129 :doc:`trainbow`
0130 Rainbow scattering angle comparison between Opticks and Geant4,
0131 see :doc:`../tests/trainbow`
0132
0133 **xrainbow.py**
0134 Rainbow expectations with classes XRainbow and XFrac
0135
0136 **droplet.py**
0137 geometry calculation of spherical drop incident, refracted,
0138 deviation angles for k orders of rainbow corresponding to different numbers
0139 of internal reflections
0140
0141 **sphere.py**
0142 SphereReflect intersection, polarization calculation and spatial plot
0143
0144
0145 Scatter Tests
0146 ---------------
0147
0148 **rayleigh.py**
0149 Without selection scatter distrib plots from arrays created by:
0150
0151 optixrap/tests/ORayleighTest.cc
0152 cfg4/tests/OpRayleighTest.cc
0153
0154
0155 Source Tests
0156 --------------
0157
0158 :doc:`twhite`
0159 Compare wavelength spectrum from :doc:`../tests/twhite` against analytic Planck distribution
0160
0161 **planck.py**
0162 Planck black body formula : CDF technique dev, plotting
0163
0164
0165 Full Geometry Tests
0166 ----------------------
0167
0168 **tdefault.py**
0169 tests within default full geometry, using CF (older than the AB/CFH machinery?)
0170
0171 **tdefault_distrib.py**
0172 tests within default full geometry, using cf,cfplot
0173
0174 **tlaser.py**
0175 okg4 comparisons manually using Evt (not the newer AB)
0176
0177 **tlaser_distrib.py**
0178 okg4 comparisons using CF (not the newer CFH)
0179
0180
0181 Analytic/NCSG Geometry tests
0182 -----------------------------
0183
0184 **analytic_boundary_dbg.py**
0185 analysis of photon_buffer written by oxrap/cu/generate.cu:tracetest
0186
0187 TODO: rename, too special case to share name with tboolean-
0188
0189 **tgltf.py**
0190 Shakedown analytic geometry, with analytic geometry transform access
0191
0192 Concentric Tests : idealised spherical DYB AD
0193 ----------------------------------------------
0194
0195 **tconcentric.py**
0196 comparison using AB, with scatter polarization debug/plotting
0197 see tconcentric-i
0198
0199 **tconcentric_distrib.py**
0200 comparison histo mass production with
0201 see tconcentric-d
0202
0203
0204 Lens/Prism Tests
0205 ------------------
0206
0207 **tlens.py**
0208 Single Evt dumping, no comparisons
0209
0210 **tprism.py**
0211 Comparison of simulation with analytic expectations for deviation angle vs incident angle,
0212 see :doc:`../tests/tprism`
0213
0214 **prism_spectrum.py**
0215 Compare ggv-newton evts with PrismExpected
0216
0217
0218 Reflection Tests
0219 -------------------
0220
0221 **treflect.py**
0222 comparison of simulated S and P absolute reflection with Fresnel formula
0223 see :doc:`../tests/treflect`
0224
0225 **fresnel.py**
0226 analytic reflection expectations from Fresnel formula
0227
0228
0229 G4Gun Tests
0230 --------------
0231
0232 :doc:`g4gun`
0233 Load single G4Gun event
0234
0235
0236 Geometry Infrastructure
0237 -------------------------
0238
0239 :doc:`material`
0240 Material class gives access to geocache material properties
0241
0242 :doc:`boundary`
0243 Boundary class acts as holder of inner/outer materials and surfaces
0244
0245 :doc:`proplib`
0246 Access to geocache via PropLib
0247
0248 **bnd.py**
0249 testing PropLib usage to access material and surface properties
0250
0251 :doc:`mergedmesh`
0252 Access geometrical data such as positions, transforms of volumes of the geometry
0253
0254 **geometry.py**
0255 Shape, Ray, Plane, Intersect, IntersectFrame : simple intersect calulations
0256
0257
0258
0259 Event Comparison Infrastructure
0260 -----------------------------------
0261
0262 **tokg4.py**
0263 loads evt pair and compares at Evt level
0264
0265 **ab.py**
0266 event pair comparison with AB class. Used by cfh.py, cfplot.py, tconcentric.py, tconcentric_distrib.py
0267
0268 **abstat.py**
0269 history table slicing, selection. Used by ab.py, cfh.py
0270
0271 **make_rst_table.py**
0272 pure python utility used by ab.py abstat.py
0273
0274 **cf.py**
0275 Sliced history CF spawning.
0276 Used by tdefault.py tdefault_distrib.py tlaser_distrib.py tpmt_distrib.py
0277
0278 **decompression.py**
0279 Deco : utils for re-binning domain compressed values that avoid binning artifacts
0280
0281 Used from : ab.py cf.py
0282
0283
0284 **cfh.py**
0285 CFH : persistable comparison histograms and chi2, with random access via path specification
0286
0287 ipython -i $(which cfh.py) -- /tmp/blyth/opticks/CFH/concentric/1/TO_BT_BT_BT_BT_SA/0/X
0288
0289 Used from : ab.py cf.py cfhload.py cfplot.py tconcentric.py
0290
0291 **cfhload.py**
0292 Testing cfh.py CFH
0293
0294 **ctx.py**
0295 Ctx : Utility providing conversions between various ways of addressing comparison histograms
0296
0297 Used from : ab.py cfh.py evt.py
0298
0299
0300 Event Infrastructure
0301 -----------------------
0302
0303 :doc:`tevt`
0304 Loads single event and dumps constituent array dimensions and photon history tables
0305
0306 **evt.py**
0307 loads event data : used by many ~30 other scripts
0308
0309 **tmeta.py**
0310 loads and dumps a single events metadata
0311
0312 tmeta.py --det tboolean-torus --tag 1
0313
0314
0315 **base.py**
0316 internal envvar setup based on input envvar IDPATH
0317 json and ini loading with Abbrev and ItemList classes
0318
0319 **ok.py**
0320 test of opticks_main arg parsing/defaults
0321
0322 **enum.py**
0323 parsing C++ enum into python dict. Used by base.py
0324
0325 **nload.py**
0326 numpy array and .ini metadata loading with clases A, I, II
0327
0328 **ox.py**
0329 load just final photons, testing nload and arg parsing
0330
0331 **ph.py**
0332 load ph photon seqhis, dumping progressing SeqAna sequences
0333
0334
0335 **nbase.py**
0336 pure numpy utility functions: count_unique, count_unique_sorted, chi2, decompression_bins
0337
0338 **seq.py**
0339 SeqType conversions of long integer sequence codes to abbreviation string sequences like "TO BT BR BR BT SA"
0340 SeqTable presenting frequencies of different sequences
0341
0342 Used by : evt.py hismask.py histype.py mattype.py
0343
0344 **histype.py**
0345 HisType (SeqType subclass) and tests of history table formation and dumping.
0346 Used by ab.py cf.py evt.py seq.py. With entry point::
0347
0348 histype.py --det tboolean-torus --tag -1 --src torch
0349
0350 **hismask.py**
0351 converts seqhis into a mask, not the usual sequence : used by evt.py pflags.py
0352
0353
0354 **mattype.py**
0355 MatType (SeqType subclass) and tests
0356
0357 **genstep.py**
0358 fit genstep xyz vs time, to obtain parametric eqn for the viewpoint tracking
0359 used to create videos, see `vids-`
0360
0361 **genstep_merge.py**
0362 combine Cerenkov and scintillation gensteps in natural ones
0363
0364
0365 **ana.py**
0366 geometrical and plotting utils
0367
0368 **OpticksQuery.py**
0369 analog of okc/OpticksQuery.cc geometry selection string parsing available from opticks_main args.query
0370
0371
0372
0373 Plotting Infrastructure
0374 --------------------------
0375
0376 **cfplot.py**
0377 Comparison Plotter with Chi2 Underplot
0378
0379
0380 Metadata Infrastructure
0381 --------------------------
0382
0383 **cfg4_speedplot.py**
0384 compare simulation times using json metadata written by Opticks simulation invokations
0385
0386 **metadata.py**
0387 access metadata .json written by Opticks allowing
0388 comparisons of evt digests and simulation times
0389
0390 **ncensus.py**
0391 event census looking across many events with array shape dumping
0392
0393
0394 Color Infrastructure
0395 ----------------------
0396
0397 **cie.py**
0398 converts wavelength spectra into XYZ and RGB colorspace (depends on **env** repo)
0399
0400
0401
0402 EOU
0403 }
0404
0405 ana-notes(){ cat << EON
0406
0407 DEBUGGING SCRIPTS : NOT SURFACING THESE IN THE DOCS
0408 ------------------------------------------------------
0409
0410 types.py
0411 MOSTLY DEPRECATED : INSTEAD USE histype mattype ETC
0412
0413 analytic_cf_triangulated.py
0414 plotting analytic PMT and mesh points together
0415
0416 nopstep_viz_debug.py
0417 creates fake nopstep (non-photon step) for visualization debugging
0418
0419 mm_buffer.py
0420 debugging mesh buffer structure
0421
0422
0423 dae.py
0424 simple XML COLLADA parsing of .dae for debugging
0425
0426 xmatlib.py
0427 COLLADA XML material properties access for debugging
0428
0429 groupvel.py
0430 debug in progress
0431
0432 genstep_sequence_material_mismatch.py
0433 dbg
0434
0435 CGDMLDetector.py
0436 access to global transforms obtained from GDMLDetector
0437
0438 instancedmergedmesh.py
0439 debugging of instanced mesh info such as PMT meshes
0440
0441 vacuum_offset.py
0442 geometry debug, the sagging vacuum
0443
0444 IndexerTest.py
0445 debug small GPU CPU indexing differences
0446
0447 polarization.py
0448 checking magnitude of polarization for Opticks and G4 rainbow events
0449
0450 ana.py
0451 misc old analysis funcs. Used from tprism.py, treflect.py
0452
0453 cf5d.py
0454 5d Proplib comparison (dev code ?)
0455
0456 dat.py
0457 Dat : For interactive exploration of dimension > 3 arrays
0458
0459 dbgseed.py
0460 old dev script used from oks-dbgseed
0461
0462 gltf.py
0463 dev exploration of precision of transforms parsed from GLTF geometry json files
0464
0465 gs.py
0466 example of pure numpy dumping of opticks buffers
0467
0468 nodelib.py
0469 check analytic and triangulates LVNames, PVNames lists
0470
0471 old_cfplot.py
0472 looks ancient
0473
0474 pflags.py
0475 debugging inconsistent pflags in CFG4 evt
0476
0477 seqmat.py
0478 debugging seqmat mismatch, zeros.
0479
0480 truncation.py
0481 pseudo duplication of oxrap/cu/generate.cu for easy thinking about truncation
0482 and thinking about seqhis steered propagations
0483
0484
0485
0486 EON
0487 }
0488 ana-env(){
0489 olocal-
0490 opticks-
0491 }
0492 ana-sdir(){ echo $(opticks-home)/ana ; }
0493 ana-cd(){ cd $(ana-sdir); }
0494
0495 ana-py-(){
0496 ana-cd
0497 ls -1 *.py
0498 }
0499
0500 ana-skips-note(){ cat << EON
0501 *ana-skips*
0502 list .py scripts without executable bit set.
0503
0504 Known fails, for example due to *env* repo dependency
0505 can be skipped from ana-test simply by removing
0506 the executable bit::
0507
0508 chmod ugo-x cie.py
0509
0510 EON
0511 }
0512 ana-skips(){
0513 local py
0514 ana-py- | while read py ; do
0515 [ ! -x $py ] && echo $msg SKIP $py
0516 done
0517 }
0518
0519 ana-t-note(){ cat << EON
0520 *ana-t*
0521 runs all executable .py in ana directory,
0522 stopping at any script that yields a return code
0523 that is not zero or 101
0524
0525 Return code 101 is used to signal missing simulated evts
0526
0527 Use to check for simple python breakages from moving
0528 things around for example.
0529
0530 Intended to just test mechanics, not meaning.
0531 Failure to load events should not cause failures, just warnings.
0532 EON
0533 }
0534
0535 ana-t-rcm()
0536 {
0537 case $1 in
0538 0) echo OK ;;
0539 101) echo MISSING EVT ;;
0540 *) echo PY FAIL ;;
0541 esac
0542 }
0543
0544 ana-t(){
0545 local py
0546 local rc
0547 local rcm
0548 ana-cd
0549 ana-py- | while read py ; do
0550
0551 printf "== %30s == " $msg $py
0552
0553 [ ! -x $py ] && printf " SKIP\n" && continue
0554
0555 ./$py > /dev/null 2>&1
0556 rc=$?
0557 rcm="$(ana-t-rcm $rc)"
0558 printf " -> %4s %s \n" $rc "$rcm"
0559
0560 if [ "$rc" == "0" -o "$rc" == "101" ]; then
0561 echo -n
0562 else
0563 echo $msg WARNING : PY FAILURE OF $py : RC $rc
0564 break
0565 fi
0566 done
0567 }
0568
0569
0570 ana-shim(){
0571 ana-cd
0572 local py
0573 local rst
0574 local name
0575 ls -1 t*.py | while read py ; do
0576 rst=${py/.py}.rst
0577 if [ ! -f "$rst" ]; then
0578 echo $msg writing rst shim $rst shim
0579 ana-shim- $py > $rst
0580 fi
0581 done
0582 }
0583
0584 ana-shim-(){ cat << EOR
0585
0586 .. include:: ${1:-dummy}
0587 :start-after: """
0588 :end-before: """
0589
0590 EOR
0591 }
0592
0593
0594 ana-pyref-(){ ana-usage | perl -n -e "m,(\w*\.py), && print \"\$1\n\"" | uniq ; }
0595 ana-pyref(){
0596 ana-cd
0597 local py
0598 ana-pyref- | while read py ; do
0599 [ ! -f "$py" ] && echo $msg bad pyref $py
0600 printf " py %30s \n" $py
0601 done
0602 }
0603
0604 ana-docref-(){ ana-usage | perl -n -e "m,:doc:\`(.*)\`, && print \"\$1\n\"" | uniq ; }
0605 ana-docref(){
0606 ana-cd
0607 local doc
0608 local rst
0609 ana-docref- | while read doc ; do
0610 rst=$doc.rst
0611 [ ! -f "$rst" ] && echo $msg BAD DOC REF $rst
0612 printf " doc %30s rst %30s \n" $doc $rst
0613 done
0614 }
0615
0616 ana-usage-refcheck-note(){ cat << EON
0617 **ana-usage-refcheck**
0618 check **ana-usage** for broken py and doc references
0619 EON
0620 }
0621 ana-usage-refcheck()
0622 {
0623 ana-pyref
0624 ana-docref
0625 }
0626
0627
0628 ana-rstcheck()
0629 {
0630 ana-cd
0631 local rst
0632 local py
0633 grep -l include:: *.rst | grep -v index.rst | while read rst ; do
0634 py=${rst/.rst}.py
0635 [ ! -f "$py" ] && echo $msg dud include $rst
0636 done
0637
0638 }
0639
0640
0641
0642
0643 ana-mod-ls-()
0644 {
0645 ana-cd
0646 ls -1 *.py
0647 }
0648
0649 ana-mod-from()
0650 {
0651 local module
0652 ana-mod-ls- | while read module
0653 do
0654 ana-mod-from- ${module/.py}
0655 done
0656 }
0657
0658 ana-mod-from-()
0659 {
0660 local msg="=== $FUNCNAME : "
0661 local module=${1:-cf}
0662
0663 echo $msg module $module used from :
0664 ana-cd
0665 $FUNCNAME- $module
0666 }
0667
0668 ana-mod-from--()
0669 {
0670 grep -l from\ opticks.ana.${1:-cf}\ *.py
0671 }