Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:19:43

0001 #!/bin/bash
0002 
0003 MYINSTALL=""
0004 # MYINSTALL="/sphenix/user/jbertaux/MYINSTALL"
0005 
0006 # One-liner to get location of this shell script
0007 # PWD=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)
0008 PWD="."
0009 
0010 INTT_FORMAT="/sphenix/lustre01/sphnxpro/physics/INTT/%s/%s_intt%d-%08d-*"
0011 
0012 # Intermediate variable to hold file lists
0013 # Given unique names to prevent conflicts if multiple jobs are run simultaneously
0014 # Removed before the shell script exits to avoid unnecessary buildup of files
0015 INTT_LIST="${PWD}/lst/run_%08d_intt%01d.list"
0016 
0017 # Output--can be set relative to the $(pwd) or given absolute paths
0018 # If any are unset, those outputs are not produced
0019 HOTMAP_CDB_FORMAT="${PWD}/hotmap_cdb/hotmap_run_%08d.root"
0020 HOTMAP_PNG_FORMAT="${PWD}/hotmap_png/hotmap_run_%08d.png"
0021 
0022 BCOMAP_CDB_FORMAT="${PWD}/bcomap_cdb/bcomap_run_%08d.root"
0023 BCOMAP_PNG_FORMAT="${PWD}/bcomap_png/bcomap_run_%08d.png"
0024 
0025 RUN_NUM=""         # required
0026 NUM_EVT="200000"   # default if argument 2 is empty
0027 RUN_TYPE="physics" # default if argument 3 is empty
0028 
0029 show_help()
0030 {
0031 cat << EOF
0032 
0033         usage:
0034                 $0 [run number] [num events (optional)] [run type (optional)]
0035         The default for [num events] is ${NUM_EVT}
0036         The default for [run type] is ${RUN_TYPE}
0037         For older runs, you may need to set [run type] as "beam" (and specify [num events])
0038 
0039 EOF
0040 }
0041 
0042 # Arguments
0043 if [[ $# -lt 1 || $1 == "-h" || $1 == "--help" ]]; then
0044         show_help
0045         exit 0
0046 fi
0047 
0048 if [[ -n "$1" ]]; then
0049         RUN_NUM="$1"
0050 fi
0051 
0052 if [[ -n "$2" ]]; then
0053         NUM_EVT="$2"
0054 fi
0055 
0056 if [[ -n "$3" ]]; then
0057         RUN_TYPE="$3"
0058 fi
0059 
0060 # Custom MYINSTALL for developement/debugging purposes
0061 source /opt/sphenix/core/bin/sphenix_setup.sh -n new
0062 if [ -n "${MYINSTALL}" ] && [ -d "${MYINSTALL}" ]; then
0063         source /opt/sphenix/core/bin/setup_local.sh ${MYINSTALL}
0064 fi
0065 
0066 for FLX_SVR in $(seq 0 7); do
0067         printf -v LIST ${INTT_LIST} ${RUN_NUM} ${FLX_SVR}
0068         printf -v FILE ${INTT_FORMAT} ${RUN_TYPE} ${RUN_TYPE} ${FLX_SVR} ${RUN_NUM}
0069         mkdir -p $(dirname ${LIST})
0070         ls -1 ${FILE} > ${LIST} 2>/dev/null
0071 done
0072 
0073 # Output
0074 printf -v HOTMAP_CDB_FILE ${HOTMAP_CDB_FORMAT} ${RUN_NUM}
0075 mkdir -p $(dirname ${HOTMAP_CDB_FILE})
0076 printf -v HOTMAP_PNG_FILE ${HOTMAP_PNG_FORMAT} ${RUN_NUM}
0077 mkdir -p $(dirname ${HOTMAP_PNG_FILE})
0078 
0079 printf -v BCOMAP_CDB_FILE ${BCOMAP_CDB_FORMAT} ${RUN_NUM}
0080 mkdir -p $(dirname ${BCOMAP_CDB_FILE})
0081 printf -v BCOMAP_PNG_FILE ${BCOMAP_PNG_FORMAT} ${RUN_NUM}
0082 mkdir -p $(dirname ${BCOMAP_PNG_FILE})
0083 
0084 # Macro
0085 root -q -b "${PWD}/macro.C(${RUN_NUM}, ${NUM_EVT}, \"${INTT_LIST}\", \"${HOTMAP_CDB_FILE}\", \"${HOTMAP_PNG_FILE}\", \"${BCOMAP_CDB_FILE}\", \"${BCOMAP_PNG_FILE}\")"
0086 # gdb -ex run --args root.exe "${PWD}/macro.C(${RUN_NUM}, ${NUM_EVT}, \"${INTT_LIST}\", \"${HOTMAP_CDB_FILE}\", \"${HOTMAP_PNG_FILE}\", \"${BCOMAP_CDB_FILE}\", \"${BCOMAP_PNG_FILE}\")"
0087 EXIT_VALUE="$?"
0088 
0089 # Remove list files after finishing
0090 for FLX_SVR in $(seq 0 7); do
0091         printf -v LIST ${INTT_LIST} ${RUN_NUM} ${FLX_SVR}
0092         rm -f ${LIST}
0093 done
0094 
0095 exit ${EXIT_VALUE}