Back to home page

EIC code displayed by LXR

 
 

    


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

0001 #!/bin/bash 
0002 usage(){ cat << EOU
0003 sreport.sh : summarize SEvt metadata into eg ALL0_sreport SREPORT_FOLD 
0004 ========================================================================
0005 
0006 The natural directory from which to use sreport is the run folder 
0007 (aka the LOGDIR) which is one level above the event folders. 
0008 In this way the subfolders "A000,A001,.." correspond to each event. 
0009 
0010 The output NPFold and summary NPFold from several scripts are managed 
0011 by this sreport.sh script. 
0012 
0013 +-----------------------------------------+---------------+
0014 |  bash script that creates SEvt NPFold   |   JOB tags    |      
0015 +=========================================+===============+
0016 | ~/opticks/CSGOptiX/cxs_min.sh           |  N3           |
0017 +-----------------------------------------+---------------+
0018 | ~/opticks/g4cx/tests/G4CXTest_GEOM.sh   |  N2,N4        |
0019 +-----------------------------------------+---------------+
0020 | ~/j/okjob.sh + ~/j/jok.bash             |  L1,N1        |
0021 +-----------------------------------------+---------------+
0022 
0023 ::
0024 
0025    ~/opticks/sysrap/tests/sreport.sh
0026 
0027    DEV=1 ~/opticks/sysrap/tests/sreport.sh
0028        ## Using DEV=1 does local build, faster than CMake build.
0029        ## Its good to do this while changing NP.hh/NPX.h/NPFold.h 
0030        ## metadata handling 
0031 
0032 
0033    JOB=N3 ~/opticks/sysrap/tests/sreport.sh           ## summarize SEvt folders
0034    JOB=N3 ~/opticks/sysrap/tests/sreport.sh grab      ## from remote to local 
0035    JOB=N3 ~/opticks/sysrap/tests/sreport.sh ana       ## local plotting 
0036 
0037 
0038    JOB=N7 ~/o/sreport.sh desc_info
0039    JOB=A7 ~/o/sreport.sh desc_info
0040 
0041 
0042 
0043    PLOT=Substamp_ONE_Delta PICK=A ~/o/sreport.sh
0044    PLOT=Substamp_ONE_Delta PICK=B ~/o/sreport.sh
0045 
0046    PLOT=Substamp_ONE_Etime PICK=A ~/o/sreport.sh
0047    PLOT=Substamp_ONE_Etime PICK=B ~/o/sreport.sh
0048    
0049    PLOT=Substamp_ONE_maxb_scan PICK=A ~/o/sreport.sh
0050    PLOT=Substamp_ONE_maxb_scan PICK=B ~/o/sreport.sh
0051 
0052    PLOT=Ranges_ONE ~/o/sreport.sh
0053    PLOT=Ranges_SPAN ~/o/sreport.sh
0054 
0055    PLOT=Substamp_ALL_Etime_vs_Photon ~/o/sreport.sh
0056    PLOT=Substamp_ALL_Hit_vs_Photon   ~/o/sreport.sh
0057    PLOT=Substamp_ALL_RATIO_vs_Photon ~/o/sreport.sh
0058 
0059    PLOT=Subprofile_ONE PICK=A ~/o/sreport.sh
0060    PLOT=Subprofile_ONE PICK=B ~/o/sreport.sh
0061  
0062    PLOT=Subprofile_ALL ~/o/sreport.sh
0063    PLOT=Runprof_ALL    ~/o/sreport.sh    
0064 
0065 
0066 
0067 
0068 **JOB**
0069    selects the output and summary folders of various scripts
0070 
0071 **build**
0072    standalone build of the sreport binary, CAUTION the binary is also built 
0073    and installed by the standard "om" build 
0074 
0075 **run**  
0076    sreport loads the SEvt subfolders "A000" "A001" "B000" "B001" etc beneath 
0077    the invoking directory in NoData(metadata only) mode and 
0078    writes a summary NPFold into SREPORT_FOLD directory 
0079    
0080    NB DEV=1 uses the standalone binary built by this script, and 
0081    not defining DEV uses the CMake standardly built and installed sreport binary 
0082 
0083 **grab**
0084    grab command just rsyncs the summary SREPORT_FOLD back to laptop for 
0085    metadata plotting without needing to transfer the potentially 
0086    large SEvt folders. 
0087 
0088 **ana**
0089    python plotting using ~/opticks/sysrap/tests/sreport.py::
0090 
0091        substamp=1 ~/opticks/sysrap/tests/sreport.sh ana 
0092        subprofile=1 ~/opticks/sysrap/tests/sreport.sh ana 
0093 
0094 
0095 **mpcap**
0096    capture plot screenshots::
0097 
0098        PLOT=Substamp_ONE_maxb_scan PICK=A ~/opticks/sreport.sh        ## display plot form one tab
0099        PLOT=Substamp_ONE_maxb_scan PICK=A ~/opticks/sreport.sh mpcap  ## capture from another
0100        PLOT=Substamp_ONE_maxb_scan PICK=A PUB=some_anno ~/opticks/sreport.sh mppub  ## publish 
0101 
0102 
0103 Note that *sreport* executable can be used without this script 
0104 by invoking it from appropriate directories, examples are shown below.
0105 
0106 Invoking Directory 
0107    /data/blyth/opticks/GEOM/J23_1_0_rc3_ok0/CSGOptiXSMTest/ALL0
0108 Summary "SREPORT_FOLD" Directory 
0109    /data/blyth/opticks/GEOM/J23_1_0_rc3_ok0/CSGOptiXSMTest/ALL0_sreport
0110 
0111 
0112 Debugging::
0113 
0114    JOB=N7 DEV=1 ~/o/sysrap/tests/sreport.sh
0115 
0116 EOU
0117 }
0118 
0119 IDIR=$(pwd)
0120 cd $(dirname $(realpath $BASH_SOURCE))
0121 source dbg__.sh 
0122 SDIR=$(pwd)
0123 # sreport does different things depending on the invoking directory : so caution with cd
0124 
0125 
0126 name=sreport
0127 src=$SDIR/$name.cc
0128 script=$SDIR/$name.py
0129 
0130 dev=0
0131 DEV=${DEV:-$dev}  ## set to 1 to standalone build the sreport binary before use
0132 if [ "$DEV" = "0" ]; then
0133     bin=$name                                   ## standard binary 
0134     defarg="run_info_ana"
0135 else
0136     bin=${TMP:-/tmp/$USER/opticks}/$name/$name    ## standalone binary
0137     #defarg="build_run_info_ana"
0138     defarg="build_run_info_noa"
0139 fi
0140 
0141 [ -n "$PLOT" ] && defarg="ana"
0142 [ -n "$BP" ] && defarg="dbg"
0143 
0144 arg=${1:-$defarg}
0145 
0146 
0147 if [ "$bin" == "$name" ]; then
0148     echo $BASH_SOURCE : using standard CMake built and installed binary 
0149 else
0150     mkdir -p $(dirname $bin)
0151 fi
0152 
0153 source $HOME/.opticks/GEOM/GEOM.sh 
0154 
0155 #job=N5
0156 #job=S5
0157 #job=Y1
0158 #job=N7   
0159 #job=N8   
0160 job=N9   
0161 #job=A7   
0162 #job=S7  
0163 
0164 JOB=${JOB:-$job}
0165 LAB="Undefined"
0166 
0167 DIR=unknown 
0168 case $JOB in 
0169   L1) DIR=/hpcfs/juno/junogpu/blyth/tmp/GEOM/$GEOM/jok-tds/ALL0 ;;
0170   N1) DIR=/data/blyth/opticks/GEOM/$GEOM/jok-tds/ALL0 ;;
0171   N2) DIR=/data/blyth/opticks/GEOM/$GEOM/G4CXTest/ALL0 ;;
0172   N4) DIR=/data/blyth/opticks/GEOM/$GEOM/G4CXTest/ALL2 ;;
0173   N5) DIR=/data/blyth/opticks/GEOM/$GEOM/G4CXTest/ALL3 ;;   ## blyth:Debug 
0174   S5) DIR=/data/simon/opticks/GEOM/$GEOM/G4CXTest/ALL3 ;;   ## simon:Release TODO 
0175 
0176   N3) DIR=/data/blyth/opticks/GEOM/$GEOM/CSGOptiXSMTest/ALL2 ;;
0177   N6) DIR=/data/blyth/opticks/GEOM/$GEOM/CSGOptiXSMTest/ALL3 ;;
0178   N7) DIR=/data/blyth/opticks/GEOM/$GEOM/CSGOptiXSMTest/ALL1 ; LAB="TITAN RTX : Debug" ;; 
0179   N8) DIR=/data/blyth/opticks/GEOM/J_2024nov27/CSGOptiXSMTest/ALL1_Debug_Philox_large_evt ; LAB="TITAN RTX" ;; 
0180   N9) DIR=/data/blyth/opticks/GEOM/J_2024nov27/CSGOptiXSMTest/ALL1_Debug_Philox_vlarge_evt ; LAB="TITAN RTX" ;;
0181   A7) DIR=/data1/blyth/tmp/GEOM/$GEOM/CSGOptiXSMTest/ALL1    ; LAB="Ada RTX 5000 : Debug" ;;
0182   S7) DIR=/data/simon/opticks/GEOM/$GEOM/CSGOptiXSMTest/ALL1 ; LAB="TITAN RTX : Release" ;; 
0183 
0184   Y1) DIR=/tmp/ihep/opticks/GEOM/$GEOM/jok-tds/ALLLUT_1_ENE_-1_OIM_1_GUN_5 ;; ## 'yuxiang': Release TODO
0185   II) DIR=$IDIR  ;;
0186 esac
0187 
0188 export STEM=${JOB}_${PLOT}_${PICK}
0189 export SREPORT_FOLD=${DIR}_${name}   ## SREPORT_FOLD is output directory used by binary, export it for python 
0190 export MODE=2                        ## 2:matplotlib plotting 
0191 
0192 
0193 #export NPFold__subfold_summary_DEBUG=1
0194 #export NPFold__subprofile_DUMP=1
0195 
0196 
0197 vars="0 BASH_SOURCE arg defarg DEV bin script SDIR JOB LAB DIR SREPORT_FOLD MODE name STEM PLOT PICK"
0198 
0199 if [ "${arg/info}" != "$arg" ]; then
0200     for var in $vars ; do printf "%25s : %s \n" "$var" "${!var}" ; done 
0201 fi 
0202 
0203 if [ "${arg/build}" != "$arg" ]; then 
0204     gcc $src -g -std=c++11 -lstdc++ -I$SDIR/.. -o $bin 
0205     [ $? -ne 0 ] && echo $BASH_SOURCE : build error && exit 1
0206 fi
0207 
0208 
0209 if [ "${arg/dbg}" != "$arg" ]; then 
0210     cd $DIR
0211     [ $? -ne 0 ] && echo $BASH_SOURCE : NO SUCH DIRECTORY : JOB  $JOB DIR $DIR && exit 0 
0212 
0213     dbg__ $bin
0214     [ $? -ne 0 ] && echo $BASH_SOURCE : dbg error && exit 3
0215 fi
0216 
0217 if [ "${arg/run}" != "$arg" ]; then   ## create report from SEvt metadata
0218     cd $DIR
0219     [ $? -ne 0 ] && echo $BASH_SOURCE : NO SUCH DIRECTORY : JOB  $JOB DIR $DIR && exit 0 
0220     $bin
0221     [ $? -ne 0 ] && echo $BASH_SOURCE : run error && exit 3
0222 fi
0223 
0224 if [ "${arg/desc}" != "$arg" ]; then   ## load existing report and present it 
0225     cd $SREPORT_FOLD
0226     [ $? -ne 0 ] && echo $BASH_SOURCE : NO SUCH DIRECTORY : JOB  $JOB DIR $DIR SREPORT_FOLD $SREPORT_FOLD  && exit 0 
0227     $bin
0228     [ $? -ne 0 ] && echo $BASH_SOURCE : desc error && exit 3
0229 fi
0230 
0231 
0232 if [ "${arg/grab}" != "$arg" ]; then 
0233     echo $BASH_SOURCE : grab SREPORT_FOLD $SREPORT_FOLD 
0234     source $OPTICKS_HOME/bin/rsync.sh $SREPORT_FOLD
0235     [ $? -ne 0 ] && echo $BASH_SOURCE : grab error && exit 4
0236 fi
0237 
0238 if [ "${arg/noa}" != "$arg" ]; then 
0239     echo $BASH_SOURCE : noa : no analysis exit 
0240     exit 0
0241 fi
0242 
0243 if [ "${arg/ana}" != "$arg" ]; then 
0244     export COMMANDLINE="JOB=$JOB PLOT=$PLOT ~/o/sreport.sh"
0245     ${IPYTHON:-ipython} --pdb -i $script
0246     [ $? -ne 0 ] && echo $BASH_SOURCE : ana error && exit 3
0247 fi
0248 
0249 if [ "${arg/info}" != "$arg" ]; then
0250     for var in $vars ; do printf "%25s : %s \n" "$var" "${!var}" ; done 
0251 fi 
0252 
0253 if [ "$arg" == "mpcap" -o "$arg" == "mppub" ]; then
0254     export CAP_BASE=$SREPORT_FOLD/figs
0255     export CAP_REL=cxs_min
0256     export CAP_STEM=$STEM
0257     case $arg in  
0258        mpcap) source mpcap.sh cap  ;;  
0259        mppub) source mpcap.sh env  ;;  
0260     esac
0261     if [ "$arg" == "mppub" ]; then 
0262         source epub.sh 
0263     fi  
0264 fi 
0265 
0266 exit 0 
0267