diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index e6193da..7d130c6 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -40,4 +40,4 @@ jobs: - name: ShellCheck run: | - find scripts -name "*.sh" | sort | xargs shellcheck --severity=warning + find scripts -name "*.sh" | sort | xargs shellcheck --severity=info diff --git a/scripts/ANALYSIS.anasum.sh b/scripts/ANALYSIS.anasum.sh index d3edba0..84be27b 100755 --- a/scripts/ANALYSIS.anasum.sh +++ b/scripts/ANALYSIS.anasum.sh @@ -2,7 +2,7 @@ # script to analyse data files with anasum # qsub parameters -# shellcheck disable=SC2034 +# shellcheck disable=SC2034 # SGE resource directives, read by job scheduler h_cpu=8:00:00; h_vmem=4000M; tmpdir_size=10G if [[ $# -lt 3 ]]; then @@ -37,8 +37,7 @@ exit fi # Run init script -bash "$(dirname "$0")/helper_scripts/UTILITY.script_init.sh" -[[ $? != "0" ]] && exit 1 +bash "$(dirname "$0")/helper_scripts/UTILITY.script_init.sh" || exit 1 # Parse command line arguments FLIST=$1 @@ -55,7 +54,7 @@ if [[ ! -f "$FLIST" ]]; then fi # Check that run parameter file exists -if [[ "$RUNP" == `basename $RUNP` ]]; then +if [[ "$RUNP" == $(basename "$RUNP") ]]; then RUNP="$VERITAS_EVNDISP_AUX_DIR/ParameterFiles/$RUNP" fi if [[ ! -f "$RUNP" ]]; then @@ -64,7 +63,7 @@ if [[ ! -f "$RUNP" ]]; then fi # directory for run scripts -DATE=`date +"%y%m%d"` +DATE=$(date +"%y%m%d") LOGDIR="$VERITAS_USER_LOG_DIR/$DATE/ANASUM.ANADATA" echo -e "Log files will be written to:\n $LOGDIR" mkdir -p "$LOGDIR" @@ -76,7 +75,7 @@ mkdir -p "$ODIR" # Job submission script SUBSCRIPT="$(dirname "$0")/helper_scripts/ANALYSIS.anasum_sub" -TIMETAG=`date +"%s"` +TIMETAG=$(date +"%s") FSCRIPT="$LOGDIR/ANA.$ONAME-$(date +%s)" sed -e "s|FILELIST|$FLIST|" \ @@ -90,13 +89,14 @@ echo "$FSCRIPT.sh" SUBC=$("$(dirname "$0")/helper_scripts/UTILITY.readSubmissionCommand.sh") # run locally or on cluster (expand shell variables in submission string) -SUBC=`eval "echo \"$SUBC\""` +SUBC=$(eval "echo \"$SUBC\"") if [[ $SUBC == *"ERROR"* ]]; then echo "$SUBC" exit fi if [[ $SUBC == *qsub* ]]; then - JOBID=`$SUBC $FSCRIPT.sh` + # shellcheck disable=SC2086 + JOBID=$($SUBC "$FSCRIPT".sh) # account for -terse changing the job number format if [[ $SUBC != *-terse* ]] ; then @@ -106,11 +106,12 @@ if [[ $SUBC == *qsub* ]]; then echo "RUN $AFILE JOBID $JOBID" elif [[ $SUBC == *condor* ]]; then "$(dirname "$0")/helper_scripts/UTILITY.condorSubmission.sh" "$FSCRIPT.sh" "$h_vmem" "$tmpdir_size" - condor_submit $FSCRIPT.sh.condor + condor_submit "$FSCRIPT".sh.condor elif [[ $SUBC == *parallel* ]]; then - echo "$FSCRIPT.sh &> $FSCRIPT.log" >> $LOGDIR/runscripts.$TIMETAG.dat - cat $LOGDIR/runscripts.$TIMETAG.dat | $SUBC + echo "$FSCRIPT.sh &> $FSCRIPT.log" >> "$LOGDIR"/runscripts."$TIMETAG".dat + # shellcheck disable=SC2086 + cat "$LOGDIR"/runscripts."$TIMETAG".dat | $SUBC elif [[ $SUBC == *simple* ]]; then - "$FSCRIPT.sh" |& tee $FSCRIPT.log + "$FSCRIPT.sh" |& tee "$FSCRIPT".log fi diff --git a/scripts/ANALYSIS.anasum_allcuts.sh b/scripts/ANALYSIS.anasum_allcuts.sh index 850e8e6..3bf912c 100755 --- a/scripts/ANALYSIS.anasum_allcuts.sh +++ b/scripts/ANALYSIS.anasum_allcuts.sh @@ -28,8 +28,8 @@ EPOCH="${3:-V6}" IGNORETYPE="IGNOREACCEPTANCE" # set this to zero to force reprocessing SKIPIFPROCESSED="1" -EDVERSION=$(cat $VERITAS_EVNDISP_AUX_DIR/IRFMINORVERSION) -EDMAJORVERSION=$(cat $VERITAS_EVNDISP_AUX_DIR/IRFVERSION) +EDVERSION=$(cat "$VERITAS_EVNDISP_AUX_DIR"/IRFMINORVERSION) +EDMAJORVERSION=$(cat "$VERITAS_EVNDISP_AUX_DIR"/IRFVERSION) # anasum file are writing into this directory TMPDIR="$VERITAS_DATA_DIR/tmp/${EDVERSION}/${VERITAS_ANALYSIS_TYPE:0:2}/" @@ -47,12 +47,12 @@ if [[ ${RUNTYPE} == "PRECUTS" ]]; then fi PREDIR="$VERITAS_PREPROCESSED_DATA_DIR/${VERITAS_ANALYSIS_TYPE:0:2}/mscw/" -echo $PREDIR +echo "$PREDIR" echo "TMP $TMPDIR" # temporary file for output TMPLOG="$(pwd)/anasum.submit.$(uuidgen).tmp.txt" -rm -f ${TMPLOG} +rm -f "${TMPLOG}" for C in $CUTS do @@ -61,19 +61,19 @@ do if [[ $RUNTYPE == "PRECUTS" ]]; then CDIR=$(echo "$CDIR" | sed -E 's/anasum_(NTel[23])([A-Za-z]+)Pre/\1-\2/') fi - echo $CDIR + echo "$CDIR" mkdir -p "$TMPDIR/${CDIR}" - "$(dirname "$0")/ANALYSIS.anasum_parallel_from_runlist.sh" ${RUNL} \ + "$(dirname "$0")/ANALYSIS.anasum_parallel_from_runlist.sh" "${RUNL}" \ "$TMPDIR/${CDIR}" \ - ${C} \ + "${C}" \ ${IGNORETYPE} \ - $VERITAS_EVNDISP_AUX_DIR/ParameterFiles/ANASUM.runparameter \ - $PREDIR $SKIPIFPROCESSED | tee -a ${TMPLOG} + "$VERITAS_EVNDISP_AUX_DIR"/ParameterFiles/ANASUM.runparameter \ + "$PREDIR" $SKIPIFPROCESSED | tee -a "${TMPLOG}" elif [[ $RUNTYPE == "V2DL3" ]]; then mkdir -p "$TMPDIR/v2dl3_${C}" - "$(dirname "$0")/ANALYSIS.v2dl3.sh" ${RUNL} \ + "$(dirname "$0")/ANALYSIS.v2dl3.sh" "${RUNL}" \ "$TMPDIR/v2dl3_${C}" \ - ${C} | tee -a ${TMPLOG} + "${C}" | tee -a "${TMPLOG}" else echo "Error: unknown run type $RUNTYPE (allowed: ANASUM, V2DL3, or PRECUTS)" exit @@ -84,5 +84,5 @@ echo echo "====================================================================" echo "JOB SUBMISSION" echo "====================================================================" -grep -A 1 "Job submission using HTCondor" ${TMPLOG} | sort -r -u -rm -f ${TMPLOG} +grep -A 1 "Job submission using HTCondor" "${TMPLOG}" | sort -r -u +rm -f "${TMPLOG}" diff --git a/scripts/ANALYSIS.anasum_combine.sh b/scripts/ANALYSIS.anasum_combine.sh index c4b196a..60fe9de 100755 --- a/scripts/ANALYSIS.anasum_combine.sh +++ b/scripts/ANALYSIS.anasum_combine.sh @@ -2,7 +2,7 @@ # script to combine anasum files processed in parallel mode # qsub parameters -# shellcheck disable=SC2034 +# shellcheck disable=SC2034 # SGE resource directives, read by job scheduler h_cpu=0:59:00; h_vmem=12000M; tmpdir_size=150G if [[ $# -lt 3 ]]; then @@ -39,9 +39,8 @@ fi # Run init script if [ ! -n "$EVNDISP_APPTAINER" ]; then - bash "$( cd "$( dirname "$0" )" && pwd )/helper_scripts/UTILITY.script_init.sh" + bash "$( cd "$( dirname "$0" )" && pwd )/helper_scripts/UTILITY.script_init.sh" || exit 1 fi -[[ $? != "0" ]] && exit 1 # Parse command line arguments RUNLIST=$1 @@ -57,7 +56,7 @@ if [[ ! -f "$RUNLIST" ]]; then fi # Check that run parameter file exists -if [[ "$RUNP" == `basename $RUNP` ]]; then +if [[ "$RUNP" == $(basename "$RUNP") ]]; then RUNP="$VERITAS_EVNDISP_AUX_DIR/ParameterFiles/$RUNP" fi if [[ ! -f "$RUNP" ]]; then @@ -66,7 +65,7 @@ if [[ ! -f "$RUNP" ]]; then fi # directory for run scripts -DATE=`date +"%y%m%d"` +DATE=$(date +"%y%m%d") LOGDIR="$VERITAS_USER_LOG_DIR/ANASUM.COMBINE-${DATE}-$(uuidgen)" mkdir -p "$LOGDIR" echo -e "Log files will be written to:\n $LOGDIR" @@ -74,7 +73,7 @@ echo -e "Log files will be written to:\n $LOGDIR" # Job submission script SUBSCRIPT="$(dirname "$0")/helper_scripts/ANALYSIS.anasum_combine_sub" -FSCRIPT="$LOGDIR/anasum_combine-$DATE-RUN$RUN-$(date +%s)" +FSCRIPT="$LOGDIR/anasum_combine-$DATE-$(basename "$OUTFILE")-$(date +%s)" echo "Run script written to $FSCRIPT" # Check that anasum output files exist before combining @@ -94,13 +93,14 @@ chmod u+x "$FSCRIPT.sh" # run locally or on cluster SUBC=$("$(dirname "$0")/helper_scripts/UTILITY.readSubmissionCommand.sh") -SUBC=`eval "echo \"$SUBC\""` +SUBC=$(eval "echo \"$SUBC\"") if [[ $SUBC == *"ERROR"* ]]; then echo "$SUBC" exit fi if [[ $SUBC == *qsub* ]]; then - JOBID=`$SUBC $FSCRIPT.sh` + # shellcheck disable=SC2086 + JOBID=$($SUBC "$FSCRIPT".sh) # account for -terse changing the job number format if [[ $SUBC != *-terse* ]] ; then echo "without -terse!" # need to match VVVVVVVV 8539483 and 3843483.1-4:2 @@ -108,15 +108,16 @@ if [[ $SUBC == *qsub* ]]; then fi elif [[ $SUBC == *condor* ]]; then "$(dirname "$0")/helper_scripts/UTILITY.condorSubmission.sh" "$FSCRIPT.sh" "$h_vmem" "$tmpdir_size" - condor_submit $FSCRIPT.sh.condor -echo "RUN $RUN JOBID $JOBID" - echo "RUN $RUN SCRIPT $FSCRIPT.sh" + condor_submit "$FSCRIPT".sh.condor +echo "OUTFILE $OUTFILE JOBID $JOBID" + echo "OUTFILE $OUTFILE SCRIPT $FSCRIPT.sh" if [[ $SUBC != */dev/null* ]] ; then - echo "RUN $RUN OLOG $FSCRIPT.sh.o$JOBID" - echo "RUN $RUN ELOG $FSCRIPT.sh.e$JOBID" + echo "OUTFILE $OUTFILE OLOG $FSCRIPT.sh.o$JOBID" + echo "OUTFILE $OUTFILE ELOG $FSCRIPT.sh.e$JOBID" fi elif [[ $SUBC == *sbatch* ]]; then - $SUBC $FSCRIPT.sh + # shellcheck disable=SC2086 + $SUBC "$FSCRIPT".sh elif [[ $SUBC == *parallel* ]]; then echo "$FSCRIPT.sh &> $FSCRIPT.log" >> "$LOGDIR/runscripts.$(date +"%s").dat" elif [[ "$SUBC" == *simple* ]] ; then diff --git a/scripts/ANALYSIS.anasum_link_files.sh b/scripts/ANALYSIS.anasum_link_files.sh index 6cd83b4..720889d 100755 --- a/scripts/ANALYSIS.anasum_link_files.sh +++ b/scripts/ANALYSIS.anasum_link_files.sh @@ -25,8 +25,7 @@ exit fi # Run init script -bash "$(dirname "$0")/helper_scripts/UTILITY.script_init.sh" -[[ $? != "0" ]] && exit 1 +bash "$(dirname "$0")/helper_scripts/UTILITY.script_init.sh" || exit 1 # Parse command line arguments RUNLIST=$1 @@ -40,7 +39,7 @@ if [[ ! -f "$RUNLIST" ]]; then fi # output directory -mkdir -p ${ODIR} +mkdir -p "${ODIR}" # directory schema getNumberedDirectory() { @@ -51,17 +50,17 @@ getNumberedDirectory() else NDIR="${IDIR}/${TRUN:0:2}/" fi - echo ${NDIR} + echo "${NDIR}" } -RUNS=`cat "$RUNLIST"` -NRUNS=`cat "$RUNLIST" | wc -l ` +RUNS=$(cat "$RUNLIST") +NRUNS=$(cat "$RUNLIST" | wc -l ) echo "total number of runs to be linked: $NRUNS" for RUN in "${RUNS[@]}"; do - ARCHIVEDIR=$(getNumberedDirectory $RUN $DDIR) + ARCHIVEDIR=$(getNumberedDirectory "$RUN" "$DDIR") if [ -e "${ARCHIVEDIR}/${RUN}.anasum.root" ]; then - ls ${ARCHIVEDIR}/${RUN}.anasum.root - ln -f -s ${ARCHIVEDIR}/${RUN}.anasum.root ${ODIR}/${RUN}.anasum.root + ls "${ARCHIVEDIR}"/"${RUN}".anasum.root + ln -f -s "${ARCHIVEDIR}"/"${RUN}".anasum.root "${ODIR}"/"${RUN}".anasum.root fi done diff --git a/scripts/ANALYSIS.anasum_parallel_from_runlist.sh b/scripts/ANALYSIS.anasum_parallel_from_runlist.sh index 817d6d0..91e4b97 100755 --- a/scripts/ANALYSIS.anasum_parallel_from_runlist.sh +++ b/scripts/ANALYSIS.anasum_parallel_from_runlist.sh @@ -2,11 +2,11 @@ # script to analyse data files with anasum (parallel analysis) from a simple run list # qsub parameters -# shellcheck disable=SC2034 +# shellcheck disable=SC2034 # SGE resource directives, read by job scheduler h_cpu=0:59:00; h_vmem=4000M; tmpdir_size=1G # EventDisplay version -EDVERSION=$(cat $VERITAS_EVNDISP_AUX_DIR/IRFVERSION) +EDVERSION=$(cat "$VERITAS_EVNDISP_AUX_DIR"/IRFVERSION) IRFVERSION="$EDVERSION" AUXVERSION="auxv01" @@ -62,9 +62,8 @@ fi # Run init script if [ ! -n "$EVNDISP_APPTAINER" ]; then - bash "$( cd "$( dirname "$0" )" && pwd )/helper_scripts/UTILITY.script_init.sh" + bash "$( cd "$( dirname "$0" )" && pwd )/helper_scripts/UTILITY.script_init.sh" || exit 1 fi -[[ $? != "0" ]] && exit 1 # Parse command line arguments RUNLIST=$1 @@ -84,7 +83,7 @@ if [[ ! -z $VERITAS_ANALYSIS_TYPE ]]; then DISPBDT="0" fi fi -echo $VERITAS_ANALYSIS_TYPE $ANATYPE $DISPBDT +echo "$VERITAS_ANALYSIS_TYPE" "$ANATYPE" $DISPBDT # short-cuts for gamma/hadron cuts (note: VX to be replaced later in script) if [[ $CUTS = "moderate2tel" ]] || [[ $CUTS = "BDTmoderate2tel" ]]; then @@ -151,12 +150,12 @@ fi # remove PointSource and ExtendedSource string from cut file name for radial acceptances names if [[ $CUT == *PointSource-* ]] ; then CUTRADACC=${CUT/-PointSource-/"-"} - echo $CUTRACACC + echo "$CUTRADACC" elif [[ $CUT == *"Extended"* ]]; then CUTRADACC=${CUT/-PointSource-/"-"} elif [[ $CUT == *ExtendedSource-* ]]; then CUTRADACC=${CUT/-ExtendedSource-/"-"} - echo $CUTRADACC + echo "$CUTRADACC" fi if [[ $DISPBDT == "1" ]]; then @@ -201,7 +200,7 @@ NRUNS=$(cat "$RUNLIST" | sort -u | wc -l) echo "total number of runs to analyze: $NRUNS" # Check that run parameter file exists -if [[ "$RUNP" == `basename $RUNP` ]]; then +if [[ "$RUNP" == $(basename "$RUNP") ]]; then RUNP="$VERITAS_EVNDISP_AUX_DIR/ParameterFiles/$RUNP" fi if [[ ! -f "$RUNP" ]]; then @@ -210,7 +209,7 @@ if [[ ! -f "$RUNP" ]]; then fi # directory for run scripts -DATE=`date +"%y%m%d"` +DATE=$(date +"%y%m%d") LOGDIR="$VERITAS_USER_LOG_DIR/ANASUM.${CUTS}-${DATE}-$(uuidgen)" mkdir -p "$LOGDIR" echo -e "Log files will be written to:\n $LOGDIR" @@ -221,7 +220,7 @@ mkdir -p "$ODIR" # Job submission script SUBSCRIPT="$(dirname "$0")/helper_scripts/ANALYSIS.anasum_sub" -TIMETAG=`date +"%s"` +TIMETAG=$(date +"%s") # directory schema getNumberedDirectory() @@ -233,7 +232,7 @@ getNumberedDirectory() else ODIR="${IDIR}/${TRUN:0:2}/" fi - echo ${ODIR} + echo "${ODIR}" } @@ -243,7 +242,7 @@ for RUN in "${RUNS[@]}"; do # check if file already has been processed if [[ $SKIP == "1" ]]; then - ARCHIVEDIR="$(getNumberedDirectory $RUN $VERITAS_PREPROCESSED_DATA_DIR/${VERITAS_ANALYSIS_TYPE:0:2}/anasum_${CUTS})" + ARCHIVEDIR="$(getNumberedDirectory "$RUN" "$VERITAS_PREPROCESSED_DATA_DIR"/"${VERITAS_ANALYSIS_TYPE:0:2}"/anasum_"${CUTS}")" if [ -e "${ARCHIVEDIR}/${RUN}.anasum.root" ]; then echo "$RUN already processed (${ARCHIVEDIR}/${RUN}.anasum.root)" echo "skipping run" @@ -255,14 +254,14 @@ for RUN in "${RUNS[@]}"; do TMPINDIR="$INDIR" # check for mscw file if [ ! -e "$TMPINDIR/$RUN.mscw.root" ]; then - TMPINDIR=$(getNumberedDirectory $RUN $INDIR) + TMPINDIR=$(getNumberedDirectory "$RUN" "$INDIR") if [ ! -e "$TMPINDIR/$RUN.mscw.root" ]; then echo "error: mscw file not found: $TMPINDIR/$RUN.mscw.root (also not found in directory above)" - touch $ODIR/$RUN.NOTFOUND + touch "$ODIR"/"$RUN".NOTFOUND continue fi fi - rm -f $ODIR/$RUN.NOTFOUND + rm -f "$ODIR"/"$RUN".NOTFOUND TMPLOGDIR=${LOGDIR} # avoid reaching limits of number of files per @@ -270,9 +269,9 @@ for RUN in "${RUNS[@]}"; do if [[ ${NRUNS} -gt 5000 ]]; then TMPLOGDIR=${LOGDIR}-${RUN:0:1} fi - mkdir -p ${TMPLOGDIR} + mkdir -p "${TMPLOGDIR}" FSCRIPT="$TMPLOGDIR/ANASUM.$RUN-$(date +%s)" - rm -f $FSCRIPT.sh + rm -f "$FSCRIPT".sh echo "Run script written to $FSCRIPT" sed -e "s|FILELIST|NOTDEFINED|" \ @@ -294,13 +293,14 @@ for RUN in "${RUNS[@]}"; do # run locally or on cluster SUBC=$("$(dirname "$0")/helper_scripts/UTILITY.readSubmissionCommand.sh") - SUBC=`eval "echo \"$SUBC\""` + SUBC=$(eval "echo \"$SUBC\"") if [[ $SUBC == *"ERROR"* ]]; then echo "$SUBC" exit fi if [[ $SUBC == *qsub* ]]; then - JOBID=`$SUBC $FSCRIPT.sh` + # shellcheck disable=SC2086 + JOBID=$($SUBC "$FSCRIPT".sh) # account for -terse changing the job number format if [[ $SUBC != *-terse* ]] ; then echo "without -terse!" # need to match VVVVVVVV 8539483 and 3843483.1-4:2 @@ -313,7 +313,8 @@ for RUN in "${RUNS[@]}"; do echo "-------------------------------------------------------------------------------" echo elif [[ $SUBC == *sbatch* ]]; then - $SUBC $FSCRIPT.sh + # shellcheck disable=SC2086 + $SUBC "$FSCRIPT".sh elif [[ $SUBC == *parallel* ]]; then echo "$FSCRIPT.sh &> $FSCRIPT.log" >> "$TMPLOGDIR/runscripts.$TIMETAG.dat" echo "RUN $RUN OLOG $FSCRIPT.log" @@ -324,5 +325,6 @@ done # Execute all FSCRIPTs locally in parallel if [[ $SUBC == *parallel* ]]; then + # shellcheck disable=SC2086 cat "$LOGDIR/runscripts.$TIMETAG.dat" | $SUBC fi diff --git a/scripts/ANALYSIS.dispXGB.sh b/scripts/ANALYSIS.dispXGB.sh index 48ccd6f..5b44564 100755 --- a/scripts/ANALYSIS.dispXGB.sh +++ b/scripts/ANALYSIS.dispXGB.sh @@ -2,7 +2,7 @@ # XGBoost analysis on mscw data files. # qsub parameters -# shellcheck disable=SC2034 +# shellcheck disable=SC2034 # SGE resource directives, read by job scheduler h_cpu=11:59:00; h_vmem=4000M; tmpdir_size=25G if [ "$#" -lt 3 ]; then @@ -46,37 +46,37 @@ else fi # make output directory if it doesn't exist -mkdir -p $ODIR +mkdir -p "$ODIR" echo -e "Output files will be written to:\n $ODIR" # directory for run scripts -DATE=`date +"%y%m%d"` +DATE=$(date +"%y%m%d") LOGDIR="$VERITAS_USER_LOG_DIR/XGB-${XGB_TYPE}-${DATE}-$(uuidgen)/" mkdir -p "$LOGDIR" echo -e "Log files will be written to:\n $LOGDIR" -rm -f ${LOGDIR}/x* 2>/dev/null +rm -f "${LOGDIR}"/x* 2>/dev/null # Job submission script SUBSCRIPT="$(dirname "$0")/helper_scripts/ANALYSIS.dispXGB_sub" -TIMETAG=`date +"%s"` +TIMETAG=$(date +"%s") for RUNN in $FILES do echo "Now analysing run $RUNN" FSCRIPT="$LOGDIR/dispXGB-${XGB_TYPE}-$RUNN" - rm -f $FSCRIPT.sh + rm -f "$FSCRIPT".sh sed -e "s|RRUN|$RUNN|" \ -e "s|XXGB|$XGB|" \ -e "s|XGB_TTYPE|$XGB_TYPE|" \ -e "s|ANALYSISTYPE|$ANALYSIS_TYPE|" \ - -e "s|OODIR|$ODIR|" $SUBSCRIPT.sh > $FSCRIPT.sh + -e "s|OODIR|$ODIR|" "$SUBSCRIPT".sh > "$FSCRIPT".sh chmod u+x "$FSCRIPT.sh" - echo $FSCRIPT.sh + echo "$FSCRIPT".sh SUBC=$("$(dirname "$0")/helper_scripts/UTILITY.readSubmissionCommand.sh") - SUBC=`eval "echo \"$SUBC\""` + SUBC=$(eval "echo \"$SUBC\"") if [[ $SUBC == *condor* ]]; then "$(dirname "$0")/helper_scripts/UTILITY.condorSubmission.sh" "$FSCRIPT.sh" "$h_vmem" "$tmpdir_size" echo @@ -86,9 +86,10 @@ do echo "-------------------------------------------------------------------------------" echo elif [[ $SUBC == *sbatch* ]]; then - $SUBC $FSCRIPT.sh + # shellcheck disable=SC2086 + $SUBC "$FSCRIPT".sh elif [[ $SUBC == *parallel* ]]; then - echo "$FSCRIPT.sh &> $FSCRIPT.log" >> ${LOGDIR}/runscripts.$TIMETAG.dat + echo "$FSCRIPT.sh &> $FSCRIPT.log" >> "${LOGDIR}"/runscripts."$TIMETAG".dat echo "RUN $RUNN OLOG $FSCRIPT.log" elif [[ "$SUBC" == *simple* ]] ; then "$FSCRIPT.sh" |& tee "$FSCRIPT.log" diff --git a/scripts/ANALYSIS.evndisp.sh b/scripts/ANALYSIS.evndisp.sh index fb6772f..ca786bd 100755 --- a/scripts/ANALYSIS.evndisp.sh +++ b/scripts/ANALYSIS.evndisp.sh @@ -2,11 +2,11 @@ # script to run eventdisplay analysis for VTS data # qsub parameters -# shellcheck disable=SC2034 +# shellcheck disable=SC2034 # SGE resource directives, read by job scheduler h_cpu=11:59:00; h_vmem=4000M; tmpdir_size=25G # EventDisplay version -EDVERSION=$(cat $VERITAS_EVNDISP_AUX_DIR/IRFVERSION) +EDVERSION=$(cat "$VERITAS_EVNDISP_AUX_DIR"/IRFVERSION) if [ ! -n "$1" ] || [ "$1" = "-h" ]; then echo " @@ -65,9 +65,8 @@ fi # Run init script if [ ! -n "$EVNDISP_APPTAINER" ]; then - bash "$( cd "$( dirname "$0" )" && pwd )/helper_scripts/UTILITY.script_init.sh" + bash "$( cd "$( dirname "$0" )" && pwd )/helper_scripts/UTILITY.script_init.sh" || exit 1 fi -[[ $? != "0" ]] && exit 1 # create extra stdout for duplication of command output # look for ">&5" below @@ -76,7 +75,7 @@ exec 5>&1 # Parse command line arguments RLIST=$1 [[ "$2" ]] && ODIR=$2 || ODIR="$VERITAS_USER_DATA_DIR/analysis/Results/$EDVERSION/" -mkdir -p $ODIR +mkdir -p "$ODIR" ACUTS_AUTO="EVNDISP.reconstruction.runparameter.AP.v4x" if [[ $VERITAS_ANALYSIS_TYPE = "TS"* ]]; then @@ -99,6 +98,7 @@ fi # VPM is on by default VPM=1 # directory with DB text +# shellcheck disable=SC2153 DBTEXTDIRECTORY="${VERITAS_DATA_DIR}/shared/DBTEXT" # hardwired alternative data directory VERITAS_DATA_DIR_2="/lustre/fs23/group/veritas/data" @@ -110,13 +110,13 @@ if [ ! -f "$RLIST" ] ; then echo "Error, runlist $RLIST not found, exiting..." exit 1 fi -FILES=`cat "$RLIST"` +FILES=$(cat "$RLIST") -NRUNS=`cat "$RLIST" | wc -l ` +NRUNS=$(cat "$RLIST" | wc -l ) echo "total number of runs to analyze: $NRUNS" echo # run scripts are written into this directory -DATE=`date +"%y%m%d"` +DATE=$(date +"%y%m%d") LOGDIR="$VERITAS_USER_LOG_DIR/EVN.${DATE}-$(uuidgen)/" mkdir -p "$LOGDIR" echo -e "Log files will be written to:\n $LOGDIR" @@ -125,10 +125,10 @@ echo -e "Log files will be written to:\n $LOGDIR" SUBSCRIPT="$(dirname "$0")/helper_scripts/ANALYSIS.evndisp_sub" # run locally or on cluster SUBC=$("$(dirname "$0")/helper_scripts/UTILITY.readSubmissionCommand.sh") -SUBC=`eval "echo \"$SUBC\""` +SUBC=$(eval "echo \"$SUBC\"") if [[ $SUBC == *parallel* ]]; then - touch $LOGDIR/runscripts.sh + touch "$LOGDIR"/runscripts.sh fi echo "total number of runs to analyze: $NRUNS" @@ -146,11 +146,11 @@ fi # low gain calibration file for T in Tel_1 Tel_2 Tel_3 Tel_4 do - mkdir -p ${ODIR}/Calibration/${T} + mkdir -p "${ODIR}"/Calibration/${T} done if [[ -e "${VERITAS_EVNDISP_AUX_DIR}/Calibration/calibrationlist.LowGain.dat" ]]; then if [[ ! -e ${ODIR}/Calibration/calibrationlist.LowGain.dat ]]; then - cp -f -v ${VERITAS_EVNDISP_AUX_DIR}/Calibration/calibrationlist.LowGain.dat ${ODIR}/Calibration/ + cp -f -v "${VERITAS_EVNDISP_AUX_DIR}"/Calibration/calibrationlist.LowGain.dat "${ODIR}"/Calibration/ fi else echo "error - low-gain calibration list not found (${VERITAS_EVNDISP_AUX_DIR}/Calibration/calibrationlist.LowGain.dat)" @@ -158,7 +158,7 @@ else fi if [[ -e "${VERITAS_EVNDISP_AUX_DIR}/Calibration/LowGainPedestals.lped" ]]; then if [[ ! -e ${ODIR}/Calibration/LowGainPedestals.lped ]]; then - cp -f -v ${VERITAS_EVNDISP_AUX_DIR}/Calibration/LowGainPedestals.lped ${ODIR}/Calibration/ + cp -f -v "${VERITAS_EVNDISP_AUX_DIR}"/Calibration/LowGainPedestals.lped "${ODIR}"/Calibration/ fi else echo "error - low-gain calibration list not found (${VERITAS_EVNDISP_AUX_DIR}/Calibration/LowGainPedestals.lped)" @@ -192,7 +192,7 @@ do # check if file is on disk if [[ $SKIP == "1" ]]; then - FDISK=$(file_on_disk $FILE) + FDISK=$(file_on_disk "$FILE") if [[ $FDISK == "TRUE" ]]; then echo "RUN $FILE already processed; skipping" continue @@ -253,7 +253,8 @@ do fi if [[ $SUBC == *qsub* ]]; then - JOBID=`$SUBC $FSCRIPT.sh` + # shellcheck disable=SC2086 + JOBID=$($SUBC "$FSCRIPT".sh) # account for -terse changing the job number format if [[ $SUBC != *-terse* ]] ; then echo "without -terse!" # need to match VVVVVVVV 8539483 and 3843483.1-4:2 @@ -275,9 +276,10 @@ do echo "-------------------------------------------------------------------------------" echo elif [[ $SUBC == *sbatch* ]]; then - $SUBC $FSCRIPT.sh + # shellcheck disable=SC2086 + $SUBC "$FSCRIPT".sh elif [[ $SUBC == *parallel* ]]; then - echo "$FSCRIPT.sh" >> $LOGDIR/runscripts.sh + echo "$FSCRIPT.sh" >> "$LOGDIR"/runscripts.sh echo "RUN $FILE OLOG $FSCRIPT.log" elif [[ "$SUBC" == *simple* ]] ; then "$FSCRIPT.sh" | tee "$FSCRIPT.log" @@ -296,12 +298,16 @@ if [[ $SUBC == *parallel* ]]; then echo echo "$LOGDIR/runscripts.sh" echo - chmod +x $LOGDIR/runscripts.sh - echo "echo \"==================================\"" >> Run_me.sh - echo "echo \"List of scripts to run\"" >> Run_me.sh - cat $LOGDIR/runscripts.sh | sort -u | awk "{print \$1}" | sed 's/.*/echo \" & \"/' >> Run_me.sh - echo "cat $LOGDIR/runscripts.sh | sort -u | $SUBC" >> Run_me.sh + chmod +x "$LOGDIR"/runscripts.sh + { + echo "echo \"==================================\"" + echo "echo \"List of scripts to run\"" + cat "$LOGDIR"/runscripts.sh | sort -u | awk "{print \$1}" | sed 's/.*/echo \" & \"/' + # shellcheck disable=SC2086 + echo "cat $LOGDIR/runscripts.sh | sort -u | $SUBC" + } >> Run_me.sh chmod +x Run_me.sh +# shellcheck source=/dev/null source Run_me.sh rm Run_me.sh fi diff --git a/scripts/ANALYSIS.evndisp_laser.sh b/scripts/ANALYSIS.evndisp_laser.sh index 51ccf2f..c5cb6ff 100755 --- a/scripts/ANALYSIS.evndisp_laser.sh +++ b/scripts/ANALYSIS.evndisp_laser.sh @@ -2,7 +2,7 @@ # script run eventdisplay laser analysis with a queue system # qsub parameters -# shellcheck disable=SC2034 +# shellcheck disable=SC2034 # SGE resource directives, read by job scheduler h_cpu=11:29:00; h_vmem=2000M; tmpdir_size=5G if [ ! -n "$1" ] || [ "$1" = "-h" ]; then @@ -33,8 +33,7 @@ exit fi # Run init script -bash "$(dirname "$0")/helper_scripts/UTILITY.script_init.sh" -[[ $? != "0" ]] && exit 1 +bash "$(dirname "$0")/helper_scripts/UTILITY.script_init.sh" || exit 1 CDIR=$(dirname "$0") # Parse command line arguments @@ -47,15 +46,15 @@ if [[ ! -f "$RLIST" ]] ; then echo "Error, runlist $RLIST not found, exiting..." exit 1 fi -RUNNUMS=`cat $RLIST` +RUNNUMS=$(cat "$RLIST") echo "Laser files to analyze:" -echo $RUNNUMS +echo "$RUNNUMS" # Output directory for error/output from batch system -DATE=`date +"%y%m%d"` +DATE=$(date +"%y%m%d") LOGDIR="$VERITAS_USER_LOG_DIR/$DATE/EVNDISP.ANADATA" echo "Log files will be written to: $LOGDIR" -mkdir -p $LOGDIR +mkdir -p "$LOGDIR" # Job submission script SUBSCRIPT="$(dirname "$0")/helper_scripts/ANALYSIS.evndisp_laser_sub" @@ -64,7 +63,7 @@ SUBSCRIPT="$(dirname "$0")/helper_scripts/ANALYSIS.evndisp_laser_sub" # loop over all files in files loop for RUN in $RUNNUMS; do # check if laser file exists - #DFILE=`find -L $VERITAS_DATA_DIR/data/ -name "$RUN.cvbf"` + #DFILE=$(find -L $VERITAS_DATA_DIR/data/ -name "$RUN.cvbf") #if [ -z "$DFILE" ]; then # echo "Error: laser vbf file not found for run $RUN" # continue @@ -83,16 +82,17 @@ for RUN in $RUNNUMS; do sed -e "s|RUNFILE|$RUN|" \ -e "s|TELTOANACOMB|$TELTOANA|" \ -e "s|CURRENTDIR|$CDIR|" \ - -e "s|LOGDIRECTORY|$LOGDIR|" $SUBSCRIPT.sh > $FSCRIPT.sh + -e "s|LOGDIRECTORY|$LOGDIR|" "$SUBSCRIPT".sh > "$FSCRIPT".sh - chmod u+x $FSCRIPT.sh - echo $FSCRIPT.sh + chmod u+x "$FSCRIPT".sh + echo "$FSCRIPT".sh # run locally or on cluster SUBC=$("$(dirname "$0")/helper_scripts/UTILITY.readSubmissionCommand.sh") - SUBC=`eval "echo \"$SUBC\""` + SUBC=$(eval "echo \"$SUBC\"") if [[ $SUBC == *qsub* ]]; then - JOBID=`$SUBC $FSCRIPT.sh` + # shellcheck disable=SC2086 + JOBID=$($SUBC "$FSCRIPT".sh) # account for -terse changing the job number format if [[ $SUBC != *-terse* ]] ; then @@ -103,11 +103,12 @@ for RUN in $RUNNUMS; do echo "RUN $RUN: JOBID $JOBID" elif [[ $SUBC == *condor* ]]; then "$(dirname "$0")/helper_scripts/UTILITY.condorSubmission.sh" "$FSCRIPT.sh" "$h_vmem" "$tmpdir_size" - condor_submit $FSCRIPT.sh.condor + condor_submit "$FSCRIPT".sh.condor elif [[ $SUBC == *sbatch* ]]; then - $SUBC $FSCRIPT.sh + # shellcheck disable=SC2086 + $SUBC "$FSCRIPT".sh elif [[ $SUBC == *parallel* ]]; then - echo "$FSCRIPT.sh &> $FSCRIPT.log" >> $LOGDIR/runscripts.dat + echo "$FSCRIPT.sh &> $FSCRIPT.log" >> "$LOGDIR"/runscripts.dat elif [[ "$SUBC" == *simple* ]] ; then "$FSCRIPT.sh" |& tee "$FSCRIPT.log" fi @@ -115,7 +116,8 @@ done # Execute all FSCRIPTs locally in parallel if [[ $SUBC == *parallel* ]]; then - cat $LOGDIR/runscripts.dat | $SUBC + # shellcheck disable=SC2086 + cat "$LOGDIR"/runscripts.dat | $SUBC fi exit diff --git a/scripts/ANALYSIS.evndisp_muon.sh b/scripts/ANALYSIS.evndisp_muon.sh index f12ea82..30b242e 100755 --- a/scripts/ANALYSIS.evndisp_muon.sh +++ b/scripts/ANALYSIS.evndisp_muon.sh @@ -2,11 +2,11 @@ # script to run eventdisplay analysis for VTS data # qsub parameters -# shellcheck disable=SC2034 +# shellcheck disable=SC2034 # SGE resource directives, read by job scheduler h_cpu=11:59:00; h_vmem=2000M; tmpdir_size=25G # EventDisplay version -EDVERSION=`$EVNDISPSYS/bin/evndisp --version | tr -d .` +EDVERSION=$("$EVNDISPSYS"/bin/evndisp --version | tr -d .) if [ ! -n "$1" ] || [ "$1" = "-h" ]; then # begin help message @@ -66,8 +66,7 @@ exit fi # Run init script -bash "$( cd "$( dirname "$0" )" && pwd )/helper_scripts/UTILITY.script_init.sh" -[[ $? != "0" ]] && exit 1 +bash "$( cd "$( dirname "$0" )" && pwd )/helper_scripts/UTILITY.script_init.sh" || exit 1 # create extra stdout for duplication of command output # look for ">&5" below @@ -76,7 +75,7 @@ exec 5>&1 # Parse command line arguments RLIST=$1 [[ "$2" ]] && ODIR=$2 || ODIR="$VERITAS_USER_DATA_DIR/analysis/Results/$EDVERSION/" -mkdir -p $ODIR +mkdir -p "$ODIR" # Try to use the correct reconstruction runparameters. For V4 and V5 the default is GRISU / SumWindow6-noDISP. if [[ "$SIMTYPE" == "CARE"* ]]; then @@ -109,19 +108,19 @@ if [ ! -f "$RLIST" ] ; then echo "Error, runlist $RLIST not found, exiting..." exit 1 fi -FILES=`cat $RLIST` +FILES=$(cat "$RLIST") # Output directory for error/output -DATE=`date +"%y%m%d"` +DATE=$(date +"%y%m%d") LOGDIR="$VERITAS_USER_LOG_DIR/$DATE/EVNDISP.ANADATA" -mkdir -p $LOGDIR +mkdir -p "$LOGDIR" # Job submission script SUBSCRIPT="$(dirname "$0")/helper_scripts/ANALYSIS.evndisp_sub" -TIMETAG=`date +"%s"` +TIMETAG=$(date +"%s") -NRUNS=`cat $RLIST | wc -l ` +NRUNS=$(cat "$RLIST" | wc -l ) echo "total number of runs to analyze: $NRUNS" echo @@ -140,10 +139,10 @@ do -e "s|TELTOANACOMB|$TELTOANA|" \ -e "s|USECALIBLIST|$CALIBFILE|" \ -e "s|USEMODEL3D|$MODEL3D|" \ - -e "s|EXTRAPARS|\"$EXTRAPARS\"|" $SUBSCRIPT.sh > $FSCRIPT.sh + -e "s|EXTRAPARS|\"$EXTRAPARS\"|" "$SUBSCRIPT".sh > "$FSCRIPT".sh - chmod u+x $FSCRIPT.sh - echo $FSCRIPT.sh + chmod u+x "$FSCRIPT".sh + echo "$FSCRIPT".sh # output selected input during submission: echo "Using runparameter file $VERITAS_EVNDISP_AUX_DIR/ParameterFiles/$ACUTS" @@ -171,9 +170,10 @@ do # run locally or on cluster SUBC=$("$(dirname "$0")/helper_scripts/UTILITY.readSubmissionCommand.sh") - SUBC=`eval "echo \"$SUBC\""` + SUBC=$(eval "echo \"$SUBC\"") if [[ $SUBC == *qsub* ]]; then - JOBID=`$SUBC $FSCRIPT.sh` + # shellcheck disable=SC2086 + JOBID=$($SUBC "$FSCRIPT".sh) # account for -terse changing the job number format if [[ $SUBC != *-terse* ]] ; then echo "without -terse!" # need to match VVVVVVVV 8539483 and 3843483.1-4:2 @@ -188,11 +188,12 @@ do fi elif [[ $SUBC == *condor* ]]; then "$(dirname "$0")/helper_scripts/UTILITY.condorSubmission.sh" "$FSCRIPT.sh" "$h_vmem" "$tmpdir_size" - condor_submit $FSCRIPT.sh.condor + condor_submit "$FSCRIPT".sh.condor elif [[ $SUBC == *sbatch* ]]; then - $SUBC $FSCRIPT.sh + # shellcheck disable=SC2086 + $SUBC "$FSCRIPT".sh elif [[ $SUBC == *parallel* ]]; then - echo "$FSCRIPT.sh &> $FSCRIPT.log" >> $LOGDIR/runscripts.$TIMETAG.dat + echo "$FSCRIPT.sh &> $FSCRIPT.log" >> "$LOGDIR"/runscripts."$TIMETAG".dat echo "RUN $AFILE OLOG $FSCRIPT.log" elif [[ "$SUBC" == *simple* ]] ; then "$FSCRIPT.sh" |& tee "$FSCRIPT.log" @@ -201,7 +202,8 @@ done # Execute all FSCRIPTs locally in parallel if [[ $SUBC == *parallel* ]]; then - cat $LOGDIR/runscripts.$TIMETAG.dat | sort -u | $SUBC + # shellcheck disable=SC2086 + cat "$LOGDIR"/runscripts."$TIMETAG".dat | sort -u | $SUBC fi exit diff --git a/scripts/ANALYSIS.mscw_energy.sh b/scripts/ANALYSIS.mscw_energy.sh index e8d19d4..c0f1272 100755 --- a/scripts/ANALYSIS.mscw_energy.sh +++ b/scripts/ANALYSIS.mscw_energy.sh @@ -2,11 +2,11 @@ # script to analyse data files with lookup tables # qsub parameters -# shellcheck disable=SC2034 +# shellcheck disable=SC2034 # SGE resource directives, read by job scheduler h_cpu=00:29:00; h_vmem=4000M; tmpdir_size=4G # EventDisplay version -EDVERSION=$(cat $VERITAS_EVNDISP_AUX_DIR/IRFVERSION) +EDVERSION=$(cat "$VERITAS_EVNDISP_AUX_DIR"/IRFVERSION) IRFVERSION="$EDVERSION" if [ "$#" -lt 2 ]; then @@ -44,9 +44,8 @@ fi # Run init script if [ ! -n "$EVNDISP_APPTAINER" ]; then - bash "$( cd "$( dirname "$0" )" && pwd )/helper_scripts/UTILITY.script_init.sh" + bash "$( cd "$( dirname "$0" )" && pwd )/helper_scripts/UTILITY.script_init.sh" || exit 1 fi -[[ $? != "0" ]] && exit 1 # create extra stdout for duplication of command output # look for ">&5" below @@ -71,18 +70,18 @@ NRUNS=$(cat "$RUNLIST" | wc -l) echo "total number of runs to analyze: $NRUNS" # make output directory if it doesn't exist -mkdir -p $ODIR +mkdir -p "$ODIR" echo -e "Output files will be written to:\n $ODIR" # directory for run scripts -DATE=`date +"%y%m%d"` +DATE=$(date +"%y%m%d") LOGDIR="$VERITAS_USER_LOG_DIR/MSCW.${DATE}-$(uuidgen)/" mkdir -p "$LOGDIR" echo -e "Log files will be written to:\n $LOGDIR" # Job submission script SUBSCRIPT="$(dirname "$0")/helper_scripts/ANALYSIS.mscw_energy_sub" -TIMETAG=`date +"%s"` +TIMETAG=$(date +"%s") # directory schema getNumberedDirectory() @@ -94,7 +93,7 @@ getNumberedDirectory() else ODIR="${IDIR}/${TRUN:0:2}/" fi - echo ${ODIR} + echo "${ODIR}" } @@ -109,7 +108,7 @@ do if [[ $SKIP == "1" ]]; then TMPDIR="$VERITAS_PREPROCESSED_DATA_DIR/${VERITAS_ANALYSIS_TYPE:0:2}/mscw/" if [[ -d "$TMPDIR" ]]; then - TMPMDIR=$(getNumberedDirectory $RUNN "$TMPDIR") + TMPMDIR=$(getNumberedDirectory "$RUNN" "$TMPDIR") if [ -e "$TMPMDIR/$RUNN.mscw.root" ]; then echo "RUN $RUNN already processed; skipping (FOUND IN $TMPMDIR/$RUNN.mscw.root)" continue @@ -120,7 +119,7 @@ do # EVNDISP file if [ ! -e "$BFILE" ]; then - TMPINDIR=$(getNumberedDirectory $RUNN ${INPUTDIR}) + TMPINDIR=$(getNumberedDirectory "$RUNN" "${INPUTDIR}") if [ ! -e "$TMPINDIR/$RUNN.root" ]; then echo "ERR: File $BFILE does not exist" >> mscw.errors.log continue @@ -134,26 +133,27 @@ do # directory (e.g., on afs) if [[ ${NRUNS} -gt 1000 ]]; then TMPLOGDIR=${LOGDIR}/MSCW_${RUNN:0:1} - mkdir -p ${TMPLOGDIR} + mkdir -p "${TMPLOGDIR}" fi FSCRIPT="$TMPLOGDIR/MSCW.data-ID$ID-$RUNN" - rm -f $FSCRIPT.sh + rm -f "$FSCRIPT".sh sed -e "s|RECONSTRUCTIONID|$ID|" \ -e "s|OUTPUTDIRECTORY|$ODIR|" \ -e "s|BDTDISP|${DISPBDT}|" \ -e "s|VERSIONIRF|${IRFVERSION}|" \ - -e "s|EVNDISPFILE|$BFILE|" $SUBSCRIPT.sh > $FSCRIPT.sh + -e "s|EVNDISPFILE|$BFILE|" "$SUBSCRIPT".sh > "$FSCRIPT".sh chmod u+x "$FSCRIPT.sh" - echo $FSCRIPT.sh + echo "$FSCRIPT".sh # run locally or on cluster SUBC=$("$(dirname "$0")/helper_scripts/UTILITY.readSubmissionCommand.sh") - SUBC=`eval "echo \"$SUBC\""` + SUBC=$(eval "echo \"$SUBC\"") echo "Submission command: $SUBC" if [[ $SUBC == *qsub* ]]; then - JOBID=`$SUBC $FSCRIPT.sh` + # shellcheck disable=SC2086 + JOBID=$($SUBC "$FSCRIPT".sh) # account for -terse changing the job number format if [[ $SUBC != *-terse* ]] ; then echo "without -terse!" # need to match VVVVVVVV 8539483 and 3843483.1-4:2 @@ -175,9 +175,10 @@ do echo "-------------------------------------------------------------------------------" echo elif [[ $SUBC == *sbatch* ]]; then - $SUBC $FSCRIPT.sh + # shellcheck disable=SC2086 + $SUBC "$FSCRIPT".sh elif [[ $SUBC == *parallel* ]]; then - echo "$FSCRIPT.sh &> $FSCRIPT.log" >> ${TMPLOGDIR}/runscripts.$TIMETAG.dat + echo "$FSCRIPT.sh &> $FSCRIPT.log" >> "${TMPLOGDIR}"/runscripts."$TIMETAG".dat echo "RUN $RUNN OLOG $FSCRIPT.log" elif [[ "$SUBC" == *simple* ]] ; then "$FSCRIPT.sh" |& tee "$FSCRIPT.log" @@ -186,7 +187,8 @@ done # Execute all FSCRIPTs locally in parallel if [[ $SUBC == *parallel* ]]; then - cat $TMPLOGDIR/runscripts.$TIMETAG.dat | $SUBC + # shellcheck disable=SC2086 + cat "$TMPLOGDIR"/runscripts."$TIMETAG".dat | $SUBC fi echo "LOG/SUBMIT DIR: ${TMPLOGDIR}" diff --git a/scripts/ANALYSIS.v2dl3.sh b/scripts/ANALYSIS.v2dl3.sh index 9d6b247..de13df8 100755 --- a/scripts/ANALYSIS.v2dl3.sh +++ b/scripts/ANALYSIS.v2dl3.sh @@ -5,7 +5,7 @@ # # qsub parameters -# shellcheck disable=SC2034 +# shellcheck disable=SC2034 # SGE resource directives, read by job scheduler h_cpu=11:59:00; h_vmem=4000M; tmpdir_size=25G if [ "$#" -lt 3 ]; then @@ -47,52 +47,53 @@ echo "total number of runs to analyze: $NRUNS" echo # make output directory if it doesn't exist -mkdir -p $ODIR +mkdir -p "$ODIR" echo -e "Output files will be written to:\n $ODIR" # directory for run scripts -DATE=`date +"%y%m%d"` +DATE=$(date +"%y%m%d") LOGDIR="$VERITAS_USER_LOG_DIR/V2DL3-${DATE}-$(uuidgen)/" mkdir -p "$LOGDIR" echo -e "Log files will be written to:\n $LOGDIR" -rm -f ${LOGDIR}/x* 2>/dev/null +rm -f "${LOGDIR}"/x* 2>/dev/null # split run list into smaller run lists sort -u "${RUNLIST}" -o "${LOGDIR}/$(basename "${RUNLIST}")" -(cd "${LOGDIR}" && split -l $SPLITRUN "${LOGDIR}/$(basename ${RUNLIST})") +(cd "${LOGDIR}" && split -l "$SPLITRUN" "${LOGDIR}/$(basename "${RUNLIST}")") -FILELISTS=$(ls ${LOGDIR}/x*) -NFILELISTS=$(ls ${LOGDIR}/x* | wc -l) +FILELISTS=$(find "$LOGDIR" -maxdepth 1 -name "x*" | sort) +NFILELISTS=$(find "$LOGDIR" -maxdepth 1 -name "x*" | wc -l) echo -e "Processing $NFILELISTS file lists (equal to number of jobs)" # Job submission script SUBSCRIPT="$(dirname "$0")/helper_scripts/ANALYSIS.v2dl3_sub" -TIMETAG=`date +"%s"` +TIMETAG=$(date +"%s") for J in ${FILELISTS} do echo "Submitting analysis for file list $J" - FSCRIPT="$LOGDIR/V2DL3-$(basename $J)" - rm -f $FSCRIPT.sh + FSCRIPT="$LOGDIR/V2DL3-$(basename "$J")" + rm -f "$FSCRIPT".sh echo "Run script written to $FSCRIPT" sed -e "s|RRUNLIST|$J|" \ -e "s|OODIR|$ODIR|" \ - -e "s|CCUT|$CUT|" $SUBSCRIPT.sh > $FSCRIPT.sh + -e "s|CCUT|$CUT|" "$SUBSCRIPT".sh > "$FSCRIPT".sh chmod u+x "$FSCRIPT.sh" # run locally or on cluster SUBC=$("$(dirname "$0")/helper_scripts/UTILITY.readSubmissionCommand.sh") - SUBC=`eval "echo \"$SUBC\""` + SUBC=$(eval "echo \"$SUBC\"") if [[ $SUBC == *"ERROR"* ]]; then echo "$SUBC" exit fi if [[ $SUBC == *qsub* ]]; then - JOBID=`$SUBC $FSCRIPT.sh` + # shellcheck disable=SC2086 + JOBID=$($SUBC "$FSCRIPT".sh) # account for -terse changing the job number format if [[ $SUBC != *-terse* ]] ; then echo "without -terse!" # need to match VVVVVVVV 8539483 and 3843483.1-4:2 @@ -114,7 +115,8 @@ do echo "-------------------------------------------------------------------------------" echo elif [[ $SUBC == *sbatch* ]]; then - $SUBC $FSCRIPT.sh + # shellcheck disable=SC2086 + $SUBC "$FSCRIPT".sh elif [[ $SUBC == *parallel* ]]; then echo "$FSCRIPT.sh &> $FSCRIPT.log" >> "$LOGDIR/runscripts.$TIMETAG.dat" echo "RUN $J OLOG $FSCRIPT.log" @@ -125,5 +127,6 @@ done # Execute all FSCRIPTs locally in parallel if [[ $SUBC == *parallel* ]]; then + # shellcheck disable=SC2086 cat "$LOGDIR/runscripts.$TIMETAG.dat" | $SUBC fi diff --git a/scripts/IRF.combine_effective_area_parts.sh b/scripts/IRF.combine_effective_area_parts.sh index 04ffaec..46bab66 100755 --- a/scripts/IRF.combine_effective_area_parts.sh +++ b/scripts/IRF.combine_effective_area_parts.sh @@ -2,11 +2,11 @@ # combine effective area files into one # job requirements -# shellcheck disable=SC2034 +# shellcheck disable=SC2034 # SGE resource directives, read by job scheduler h_cpu=11:29:00; h_vmem=12000M; tmpdir_size=20G # # EventDisplay version -EDVERSION=$(cat $VERITAS_EVNDISP_AUX_DIR/IRFVERSION) +EDVERSION=$(cat "$VERITAS_EVNDISP_AUX_DIR"/IRFVERSION) if [ $# -lt 5 ]; then echo " @@ -45,9 +45,8 @@ fi # Run init script if [ ! -n "$EVNDISP_APPTAINER" ]; then - bash "$(dirname "$0")/helper_scripts/UTILITY.script_init.sh" + bash "$(dirname "$0")/helper_scripts/UTILITY.script_init.sh" || exit 1 fi -[[ $? != "0" ]] && exit 1 # date used in run scripts / log file directories DATE=$(date +"%y%m%d") @@ -64,7 +63,7 @@ SIMTYPE=$5 [[ "${9}" ]] && UUID=${9} || UUID=${DATE}-$(uuidgen) # Generate EA base file name based on cuts file -CUTS_NAME=`basename $CUTSFILE` +CUTS_NAME=$(basename "$CUTSFILE") CUTS_NAME=${CUTS_NAME##ANASUM.GammaHadron-} CUTS_NAME=${CUTS_NAME%%.dat} @@ -128,24 +127,25 @@ SUBSCRIPT="$(dirname "$0")/helper_scripts/IRF.effective_area_combine_sub" # make run script FSCRIPT="$LOGDIR/COMB-EFFAREA-ID${RECID}-${CUTS_NAME}-ATM${ATMOS}-${EPOCH}-${DISPBDT}-$(date +%s%N)" -rm -f $FSCRIPT.sh +rm -f "$FSCRIPT".sh sed -e "s|INPUTFILES|$INFILES|" \ -e "s|OUTPUTFILE|$OFILE|" \ - -e "s|OUTPUTDIR|$ODIR|" $SUBSCRIPT.sh > $FSCRIPT.sh + -e "s|OUTPUTDIR|$ODIR|" "$SUBSCRIPT".sh > "$FSCRIPT".sh chmod u+x "$FSCRIPT.sh" echo "Run script written to: $FSCRIPT" # run locally or on cluster SUBC=$("$(dirname "$0")/helper_scripts/UTILITY.readSubmissionCommand.sh") -SUBC=`eval "echo \"$SUBC\""` +SUBC=$(eval "echo \"$SUBC\"") if [[ $SUBC == *"ERROR"* ]]; then echo "$SUBC" exit fi if [[ $SUBC == *qsub* ]]; then - JOBID=`$SUBC $FSCRIPT.sh` + # shellcheck disable=SC2086 + JOBID=$($SUBC "$FSCRIPT".sh) echo "JOBID: $JOBID" elif [[ $SUBC == *condor* ]]; then "$(dirname "$0")/helper_scripts/UTILITY.condorSubmission.sh" "$FSCRIPT.sh" "$h_vmem" "$tmpdir_size" @@ -156,7 +156,8 @@ elif [[ $SUBC == *condor* ]]; then echo "-------------------------------------------------------------------------------" echo elif [[ $SUBC == *sbatch* ]]; then - $SUBC $FSCRIPT.sh + # shellcheck disable=SC2086 + $SUBC "$FSCRIPT".sh elif [[ $SUBC == *parallel* ]]; then echo "$FSCRIPT.sh &> $FSCRIPT.log" >> "$LOGDIR/runscripts.dat" elif [[ "$SUBC" == *simple* ]]; then diff --git a/scripts/IRF.combine_lookup_table_parts.sh b/scripts/IRF.combine_lookup_table_parts.sh index d4ceaac..92876b0 100755 --- a/scripts/IRF.combine_lookup_table_parts.sh +++ b/scripts/IRF.combine_lookup_table_parts.sh @@ -2,11 +2,11 @@ # script to combine several table file into one # job requirements -# shellcheck disable=SC2034 +# shellcheck disable=SC2034 # SGE resource directives, read by job scheduler h_cpu=20:29:00; h_vmem=12000M; tmpdir_size=10G # EventDisplay version -EDVERSION=$(cat $VERITAS_EVNDISP_AUX_DIR/IRFVERSION) +EDVERSION=$(cat "$VERITAS_EVNDISP_AUX_DIR"/IRFVERSION) if [ $# -lt 4 ]; then echo " @@ -40,9 +40,8 @@ fi # Run init script if [ ! -n "$EVNDISP_APPTAINER" ]; then - bash "$(dirname "$0")/helper_scripts/UTILITY.script_init.sh" + bash "$(dirname "$0")/helper_scripts/UTILITY.script_init.sh" || exit 1 fi -[[ $? != "0" ]] && exit 1 # date used in run scripts / log file directories DATE=$(date +"%y%m%d") @@ -88,8 +87,8 @@ mkdir -p "$LOGDIR" # Create list of partial table files FLIST=$OFILE.list rm -f "$ODIR/$FLIST" -ls -1 $INDIR/*ID${RECID}.root > "$ODIR/$FLIST" -NFIL=`cat "$ODIR/$FLIST" | wc -l` +ls -1 "$INDIR"/*ID"${RECID}".root > "$ODIR/$FLIST" +NFIL=$(cat "$ODIR/$FLIST" | wc -l) if [[ $NFIL = "0" ]]; then echo "No lookup table root files found" exit @@ -105,20 +104,21 @@ FSCRIPT="$LOGDIR/TABLES-COMBINE.$OFILE.$DATE.MC" sed -e "s|TABLELIST|$FLIST|" \ -e "s|OUTPUTFILE|$OFILE|" \ - -e "s|OUTPUTDIR|$ODIR|" $SUBSCRIPT.sh > $FSCRIPT.sh + -e "s|OUTPUTDIR|$ODIR|" "$SUBSCRIPT".sh > "$FSCRIPT".sh chmod u+x "$FSCRIPT.sh" echo "Run script written to: $FSCRIPT" # run locally or on cluster SUBC=$("$(dirname "$0")/helper_scripts/UTILITY.readSubmissionCommand.sh") -SUBC=`eval "echo \"$SUBC\""` +SUBC=$(eval "echo \"$SUBC\"") if [[ $SUBC == *"ERROR"* ]]; then echo "$SUBC" exit fi if [[ $SUBC == *qsub* ]]; then - JOBID=`$SUBC $FSCRIPT.sh` + # shellcheck disable=SC2086 + JOBID=$($SUBC "$FSCRIPT".sh) echo "JOBID: $JOBID" elif [[ $SUBC == *condor* ]]; then "$(dirname "$0")/helper_scripts/UTILITY.condorSubmission.sh" "$FSCRIPT.sh" "$h_vmem" "$tmpdir_size" @@ -129,6 +129,6 @@ elif [[ $SUBC == *condor* ]]; then echo "-------------------------------------------------------------------------------" echo elif [[ $SUBC == *parallel* ]]; then - echo "$FSCRIPT.sh &> $FSCRIPT.log" >> $LOGDIR/runscripts.dat + echo "$FSCRIPT.sh &> $FSCRIPT.log" >> "$LOGDIR"/runscripts.dat fi echo "LOG/SUBMIT DIR: ${LOGDIR}" diff --git a/scripts/IRF.compress_evndisp_MC.sh b/scripts/IRF.compress_evndisp_MC.sh index e581299..9dfa8fa 100755 --- a/scripts/IRF.compress_evndisp_MC.sh +++ b/scripts/IRF.compress_evndisp_MC.sh @@ -3,7 +3,7 @@ # # qsub parameters -# shellcheck disable=SC2034 +# shellcheck disable=SC2034 # SGE resource directives, read by job scheduler h_cpu=0:29:00; h_vmem=4000M; tmpdir_size=20G if [ $# -lt 7 ]; then @@ -48,13 +48,12 @@ exit fi # Run init script -bash "$( cd "$( dirname "$0" )" && pwd )/helper_scripts/UTILITY.script_init.sh" -[[ $? != "0" ]] && exit 1 +bash "$( cd "$( dirname "$0" )" && pwd )/helper_scripts/UTILITY.script_init.sh" || exit 1 # EventDisplay version -EDVERSION=`$EVNDISPSYS/bin/evndisp --version | tr -d .` +EDVERSION=$("$EVNDISPSYS"/bin/evndisp --version | tr -d .) # directory for run scripts -DATE=`date +"%y%m%d"` +DATE=$(date +"%y%m%d") # Parse command line arguments SIMDIR=$1 @@ -86,24 +85,18 @@ LOGDIR="${VERITAS_IRFPRODUCTION_DIR}/$EDVERSION/${ANALYSIS_TYPE}/${SIMTYPE}/${EP mkdir -p "$LOGDIR" echo -e "input files will be read from:\n $IPDIR" -# Analysis options -EDOPTIONS="" -if [[ ${ANALYSIS_TYPE} == *"SQ2"* ]]; then - EDOPTIONS="-imagesquared" -fi - # Create a unique set of run numbers if [[ ${SIMTYPE:0:5} = "GRISU" ]]; then [[ ${EPOCH:0:2} == "V4" ]] && RUNNUM="946500" [[ ${EPOCH:0:2} == "V5" ]] && RUNNUM="956500" [[ ${EPOCH:0:2} == "V6" ]] && RUNNUM="966500" -elif [ ${SIMTYPE:0:4} = "CARE" ]; then +elif [ "${SIMTYPE:0:4}" = "CARE" ]; then [[ ${EPOCH:0:2} == "V4" ]] && RUNNUM="941200" [[ ${EPOCH:0:2} == "V5" ]] && RUNNUM="951200" [[ ${EPOCH:0:2} == "V6" ]] && RUNNUM="961200" fi -INT_WOBBLE=`echo "$WOBBLE*100" | bc | awk -F '.' '{print $1}'` +INT_WOBBLE=$(echo "$WOBBLE*100" | bc | awk -F '.' '{print $1}') if [[ ${#INT_WOBBLE} -lt 2 ]]; then INT_WOBBLE="000" elif [[ ${#INT_WOBBLE} -lt 3 ]]; then @@ -120,68 +113,65 @@ NOISEFILE="NO_NOISEFILE" ####################################################### # GRISU simulations if [[ ${SIMTYPE:0:5} == "GRISU" ]]; then - if [[ -z $VERITAS_EVNDISP_AUX_DIR ]]; then - VERITAS_EVNDISP_AUX_DIR=$VERITAS_EVNDISP_AUX_DIR - fi # Input files (observe that these might need some adjustments) if [[ ${EPOCH:0:2} == "V4" ]]; then if [[ $ATM == "21" ]]; then - VBFNAME=$(find ${SIMDIR}/ -maxdepth 1 -name "Oct2012_oa_ATM21_${ZA}deg_${INT_WOBBLE}*" -not -name "*.log" -not -name "*.md5sum") + VBFNAME=$(find "${SIMDIR}"/ -maxdepth 1 -name "Oct2012_oa_ATM21_${ZA}deg_${INT_WOBBLE}*" -not -name "*.log" -not -name "*.md5sum") else - VBFNAME=$(find ${SIMDIR}/ -maxdepth 1 -name "gamma_V4_Oct2012_SummerV4ForProcessing_20130611_v420_ATM${ATM}_${ZA}deg_${INT_WOBBLE}*" -not -name "*.log" -not -name "*.md5sum") + VBFNAME=$(find "${SIMDIR}"/ -maxdepth 1 -name "gamma_V4_Oct2012_SummerV4ForProcessing_20130611_v420_ATM${ATM}_${ZA}deg_${INT_WOBBLE}*" -not -name "*.log" -not -name "*.md5sum") fi NOISEFILE="$VERITAS_EVNDISP_AUX_DIR/NOISE/NOISE$NOISE.grisu" elif [[ ${EPOCH:0:2} == "V5" ]]; then - VBFNAME=$(find ${SIMDIR}/ -maxdepth 1 -name "gamma_V5_Oct2012_newArrayConfig_20121027_v420_ATM${ATM}_${ZA}deg_${INT_WOBBLE}*" -not -name "*.log" -not -name "*.md5sum") + VBFNAME=$(find "${SIMDIR}"/ -maxdepth 1 -name "gamma_V5_Oct2012_newArrayConfig_20121027_v420_ATM${ATM}_${ZA}deg_${INT_WOBBLE}*" -not -name "*.log" -not -name "*.md5sum") NOISEFILE="$VERITAS_EVNDISP_AUX_DIR/NOISE/NOISE$NOISE.grisu" elif [[ ${EPOCH:0:2} == "V6" ]]; then if [[ $ATM == "21-redHV" ]]; then - VBFNAME=$(find ${SIMDIR}/ -maxdepth 1 -name "gamma_V6_Upgrade_ReducedHV_20121211_v420_ATM21_${ZA}deg_${INT_WOBBLE}*" -not -name "*.log" -not -name "*.md5sum") + VBFNAME=$(find "${SIMDIR}"/ -maxdepth 1 -name "gamma_V6_Upgrade_ReducedHV_20121211_v420_ATM21_${ZA}deg_${INT_WOBBLE}*" -not -name "*.log" -not -name "*.md5sum") elif [[ $ATM == "21-UV" ]]; then - VBFNAME=$(find ${SIMDIR}/ -maxdepth 1 -name "gamma_V6_Upgrade_UVfilters_20121211_v420_ATM21_${ZA}deg_${INT_WOBBLE}*" -not -name "*.log" -not -name "*.md5sum") + VBFNAME=$(find "${SIMDIR}"/ -maxdepth 1 -name "gamma_V6_Upgrade_UVfilters_20121211_v420_ATM21_${ZA}deg_${INT_WOBBLE}*" -not -name "*.log" -not -name "*.md5sum") elif [[ $ATM == "21-SNR" ]]; then - VBFNAME=$(find ${SIMDIR}/ -maxdepth 1 -name "gamma_V6_201304_SN2013ak_v420_ATM21_${ZA}deg_${INT_WOBBLE}*" -not -name "*.log" -not -name "*.md5sum") + VBFNAME=$(find "${SIMDIR}"/ -maxdepth 1 -name "gamma_V6_201304_SN2013ak_v420_ATM21_${ZA}deg_${INT_WOBBLE}*" -not -name "*.log" -not -name "*.md5sum") else - VBFNAME=$(find ${SIMDIR}/ -maxdepth 1 -name "gamma_V6_Upgrade_20121127_v420_ATM${ATM}_${ZA}deg_${INT_WOBBLE}*" -not -name "*.log" -not -name "*.md5sum") + VBFNAME=$(find "${SIMDIR}"/ -maxdepth 1 -name "gamma_V6_Upgrade_20121127_v420_ATM${ATM}_${ZA}deg_${INT_WOBBLE}*" -not -name "*.log" -not -name "*.md5sum") fi NOISEFILE="$VERITAS_EVNDISP_AUX_DIR/NOISE/NOISE${NOISE}_20120827_v420.grisu" fi ####################################################### -elif [ ${SIMTYPE} == "CARE_UV_June1409" ]; then +elif [ "${SIMTYPE}" == "CARE_UV_June1409" ]; then # example gamma_00deg_750m_0.5wob_180mhz_up_ATM21_part0.cvbf.bz2 - WOFFSET=$(awk -v WB=$WOBBLE 'BEGIN { printf("%03d",100*WB) }') - VBFNAME=$(find ${SIMDIR}/ -maxdepth 1 -name "gamma_${ZA}deg_750m_${WOBBLE}wob_${NOISE}mhz_up_ATM${ATM}_part0.cvbf.bz2") + WOFFSET=$(awk -v WB="$WOBBLE" 'BEGIN { printf("%03d",100*WB) }') + VBFNAME=$(find "${SIMDIR}"/ -maxdepth 1 -name "gamma_${ZA}deg_750m_${WOBBLE}wob_${NOISE}mhz_up_ATM${ATM}_part0.cvbf.bz2") ####################################################### -elif [ ${SIMTYPE} == "CARE_UV_2212" ]; then +elif [ "${SIMTYPE}" == "CARE_UV_2212" ]; then # example gamma_V6_CARE_uvf_Atmosphere61_zen20deg_0.25wob_120MHz.vbf.zst LBL="CARE_uvf" - VBFNAME=$(find ${SIMDIR}/ -maxdepth 1 -name "gamma_V6_${LBL}_Atmosphere${ATM}_zen${ZA}deg_${WOBBLE}wob_${NOISE}MHz*.zst" -not -name "*.log" -not -name "*.md5sum") + VBFNAME=$(find "${SIMDIR}"/ -maxdepth 1 -name "gamma_V6_${LBL}_Atmosphere${ATM}_zen${ZA}deg_${WOBBLE}wob_${NOISE}MHz*.zst" -not -name "*.log" -not -name "*.md5sum") echo "gamma_V6_${LBL}_Atmosphere${ATM}_zen${ZA}deg_${WOFFSET}wob_${NOISE}MHz" ####################################################### -elif [ ${SIMTYPE:0:10} == "CARE_RedHV" ]; then +elif [ "${SIMTYPE:0:10}" == "CARE_RedHV" ]; then # example gamma_V6_PMTUpgrade_RHV_CARE_v1.6.2_12_ATM61_zen40deg_050wob_150MHz.cvbf.zst if [[ ${ATM} == 61 ]]; then LBL="PMTUpgrade_RHV_CARE_v1.6.2_12" - WOFFSET=$(awk -v WB=$WOBBLE 'BEGIN { printf("%03d",100*WB) }') + WOFFSET=$(awk -v WB="$WOBBLE" 'BEGIN { printf("%03d",100*WB) }') else LBL="RHV_CARE_v1.6.2_12" - WOFFSET=$(awk -v WB=$WOBBLE 'BEGIN { printf("%02d",10*WB) }') + WOFFSET=$(awk -v WB="$WOBBLE" 'BEGIN { printf("%02d",10*WB) }') fi - VBFNAME=$(find ${SIMDIR}/ -maxdepth 1 -name "gamma_V6_${LBL}_ATM${ATM}_zen${ZA}deg_${WOFFSET}wob_${NOISE}MHz*.zst" -not -name "*.log" -not -name "*.md5sum") + VBFNAME=$(find "${SIMDIR}"/ -maxdepth 1 -name "gamma_V6_${LBL}_ATM${ATM}_zen${ZA}deg_${WOFFSET}wob_${NOISE}MHz*.zst" -not -name "*.log" -not -name "*.md5sum") ####################################################### -elif [ ${SIMTYPE} == "CARE_June2020" ]; then - VBFNAME=$(find ${SIMDIR} -name "*_${WOBBLE}wob_${NOISE}MHz*.zst" -not -name "*.log" -not -name "*.md5sum") - echo _${WOFFSET}wob_${NOISE}MHz - echo $SIMDIR/Zd${ZA}/merged/Data/ +elif [ "${SIMTYPE}" == "CARE_June2020" ]; then + VBFNAME=$(find "${SIMDIR}" -name "*_${WOBBLE}wob_${NOISE}MHz*.zst" -not -name "*.log" -not -name "*.md5sum") + echo _"${WOFFSET}"wob_"${NOISE}"MHz + echo "$SIMDIR"/Zd"${ZA}"/merged/Data/ ####################################################### -elif [ ${SIMTYPE:0:4} == "CARE" ]; then +elif [ "${SIMTYPE:0:4}" == "CARE" ]; then # input files (observe that these might need some adjustments) if [[ $PARTICLE == "1" ]]; then - VBFNAME=$(find ${SIMDIR}/ -name "gamma_${ZA}deg*${WOBBLE}wob_${NOISE}mhz*ATM${ATM}*.zst" -not -name "*.log" -not -name "*.md5sum") + VBFNAME=$(find "${SIMDIR}"/ -name "gamma_${ZA}deg*${WOBBLE}wob_${NOISE}mhz*ATM${ATM}*.zst" -not -name "*.log" -not -name "*.md5sum") elif [[ $PARTICLE == "2" ]]; then - VBFNAME=$(find ${SIMDIR} -name "electron_${ZA}deg*${WOBBLE}wob_${NOISE}mhz*ATM${ATM}*.zst" -not -name "*.log" -not -name "*.md5sum") + VBFNAME=$(find "${SIMDIR}" -name "electron_${ZA}deg*${WOBBLE}wob_${NOISE}mhz*ATM${ATM}*.zst" -not -name "*.log" -not -name "*.md5sum") elif [[ $PARTICLE == "14" ]]; then - VBFNAME=$(find ${SIMDIR} -name "proton_${ZA}deg*${WOBBLE}wob_${NOISE}mhz*ATM${ATM}*.zst" -not -name "*.log" -not -name "*.md5sum") + VBFNAME=$(find "${SIMDIR}" -name "proton_${ZA}deg*${WOBBLE}wob_${NOISE}mhz*ATM${ATM}*.zst" -not -name "*.log" -not -name "*.md5sum") fi fi ####################################################### @@ -191,11 +181,11 @@ fi for V in ${VBFNAME} do echo "Processing ${V}" - SIMDIR=$(dirname ${V}) + SIMDIR=$(dirname "${V}") # size of VBF file - FF=$(ls -ls -Llh ${V} | awk '{print $1}' | sed 's/,/./g') - V=$(basename ${V}) + FF=$(du -shL "${V}" | awk '{print $1}' | sed 's/,/./g') + V=$(basename "${V}") echo "SIMDIR: $SIMDIR" echo "VBFILE: ${V} $FF" echo "NOISEFILE: ${NOISEFILE}" @@ -209,7 +199,7 @@ do TMSF=$(echo "${FF%?}*25.0" | bc) fi - TMUNI=$(echo "${FF: -1}") + TMUNI="${FF: -1}" tmpdir_size=${TMSF%.*}$TMUNI echo "Setting TMPDIR_SIZE to $tmpdir_size" @@ -220,19 +210,20 @@ do FSCRIPT="$LOGDIR/comp-$EPOCH-$SIMTYPE-$ZA-$WOBBLE-$NOISE-ATM$ATM-${RUNNUM}" sed -e "s|RUNNUMBER|$RUNNUM|" \ -e "s|OUTPUTDIR|$OPDIR|" \ - -e "s|INPUTDIR|$IPDIR|" $SUBSCRIPT.sh > $FSCRIPT.sh + -e "s|INPUTDIR|$IPDIR|" "$SUBSCRIPT".sh > "$FSCRIPT".sh - chmod u+x $FSCRIPT.sh - echo $FSCRIPT.sh + chmod u+x "$FSCRIPT".sh + echo "$FSCRIPT".sh - let "RUNNUM = ${RUNNUM} + 100" + (( RUNNUM += 100 )) # run locally or on cluster SUBC=$("$(dirname "$0")/helper_scripts/UTILITY.readSubmissionCommand.sh") - SUBC=`eval "echo \"$SUBC\""` + SUBC=$(eval "echo \"$SUBC\"") echo "$SUBC" if [[ $SUBC == *qsub* ]]; then - JOBID=`$SUBC $FSCRIPT.sh` + # shellcheck disable=SC2086 + JOBID=$($SUBC "$FSCRIPT".sh) echo "RUN $RUNNUM: JOBID $JOBID" elif [[ $SUBC == *condor* ]]; then "$(dirname "$0")/helper_scripts/UTILITY.condorSubmission.sh" "$FSCRIPT.sh" "$h_vmem" "$tmpdir_size" @@ -243,7 +234,7 @@ do echo "-------------------------------------------------------------------------------" echo elif [[ $SUBC == *parallel* ]]; then - echo "$FSCRIPT.sh &> $FSCRIPT.log" >> $LOGDIR/runscripts.dat + echo "$FSCRIPT.sh &> $FSCRIPT.log" >> "$LOGDIR"/runscripts.dat fi done echo "LOG/SUBMIT DIR: ${LOGDIR}" diff --git a/scripts/IRF.dispXGB.sh b/scripts/IRF.dispXGB.sh index 6fd9f1a..541d2f7 100755 --- a/scripts/IRF.dispXGB.sh +++ b/scripts/IRF.dispXGB.sh @@ -2,7 +2,7 @@ # XGBoost analysis on mscw MC files. # qsub parameters -# shellcheck disable=SC2034 +# shellcheck disable=SC2034 # SGE resource directives, read by job scheduler h_cpu=11:59:00; h_vmem=8000M; tmpdir_size=25G if [ "$#" -lt 3 ]; then @@ -46,37 +46,36 @@ else fi # make output directory if it doesn't exist -mkdir -p $ODIR +mkdir -p "$ODIR" echo -e "Output files will be written to:\n $ODIR" # directory for run scripts -DATE=`date +"%y%m%d"` -LOGDIR="$(dirname $INPUTDIR)/submit-XGB-${XGB_TYPE}-${DATE}-$(uuidgen)/" +DATE=$(date +"%y%m%d") +LOGDIR="$(dirname "$INPUTDIR")/submit-XGB-${XGB_TYPE}-${DATE}-$(uuidgen)/" mkdir -p "$LOGDIR" echo -e "Log files will be written to:\n $LOGDIR" -rm -f ${LOGDIR}/x* 2>/dev/null +rm -f "${LOGDIR}"/x* 2>/dev/null # Job submission script SUBSCRIPT="$(dirname "$0")/helper_scripts/IRF.dispXGB_sub" -TIMETAG=`date +"%s"` for FILE in $FILES do echo "Now analysing $FILE" - FSCRIPT="$LOGDIR/dispXGB-${XGB_TYPE}-$(basename $FILE .root)" - rm -f $FSCRIPT.sh + FSCRIPT="$LOGDIR/dispXGB-${XGB_TYPE}-$(basename "$FILE" .root)" + rm -f "$FSCRIPT".sh sed -e "s|FFILE|$FILE|" \ -e "s|XXGB|$XGB|" \ -e "s|XGB_TTYPE|$XGB_TYPE|" \ -e "s|ANALYSISTYPE|$ANALYSIS_TYPE|" \ - -e "s|OODIR|$ODIR|" $SUBSCRIPT.sh > $FSCRIPT.sh + -e "s|OODIR|$ODIR|" "$SUBSCRIPT".sh > "$FSCRIPT".sh chmod u+x "$FSCRIPT.sh" - echo $FSCRIPT.sh + echo "$FSCRIPT".sh SUBC=$("$(dirname "$0")/helper_scripts/UTILITY.readSubmissionCommand.sh") - SUBC=`eval "echo \"$SUBC\""` + SUBC=$(eval "echo \"$SUBC\"") if [[ $SUBC == *condor* ]]; then "$(dirname "$0")/helper_scripts/UTILITY.condorSubmission.sh" "$FSCRIPT.sh" "$h_vmem" "$tmpdir_size" echo diff --git a/scripts/IRF.evndisp_MC.sh b/scripts/IRF.evndisp_MC.sh index 01abdfa..8831ef5 100755 --- a/scripts/IRF.evndisp_MC.sh +++ b/scripts/IRF.evndisp_MC.sh @@ -2,7 +2,7 @@ # submit evndisp for grisu/care simulations # qsub parameters -# shellcheck disable=SC2034 +# shellcheck disable=SC2034 # SGE resource directives, read by job scheduler h_cpu=47:59:00; h_vmem=8000M; tmpdir_size=50G DATE=$(date +"%y%m%d") @@ -54,9 +54,8 @@ fi # Run init script if [ -z "$EVNDISP_APPTAINER" ]; then - bash "$(dirname "$0")/helper_scripts/UTILITY.script_init.sh" + bash "$(dirname "$0")/helper_scripts/UTILITY.script_init.sh" || exit 1 fi -[[ $? != "0" ]] && exit 1 SIMDIR="$1" @@ -102,7 +101,7 @@ if [[ ${SIMTYPE:0:5} == "GRISU" ]]; then [[ ${EPOCH:0:2} == "V4" ]] && RUNNUM="946500" [[ ${EPOCH:0:2} == "V5" ]] && RUNNUM="956500" [[ ${EPOCH:0:2} == "V6" ]] && RUNNUM="966500" -elif [ ${SIMTYPE:0:4} == "CARE" ]; then +elif [ "${SIMTYPE:0:4}" == "CARE" ]; then [[ ${EPOCH:0:2} == "V4" ]] && RUNNUM="941200" [[ ${EPOCH:0:2} == "V5" ]] && RUNNUM="951200" [[ ${EPOCH:0:2} == "V6" ]] && RUNNUM="961200" @@ -125,44 +124,44 @@ NOISEFILE="NO_NOISEFILE" if [[ ${SIMTYPE:0:5} == "GRISU" ]]; then if [[ ${EPOCH:0:2} == "V4" ]] || [[ ${EPOCH:0:2} == "V5" ]]; then if [[ ${EPOCH:0:2} == "V5" ]]; then - VBFFILENAME="gamma_V5_Oct2012_newArrayConfig_20121027_v420_ATM${ATM}_${ZA}deg_${INT_WOBBLE}*" + VBFILENAME="gamma_V5_Oct2012_newArrayConfig_20121027_v420_ATM${ATM}_${ZA}deg_${INT_WOBBLE}*" elif [[ $ATM == "21" ]]; then - VBFFILENAME="Oct2012_oa_ATM21_${ZA}deg_${INT_WOBBLE}*" + VBFILENAME="Oct2012_oa_ATM21_${ZA}deg_${INT_WOBBLE}*" else - VBFFILENAME="gamma_V4_Oct2012_SummerV4ForProcessing_20130611_v420_ATM${ATM}_${ZA}deg_${INT_WOBBLE}*" + VBFILENAME="gamma_V4_Oct2012_SummerV4ForProcessing_20130611_v420_ATM${ATM}_${ZA}deg_${INT_WOBBLE}*" fi NOISEFILE="$VERITAS_EVNDISP_AUX_DIR/NOISE/NOISE$NOISE.grisu" elif [[ ${EPOCH:0:2} == "V6" ]]; then if [[ $ATM == "21-redHV" ]]; then - VBFFILENAME="gamma_V6_Upgrade_ReducedHV_20121211_v420_ATM21_${ZA}deg_${INT_WOBBLE}*" + VBFILENAME="gamma_V6_Upgrade_ReducedHV_20121211_v420_ATM21_${ZA}deg_${INT_WOBBLE}*" elif [[ $ATM == "21-UV" ]]; then - VBFFILENAME="gamma_V6_Upgrade_UVfilters_20121211_v420_ATM21_${ZA}deg_${INT_WOBBLE}*" + VBFILENAME="gamma_V6_Upgrade_UVfilters_20121211_v420_ATM21_${ZA}deg_${INT_WOBBLE}*" elif [[ $ATM == "21-SNR" ]]; then - VBFFILENAME="gamma_V6_201304_SN2013ak_v420_ATM21_${ZA}deg_${INT_WOBBLE}*" + VBFILENAME="gamma_V6_201304_SN2013ak_v420_ATM21_${ZA}deg_${INT_WOBBLE}*" else - VBFFILENAME="gamma_V6_Upgrade_20121127_v420_ATM${ATM}_${ZA}deg_${INT_WOBBLE}*" + VBFILENAME="gamma_V6_Upgrade_20121127_v420_ATM${ATM}_${ZA}deg_${INT_WOBBLE}*" fi NOISEFILE="$VERITAS_EVNDISP_AUX_DIR/NOISE/NOISE${NOISE}_20120827_v420.grisu" fi ####################################################### -elif [ ${SIMTYPE} == "CARE_UV_June1409" ]; then +elif [ "${SIMTYPE}" == "CARE_UV_June1409" ]; then # example gamma_00deg_750m_0.5wob_180mhz_up_ATM21_part0.cvbf.bz2 - WOFFSET=$(awk -v WB=$WOBBLE 'BEGIN { printf("%03d",100*WB) }') - VBFFILENAME="gamma_${ZA}deg_750m_${WOFFSET}wob_${NOISE}mhz_up_ATM${ATM}_part0.cvbf.bz2" -elif [ ${SIMTYPE} == "CARE_UV_2212" ]; then + WOFFSET=$(awk -v WB="$WOBBLE" 'BEGIN { printf("%03d",100*WB) }') + VBFILENAME="gamma_${ZA}deg_750m_${WOFFSET}wob_${NOISE}mhz_up_ATM${ATM}_part0.cvbf.bz2" +elif [ "${SIMTYPE}" == "CARE_UV_2212" ]; then # example gamma_V6_CARE_uvf_Atmosphere61_zen20deg_0.25wob_120MHz.vbf.zst VBFILENAME="gamma_V6_CARE_uvf_Atmosphere${ATM}_zen${ZA}deg_${WOBBLE}wob_${NOISE}MHz*.zst" -elif [ ${SIMTYPE} == "CARE_RedHV" ]; then +elif [ "${SIMTYPE}" == "CARE_RedHV" ]; then # example gamma_V6_PMTUpgrade_RHV_CARE_v1.6.2_12_ATM61_zen40deg_050wob_150MHz.cvbf.zst if [[ ${ATM} == 61 ]]; then LBL="PMTUpgrade_RHV_CARE_v1.6.2_12" - WOFFSET=$(awk -v WB=$WOBBLE 'BEGIN { printf("%03d",100*WB) }') + WOFFSET=$(awk -v WB="$WOBBLE" 'BEGIN { printf("%03d",100*WB) }') else LBL="RHV_CARE_v1.6.2_12" - WOFFSET=$(awk -v WB=$WOBBLE 'BEGIN { printf("%02d",10*WB) }') + WOFFSET=$(awk -v WB="$WOBBLE" 'BEGIN { printf("%02d",10*WB) }') fi VBFILENAME="gamma_V6_${LBL}_ATM${ATM}_zen${ZA}deg_${WOFFSET}wob_${NOISE}MHz*.zst" -elif [ ${SIMTYPE:0:4} == "CARE" ]; then +elif [ "${SIMTYPE:0:4}" == "CARE" ]; then # VBFILENAME="*_${WOBBLE}wob_${NOISE}MHz*.zst" # Used for processing of pre-2025 simulations (run number starting with 65...) VBFILENAME="*_${WOBBLE}wob_${NOISE}MHz_*.vbf.zst" @@ -171,7 +170,7 @@ elif [ ${SIMTYPE:0:4} == "CARE" ]; then # VBFILENAME="*_${WOBBLE}wob_${NOISE}MHz_66*.zst" fi echo "VBF file name search string: $VBFILENAME" -VBFNAME=$(find ${SIMDIR} -name "$VBFILENAME" -not -name "*.log" -not -name "*.md5sum") +VBFNAME=$(find "${SIMDIR}" -name "$VBFILENAME" -not -name "*.log" -not -name "*.md5sum") if [[ -z "$VBFNAME" ]]; then echo "No vbf files found" exit @@ -194,8 +193,8 @@ rm -f "${FSCRIPT}.txt" touch "${FSCRIPT}.txt" for V in $VBFNAME; do - echo "$RUNNUM $(basename $V)" >> "${FSCRIPT}.txt" - let "RUNNUM = ${RUNNUM} + 100" + echo "$RUNNUM $(basename "$V")" >> "${FSCRIPT}.txt" + (( RUNNUM += 100 )) done # Job submission script @@ -212,7 +211,7 @@ sed -e "s|DATADIR|$SIMDIR|" \ -e "s|SIMULATIONTYPE|$SIMTYPE|" \ -e "s|VVERSION|$EDVERSION|" \ -e "s|ADDITIONALOPTIONS|$EDOPTIONS|" \ - -e "s|NOISEFFILE|$NOISEFILE|" $SUBSCRIPT > $FSCRIPT + -e "s|NOISEFFILE|$NOISEFILE|" "$SUBSCRIPT" > "$FSCRIPT" chmod u+x "$FSCRIPT" echo "Run script: $FSCRIPT" @@ -223,7 +222,7 @@ if [[ $SUBC == *"condor"* ]]; then SUBFIL=${SUBSCRIPT}.condor [[ -f "$SUBFIL" ]] && rm -f "$SUBFIL" -cat > ${SUBFIL} < "${SUBFIL}" < $FSCRIPT + -e "s|GAMMACUTS|${CUTSFILE}|" "$SUBSCRIPT".sh > "$FSCRIPT" chmod u+x "$FSCRIPT" echo "Run script: $FSCRIPT" @@ -126,7 +125,8 @@ if [[ $SUBC == *"ERROR"* ]]; then exit 1 fi if [[ $SUBC == *qsub* ]]; then - JOBID=`$SUBC $FSCRIPT` + # shellcheck disable=SC2086 + JOBID=$($SUBC "$FSCRIPT") echo "JOBID: $JOBID" elif [[ $SUBC == *condor* ]]; then "$(dirname "$0")/helper_scripts/UTILITY.condorSubmission.sh" "$FSCRIPT" "$h_vmem" "$tmpdir_size" @@ -135,9 +135,10 @@ elif [[ $SUBC == *condor* ]]; then echo "$EVNDISPSCRIPTS/helper_scripts/submit_scripts_to_htcondor.sh ${LOGDIR} submit" echo "-------------------------------------------------------------------------------" elif [[ $SUBC == *sbatch* ]]; then - $SUBC $FSCRIPT + # shellcheck disable=SC2086 + $SUBC "$FSCRIPT" elif [[ $SUBC == *parallel* ]]; then - echo "$FSCRIPT &> $(basename $FSCRIPT .sh).log" >> "$LOGDIR/runscripts.dat" + echo "$FSCRIPT &> $(basename "$FSCRIPT" .sh).log" >> "$LOGDIR/runscripts.dat" elif [[ "$SUBC" == *simple* ]]; then - "$FSCRIPT" | tee "$(basename $FSCRIPT .sh).log" + "$FSCRIPT" | tee "$(basename "$FSCRIPT" .sh).log" fi diff --git a/scripts/IRF.generate_lookup_table_parts.sh b/scripts/IRF.generate_lookup_table_parts.sh index 798b92c..4c08c9a 100755 --- a/scripts/IRF.generate_lookup_table_parts.sh +++ b/scripts/IRF.generate_lookup_table_parts.sh @@ -3,11 +3,11 @@ # (generated tables need to be combined afterwards) # qsub parameters -# shellcheck disable=SC2034 +# shellcheck disable=SC2034 # SGE resource directives, read by job scheduler h_cpu=03:29:00; h_vmem=12000M; tmpdir_size=20G # EventDisplay version -EDVERSION=$(cat $VERITAS_EVNDISP_AUX_DIR/IRFVERSION) +EDVERSION=$(cat "$VERITAS_EVNDISP_AUX_DIR"/IRFVERSION) EVNIRFVERSION="v4N" if [ $# -lt 7 ]; then @@ -47,9 +47,8 @@ fi # Run init script if [ -z "$EVNDISP_APPTAINER" ]; then - bash "$(dirname "$0")/helper_scripts/UTILITY.script_init.sh" + bash "$(dirname "$0")/helper_scripts/UTILITY.script_init.sh" || exit 1 fi -[[ $? != "0" ]] && exit 1 EPOCH="$1" ATM="$2" @@ -113,7 +112,8 @@ if [[ $SUBC == *"ERROR"* ]]; then exit 1 fi if [[ $SUBC == *qsub* ]]; then - JOBID=`$SUBC $FSCRIPT` + # shellcheck disable=SC2086 + JOBID=$($SUBC "$FSCRIPT") echo "JOBID: $JOBID" elif [[ $SUBC == *condor* ]]; then "$(dirname "$0")/helper_scripts/UTILITY.condorSubmission.sh" "$FSCRIPT" "$h_vmem" "$tmpdir_size" @@ -122,7 +122,8 @@ elif [[ $SUBC == *condor* ]]; then echo "$EVNDISPSCRIPTS/helper_scripts/submit_scripts_to_htcondor.sh ${LOGDIR} submit" echo "-------------------------------------------------------------------------------" elif [[ $SUBC == *sbatch* ]]; then - $SUBC $FSCRIPT + # shellcheck disable=SC2086 + $SUBC "$FSCRIPT" elif [[ $SUBC == *parallel* ]]; then echo "$FSCRIPT &> $FSCRIPT.log" >> "$LOGDIR/runscripts.dat" elif [[ "$SUBC" == *simple* ]]; then diff --git a/scripts/IRF.generate_radial_acceptance.sh b/scripts/IRF.generate_radial_acceptance.sh index 0a8f087..9053982 100755 --- a/scripts/IRF.generate_radial_acceptance.sh +++ b/scripts/IRF.generate_radial_acceptance.sh @@ -2,7 +2,7 @@ # calculate radial acceptances # qsub parameters -# shellcheck disable=SC2034 +# shellcheck disable=SC2034 # SGE resource directives, read by job scheduler h_cpu=04:29:00; h_vmem=6000M; tmpdir_size=10G if [[ $# != 6 ]]; then @@ -49,8 +49,7 @@ exit fi # Run init script -bash "$(dirname "$0")/helper_scripts/UTILITY.script_init.sh" -[[ $? != "0" ]] && exit 1 +bash "$(dirname "$0")/helper_scripts/UTILITY.script_init.sh" || exit 1 # Parse command line arguments RLIST=$1 @@ -60,7 +59,7 @@ EPOCH=$4 SIM=$5 RECID="$6" # make radial acceptance version -IRFVERSION=`$EVNDISPSYS/bin/makeRadialAcceptance --version | tr -d . | sed -e 's/[a-Z]*$//'` +IRFVERSION=$("$EVNDISPSYS"/bin/makeRadialAcceptance --version | tr -d . | sed -e 's/[a-Z]*$//') # version string for aux files AUX="auxv01" @@ -81,7 +80,7 @@ fi CUTLIST=$(IFS=$'\r\n'; cat "$CUTLISTFILE") # run scripts and logs are written into this directory -DATE=`date +"%y%m%d"` +DATE=$(date +"%y%m%d") LOGDIR="$VERITAS_USER_LOG_DIR/$DATE/RADIAL" echo -e "Log files will be written to:\n $LOGDIR" mkdir -p "$LOGDIR" @@ -110,7 +109,7 @@ for CUTS in "${CUTLIST[@]}"; do # Check that cuts file exists CUTSFILE=${CUTS%%.dat}.dat - if [[ "$CUTSFILE" == `basename $CUTSFILE` ]]; then + if [[ "$CUTSFILE" == $(basename "$CUTSFILE") ]]; then CUTSFILE="$VERITAS_EVNDISP_AUX_DIR/GammaHadronCutFiles/$CUTSFILE" fi if [[ ! -f "$CUTSFILE" ]]; then @@ -120,16 +119,16 @@ for CUTS in "${CUTLIST[@]}"; do fi METH="${VERITAS_ANALYSIS_TYPE/_/-}" - CUTSNAME=`basename $CUTSFILE` + CUTSNAME=$(basename "$CUTSFILE") # Generate base file name based on cuts file, extended and point source radial acceptances are the same CUTSNAME=${CUTSNAME##ANASUM.GammaHadron-} CUTSNAME=${CUTSNAME%%.dat} if [[ $CUTSNAME == *PointSource-* ]] ; then CUTSNAME=${CUTSNAME/-PointSource-/"-"} - echo $CUTSNAME + echo "$CUTSNAME" elif [[ $CUTSNAME == *ExtendedSource-* ]]; then CUTSNAME=${CUTSNAME/-ExtendedSource-/"-"} - echo $CUTSNAME + echo "$CUTSNAME" fi OFILE="radialAcceptance-${IRFVERSION}-${AUX}-${SIM}-$CUTSNAME-${METH}-$VX-T$TELES" ODIR="$VERITAS_IRFPRODUCTION_DIR/${IRFVERSION}/${VERITAS_ANALYSIS_TYPE:0:2}/RadialAcceptances" @@ -144,30 +143,32 @@ for CUTS in "${CUTLIST[@]}"; do -e "s|CUTSFILE|$CUTSFILE|" \ -e "s|OUTPUTDIR|$ODIR|" \ -e "s|TELTOANA|$TELES|" \ - -e "s|OUTPUTFILE|$OFILE|" $SUBSCRIPT > $FSCRIPT.sh + -e "s|OUTPUTFILE|$OFILE|" "$SUBSCRIPT" > "$FSCRIPT".sh - chmod u+x $FSCRIPT.sh + chmod u+x "$FSCRIPT".sh echo "Script submitted to cluster: $FSCRIPT.sh" # run locally or on cluster SUBC=$("$(dirname "$0")/helper_scripts/UTILITY.readSubmissionCommand.sh") echo "$LOGDIR" - SUBC=`eval "echo \"$SUBC\""` + SUBC=$(eval "echo \"$SUBC\"") if [[ $SUBC == *"ERROR"* ]]; then - echo $SUBC + echo "$SUBC" exit fi if [[ $SUBC == *qsub* ]]; then echo "$SUBC" "$FSCRIPT.sh" - JOBID=`$SUBC $FSCRIPT.sh` + # shellcheck disable=SC2086 + JOBID=$($SUBC "$FSCRIPT".sh) echo "JOBID: $JOBID" elif [[ $SUBC == *condor* ]]; then "$(dirname "$0")/helper_scripts/UTILITY.condorSubmission.sh" "$FSCRIPT.sh" "$h_vmem" "$tmpdir_size" - condor_submit $FSCRIPT.sh.condor - elif [[ $SUBC == *sbatch* ]]; then - $SUBC $FSCRIPT.sh + condor_submit "$FSCRIPT".sh.condor + elif [[ $SUBC == *sbatch* ]]; then + # shellcheck disable=SC2086 + $SUBC "$FSCRIPT".sh elif [[ $SUBC == *parallel* ]]; then - echo "$FSCRIPT.sh &> $FSCRIPT.log" >> $LOGDIR/runscripts.dat + echo "$FSCRIPT.sh &> $FSCRIPT.log" >> "$LOGDIR"/runscripts.dat fi done done @@ -175,7 +176,8 @@ done # Execute all FSCRIPTs locally in parallel if [[ $SUBC == *parallel* ]]; then - cat "$LOGDIR/runscripts.dat" | "$SUBC" + # shellcheck disable=SC2086 + cat "$LOGDIR/runscripts.dat" | $SUBC fi exit diff --git a/scripts/IRF.mscw_energy_MC.sh b/scripts/IRF.mscw_energy_MC.sh index c0d1acd..3683b8f 100755 --- a/scripts/IRF.mscw_energy_MC.sh +++ b/scripts/IRF.mscw_energy_MC.sh @@ -3,11 +3,11 @@ # Allow optionally to calculate instrument response functions (for 4 and 3-telescope combinations). # qsub parameters -# shellcheck disable=SC2034 +# shellcheck disable=SC2034 # SGE resource directives, read by job scheduler h_cpu=10:29:00; h_vmem=12000M; tmpdir_size=100G # EventDisplay version -EDVERSION=$(cat $VERITAS_EVNDISP_AUX_DIR/IRFVERSION) +EDVERSION=$(cat "$VERITAS_EVNDISP_AUX_DIR"/IRFVERSION) EVNIRFVERSION="v4N" if [ $# -lt 8 ]; then @@ -55,9 +55,8 @@ fi # Run init script if [ -z "$EVNDISP_APPTAINER" ]; then - bash "$(dirname "$0")/helper_scripts/UTILITY.script_init.sh" + bash "$(dirname "$0")/helper_scripts/UTILITY.script_init.sh" || exit 1 fi -[[ $? != "0" ]] && exit 1 TABFILE=${1%.root}.root EPOCH="$2" @@ -75,7 +74,7 @@ XGBVERSION="xgb" echo "IRF.mscw_energy_MC for epoch $EPOCH, atmo $ATM, zenith $ZA, wobble $WOBBLE, noise $NOISE (DISP: $DISPBDT, XGB $XGBVERSION)" -TABFILE="$VERITAS_EVNDISP_AUX_DIR/Tables/$(basename $TABFILE)" +TABFILE="$VERITAS_EVNDISP_AUX_DIR/Tables/$(basename "$TABFILE")" if [[ ! -f "$TABFILE" ]]; then echo "Error: table file not found: $TABFILE" exit 1 @@ -138,7 +137,8 @@ if [[ $SUBC == *"ERROR"* ]]; then exit 1 fi if [[ $SUBC == *qsub* ]]; then - JOBID=`$SUBC $FSCRIPT` + # shellcheck disable=SC2086 + JOBID=$($SUBC "$FSCRIPT") echo "JOBID: $JOBID" elif [[ $SUBC == *condor* ]]; then "$(dirname "$0")/helper_scripts/UTILITY.condorSubmission.sh" "$FSCRIPT" "$h_vmem" "$tmpdir_size" @@ -147,7 +147,8 @@ elif [[ $SUBC == *condor* ]]; then echo "$EVNDISPSCRIPTS/helper_scripts/submit_scripts_to_htcondor.sh ${LOGDIR} submit" echo "-------------------------------------------------------------------------------" elif [[ $SUBC == *sbatch* ]]; then - $SUBC $FSCRIPT + # shellcheck disable=SC2086 + $SUBC "$FSCRIPT" elif [[ $SUBC == *parallel* ]]; then echo "$FSCRIPT &> $FSCRIPT.log" >> "$LOGDIR/runscripts.dat" elif [[ "$SUBC" == *simple* ]]; then diff --git a/scripts/IRF.optimizeTMVAforGammaHadronSeparation.sh b/scripts/IRF.optimizeTMVAforGammaHadronSeparation.sh index 0724b37..fe92642 100755 --- a/scripts/IRF.optimizeTMVAforGammaHadronSeparation.sh +++ b/scripts/IRF.optimizeTMVAforGammaHadronSeparation.sh @@ -3,7 +3,7 @@ # # -# shellcheck disable=SC2034 +# shellcheck disable=SC2034 # SGE resource directives, read by job scheduler h_cpu=11:59:59; h_vmem=4000M; tmpdir_size=1G if [[ $# -lt 5 ]]; then @@ -32,8 +32,7 @@ exit fi echo " " # Run init script -bash "$(dirname "$0")/helper_scripts/UTILITY.script_init.sh" -[[ $? != "0" ]] && exit 1 +bash "$(dirname "$0")/helper_scripts/UTILITY.script_init.sh" || exit 1 # Parse command line arguments PREDIR=$1 @@ -42,16 +41,7 @@ SIMTYPE=$3 EPOCH=$4 ATM=$5 # evndisplay version -IRFVERSION=$(cat $VERITAS_EVNDISP_AUX_DIR/IRFVERSION) - -DISPBDT="" -ANATYPE="AP" -if [[ ! -z $VERITAS_ANALYSIS_TYPE ]]; then - ANATYPE="${VERITAS_ANALYSIS_TYPE:0:2}" - if [[ ${VERITAS_ANALYSIS_TYPE} == *"DISP"* ]]; then - DISPBDT="_DISP" - fi -fi +IRFVERSION=$(cat "$VERITAS_EVNDISP_AUX_DIR"/IRFVERSION) # Check that list of background files exists if [[ ! -d "${PREDIR}/${CUTTYPE}" ]]; then @@ -61,10 +51,10 @@ fi ##################################### # directory for run scripts -DATE=`date +"%y%m%d"` +DATE=$(date +"%y%m%d") LOGDIR="$PREDIR/${CUTTYPE}/$DATE/" echo -e "Log files will be written to:\n $LOGDIR" -mkdir -p $LOGDIR +mkdir -p "$LOGDIR" # EffAreaFile if [[ $CUTTYPE == *"Moderate"* ]]; then @@ -90,36 +80,22 @@ else fi ##################################### # energy bins +count1=1 if grep -q "^\* ENERGYBINS" "$RUNPAR"; then ENBINS=$( cat "$RUNPAR" | grep "^\* ENERGYBINS" | sed -e 's/\* ENERGYBINS//' | sed -e 's/ /\n/g') mapfile -t EBINARRAY <<< "$ENBINS" - count1=1 - NENE=$((${#EBINARRAY[@]}-$count1)) #get number of bins - for (( i=0; i < $NENE; i++ )) - do - EBINMIN[$i]=${EBINARRAY[$i]} - EBINMAX[$i]=${EBINARRAY[$i+1]} - done + NENE=$(( ${#EBINARRAY[@]}-count1 )) #get number of bins else ENBINS=$( cat "$RUNPAR" | grep "^* ENERGYBINEDGES" | sed -e 's/* ENERGYBINEDGES//' | sed -e 's/ /\n/g') mapfile -t EBINARRAY <<< "$ENBINS" - count1=1 - NENE=$((${#EBINARRAY[@]}-$count1)) #get number of bins - z="0" - for (( i=0; i < $NENE; i+=2 )) - do - EBINMIN[$z]=${EBINARRAY[$i]} - EBINMAX[$z]=${EBINARRAY[$i+1]} - let "z = ${z} + 1" - done - NENE=$((${#EBINMAX[@]})) + NENE=$(( ${#EBINARRAY[@]} / 2 )) fi ##################################### # zenith angle bins ZEBINS=$( cat "$RUNPAR" | grep "^* ZENBINS " | sed -e 's/* ZENBINS//' | sed -e 's/ /\n/g') mapfile -t ZEBINARRAY <<< "$ZEBINS" -NZEW=$((${#ZEBINARRAY[@]}-$count1)) #get number of bins +NZEW=$(( ${#ZEBINARRAY[@]}-count1 )) #get number of bins # Job submission script SUBSCRIPT="$(dirname "$0")/helper_scripts/IRF.optimizeTMVAforGammaHadronSeparation_sub" @@ -132,20 +108,21 @@ sed -e "s|EFFFILE|$EFFFILE|" \ -e "s|EEBINS|${NENE}|" \ -e "s|ZZBINS|${NZEW}|" \ -e "s|TMVARUNPARA|${RUNPAR}|" \ - -e "s|CUTTYPE|${CUTTYPE}|" $SUBSCRIPT.sh > $FSCRIPT.sh + -e "s|CUTTYPE|${CUTTYPE}|" "$SUBSCRIPT".sh > "$FSCRIPT".sh -chmod u+x $FSCRIPT.sh -echo $FSCRIPT.sh +chmod u+x "$FSCRIPT".sh +echo "$FSCRIPT".sh # run locally or on cluster SUBC=$("$(dirname "$0")/helper_scripts/UTILITY.readSubmissionCommand.sh") -SUBC=`eval "echo \"$SUBC\""` +SUBC=$(eval "echo \"$SUBC\"") if [[ $SUBC == *"ERROR"* ]]; then - echo $SUBC + echo "$SUBC" exit fi if [[ $SUBC == *qsub* ]]; then - JOBID=`$SUBC $FSCRIPT.sh` + # shellcheck disable=SC2086 + JOBID=$($SUBC "$FSCRIPT".sh) # account for -terse changing the job number format if [[ $SUBC != *-terse* ]] ; then echo "without -terse!" # need to match VVVVVVVV 8539483 and 3843483.1-4:2 @@ -154,12 +131,14 @@ if [[ $SUBC == *qsub* ]]; then echo "JOBID: $JOBID" elif [[ $SUBC == *condor* ]]; then "$(dirname "$0")/helper_scripts/UTILITY.condorSubmission.sh" "$FSCRIPT.sh" "$h_vmem" "$tmpdir_size" - condor_submit $FSCRIPT.sh.condor + condor_submit "$FSCRIPT".sh.condor elif [[ $SUBC == *sbatch* ]]; then - $SUBC $FSCRIPT.sh + # shellcheck disable=SC2086 + $SUBC "$FSCRIPT".sh elif [[ $SUBC == *parallel* ]]; then - echo "$FSCRIPT.sh &> $FSCRIPT.log" >> $LOGDIR/runscripts.dat - cat $LOGDIR/runscripts.dat | $SUBC + echo "$FSCRIPT.sh &> $FSCRIPT.log" >> "$LOGDIR"/runscripts.dat + # shellcheck disable=SC2086 + cat "$LOGDIR"/runscripts.dat | $SUBC elif [[ "$SUBC" == *simple* ]] ; then "$FSCRIPT.sh" | tee "$FSCRIPT.log" fi diff --git a/scripts/IRF.production.sh b/scripts/IRF.production.sh index e72548e..a11adc3 100755 --- a/scripts/IRF.production.sh +++ b/scripts/IRF.production.sh @@ -3,7 +3,7 @@ # IRF production script (VERITAS) # EventDisplay version -EDVERSION=$(cat $VERITAS_EVNDISP_AUX_DIR/IRFVERSION) +EDVERSION=$(cat "$VERITAS_EVNDISP_AUX_DIR"/IRFVERSION) if [ $# -lt 2 ]; then echo " @@ -70,9 +70,8 @@ cd "$(dirname "$0")" || exit # Run init script if [ ! -n "$EVNDISP_APPTAINER" ]; then - bash "$( cd "$( dirname "$0" )" && pwd )/helper_scripts/UTILITY.script_init.sh" + bash "$( cd "$( dirname "$0" )" && pwd )/helper_scripts/UTILITY.script_init.sh" || exit 1 fi -[[ $? != "0" ]] && exit 1 # Parse command line arguments SIMTYPE="$1" @@ -84,7 +83,7 @@ IRFTYPE="$2" [[ "$7" ]] && SIMDIR="$7" || SIMDIR="" # uuid for this job batch -DATE=`date +"%y%m%d"` +DATE=$(date +"%y%m%d") UUID=${DATE}-$(uuidgen) # version string for aux files @@ -149,25 +148,25 @@ elif [ "${SIMTYPE}" = "CARE_June1702" ]; then WOBBLE_OFFSETS=( 0.5 ) elif [ "${SIMTYPE}" == "CARE_UV_June1409" ]; then SIMDIR=${VERITAS_DATA_DIR}/simulations/V6_FLWO/CARE_June1409_UV/ - ZENITH_ANGLES=$(ls ${SIMDIR}/*.bz2 | awk -F "gamma_" '{print $2}' | awk -F "deg." '{print $1}' | sort | uniq) - NSB_LEVELS=$(ls ${SIMDIR}/*.bz2 | awk -F "wob_" '{print $2}' | awk -F "mhz." '{print $1}' | sort | uniq) + ZENITH_ANGLES=$(find "${SIMDIR}" -maxdepth 1 -name "*.bz2" -exec basename {} \; | awk -F "gamma_" '{print $2}' | awk -F "deg." '{print $1}' | sort | uniq) + NSB_LEVELS=$(find "${SIMDIR}" -maxdepth 1 -name "*.bz2" -exec basename {} \; | awk -F "wob_" '{print $2}' | awk -F "mhz." '{print $1}' | sort | uniq) WOBBLE_OFFSETS=( 0.5 ) elif [ "${SIMTYPE}" == "CARE_UV_2212" ]; then SIMDIR=${VERITAS_DATA_DIR}/simulations/UVF_Dec2022/CARE/ - ZENITH_ANGLES=$(ls ${SIMDIR}/*.zst | awk -F "_zen" '{print $2}' | awk -F "deg." '{print $1}' | sort | uniq) - NSB_LEVELS=$(ls ${SIMDIR}/*.zst | awk -F "wob_" '{print $2}' | awk -F "MHz." '{print $1}' | sort | uniq) - WOBBLE_OFFSETS=$(ls ${SIMDIR}/*.zst | awk -F "_" '{print $8}' | awk -F "wob" '{print $1}' | sort -u) + ZENITH_ANGLES=$(find "${SIMDIR}" -maxdepth 1 -name "*.zst" -exec basename {} \; | awk -F "_zen" '{print $2}' | awk -F "deg." '{print $1}' | sort | uniq) + NSB_LEVELS=$(find "${SIMDIR}" -maxdepth 1 -name "*.zst" -exec basename {} \; | awk -F "wob_" '{print $2}' | awk -F "MHz." '{print $1}' | sort | uniq) + WOBBLE_OFFSETS=$(find "${SIMDIR}" -maxdepth 1 -name "*.zst" -exec basename {} \; | awk -F "_" '{print $8}' | awk -F "wob" '{print $1}' | sort -u) elif [ "${SIMTYPE}" == "CARE_RedHV" ]; then SIMDIR="${VERITAS_DCACHE_DIR}/simulations/V6_FLWO/CARE_June1702_RHV/ATM${ATMOS}" - ZENITH_ANGLES=$(ls ${SIMDIR}/*.zst | awk -F "_zen" '{print $2}' | awk -F "deg." '{print $1}' | sort | uniq) - NSB_LEVELS=$(ls ${SIMDIR}/*.zst | awk -F "wob_" '{print $2}' | awk -F "MHz." '{print $1}' | sort | uniq) + ZENITH_ANGLES=$(find "${SIMDIR}" -maxdepth 1 -name "*.zst" -exec basename {} \; | awk -F "_zen" '{print $2}' | awk -F "deg." '{print $1}' | sort | uniq) + NSB_LEVELS=$(find "${SIMDIR}" -maxdepth 1 -name "*.zst" -exec basename {} \; | awk -F "wob_" '{print $2}' | awk -F "MHz." '{print $1}' | sort | uniq) WOBBLE_OFFSETS=( 0.5 ) elif [[ "${SIMTYPE}" == "CARE_June2020" ]]; then SIMDIR="${VERITAS_DATA_DIR}/shared/simulations/NSOffsetSimulations/Atmosphere${ATMOS}" - ZENITH_ANGLES=$(ls ${SIMDIR} | awk -F "Zd" '{print $2}' | sort | uniq) - set -- $ZENITH_ANGLES - NSB_LEVELS=$(ls ${SIMDIR}/Zd*/* | awk -F "_" '{print $8}' | awk -F "MHz" '{print $1}'| sort -u) - WOBBLE_OFFSETS=$(ls ${SIMDIR}/Zd*/* | awk -F "_" '{print $7}' | awk -F "wob" '{print $1}' | sort -u) + ZENITH_ANGLES=$(find "${SIMDIR}" -mindepth 1 -maxdepth 1 -type d -name "Zd*" -exec basename {} \; | awk -F "Zd" '{print $2}' | sort | uniq) + set -- "$ZENITH_ANGLES" + NSB_LEVELS=$(find "${SIMDIR}" -path '*/Zd*/*' -type f -exec basename {} \; | awk -F "_" '{print $8}' | awk -F "MHz" '{print $1}' | sort -u) + WOBBLE_OFFSETS=$(find "${SIMDIR}" -path '*/Zd*/*' -type f -exec basename {} \; | awk -F "_" '{print $7}' | awk -F "wob" '{print $1}' | sort -u) ###################################### # TEST # ZENITH_ANGLES=( 20 ) @@ -188,13 +187,13 @@ elif [[ "${SIMTYPE}" == "CARE_June2020" ]]; then ###################################### elif [[ "${SIMTYPE}" == "CARE_RedHV_Feb2024" ]]; then SIMDIR="${VERITAS_DCACHE_DIR}/simulations/NSOffsetSimulations_redHV/Atmosphere${ATMOS}" - ZENITH_ANGLES=$(ls ${SIMDIR} | awk -F "Zd" '{print $2}' | grep -v curved | sort | uniq) + ZENITH_ANGLES=$(find "${SIMDIR}" -mindepth 1 -maxdepth 1 -type d -name "Zd*" -exec basename {} \; | awk -F "Zd" '{print $2}' | grep -v curved | sort | uniq) # ZENITH_ANGLES=( 60 65 ) - set -- $ZENITH_ANGLES - ze_first_bin=$(echo $ZENITH_ANGLES | awk '{print $1}') + set -- "$ZENITH_ANGLES" + ze_first_bin=$(echo "$ZENITH_ANGLES" | awk '{print $1}') # Note! Assumes same NSB and WOBBLE offsets for flat and curved atmosphere - NSB_LEVELS=$(ls ${SIMDIR}/Zd${ze_first_bin}/*vbf.zst | awk -F "_" '{print $9}' | awk -F "MHz" '{print $1}'| sort -u) - WOBBLE_OFFSETS=$(ls ${SIMDIR}/Zd${ze_first_bin}/*.vbf.zst | awk -F "_" '{print $8}' | awk -F "wob" '{print $1}' | sort -u) + NSB_LEVELS=$(find "${SIMDIR}/Zd${ze_first_bin}" -maxdepth 1 -name "*vbf.zst" -exec basename {} \; | awk -F "_" '{print $9}' | awk -F "MHz" '{print $1}' | sort -u) + WOBBLE_OFFSETS=$(find "${SIMDIR}/Zd${ze_first_bin}" -maxdepth 1 -name "*.vbf.zst" -exec basename {} \; | awk -F "_" '{print $8}' | awk -F "wob" '{print $1}' | sort -u) ###################################### # TEST # NSB_LEVELS=( 300 ) @@ -202,12 +201,12 @@ elif [[ "${SIMTYPE}" == "CARE_RedHV_Feb2024" ]]; then # WOBBLE_OFFSETS=( 0.5 ) elif [[ "${SIMTYPE}" == "CARE_202404" ]] || [[ "${SIMTYPE}" == "CARE_24_20" ]]; then SIMDIR="${VERITAS_DCACHE_DIR}/simulations/NSOffsetSimulations_202404/Atmosphere${ATMOS}" - ZENITH_ANGLES=$(ls ${SIMDIR} | awk -F "Zd" '{print $2}' | grep -v curved | sort | uniq) - set -- $ZENITH_ANGLES - ze_first_bin=$(echo $ZENITH_ANGLES | awk '{print $1}') + ZENITH_ANGLES=$(find "${SIMDIR}" -mindepth 1 -maxdepth 1 -type d -name "Zd*" -exec basename {} \; | awk -F "Zd" '{print $2}' | grep -v curved | sort | uniq) + set -- "$ZENITH_ANGLES" + ze_first_bin=$(echo "$ZENITH_ANGLES" | awk '{print $1}') # assume same NSB and wobble offsets in all bins - NSB_LEVELS=$(ls ${SIMDIR}/*${ze_first_bin}*/* | awk -F "_" '{print $9}' | awk -F "MHz" '{print $1}'| sort -u) - WOBBLE_OFFSETS=$(ls ${SIMDIR}/*${ze_first_bin}*/* | awk -F "_" '{print $8}' | awk -F "wob" '{print $1}' | sort -u) + NSB_LEVELS=$(find "${SIMDIR}" -path "*${ze_first_bin}*/*" -type f -exec basename {} \; | awk -F "_" '{print $9}' | awk -F "MHz" '{print $1}' | sort -u) + WOBBLE_OFFSETS=$(find "${SIMDIR}" -path "*${ze_first_bin}*/*" -type f -exec basename {} \; | awk -F "_" '{print $8}' | awk -F "wob" '{print $1}' | sort -u) ###################################### # TEST # ZENITH_ANGLES=( 00 20 30 35 40 45 ) @@ -220,7 +219,7 @@ elif [[ "${SIMTYPE}" == "CARE_202404" ]] || [[ "${SIMTYPE}" == "CARE_24_20" ]]; # NSB_LEVELS=( 200 ) ###################################### # TRAINMVANGRES production -elif [ ${SIMTYPE:0:4} == "CARE" ]; then +elif [ "${SIMTYPE:0:4}" == "CARE" ]; then # Older CARE simulation parameters SIMDIR=$VERITAS_DATA_DIR/simulations/"${VX:0:2}"_FLWO/CARE_June1425/ ZENITH_ANGLES=( 00 20 30 35 40 45 50 55 60 65 ) @@ -242,17 +241,17 @@ echo "Wobble offsets: ${WOBBLE_OFFSETS}" read_cutlist() { CUTFILE="${1}" - if [[ $CUTFILE == "" ]] || [ ! -f $CUTFILE ]; then + if [[ $CUTFILE == "" ]] || [ ! -f "$CUTFILE" ]; then echo "Error, cuts list file not found, exiting..." >&2 - echo $CUTFILE + echo "$CUTFILE" exit 1 fi - CUTLISTFROMFILE=$(cat $CUTFILE) + CUTLISTFROMFILE=$(cat "$CUTFILE") CUTLIST="" for CUT in "${CUTLISTFROMFILE[@]}"; do CUTLIST="${CUTLIST} ANASUM.GammaHadron-Cut-$CUT.dat" done - echo $CUTLIST + echo "$CUTLIST" } # Cut types are used for BDT training and optimisation @@ -264,7 +263,7 @@ CUTTYPES="NTel2-PointSource-Moderate if [[ $ANATYPE = "NN"* ]]; then CUTTYPES="NTel2-PointSource-SuperSoft" fi -CUTTYPES=`echo $CUTTYPES |tr '\r' ' '` +CUTTYPES=$(echo "$CUTTYPES" |tr '\r' ' ') CUTTYPES=${CUTTYPES//$'\n'/} echo "===== Start submission =====" @@ -371,14 +370,14 @@ for VX in $EPOCH; do "$(dirname "$0")/IRF.trainTMVAforGammaHadronSeparation.sh" \ "${TRAINDIR}" \ "$MVADIR"/"$RUNPAR" \ - "${MVADIR}" BDT ${SIMTYPE} ${VX} "${ATM}" + "${MVADIR}" BDT "${SIMTYPE}" "${VX}" "${ATM}" # Cut optimization elif [[ $IRFTYPE == "OPTIMIZETMVA" ]]; then echo "OPTIMIZE TMVA $C ${BDTDIR}/BackgroundRates/${VX:0:2}" "$(dirname "$0")/IRF.optimizeTMVAforGammaHadronSeparation.sh" \ "${BDTDIR}/BackgroundRates/${VX:0:2}" \ "${C/PointSource-/}" \ - ${SIMTYPE} ${VX} "${ATM}" + "${SIMTYPE}" "${VX}" "${ATM}" fi done continue @@ -388,14 +387,14 @@ for VX in $EPOCH; do ################################################# if [[ $IRFTYPE == "TRAINXGBANGRES" ]]; then STEREO_PAR="$VERITAS_EVNDISP_AUX_DIR/ParameterFiles/XGB-stereo-parameter.json" - IDS=$(jq -r '.zenith[].id' $STEREO_PAR) + IDS=$(jq -r '.zenith[].id' "$STEREO_PAR") for ZAB in $IDS; do # Explicitly remove 0.0 bin FIXEDWOBBLE="0.25 0.5 0.75 1.0 1.25 1.5 1.75 2.0" FIXEDNSB="160 200 350 450" "$(dirname "$0")/IRF.trainXGBforAngularReconstructionBinned.sh" \ - $VX $ATM $ZAB "$FIXEDWOBBLE" "$FIXEDNSB" 0 \ - $SIMTYPE $ANATYPE $UUID + "$VX" "$ATM" "$ZAB" "$FIXEDWOBBLE" "$FIXEDNSB" 0 \ + "$SIMTYPE" "$ANATYPE" "$UUID" done continue fi @@ -421,8 +420,8 @@ for VX in $EPOCH; do fi if [[ $IRFTYPE == "TRAINMVANGRES" ]]; then "$(dirname "$0")/IRF.trainTMVAforAngularReconstruction.sh" \ - $VX $ATM $ZA "$FIXEDWOBBLE" "$FIXEDNSB" 0 \ - $SIMTYPE $ANATYPE $UUID + "$VX" "$ATM" "$ZA" "$FIXEDWOBBLE" "$FIXEDNSB" 0 \ + "$SIMTYPE" "$ANATYPE" "$UUID" fi continue fi @@ -443,20 +442,20 @@ for VX in $EPOCH; do fi if [[ $IRFTYPE == "EVNDISP" ]]; then "$(dirname "$0")/IRF.evndisp_MC.sh" \ - $SIMDIRZA $VX $ATM $ZA $WOBBLE $NOISE \ - $SIMTYPE $ACUTS 1 $ANATYPE $UUID + "$SIMDIRZA" "$VX" "$ATM" "$ZA" "$WOBBLE" "$NOISE" \ + "$SIMTYPE" $ACUTS 1 "$ANATYPE" "$UUID" elif [[ $IRFTYPE == "EVNDISPCOMPRESS" ]]; then "$(dirname "$0")/IRF.compress_evndisp_MC.sh" \ - $SIMDIRZA $VX $ATM $ZA $WOBBLE $NOISE \ - $SIMTYPE $ANATYPE $UUID + "$SIMDIRZA" "$VX" "$ATM" "$ZA" "$WOBBLE" "$NOISE" \ + "$SIMTYPE" "$ANATYPE" "$UUID" fi ###################### # make tables elif [[ $IRFTYPE == "MAKETABLES" ]]; then for ID in $RECID; do "$(dirname "$0")/IRF.generate_lookup_table_parts.sh" \ - $VX $ATM $ZA $WOBBLE $NOISE \ - $ID $SIMTYPE $ANATYPE $UUID + "$VX" "$ATM" "$ZA" "$WOBBLE" "$NOISE" \ + "$ID" "$SIMTYPE" "$ANATYPE" "$UUID" done #recID ###################### # analyse table files @@ -472,8 +471,8 @@ for VX in $EPOCH; do EFFAREACUTLIST="$CUTSLISTFILE" fi "$(dirname "$0")/IRF.mscw_energy_MC.sh" \ - $TFILID $VX $ATM $ZA $WOBBLE $NOISE \ - $ID $SIMTYPE $ANATYPE $DISPBDT $EFFAREACUTLIST $UUID + "$TFILID" "$VX" "$ATM" "$ZA" "$WOBBLE" "$NOISE" \ + "$ID" "$SIMTYPE" "$ANATYPE" $DISPBDT "$EFFAREACUTLIST" "$UUID" done #recID ###################### # analyse effective areas @@ -484,9 +483,9 @@ for VX in $EPOCH; do for CUTS in "${CUTLIST[@]}"; do echo "calculate effective areas $CUTS (ID $ID)" "$(dirname "$0")/IRF.generate_effective_area_parts.sh" \ - $CUTS $VX $ATM $ZA $WOBBLE $NOISE \ - $ID $SIMTYPE $ANATYPE \ - $DISPBDT $UUID + "$CUTS" "$VX" "$ATM" "$ZA" "$WOBBLE" "$NOISE" \ + "$ID" "$SIMTYPE" "$ANATYPE" \ + $DISPBDT "$UUID" done # cuts done #recID fi diff --git a/scripts/IRF.selectRunsForGammaHadronSeparationTraining.sh b/scripts/IRF.selectRunsForGammaHadronSeparationTraining.sh index 6cca1bf..6374858 100755 --- a/scripts/IRF.selectRunsForGammaHadronSeparationTraining.sh +++ b/scripts/IRF.selectRunsForGammaHadronSeparationTraining.sh @@ -80,7 +80,7 @@ echo "Found ${#FLIST[@]} files to process" mkdir -p "${3}" # Pre-create zenith bin directories for efficiency -for (( j=0; j < $NZEW; j++ )); do +for (( j=0; j < NZEW; j++ )); do mkdir -p "${TARGETDIR}/Ze_${j}" done @@ -113,7 +113,7 @@ do fi # Get run info once and parse into array for efficiency - RUNINFO=$($EVNDISPSYS/bin/printRunParameter "${F}.root" -runinfo 2>/dev/null) + RUNINFO=$("$EVNDISPSYS"/bin/printRunParameter "${F}.root" -runinfo 2>/dev/null) if [[ -z "$RUNINFO" ]]; then [[ $VERBOSE -eq 1 ]] && echo " ERROR: Could not read run info" ((SKIPPED++)) @@ -167,7 +167,7 @@ do # Find zenith bin using numeric comparison (bc for float comparison) ZEBIN=0 - for (( j=0; j < $NZEW; j++ )); do + for (( j=0; j < NZEW; j++ )); do if (( $(echo "${RUNZENITH} > ${ZEBINARRAY[$j]}" | bc -l) )) && \ (( $(echo "${RUNZENITH} < ${ZEBINARRAY[$j+1]}" | bc -l) )); then ZEBIN=$j diff --git a/scripts/IRF.trainTMVAforAngularReconstruction.sh b/scripts/IRF.trainTMVAforAngularReconstruction.sh index 53e09ba..d354c53 100755 --- a/scripts/IRF.trainTMVAforAngularReconstruction.sh +++ b/scripts/IRF.trainTMVAforAngularReconstruction.sh @@ -2,11 +2,11 @@ # submit TMVA training for angular reconstruction # qsub parameters -# shellcheck disable=SC2034 +# shellcheck disable=SC2034 # SGE resource directives, read by job scheduler h_cpu=47:29:00; h_vmem=16000M; tmpdir_size=100G # EventDisplay version -EDVERSION=$(cat $VERITAS_EVNDISP_AUX_DIR/IRFVERSION) +EDVERSION=$(cat "$VERITAS_EVNDISP_AUX_DIR"/IRFVERSION) EVNIRFVERSION="v4N" if [ $# -lt 8 ]; then @@ -44,9 +44,8 @@ fi # Run init script if [ -z "$EVNDISP_APPTAINER" ]; then - bash "$(dirname "$0")/helper_scripts/UTILITY.script_init.sh" + bash "$(dirname "$0")/helper_scripts/UTILITY.script_init.sh" || exit 1 fi -[[ $? != "0" ]] && exit 1 EPOCH="$1" ATM="$2" @@ -79,8 +78,8 @@ BDTFILE="mvaAngRes_${ZA}deg" # prepare list of input files EVNLIST=$ODIR/${BDTFILE}.list -rm -f ${EVNLIST} -touch ${EVNLIST} +rm -f "${EVNLIST}" +touch "${EVNLIST}" check_evndisp_directory() { @@ -100,16 +99,16 @@ check_evndisp_directory() exit 1 fi fi - echo $INDIR + echo "$INDIR" } for W in ${WOBBLE} do for N in ${NOISE} do - check_evndisp_directory $W $N + check_evndisp_directory "$W" "$N" # choose a random file from all files - ls -1 $INDIR/*[0-9].root.zst | sort -R | head -n 1 >> ${EVNLIST} + find "$INDIR" -maxdepth 1 -name "*[0-9].root.zst" | sort -R | head -n 1 >> "${EVNLIST}" done done echo "FILE LIST: ${EVNLIST}" @@ -136,13 +135,14 @@ do # run locally or on cluster SUBC=$("$(dirname "$0")/helper_scripts/UTILITY.readSubmissionCommand.sh") - SUBC=`eval "echo \"$SUBC\""` + SUBC=$(eval "echo \"$SUBC\"") if [[ $SUBC == *"ERROR"* ]]; then - echo $SUBC + echo "$SUBC" exit fi if [[ $SUBC == *qsub* ]]; then - JOBID=`$SUBC $FSCRIPT` + # shellcheck disable=SC2086 + JOBID=$($SUBC "$FSCRIPT") echo "RUN $RUNNUM: JOBID $JOBID" elif [[ $SUBC == *condor* ]]; then "$(dirname "$0")/helper_scripts/UTILITY.condorSubmission.sh" "$FSCRIPT" "$h_vmem" "$tmpdir_size" @@ -153,7 +153,8 @@ do echo "-------------------------------------------------------------------------------" echo elif [[ $SUBC == *sbatch* ]]; then - $SUBC $FSCRIPT + # shellcheck disable=SC2086 + $SUBC "$FSCRIPT" elif [[ $SUBC == *parallel* ]]; then echo "$FSCRIPT &> $FSCRIPT.log" >> "$LOGDIR/runscripts.dat" fi diff --git a/scripts/IRF.trainTMVAforGammaHadronSeparation.sh b/scripts/IRF.trainTMVAforGammaHadronSeparation.sh index 8777f76..72d87a7 100755 --- a/scripts/IRF.trainTMVAforGammaHadronSeparation.sh +++ b/scripts/IRF.trainTMVAforGammaHadronSeparation.sh @@ -7,9 +7,9 @@ # - fixed of NSB levels (adapted to stdHV settings) # -# shellcheck disable=SC2034 +# shellcheck disable=SC2034 # SGE resource directives, read by job scheduler h_cpu=11:59:59; h_vmem=8000M; tmpdir_size=24G -EDVERSION=$(cat $VERITAS_EVNDISP_AUX_DIR/IRFVERSION) +EDVERSION=$(cat "$VERITAS_EVNDISP_AUX_DIR"/IRFVERSION) if [ $# -lt 7 ]; then echo " @@ -43,9 +43,8 @@ fi # Run init script if [ -z "$EVNDISP_APPTAINER" ]; then - bash "$(dirname "$0")/helper_scripts/UTILITY.script_init.sh" + bash "$(dirname "$0")/helper_scripts/UTILITY.script_init.sh" || exit 1 fi -[[ $? != "0" ]] && exit 1 BDIR="$1" RUNPAR="$2" @@ -85,7 +84,7 @@ if [[ ! -d "$BDIR" ]]; then fi # Check that TMVA run parameter file exists -if [[ "$RUNPAR" == `basename $RUNPAR` ]]; then +if [[ "$RUNPAR" == $(basename "$RUNPAR") ]]; then RUNPAR="$VERITAS_EVNDISP_AUX_DIR/ParameterFiles/$RUNPAR" fi if [[ ! -f "$RUNPAR" ]]; then @@ -93,14 +92,14 @@ if [[ ! -f "$RUNPAR" ]]; then exit 1 fi -RXPAR=`basename $RUNPAR .runparameter` +RXPAR=$(basename "$RUNPAR" .runparameter) echo "Original TMVA run parameter file: $RXPAR.runparameter " LOGDIR="$ODIR/TMVA.ANADATA.${UUID}" echo "Output: $ODIR" echo "Logs: $LOGDIR" -mkdir -p $LOGDIR -mkdir -p $ODIR +mkdir -p "$LOGDIR" +mkdir -p "$ODIR" ##################################### # Read runparameter file once for efficiency @@ -112,23 +111,23 @@ if echo "$RUNPAR_CONTENT" | grep -q "^\* ENERGYBINS"; then ENBINS=$(echo "$RUNPAR_CONTENT" | grep "^\* ENERGYBINS" | sed -e 's/* ENERGYBINS//' | sed -e 's/ /\n/g') mapfile -t EBINARRAY <<< "$ENBINS" count1=1 - NENE=$((${#EBINARRAY[@]}-$count1)) # get number of bins - for (( i=0; i < $NENE; i++ )) + NENE=$(( ${#EBINARRAY[@]}-count1 )) # get number of bins + for (( i=0; i < NENE; i++ )) do - EBINMIN[$i]=${EBINARRAY[$i]} - EBINMAX[$i]=${EBINARRAY[$i+1]} + EBINMIN[i]=${EBINARRAY[i]} + EBINMAX[i]=${EBINARRAY[i+1]} done else ENBINS=$(echo "$RUNPAR_CONTENT" | grep "^\* ENERGYBINEDGES" | sed -e 's/* ENERGYBINEDGES//' | sed -e 's/ /\n/g') mapfile -t EBINARRAY <<< "$ENBINS" count1=1 - NENE=$((${#EBINARRAY[@]}-$count1)) # get number of bins + NENE=$(( ${#EBINARRAY[@]}-count1 )) # get number of bins z="0" - for (( i=0; i < $NENE; i+=2 )) + for (( i=0; i < NENE; i+=2 )) do - EBINMIN[$z]=${EBINARRAY[$i]} - EBINMAX[$z]=${EBINARRAY[$i+1]} - let "z = ${z} + 1" + EBINMIN[z]=${EBINARRAY[i]} + EBINMAX[z]=${EBINARRAY[i+1]} + (( z++ )) done NENE=$((${#EBINMAX[@]})) fi @@ -137,7 +136,7 @@ fi # zenith angle bins ZEBINS=$(echo "$RUNPAR_CONTENT" | grep "^\* ZENBINS " | sed -e 's/* ZENBINS//' | sed -e 's/ /\n/g') mapfile -t ZEBINARRAY <<< "$ZEBINS" -NZEW=$((${#ZEBINARRAY[@]}-$count1)) #get number of bins +NZEW=$(( ${#ZEBINARRAY[@]}-count1 )) #get number of bins ##################################### # zenith angle bins of MC simulation files @@ -162,33 +161,33 @@ SUBSCRIPT="$(dirname "$0")/helper_scripts/IRF.trainTMVAforGammaHadronSeparation_ ############################################################### # loop over all energy/zenith bins and submit a job for each bin -for (( i=0; i < $NENE; i++ )) +for (( i=0; i < NENE; i++ )) do echo "===========================================================================" echo " " - echo "Energy Bin: $(($i+$count1)) of $NENE: ${EBINMIN[$i]} to ${EBINMAX[$i]} (in log TeV)" - for (( j=0; j < $NZEW; j++ )) + echo "Energy Bin: $((i+count1)) of $NENE: ${EBINMIN[$i]} to ${EBINMAX[$i]} (in log TeV)" + for (( j=0; j < NZEW; j++ )) do echo "---------------------------------------------------------------------------" - echo "Zenith Bin: $(($j+$count1)) of $NZEW: ${ZEBINARRAY[$j]} to ${ZEBINARRAY[$j+1]} (deg)" + echo "Zenith Bin: $((j+count1)) of $NZEW: ${ZEBINARRAY[$j]} to ${ZEBINARRAY[$j+1]} (deg)" # updating the run parameter file for each parameter space RFIL=$ODIR/$RXPAR"_$i""_$j" echo "TMVA Runparameter file: $RFIL.runparameter" - rm -f $RFIL + rm -f "$RFIL" - echo "* ENERGYBINS ${EBINMIN[$i]} ${EBINMAX[$i]}" > $RFIL.runparameter - echo "* ZENBINS ${ZEBINARRAY[$j]} ${ZEBINARRAY[$j+1]}" >> $RFIL.runparameter - echo "$RUNPAR_CONTENT" | grep "^\*" | grep -v ENERGYBINS | grep -v ENERGYBINEDGES | grep -v ZENBINS | grep -v OUTPUTFILE | grep -v SIGNALFILE | grep -v BACKGROUNDFILE | grep -v MCXYOFF >> $RFIL.runparameter + echo "* ENERGYBINS ${EBINMIN[$i]} ${EBINMAX[$i]}" > "$RFIL".runparameter + echo "* ZENBINS ${ZEBINARRAY[$j]} ${ZEBINARRAY[$j+1]}" >> "$RFIL".runparameter + echo "$RUNPAR_CONTENT" | grep "^\*" | grep -v ENERGYBINS | grep -v ENERGYBINEDGES | grep -v ZENBINS | grep -v OUTPUTFILE | grep -v SIGNALFILE | grep -v BACKGROUNDFILE | grep -v MCXYOFF >> "$RFIL".runparameter nTrainSignal=200000 nTrainBackground=200000 - echo "* PREPARE_TRAINING_OPTIONS SplitMode=Random:!V:nTrain_Signal=$nTrainSignal:nTrain_Background=$nTrainBackground::nTest_Signal=$nTrainSignal:nTest_Background=$nTrainBackground" >> $RFIL.runparameter - - echo "* OUTPUTFILE ODIR ${ONAME}_${i}_${j}" >> $RFIL.runparameter - - echo "#######################################################################################" >> $RFIL.runparameter + { + echo "* PREPARE_TRAINING_OPTIONS SplitMode=Random:!V:nTrain_Signal=$nTrainSignal:nTrain_Background=$nTrainBackground::nTest_Signal=$nTrainSignal:nTest_Background=$nTrainBackground" + echo "* OUTPUTFILE ODIR ${ONAME}_${i}_${j}" + echo "#######################################################################################" + } >> "$RFIL.runparameter" # signal and background files (depending on on-axis or cone data set) # Collect all signal files first, then write in one batch { @@ -223,17 +222,17 @@ do done fi shopt -u nullglob - } >> $RFIL.runparameter - echo "#######################################################################################" >> $RFIL.runparameter + } >> "$RFIL".runparameter + echo "#######################################################################################" >> "$RFIL".runparameter BLIST="$ODIR/BackgroundRunlist_Ze${j}.list" - rm -f ${BLIST} + rm -f "${BLIST}" if [[ ! -d "${BDIR}/Ze_${j}" ]]; then echo "Error, directory with background files ${BDIR}/Ze_${j} not found, exiting..." exit 1 fi # Optimized background file listing using awk instead of subshell per file # This replaces the get_run_prefix() function call for each file - find ${BDIR}/Ze_${j} -name "*.root" -printf "%f\n" | sort -n | \ + find "${BDIR}"/Ze_${j} -name "*.root" -printf "%f\n" | sort -n | \ awk '{ filename = $0; # Remove extension to get run number (equivalent to ${1%%.*}) @@ -255,20 +254,21 @@ do -e "s|MCDIRECTORY|$SDIR|" \ -e "s|DATADIRECTORY|$BCKFILEDIR|" \ -e "s|OUTPUTDIR|${ODIR}|" \ - -e "s|OUTNAME|$ODIR/$ONAME_${i}_${j}|" $SUBSCRIPT.sh > $FSCRIPT.sh + -e "s|OUTNAME|$ODIR/${ONAME}_${i}_${j}|" "$SUBSCRIPT".sh > "$FSCRIPT".sh - chmod u+x $FSCRIPT.sh - echo $FSCRIPT.sh + chmod u+x "$FSCRIPT".sh + echo "$FSCRIPT".sh # run locally or on cluster SUBC=$("$(dirname "$0")/helper_scripts/UTILITY.readSubmissionCommand.sh") SUBC=$(eval "echo \"$SUBC\"") if [[ $SUBC == *"ERROR"* ]]; then - echo $SUBC + echo "$SUBC" exit fi if [[ $SUBC == *qsub* ]]; then - JOBID=$($SUBC $FSCRIPT.sh) + # shellcheck disable=SC2086 + JOBID=$($SUBC "$FSCRIPT".sh) # account for -terse changing the job number format if [[ $SUBC != *-terse* ]] ; then echo "without -terse!" # need to match VVVVVVVV 8539483 and 3843483.1-4:2 @@ -284,10 +284,12 @@ do echo "-------------------------------------------------------------------------------" echo elif [[ $SUBC == *sbatch* ]]; then - $SUBC $FSCRIPT.sh + # shellcheck disable=SC2086 + $SUBC "$FSCRIPT".sh elif [[ $SUBC == *parallel* ]]; then - echo "$FSCRIPT.sh &> $FSCRIPT.log" >> $LOGDIR/runscripts.dat - cat $LOGDIR/runscripts.dat | $SUBC + echo "$FSCRIPT.sh &> $FSCRIPT.log" >> "$LOGDIR"/runscripts.dat + # shellcheck disable=SC2086 + cat "$LOGDIR"/runscripts.dat | $SUBC elif [[ "$SUBC" == *simple* ]] ; then "$FSCRIPT.sh" | tee "$FSCRIPT.log" fi diff --git a/scripts/IRF.trainXGBforAngularReconstructionBinned.sh b/scripts/IRF.trainXGBforAngularReconstructionBinned.sh index e78b2ab..7864ec0 100755 --- a/scripts/IRF.trainXGBforAngularReconstructionBinned.sh +++ b/scripts/IRF.trainXGBforAngularReconstructionBinned.sh @@ -1,10 +1,10 @@ #!/bin/bash # train XGB for angular reconstruction -# shellcheck disable=SC2034 +# shellcheck disable=SC2034 # SGE resource directives, read by job scheduler h_cpu=47:29:00; h_vmem=16000M; tmpdir_size=100G -EDVERSION=$(cat $VERITAS_EVNDISP_AUX_DIR/IRFVERSION) +EDVERSION=$(cat "$VERITAS_EVNDISP_AUX_DIR"/IRFVERSION) if [ $# -lt 7 ]; then echo " @@ -42,9 +42,8 @@ fi # Run init script if [ -z "$EVNDISP_APPTAINER" ]; then - bash "$(dirname "$0")/helper_scripts/UTILITY.script_init.sh" + bash "$(dirname "$0")/helper_scripts/UTILITY.script_init.sh" || exit 1 fi -[[ $? != "0" ]] && exit 1 EPOCH="$1" ATM="$2" @@ -71,13 +70,13 @@ echo "Logs: $LOGDIR" # prepare list of input files MSCWLIST="$ODIR/xgbFiles.list" -rm -f ${MSCWLIST} -touch ${MSCWLIST} +rm -f "${MSCWLIST}" +touch "${MSCWLIST}" INDIR="$VERITAS_IRFPRODUCTION_DIR/$EDVERSION/${ANALYSIS_TYPE}/$SIMTYPE/${EPOCH}_ATM${ATM}_gamma/MSCW_RECID${RECID}_DISP" STEREO_PAR="$VERITAS_EVNDISP_AUX_DIR/ParameterFiles/XGB-stereo-parameter.json" -TRAIN_ANGLES=$(jq -r ".zenith[] | select(.id==\"$ZA\") | .train | join(\" \")" $STEREO_PAR) +TRAIN_ANGLES=$(jq -r ".zenith[] | select(.id==\"$ZA\") | .train | join(\" \")" "$STEREO_PAR") if [[ -z "$TRAIN_ANGLES" ]]; then echo "Error: Bin ID $ZA not found in $STEREO_PAR" exit 1 @@ -113,13 +112,14 @@ echo "$FSCRIPT" # run locally or on cluster SUBC=$("$(dirname "$0")/helper_scripts/UTILITY.readSubmissionCommand.sh") -SUBC=`eval "echo \"$SUBC\""` +SUBC=$(eval "echo \"$SUBC\"") if [[ $SUBC == *"ERROR"* ]]; then - echo $SUBC + echo "$SUBC" exit fi if [[ $SUBC == *qsub* ]]; then - JOBID=`$SUBC $FSCRIPT` + # shellcheck disable=SC2086 + JOBID=$($SUBC "$FSCRIPT") echo "RUN $RUNNUM: JOBID $JOBID" elif [[ $SUBC == *condor* ]]; then "$(dirname "$0")/helper_scripts/UTILITY.condorSubmission.sh" "$FSCRIPT" "$h_vmem" "$tmpdir_size" @@ -130,7 +130,8 @@ elif [[ $SUBC == *condor* ]]; then echo "-------------------------------------------------------------------------------" echo elif [[ $SUBC == *sbatch* ]]; then - $SUBC $FSCRIPT + # shellcheck disable=SC2086 + $SUBC "$FSCRIPT" elif [[ $SUBC == *parallel* ]]; then echo "$FSCRIPT &> $FSCRIPT.log" >> "$LOGDIR/runscripts.dat" fi diff --git a/scripts/IRF.trainXGBforGammaHadronSeparationTraining.sh b/scripts/IRF.trainXGBforGammaHadronSeparationTraining.sh index 6c21614..632fbb9 100755 --- a/scripts/IRF.trainXGBforGammaHadronSeparationTraining.sh +++ b/scripts/IRF.trainXGBforGammaHadronSeparationTraining.sh @@ -3,9 +3,9 @@ # # - training at wobble offsets 0.5 deg only -# shellcheck disable=SC2034 +# shellcheck disable=SC2034 # SGE resource directives, read by job scheduler h_cpu=11:59:59; h_vmem=16000M; tmpdir_size=24G -EDVERSION=$(cat $VERITAS_EVNDISP_AUX_DIR/IRFVERSION) +EDVERSION=$(cat "$VERITAS_EVNDISP_AUX_DIR"/IRFVERSION) if [ $# -lt 6 ]; then echo " @@ -37,9 +37,8 @@ fi # Run init script if [ -z "$EVNDISP_APPTAINER" ]; then - bash "$(dirname "$0")/helper_scripts/UTILITY.script_init.sh" + bash "$(dirname "$0")/helper_scripts/UTILITY.script_init.sh" || exit 1 fi -[[ $? != "0" ]] && exit 1 BDIR="$1" RUNPAR="$2" @@ -77,7 +76,7 @@ if [[ ! -d "$BDIR" ]]; then fi # Check that XGB run parameter file exists -if [[ "$RUNPAR" == `basename $RUNPAR` ]]; then +if [[ "$RUNPAR" == $(basename "$RUNPAR") ]]; then RUNPAR="$VERITAS_EVNDISP_AUX_DIR/ParameterFiles/$RUNPAR" fi if [[ ! -f "$RUNPAR" ]]; then @@ -88,14 +87,13 @@ fi LOGDIR="$ODIR/XGB.ANADATA.${UUID}" echo "Output: $ODIR" echo "Logs: $LOGDIR" -mkdir -p $LOGDIR -mkdir -p $ODIR +mkdir -p "$LOGDIR" +mkdir -p "$ODIR" ##################################### # energy / zenith bins NENE=$(jq '.energy_bins_log10_tev | length' "$RUNPAR") NEZE=$(jq '.zenith_bins_deg | length' "$RUNPAR") -RUNPAR_CONTENT=$(cat "$RUNPAR") echo "Number of energy / zenith bins: $NENE $NEZE" ##################################### @@ -135,7 +133,7 @@ if [[ ${SIMTYPE:0:5} = "GRISU" ]]; then else for z in "${ZENITH_ANGLES[@]}"; do for n in "${NOISE_VALUES[@]}"; do - for f in "$SDIR"/${z}deg_*wob_NOISE${n}.mscw.root; do + for f in "$SDIR"/"${z}"deg_*wob_NOISE"${n}".mscw.root; do [[ -f "$f" ]] && echo "$f" >> "$SIGNALLIST" done @@ -148,19 +146,19 @@ echo "Background file list: $BCKLIST" rm -f "${BCKLIST}" touch "${BCKLIST}" tmpfile=$(mktemp) -for ((i=0; i<${NEZE}; i++)); do +for ((i=0; i> "${tmpfile}" + find "${BDIR}"/Ze_${i} -name "*.root" | shuf -n 1000 >> "${tmpfile}" done shuf "$tmpfile" > "${BCKLIST}" rm "$tmpfile" ############################################################### # loop over energy bins and submit a job for each bin -for (( i=0; i < $NENE; i++ )); do +for (( i=0; i < NENE; i++ )); do echo "Energy Bin: $i" FSCRIPT=$LOGDIR/XGBGAMMA"_$EPOCH""_ENERGY$i.sh" @@ -168,16 +166,16 @@ for (( i=0; i < $NENE; i++ )); do -e "s|MSCWBCK|$BCKLIST|" \ -e "s|MODELPARA|$RUNPAR|" \ -e "s|ENERGYBIN|$i|" \ - -e "s|OUTPUTDIR|${ODIR}|" $SUBSCRIPT > $FSCRIPT + -e "s|OUTPUTDIR|${ODIR}|" "$SUBSCRIPT" > "$FSCRIPT" - chmod u+x $FSCRIPT - echo $FSCRIPT + chmod u+x "$FSCRIPT" + echo "$FSCRIPT" # run locally or on cluster SUBC=$("$(dirname "$0")/helper_scripts/UTILITY.readSubmissionCommand.sh") SUBC=$(eval "echo \"$SUBC\"") if [[ $SUBC == *"ERROR"* ]]; then - echo $SUBC + echo "$SUBC" exit fi "$(dirname "$0")/helper_scripts/UTILITY.condorSubmission.sh" "$FSCRIPT" "$h_vmem" "$tmpdir_size" diff --git a/scripts/RUNLIST.findBackgroundRuns.sh b/scripts/RUNLIST.findBackgroundRuns.sh index e97c622..ab7895d 100755 --- a/scripts/RUNLIST.findBackgroundRuns.sh +++ b/scripts/RUNLIST.findBackgroundRuns.sh @@ -56,15 +56,14 @@ exit fi # Run init script -bash "$( cd "$( dirname "$0" )" && pwd )/helper_scripts/UTILITY.script_init.sh" -[[ $? != "0" ]] && exit 1 +bash "$( cd "$( dirname "$0" )" && pwd )/helper_scripts/UTILITY.script_init.sh" || exit 1 # Parse command line arguments [[ "$1" ]] && ALLOW_THREE_TEL=$1 || ALLOW_THREE_TEL=0 [[ "$2" ]] && WORST_WEATHER=$2 || WORST_WEATHER='B' [[ "$3" ]] && MIN_DURATION=$3 || MIN_DURATION=15 [[ "$4" ]] && DATE_BEG="$4" || DATE_BEG="2011-01-01" -[[ "$5" ]] && DATE_END="$5" || DATE_END=`date +"%Y-%m-%d"` +[[ "$5" ]] && DATE_END="$5" || DATE_END=$(date +"%Y-%m-%d") [[ "$6" ]] && MODE="$6" || MODE="observing" [[ "$7" ]] && DQMCATEGORY="$7" || DQMCATEGORY="science" [[ "$8" ]] && ELEVSTRING="$8" || ELEVSTRING="" @@ -112,7 +111,7 @@ MAXAZIM=$( echo "$AZIMSTRING" | cut -d '-' -f 2 ) #echo "MAXAZIM:'$MAXAZIM'" # Get VERITAS database URL from EVNDISP.global.runparameter file -MYSQLDB=`grep '^\*[ \t]*DBSERVER[ \t]*mysql://' $VERITAS_EVNDISP_AUX_DIR/ParameterFiles/EVNDISP.global.runparameter | egrep -o '[[:alpha:]]{1,20}\.[[:alpha:]]{1,20}\.[[:alpha:]]{1,20}'` +MYSQLDB=$(grep '^\*[ \t]*DBSERVER[ \t]*mysql://' "$VERITAS_EVNDISP_AUX_DIR"/ParameterFiles/EVNDISP.global.runparameter | grep -E -o '[[:alpha:]]{1,20}\.[[:alpha:]]{1,20}\.[[:alpha:]]{1,20}') if [ ! -n "$MYSQLDB" ]; then echo "* DBSERVER param not found in \$VERITAS_EVNDISP_AUX_DIR/ParameterFiles/EVNDISP.global.runparameter!" exit 1 @@ -121,7 +120,7 @@ MYSQL="mysql -u readonly -h $MYSQLDB -A" # get segments of time that are within our time, azimuth, and elevation bounts #echo "submitting database request..." -TIMESEGMENTS=$( $EVNDISPSYS/bin/VTS.getObservingTimesWithinTimeAzElBounds "$DATE_BEG" "$DATE_END" "$MINELEV" "$MAXELEV" "$MINAZIM" "$MAXAZIM" | grep -P "^MJDSEGMENT" | awk '{ printf "%s %s\n", $2, $4 }' ) +TIMESEGMENTS=$( "$EVNDISPSYS"/bin/VTS.getObservingTimesWithinTimeAzElBounds "$DATE_BEG" "$DATE_END" "$MINELEV" "$MAXELEV" "$MINAZIM" "$MAXAZIM" | grep -P "^MJDSEGMENT" | awk '{ printf "%s %s\n", $2, $4 }' ) #echo "TIMESEGMENTS:" #echo "$TIMESEGMENTS" @@ -129,7 +128,7 @@ TIMESEGMENTS=$( $EVNDISPSYS/bin/VTS.getObservingTimesWithinTimeAzElBounds "$DATE # which runs fall into these time segments TIMESEGCONDITION="" segmentiter=0 -while read lin ; do +while read -r lin ; do segmentiter=$((segmentiter+1)) #echo "$segmentiter - lin:'$lin'" mjdstart=$( echo "$lin" | cut -d ' ' -f 1 ) diff --git a/scripts/RUNLIST.findDBSourceCoordinates.sh b/scripts/RUNLIST.findDBSourceCoordinates.sh index 6ebfa0c..1d78307 100755 --- a/scripts/RUNLIST.findDBSourceCoordinates.sh +++ b/scripts/RUNLIST.findDBSourceCoordinates.sh @@ -2,15 +2,15 @@ if [ ! "$#" -eq "1" ] || [ "$1" = "-h" ] ; then echo "Print the coordinates of a source" ; echo - echo "`basename $0` " ; echo + echo "$(basename "$0") " ; echo echo " : The name of the source, as stored in VERITAS.tblObserving_Sources" echo " or from \$EVNDISPSYS/scripts/VTS/RUNLIST.findDBSourceCoordinates.sh" ; echo echo "Examples:" ; echo echo " Print the Crab's position:" - echo " $ `basename $0` \"Crab\"" + echo " $ $(basename "$0") \"Crab\"" echo " 83.633349 22.014475" ; echo echo " Print Markarian 501's position:" - echo " $ `basename $0` \"Mrk501\"" + echo " $ $(basename "$0") \"Mrk501\"" echo " 253.467529 39.760300" ; echo echo "Source name should be from the database table VERITAS.tblObserving_Sources ," echo "Prints the RA/DEC (in degrees, J2000 epoch) of the sourcename, as stored in the database." @@ -26,7 +26,7 @@ SOURCENAME="$1" #echo "Searching for sources that contain '$SOURCENAME'" # get url of veritas db -MYSQLDB=`grep '^\*[ \t]*DBSERVER[ \t]*mysql://' $VERITAS_EVNDISP_AUX_DIR/ParameterFiles/EVNDISP.global.runparameter | egrep -o '[[:alpha:]]{1,20}\.[[:alpha:]]{1,20}\.[[:alpha:]]{1,20}'` +MYSQLDB=$(grep '^\*[ \t]*DBSERVER[ \t]*mysql://' "$VERITAS_EVNDISP_AUX_DIR"/ParameterFiles/EVNDISP.global.runparameter | grep -E -o '[[:alpha:]]{1,20}\.[[:alpha:]]{1,20}\.[[:alpha:]]{1,20}') if [ ! -n "$MYSQLDB" ] ; then echo "* DBSERVER param not found in \$VERITAS_EVNDISP_AUX_DIR/ParameterFiles/EVNDISP.global.runparameter!" exit 1 @@ -39,8 +39,8 @@ while read -r EPOCH RA DEC _; do if [[ "$EPOCH" == "2000" ]] ; then SRCRADEG=$( bc -l <<< "$RA * 180.0 / 3.141592" ) # convert radians to degrees SRCDECDEG=$( bc -l <<< "$DEC * 180.0 / 3.141592" ) - SRCRADEG=$( printf "%9.6f" $SRCRADEG ) - SRCDECDEG=$( printf "%9.6f" $SRCDECDEG ) + SRCRADEG=$( printf "%9.6f" "$SRCRADEG" ) + SRCDECDEG=$( printf "%9.6f" "$SRCDECDEG" ) echo "$SRCRADEG $SRCDECDEG" exit 0 fi diff --git a/scripts/RUNLIST.findDBSourceNames.sh b/scripts/RUNLIST.findDBSourceNames.sh index 8f1c6c9..ab6d35b 100755 --- a/scripts/RUNLIST.findDBSourceNames.sh +++ b/scripts/RUNLIST.findDBSourceNames.sh @@ -41,15 +41,14 @@ exit fi # Run init script -bash "$( cd "$( dirname "$0" )" && pwd )/helper_scripts/UTILITY.script_init.sh" -[[ $? != "0" ]] && exit 1 +bash "$( cd "$( dirname "$0" )" && pwd )/helper_scripts/UTILITY.script_init.sh" || exit 1 # Parse command line arguments SEARCHSTR="$1" echo "Searching for sources that contain '$SEARCHSTR'" # get url of veritas db -MYSQLDB=`grep '^\*[ \t]*DBSERVER[ \t]*mysql://' $VERITAS_EVNDISP_AUX_DIR/ParameterFiles/EVNDISP.global.runparameter | egrep -o '[[:alpha:]]{1,20}\.[[:alpha:]]{1,20}\.[[:alpha:]]{1,20}'` +MYSQLDB=$(grep '^\*[ \t]*DBSERVER[ \t]*mysql://' "$VERITAS_EVNDISP_AUX_DIR"/ParameterFiles/EVNDISP.global.runparameter | grep -E -o '[[:alpha:]]{1,20}\.[[:alpha:]]{1,20}\.[[:alpha:]]{1,20}') if [ ! -n "$MYSQLDB" ] ; then echo "* DBSERVER param not found in \$VERITAS_EVNDISP_AUX_DIR/ParameterFiles/EVNDISP.global.runparameter!" exit 1 diff --git a/scripts/RUNLIST.generate.sh b/scripts/RUNLIST.generate.sh index cf6c60d..a8b3984 100755 --- a/scripts/RUNLIST.generate.sh +++ b/scripts/RUNLIST.generate.sh @@ -45,8 +45,7 @@ exit fi # Run init script -bash "$( cd "$( dirname "$0" )" && pwd )/helper_scripts/UTILITY.script_init.sh" -[[ $? != "0" ]] && exit 1 +bash "$( cd "$( dirname "$0" )" && pwd )/helper_scripts/UTILITY.script_init.sh" || exit 1 # Parse command line arguments SOURCE_NAME=$1 @@ -78,7 +77,7 @@ for (( i=0; i < ${#WEATHER_GRADES[@]}; i++ )); do done # Get VERITAS database URL from EVNDISP.global.runparameter file -MYSQLDB=`grep '^\*[ \t]*DBSERVER[ \t]*mysql://' $VERITAS_EVNDISP_AUX_DIR/ParameterFiles/EVNDISP.global.runparameter | egrep -o '[[:alpha:]]{1,20}\.[[:alpha:]]{1,20}\.[[:alpha:]]{1,20}'` +MYSQLDB=$(grep '^\*[ \t]*DBSERVER[ \t]*mysql://' "$VERITAS_EVNDISP_AUX_DIR"/ParameterFiles/EVNDISP.global.runparameter | grep -E -o '[[:alpha:]]{1,20}\.[[:alpha:]]{1,20}\.[[:alpha:]]{1,20}') if [ ! -n "$MYSQLDB" ]; then echo "* DBSERVER param not found in \$VERITAS_EVNDISP_AUX_DIR/ParameterFiles/EVNDISP.global.runparameter!" exit 1 diff --git a/scripts/RUNLIST.preprocessing.sh b/scripts/RUNLIST.preprocessing.sh index 3a3c653..70fce6c 100755 --- a/scripts/RUNLIST.preprocessing.sh +++ b/scripts/RUNLIST.preprocessing.sh @@ -24,8 +24,7 @@ exit fi # Run init script -bash "$( cd "$( dirname "$0" )" && pwd )/helper_scripts/UTILITY.script_init.sh" -[[ $? != "0" ]] && exit 1 +bash "$( cd "$( dirname "$0" )" && pwd )/helper_scripts/UTILITY.script_init.sh" || exit 1 # Parse command line arguments [[ "$1" ]] && START_DATE=$1" 00:00:00" || START_DATE="2011-01-01 00:00:00" @@ -41,7 +40,7 @@ TEL_MASKS="('15', '7', '11', '13', '14')" TEL_CUT_MASKS="('0', '8', '4', '2', '1')" # Get VERITAS database URL from EVNDISP.global.runparameter file -MYSQLDB=`grep '^\*[ \t]*DBSERVER[ \t]*mysql://' $VERITAS_EVNDISP_AUX_DIR/ParameterFiles/EVNDISP.global.runparameter | egrep -o '[[:alpha:]]{1,20}\.[[:alpha:]]{1,20}\.[[:alpha:]]{1,20}'` +MYSQLDB=$(grep '^\*[ \t]*DBSERVER[ \t]*mysql://' "$VERITAS_EVNDISP_AUX_DIR"/ParameterFiles/EVNDISP.global.runparameter | grep -E -o '[[:alpha:]]{1,20}\.[[:alpha:]]{1,20}\.[[:alpha:]]{1,20}') if [ ! -n "$MYSQLDB" ]; then echo "* DBSERVER param not found in \$VERITAS_EVNDISP_AUX_DIR/ParameterFiles/EVNDISP.global.runparameter!" exit 1 diff --git a/scripts/RUNLIST.whichRunsAreArrayEpoch.sh b/scripts/RUNLIST.whichRunsAreArrayEpoch.sh index 95bf5d4..09c541b 100755 --- a/scripts/RUNLIST.whichRunsAreArrayEpoch.sh +++ b/scripts/RUNLIST.whichRunsAreArrayEpoch.sh @@ -3,19 +3,19 @@ #echo "\$#:$# \$1:$1 \$2:$2 \$3:$3 \$4:$4" -ISPIPEFILE=`readlink /dev/fd/0` # check to see if input is from terminal, or from a pipe +ISPIPEFILE=$(readlink /dev/fd/0) # check to see if input is from terminal, or from a pipe #echo "\$ISPIPEFILE: '$ISPIPEFILE'" if [[ "$ISPIPEFILE" =~ ^/dev/pts/[0-9]{1,2} ]] ; then # its a terminal (not a pipe) if ! [ $# -eq 2 ] ; then # the human didn't add any arguments, and we must tell them so echo "Prints the run numbers that are of the specific run versions runs." echo " for just V4 runs, do" - echo " $ `basename $0` 4 " + echo " $ $(basename "$0") 4 " echo " for just V5 runs, do" - echo " $ `basename $0` 5 " + echo " $ $(basename "$0") 5 " echo " for just V6_2014 and V6_2015 (scaling tests, do not use in production) runs, do" - echo " $ `basename $0` 6_2014,6_2015 " + echo " $ $(basename "$0") 6_2014,6_2015 " echo " to print all V5 and V6 runs, do" - echo " $ `basename $0` 5,6 " + echo " $ $(basename "$0") 5,6 " exit fi fi @@ -24,11 +24,11 @@ INPUTEPOCH="$1" # list of run_id's to read in RUNFILE=$2 -if [ ! -e $RUNFILE ] ; then +if [ ! -e "$RUNFILE" ] ; then echo "File $RUNFILE could not be found in $PWD , sorry." exit fi -RUNLIST=`cat $RUNFILE` +RUNLIST=$(cat "$RUNFILE") #echo "RUNLIST:$RUNLIST" # how should we get the array epochs? @@ -40,7 +40,7 @@ if [[ "$METHOD" == "irfperiod" ]]; then PARAMFILE="$VERITAS_EVNDISP_AUX_DIR/ParameterFiles/VERITAS.Epochs.runparameter" # get only lines that start with '*' - EPOCHTHRESH=$( cat $PARAMFILE | grep -P "^\s??\*" | grep "EPOCH" | grep -P "V\d" ) + EPOCHTHRESH=$( cat "$PARAMFILE" | grep -P "^\s??\*" | grep "EPOCH" | grep -P "V\d" ) AVAILABLEEPOCHS=$( echo "$EPOCHTHRESH" | awk '{ print $3 }' ) DESIREDPERIODS=$( echo "$INPUTEPOCH" | sed 's/\,/ /g' | sed 's/\;/ /g' | tr " " "\n" ) # loop over runs in runlist @@ -69,7 +69,7 @@ if [[ "$METHOD" == "useparamfile" ]] ; then PARAMFILE="$VERITAS_EVNDISP_AUX_DIR/ParameterFiles/VERITAS.Epochs.runparameter" # get only lines that start with '*' - EPOCHTHRESH=$( cat $PARAMFILE | grep -P "^\s??\*" | grep "EPOCH" | grep -P "V\d" ) + EPOCHTHRESH=$( cat "$PARAMFILE" | grep -P "^\s??\*" | grep "EPOCH" | grep -P "V\d" ) #echo "$EPOCHTHRESH" # find out what are the smallest and largest epochs to work with @@ -85,7 +85,7 @@ if [[ "$METHOD" == "useparamfile" ]] ; then for run in $RUNLIST ; do # loop through all epochs between min and max - for epoch in $(seq $MINEPOCH $MAXEPOCH) ; do + for epoch in $(seq "$MINEPOCH" "$MAXEPOCH") ; do # check to see if the user wants each epoch if [[ $INPUTEPOCH == *$epoch* ]] ; then diff --git a/scripts/RUNLIST.whichRunsAreAtmosphere.sh b/scripts/RUNLIST.whichRunsAreAtmosphere.sh index a78035e..7bdb592 100755 --- a/scripts/RUNLIST.whichRunsAreAtmosphere.sh +++ b/scripts/RUNLIST.whichRunsAreAtmosphere.sh @@ -2,18 +2,18 @@ # from a run list, prints the list of runs that were taken in a specific atmosphere, summer(22/62) or winter(21/61) # check to see if input is from terminal, or from a pipe -ISPIPEFILE=`readlink /dev/fd/0` +ISPIPEFILE=$(readlink /dev/fd/0) if [[ "$ISPIPEFILE" =~ ^/dev/pts/[0-9]{1,2} && $# -lt 2 ]]; then # its a terminal (not a pipe) echo echo "From a runlist or pipe, prints the run numbers that are of a particular atmosphere." - echo " $ `basename $0` [w|21|s|22] " ; echo + echo " $ $(basename "$0") [w|21|s|22] " ; echo echo "w = 21 = 61 = winter, s = 22 = 62 = summer" ; echo echo "Print list of summer runs:" - echo " $ `basename $0` s myrunlist.dat" ; echo + echo " $ $(basename "$0") s myrunlist.dat" ; echo echo "Print list of winter runs:" - echo " $ `basename $0` 61 myrunlist.dat" ; echo + echo " $ $(basename "$0") 61 myrunlist.dat" ; echo echo "Works with pipes : " - echo " $ cat myrunlist.dat | `basename $0` w" ; echo + echo " $ cat myrunlist.dat | $(basename "$0") w" ; echo echo "Summer/winter transition dates taken from $VERITAS_EVNDISP_AUX_DIR/ParameterFiles/VERITAS.Epochs.runparameter" exit fi @@ -22,16 +22,16 @@ function echoerr(){ echo "$@" 1>&2; } #for spitting out error text # list of run_id's to read in RUNFILE=$2 -if [ ! -e $RUNFILE ] ; then +if [ ! -e "$RUNFILE" ] ; then echo "File $RUNFILE could not be found in $PWD , sorry." exit fi -RUNLIST=`cat $RUNFILE` +RUNLIST=$(cat "$RUNFILE") #echo "RUNLIST:$RUNLIST" SUMMFLAG=false WINTFLAG=false -LOWARG=`echo "$1" | tr '[A-Z]' '[a-z]'` # make all uppercase letters in arg 1 lowercase, for easier handling +LOWARG=$(echo "$1" | tr '[:upper:]' '[:lower:]') # make all uppercase letters in arg 1 lowercase, for easier handling #echo "\$LOWARG: '$LOWARG'" if [[ "$LOWARG" == *w* ]] || [[ "$LOWARG" == "21" ]] || [[ "$LOWARG" == "61" ]] ; then WINTFLAG=true @@ -73,9 +73,7 @@ function IsWinter { local ATMOCODE="" local MINDATE="" local MAXDATE="" - (IFS=' -' - for line in $ATMOTHRESH ; do + while IFS= read -r line ; do #echoerr "line:$line" ATMOCODE=$( echo "$line" | awk '{ print $3 }' | grep -oP "\d+" ) MINDATE=$( echo "$line" | awk '{ print $4 }' | tr -d '-' | grep -oP "\d+" ) @@ -99,8 +97,7 @@ function IsWinter { break fi fi - done - ) + done <<< "$ATMOTHRESH" # 3 = did not find valid atmo range if [ ! $FOUNDATMO ] ; then echo 3 @@ -142,7 +139,7 @@ function badAtmosphere { } # get database url from parameter file -MYSQLDB=`grep '^\*[ \t]*DBSERVER[ \t]*mysql://' "$VERITAS_EVNDISP_AUX_DIR/ParameterFiles/EVNDISP.global.runparameter" | egrep -o '[[:alpha:]]{1,20}\.[[:alpha:]]{1,20}\.[[:alpha:]]{1,20}'` +MYSQLDB=$(grep '^\*[ \t]*DBSERVER[ \t]*mysql://' "$VERITAS_EVNDISP_AUX_DIR/ParameterFiles/EVNDISP.global.runparameter" | grep -E -o '[[:alpha:]]{1,20}\.[[:alpha:]]{1,20}\.[[:alpha:]]{1,20}') if [ ! -n "$MYSQLDB" ] ; then echo "* DBSERVER param not found in \$VERITAS_EVNDISP_AUX_DIR/ParameterFiles/EVNDISP.global.runparameter!" @@ -158,7 +155,7 @@ MYSQL="mysql -u readonly -h $MYSQLDB -A" COUNT=0 SUB="" for ARUN in $RUNLIST ; do - if (( $ARUN > 0 )); then + if (( ARUN > 0 )); then if [[ "$COUNT" -eq 0 ]] ; then SUB="run_id = $ARUN" else @@ -180,7 +177,7 @@ while read -r RUNID RUNDATE ; do #echo " YEARMONTHDAY:$YY$MM$DD" # get the atmosphere code - STATUSFLAG=`IsWinter "$YY$MM$DD"` + STATUSFLAG=$(IsWinter "$YY$MM$DD") #echo "$RUNID '$STATUSFLAG'" # did the user ask for summer runs? diff --git a/scripts/RUNLIST.whichRunsAreObservingMode.sh b/scripts/RUNLIST.whichRunsAreObservingMode.sh index c840949..f53d569 100755 --- a/scripts/RUNLIST.whichRunsAreObservingMode.sh +++ b/scripts/RUNLIST.whichRunsAreObservingMode.sh @@ -2,15 +2,15 @@ # from a run list, prints the list of runs that were taken in a specific observing mode (observing, obsLowHV, obsFilter,...) # -ISPIPEFILE=`readlink /dev/fd/0` # check to see if input is from terminal, or from a pipe +ISPIPEFILE=$(readlink /dev/fd/0) # check to see if input is from terminal, or from a pipe if [[ "$ISPIPEFILE" =~ ^/dev/pts/[0-9]{1,2} ]] ; then # its a terminal (not a pipe) if ! [ $# -eq 2 ] ; then # the human didn't add any arguments, and we must tell them so echo echo "From a runlist or pipe, prints the run numbers that have been taken in a particular observing mode." echo "Usage: " - echo " $ `basename $0` " + echo " $ $(basename "$0") " echo "or" - echo " $ cat myrunlist.dat | `basename $0` " ; echo + echo " $ cat myrunlist.dat | $(basename "$0") " ; echo echo " = observing for regular runs" echo " obsLowHV for runs taken with reduced HV" echo " obsFilter for runs taken with UV filters" @@ -23,17 +23,17 @@ fi # list of run_ids to read in RUNFILE=$2 -if [ ! -e $RUNFILE ] ; then +if [ ! -e "$RUNFILE" ] ; then echoerr "File $RUNFILE could not be found in $PWD , sorry." exit 1 fi -RUNLIST=`cat $RUNFILE` +RUNLIST=$(cat "$RUNFILE") #echo "RUNLIST:$RUNLIST" MODE="$1" # get database url from parameter file -MYSQLDB=`grep '^\*[ \t]*DBSERVER[ \t]*mysql://' "$VERITAS_EVNDISP_AUX_DIR/ParameterFiles/EVNDISP.global.runparameter" | egrep -o '[[:alpha:]]{1,20}\.[[:alpha:]]{1,20}\.[[:alpha:]]{1,20}'` +MYSQLDB=$(grep '^\*[ \t]*DBSERVER[ \t]*mysql://' "$VERITAS_EVNDISP_AUX_DIR/ParameterFiles/EVNDISP.global.runparameter" | grep -E -o '[[:alpha:]]{1,20}\.[[:alpha:]]{1,20}\.[[:alpha:]]{1,20}') if [ ! -n "$MYSQLDB" ] ; then echo "* DBSERVER param not found in \$VERITAS_EVNDISP_AUX_DIR/ParameterFiles/EVNDISP.global.runparameter!" @@ -49,7 +49,7 @@ MYSQL="mysql -u readonly -h $MYSQLDB -A" COUNT=0 SUB="" for ARUN in $RUNLIST ; do - if (( $ARUN > 0 )); then + if (( ARUN > 0 )); then if [[ "$COUNT" -eq 0 ]] ; then SUB="run_id = $ARUN" else diff --git a/scripts/RUNLIST.whichRunsAreOnDisk.sh b/scripts/RUNLIST.whichRunsAreOnDisk.sh index 5a41b72..8e27741 100755 --- a/scripts/RUNLIST.whichRunsAreOnDisk.sh +++ b/scripts/RUNLIST.whichRunsAreOnDisk.sh @@ -6,10 +6,10 @@ DATFLAG=false # flat to print full date of run HELPFLAG=false # if true, print help text and exit PRINTPATH=false # if true, print full path of file on disl DOWNLOADFLAG=true -RAWDATASERVER=$(grep "\* VTSRAWDATA" $VERITAS_EVNDISP_AUX_DIR/ParameterFiles/EVNDISP.global.runparameter | awk '{print $3}') -#echo "INP:'`basename $0`' '$1' '$2' '$3'" +RAWDATASERVER=$(grep "\* VTSRAWDATA" "$VERITAS_EVNDISP_AUX_DIR"/ParameterFiles/EVNDISP.global.runparameter | awk '{print $3}') +#echo "INP:'$(basename $0)' '$1' '$2' '$3'" -ISPIPEFILE=`readlink /dev/fd/0` # check to see if input is from terminal, or from a pipe +ISPIPEFILE=$(readlink /dev/fd/0) # check to see if input is from terminal, or from a pipe if [[ "$ISPIPEFILE" =~ ^/dev/pts/[0-9]{1,2} ]] ; then # its a terminal (not a pipe) if [ "$#" -eq "1" ] ; then # format is "exe " RUNFILE=$1 @@ -21,7 +21,7 @@ if [[ "$ISPIPEFILE" =~ ^/dev/pts/[0-9]{1,2} ]] ; then # its a terminal (not a pi PRINTPATH=true RUNFILE=$2 else - echo " Error: `basename $0` doesn't understand flag $1. Only acceptable flag is -n" + echo " Error: $(basename "$0") doesn't understand flag $1. Only acceptable flag is -n" HELPFLAG=true fi else @@ -42,7 +42,7 @@ else # it is a pipe DATFLAG=true RUNFILE=$2 else - echo " Error: `basename $0` doesn't understand flag $1. Only acceptable flag is -n" + echo " Error: $(basename "$0") doesn't understand flag $1. Only acceptable flag is -n" HELPFLAG=true fi else @@ -54,13 +54,13 @@ fi if $HELPFLAG ; then echo echo "Prints the run numbers that ARE stored on disk." ; echo - echo " $ `basename $0` " ; echo + echo " $ $(basename "$0") " ; echo echo "Prints the full path of runs that ARE stored on disk." ; echo - echo " $ `basename $0` -p " ; echo + echo " $ $(basename "$0") -p " ; echo echo "Prints the run numbers that are NOT stored on disk" ; echo - echo " $ `basename $0` -n " ; echo - echo " $ cat | `basename $0`" ; echo - echo " $ cat | `basename $0` -n" ; echo + echo " $ $(basename "$0") -n " ; echo + echo " $ cat | $(basename "$0")" ; echo + echo " $ cat | $(basename "$0") -n" ; echo exit fi @@ -68,11 +68,11 @@ fi # list of run_id's to read in #RUNFILE=$1 -if [ ! -e $RUNFILE ] ; then +if [ ! -e "$RUNFILE" ] ; then echo "File '$RUNFILE' could not be found, sorry." exit fi -RUNLISTTMP=`cat $RUNFILE` +RUNLISTTMP=$(cat "$RUNFILE") RUNLIST=$(echo "$RUNLISTTMP" | grep -oP "^\d+$" ) if [ -z "$RUNLIST" ] ; then >&2 echo "Error, RUNLIST.whichRunsAreOnDisk.sh : input file/pipe $RUNLISTTMP contains no runs, exiting..." @@ -82,7 +82,7 @@ fi #echo "Files not on disk:" # find the veritas db url -MYSQLDB=`grep '^\*[ \t]*DBSERVER[ \t]*mysql://' $VERITAS_EVNDISP_AUX_DIR/ParameterFiles/EVNDISP.global.runparameter | egrep -o '[[:alpha:]]{1,20}\.[[:alpha:]]{1,20}\.[[:alpha:]]{1,20}'` +MYSQLDB=$(grep '^\*[ \t]*DBSERVER[ \t]*mysql://' "$VERITAS_EVNDISP_AUX_DIR"/ParameterFiles/EVNDISP.global.runparameter | grep -E -o '[[:alpha:]]{1,20}\.[[:alpha:]]{1,20}\.[[:alpha:]]{1,20}') if [ ! -n "$MYSQLDB" ] ; then echo "* DBSERVER param not found in \$VERITAS_EVNDISP_AUX_DIR/ParameterFiles/EVNDISP.global.runparameter!" exit @@ -96,7 +96,7 @@ MYSQL="mysql -u readonly -h $MYSQLDB -A" COUNT=0 SUB="" for ARUN in $RUNLIST ; do - if (( $ARUN > 0 )); then + if (( ARUN > 0 )); then if [[ "$COUNT" -eq 0 ]] ; then SUB="run_id = $ARUN" else @@ -122,7 +122,7 @@ while read -r RUNID RUNDATE ; do # test to see if the file exists #echo " Does file exist: $TARGFILE" - if [ -e $TARGFILE ] ; then # file exists + if [ -e "$TARGFILE" ] ; then # file exists if ! $NOTFLAG ; then # $NOTFLAG is false, and we should print the runnumber if $PRINTPATH ; then echo "$TARGFILE" diff --git a/scripts/RUNLIST.whichRunsAreSource.sh b/scripts/RUNLIST.whichRunsAreSource.sh index 007aac3..90da887 100755 --- a/scripts/RUNLIST.whichRunsAreSource.sh +++ b/scripts/RUNLIST.whichRunsAreSource.sh @@ -1,16 +1,11 @@ #!/bin/bash -# shellcheck disable=SC2034 # from a run list, prints the list of runs that target a specific source -# variables for coloring terminal output -CONORM="\e[0m" -CORED='\e[1;31m' - NOTFLAG=false # flag for if the -n flag was used HELPFLAG=false # if true, print help text and exit # check to see if input is from terminal, or from a pipe -ISPIPEFILE=`readlink /dev/fd/0` +ISPIPEFILE=$(readlink /dev/fd/0) if [[ "$ISPIPEFILE" =~ ^/dev/pts/[0-9]{1,2} ]] ; then # its a terminal (not a pipe) if [ "$#" -eq "1" ] ; then NOTFLAG=true @@ -25,7 +20,7 @@ if [[ "$ISPIPEFILE" =~ ^/dev/pts/[0-9]{1,2} ]] ; then # its a terminal (not a pi SOURCE="$2" RUNFILE="$3" else - echo " Error: `basename $0` doesn't understand flag '$1'. Only acceptable flag is -n" + echo " Error: $(basename "$0") doesn't understand flag '$1'. Only acceptable flag is -n" HELPFLAG=true fi else @@ -46,7 +41,7 @@ else # it is a pipe SOURCE=$2 RUNFILE=$3 else - echo " Error: `basename $0` doesn't understand flag '$1'. Only acceptable flag is -n" + echo " Error: $(basename "$0") doesn't understand flag '$1'. Only acceptable flag is -n" HELPFLAG=true fi else @@ -59,7 +54,7 @@ if $HELPFLAG ; then echo echo "Prints the source names for a list of run numbers," echo " OR, only print runs that do or do not target a particular source." ; echo - echo "$ `basename $0` [-n] [source name] " ; echo + echo "$ $(basename "$0") [-n] [source name] " ; echo echo "Required arguments:" echo " : The runlist file, containing the list of runs, 1 runnumber per line" echo " Can also take input from a piped runlist" ; echo @@ -69,45 +64,43 @@ if $HELPFLAG ; then echo " (only has effect if [source name] is specified)" ; echo echo "Examples:" ; echo echo " Print source names for each run:" - echo " $ `basename $0` myrunlist.dat" + echo " $ $(basename "$0") myrunlist.dat" echo " 43744 PSRJ2229+6114" echo " 43745 PSRJ2229+6114" echo " 47146 Tycho" echo " 47147 Tycho" echo " 47478 Tycho" ; echo echo " Only print the Tycho runs from a runlist:" - echo " $ `basename $0` \"Tycho\" myrunlist.dat" + echo " $ $(basename "$0") \"Tycho\" myrunlist.dat" echo " 47146" echo " 47147" echo " 47478" ; echo echo " Only print the PSRJ2229+6114 runs from a runlist:" - echo " $ `basename $0` \"PSRJ2229+6114\" myrunlist.dat" + echo " $ $(basename "$0") \"PSRJ2229+6114\" myrunlist.dat" echo " 43744" echo " 43745" ; echo echo " Print list of non-Tycho runs, along with their source name:" - echo " $ `basename $0` -n \"Tycho\" myrunlist.dat" + echo " $ $(basename "$0") -n \"Tycho\" myrunlist.dat" echo " 43744 PSRJ2229+6114" echo " 43745 PSRJ2229+6114" ; echo echo "Works with pipes : " - echo " $ cat myrunlist.dat | `basename $0` \"Tycho\"" + echo " $ cat myrunlist.dat | $(basename "$0") \"Tycho\"" echo " 47146" echo " 47147" echo " 47478" ; echo exit fi -function echoerr(){ echo "$@" 1>&2; } #for spitting out error text - # list of run_id's to read in -if [ ! -e $RUNFILE ] ; then +if [ ! -e "$RUNFILE" ] ; then echo "File '$RUNFILE' could not be found in $PWD , sorry." exit fi -RUNLIST=`cat $RUNFILE` +RUNLIST=$(cat "$RUNFILE") #echo "RUNLIST:$RUNLIST" # get database url from parameter file -MYSQLDB=`grep '^\*[ \t]*DBSERVER[ \t]*mysql://' "$VERITAS_EVNDISP_AUX_DIR/ParameterFiles/EVNDISP.global.runparameter" | egrep -o '[[:alpha:]]{1,20}\.[[:alpha:]]{1,20}\.[[:alpha:]]{1,20}'` +MYSQLDB=$(grep '^\*[ \t]*DBSERVER[ \t]*mysql://' "$VERITAS_EVNDISP_AUX_DIR/ParameterFiles/EVNDISP.global.runparameter" | grep -E -o '[[:alpha:]]{1,20}\.[[:alpha:]]{1,20}\.[[:alpha:]]{1,20}') if [ ! -n "$MYSQLDB" ] ; then echo "* DBSERVER param not found in \$VERITAS_EVNDISP_AUX_DIR/ParameterFiles/EVNDISP.global.runparameter!" @@ -123,7 +116,7 @@ MYSQL="mysql -u readonly -h $MYSQLDB -A" COUNT=0 SUB="" for ARUN in $RUNLIST ; do - if (( $ARUN > 0 )); then + if (( ARUN > 0 )); then if [[ "$COUNT" -eq 0 ]] ; then SUB="run_id = $ARUN" else diff --git a/scripts/RUNLIST.whichRunsAreWobble.sh b/scripts/RUNLIST.whichRunsAreWobble.sh index bfb0592..68d8c31 100755 --- a/scripts/RUNLIST.whichRunsAreWobble.sh +++ b/scripts/RUNLIST.whichRunsAreWobble.sh @@ -4,18 +4,18 @@ CONORM="\e[0m" CORED='\e[1;31m' -ISPIPEFILE=`readlink /dev/fd/0` # check to see if input is from terminal, or from a pipe +ISPIPEFILE=$(readlink /dev/fd/0) # check to see if input is from terminal, or from a pipe if [[ "$ISPIPEFILE" =~ ^/dev/pts/[0-9]{1,2} ]] ; then # its a terminal (not a pipe) if ! [ $# -eq 2 ] ; then # the human didn't add any arguments, and we must tell them so echo echo "From a runlist or pipe, prints the run numbers that are of a particular wobble or wobbles." - echo " $ `basename $0` [nsew] " ; echo + echo " $ $(basename "$0") [nsew] " ; echo echo "Print list of only north wobble runs:" - echo " $ `basename $0` n myrunlist.dat" ; echo + echo " $ $(basename "$0") n myrunlist.dat" ; echo echo "Print list of only south and east wobble runs:" - echo " $ `basename $0` se myrunlist.dat" ; echo + echo " $ $(basename "$0") se myrunlist.dat" ; echo echo "Works with pipes : " - echo " $ cat myrunlist.dat | `basename $0` w" ; echo + echo " $ cat myrunlist.dat | $(basename "$0") w" ; echo exit fi fi @@ -24,11 +24,11 @@ function echoerr(){ echo -e "${CORED}$*${CONORM}" 1>&2; } #for spitting out erro # list of run_id's to read in RUNFILE=$2 -if [ ! -e $RUNFILE ] ; then +if [ ! -e "$RUNFILE" ] ; then echoerr "File $RUNFILE could not be found in $PWD , sorry." exit 1 fi -RUNLIST=`cat $RUNFILE` +RUNLIST=$(cat "$RUNFILE") #echo "RUNLIST:$RUNLIST" NORTFLAG=false @@ -36,7 +36,7 @@ SOUTFLAG=false EASTFLAG=false WESTFLAG=false -LOWARG=`echo "$1" | tr '[A-Z]' '[a-z]'` # make all uppercase letters in arg 1 lowercase, for easier handling +LOWARG=$(echo "$1" | tr '[:upper:]' '[:lower:]') # make all uppercase letters in arg 1 lowercase, for easier handling #echo "\$LOWARG: '$LOWARG'" if [[ "$LOWARG" == *n* ]] ; then NORTFLAG=true ; fi if [[ "$LOWARG" == *s* ]] ; then SOUTFLAG=true ; fi @@ -44,7 +44,7 @@ if [[ "$LOWARG" == *e* ]] ; then EASTFLAG=true ; fi if [[ "$LOWARG" == *w* ]] ; then WESTFLAG=true ; fi # get database url from parameter file -MYSQLDB=`grep '^\*[ \t]*DBSERVER[ \t]*mysql://' "$VERITAS_EVNDISP_AUX_DIR/ParameterFiles/EVNDISP.global.runparameter" | egrep -o '[[:alpha:]]{1,20}\.[[:alpha:]]{1,20}\.[[:alpha:]]{1,20}'` +MYSQLDB=$(grep '^\*[ \t]*DBSERVER[ \t]*mysql://' "$VERITAS_EVNDISP_AUX_DIR/ParameterFiles/EVNDISP.global.runparameter" | grep -E -o '[[:alpha:]]{1,20}\.[[:alpha:]]{1,20}\.[[:alpha:]]{1,20}') if [ ! -n "$MYSQLDB" ] ; then echo "* DBSERVER param not found in \$VERITAS_EVNDISP_AUX_DIR/ParameterFiles/EVNDISP.global.runparameter!" @@ -60,7 +60,7 @@ MYSQL="mysql -u readonly -h $MYSQLDB -A" COUNT=0 SUB="" for ARUN in $RUNLIST ; do - if (( $ARUN > 0 )); then + if (( ARUN > 0 )); then if [[ "$COUNT" -eq 0 ]] ; then SUB="run_id = $ARUN" else diff --git a/scripts/SPANALYSIS.evndisp_laser_run.sh b/scripts/SPANALYSIS.evndisp_laser_run.sh index 0597ad8..becbc68 100755 --- a/scripts/SPANALYSIS.evndisp_laser_run.sh +++ b/scripts/SPANALYSIS.evndisp_laser_run.sh @@ -31,8 +31,7 @@ exit fi # Run init script -bash "$(dirname "$0")/helper_scripts/UTILITY.script_init.sh" -[[ $? != "0" ]] && exit 1 +bash "$(dirname "$0")/helper_scripts/UTILITY.script_init.sh" || exit 1 # Parse command line arguments RUNNUM=$1 @@ -50,26 +49,38 @@ fi CALIBDIR="$VERITAS_USER_DATA_DIR/" # Check if source vbf file exists -SF=`find -L $VERITAS_DATA_DIR/data -name "$RUNNUM.cvbf"` +SF=$(find -L "$VERITAS_DATA_DIR"/data -name "$RUNNUM.cvbf") if [ ${#SF} = 0 ]; then echo "ERROR: VERITAS source (VBF laser/flasher) file $RUNNUM.cvbf not found in $VERITAS_DATA_DIR/data/" exit 1 fi # Run options -OPT="-runmode=$RUNMODE -runnumber=$RUNNUM -lasermin=$LASERMIN -calibrationsumwindow=18 -calibrationsumfirst=2 -reconstructionparameter EVNDISP.reconstruction.SW18_noDoublePass.runparameter -calibrationdirectory $CALIBDIR -writeextracalibtree -printdeadpixelinfo" +OPT=( + "-runmode=$RUNMODE" + "-runnumber=$RUNNUM" + "-lasermin=$LASERMIN" + -calibrationsumwindow=18 + -calibrationsumfirst=2 + -reconstructionparameter + EVNDISP.reconstruction.SW18_noDoublePass.runparameter + -calibrationdirectory + "$CALIBDIR" + -writeextracalibtree + -printdeadpixelinfo +) # calculate pedestals (for high gain only) if [[ $RUNMODE == 2 ]]; then echo "Calculating pedestals for run $RUNNUM" - "$(dirname "$0")/SPANALYSIS.evndisp_pedestal_events.sh" $RUNNUM + "$(dirname "$0")/SPANALYSIS.evndisp_pedestal_events.sh" "$RUNNUM" fi # calculate gains, looping over all telescopes -TELTOANA=`echo $TELTOANA | fold -w1` +TELTOANA=$(echo "$TELTOANA" | fold -w1) for i in $TELTOANA; do echo "Calculating gains for run $RUNNUM, telescope $i" - $EVNDISPSYS/bin/evndisp -teltoana=$i $OPT + "$EVNDISPSYS"/bin/evndisp -teltoana="$i" "${OPT[@]}" done exit diff --git a/scripts/SPANALYSIS.evndisp_laser_runs_from_calibfile.sh b/scripts/SPANALYSIS.evndisp_laser_runs_from_calibfile.sh index 9f362ba..d39f1c0 100755 --- a/scripts/SPANALYSIS.evndisp_laser_runs_from_calibfile.sh +++ b/scripts/SPANALYSIS.evndisp_laser_runs_from_calibfile.sh @@ -19,8 +19,7 @@ exit fi # Run init script -bash "$(dirname "$0")/helper_scripts/UTILITY.script_init.sh" -[[ $? != "0" ]] && exit 1 +bash "$(dirname "$0")/helper_scripts/UTILITY.script_init.sh" || exit 1 # Parse command line arguments CALIBFILE=$1 @@ -28,17 +27,17 @@ CALIBFILE=$1 # locations of vbf files DDIR="$VERITAS_DATA_DIR/data/" -FILES=`grep LASER $CALIBFILE | awk '{print $2"_"$3}'` +FILES=$(grep LASER "$CALIBFILE" | awk '{print $2"_"$3}') for AFILE in $FILES do RUN=${AFILE:0:5} DTEL=${AFILE:6} - echo $AFILE $RUN $DTEL - DFILE=`find -L $DDIR -name "$RUN.cvbf"` + echo "$AFILE" "$RUN" "$DTEL" + DFILE=$(find -L "$DDIR" -name "$RUN.cvbf") if [[ -f $DFILE ]]; then - "$(dirname "$0")/SPANALYSIS.evndisp_laser_run.sh" $DTEL $DFILE + "$(dirname "$0")/SPANALYSIS.evndisp_laser_run.sh" "$DTEL" "$DFILE" else echo "Missing laser/flasher file $DFILE, please download it" fi diff --git a/scripts/SPANALYSIS.evndisp_laser_runs_from_runlist.sh b/scripts/SPANALYSIS.evndisp_laser_runs_from_runlist.sh index d263325..825ec24 100755 --- a/scripts/SPANALYSIS.evndisp_laser_runs_from_runlist.sh +++ b/scripts/SPANALYSIS.evndisp_laser_runs_from_runlist.sh @@ -26,13 +26,12 @@ exit fi # Run init script -bash "$(dirname "$0")/helper_scripts/UTILITY.script_init.sh" -[[ $? != "0" ]] && exit 1 +bash "$(dirname "$0")/helper_scripts/UTILITY.script_init.sh" || exit 1 # Parse command line arguments RLIST=$1 [[ "$2" ]] && TELTOANA=$2 || TELTOANA="1234" -TELTOANA=`echo $TELTOANA | fold -w1` +TELTOANA=$(echo "$TELTOANA" | fold -w1) # locations of vbf files and laser/flasher calibration files DDIR="$VERITAS_DATA_DIR/data/" @@ -43,19 +42,19 @@ if [[ ! -f "$RLIST" ]]; then echo "Error, runlist $RLIST not found, exiting..." exit 1 fi -RUNNUMS=`cat $RLIST` +RUNNUMS=$(cat "$RLIST") for RUN in $RUNNUMS; do for i in $TELTOANA; do - RUN=`$EVNDISPSYS/bin/VTS.getLaserRunFromDB $i $RUN` + RUN=$("$EVNDISPSYS"/bin/VTS.getLaserRunFromDB "$i" "$RUN") echo "Checking telescope $i, laser run $RUN, data run $RUN:" echo "$CALIBDIR/Tel_$i/$RUN.gain.root" if [[ ! -f "$CALIBDIR/Tel_$i/$RUN.gain.root" ]]; then echo "Processing gains from laser/flash run $RUN, telescope $i" - RUNFILE=`find -L $DDIR -name "$RUN.cvbf"` + RUNFILE=$(find -L "$DDIR" -name "$RUN.cvbf") if [[ -f $RUNFILE ]]; then - $EVNDISPSYS/scripts/VTS/SPANALYSIS.evndisp_laser_run.sh $i $RUNFILE + "$EVNDISPSYS"/scripts/VTS/SPANALYSIS.evndisp_laser_run.sh "$i" "$RUNFILE" else echo "Missing laser/flasher file $RUNFILE, please download it" fi diff --git a/scripts/SPANALYSIS.evndisp_pedestal_events.sh b/scripts/SPANALYSIS.evndisp_pedestal_events.sh index 9e76be3..db3031c 100755 --- a/scripts/SPANALYSIS.evndisp_pedestal_events.sh +++ b/scripts/SPANALYSIS.evndisp_pedestal_events.sh @@ -26,38 +26,48 @@ exit fi # Run init script -bash "$(dirname "$0")/helper_scripts/UTILITY.script_init.sh" -[[ $? != "0" ]] && exit 1 +bash "$(dirname "$0")/helper_scripts/UTILITY.script_init.sh" || exit 1 # Parse command line arguments RUNNUM=$1 [[ "$2" ]] && SAMPLES=$2 || SAMPLES="0" [[ "$3" ]] && CALIBDIR=$3 || CALIBDIR="$VERITAS_USER_DATA_DIR/" -OPT=" -calibrationsumwindow=20 -calibrationdirectory $CALIBDIR " +OPT=( + -calibrationsumwindow=20 + -calibrationdirectory + "$CALIBDIR" +) #high gain mode if [[ $SAMPLES == "0" ]]; then - OPT="$OPT -runmode=1 -calibrationsumfirst=0 " + OPT+=( + -runmode=1 + -calibrationsumfirst=0 + ) #low gain mode else - OPT="$OPT -runmode=6 -reconstructionparameter EVNDISP.reconstruction.LGCalibration.runparameter " - - if [[ $SAMPLES == "64" ]]; then - OPT="$OPT -calibrationsumfirst=40 " - elif [[ $SAMPLES == "128" ]]; then - OPT="$OPT -calibrationsumfirst=100 " - elif [[ $SAMPLES == "100" ]]; then - OPT="$OPT -calibrationsumfirst=75 " - else - echo "Invalid number of samples given, please fix the script." - exit 1 - fi + OPT+=( + -runmode=6 + -reconstructionparameter + EVNDISP.reconstruction.LGCalibration.runparameter + ) + + if [[ $SAMPLES == "64" ]]; then + OPT+=("-calibrationsumfirst=40") + elif [[ $SAMPLES == "128" ]]; then + OPT+=("-calibrationsumfirst=100") + elif [[ $SAMPLES == "100" ]]; then + OPT+=("-calibrationsumfirst=75") + else + echo "Invalid number of samples given, please fix the script." + exit 1 + fi fi # Run evndisp -echo "$EVNDISPSYS/bin/evndisp -runnumber=$RUNNUM $OPT " -$EVNDISPSYS/bin/evndisp -runnumber=$RUNNUM $OPT +echo "$EVNDISPSYS/bin/evndisp -runnumber=$RUNNUM ${OPT[*]}" +"$EVNDISPSYS"/bin/evndisp -runnumber="$RUNNUM" "${OPT[@]}" exit diff --git a/scripts/SPANALYSIS.evndisp_tzeros.sh b/scripts/SPANALYSIS.evndisp_tzeros.sh index e87ad31..cb97111 100755 --- a/scripts/SPANALYSIS.evndisp_tzeros.sh +++ b/scripts/SPANALYSIS.evndisp_tzeros.sh @@ -28,8 +28,7 @@ exit fi # Run init script -bash "$(dirname "$0")/helper_scripts/UTILITY.script_init.sh" -[[ $? != "0" ]] && exit 1 +bash "$(dirname "$0")/helper_scripts/UTILITY.script_init.sh" || exit 1 # Parse command line arguments RUNNUM=$1 @@ -40,24 +39,24 @@ fi [[ "$3" ]] && CALDB=$3 || CALDB="1" # Check if source vbf file exists -SF=`find -L $VERITAS_DATA_DIR/data -name "$RUNNUM.cvbf"` +SF=$(find -L "$VERITAS_DATA_DIR"/data -name "$RUNNUM.cvbf") if [[ ${#SF} = 0 ]]; then echo "ERROR: VERITAS source file $RUNNUM.cvbf not found in $VERITAS_DATA_DIR/data/" exit 1 fi if [[ $CALDB == "1" ]]; then - OPT="$OPT -readCalibDB" + OPT=(-readCalibDB) else - OPT="$OPT -nocalibnoproblem" + OPT=(-nocalibnoproblem) fi -echo $OPT +echo "${OPT[*]}" # run options -OPT="-runmode=7 -runnumber=$RUNNUM -teltoana=$TELTOANA $OPT" +OPT=("-runmode=7" "-runnumber=$RUNNUM" "-teltoana=$TELTOANA" "${OPT[@]}") # Run evndisp -echo "$EVNDISPSYS/bin/evndisp $OPT" -$EVNDISPSYS/bin/evndisp $OPT +echo "$EVNDISPSYS/bin/evndisp ${OPT[*]}" +"$EVNDISPSYS"/bin/evndisp "${OPT[@]}" exit diff --git a/scripts/SPANALYSIS.lowgainped.sh b/scripts/SPANALYSIS.lowgainped.sh index 979d993..187d76c 100755 --- a/scripts/SPANALYSIS.lowgainped.sh +++ b/scripts/SPANALYSIS.lowgainped.sh @@ -2,7 +2,7 @@ # script to run eventdisplay analysis for VTS data # qsub parameters -# shellcheck disable=SC2034 +# shellcheck disable=SC2034 # SGE resource directives, read by job scheduler h_cpu=11:59:00; h_vmem=2000M; tmpdir_size=25G if [ ! -n "$1" ] || [ ! -n "$2" ] || [ "$1" = "-h" ]; then @@ -37,11 +37,7 @@ exit fi # Run init script -bash "$( cd "$( dirname "$0" )" && pwd )/helper_scripts/UTILITY.script_init.sh" -[[ $? != "0" ]] && exit 1 - -# EventDisplay version -EDVERSION=`$EVNDISPSYS/bin/evndisp --version | tr -d .` +bash "$( cd "$( dirname "$0" )" && pwd )/helper_scripts/UTILITY.script_init.sh" || exit 1 # create extra stdout for duplication of command output # look for ">&5" below @@ -51,8 +47,8 @@ exec 5>&1 RLIST=$1 SUMSTART=$2 [[ "$3" ]] && ODIR=$3 || ODIR="$VERITAS_EVNDISP_AUX_DIR" -mkdir -p $ODIR -[[ "$4" ]] && SUMWINDOW=$4 || SUMWINNDOW=20 +mkdir -p "$ODIR" +[[ "$4" ]] && SUMWINDOW=$4 || SUMWINDOW=20 [[ "$5" ]] && TELTOANA=$5 || TELTOANA=1234 [[ "$6" ]] && NEVENTS=$6 || NEVENTS=-1 @@ -61,18 +57,18 @@ if [ ! -f "$RLIST" ] ; then echo "Error, runlist $RLIST not found, exiting..." exit 1 fi -FILES=`cat $RLIST` +FILES=$(cat "$RLIST") # Output directory for error/output -DATE=`date +"%y%m%d"` +DATE=$(date +"%y%m%d") LOGDIR="$VERITAS_USER_LOG_DIR/$DATE/EVNDISP.LGAINPED" -mkdir -p $LOGDIR +mkdir -p "$LOGDIR" # Job submission script SUBSCRIPT="$(dirname "$0")/helper_scripts/SPANALYSIS.lowgainped_sub" -NRUNS=`cat $RLIST | wc -l ` +NRUNS=$(cat "$RLIST" | wc -l ) echo "total number of runs to analyze: $NRUNS" echo @@ -89,10 +85,10 @@ do -e "s|NNNN|$NEVENTS|" \ -e "s|CALIBFIRST|$SUMSTART|" \ -e "s|CALIBSUMWINDOW|$SUMWINDOW|" \ - $SUBSCRIPT.sh > $FSCRIPT.sh + "$SUBSCRIPT".sh > "$FSCRIPT".sh - chmod u+x $FSCRIPT.sh - echo $FSCRIPT.sh + chmod u+x "$FSCRIPT".sh + echo "$FSCRIPT".sh # output selected input during submission: echo "calibrationsumwindow $SUMWINDOW, start at $SUMSTART, $NEVENTS events " echo "Output: $ODIR" @@ -105,14 +101,15 @@ do # run locally or on cluster SUBC=$("$(dirname "$0")/helper_scripts/UTILITY.readSubmissionCommand.sh") - SUBC=`eval "echo \"$SUBC\""` + SUBC=$(eval "echo \"$SUBC\"") if [[ $SUBC == *"ERROR"* ]]; then - echo $SUBC + echo "$SUBC" exit fi - echo $SUBC + echo "$SUBC" if [[ $SUBC == *qsub* ]]; then - JOBID=`$SUBC $FSCRIPT.sh` + # shellcheck disable=SC2086 + JOBID=$($SUBC "$FSCRIPT".sh) # account for -terse changing the job number format if [[ $SUBC != *-terse* ]] ; then echo "without -terse!" # need to match VVVVVVVV 8539483 and 3843483.1-4:2 @@ -127,18 +124,20 @@ do fi elif [[ $SUBC == *condor* ]]; then "$(dirname "$0")/helper_scripts/UTILITY.condorSubmission.sh" "$FSCRIPT.sh" "$h_vmem" "$tmpdir_size" - condor_submit $FSCRIPT.sh.condor + condor_submit "$FSCRIPT".sh.condor elif [[ $SUBC == *sbatch* ]]; then - $SUBC $FSCRIPT.sh + # shellcheck disable=SC2086 + $SUBC "$FSCRIPT".sh elif [[ $SUBC == *parallel* ]]; then - echo "$FSCRIPT.sh &> $FSCRIPT.log" >> $LOGDIR/runscripts.dat + echo "$FSCRIPT.sh &> $FSCRIPT.log" >> "$LOGDIR"/runscripts.dat echo "RUN $AFILE OLOG $FSCRIPT.log" fi done # Execute all FSCRIPTs locally in parallel if [[ $SUBC == *parallel* ]]; then - cat $LOGDIR/runscripts.dat | $SUBC + # shellcheck disable=SC2086 + cat "$LOGDIR"/runscripts.dat | $SUBC fi exit diff --git a/scripts/SPANALYSIS.make_DST.sh b/scripts/SPANALYSIS.make_DST.sh index cefc39a..40655c5 100755 --- a/scripts/SPANALYSIS.make_DST.sh +++ b/scripts/SPANALYSIS.make_DST.sh @@ -2,7 +2,7 @@ # script to make DST files from a raw data file # qsub parameters -# shellcheck disable=SC2034 +# shellcheck disable=SC2034 # SGE resource directives, read by job scheduler h_cpu=11:29:00; h_vmem=4000M; tmpdir_size=40G if [[ $# -lt 2 ]]; then @@ -40,8 +40,7 @@ exit fi # Run init script -bash "$(dirname "$0")/helper_scripts/UTILITY.script_init.sh" -[[ $? != "0" ]] && exit 1 +bash "$(dirname "$0")/helper_scripts/UTILITY.script_init.sh" || exit 1 # Parse command line arguments RLIST=$1 @@ -56,13 +55,13 @@ if [[ ! -f "$RLIST" ]]; then echo "Error, runlist $RLIST not found, exiting..." exit 1 fi -RUNNUMS=`cat $RLIST` +RUNNUMS=$(cat "$RLIST") # run scripts are written into this directory -DATE=`date +"%y%m%d"` +DATE=$(date +"%y%m%d") LOGDIR="$VERITAS_USER_LOG_DIR/$DATE/EVNDISP.ANADATA" echo -e "Log files will be written to:\n $LOGDIR" -mkdir -p $LOGDIR +mkdir -p "$LOGDIR" # check for the existence of a run parameter file corresponding @@ -75,7 +74,7 @@ if [[ -z $RUNPFILE ]]; then RUNPFILE="EVNDISP.reconstruction.LMULT.SW$SUMW.runparameter" if [ ! -e "$RUNPDIR/$RUNPFILE" ]; then - sed -e "s|XX|$SUMW|g" $RUNPDIR/EVNDISP.reconstruction.LMULT.SWXX.runparameter > $RUNPDIR/$RUNPFILE + sed -e "s|XX|$SUMW|g" "$RUNPDIR"/EVNDISP.reconstruction.LMULT.SWXX.runparameter > "$RUNPDIR"/"$RUNPFILE" fi fi @@ -94,32 +93,35 @@ for RUN in $RUNNUMS; do -e "s|LLLOWGAIN|$LMULT|" \ -e "s|OUTPUTDIR|$ODIR|" \ -e "s|RRRRPFILE|$RUNPFILE|" \ - -e "s|SUMWINDOW|$SUMW|" $SUBSCRIPT.sh > $FSCRIPT.sh + -e "s|SUMWINDOW|$SUMW|" "$SUBSCRIPT".sh > "$FSCRIPT".sh - chmod u+x $FSCRIPT.sh - echo $FSCRIPT.sh + chmod u+x "$FSCRIPT".sh + echo "$FSCRIPT".sh # run locally or on cluster SUBC=$("$(dirname "$0")/helper_scripts/UTILITY.readSubmissionCommand.sh") - SUBC=`eval "echo \"$SUBC\""` + SUBC=$(eval "echo \"$SUBC\"") if [[ $SUBC == *qsub* ]]; then - JOBID=`$SUBC $FSCRIPT.sh` + # shellcheck disable=SC2086 + JOBID=$($SUBC "$FSCRIPT".sh) echo "RUN $RUN: JOBID $JOBID" elif [[ $SUBC == *condor* ]]; then "$(dirname "$0")/helper_scripts/UTILITY.condorSubmission.sh" "$FSCRIPT.sh" "$h_vmem" "$tmpdir_size" - condor_submit $FSCRIPT.sh.condor + condor_submit "$FSCRIPT".sh.condor elif [[ $SUBC == *sbatch* ]]; then - $SUBC $FSCRIPT.sh + # shellcheck disable=SC2086 + $SUBC "$FSCRIPT".sh elif [[ $SUBC == *parallel* ]]; then - echo "$FSCRIPT.sh &> $FSCRIPT.log" >> $LOGDIR/runscripts.dat + echo "$FSCRIPT.sh &> $FSCRIPT.log" >> "$LOGDIR"/runscripts.dat elif [[ $SUBC == *simple* ]]; then - $FSCRIPT.sh |& tee $FSCRIPT.log + "$FSCRIPT".sh |& tee "$FSCRIPT".log fi done # Execute all FSCRIPTs locally in parallel if [[ $SUBC == *parallel* ]]; then - cat $LOGDIR/runscripts.dat | $SUBC + # shellcheck disable=SC2086 + cat "$LOGDIR"/runscripts.dat | $SUBC fi exit diff --git a/scripts/UTILITY.downloadSoundingDatafromUWYO.sh b/scripts/UTILITY.downloadSoundingDatafromUWYO.sh index b727f91..899305d 100755 --- a/scripts/UTILITY.downloadSoundingDatafromUWYO.sh +++ b/scripts/UTILITY.downloadSoundingDatafromUWYO.sh @@ -26,21 +26,21 @@ MONTH=( 01 02 03 04 05 06 07 08 09 10 11 12 ) DAY=( 31 28 31 30 31 30 31 31 30 31 30 30 ) NMONTH=${#MONTH[@]} -for (( y = $YEAR1; y <= $YEAR2; y++ )) +for (( y = YEAR1; y <= YEAR2; y++ )) do echo "Fetching $y" - for (( i = 0 ; i < $NMONTH; i++ )) + for (( i = 0 ; i < NMONTH; i++ )) do M=${MONTH[$i]} D=${DAY[$i]} ONAME="sounding_${y}${M}" - echo $M $D $ONAME + echo "$M" "$D" "$ONAME" - wget --output-document=$ONAME.dat2 "http://weather.uwyo.edu/cgi-bin/sounding?region=naconf&TYPE=TEXT%3ALIST&YEAR=${y}&MONTH=${M}&FROM=0100&TO=${D}12&STNM=${USM}&REPLOT=1" + wget --output-document="$ONAME".dat2 "http://weather.uwyo.edu/cgi-bin/sounding?region=naconf&TYPE=TEXT%3ALIST&YEAR=${y}&MONTH=${M}&FROM=0100&TO=${D}12&STNM=${USM}&REPLOT=1" - sed -e :a -e 's/<[^>]*>//g;/ $ONAME.dat - rm -f $ONAME.dat2 + sed -e :a -e 's/<[^>]*>//g;/ "$ONAME".dat + rm -f "$ONAME".dat2 done done diff --git a/scripts/UTILITY.sortRunsInSubDirectories.sh b/scripts/UTILITY.sortRunsInSubDirectories.sh index ba39f60..a680bbf 100755 --- a/scripts/UTILITY.sortRunsInSubDirectories.sh +++ b/scripts/UTILITY.sortRunsInSubDirectories.sh @@ -30,16 +30,16 @@ getNumberedDirectory() else ODIR="${TDIR}/${TRUN:0:2}/" fi - mkdir -p ${ODIR} - echo ${ODIR} + mkdir -p "${ODIR}" + echo "${ODIR}" } FLIST=$(find "${DDIR}" -name "[0-9]*.*${SUFF}") for F in ${FLIST} do - RUNN=$(basename ${F}) + RUNN=$(basename "${F}") RUNN="${RUNN%%.*}" - ODIR=$(getNumberedDirectory $RUNN) - mv -f -v ${F} ${ODIR} + ODIR=$(getNumberedDirectory "$RUNN") + mv -f -v "${F}" "${ODIR}" done diff --git a/scripts/db_scripts/db_FADCsettings.sh b/scripts/db_scripts/db_FADCsettings.sh index 10061a5..d4d5ce7 100755 --- a/scripts/db_scripts/db_FADCsettings.sh +++ b/scripts/db_scripts/db_FADCsettings.sh @@ -18,4 +18,4 @@ TELID="$3" QUERY="select c.pixel_id , s.fadc_id, c.fadc_channel from tblFADC_Slot_Relation as s, tblFADC_Channel_Relation as c where s.db_start_time < \"${STARTDATE}\" and c.db_start_time < \"${STARTDATE}\" and ( s.db_end_time IS NULL or s.db_end_time > \"${ENDDATE}\" ) and ( c.db_end_time IS NULL or c.db_end_time > \"${ENDDATE}\" ) and s.fadc_crate=c.fadc_crate and s.fadc_slot=c.fadc_slot and s.telescope_id=c.telescope_id and c.pixel_id IS NOT NULL and s.telescope_id=${TELID} order by c.pixel_id ;" -$($EVNDISPSCRIPTS/db_scripts/db_mysqldb.sh) -e "USE VERITAS; ${QUERY}" | sed 's/\t/|/g' +$("$EVNDISPSCRIPTS"/db_scripts/db_mysqldb.sh) -e "USE VERITAS; ${QUERY}" | sed 's/\t/|/g' diff --git a/scripts/db_scripts/db_HVsettings.sh b/scripts/db_scripts/db_HVsettings.sh index 51e47eb..fb33c76 100755 --- a/scripts/db_scripts/db_HVsettings.sh +++ b/scripts/db_scripts/db_HVsettings.sh @@ -18,4 +18,4 @@ TELID="$3" QUERY="select * FROM tblHV_Telescope${TELID}_Status WHERE channel > 0 AND (db_start_time >=\"${STARTDATE}\" - INTERVAL 1 MINUTE) AND (db_start_time <= \"${ENDDATE}\" );" -$($EVNDISPSCRIPTS/db_scripts/db_mysqldb.sh) -e "USE VERITAS; ${QUERY}" | sed 's/\t/|/g' +$("$EVNDISPSCRIPTS"/db_scripts/db_mysqldb.sh) -e "USE VERITAS; ${QUERY}" | sed 's/\t/|/g' diff --git a/scripts/db_scripts/db_L1_TriggerInfo.sh b/scripts/db_scripts/db_L1_TriggerInfo.sh index 82c74b9..5492e07 100755 --- a/scripts/db_scripts/db_L1_TriggerInfo.sh +++ b/scripts/db_scripts/db_L1_TriggerInfo.sh @@ -17,4 +17,4 @@ fi RUN=$1 QUERY="select timestamp, telescope_id, pixel_id, rate from tblL1_TriggerInfo, tblRun_Info where timestamp >= tblRun_Info.data_start_time - INTERVAL 1 MINUTE AND timestamp <= tblRun_Info.data_end_time + INTERVAL 1 MINUTE AND tblRun_Info.run_id=${RUN};" -$($EVNDISPSCRIPTS/db_scripts/db_mysqldb.sh) -e "USE VERITAS; ${QUERY}" | sed 's/\t/|/g' +$("$EVNDISPSCRIPTS"/db_scripts/db_mysqldb.sh) -e "USE VERITAS; ${QUERY}" | sed 's/\t/|/g' diff --git a/scripts/db_scripts/db_L3.sh b/scripts/db_scripts/db_L3.sh index a30cf25..dc95145 100755 --- a/scripts/db_scripts/db_L3.sh +++ b/scripts/db_scripts/db_L3.sh @@ -27,5 +27,5 @@ if [[ "${STARTDATE}" == *NULL* ]] || [[ "${ENDDATE}" == *NULL* ]]; then echo "" else QUERY="SELECT timestamp, run_id, L3, L3orVDAQBusy, VDAQBusy, SpareBusy, PED, OC, VDAQBusyScaler, L3orVDAQBusyScaler, TenMHzScaler FROM tblL3_Array_TriggerInfo WHERE timestamp >= ${TIMESTART} AND timestamp <= ${TIMEEND};" - $($EVNDISPSCRIPTS/db_scripts/db_mysqldb.sh) -e "USE VERITAS; ${QUERY}" | sed 's/\t/|/g' + $("$EVNDISPSCRIPTS"/db_scripts/db_mysqldb.sh) -e "USE VERITAS; ${QUERY}" | sed 's/\t/|/g' fi diff --git a/scripts/db_scripts/db_VPM.sh b/scripts/db_scripts/db_VPM.sh index e645532..3288d13 100755 --- a/scripts/db_scripts/db_VPM.sh +++ b/scripts/db_scripts/db_VPM.sh @@ -15,12 +15,12 @@ STARTDATE="$1" ENDDATE="$2" TELID="$3" -STARTMJD=$($EVNDISPSYS/bin/printMJD "${STARTDATE}") -ENDMJD=$($EVNDISPSYS/bin/printMJD "${ENDDATE}") +STARTMJD=$("$EVNDISPSYS"/bin/printMJD "${STARTDATE}") +ENDMJD=$("$EVNDISPSYS"/bin/printMJD "${ENDDATE}") if [[ "${STARTDATE}" == *NULL* ]] || [[ "${ENDDATE}" == *NULL* ]]; then echo "" else QUERY="SELECT mjd,ra,decl FROM tblPointing_Monitor_Telescope${TELID}_Calibrated_Pointing WHERE mjd<=${ENDMJD} AND mjd>=${STARTMJD}" - $($EVNDISPSCRIPTS/db_scripts/db_mysqldb.sh) -e "USE VOFFLINE; ${QUERY}" | sed 's/\t/|/g' + $("$EVNDISPSCRIPTS"/db_scripts/db_mysqldb.sh) -e "USE VOFFLINE; ${QUERY}" | sed 's/\t/|/g' fi diff --git a/scripts/db_scripts/db_camerarotation.sh b/scripts/db_scripts/db_camerarotation.sh index e0fc04c..273b10a 100755 --- a/scripts/db_scripts/db_camerarotation.sh +++ b/scripts/db_scripts/db_camerarotation.sh @@ -17,4 +17,4 @@ fi STARTDATE="$1" ENDDATE="$2" QUERY="select telescope_id, version, pmt_rotation from tblPointing_Monitor_Camera_Parameters where start_date <=\"${STARTDATE}\" and end_date >\"${ENDDATE}\" ORDER BY version DESC" -$($EVNDISPSCRIPTS/db_scripts/db_mysqldb.sh) -e "USE VOFFLINE; ${QUERY}" | sed 's/\t/|/g' +$("$EVNDISPSCRIPTS"/db_scripts/db_mysqldb.sh) -e "USE VOFFLINE; ${QUERY}" | sed 's/\t/|/g' diff --git a/scripts/db_scripts/db_copy_old_laser_calibration.sh b/scripts/db_scripts/db_copy_old_laser_calibration.sh index ea4f83d..ef98a5a 100755 --- a/scripts/db_scripts/db_copy_old_laser_calibration.sh +++ b/scripts/db_scripts/db_copy_old_laser_calibration.sh @@ -34,31 +34,31 @@ fill_gain_or_toff() { LRUN=${1} if [[ -e ${CALIBDIR}/Tel_${2}/${LRUN}.${3/set/} ]]; then - cp -v ${CALIBDIR}/Tel_${2}/${LRUN}.${3/set/} ${LRUN}/${LRUN}.${3}_TEL${2} - sed -i "1s/^/channel_id|${3}_mean|${3}_var\n/" ${LRUN}/${LRUN}.${3}_TEL${2} - sed -i "s/ /|/g" ${LRUN}/${LRUN}.${3}_TEL${2} + cp -v "${CALIBDIR}"/Tel_"${2}"/"${LRUN}"."${3/set/}" "${LRUN}"/"${LRUN}"."${3}"_TEL"${2}" + sed -i "1s/^/channel_id|${3}_mean|${3}_var\n/" "${LRUN}"/"${LRUN}"."${3}"_TEL"${2}" + sed -i "s/ /|/g" "${LRUN}"/"${LRUN}"."${3}"_TEL"${2}" else echo "No calibration found for ${LRUN} ${2}" echo "${CALIBDIR}/Tel_${2}/${LRUN}.${3}" fi } -DBTEXTFILE=$(get_db_text_tar_file ${1}) +DBTEXTFILE=$(get_db_text_tar_file "${1}") if [[ ! -e ${DBTEXTFILE} ]]; then echo "Error: db tar file not found: ${DBTEXTFILE}" exit fi mkdir -p tmp_update_laser_run cd tmp_update_laser_run || exit -cp -v ${DBTEXTFILE} . -tar -xzf ${DBTEXTFILE} +cp -v "${DBTEXTFILE}" . +tar -xzf "${DBTEXTFILE}" for T in 1 2 3 4 do for C in gain toffset do # if [[ ! -e ${LRUN}/${LASERRUN}.${C}_TEL${T} ]]; then - fill_gain_or_toff $LASERRUN ${T} $C + fill_gain_or_toff "$LASERRUN" ${T} $C # else # echo "Calibration files $C exists for run $LASERRUN" # fi diff --git a/scripts/db_scripts/db_fir.sh b/scripts/db_scripts/db_fir.sh index 9ea3cf0..93fd8dc 100755 --- a/scripts/db_scripts/db_fir.sh +++ b/scripts/db_scripts/db_fir.sh @@ -15,4 +15,4 @@ STARTDATE="$1" ENDDATE="$2" QUERY="SELECT timestamp, telescope_id, ambient_temp, radiant_sky_temp FROM tblFIR_Pyrometer_Info WHERE timestamp >= \"${STARTDATE}\" AND timestamp < \"${ENDDATE}\"" -$($EVNDISPSCRIPTS/db_scripts/db_mysqldb.sh) -e "USE VERITAS; ${QUERY}" | sed 's/\t/|/g' +$("$EVNDISPSCRIPTS"/db_scripts/db_mysqldb.sh) -e "USE VERITAS; ${QUERY}" | sed 's/\t/|/g' diff --git a/scripts/db_scripts/db_gain.sh b/scripts/db_scripts/db_gain.sh index a00128a..8d23a20 100755 --- a/scripts/db_scripts/db_gain.sh +++ b/scripts/db_scripts/db_gain.sh @@ -18,4 +18,4 @@ LOWGAIN="0" QUERY="SELECT * FROM(SELECT tbl.channel_id, tbl.gain_mean, tbl.gain_var FROM tblEventDisplay_Analysis_Calibration_Flasher AS tbl WHERE tbl.telescope = ${TELID} AND tbl.run_id = ${RUN} AND tbl.high_low_gain_flag = $LOWGAIN ORDER BY tbl.update_time DESC ) AS BIG_table GROUP BY channel_id;" -$($EVNDISPSCRIPTS/db_scripts/db_mysqldb.sh) -e "USE VOFFLINE; ${QUERY}" | sed 's/\t/|/g' +$("$EVNDISPSCRIPTS"/db_scripts/db_mysqldb.sh) -e "USE VOFFLINE; ${QUERY}" | sed 's/\t/|/g' diff --git a/scripts/db_scripts/db_laserrun.sh b/scripts/db_scripts/db_laserrun.sh index e4a2789..6d3418d 100755 --- a/scripts/db_scripts/db_laserrun.sh +++ b/scripts/db_scripts/db_laserrun.sh @@ -1,5 +1,4 @@ #!/bin/bash -# shellcheck disable=SC2034 # if [ ! -n "$1" ] || [ "$1" = "-h" ]; then @@ -16,6 +15,6 @@ exit fi RUN=$1 -QUERY="SELECT info.run_id, grp_cmt.excluded_telescopes, info.config_mask FROM tblRun_Info AS info, tblRun_Group AS grp, tblRun_GroupComment AS grp_cmt, (SELECT group_id FROM tblRun_Group WHERE run_id=$1) AS run_grp WHERE grp_cmt.group_id = run_grp.group_id AND grp_cmt.group_type='laser' AND grp_cmt.group_id=grp.group_id AND grp.run_id=info.run_id AND (info.run_type='flasher' OR info.run_type='laser');" +QUERY="SELECT info.run_id, grp_cmt.excluded_telescopes, info.config_mask FROM tblRun_Info AS info, tblRun_Group AS grp, tblRun_GroupComment AS grp_cmt, (SELECT group_id FROM tblRun_Group WHERE run_id=$RUN) AS run_grp WHERE grp_cmt.group_id = run_grp.group_id AND grp_cmt.group_type='laser' AND grp_cmt.group_id=grp.group_id AND grp.run_id=info.run_id AND (info.run_type='flasher' OR info.run_type='laser');" -$($EVNDISPSCRIPTS/db_scripts/db_mysqldb.sh) -e "USE VERITAS; ${QUERY}" | sed 's/\t/|/g' +$("$EVNDISPSCRIPTS"/db_scripts/db_mysqldb.sh) -e "USE VERITAS; ${QUERY}" | sed 's/\t/|/g' diff --git a/scripts/db_scripts/db_lidar.sh b/scripts/db_scripts/db_lidar.sh index f63c54f..5b17957 100755 --- a/scripts/db_scripts/db_lidar.sh +++ b/scripts/db_scripts/db_lidar.sh @@ -18,5 +18,5 @@ if [[ "${STARTDATE}" == *NULL* ]] || [[ "${ENDDATE}" == *NULL* ]]; then echo "" else QUERY="SELECT * FROM tblLIDAR_Info WHERE timestamp >= \"${STARTDATE}\" AND timestamp < \"${ENDDATE}\"" - $($EVNDISPSCRIPTS/db_scripts/db_mysqldb.sh) -e "USE VERITAS; ${QUERY}" | sed 's/\t/|/g' + $("$EVNDISPSCRIPTS"/db_scripts/db_mysqldb.sh) -e "USE VERITAS; ${QUERY}" | sed 's/\t/|/g' fi diff --git a/scripts/db_scripts/db_mysqldb.sh b/scripts/db_scripts/db_mysqldb.sh index c4d7019..bca5cc6 100755 --- a/scripts/db_scripts/db_mysqldb.sh +++ b/scripts/db_scripts/db_mysqldb.sh @@ -13,7 +13,7 @@ fi # get url of veritas db PARAFILE="${VERITAS_EVNDISP_AUX_DIR}/ParameterFiles/EVNDISP.global.runparameter" -MYSQLDB=`grep '^\*[ \t]*DBSERVER[ \t]*mysql://' ${PARAFILE} | egrep -o '[[:alpha:]]{1,20}\.[[:alpha:]]{1,20}\.[[:alpha:]]{1,20}'` +MYSQLDB=$(grep '^\*[ \t]*DBSERVER[ \t]*mysql://' "${PARAFILE}" | grep -E -o '[[:alpha:]]{1,20}\.[[:alpha:]]{1,20}\.[[:alpha:]]{1,20}') if [ ! -n "$MYSQLDB" ] ; then echo "Error: DBSERVER parameters not found in ${PARAFILE}" exit 1 diff --git a/scripts/db_scripts/db_pack_new_directories.sh b/scripts/db_scripts/db_pack_new_directories.sh index fa8a33e..3643b6c 100755 --- a/scripts/db_scripts/db_pack_new_directories.sh +++ b/scripts/db_scripts/db_pack_new_directories.sh @@ -15,17 +15,17 @@ get_run_directory() fi echo "${DBTEXTDIR}/${SRUN}" } -LDIR=$(find ${DBTEXTDIR} -type d -name "[0-9][0-9][0-9]*") +LDIR=$(find "${DBTEXTDIR}" -type d -name "[0-9][0-9][0-9]*") PDIR=$(pwd) for L in ${LDIR} do - RUN=$(basename $L) - TDIR=$(get_run_directory $RUN) - echo $RUN $TDIR/$RUN + RUN=$(basename "$L") + TDIR=$(get_run_directory "$RUN") + echo "$RUN" "$TDIR"/"$RUN" cd "$TDIR" || exit - tar -czf ${RUN}.tar.gz ${RUN} + tar -czf "${RUN}".tar.gz "${RUN}" done cd "${PDIR}" || exit diff --git a/scripts/db_scripts/db_rawpointing.sh b/scripts/db_scripts/db_rawpointing.sh index d92209f..8f9fcbe 100755 --- a/scripts/db_scripts/db_rawpointing.sh +++ b/scripts/db_scripts/db_rawpointing.sh @@ -28,5 +28,5 @@ if [[ "${STARTDATE}" == *NULL* ]] || [[ "${TIMEEND}" == *NULL* ]]; then echo "" else QUERY="SELECT timestamp, elevation_raw, azimuth_raw, elevation_meas, azimuth_meas, elevation_target, azimuth_target FROM tblPositioner_Telescope${TELID}_Status WHERE timestamp >= ${TIMESTART} AND timestamp <= ${TIMEEND};" - $($EVNDISPSCRIPTS/db_scripts/db_mysqldb.sh) -e "USE VERITAS; ${QUERY}" | sed 's/\t/|/g' + $("$EVNDISPSCRIPTS"/db_scripts/db_mysqldb.sh) -e "USE VERITAS; ${QUERY}" | sed 's/\t/|/g' fi diff --git a/scripts/db_scripts/db_run.sh b/scripts/db_scripts/db_run.sh index c65ad60..ab15b02 100755 --- a/scripts/db_scripts/db_run.sh +++ b/scripts/db_scripts/db_run.sh @@ -28,7 +28,7 @@ OVERWRITE="0" NTEL="4" DBDIR="${VERITAS_DATA_DIR%/}/shared/DBTEXT/" -mkdir -p ${DBDIR} +mkdir -p "${DBDIR}" getDBTextFileDirectory() { @@ -38,7 +38,7 @@ getDBTextFileDirectory() else ODIR="${DBDIR%/}/${TRUN:0:2}/${TRUN}" fi - echo ${ODIR} + echo "${ODIR}" } get_file_status() @@ -51,10 +51,10 @@ get_file_status() elif [[ -e ${TFIL} ]]; then echo "2" else - TARF="$(getDBTextFileDirectory ${RRUN}).tar.gz" + TARF="$(getDBTextFileDirectory "${RRUN}").tar.gz" if [[ -e ${TARF} ]]; then - FFIL="${RRUN}/$(basename ${TFIL})" - CFIL=$(tar -tzf ${TARF} ${FFIL} 2>/dev/null) + FFIL="${RRUN}/$(basename "${TFIL}")" + CFIL=$(tar -tzf "${TARF}" "${FFIL}" 2>/dev/null) if [[ "${CFIL}" == "${FFIL}" ]]; then echo "1" else @@ -68,7 +68,7 @@ get_file_status() get_start_time() { - OFIL="$(getDBTextFileDirectory ${RUN})/${RUN}.runinfo" + OFIL="$(getDBTextFileDirectory "${RUN}")/${RUN}.runinfo" if [[ "${1:-}" == "DB" ]]; then field_name="db_start_time" else @@ -86,13 +86,13 @@ get_start_time() done fi start_time="${a[$start_time_index]}" - done < ${OFIL} + done < "${OFIL}" echo "${start_time}" } get_end_time() { - OFIL="$(getDBTextFileDirectory ${RUN})/${RUN}.runinfo" + OFIL="$(getDBTextFileDirectory "${RUN}")/${RUN}.runinfo" if [[ "${1:-}" == "DB" ]]; then field_name="db_end_time" else @@ -110,7 +110,7 @@ get_end_time() done fi end_time="${a[$end_time_index]}" - done < ${OFIL} + done < "${OFIL}" # add 1 minute to end time to be save end_time=$(date -d "${end_time} 1 minutes" +'%Y-%m-%d %H:%M:%S') echo "${end_time}" @@ -118,19 +118,19 @@ get_end_time() get_laser_run() { - OFIL="$(getDBTextFileDirectory ${RUN})/${RUN}.laserrun" + OFIL="$(getDBTextFileDirectory "${RUN}")/${RUN}.laserrun" LASERRUN="" while IFS="|" read -ra a; do if [[ ${a[0]} != "run_id" ]]; then LASERRUN="${LASERRUN} ${a[0]}" fi - done < ${OFIL} - echo ${LASERRUN} + done < "${OFIL}" + echo "${LASERRUN}" } get_excluded_telescopes() { - OFIL="$(getDBTextFileDirectory ${RUN})/${RUN}.laserrun" + OFIL="$(getDBTextFileDirectory "${RUN}")/${RUN}.laserrun" excluded_telescopes="" while IFS="|" read -ra a; do if [[ ${a[0]} == "run_id" ]]; then @@ -145,8 +145,8 @@ get_excluded_telescopes() if [[ ${a[0]} == "$1" ]]; then excluded_telescopes=${a[$excluded_telescopes_index]} fi - done < ${OFIL} - echo ${excluded_telescopes} + done < "${OFIL}" + echo "${excluded_telescopes}" } @@ -166,13 +166,13 @@ hasbitset() get_source_id() { - OFIL="$(getDBTextFileDirectory ${RUN})/${RUN}.runinfo" + OFIL="$(getDBTextFileDirectory "${RUN}")/${RUN}.runinfo" local tar_file tar_file="$(getDBTextFileDirectory "${RUN}").tar.gz" if [[ ! -e ${OFIL} ]] && [[ -e ${tar_file} ]]; then OFIL=$(tar -xzf "$tar_file" "${RUN}/${RUN}.runinfo" -O) else - OFIL=$(cat $OFIL) + OFIL=$(cat "$OFIL") fi source_index=0 while IFS="|" read -ra a; do @@ -187,7 +187,7 @@ get_source_id() fi source_id="${a[$source_index]}" done <<< "$OFIL" - echo ${source_id} + echo "${source_id}" } # generic function to read call scripts reading from DB @@ -199,20 +199,20 @@ read_run_from_DB() [[ "$3" ]] && TELID=$3 || TELID="" [[ "$4" ]] && USETIME=$4 || USETIME="0" if [[ -z ${TELID} ]]; then - OFIL="$(getDBTextFileDirectory ${RRUN})/${RRUN}.${TTOOL}" + OFIL="$(getDBTextFileDirectory "${RRUN}")/${RRUN}.${TTOOL}" else - OFIL="$(getDBTextFileDirectory ${RRUN})/${RRUN}.${TTOOL}_TEL${TELID}" + OFIL="$(getDBTextFileDirectory "${RRUN}")/${RRUN}.${TTOOL}_TEL${TELID}" fi - FILESTATUS="$(get_file_status ${RRUN} ${OFIL})" + FILESTATUS="$(get_file_status "${RRUN}" "${OFIL}")" if [[ ${FILESTATUS} == 0 ]]; then - mkdir -p "$(getDBTextFileDirectory ${RRUN})" - rm -f ${OFIL} + mkdir -p "$(getDBTextFileDirectory "${RRUN}")" + rm -f "${OFIL}" if [[ $USETIME -eq "0" ]]; then cmd="./db_${TTOOL}.sh ${RRUN} ${TELID}" else cmd="./db_${TTOOL}.sh \"$(get_start_time "")\" \"$(get_end_time "")\" ${TELID}" fi - eval "$cmd" > ${OFIL} + eval "$cmd" > "${OFIL}" echo "${TTOOL} file (written): ${OFIL}" elif [[ ${FILESTATUS} == 1 ]]; then echo "${TTOOL} file (in tar package): ${OFIL}" @@ -228,18 +228,18 @@ read_laser_run_and_dqm() for L in "${LASERRUN[@]}" do if [[ -n ${L} ]]; then - read_run_from_DB rundqm ${L} + read_run_from_DB rundqm "${L}" fi done } read_target() { - OFIL="$(getDBTextFileDirectory ${RUN})/${RUN}.target" + OFIL="$(getDBTextFileDirectory "${RUN}")/${RUN}.target" source_id=$(get_source_id) - FILESTATUS="$(get_file_status ${RUN} ${OFIL})" + FILESTATUS="$(get_file_status "${RUN}" "${OFIL}")" if [[ ${FILESTATUS} == 0 ]]; then - ./db_target.sh "${source_id}" > ${OFIL} + ./db_target.sh "${source_id}" > "${OFIL}" echo "target file (written): ${OFIL}" elif [[ ${FILESTATUS} == 1 ]]; then echo "target file (in tar package): ${OFIL}" @@ -250,18 +250,18 @@ read_target() read_camera_rotation() { - OFIL="$(getDBTextFileDirectory ${RUN})/${RUN}.camerarotation" - read_run_from_DB camerarotation ${RUN} "" 1 + OFIL="$(getDBTextFileDirectory "${RUN}")/${RUN}.camerarotation" + read_run_from_DB camerarotation "${RUN}" "" 1 } read_pixel_data() { read_run_from_DB L1_TriggerInfo - for (( j=0; j<${NTEL}; j++ )); + for (( j=0; j> ${1}/${1}.laserrun - echo "${3}|0|15" >> ${1}/${1}.laserrun + echo "run_id|excluded_telescopes|config_mask" >> "${1}"/"${1}".laserrun + echo "${3}|0|15" >> "${1}"/"${1}".laserrun cd .. || exit } -DBTEXTFILE=$(get_db_text_tar_file ${1}) +DBTEXTFILE=$(get_db_text_tar_file "${1}") if [[ ! -e ${DBTEXTFILE} ]]; then echo "Error: db tar file nout found: ${DBTEXTFILE}" exit fi echo "checking for laser runs for run ${1}" -LASERSTRING=$(tar -axf ${DBTEXTFILE} ${1}/${1}.laserrun -O) +LASERSTRING=$(tar -axf "${DBTEXTFILE}" "${1}"/"${1}".laserrun -O) if [ -z "${LASERSTRING}" ]; then - OBSDATE=$(get_date ${1} ${DBTEXTFILE}) + OBSDATE=$(get_date "${1}" "${DBTEXTFILE}") echo " Observation date is: ${OBSDATE} found in ${2}" - LASERRUN=$(grep ${OBSDATE} ${2}) + LASERRUN=$(grep "${OBSDATE}" "${2}") if [ -n "${LASERRUN}" ]; then echo " FOUND ${LASERRUN} ${OBSDATE}" fill_laser_run "${1}" "${DBTEXTFILE}" "$(echo "$LASERRUN" | cut -d ' ' -f 2)" diff --git a/scripts/db_scripts/db_update_tar_balls.sh b/scripts/db_scripts/db_update_tar_balls.sh index 17b5ecc..f1a336a 100755 --- a/scripts/db_scripts/db_update_tar_balls.sh +++ b/scripts/db_scripts/db_update_tar_balls.sh @@ -28,11 +28,11 @@ get_run_directory() } PDIR=$(pwd) -FILES=$(cat $FLIST) +FILES=$(cat "$FLIST") for RUN in $FILES do - SUBDIR=$(get_run_directory $RUN) + SUBDIR=$(get_run_directory "$RUN") ORG_FILE="${DBTEXTDIR}/${SUBDIR}/${RUN}.tar.gz" if [[ ! -e "${ORG_FILE}" ]]; then @@ -47,11 +47,11 @@ do # copy and unpack tar ball cd "${NEWDIR}/${SUBDIR}/" || exit - cp ${ORG_FILE} . - tar -xvzf ${RUN}.tar.gz - rm -f ${RUN}.tar.gz + cp "${ORG_FILE}" . + tar -xvzf "${RUN}".tar.gz + rm -f "${RUN}".tar.gz # pack again with all files - tar -cvzf ${RUN}.tar.gz ${RUN} + tar -cvzf "${RUN}".tar.gz "${RUN}" cd "${PDIR}" || exit done diff --git a/scripts/db_scripts/db_weather.sh b/scripts/db_scripts/db_weather.sh index 103048c..6b78a78 100755 --- a/scripts/db_scripts/db_weather.sh +++ b/scripts/db_scripts/db_weather.sh @@ -15,4 +15,4 @@ STARTDATE="$1" ENDDATE="$2" QUERY="SELECT timestamp, WS_mph_Avg, WS_mph_Max, WS_mph_Min, WindDir, AirTF_Avg, RH, Rain_in_Tot, SlrW_Avg, SlrkJ_Tot, BP_mbar_Avg FROM tblWeather_Status WHERE timestamp >= \"${STARTDATE}\" AND timestamp < \"${ENDDATE}\"" -$($EVNDISPSCRIPTS/db_scripts/db_mysqldb.sh) -e "USE VERITAS; ${QUERY}" | sed 's/\t/|/g' +$("$EVNDISPSCRIPTS"/db_scripts/db_mysqldb.sh) -e "USE VERITAS; ${QUERY}" | sed 's/\t/|/g' diff --git a/scripts/db_scripts/db_write_fits_from_runlist.sh b/scripts/db_scripts/db_write_fits_from_runlist.sh index 2f6d47c..20c4eb3 100755 --- a/scripts/db_scripts/db_write_fits_from_runlist.sh +++ b/scripts/db_scripts/db_write_fits_from_runlist.sh @@ -12,11 +12,11 @@ db_write_fits_from_runlist.sh: write DB FITS files from run list exit fi -RUNS=$(cat $1) +RUNS=$(cat "$1") IDIR="$VERITAS_DATA_DIR/shared/DBTEXT/" ODIR="./" for R in $RUNS do - python ./db_write_fits.py --run ${R} --input_path ${IDIR} --output_path ${ODIR} + python ./db_write_fits.py --run "${R}" --input_path "${IDIR}" --output_path ${ODIR} done diff --git a/scripts/db_scripts/query_run_list.sh b/scripts/db_scripts/query_run_list.sh index b8b8665..4a7cf69 100755 --- a/scripts/db_scripts/query_run_list.sh +++ b/scripts/db_scripts/query_run_list.sh @@ -13,10 +13,10 @@ query_run_list.sh: query DB and write DBTEXT files exit fi -RUNS=$(cat $1) +RUNS=$(cat "$1") [[ "$2" ]] && OVERW=$2 || OVERW="0" for R in $RUNS do - ./db_run.sh ${R} ${OVERW} + ./db_run.sh "${R}" "${OVERW}" done diff --git a/scripts/helper_scripts/ANALYSIS.anasum_combine_sub.sh b/scripts/helper_scripts/ANALYSIS.anasum_combine_sub.sh index 8d16cfc..c7270ec 100755 --- a/scripts/helper_scripts/ANALYSIS.anasum_combine_sub.sh +++ b/scripts/helper_scripts/ANALYSIS.anasum_combine_sub.sh @@ -2,8 +2,9 @@ # script to combine anasum runs # # set observatory environmental variables +# shellcheck source=/dev/null if [ ! -n "$EVNDISP_APPTAINER" ]; then - source $EVNDISPSYS/setObservatory.sh VTS + source "$EVNDISPSYS"/setObservatory.sh VTS fi # parameters replaced by parent script using sed @@ -20,7 +21,7 @@ if [[ -n $TMPDIR ]]; then else TEMPDIR="$VERITAS_USER_DATA_DIR/TMPDIR/ANASUM-$(uuidgen)" fi -mkdir -p $TEMPDIR +mkdir -p "$TEMPDIR" echo "TEMPDIR: $TEMPDIR" getNumberedDirectory() @@ -32,7 +33,7 @@ getNumberedDirectory() else ODIR="${IDIR}/${TRUN:0:2}/" fi - echo ${ODIR} + echo "${ODIR}" } # copy file list, runparameter and time masks file to tmp disk @@ -53,7 +54,7 @@ for R in $RUNS; do if [[ -e "$DDIR/$R.anasum.root" ]]; then cp -f -v "$DDIR/$R.anasum.root" "$TEMPDIR" else - FIL="$(getNumberedDirectory $R ${DDIR})/${R}.anasum.root" + FIL="$(getNumberedDirectory "$R" ${DDIR})/${R}.anasum.root" if [[ -e "$FIL" ]]; then cp -f -v "$FIL" "$TEMPDIR" else @@ -71,7 +72,7 @@ fi # determine if this is a short or long run list # (use VERSION string to identify long run list) NV=$(grep -c "VERSION" ${RUNLIST}) -if [ $NV -eq 0 ]; then +if [ "$NV" -eq 0 ]; then RUNLISTSTRING="-k" else RUNLISTSTRING="-l" @@ -101,7 +102,7 @@ inspect_executables() if [ -n "$EVNDISP_APPTAINER" ]; then apptainer inspect "$EVNDISP_APPTAINER" else - ls -l ${EVNDISPSYS}/bin/anasum + ls -l "${EVNDISPSYS}"/bin/anasum fi } echo "TEMPDIR: ${TEMPDIR}" @@ -115,28 +116,30 @@ echo "RUNP ${RUNP}" echo "OUTPUTDATAFILE ${OUTPUTDATAFILE}" echo "OUTPUTLOGFILE ${OUTPUTLOGFILE}" -$EVNDISPSYS/bin/anasum \ +"$EVNDISPSYS"/bin/anasum \ -i 1 \ - ${RUNLISTSTRING} ${RUNLIST} \ - -d ${TEMPDIR} \ - -f ${RUNP} \ - -o ${OUTPUTDATAFILE}.root 2>&1 | tee ${OUTPUTLOGFILE} + ${RUNLISTSTRING} "${RUNLIST}" \ + -d "${TEMPDIR}" \ + -f "${RUNP}" \ + -o "${OUTPUTDATAFILE}".root 2>&1 | tee ${OUTPUTLOGFILE} # for Crab runs: print sensitivity estimate -RUNINFO=$($EVNDISPSYS/bin/printRunParameter ${OUTPUTDATAFILE}.root -runinfo) -TMPTARGET=$(echo $RUNINFO | cut -d\ -f7- ) +RUNINFO=$("$EVNDISPSYS"/bin/printRunParameter "${OUTPUTDATAFILE}".root -runinfo) +TMPTARGET=$(echo "$RUNINFO" | cut -d\ -f7- ) if [[ ${TMPTARGET} == "Crab" ]]; then - echo "========================== SENSITIVITY ESTIMATE ==========================" >> ${OUTFILE}.log - $EVNDISPSYS/bin/printCrabSensitivity ${OUTPUTDATAFILE}.root >> ${OUTFILE}.log - echo "========================== ==========================" >> ${OUTFILE}.log + { + echo "========================== SENSITIVITY ESTIMATE ==========================" + "$EVNDISPSYS"/bin/printCrabSensitivity "${OUTPUTDATAFILE}".root + echo "========================== ==========================" + } >> "${OUTFILE}.log" fi -echo "$(inspect_executables)" >> ${OUTFILE}.log +inspect_executables >> ${OUTFILE}.log # log file into root file -$EVNDISPSYS/bin/logFile \ +"$EVNDISPSYS"/bin/logFile \ anasumLog \ - ${OUTPUTDATAFILE}.root \ - ${OUTPUTDATAFILE}.log + "${OUTPUTDATAFILE}".root \ + "${OUTPUTDATAFILE}".log exit diff --git a/scripts/helper_scripts/ANALYSIS.anasum_sub.sh b/scripts/helper_scripts/ANALYSIS.anasum_sub.sh index a3915f8..01fae23 100755 --- a/scripts/helper_scripts/ANALYSIS.anasum_sub.sh +++ b/scripts/helper_scripts/ANALYSIS.anasum_sub.sh @@ -2,6 +2,7 @@ # script to analyse one run with anasum # set observatory environmental variables +# shellcheck source=/dev/null if [ ! -n "$EVNDISP_APPTAINER" ]; then source "$EVNDISPSYS"/setObservatory.sh VTS fi @@ -48,7 +49,7 @@ if [[ -n "$TMPDIR" ]]; then else TEMPDIR="$VERITAS_USER_DATA_DIR/TMPDIR/MSCWDISP-$(uuidgen)" fi -mkdir -p $TEMPDIR +mkdir -p "$TEMPDIR" # explicit binding for apptainers if [ -n "$EVNDISP_APPTAINER" ]; then @@ -79,7 +80,7 @@ inspect_executables() if [ -n "$EVNDISP_APPTAINER" ]; then apptainer inspect "$EVNDISP_APPTAINER" else - ls -l ${EVNDISPSYS}/bin/anasum + ls -l "${EVNDISPSYS}"/bin/anasum fi } @@ -121,15 +122,15 @@ if [[ $FLIST == "NOTDEFINED" ]]; then echo "* VERSION 6" > $FLIST echo "" >> $FLIST # preparing effective area and radial acceptance names - RUNINFO=$($EVNDISPSYS/bin/printRunParameter "$INFILEPATH" -runinfo) - EPOCH=`echo "$RUNINFO" | awk '{print $(1)}'` - MAJOREPOCH=`echo $RUNINFO | awk '{print $(2)}'` - ATMO=${FORCEDATMO:-`echo $RUNINFO | awk '{print $(3)}'`} - OBSL=$(echo $RUNINFO | awk '{print $4}') - TELTOANA=`echo $RUNINFO | awk '{print "T"$(5)}'` + RUNINFO=$("$EVNDISPSYS"/bin/printRunParameter "$INFILEPATH" -runinfo) + EPOCH=$(echo "$RUNINFO" | awk '{print $(1)}') + MAJOREPOCH=$(echo "$RUNINFO" | awk '{print $(2)}') + ATMO=${FORCEDATMO:-$(echo "$RUNINFO" | awk '{print $(3)}')} + OBSL=$(echo "$RUNINFO" | awk '{print $4}') + TELTOANA=$(echo "$RUNINFO" | awk '{print "T"$(5)}') - REPLACESIMTYPEEff=$(prepare_irf_string $EPOCH $OBSL $SIMTYPE 0) - REPLACESIMTYPERad=$(prepare_irf_string $EPOCH $OBSL $SIMTYPE 1) + REPLACESIMTYPEEff=$(prepare_irf_string "$EPOCH" "$OBSL" $SIMTYPE 0) + REPLACESIMTYPERad=$(prepare_irf_string "$EPOCH" "$OBSL" $SIMTYPE 1) echo "RUN $RUNNUM at epoch $EPOCH and atmosphere $ATMO (Telescopes $TELTOANA SIMTYPE $REPLACESIMTYPEEff $REPLACESIMTYPERad)" # do string replacements @@ -205,18 +206,20 @@ RUNP="${TEMPDIR}/$(basename $RUNP)" ################################# # run anasum -$EVNDISPSYS/bin/anasum \ - -f $RUNP \ - -l $FLIST \ +"$EVNDISPSYS"/bin/anasum \ + -f "$RUNP" \ + -l "$FLIST" \ -d $INDIR \ -o $OUTPUTDATAFILE &> $OUTPUTLOGFILE -echo "$(inspect_executables)" >> ${OUTPUTLOGFILE} -echo "INDIR ${INDIR}" >> ${OUTPUTLOGFILE} -echo "VERITAS_ANALYSIS_TYPE ${VERITAS_ANALYSIS_TYPE}" >> ${OUTPUTLOGFILE} +{ + inspect_executables + echo "INDIR ${INDIR}" + echo "VERITAS_ANALYSIS_TYPE ${VERITAS_ANALYSIS_TYPE}" +} >> "${OUTPUTLOGFILE}" if [[ -e "$OUTPUTLOGFILE" ]]; then - $EVNDISPSYS/bin/logFile anasumLog "$OUTPUTDATAFILE" "$(dirname $OUTPUTDATAFILE)/$(basename $OUTPUTLOGFILE)" + "$EVNDISPSYS"/bin/logFile anasumLog "$OUTPUTDATAFILE" "$(dirname $OUTPUTDATAFILE)/$(basename $OUTPUTLOGFILE)" fi echo "RUN$RUNNUM ANPARLOG log file: $OUTPUTLOGFILE" diff --git a/scripts/helper_scripts/ANALYSIS.dispXGB_sub.sh b/scripts/helper_scripts/ANALYSIS.dispXGB_sub.sh index 90da6bc..a9a1a8a 100755 --- a/scripts/helper_scripts/ANALYSIS.dispXGB_sub.sh +++ b/scripts/helper_scripts/ANALYSIS.dispXGB_sub.sh @@ -58,27 +58,27 @@ getNumberedDirectory() else ODIR="${IDIR}/${TRUN:0:2}/" fi - echo ${ODIR} + echo "${ODIR}" } echo $RUN -MSCW_FILE="$(getNumberedDirectory $RUN ${VERITAS_PREPROCESSED_DATA_DIR}${VERITAS_ANALYSIS_TYPE:0:2}/mscw)/$RUN.mscw.root" +MSCW_FILE="$(getNumberedDirectory $RUN "${VERITAS_PREPROCESSED_DATA_DIR}""${VERITAS_ANALYSIS_TYPE:0:2}"/mscw)/$RUN.mscw.root" if [[ ! -e ${MSCW_FILE} ]]; then echo "File ${MSCW_FILE} not found. Exiting." exit fi -RUNINFO=$($EVNDISPSYS/bin/printRunParameter ${MSCW_FILE} -runinfo) +RUNINFO=$("$EVNDISPSYS"/bin/printRunParameter "${MSCW_FILE}" -runinfo) echo "RUNINFO $RUNINFO" -ZA=$(echo $RUNINFO | awk '{print $8}') -EPOCH=$(echo $RUNINFO | awk '{print $1}') -ATM=$(echo $RUNINFO | awk '{print $3}') +ZA=$(echo "$RUNINFO" | awk '{print $8}') +EPOCH=$(echo "$RUNINFO" | awk '{print $1}') +ATM=$(echo "$RUNINFO" | awk '{print $3}') echo "MSCW file: ${MSCW_FILE} at zenith ${ZA} deg, epoch ${EPOCH}, ATM ${ATM}" DISPDIR="$VERITAS_EVNDISP_AUX_DIR/DispXGB/${ANATYPE}/${EPOCH}_ATM${ATM}" if [[ ! -d "${DISPDIR}" ]]; then echo "Error finding model directory $DISPDIR" exit fi -OFIL=$(basename $MSCW_FILE .root) +OFIL=$(basename "$MSCW_FILE" .root) if [[ "${XGB_TYPE}" == "stereo_analysis" ]]; then STEREO_PAR="$VERITAS_EVNDISP_AUX_DIR/ParameterFiles/XGB-stereo-parameter.json" BIN_ID=$(jq -r --arg za "$ZA" ' diff --git a/scripts/helper_scripts/ANALYSIS.evndisp_laser_sub.sh b/scripts/helper_scripts/ANALYSIS.evndisp_laser_sub.sh index a89cbb6..6046daa 100755 --- a/scripts/helper_scripts/ANALYSIS.evndisp_laser_sub.sh +++ b/scripts/helper_scripts/ANALYSIS.evndisp_laser_sub.sh @@ -1,8 +1,9 @@ #!/bin/bash # script to analyse laser files +# shellcheck source=/dev/null # set observatory environmental variables -source $EVNDISPSYS/setObservatory.sh VTS +source "$EVNDISPSYS"/setObservatory.sh VTS # parameters replaced by parent script using sed RUN=RUNFILE @@ -12,6 +13,6 @@ echo $RUN # run eventdisplay rm -f "$LOGDIR/$RUN.laser.log" -${EVNDISPSCRIPTS}/SPANALYSIS.evndisp_laser_run.sh $RUN $TELTOANA &> $LOGDIR/$RUN.laser.log +"${EVNDISPSCRIPTS}"/SPANALYSIS.evndisp_laser_run.sh $RUN $TELTOANA &> $LOGDIR/$RUN.laser.log exit diff --git a/scripts/helper_scripts/ANALYSIS.evndisp_sub.sh b/scripts/helper_scripts/ANALYSIS.evndisp_sub.sh index 506d3c5..de56d4c 100755 --- a/scripts/helper_scripts/ANALYSIS.evndisp_sub.sh +++ b/scripts/helper_scripts/ANALYSIS.evndisp_sub.sh @@ -2,6 +2,7 @@ # script to analyse VTS raw files (VBF) with eventdisplay # set observatory environmental variables +# shellcheck source=/dev/null if [ ! -n "$EVNDISP_APPTAINER" ]; then source "$EVNDISPSYS"/setObservatory.sh VTS fi @@ -57,7 +58,7 @@ inspect_executables() if [ -n "$EVNDISP_APPTAINER" ]; then apptainer inspect "$EVNDISP_APPTAINER" else - ls -l ${EVNDISPSYS}/bin/evndisp + ls -l "${EVNDISPSYS}"/bin/evndisp fi } @@ -73,8 +74,8 @@ unpack_db_textdirectory() DBRUNFIL="${DBTEXTDIRECTORY}/${SRUN}/${RRUN}.tar.gz" echo "DBTEXT FILE for $RRUN $DBRUNFIL" >&2 if [[ -e ${DBRUNFIL} ]]; then - mkdir -p ${TMP_DBTEXTDIRECTORY}/${SRUN} - tar -xzf ${DBRUNFIL} -C ${TMP_DBTEXTDIRECTORY}/${SRUN}/ || return 1 + mkdir -p "${TMP_DBTEXTDIRECTORY}"/"${SRUN}" + tar -xzf "${DBRUNFIL}" -C "${TMP_DBTEXTDIRECTORY}"/"${SRUN}"/ || return 1 else echo "DBTEXT FILE not found ($DBRUNFIL)" >&2 return 1 @@ -104,18 +105,18 @@ sub_dir() if [[ "${DBTEXTDIRECTORY}" != "0" ]]; then echo "UNPACKING DBTEXT from $RUN ${DBTEXTDIRECTORY}" TMP_DBTEXTDIRECTORY="${TEMPDIR}/DBTEXT" - TMP_LASERRUN=$(unpack_db_textdirectory $RUN $TMP_DBTEXTDIRECTORY) + TMP_LASERRUN=$(unpack_db_textdirectory $RUN "$TMP_DBTEXTDIRECTORY") if [[ $? -ne 0 || ! -r ${TMP_LASERRUN} ]]; then echo "failed to unpack DBTEXT laser-run metadata for run $RUN" >&2 exit 1 fi - LRUNID=$(cat ${TMP_LASERRUN} | grep -v run_id | awk -F "|" '{print $1}') + LRUNID=$(cat "${TMP_LASERRUN}" | grep -v run_id | awk -F "|" '{print $1}') for LL in ${LRUNID} do echo " unpacking flasher/laser run: $LL" - unpack_db_textdirectory $LL $TMP_DBTEXTDIRECTORY >/dev/null || exit 1 + unpack_db_textdirectory "$LL" "$TMP_DBTEXTDIRECTORY" >/dev/null || exit 1 done - echo "DBTEXT directory $(ls -l $TMP_DBTEXTDIRECTORY)" + echo "DBTEXT directory $(ls -l "$TMP_DBTEXTDIRECTORY")" OPT=(-dbtextdirectory "${TMP_DBTEXTDIRECTORY}" -epochfile VERITAS.Epochs.runparameter) echo "${OPT[@]}" @@ -135,7 +136,7 @@ get_run_date() done fi start_time="${a[$start_time_index]}" - done < ${OFIL} + done < "${OFIL}" year=$(date --utc -d "$start_time" +%Y) month=$(date --utc -d "$start_time" +%m) day=$(date --utc -d "$start_time" +%d) @@ -146,14 +147,14 @@ get_run_date() ################################# # check if run is on disk if [[ "${DBTEXTDIRECTORY}" != "0" ]]; then - RUNINFO=$(sub_dir ${TMP_DBTEXTDIRECTORY} ${RUN})/${RUN}/${RUN}.runinfo + RUNINFO=$(sub_dir "${TMP_DBTEXTDIRECTORY}" ${RUN})/${RUN}/${RUN}.runinfo if [[ ! -r ${RUNINFO} ]]; then echo "DBTEXT run info not readable (${RUNINFO})" >&2 exit 1 fi - RUNDATE=$(get_run_date ${RUNINFO}) + RUNDATE=$(get_run_date "${RUNINFO}") echo "RUN $RUN $RUNINFO $RUNDATE" - ls -l ${TMP_DBTEXTDIRECTORY} + ls -l "${TMP_DBTEXTDIRECTORY}" # preference to VERITAS_DATA_DIR_2 if [[ -e ${VERITAS_DATA_DIR_2}/data/${RUNDATE}/${RUN}.cvbf ]]; then if [ -n "$EVNDISP_APPTAINER" ]; then @@ -172,7 +173,7 @@ if [[ "${DBTEXTDIRECTORY}" != "0" ]]; then fi else # original way accessing the VERITAS DB - RUNONDISK=$(echo $RUN | $EVNDISPSCRIPTS/RUNLIST.whichRunsAreOnDisk.sh -d) + RUNONDISK=$(echo $RUN | "$EVNDISPSCRIPTS"/RUNLIST.whichRunsAreOnDisk.sh -d) fi if [[ ${RUNONDISK} == *"file not found"** ]]; then echo "$RUN not on disk" @@ -196,12 +197,12 @@ fi # pedestal calculation if [[ $CALIB == "1" || $CALIB == "2" || $CALIB == "4" || $CALIB == "5" ]]; then rm -f $LOGDIR/$RUN.ped.log - $EVNDISPSYS/bin/evndisp \ + "$EVNDISPSYS"/bin/evndisp \ -runmode=1 -runnumber="$RUN" \ -reconstructionparameter "$ACUTS" \ "${OPT[@]}" \ -calibrationdirectory "$CALDIR" &> "$LOGDIR/$RUN.ped.log" - echo "$(inspect_executables)" >> "$LOGDIR/$RUN.ped.log" + inspect_executables >> "$LOGDIR/$RUN.ped.log" echo "RUN$RUN PEDLOG $LOGDIR/$RUN.ped.log" fi @@ -228,13 +229,13 @@ fi # average tzero calculation if [[ $CALIB == "1" || $CALIB == "3" || $CALIB == "4" || $CALIB == "5" ]]; then rm -f $LOGDIR/$RUN.tzero.log - $EVNDISPSYS/bin/evndisp \ + "$EVNDISPSYS"/bin/evndisp \ -runnumber=$RUN -runmode=7 \ -calibrationsummin=50 \ -reconstructionparameter "$ACUTS" \ "${OPT[@]}" \ -calibrationdirectory "$CALDIR" &> "$LOGDIR/$RUN.tzero.log" - echo "$(inspect_executables)" >> "$LOGDIR/$RUN.tzero.log" + inspect_executables >> "$LOGDIR/$RUN.tzero.log" echo "RUN$RUN TZEROLOG $LOGDIR/$RUN.tzero.log" fi @@ -263,31 +264,31 @@ fi if [[ $CALIB != "5" ]]; then LOGFILE="$LOGDIR/$RUN.log" rm -f "$LOGDIR/$RUN.log" - $EVNDISPSYS/bin/evndisp \ + "$EVNDISPSYS"/bin/evndisp \ -runnumber="$RUN" \ -reconstructionparameter "$ACUTS" \ -outputfile "$TEMPDIR/$RUN.root" \ "${OPT[@]}" \ -calibrationdirectory "$CALDIR" &> "$LOGFILE" - echo "$(inspect_executables)" >> "$LOGFILE" + inspect_executables >> "$LOGFILE" echo "RUN$RUN EVNDISPLOG $LOGFILE" fi # move log file into root file if [[ -e "$LOGFILE" ]]; then - cp -v $LOGFILE $TEMPDIR + cp -v "$LOGFILE" "$TEMPDIR" LLF="${TEMPDIR}/$RUN.log" - $EVNDISPSYS/bin/logFile evndispLog "$TEMPDIR/$RUN.root" "$LLF" + "$EVNDISPSYS"/bin/logFile evndispLog "$TEMPDIR/$RUN.root" "$LLF" fi if [[ -e "$LOGDIR/$RUN.ped.log" ]]; then - cp -v $LOGDIR/$RUN.ped.log $TEMPDIR + cp -v $LOGDIR/$RUN.ped.log "$TEMPDIR" LLF="${TEMPDIR}/$RUN.ped.log" - $EVNDISPSYS/bin/logFile evndisppedLog "$TEMPDIR/$RUN.root" "$LLF" + "$EVNDISPSYS"/bin/logFile evndisppedLog "$TEMPDIR/$RUN.root" "$LLF" fi if [[ -e "$LOGDIR/$RUN.tzero.log" ]]; then - cp -v $LOGDIR/$RUN.tzero.log $TEMPDIR + cp -v $LOGDIR/$RUN.tzero.log "$TEMPDIR" LLF="${TEMPDIR}/$RUN.tzero.log" - $EVNDISPSYS/bin/logFile evndisptzeroLog "$TEMPDIR/$RUN.root" "$LLF" + "$EVNDISPSYS"/bin/logFile evndisptzeroLog "$TEMPDIR/$RUN.root" "$LLF" fi # move data file from tmp dir to data dir diff --git a/scripts/helper_scripts/ANALYSIS.mscw_energy_sub.sh b/scripts/helper_scripts/ANALYSIS.mscw_energy_sub.sh index 4e3356a..2e432e9 100755 --- a/scripts/helper_scripts/ANALYSIS.mscw_energy_sub.sh +++ b/scripts/helper_scripts/ANALYSIS.mscw_energy_sub.sh @@ -2,6 +2,7 @@ # analyse MC files with lookup tables # set observatory environmental variables +# shellcheck source=/dev/null if [ ! -n "$EVNDISP_APPTAINER" ]; then source "$EVNDISPSYS"/setObservatory.sh VTS fi @@ -33,8 +34,8 @@ if [[ ! -z $VERITAS_ANALYSIS_TYPE ]]; then ANATYPE="${VERITAS_ANALYSIS_TYPE:0:2}" fi -INDIR=`dirname $INFILE` -BFILE=`basename $INFILE .root` +INDIR=$(dirname $INFILE) +BFILE=$(basename $INFILE .root) INFILEPATH="$INFILE" # temporary directory @@ -66,10 +67,10 @@ if [ -n "$EVNDISP_APPTAINER" ]; then fi echo "READING RUNINFO from $INFILEPATH" -RUNINFO=$($EVNDISPSYS/bin/printRunParameter $INFILEPATH updated-runinfo) -EPOCH=`echo $RUNINFO | awk '{print $(1)}'` -ATMO=${FORCEDATMO:-`echo $RUNINFO | awk '{print $(3)}'`} -HVSETTINGS=`echo $RUNINFO | awk '{print $(4)}'` +RUNINFO=$("$EVNDISPSYS"/bin/printRunParameter "$INFILEPATH" updated-runinfo) +EPOCH=$(echo "$RUNINFO" | awk '{print $(1)}') +ATMO=${FORCEDATMO:-$(echo "$RUNINFO" | awk '{print $(3)}')} +HVSETTINGS=$(echo "$RUNINFO" | awk '{print $(4)}') if [[ $ATMO == *error* ]]; then echo "error finding atmosphere; skipping run $BFILE" exit @@ -97,7 +98,7 @@ fi TABFILE=table-${IRFVERSION}-auxv01-${SIMTYPE_RUN}-ATM${ATMO}-${EPOCH}-${ANATYPE}.root echo "TABLEFILE: $TABFILE" # Check that table file exists -if [[ "$TABFILE" == $(basename $TABFILE) ]]; then +if [[ "$TABFILE" == $(basename "$TABFILE") ]]; then TABFILE="$VERITAS_EVNDISP_AUX_DIR/Tables/$TABFILE" fi echo "TABLEFILE $TABFILE" @@ -106,7 +107,7 @@ if [ ! -f "$TABFILE" ]; then exit 1 fi if [ -n "$EVNDISP_APPTAINER" ]; then - TABFILE="/opt/VERITAS_EVNDISP_AUX_DIR/Tables/$(basename $TABFILE)" + TABFILE="/opt/VERITAS_EVNDISP_AUX_DIR/Tables/$(basename "$TABFILE")" fi inspect_executables() @@ -114,7 +115,7 @@ inspect_executables() if [ -n "$EVNDISP_APPTAINER" ]; then apptainer inspect "$EVNDISP_APPTAINER" else - ls -l ${EVNDISPSYS}/bin/mscw_energy + ls -l "${EVNDISPSYS}"/bin/mscw_energy fi } @@ -153,9 +154,9 @@ get_disp_dir() } if [[ $DISPBDT == "1" ]]; then - ZA=$($EVNDISPSYS/bin/printRunParameter $INFILEPATH -zenith | awk '{print $4}') - DISPDIR=$(get_disp_dir ${ZA}) - echo "DISPDIR (Zenith is $ZA deg): " $DISPDIR + ZA=$("$EVNDISPSYS"/bin/printRunParameter "$INFILEPATH" -zenith | awk '{print $4}') + DISPDIR=$(get_disp_dir "${ZA}") + echo "DISPDIR (Zenith is $ZA deg): " "$DISPDIR" if [[ ! -d "$DISPDIR" ]]; then echo "Error: DispBDT directory $DISPDIR not found, exiting..." exit 1 @@ -166,73 +167,91 @@ fi # run analysis MSCWLOGFILE="$ODIR/$BFILE.mscw.log" -rm -f ${MSCWLOGFILE} +rm -f "${MSCWLOGFILE}" MSCWDATAFILE="$ODIR/$BFILE.mscw.root" echo "MSCWDATAFILE $MSCWDATAFILE" # mscw_energy command line options -MOPT="" +MOPT=() # dispBDT reconstruction if [ $DISPBDT -eq 1 ]; then - MOPT="$MOPT -redo_stereo_reconstruction" - MOPT="$MOPT -tmva_disperror_weight 50" - MOPT="$MOPT -minangle_stereo_reconstruction=10." + MOPT+=( + -redo_stereo_reconstruction + -tmva_disperror_weight + 50 + -minangle_stereo_reconstruction=10. + ) if [[ $IRFVERSION == v490* ]]; then - MOPT="$MOPT -maxloss=0.20" + MOPT+=("-maxloss=0.20") else - MOPT="$MOPT -maxdist=1.75 -minntubes=5 -minwidth=0.02 -minsize=100" - MOPT="$MOPT -maxloss=0.40" - MOPT="$MOPT -use_evndisp_selected_images=0" + MOPT+=( + -maxdist=1.75 + -minntubes=5 + -minwidth=0.02 + -minsize=100 + -maxloss=0.40 + -use_evndisp_selected_images=0 + ) fi - # MOPT="$MOPT -minfui=0.2" - # MOPT="$MOPT -minfitstat=3" + # MOPT+=("-minfui=0.2") + # MOPT+=("-minfitstat=3") # unzip XML files into DDIR - cp -v -f ${DISPDIR}/*.xml.gz ${DDIR}/ - gunzip -v ${DDIR}/*xml.gz - MOPT="$MOPT -tmva_filename_stereo_reconstruction ${DDIR}/BDTDisp_BDT_" - MOPT="$MOPT -tmva_filename_disperror_reconstruction ${DDIR}/BDTDispError_BDT_" - MOPT="$MOPT -tmva_filename_dispsign_reconstruction ${DDIR}/BDTDispSign_BDT_" + cp -v -f "${DISPDIR}"/*.xml.gz "${DDIR}"/ + gunzip -v "${DDIR}"/*xml.gz + MOPT+=( + -tmva_filename_stereo_reconstruction + "${DDIR}/BDTDisp_BDT_" + -tmva_filename_disperror_reconstruction + "${DDIR}/BDTDispError_BDT_" + -tmva_filename_dispsign_reconstruction + "${DDIR}/BDTDispSign_BDT_" + ) if [[ $IRFVERSION != v490* ]]; then - MOPT="$MOPT -tmva_filename_energy_reconstruction ${DDIR}/BDTDispEnergy_BDT_" + MOPT+=( + -tmva_filename_energy_reconstruction + "${DDIR}/BDTDispEnergy_BDT_" + ) fi - echo "DISP BDT options: $MOPT" + echo "DISP BDT options: ${MOPT[*]}" fi -$EVNDISPSYS/bin/mscw_energy \ - ${MOPT} \ +"$EVNDISPSYS"/bin/mscw_energy \ + "${MOPT[@]}" \ -updateEpoch=1 \ - -tablefile $TABFILE \ + -tablefile "$TABFILE" \ -arrayrecid=$RECID \ - -inputfile $DDIR/$BFILE.root \ - -writeReconstructedEventsOnly=1 &> ${MSCWLOGFILE} + -inputfile "$DDIR"/"$BFILE".root \ + -writeReconstructedEventsOnly=1 &> "${MSCWLOGFILE}" -echo "$(inspect_executables)" >> ${MSCWLOGFILE} +inspect_executables >> "${MSCWLOGFILE}" # write DISP directory into log file (as tmp directories are used) if [[ $DISPBDT != "NOTSET" ]]; then - echo "" >> ${MSCWLOGFILE} - echo "dispBDT XML files read from ${DISPDIR}" >> ${MSCWLOGFILE} + echo "" >> "${MSCWLOGFILE}" + echo "dispBDT XML files read from ${DISPDIR}" >> "${MSCWLOGFILE}" fi -echo "EVNDISP file: ${INFILE}" >> ${MSCWLOGFILE} -echo "VERITAS_EVNDISP_AUX: ${VERITAS_EVNDISP_AUX_DIR}" >> ${MSCWLOGFILE} -echo "VERITAS_ANALYSIS_TYPE ${VERITAS_ANALYSIS_TYPE}" >> ${MSCWLOGFILE} +{ + echo "EVNDISP file: ${INFILE}" + echo "VERITAS_EVNDISP_AUX: ${VERITAS_EVNDISP_AUX_DIR}" + echo "VERITAS_ANALYSIS_TYPE ${VERITAS_ANALYSIS_TYPE}" +} >> "${MSCWLOGFILE}" # move logfiles into output file if [[ -e ${MSCWLOGFILE} ]]; then - cp -v ${MSCWLOGFILE} $DDIR/ - LLF="${DDIR}/$(basename ${MSCWLOGFILE})" - $EVNDISPSYS/bin/logFile mscwTableLog "$DDIR/$BFILE.mscw.root" "$LLF" + cp -v "${MSCWLOGFILE}" "$DDIR"/ + LLF="${DDIR}/$(basename "${MSCWLOGFILE}")" + "$EVNDISPSYS"/bin/logFile mscwTableLog "$DDIR/$BFILE.mscw.root" "$LLF" fi # move output file from scratch and clean up -cp -f -v $DDIR/$BFILE.mscw.root $MSCWDATAFILE -rm -f $DDIR/$BFILE.mscw.root -rm -f $DDIR/$BFILE.root +cp -f -v "$DDIR"/"$BFILE".mscw.root "$MSCWDATAFILE" +rm -f "$DDIR"/"$BFILE".mscw.root +rm -f "$DDIR"/"$BFILE".root # write info to log echo "RUN$BFILE MSCWLOG ${MSCWLOGFILE}" echo "RUN$BFILE MSCWDATA $MSCWDATAFILE" # remove files in DDIR -rm -rf $DDIR +rm -rf "$DDIR" diff --git a/scripts/helper_scripts/ANALYSIS.v2dl3_sub.sh b/scripts/helper_scripts/ANALYSIS.v2dl3_sub.sh index c4b9136..4a44aa1 100755 --- a/scripts/helper_scripts/ANALYSIS.v2dl3_sub.sh +++ b/scripts/helper_scripts/ANALYSIS.v2dl3_sub.sh @@ -22,8 +22,8 @@ echo "Scratch dir: $TEMPDIR" mkdir -p "$TEMPDIR" # run list -FILES=`cat "$RUNLIST"` -NRUNS=`cat "$RUNLIST" | wc -l ` +FILES=$(cat "$RUNLIST") +NRUNS=$(cat "$RUNLIST" | wc -l ) echo "total number of runs to analyze: $NRUNS" echo @@ -52,19 +52,24 @@ check_conda_installation() } check_conda_installation +# shellcheck source=/dev/null source activate base conda activate v2dl3Eventdisplay-${V2DL3VERSION} # Install only if not already present (avoid slow per-job reinstall) pip show v2dl3-eventdisplay &>/dev/null 2>&1 || pip install -e "${V2DL3SYS%/}-v${V2DL3VERSION}" -V2DL3OPT="--fuzzy_boundary zenith 0.05 --fuzzy_boundary pedvar 0.5 --save_multiplicity" +V2DL3OPT=( + --fuzzy_boundary zenith 0.05 + --fuzzy_boundary pedvar 0.5 + --save_multiplicity +) # selection for full-gamma files EVENTFILTER="${TEMPDIR}/tmp_select.yml" -echo "IsGamma: 1" > $EVENTFILTER +echo "IsGamma: 1" > "$EVENTFILTER" echo "Event filter file: ${EVENTFILTER}" -ls -l ${EVENTFILTER} -cat ${EVENTFILTER} +ls -l "${EVENTFILTER}" +cat "${EVENTFILTER}" # directory schema for preprocessed files getNumberedDirectory() @@ -76,7 +81,7 @@ getNumberedDirectory() else ODIR="${IDIR}/${TRUN:0:2}/" fi - echo ${ODIR} + echo "${ODIR}" } # interpolator; might depend on IRF type @@ -99,20 +104,20 @@ getInterpolator() for RUN in $FILES do - echo $RUN - ANASUMFILE="$(getNumberedDirectory $RUN $VERITAS_PREPROCESSED_DATA_DIR/${VERITAS_ANALYSIS_TYPE:0:2}/anasum_${CUT})/${RUN}.anasum.root" + echo "$RUN" + ANASUMFILE="$(getNumberedDirectory "$RUN" "$VERITAS_PREPROCESSED_DATA_DIR"/"${VERITAS_ANALYSIS_TYPE:0:2}"/anasum_${CUT})/${RUN}.anasum.root" if [[ ! -e ${ANASUMFILE} ]]; then echo "File ${ANASUMFILE} not found" echo "Skipping run $RUN" continue fi echo " ANASUM file: ${ANASUMFILE}" - result=$(v2dl3-eventdisplay-query-runparameters ${ANASUMFILE} ${RUN}) - EPOCH=$(echo $result | awk '{print $2}') - EFFAREA=$(echo $result | awk '{print $5}') + result=$(v2dl3-eventdisplay-query-runparameters "${ANASUMFILE}" "${RUN}") + EPOCH=$(echo "$result" | awk '{print $2}') + EFFAREA=$(echo "$result" | awk '{print $5}') echo " Effective area file: $EFFAREA Epoch: $EPOCH" - DBFITSFILE=$(getNumberedDirectory $RUN $VERITAS_DATA_DIR/shared/DBFITS)/$RUN.db.fits.gz - INTERPOLATOR=$(getInterpolator $EFFAREA) + DBFITSFILE=$(getNumberedDirectory "$RUN" "$VERITAS_DATA_DIR"/shared/DBFITS)/$RUN.db.fits.gz + INTERPOLATOR=$(getInterpolator "$EFFAREA") if [[ ! -e ${DBFITSFILE} ]]; then echo "DB File ${DBFITSFILE} not found" echo "Skipping run $RUN" @@ -122,33 +127,33 @@ do for m in "point-like" "full-enclosure" do - echo " Converting (${m}, ${V2DL3OPT})" + echo " Converting (${m}, ${V2DL3OPT[*]})" for p in "" "-all-events" do if [[ "$p" != "-all-events" ]]; then - V2DL3SELECT="--evt_filter ${EVENTFILTER}" - ls -1 ${EVENTFILTER} + V2DL3SELECT=(--evt_filter "${EVENTFILTER}") + ls -1 "${EVENTFILTER}" else - V2DL3SELECT="" + V2DL3SELECT=() fi - echo "EVENTFILTER $V2DL3SELECT" + echo "EVENTFILTER ${V2DL3SELECT[*]}" mkdir -p ${ODIR}/${m}${p} - rm -f ${ODIR}/${m}${p}/${RUN}.log + rm -f ${ODIR}/${m}${p}/"${RUN}".log v2dl3-eventdisplay \ --${m} \ - ${V2DL3OPT} ${V2DL3SELECT} \ - --file_pair ${ANASUMFILE} $VERITAS_EVNDISP_AUX_DIR/EffectiveAreas/${EFFAREA} \ - --logfile ${ODIR}/${m}${p}/${RUN}.log \ - --instrument_epoch ${EPOCH} \ - --interpolator_name ${INTERPOLATOR} \ - --db_fits_file ${DBFITSFILE} \ - ${ODIR}/${m}${p}/${RUN}.fits.gz - - python --version >> ${ODIR}/${m}${p}/${RUN}.log - conda list -n v2dl3Eventdisplay-${V2DL3VERSION} >> ${ODIR}/${m}${p}/${RUN}.log + "${V2DL3OPT[@]}" "${V2DL3SELECT[@]}" \ + --file_pair "${ANASUMFILE}" "$VERITAS_EVNDISP_AUX_DIR"/EffectiveAreas/"${EFFAREA}" \ + --logfile ${ODIR}/${m}${p}/"${RUN}".log \ + --instrument_epoch "${EPOCH}" \ + --interpolator_name "${INTERPOLATOR}" \ + --db_fits_file "${DBFITSFILE}" \ + ${ODIR}/${m}${p}/"${RUN}".fits.gz + + python --version >> ${ODIR}/${m}${p}/"${RUN}".log + conda list -n v2dl3Eventdisplay-${V2DL3VERSION} >> ${ODIR}/${m}${p}/"${RUN}".log PDIR=$(pwd) cd "${PDIR}" || exit done diff --git a/scripts/helper_scripts/IRF.compress_evndisp_MC_sub.sh b/scripts/helper_scripts/IRF.compress_evndisp_MC_sub.sh index c2003a9..f82b81f 100755 --- a/scripts/helper_scripts/IRF.compress_evndisp_MC_sub.sh +++ b/scripts/helper_scripts/IRF.compress_evndisp_MC_sub.sh @@ -1,6 +1,7 @@ #!/bin/bash # script put log files into evndisp file and compress output +# shellcheck source=/dev/null # set observatory environmental variables source "$EVNDISPSYS"/setObservatory.sh VTS @@ -15,28 +16,28 @@ else DDIR="/tmp/testDir" fi DDIR=${DDIR}/$(uuidgen) -mkdir -p $DDIR +mkdir -p "$DDIR" mkdir -p $ODIR compare_log_file() { - $EVNDISPSYS/bin/logFile $1 $DDIR/$ONAME.root > ${DDIR}/${1}.log + "$EVNDISPSYS"/bin/logFile "$1" "$DDIR"/$ONAME.root > "${DDIR}"/"${1}".log if cmp -s "${2}" "${DDIR}/${1}.log"; then echo "FILES ${1} ${2} are the same, removing" else - touch $ODIR/$ONAME.${1}.errorlog - echo "Error, ${1} ${2} differ" >> $ODIR/$ONAME.${1}.errorlog + touch $ODIR/$ONAME."${1}".errorlog + echo "Error, ${1} ${2} differ" >> $ODIR/$ONAME."${1}".errorlog fi } add_log_file() { # first check if logFile is already included in evndisp file - LCON=$($EVNDISPSYS/bin/logFile $1 $DDIR/$ONAME.root | grep "Error: log file object" | wc -l) + LCON=$("$EVNDISPSYS"/bin/logFile "$1" "$DDIR"/$ONAME.root | grep -c "Error: log file object") if [[ ${LCON} == 1 ]]; then echo "writing log file ${2}" if [[ -f ${2} ]]; then - $EVNDISPSYS/bin/logFile $1 $DDIR/$ONAME.root ${2} + "$EVNDISPSYS"/bin/logFile "$1" "$DDIR"/$ONAME.root "${2}" fi else echo "log file ${2} already in $DDIR/$ONAME.root" @@ -46,8 +47,8 @@ add_log_file() compress_file() { if command -v zstd &>/dev/null; then - zstd ${1} - zstd --test ${1}.zst + zstd "${1}" + zstd --test "${1}".zst else echo "Error: zstd compressing executable not found" exit @@ -57,7 +58,7 @@ compress_file() echo "EVNDISP input root file $IDIR/$ONAME.root" echo "EVNDISP output root file $ODIR/$ONAME.root.zst" -cp -v $IDIR/$ONAME.root ${DDIR}/ +cp -v $IDIR/$ONAME.root "${DDIR}"/ ### add log files to evndisp file add_log_file evndispLog $IDIR/$ONAME.log @@ -69,5 +70,5 @@ compare_log_file evndispLog $IDIR/$ONAME.log compare_log_file evndisppedLog $IDIR/$ONAME.ped.log compare_log_file evndisptzeroLog $IDIR/$ONAME.tzero.log -compress_file $DDIR/$ONAME.root -mv -f -v $DDIR/$ONAME.root.zst ${ODIR}/ +compress_file "$DDIR"/$ONAME.root +mv -f -v "$DDIR"/$ONAME.root.zst ${ODIR}/ diff --git a/scripts/helper_scripts/IRF.dispXGB_sub.sh b/scripts/helper_scripts/IRF.dispXGB_sub.sh index bce4a3f..36b6671 100755 --- a/scripts/helper_scripts/IRF.dispXGB_sub.sh +++ b/scripts/helper_scripts/IRF.dispXGB_sub.sh @@ -57,11 +57,11 @@ if [[ ! -e ${MSCW_FILE} ]]; then echo "File ${MSCW_FILE} not found. Exiting." exit fi -RUNINFO=$($EVNDISPSYS/bin/printRunParameter ${MSCW_FILE} -runinfo) +RUNINFO=$("$EVNDISPSYS"/bin/printRunParameter ${MSCW_FILE} -runinfo) echo "RUNINFO $RUNINFO" -ZA=$(echo $RUNINFO | awk '{print $8}') -EPOCH=$(echo $RUNINFO | awk '{print $1}') -ATM=$(echo $RUNINFO | awk '{print $3}') +ZA=$(echo "$RUNINFO" | awk '{print $8}') +EPOCH=$(echo "$RUNINFO" | awk '{print $1}') +ATM=$(echo "$RUNINFO" | awk '{print $3}') echo "MSCW file: ${MSCW_FILE} at zenith ${ZA} deg, epoch ${EPOCH}, ATM ${ATM}" DISPDIR="$VERITAS_EVNDISP_AUX_DIR/DispXGB/${ANATYPE}/${EPOCH}_ATM${ATM}" if [[ ! -d "${DISPDIR}" ]]; then diff --git a/scripts/helper_scripts/IRF.effective_area_combine_sub.sh b/scripts/helper_scripts/IRF.effective_area_combine_sub.sh index 281331c..ab5d1dd 100755 --- a/scripts/helper_scripts/IRF.effective_area_combine_sub.sh +++ b/scripts/helper_scripts/IRF.effective_area_combine_sub.sh @@ -1,9 +1,9 @@ #!/bin/bash -# shellcheck disable=SC2034 # combine effective areas # set observatory environmental variables if [ ! -n "$EVNDISP_APPTAINER" ]; then +# shellcheck source=/dev/null source "$EVNDISPSYS"/setObservatory.sh VTS fi @@ -26,7 +26,6 @@ if [ -n "$EVNDISP_APPTAINER" ]; then EVNDISPSYS="${EVNDISPSYS/--cleanenv/--cleanenv $APPTAINER_ENV $APPTAINER_MOUNT}" echo "APPTAINER SYS: $EVNDISPSYS" # path used by EVNDISPSYS needs to be set - CALDIR="/opt/ODIR" DDIR="/opt/DDIR/" OPTODIR="/opt/ODIR/" fi @@ -36,7 +35,7 @@ inspect_executables() if [ -n "$EVNDISP_APPTAINER" ]; then apptainer inspect "$EVNDISP_APPTAINER" else - ls -l ${EVNDISPSYS}/bin/evndisp + ls -l "${EVNDISPSYS}"/bin/evndisp fi } @@ -46,14 +45,14 @@ chmod -R g+w $ODIR rm -f "$ODIR"/"$OFILE".list touch "$ODIR"/"$OFILE".list for F in $EAFILES; do - AP_FILE=$(basename $F) + AP_FILE=$(basename "$F") echo "$DDIR/$AP_FILE" >> "$ODIR"/"$OFILE".list done echo "Found $(cat $ODIR/$OFILE.list | wc -l) input files to merge" echo "File list: $ODIR/$OFILE.list" -$EVNDISPSYS/bin/combineEffectiveAreas "$OPTODIR/$OFILE.list" ${OPTODIR}/$OFILE DL3reduced &> ${ODIR}/$OFILE.log +"$EVNDISPSYS"/bin/combineEffectiveAreas "$OPTODIR/$OFILE.list" ${OPTODIR}/$OFILE DL3reduced &> ${ODIR}/$OFILE.log # log files -echo "$(inspect_executables)" >> "$ODIR/$OFILE.log" -$EVNDISPSYS/bin/logFile effAreaCombineLog "${OPTODIR}/$OFILE.root" "${OPTODIR}/$OFILE.log" +inspect_executables >> "$ODIR/$OFILE.log" +"$EVNDISPSYS"/bin/logFile effAreaCombineLog "${OPTODIR}/$OFILE.root" "${OPTODIR}/$OFILE.log" diff --git a/scripts/helper_scripts/IRF.effective_area_parallel_sub.sh b/scripts/helper_scripts/IRF.effective_area_parallel_sub.sh index 119f231..3191f78 100755 --- a/scripts/helper_scripts/IRF.effective_area_parallel_sub.sh +++ b/scripts/helper_scripts/IRF.effective_area_parallel_sub.sh @@ -1,11 +1,11 @@ #!/bin/bash -# shellcheck disable=SC2034 # calculate effective areas # # v490: possible issue with "RERUN_STEREO_RECONSTRUCTION_3TEL" option # set observatory environmental variables if [ ! -n "$EVNDISP_APPTAINER" ]; then +# shellcheck source=/dev/null source "$EVNDISPSYS"/setObservatory.sh VTS fi @@ -42,7 +42,6 @@ if [ -n "$EVNDISP_APPTAINER" ]; then EVNDISPSYS="${EVNDISPSYS/--cleanenv/--cleanenv $APPTAINER_ENV $APPTAINER_MOUNT}" echo "APPTAINER SYS: $EVNDISPSYS" # path used by EVNDISPSYS needs to be set - CALDIR="/opt/ODIR" fi inspect_executables() @@ -50,7 +49,7 @@ inspect_executables() if [ -n "$EVNDISP_APPTAINER" ]; then apptainer inspect "$EVNDISP_APPTAINER" else - ls -l ${EVNDISPSYS}/bin/evndisp + ls -l "${EVNDISPSYS}"/bin/evndisp fi } @@ -66,14 +65,14 @@ do done # cp MC file to TMPDIR cp -f -v "$MCFILE" "$DDIR"/ -MCFILE=`basename $MCFILE` +MCFILE=$(basename $MCFILE) MCFILE=${DDIR}/${MCFILE} # Check that cuts file exists CUTSFILE=${CUTSFILE%%.dat} -CUTS_NAME=`basename $CUTSFILE` +CUTS_NAME=$(basename "$CUTSFILE") CUTS_NAME=${CUTS_NAME##ANASUM.GammaHadron-} -if [[ "$CUTSFILE" == `basename $CUTSFILE` ]]; then +if [[ "$CUTSFILE" == $(basename "$CUTSFILE") ]]; then CUTSFILE="$VERITAS_EVNDISP_AUX_DIR"/GammaHadronCutFiles/$CUTSFILE.dat else CUTSFILE="$CUTSFILE.dat" @@ -89,7 +88,7 @@ if [[ $DISPBDT == "1" ]]; then OSUBDIR="${OSUBDIR}_DISP" fi echo -e "Output files will be written to:\n $OSUBDIR" -mkdir -p $OSUBDIR +mkdir -p "$OSUBDIR" ENERGYRECONSTRUCTIONMETHOD="0" if [[ $IRFVERSION == *"v490"* ]]; then @@ -117,7 +116,7 @@ PARAMFILE=" * FILLMONTECARLOHISTOS 0 * ENERGYSPECTRUMINDEX 40 1.5 0.1 * RERUN_STEREO_RECONSTRUCTION_3TEL $REDO3TEL -* CUTFILE $DDIR/$(basename $CUTSFILE) +* CUTFILE $DDIR/$(basename "$CUTSFILE") IGNOREFRACTIONOFEVENTS 0.5 * SIMULATIONFILE_DATA $MCFILE * XGBSTEREOFILESUFFIX $XGBSTEREOFILESUFFIX @@ -126,17 +125,17 @@ PARAMFILE=" # create makeEffectiveArea parameter file EAPARAMS="$EFFAREAFILE-${CUTS_NAME}" rm -f "$DDIR/$EAPARAMS.dat" -eval "echo \"$PARAMFILE\"" > $DDIR/$EAPARAMS.dat +eval "echo \"$PARAMFILE\"" > "$DDIR"/"$EAPARAMS".dat # calculate effective areas -rm -f $OSUBDIR/$OFILE.root -$EVNDISPSYS/bin/makeEffectiveArea $DDIR/$EAPARAMS.dat $DDIR/$EAPARAMS.root &> $OSUBDIR/$EAPARAMS.log +rm -f "$OSUBDIR"/"$OFILE".root +"$EVNDISPSYS"/bin/makeEffectiveArea "$DDIR"/"$EAPARAMS".dat "$DDIR"/"$EAPARAMS".root &> "$OSUBDIR"/"$EAPARAMS".log echo "Filling log file into root file" -echo "$(inspect_executables)" >> "$OSUBDIR/$EAPARAMS.log" +inspect_executables >> "$OSUBDIR/$EAPARAMS.log" cp -v "$OSUBDIR/$EAPARAMS.log" "$DDIR/$EAPARAMS.log" -$EVNDISPSYS/bin/logFile effAreaLog $DDIR/$EAPARAMS.root $DDIR/$EAPARAMS.log -rm -f $OSUBDIR/$EAPARAMS.log -cp -f $DDIR/$EAPARAMS.root $OSUBDIR/$EAPARAMS.root -chmod -R g+w $OSUBDIR -chmod g+w $OSUBDIR/$EAPARAMS.root +"$EVNDISPSYS"/bin/logFile effAreaLog "$DDIR"/"$EAPARAMS".root "$DDIR"/"$EAPARAMS".log +rm -f "$OSUBDIR"/"$EAPARAMS".log +cp -f "$DDIR"/"$EAPARAMS".root "$OSUBDIR"/"$EAPARAMS".root +chmod -R g+w "$OSUBDIR" +chmod g+w "$OSUBDIR"/"$EAPARAMS".root diff --git a/scripts/helper_scripts/IRF.evndisp_MC_sub.sh b/scripts/helper_scripts/IRF.evndisp_MC_sub.sh index 5c12d48..f7e41ef 100755 --- a/scripts/helper_scripts/IRF.evndisp_MC_sub.sh +++ b/scripts/helper_scripts/IRF.evndisp_MC_sub.sh @@ -1,9 +1,10 @@ #!/bin/bash -# shellcheck disable=SC2034,SC2154 +# shellcheck disable=SC2154 # script to run evndisp for simulations on one of the cluster nodes (VBF) # set observatory environmental variables if [ ! -n "$EVNDISP_APPTAINER" ]; then +# shellcheck source=/dev/null source "$EVNDISPSYS"/setObservatory.sh VTS fi @@ -11,14 +12,17 @@ fi RUNNUM="${1}" SIMDIR=DATADIR ZA=ZENITHANGLE +# shellcheck disable=SC2034 # template placeholder, replaced by sed before job submission WOB=DECIMALWOBBLE WOG=INTEGERWOBBLE NOISE=NOISELEVEL EPOCH=ARRAYEPOCH +# shellcheck disable=SC2034 # template placeholder, replaced by sed before job submission ATM=ATMOSPHERE ACUTS="RECONSTRUCTIONRUNPARAMETERFILE" SIMTYPE=SIMULATIONTYPE ODIR=OUTPUTDIR +# shellcheck disable=SC2034 # template placeholder, replaced by sed before job submission TELTOANA="1234" VBFNAME="$2" NOISEFILE=NOISEFFILE @@ -96,8 +100,8 @@ if [ -e "$V4N" ]; then for file in "$V4N"/*.root.zst; do tmpfile="$TMPDIR/$(basename "${file%.zst}")" zstd -d -c "$file" > "$tmpfile" - if $EVNDISPSYS/bin/logFile evndispLog "$tmpfile" | grep -q "$VBF_BASENAME"; then - echo "File $VBFNAME ($VBF_BASENAME) already processed ($(basename $tmpfile))" + if "$EVNDISPSYS"/bin/logFile evndispLog "$tmpfile" | grep -q "$VBF_BASENAME"; then + echo "File $VBFNAME ($VBF_BASENAME) already processed ($(basename "$tmpfile"))" exit fi done @@ -113,7 +117,7 @@ inspect_executables() if [ -n "$EVNDISP_APPTAINER" ]; then apptainer inspect "$EVNDISP_APPTAINER" else - ls -l ${EVNDISPSYS}/bin/evndisp + ls -l "${EVNDISPSYS}"/bin/evndisp fi } @@ -130,7 +134,11 @@ else fi # Amplitude correction factor options -AMPCORR="-traceamplitudecorrection ThroughputCorrection.runparameter -pedestalDefaultPedestal=$PEDLEV" +AMPCORR=( + -traceamplitudecorrection + ThroughputCorrection.runparameter + "-pedestalDefaultPedestal=$PEDLEV" +) # CARE simulations: add Gaussian noise of 3.6 mV/ (7.84 mV/dc) / 2 # Current (2018) CARE simulations: # no electronic noise included - therefore add @@ -138,7 +146,7 @@ AMPCORR="-traceamplitudecorrection ThroughputCorrection.runparameter -pedestalDe # Derived for GrIsu many years ago - source not entirely clear # add Gaussian noise of 3.6 mV/ (7.84 mV/dc) / 2 if [[ ${SIMTYPE:0:4} == "CARE" ]]; then - AMPCORR="$AMPCORR -injectGaussianNoise=0.229592" + AMPCORR+=("-injectGaussianNoise=0.229592") fi # detector configuration @@ -147,7 +155,7 @@ fi [[ ${EPOCH:0:2} == "V6" ]] && CFG="EVN_V6_Upgrade_20121127_v420.txt" CALDIR=${DDIR} -mkdir -p ${CALDIR}/Calibration +mkdir -p "${CALDIR}"/Calibration echo "Calibration directory: ${CALDIR}" ##################3 @@ -156,17 +164,17 @@ if [[ -f "${SIMDIR}/$VBFNAME" ]]; then ZTYPE=${VBFNAME##*.} if [[ $ZTYPE == "gz" ]]; then echo " (vbf is gzipped)" - VBF_FILE=$(basename $SIMDIR/${VBFNAME} .gz) - gunzip -f -q -c $SIMDIR/${VBFNAME} > ${DDIR}/${VBF_FILE} + VBF_FILE=$(basename $SIMDIR/"${VBFNAME}" .gz) + gunzip -f -q -c $SIMDIR/"${VBFNAME}" > "${DDIR}"/"${VBF_FILE}" elif [[ $ZTYPE == "bz2" ]]; then echo " (vbf is bzipped)" - VBF_FILE=$(basename $SIMDIR/${VBFNAME} .bz2) - bunzip2 -f -q -c $SIMDIR/${VBFNAME} > ${DDIR}/${VBF_FILE} + VBF_FILE=$(basename $SIMDIR/"${VBFNAME}" .bz2) + bunzip2 -f -q -c $SIMDIR/"${VBFNAME}" > "${DDIR}"/"${VBF_FILE}" elif [[ $ZTYPE == "zst" ]]; then echo " (vbf is zst-compressed)" if hash zstd 2>/dev/null; then - VBF_FILE=$(basename $SIMDIR/${VBFNAME} .zst) - zstd -d -f ${SIMDIR}/${VBFNAME} -o ${DDIR}/${VBF_FILE} + VBF_FILE=$(basename $SIMDIR/"${VBFNAME}" .zst) + zstd -d -f ${SIMDIR}/"${VBFNAME}" -o "${DDIR}"/"${VBF_FILE}" else echo "no zstd installed; exiting" exit @@ -176,7 +184,7 @@ if [[ -f "${SIMDIR}/$VBFNAME" ]]; then exit fi fi -ls -lh $DDIR/ +ls -lh "$DDIR"/ # check that the uncompressed vbf file exists if [[ ! -f "$DDIR/$VBF_FILE" ]]; then @@ -188,23 +196,41 @@ VBF_FILE="$DDIR/$VBF_FILE" ####################################### # option for all steps of the analysis -MCOPT=" -runnumber=$RUNNUM -sourcetype=2 -epoch $EPOCH -camera=$CFG" -MCOPT="$MCOPT -reconstructionparameter $ACUTS -sourcefile $VBF_FILE" -MCOPT="$MCOPT -deadchannelfile $DEAD -donotusedbinfo -calibrationdirectory ${CALDIR}" -MCOPT="$MCOPT $AMPCORR" -MCOPT="$MCOPT ${ADD_OPT}" +read -r -a ADD_OPT_ARR <<< "$ADD_OPT" +MCOPT=( + "-runnumber=$RUNNUM" + -sourcetype=2 + -epoch + "$EPOCH" + "-camera=$CFG" +) +MCOPT+=( + -reconstructionparameter + "$ACUTS" + -sourcefile + "$VBF_FILE" +) +MCOPT+=( + -deadchannelfile + "$DEAD" + -donotusedbinfo + -calibrationdirectory + "${CALDIR}" +) +MCOPT+=("${AMPCORR[@]}") +MCOPT+=("${ADD_OPT_ARR[@]}") # Low gain calibration LOWGAINCALIBRATIONFILE=NOFILE if [[ ${SIMTYPE:0:4} = "CARE" ]]; then if [[ $EDVERSION = "v4"* ]]; then if [[ ! -f ${CALDIR}/Calibration/calibrationlist.LowGainForCare.dat ]]; then - cp -f $VERITAS_EVNDISP_AUX_DIR/Calibration/calibrationlist.LowGainForCare.dat ${CALDIR}/Calibration/calibrationlist.LowGainForCare.dat + cp -f "$VERITAS_EVNDISP_AUX_DIR"/Calibration/calibrationlist.LowGainForCare.dat "${CALDIR}"/Calibration/calibrationlist.LowGainForCare.dat fi LOWGAINCALIBRATIONFILE=calibrationlist.LowGainForCare.dat else if [[ ! -f ${CALDIR}/Calibration/calibrationlist.LowGainForCare.${EPOCH:0:2}.dat ]]; then - cp -f $VERITAS_EVNDISP_AUX_DIR/Calibration/calibrationlist.LowGainForCare.${EPOCH:0:2}.dat ${CALDIR}/Calibration/calibrationlist.LowGainForCare.${EPOCH:0:2}.dat + cp -f "$VERITAS_EVNDISP_AUX_DIR"/Calibration/calibrationlist.LowGainForCare.${EPOCH:0:2}.dat "${CALDIR}"/Calibration/calibrationlist.LowGainForCare.${EPOCH:0:2}.dat fi LOWGAINCALIBRATIONFILE=calibrationlist.LowGainForCare.${EPOCH:0:2}.dat fi @@ -215,11 +241,11 @@ fi # (CARE only, GRISU used external noise file) if [[ ${SIMTYPE:0:4} == "CARE" ]]; then echo "Calculating pedestals for run $RUNNUM" - rm -f $ODIR/$RUNNUM.ped.log - PEDOPT="-runmode=1 -calibrationnevents=${PEDNEVENTS}" - $EVNDISPSYS/bin/evndisp $MCOPT $PEDOPT &> "$ODIR/$RUNNUM.ped.log" - echo "$(inspect_executables)" >> "$ODIR/$RUNNUM.ped.log" - if grep -Fq "END OF ANALYSIS, exiting" $ODIR/$RUNNUM.ped.log; + rm -f $ODIR/"$RUNNUM".ped.log + PEDOPT=("-runmode=1" "-calibrationnevents=${PEDNEVENTS}") + "$EVNDISPSYS"/bin/evndisp "${MCOPT[@]}" "${PEDOPT[@]}" &> "$ODIR/$RUNNUM.ped.log" + inspect_executables >> "$ODIR/$RUNNUM.ped.log" + if grep -Fq "END OF ANALYSIS, exiting" $ODIR/"$RUNNUM".ped.log; then echo " successful pedestal analysis" else @@ -231,17 +257,28 @@ fi ############################################### # calculate tzeros echo "Calculating average tzeros for run $RUNNUM" -TZEROPT="-runmode=7 -calibrationnevents=${TZERONEVENTS} -pedestalnoiselevel=$NOISE " -TZEROPT="$TZEROPT -lowgainpedestallevel=$LOWPEDLEV -lowgaincalibrationfile ${LOWGAINCALIBRATIONFILE}" -rm -f $ODIR/$RUNNUM.tzero.log +TZEROPT=( + "-runmode=7" + "-calibrationnevents=${TZERONEVENTS}" + "-pedestalnoiselevel=$NOISE" + "-lowgainpedestallevel=$LOWPEDLEV" + -lowgaincalibrationfile + "${LOWGAINCALIBRATIONFILE}" +) +rm -f $ODIR/"$RUNNUM".tzero.log ### eventdisplay GRISU run options if [[ ${SIMTYPE:0:5} = "GRISU" ]]; then - TZEROPT="$TZEROPT -pedestalfile $NOISEFILE -pedestalseed=$RUNNUM -pedestalDefaultPedestal=$PEDLEV" + TZEROPT+=( + -pedestalfile + "$NOISEFILE" + "-pedestalseed=$RUNNUM" + "-pedestalDefaultPedestal=$PEDLEV" + ) fi -echo "$EVNDISPSYS/bin/evndisp $MCOPT $TZEROPT" &> $ODIR/$RUNNUM.tzero.log -$EVNDISPSYS/bin/evndisp $MCOPT $TZEROPT &>> $ODIR/$RUNNUM.tzero.log -echo "$(inspect_executables)" &>> "$ODIR/$RUNNUM.tzero.log" -if grep -Fq "END OF ANALYSIS, exiting" $ODIR/$RUNNUM.tzero.log; +echo "$EVNDISPSYS/bin/evndisp ${MCOPT[*]} ${TZEROPT[*]}" &> $ODIR/"$RUNNUM".tzero.log +"$EVNDISPSYS"/bin/evndisp "${MCOPT[@]}" "${TZEROPT[@]}" &>> $ODIR/"$RUNNUM".tzero.log +inspect_executables &>> "$ODIR/$RUNNUM.tzero.log" +if grep -Fq "END OF ANALYSIS, exiting" $ODIR/"$RUNNUM".tzero.log; then echo " successful tzero analysis" else @@ -255,25 +292,37 @@ fi ##################### # general analysis options -ANAOPT=" -writenomctree -outputfile $DDIR/$ONAME.root" -ANAOPT="$ANAOPT -lowgaincalibrationfile ${LOWGAINCALIBRATIONFILE} -lowgainpedestallevel=$PEDLEV" +ANAOPT=( + -writenomctree + -outputfile + "$DDIR/$ONAME.root" + -lowgaincalibrationfile + "${LOWGAINCALIBRATIONFILE}" + "-lowgainpedestallevel=$PEDLEV" +) # ###################### ## options for GRISU (handling of low-gain values) if [[ ${SIMTYPE:0:5} == "GRISU" ]]; then - ANAOPT="$ANAOPT -simu_hilo_from_simfile -pedestalfile $NOISEFILE -pedestalseed=$RUNNUM -pedestalDefaultPedestal=$PEDLEV" + ANAOPT+=( + -simu_hilo_from_simfile + -pedestalfile + "$NOISEFILE" + "-pedestalseed=$RUNNUM" + "-pedestalDefaultPedestal=$PEDLEV" + ) fi ################################################################################# # run evndisp echo "Analysing MC file for run $RUNNUM" -echo "$EVNDISPSYS/bin/evndisp $MCOPT $ANAOPT" &> $ODIR/$ONAME.log -$EVNDISPSYS/bin/evndisp $MCOPT $ANAOPT &>> $ODIR/$ONAME.log -echo "$(inspect_executables)" >> "$ODIR/$ONAME.log" +echo "$EVNDISPSYS/bin/evndisp ${MCOPT[*]} ${ANAOPT[*]}" &> $ODIR/"$ONAME".log +"$EVNDISPSYS"/bin/evndisp "${MCOPT[@]}" "${ANAOPT[@]}" &>> $ODIR/"$ONAME".log +inspect_executables >> "$ODIR/$ONAME.log" ################################################################################# # cleanup ls -lh "$DDIR" -cp -r -f -v ${CALDIR}/Calibration ${ODIR}/ +cp -r -f -v "${CALDIR}"/Calibration ${ODIR}/ rm -f -v "$VBF_FILE" echo "EVNDISP output root file written to $ODIR/$ONAME.root" @@ -285,11 +334,11 @@ echo "EVNDISP log file written to $ODIR/$ONAME.log" add_log_file() { # first check if logFile is already included in evndisp file - LCON=$($EVNDISPSYS/bin/logFile $1 $DDIR/$ONAME.root | grep "Error: log file object" | wc -l) + LCON=$("$EVNDISPSYS"/bin/logFile "$1" "$DDIR"/"$ONAME".root | grep -c "Error: log file object") if [[ ${LCON} == 1 ]]; then echo "writing log file ${2}" if [[ -f ${2} ]]; then - $EVNDISPSYS/bin/logFile $1 $DDIR/$ONAME.root ${2} + "$EVNDISPSYS"/bin/logFile "$1" "$DDIR"/"$ONAME".root "${2}" fi else echo "log file ${2} already in $DDIR/$ONAME.root" @@ -306,36 +355,36 @@ add_log_file evndisptzeroLog "$DDIR/$ONAME.tzero.log" ### check that log files are filled correctly compare_log_file() { - $EVNDISPSYS/bin/logFile $1 $DDIR/$ONAME.root > ${DDIR}/${1}.log + "$EVNDISPSYS"/bin/logFile "$1" "$DDIR"/"$ONAME".root > "${DDIR}"/"${1}".log if cmp -s "${2}" "${DDIR}/${1}.log"; then echo "FILES ${1} ${2} are the same, removing" rm -f "${2}" else - touch $ODIR/$ONAME.${1}.errorlog - echo "Error, ${1} ${2} differ" >> $ODIR/$ONAME.${1}.errorlog + touch $ODIR/"$ONAME"."${1}".errorlog + echo "Error, ${1} ${2} differ" >> $ODIR/"$ONAME"."${1}".errorlog fi } -compare_log_file evndispLog $ODIR/$ONAME.log -if [ -e $ODIR/$ONAME.ped.log ]; then - compare_log_file evndisppedLog $ODIR/$ONAME.ped.log +compare_log_file evndispLog $ODIR/"$ONAME".log +if [ -e $ODIR/"$ONAME".ped.log ]; then + compare_log_file evndisppedLog $ODIR/"$ONAME".ped.log fi -compare_log_file evndisptzeroLog $ODIR/$ONAME.tzero.log +compare_log_file evndisptzeroLog $ODIR/"$ONAME".tzero.log ### compress evndisp root file compress_file() { if command -v zstd &>/dev/null; then - zstd ${1} - zstd --test ${1}.zst + zstd "${1}" + zstd --test "${1}".zst else echo "Error: zstd compressing executable not found" exit fi } -compress_file $DDIR/$ONAME.root -mv -f -v $DDIR/$ONAME.root.zst ${ODIR}/ +compress_file "$DDIR"/"$ONAME".root +mv -f -v "$DDIR"/"$ONAME".root.zst ${ODIR}/ ### set group permissions chmod g+w "$ODIR/$ONAME.root.zst" diff --git a/scripts/helper_scripts/IRF.lookup_table_combine_sub.sh b/scripts/helper_scripts/IRF.lookup_table_combine_sub.sh index 020a57b..f63fb61 100755 --- a/scripts/helper_scripts/IRF.lookup_table_combine_sub.sh +++ b/scripts/helper_scripts/IRF.lookup_table_combine_sub.sh @@ -1,9 +1,9 @@ #!/bin/bash -# shellcheck disable=SC2034 # combine lookup tables # set observatory environmental variables if [ ! -n "$EVNDISP_APPTAINER" ]; then +# shellcheck source=/dev/null source "$EVNDISPSYS"/setObservatory.sh VTS fi @@ -32,7 +32,6 @@ if [ -n "$EVNDISP_APPTAINER" ]; then EVNDISPSYS="${EVNDISPSYS/--cleanenv/--cleanenv $APPTAINER_ENV $APPTAINER_MOUNT}" echo "APPTAINER SYS: $EVNDISPSYS" # path used by EVNDISPSYS needs to be set - CALDIR="/opt/ODIR" fi inspect_executables() @@ -40,7 +39,7 @@ inspect_executables() if [ -n "$EVNDISP_APPTAINER" ]; then apptainer inspect "$EVNDISP_APPTAINER" else - ls -l ${EVNDISPSYS}/bin/evndisp + ls -l "${EVNDISPSYS}"/bin/evndisp fi } @@ -49,13 +48,13 @@ xargs -a "$ODIR/$FLIST" cp -t "$DDIR" ls -1 "${DDIR}"/*.root > "$DDIR/$FLIST" # combine the tables -$EVNDISPSYS/bin/combineLookupTables "$DDIR/$FLIST" "$DDIR/$OFILE.root" median &> "$ODIR/$OFILE.log" +"$EVNDISPSYS"/bin/combineLookupTables "$DDIR/$FLIST" "$DDIR/$OFILE.root" median &> "$ODIR/$OFILE.log" # log files -echo "$(inspect_executables)" >> "$ODIR/$OFILE.log" +inspect_executables >> "$ODIR/$OFILE.log" cp -v "$ODIR/$OFILE.log" "$DDIR/$OFILE.log" -$EVNDISPSYS/bin/logFile makeTableCombineLog "$DDIR/$OFILE.root" "$DDIR/$OFILE.log" -$EVNDISPSYS/bin/logFile makeTableFileList "$DDIR/$OFILE.root" "$DDIR/$FLIST" +"$EVNDISPSYS"/bin/logFile makeTableCombineLog "$DDIR/$OFILE.root" "$DDIR/$OFILE.log" +"$EVNDISPSYS"/bin/logFile makeTableFileList "$DDIR/$OFILE.root" "$DDIR/$FLIST" # cleanup mv -f -v "$DDIR/$OFILE.root" "$ODIR/$OFILE.root" diff --git a/scripts/helper_scripts/IRF.lookup_table_parallel_sub.sh b/scripts/helper_scripts/IRF.lookup_table_parallel_sub.sh index 9cc900c..ef9867d 100755 --- a/scripts/helper_scripts/IRF.lookup_table_parallel_sub.sh +++ b/scripts/helper_scripts/IRF.lookup_table_parallel_sub.sh @@ -1,9 +1,10 @@ #!/bin/bash -# shellcheck disable=SC2034,SC2154 +# shellcheck disable=SC2154 # fill lookup tables # set observatory environmental variables if [ ! -n "$EVNDISP_APPTAINER" ]; then +# shellcheck source=/dev/null source "$EVNDISPSYS"/setObservatory.sh VTS fi @@ -48,7 +49,6 @@ if [ -n "$EVNDISP_APPTAINER" ]; then EVNDISPSYS="${EVNDISPSYS/--cleanenv/--cleanenv $APPTAINER_ENV $APPTAINER_MOUNT}" echo "APPTAINER SYS: $EVNDISPSYS" # path used by EVNDISPSYS needs to be set - CALDIR="/opt/ODIR" fi inspect_executables() @@ -56,14 +56,14 @@ inspect_executables() if [ -n "$EVNDISP_APPTAINER" ]; then apptainer inspect "$EVNDISP_APPTAINER" else - ls -l ${EVNDISPSYS}/bin/mscw_energy + ls -l "${EVNDISPSYS}"/bin/mscw_energy fi } if [ -n "$(find ${INDIR} -name "*[0-9].root" 2>/dev/null)" ]; then echo "Copying evndisp root files to ${DDIR}" - find ${INDIR} -name "*[0-9].root" -exec cp -v {} ${DDIR} \; + find ${INDIR} -name "*[0-9].root" -exec cp -v {} "${DDIR}" \; elif [ -n "$(find ${INDIR} -name "*[0-9].root.zst" 2>/dev/null)" ]; then if command -v zstd &>/dev/null; then echo "Copying evndisp root.zst files to ${DDIR}" @@ -71,37 +71,44 @@ elif [ -n "$(find ${INDIR} -name "*[0-9].root.zst" 2>/dev/null)" ]; then for F in $FLIST do echo "unpacking $F" - cp -v -f $F ${DDIR}/ - ofile=$(basename $F .zst) - zstd -d ${DDIR}/${ofile}.zst -o ${DDIR}/${ofile} + cp -v -f "$F" "${DDIR}"/ + ofile=$(basename "$F" .zst) + zstd -d "${DDIR}"/"${ofile}".zst -o "${DDIR}"/"${ofile}" done else echo "Error: no zstd installation" exit fi fi -rm -f "$DDIR/$OFILE.list" -ls -1 "$DDIR"/*[0-9].root > "$DDIR/$OFILE.list" +rm -f "$DDIR/$TABFILE.list" +find "$DDIR" -maxdepth 1 -name "*[0-9].root" > "$DDIR/$TABFILE.list" # Redo stereo reconstruction with diff cuts on images (versions after v490) -MOPT="" +MOPT=() if [[ $IRFVERSION != v490* ]]; then - MOPT="-redo_stereo_reconstruction -minangle_stereo_reconstruction=10" - MOPT="$MOPT -maxloss=0.4 -use_evndisp_selected_images=0" - MOPT="$MOPT -maxdist=1.75 -minntubes=5 -minwidth=0.02 -minsize=100" + MOPT=( + -redo_stereo_reconstruction + -minangle_stereo_reconstruction=10 + -maxloss=0.4 + -use_evndisp_selected_images=0 + -maxdist=1.75 + -minntubes=5 + -minwidth=0.02 + -minsize=100 + ) fi echo "Running mscw_energy (table filling)" logfile="$ODIR/$TABFILE.log" -$EVNDISPSYS/bin/mscw_energy -filltables=1 \ +"$EVNDISPSYS"/bin/mscw_energy -filltables=1 \ -limitEnergyReconstruction \ -write1DHistograms \ - -inputfilelist "$DDIR/$OFILE.list" \ + -inputfilelist "$DDIR/$TABFILE.list" \ -tablefile "${DDIR}/$TABFILE.root" \ - -ze=$ZA $MOPT \ + -ze=$ZA "${MOPT[@]}" \ -arrayrecid=$RECID \ -woff=$WOBBLE &> "$logfile" -echo "$(inspect_executables)" >> "$logfile" -$EVNDISPSYS/bin/logFile makeTableLog "${DDIR}/$TABFILE.root" "$logfile" +inspect_executables >> "$logfile" +"$EVNDISPSYS"/bin/logFile makeTableLog "${DDIR}/$TABFILE.root" "$logfile" mv -v -f "${DDIR}/$TABFILE.root" "${ODIR}/$TABFILE.root" diff --git a/scripts/helper_scripts/IRF.mscw_energy_MC_sub.sh b/scripts/helper_scripts/IRF.mscw_energy_MC_sub.sh index 5f603f8..be9349f 100755 --- a/scripts/helper_scripts/IRF.mscw_energy_MC_sub.sh +++ b/scripts/helper_scripts/IRF.mscw_energy_MC_sub.sh @@ -1,10 +1,10 @@ #!/bin/bash -# shellcheck disable=SC2034 # Analyse MC files with lookup tables (mscw_energy stage) # (optional) Calculate instrument response functions (effective areas) for 4 and 3-telescope combinations # set observatory environmental variables if [ ! -n "$EVNDISP_APPTAINER" ]; then +# shellcheck source=/dev/null source "$EVNDISPSYS"/setObservatory.sh VTS fi set -e @@ -61,7 +61,6 @@ if [ -n "$EVNDISP_APPTAINER" ]; then EVNDISPSYS="${EVNDISPSYS/--cleanenv/--cleanenv $APPTAINER_ENV $APPTAINER_MOUNT}" echo "APPTAINER SYS: $EVNDISPSYS" # path used by EVNDISPSYS needs to be set - CALDIR="/opt/ODIR" TABFILE="/opt/VERITAS_EVNDISP_AUX_DIR/Tables/$(basename $TABFILE)" fi @@ -70,25 +69,40 @@ inspect_executables() if [ -n "$EVNDISP_APPTAINER" ]; then apptainer inspect "$EVNDISP_APPTAINER" else - ls -l ${EVNDISPSYS}/bin/mscw_energy + ls -l "${EVNDISPSYS}"/bin/mscw_energy fi } # mscw_energy command line options -MOPT="-noNoTrigger -nomctree -writeReconstructedEventsOnly=1 -arrayrecid=${RECID} -tablefile $TABFILE" +MOPT=( + -noNoTrigger + -nomctree + -writeReconstructedEventsOnly=1 + "-arrayrecid=${RECID}" + -tablefile + "$TABFILE" +) # dispBDT reconstruction if [ $DISPBDT -eq 1 ]; then - MOPT="$MOPT -redo_stereo_reconstruction" - MOPT="$MOPT -tmva_disperror_weight 50" - MOPT="$MOPT -minangle_stereo_reconstruction=10." + MOPT+=( + -redo_stereo_reconstruction + -tmva_disperror_weight + 50 + -minangle_stereo_reconstruction=10. + ) if [[ $IRFVERSION == v490* ]]; then - MOPT="$MOPT -maxloss=0.20" + MOPT+=("-maxloss=0.20") else - MOPT="$MOPT -maxdist=1.75 -minntubes=5 -minwidth=0.02 -minsize=100" - MOPT="$MOPT -maxloss=0.40" - MOPT="$MOPT -use_evndisp_selected_images=0" + MOPT+=( + -maxdist=1.75 + -minntubes=5 + -minwidth=0.02 + -minsize=100 + -maxloss=0.40 + -use_evndisp_selected_images=0 + ) fi - # MOPT="$MOPT -maxnevents=1000" + # MOPT+=("-maxnevents=1000") if [[ ${SIMTYPE} == *"RedHV"* ]]; then DISPDIR="${VERITAS_EVNDISP_AUX_DIR}/DispBDTs/${ANATYPE}/${EPOCH}_ATM${ATM}_redHV/" elif [[ ${SIMTYPE} == *"UV"* ]]; then @@ -117,15 +131,23 @@ if [ $DISPBDT -eq 1 ]; then fi fi # unzip XML files into DDIR - cp -v -f ${DISPDIR}/*.xml.gz ${DDIR}/ - gunzip -v ${DDIR}/*xml.gz - MOPT="$MOPT -tmva_filename_stereo_reconstruction ${DDIR}/BDTDisp_BDT_" - MOPT="$MOPT -tmva_filename_disperror_reconstruction ${DDIR}/BDTDispError_BDT_" - MOPT="$MOPT -tmva_filename_dispsign_reconstruction ${DDIR}/BDTDispSign_BDT_" + cp -v -f "${DISPDIR}"/*.xml.gz "${DDIR}"/ + gunzip -v "${DDIR}"/*xml.gz + MOPT+=( + -tmva_filename_stereo_reconstruction + "${DDIR}/BDTDisp_BDT_" + -tmva_filename_disperror_reconstruction + "${DDIR}/BDTDispError_BDT_" + -tmva_filename_dispsign_reconstruction + "${DDIR}/BDTDispSign_BDT_" + ) if [[ $IRFVERSION != v490* ]]; then - MOPT="$MOPT -tmva_filename_energy_reconstruction ${DDIR}/BDTDispEnergy_BDT_" + MOPT+=( + -tmva_filename_energy_reconstruction + "${DDIR}/BDTDispEnergy_BDT_" + ) fi - echo "DISP BDT options: $MOPT" + echo "DISP BDT options: ${MOPT[*]}" fi # input evndisp files @@ -142,9 +164,9 @@ elif [ -n "$(find "${INDIR}/" -name "*[0-9].root.zst" 2>/dev/null)" ]; then for F in $FLIST do echo "unpacking $F" - cp -v -f $F ${DDIR}/ - ofile=$(basename $F .zst) - zstd -d ${DDIR}/${ofile}.zst -o ${DDIR}/${ofile} + cp -v -f "$F" "${DDIR}"/ + ofile=$(basename "$F" .zst) + zstd -d "${DDIR}"/"${ofile}".zst -o "${DDIR}"/"${ofile}" done else echo "Error: no zstd installation" @@ -158,9 +180,9 @@ cat "$DDIR/$OFILE.list" echo "Running mscw_energy" outputfilename="$DDIR/$OFILE.mscw.root" logfile="$OSUBDIR/$OFILE.log" -$EVNDISPSYS/bin/mscw_energy $MOPT \ +"$EVNDISPSYS"/bin/mscw_energy "${MOPT[@]}" \ -inputfilelist "$DDIR/$OFILE.list" \ - -outputfile $outputfilename \ + -outputfile "$outputfilename" \ -noise=$NOISE &> $logfile echo "READING evndisp files from ${INDIR}" >> $logfile @@ -170,15 +192,15 @@ if [ $DISPBDT -eq 1 ]; then echo "Reading DISPBDT XML files from ${DISPDIR}" >> $logfile fi -echo "$(inspect_executables)" >> "$logfile" +inspect_executables >> "$logfile" cp -v "$logfile" "$DDIR/$OFILE.log" -$EVNDISPSYS/bin/logFile mscwTableLog $outputfilename "$DDIR/$OFILE.log" +"$EVNDISPSYS"/bin/logFile mscwTableLog "$outputfilename" "$DDIR/$OFILE.log" # cp results file back to data directory and clean up -outputbasename=$( basename $outputfilename ) +outputbasename=$( basename "$outputfilename" ) chmod g+w "$logfile" if [[ $EFFAREACUTLIST == "NOEFFAREA" ]]; then - cp -f -v $outputfilename $OSUBDIR/$outputbasename + cp -f -v "$outputfilename" $OSUBDIR/"$outputbasename" chmod g+w "$OSUBDIR/$outputbasename" exit fi @@ -192,17 +214,17 @@ echo "Effective area generation (cut list: $EFFAREACUTLIST)" read_cutlist() { CUTFILE="${1}" - if [[ $CUTFILE == "" ]] || [ ! -f $CUTFILE ]; then + if [[ $CUTFILE == "" ]] || [ ! -f "$CUTFILE" ]; then echo "Error, cuts list file not found, exiting..." >&2 - echo $CUTFILE + echo "$CUTFILE" exit 1 fi - CUTLISTFROMFILE=$(cat $CUTFILE) + CUTLISTFROMFILE=$(cat "$CUTFILE") CUTLIST="" for CUT in "${CUTLISTFROMFILE[@]}"; do CUTLIST="${CUTLIST} ANASUM.GammaHadron-Cut-$CUT.dat" done - echo $CUTLIST + echo "$CUTLIST" } # Required for DISP XGB @@ -230,7 +252,7 @@ check_conda_installation() ############################################### get_xgb_output_file() { - XGBOFIL=$(basename $MSCW_FILE .root) + XGBOFIL=$(basename "$MSCW_FILE" .root) XGBOFIL="${DDIR}/${XGBOFIL}.${XGBVERSION}_ImgSel${1}" echo "$XGBOFIL" } @@ -239,6 +261,7 @@ get_xgb_output_file() run_xgb() { check_conda_installation +# shellcheck source=/dev/null source activate base conda activate $env_name MSCW_FILE="$outputfilename" @@ -260,7 +283,7 @@ run_xgb() DISPDIR="${DISPDIR}/${BIN_ID}/dispdir_bdt" echo "DispXGB directory $DISPDIR" echo "DispXGB options $XGBVERSION" - XGBOFIL=$(get_xgb_output_file $1) + XGBOFIL=$(get_xgb_output_file "$1") echo "XGB Output file $XGBOFIL" echo "DispXGB inputfle $MSCW_FILE" @@ -270,7 +293,7 @@ run_xgb() --input-file "$MSCW_FILE" \ --model-dir "$DISPDIR" \ --output-file "$XGBOFIL.root" \ - --image-selection $1 > "$XGBOFIL.log" 2>&1 + --image-selection "$1" > "$XGBOFIL.log" 2>&1 python --version >> "${XGBOFIL}.log" conda list -n $env_name >> "${XGBOFIL}.log" @@ -300,10 +323,10 @@ for ID in 15 14 13 11 7; do fi # Check that cuts file exists CUTSFILE=${CUTSFILE%%.dat} - echo $CUTSFILE - CUTS_NAME=$(basename $CUTSFILE) + echo "$CUTSFILE" + CUTS_NAME=$(basename "$CUTSFILE") CUTS_NAME=${CUTS_NAME##ANASUM.GammaHadron-} - if [[ "$CUTSFILE" == $(basename $CUTSFILE) ]]; then + if [[ "$CUTSFILE" == $(basename "$CUTSFILE") ]]; then CUTSFILE="$VERITAS_EVNDISP_AUX_DIR"/GammaHadronCutFiles/$CUTSFILE.dat else CUTSFILE="$CUTSFILE.dat" @@ -319,7 +342,7 @@ for ID in 15 14 13 11 7; do OSUBDIR="${OSUBDIR}_DISP" fi echo -e "Output files will be written to:\n $OSUBDIR" - mkdir -p $OSUBDIR + mkdir -p "$OSUBDIR" if [[ -n $XGBVERSION ]] && [[ $XGBVERSION != "None" ]]; then XGBFILESUFFIX=${XGBVERSION}_ImgSel${ID} @@ -339,7 +362,7 @@ PARAMFILE=" * FILLMONTECARLOHISTOS 0 * ENERGYSPECTRUMINDEX 40 1.5 0.1 * RERUN_STEREO_RECONSTRUCTION_3TEL $ID -* CUTFILE $DDIR/$(basename $CUTSFILE) +* CUTFILE $DDIR/$(basename "$CUTSFILE") IGNOREFRACTIONOFEVENTS 0.5 * SIMULATIONFILE_DATA $outputfilename * XGBFILESUFFIX ${XGBFILESUFFIX}" @@ -351,32 +374,32 @@ PARAMFILE=" # create makeEffectiveArea parameter file EAPARAMS="$EFFAREAFILE-${CUTS_NAME}" rm -f "$DDIR/$EAPARAMS.dat" - eval "echo \"$PARAMFILE\"" > $DDIR/$EAPARAMS.dat + eval "echo \"$PARAMFILE\"" > "$DDIR"/"$EAPARAMS".dat echo "Run parameter file:" - cat $DDIR/$EAPARAMS.dat + cat "$DDIR"/"$EAPARAMS".dat # calculate effective areas - rm -f $OSUBDIR/$OFILE.root - $EVNDISPSYS/bin/makeEffectiveArea $DDIR/$EAPARAMS.dat $DDIR/$EAPARAMS.root &> $OSUBDIR/$EAPARAMS.log + rm -f "$OSUBDIR"/$OFILE.root + "$EVNDISPSYS"/bin/makeEffectiveArea "$DDIR"/"$EAPARAMS".dat "$DDIR"/"$EAPARAMS".root &> "$OSUBDIR"/"$EAPARAMS".log echo "Filling effAreaLog file into root file: $OSUBDIR/$EAPARAMS.log" - echo "$(inspect_executables)" >> "$OSUBDIR/$EAPARAMS.log" + inspect_executables >> "$OSUBDIR/$EAPARAMS.log" cp "$OSUBDIR/$EAPARAMS.log" "$DDIR/$EAPARAMS.log" - $EVNDISPSYS/bin/logFile effAreaLog $DDIR/$EAPARAMS.root $DDIR/$EAPARAMS.log + "$EVNDISPSYS"/bin/logFile effAreaLog "$DDIR"/"$EAPARAMS".root "$DDIR"/"$EAPARAMS".log echo "Filling mscwTableLog file into root file: $OSUBDIR/$EAPARAMS.log" - $EVNDISPSYS/bin/logFile mscwTableLog $DDIR/$EAPARAMS.root "$DDIR/$OFILE.log" + "$EVNDISPSYS"/bin/logFile mscwTableLog "$DDIR"/"$EAPARAMS".root "$DDIR/$OFILE.log" echo "Trying to fill XGB log file into root file: $OSUBDIR/$EAPARAMS.log" if [[ -n $XGBVERSION ]] && [[ $XGBVERSION != "None" ]]; then XGBLOGFILE="$(get_xgb_output_file $ID).log" if [[ -f "$XGBLOGFILE" ]]; then - $EVNDISPSYS/bin/logFile xgbLog $DDIR/$EAPARAMS.root "$XGBLOGFILE" + "$EVNDISPSYS"/bin/logFile xgbLog "$DDIR"/"$EAPARAMS".root "$XGBLOGFILE" else echo "XGB log file $XGBLOGFILE not found, skipping." fi fi - rm -f $OSUBDIR/$EAPARAMS.log - cp -f -v $DDIR/$EAPARAMS.root $OSUBDIR/$EAPARAMS.root - chmod -R g+w $OSUBDIR - chmod g+w $OSUBDIR/$EAPARAMS.root + rm -f "$OSUBDIR"/"$EAPARAMS".log + cp -f -v "$DDIR"/"$EAPARAMS".root "$OSUBDIR"/"$EAPARAMS".root + chmod -R g+w "$OSUBDIR" + chmod g+w "$OSUBDIR"/"$EAPARAMS".root done done diff --git a/scripts/helper_scripts/IRF.optimizeTMVAforGammaHadronSeparation_sub.sh b/scripts/helper_scripts/IRF.optimizeTMVAforGammaHadronSeparation_sub.sh index 2a21da6..02afb5a 100755 --- a/scripts/helper_scripts/IRF.optimizeTMVAforGammaHadronSeparation_sub.sh +++ b/scripts/helper_scripts/IRF.optimizeTMVAforGammaHadronSeparation_sub.sh @@ -3,8 +3,9 @@ # optimize BDTs with TMVA # +# shellcheck source=/dev/null # set observatory environmental variables -source $EVNDISPSYS/setObservatory.sh VTS +source "$EVNDISPSYS"/setObservatory.sh VTS EFFAREA=EFFFILE PREDIR=ODIR @@ -22,8 +23,8 @@ else TEMPDIR="$VERITAS_USER_DATA_DIR/TMPDIR/${CUT}/" fi echo "Temporary directory: $TEMPDIR" -mkdir -p $TEMPDIR -ls -1 ${PREDIR}/${CUT}/*.anasum.root > ${TEMPDIR}/anasum.list +mkdir -p "$TEMPDIR" +ls -1 ${PREDIR}/${CUT}/*.anasum.root > "${TEMPDIR}"/anasum.list OBSTIME="5." MINEVENTS="10." @@ -55,11 +56,11 @@ then # calculate rates from Crab Nebula and from background rates "$EVNDISPSYS"/bin/calculateCrabRateFromMC \ - ${EFFAREA} \ + "${EFFAREA}" \ ${RATEFILE}.root \ ${DEADTIME} \ ${TMVAPARFILES} \ - ${TEMPDIR}/anasum.list \ + "${TEMPDIR}"/anasum.list \ > ${RATEFILE}.log fi diff --git a/scripts/helper_scripts/IRF.radial_acceptance_sub.sh b/scripts/helper_scripts/IRF.radial_acceptance_sub.sh index 905795a..0c4e34c 100755 --- a/scripts/helper_scripts/IRF.radial_acceptance_sub.sh +++ b/scripts/helper_scripts/IRF.radial_acceptance_sub.sh @@ -1,8 +1,9 @@ #!/bin/bash # generate a radial acceptance file +# shellcheck source=/dev/null # set observatory environmental variables -source $EVNDISPSYS/setObservatory.sh VTS +source "$EVNDISPSYS"/setObservatory.sh VTS # parameters replaced by parent script using sed RLIST=RUNLIST @@ -14,8 +15,8 @@ TTA=TELTOANA # create radial acceptance rm -f "$ODIR/$OFILE.log" -$EVNDISPSYS/bin/makeRadialAcceptance -l $RLIST -c $CUTS -d $DDIR -o $ODIR/$OFILE.root -t $TTA &> $ODIR/$OFILE.log +"$EVNDISPSYS"/bin/makeRadialAcceptance -l $RLIST -c $CUTS -d $DDIR -o $ODIR/$OFILE.root -t $TTA &> $ODIR/$OFILE.log -$EVNDISPSYS/bin/logFile radAccLOG "$ODIR/$OFILE.root" "$ODIR/$OFILE.log" +"$EVNDISPSYS"/bin/logFile radAccLOG "$ODIR/$OFILE.root" "$ODIR/$OFILE.log" exit diff --git a/scripts/helper_scripts/IRF.trainTMVAforAngularReconstruction_sub.sh b/scripts/helper_scripts/IRF.trainTMVAforAngularReconstruction_sub.sh index 23e691f..f59c1c6 100755 --- a/scripts/helper_scripts/IRF.trainTMVAforAngularReconstruction_sub.sh +++ b/scripts/helper_scripts/IRF.trainTMVAforAngularReconstruction_sub.sh @@ -1,9 +1,9 @@ #!/bin/bash -# shellcheck disable=SC2034 # train TMVA (BDTs) for angular reconstruction # set observatory environmental variables if [ ! -n "$EVNDISP_APPTAINER" ]; then +# shellcheck source=/dev/null source "$EVNDISPSYS"/setObservatory.sh VTS fi @@ -37,23 +37,22 @@ if [ -n "$EVNDISP_APPTAINER" ]; then EVNDISPSYS="${EVNDISPSYS/--cleanenv/--cleanenv $APPTAINER_ENV $APPTAINER_MOUNT}" echo "APPTAINER SYS: $EVNDISPSYS" # path used by EVNDISPSYS needs to be set - CALDIR="/opt/ODIR" fi # decompress NLIST=${ONAME}.list -echo $NLIST -for F in $(cat $LLIST) +echo "$NLIST" +while IFS= read -r F do - IDIR=$(dirname $F) - OF=${DDIR}/$(basename $IDIR)_$(basename $F) - cp -v -f $F ${OF} -done -find $DDIR -name "*.root.zst" -exec zstd -f -d {} \; -ls -1 $DDIR -ls -1 $DDIR/*.root > ${DDIR}/$NLIST + IDIR=$(dirname "$F") + OF=${DDIR}/$(basename "$IDIR")_$(basename "$F") + cp -v -f "$F" "${OF}" +done < "$LLIST" +find "$DDIR" -name "*.root.zst" -exec zstd -f -d {} \; +ls -1 "$DDIR" +ls -1 "$DDIR"/*.root > "${DDIR}"/$NLIST echo "FILELIST ${DDIR}/$NLIST" -cat ${DDIR}/$NLIST +cat "${DDIR}"/$NLIST ODIR="${ODIR}/${BDT}" mkdir -p ${ODIR} @@ -77,7 +76,7 @@ if [[ $IRFVERSION != v490* ]]; then QUALITYCUTS="$(grep 'MVAQUALITYCUTS' $TMVAO | awk '{print $3}')" echo "QUALITYCUTS: $QUALITYCUTS" - $EVNDISPSYS/bin/trainTMVAforAngularReconstruction \ + "$EVNDISPSYS"/bin/trainTMVAforAngularReconstruction \ "${DDIR}/${NLIST}" \ "${DDIR}" \ "$TRAINTESTFRACTION" \ @@ -88,7 +87,7 @@ if [[ $IRFVERSION != v490* ]]; then "${TMVAOPTIONS}" \ "${EWEIGHT}" > "$ODIR/$ONAME-$BDT-Tel$TELTYPE.log" else - $EVNDISPSYS/bin/trainTMVAforAngularReconstruction \ + "$EVNDISPSYS"/bin/trainTMVAforAngularReconstruction \ "${DDIR}/${NLIST}" \ "${DDIR}" \ "$TRAINTESTFRACTION" \ @@ -98,7 +97,7 @@ else fi -cp -f ${DDIR}/${BDT}_*.root ${ODIR}/ -cp -f ${DDIR}/${BDT}_*.xml ${ODIR}/ +cp -f "${DDIR}"/${BDT}_*.root ${ODIR}/ +cp -f "${DDIR}"/${BDT}_*.xml ${ODIR}/ # (potentially large training file) -cp -v ${DDIR}/BDTDisp_${TELTYPE}.root ${ODIR}/ +cp -v "${DDIR}"/BDTDisp_${TELTYPE}.root ${ODIR}/ diff --git a/scripts/helper_scripts/IRF.trainTMVAforGammaHadronSeparation_sub.sh b/scripts/helper_scripts/IRF.trainTMVAforGammaHadronSeparation_sub.sh index 4c0a4fd..b112fb1 100755 --- a/scripts/helper_scripts/IRF.trainTMVAforGammaHadronSeparation_sub.sh +++ b/scripts/helper_scripts/IRF.trainTMVAforGammaHadronSeparation_sub.sh @@ -1,5 +1,4 @@ #!/bin/bash -# shellcheck disable=SC2034 # script to train TMVA (BDTs) for gamma/hadron separation RXPAR=RUNPARAM @@ -9,6 +8,7 @@ ODIR=OUTPUTDIR # set observatory environmental variables if [ ! -n "$EVNDISP_APPTAINER" ]; then +# shellcheck source=/dev/null source "$EVNDISPSYS"/setObservatory.sh VTS fi @@ -28,8 +28,6 @@ if [ -n "$EVNDISP_APPTAINER" ]; then EVNDISPSYS="${EVNDISPSYS/--cleanenv/--cleanenv $APPTAINER_ENV $APPTAINER_MOUNT}" echo "APPTAINER SYS: $EVNDISPSYS" # path used by EVNDISPSYS needs to be set - CALDIR="/opt/ODIR" - SIMDIR="/opt/SIMDIR" ODIR="/opt/ODIR" DDIR="/opt/DDIR" @@ -48,7 +46,7 @@ inspect_executables() if [ -n "$EVNDISP_APPTAINER" ]; then apptainer inspect "$EVNDISP_APPTAINER" else - ls -l ${EVNDISPSYS}/bin/evndisp + ls -l "${EVNDISPSYS}"/bin/evndisp fi } @@ -59,9 +57,9 @@ rm -f "$LDIR/${BASE_RXPAR}_preselect.log" rm -f "$LDIR/${BASE_RXPAR}.log" "$EVNDISPSYS"/bin/trainTMVAforGammaHadronSeparation "$RXPAR".runparameter.run > "$LDIR/${BASE_RXPAR}.log" -echo "$(inspect_executables)" >> "$LDIR/${BASE_RXPAR}.log" +inspect_executables >> "$LDIR/${BASE_RXPAR}.log" "$EVNDISPSYS"/bin/logFile tmvaLog "$RXPAR".root "$RXPAR".log # remove unnecessary *.C files -CDIR=`dirname $RXPAR` -rm -f -v "$CDIR"/$ONAME*.C +CDIR=$(dirname "$RXPAR") +rm -f -v "$CDIR"/"$ONAME"*.C diff --git a/scripts/helper_scripts/SPANALYSIS.lowgainped_sub.sh b/scripts/helper_scripts/SPANALYSIS.lowgainped_sub.sh index f06f1c4..c4e7333 100755 --- a/scripts/helper_scripts/SPANALYSIS.lowgainped_sub.sh +++ b/scripts/helper_scripts/SPANALYSIS.lowgainped_sub.sh @@ -1,8 +1,9 @@ #!/bin/bash # script to analyse VTS raw files (VBF) with eventdisplay +# shellcheck source=/dev/null # set observatory environmental variables -source $EVNDISPSYS/setObservatory.sh VTS +source "$EVNDISPSYS"/setObservatory.sh VTS # parameters replaced by parent script using sed RUN=RUNFILE @@ -19,28 +20,35 @@ else TEMPDIR="$VERITAS_USER_DATA_DIR/TMPDIR" fi echo "Scratch dir: $TEMPDIR" -mkdir -p $TEMPDIR +mkdir -p "$TEMPDIR" LOGDIR="$TEMPDIR" # eventdisplay reconstruction parameter -ACUTS="EVNDISP.reconstruction.LGCalibration.runparameter" +ACUTS=("EVNDISP.reconstruction.LGCalibration.runparameter") -OPT=" -calibrationsumwindow=$CALIBRATIONSUMWINDOW -calibrationsumfirst=$CALIBRATIONSUMFIRST -nevents=$NEVENTS -calibrationdirectory $TEMPDIR -teltoana=$TELTOANA " +OPT=( + "-calibrationsumwindow=$CALIBRATIONSUMWINDOW" + "-calibrationsumfirst=$CALIBRATIONSUMFIRST" + "-nevents=$NEVENTS" + -calibrationdirectory + "$TEMPDIR" + "-teltoana=$TELTOANA" +) ######################################### # pedestal calculation -rm -f $LOGDIR/$RUN.ped.log -$EVNDISPSYS/bin/evndisp -runmode=6 -runnumber=$RUN -reconstructionparameter $ACUTS $OPT &> $LOGDIR/$RUN.ped.log -echo "$EVNDISPSYS/bin/evndisp -runmode=6 -runnumber=$RUN -reconstructionparameter $ACUTS $OPT " +rm -f "$LOGDIR"/$RUN.ped.log +"$EVNDISPSYS"/bin/evndisp -runmode=6 -runnumber="$RUN" -reconstructionparameter "${ACUTS[@]}" "${OPT[@]}" &> "$LOGDIR"/$RUN.ped.log +echo "$EVNDISPSYS/bin/evndisp -runmode=6 -runnumber=$RUN -reconstructionparameter ${ACUTS[*]} ${OPT[*]}" for ((i=1; i<5; i++)) do mkdir -p $CALDIR/Calibration/Tel_$i/ - mv $TEMPDIR/Calibration/Tel_$i/$RUN.lped $CALDIR/Calibration/Tel_$i/ - mv $TEMPDIR/Calibration/Tel_$i/$RUN.lped.root $CALDIR/Calibration/Tel_$i/ - mv $LOGDIR/$RUN.ped.log $CALDIR/ + mv "$TEMPDIR"/Calibration/Tel_$i/$RUN.lped $CALDIR/Calibration/Tel_$i/ + mv "$TEMPDIR"/Calibration/Tel_$i/$RUN.lped.root $CALDIR/Calibration/Tel_$i/ + mv "$LOGDIR"/$RUN.ped.log $CALDIR/ done exit diff --git a/scripts/helper_scripts/SPANALYSIS.make_DST_sub.sh b/scripts/helper_scripts/SPANALYSIS.make_DST_sub.sh index 15be9be..b0e2c0d 100755 --- a/scripts/helper_scripts/SPANALYSIS.make_DST_sub.sh +++ b/scripts/helper_scripts/SPANALYSIS.make_DST_sub.sh @@ -1,13 +1,14 @@ #!/bin/bash -# shellcheck disable=SC2034 # script to make DSTs # set observatory environmental variables -source $EVNDISPSYS/setObservatory.sh VTS +# shellcheck source=/dev/null +source "$EVNDISPSYS"/setObservatory.sh VTS # parameters replaced by parent script using sed RUN=RUNFILE PED=PEDESTALS +# shellcheck disable=SC2034 # template placeholder, replaced by sed before job submission SUMW=SUMWINDOW LMULT=LLLOWGAIN @@ -18,7 +19,7 @@ else TEMPDIR="$VERITAS_USER_DATA_DIR/TMPDIR" fi echo "Temporary directory: $TEMPDIR" -mkdir -p $TEMPDIR +mkdir -p "$TEMPDIR" # output data files are written to this directory ODIR=OUTPUTDIR @@ -29,17 +30,17 @@ LOGDIR="$ODIR" mkdir -p $LOGDIR # eventdisplay reconstruction parameter -ACUTS=RRRRPFILE +ACUTS=("RRRRPFILE") ######################################### # pedestal and tzero calculation. No tzeros needed for lmult. if [[ $PED == "1" ]]; then rm -f $LOGDIR/$RUN.ped.log - $EVNDISPSYS/bin/evndisp -runnumber=$RUN -runmode=1 &> $LOGDIR/$RUN.ped.log + "$EVNDISPSYS"/bin/evndisp -runnumber=$RUN -runmode=1 &> $LOGDIR/$RUN.ped.log if [[ $LMULT == "0" ]] ; then rm -f $LOGDIR/$RUN.tzero.log - $EVNDISPSYS/bin/evndisp -runnumber=$RUN -runmode=7 -nocalibnoproblem &> $LOGDIR/$RUN.tzero.log + "$EVNDISPSYS"/bin/evndisp -runnumber=$RUN -runmode=7 -nocalibnoproblem &> $LOGDIR/$RUN.tzero.log fi fi @@ -47,18 +48,18 @@ fi ######################################### # Other options. hilo runs should have all events analysed. if [[ $LMULT == "0" ]] ; then - OPT=" -nevents=5000 " + OPT=("-nevents=5000") else - OPT=" -lowgaincalibrationfile calibrationlist.LowGain.CALIB.dat " + OPT=(-lowgaincalibrationfile calibrationlist.LowGain.CALIB.dat) fi ######################################### # run eventdisplay rm -f $LOGDIR/$RUN.log -$EVNDISPSYS/bin/evndisp -runnumber=$RUN -runmode=4 -nocalibnoproblem $OPT -reconstructionparameter $ACUTS -dstfile $TEMPDIR/$RUN.DST.root &> $LOGDIR/$RUN.DST.log +"$EVNDISPSYS"/bin/evndisp -runnumber="$RUN" -runmode=4 -nocalibnoproblem "${OPT[@]}" -reconstructionparameter "${ACUTS[@]}" -dstfile "$TEMPDIR"/$RUN.DST.root &> $LOGDIR/$RUN.DST.log # move data file from temp dir to data dir -cp -f -v $TEMPDIR/$RUN.DST.root $ODIR/$RUN.DST.root -rm -f $TEMPDIR/$RUN.DST.root +cp -f -v "$TEMPDIR"/$RUN.DST.root $ODIR/$RUN.DST.root +rm -f "$TEMPDIR"/$RUN.DST.root exit diff --git a/scripts/helper_scripts/UTILITY.check_root_file_closed.sh b/scripts/helper_scripts/UTILITY.check_root_file_closed.sh index 9650c29..05af647 100755 --- a/scripts/helper_scripts/UTILITY.check_root_file_closed.sh +++ b/scripts/helper_scripts/UTILITY.check_root_file_closed.sh @@ -6,9 +6,8 @@ if [ "$1" == "" ]; then echo "Usage: $0 root_file_to_check_if_closed.root" fi -filename_to_check=$(readlink -f $1) +filename_to_check=$(readlink -f "$1") #echo $filename_to_check -root -b -l -q -e "$EVNDISPSYS/macros/checkCorrupted.C(\"$filename_to_check\")" >/dev/null 2>&1 -if [ $? -ne 0 ]; then +if ! root -b -l -q -e "$EVNDISPSYS/macros/checkCorrupted.C(\"$filename_to_check\")" >/dev/null 2>&1; then exit 1 fi diff --git a/scripts/helper_scripts/UTILITY.condorSubmission.sh b/scripts/helper_scripts/UTILITY.condorSubmission.sh index 7e95a93..43391e7 100755 --- a/scripts/helper_scripts/UTILITY.condorSubmission.sh +++ b/scripts/helper_scripts/UTILITY.condorSubmission.sh @@ -15,7 +15,7 @@ SUBFIL=${SUBSCRIPT}.condor [[ -f "$SUBFIL" ]] && rm -f "$SUBFIL". -cat > ${SUBFIL} < "${SUBFIL}" <> ${SUBMITF} - echo "log = log/\$(file).log" >> ${SUBMITF} - echo "output = output/\$(file).output" >> ${SUBMITF} - echo "error = error/\$(file).error" >> ${SUBMITF} + { + echo "executable = \$(file)" + echo "log = log/\$(file).log" + echo "output = output/\$(file).output" + echo "error = error/\$(file).error" + } >> "${SUBMITF}" # assume that all condor files have similar requests - CONDORFILE=$(find ${JDIR} -name "*.condor" | head -n 1) - echo "$(grep -h request_memory $CONDORFILE)" >> ${SUBMITF} - echo "$(grep -h request_disk $CONDORFILE)" >> ${SUBMITF} - echo "getenv = True" >> ${SUBMITF} - echo "max_materialize = 1800" >> ${SUBMITF} -# echo "request_cpus = 8" >> ${SUBMITF} - echo "priority = $PRIORITY" >> ${SUBMITF} - echo "queue file matching files *.sh" >> ${SUBMITF} + CONDORFILE=$(find "${JDIR}" -name "*.condor" | head -n 1) + { + grep -h request_memory "$CONDORFILE" + grep -h request_disk "$CONDORFILE" + echo "getenv = True" + echo "max_materialize = 1800" +# echo "request_cpus = 8" + echo "priority = $PRIORITY" + echo "queue file matching files *.sh" + } >> "${SUBMITF}" PDIR=$(pwd) if [ "${2}" = "submit" ]; then - cd ${JDIR} + cd "${JDIR}" condor_submit submit.txt requirements='OpSysAndVer=="AlmaLinux9"' - cd ${PDIR} + cd "${PDIR}" fi else echo "Error: no condor files found in ${JDIR}" diff --git a/scripts/preprocessing/archive_error_files.sh b/scripts/preprocessing/archive_error_files.sh index 1a4aab4..2b32e56 100755 --- a/scripts/preprocessing/archive_error_files.sh +++ b/scripts/preprocessing/archive_error_files.sh @@ -1,5 +1,4 @@ #!/bin/bash -# shellcheck disable=SC2034 # Move Eventdisplay data products from all stages # into an runs_with_issues directory. # runs are given in a run list @@ -16,7 +15,7 @@ fi RUNLIST=${1} -EDVERSION=`$EVNDISPSYS/bin/evndisp --version | tr -d .` +EDVERSION=$("$EVNDISPSYS"/bin/evndisp --version | tr -d .) # list of data products DP="evndisp mscw anasum_moderate2tel" # archive directory @@ -25,7 +24,7 @@ do DDIR=${VERITAS_DATA_DIR}/processed_data_${EDVERSION}/${VERITAS_ANALYSIS_TYPE:0:2}/runs_with_issues/${D} for N in 3 4 5 6 7 8 9 10 11 do - mkdir -p -v ${DDIR}/$N + mkdir -p -v "${DDIR}"/$N done done @@ -37,10 +36,10 @@ get_suffix() else SRUN=${RRUN:0:2} fi - echo ${SRUN} + echo "${SRUN}" } -FF=$(cat ${1}) +FF=$(cat "$RUNLIST") for D in $DP do diff --git a/scripts/preprocessing/check_dl3_number_of_files_per_cut.sh b/scripts/preprocessing/check_dl3_number_of_files_per_cut.sh index dbb42b1..3f77e2e 100755 --- a/scripts/preprocessing/check_dl3_number_of_files_per_cut.sh +++ b/scripts/preprocessing/check_dl3_number_of_files_per_cut.sh @@ -10,7 +10,7 @@ Check number of DL3 fits and log files for all cuts and analysis types. " fi -NFIL=$(find ${1}/point-like -name "*.fits.gz" | wc -l) +NFIL=$(find "${1}"/point-like -name "*.fits.gz" | wc -l) if [[ ${VERITAS_ANALYSIS_TYPE:0:2} == "AP" ]]; then CUTS="moderate2tel soft2tel hard2tel hard3tel" @@ -23,8 +23,8 @@ TYPES="dl3_pointlike-all dl3_pointlike dl3_fullenclosure-all-events dl3_fullencl for T in $TYPES; do for C in $CUTS; do echo "Checking $T $C in ${1}/${T}_${C}" - NFIL=$(find ${1}/${T}_${C} -name "*.fits.gz" | wc -l) - NLOG=$(find ${1}/${T}_${C} -name "*.log" | wc -l) + NFIL=$(find "${1}"/"${T}"_"${C}" -name "*.fits.gz" | wc -l) + NLOG=$(find "${1}"/"${T}"_"${C}" -name "*.log" | wc -l) echo "Number of files: $NFIL $NLOG" done done diff --git a/scripts/preprocessing/check_epochs_for_3tel_irfs.sh b/scripts/preprocessing/check_epochs_for_3tel_irfs.sh index da6abb3..12a9a0c 100755 --- a/scripts/preprocessing/check_epochs_for_3tel_irfs.sh +++ b/scripts/preprocessing/check_epochs_for_3tel_irfs.sh @@ -11,7 +11,7 @@ exit fi RUNLIST="${1}" -RUNS=$(cat $RUNLIST) +RUNS=$(cat "$RUNLIST") DDIR="$VERITAS_PREPROCESSED_DATA_DIR/${VERITAS_ANALYSIS_TYPE:0:2}/mscw/" @@ -32,14 +32,14 @@ getNumberedDirectory() else NDIR="${IDIR}/${TRUN:0:2}/" fi - echo ${NDIR} + echo "${NDIR}" } for R in $RUNS; do - LOGDIR=$(getNumberedDirectory $R ${DDIR}) + LOGDIR=$(getNumberedDirectory "$R" "${DDIR}") LOGFIL="${LOGDIR}/${R}.mscw.log" if [[ -e $LOGFIL ]]; then - TELSTRING=$(grep "Mean pedvar per telescope" ${LOGFIL}) + TELSTRING=$(grep "Mean pedvar per telescope" "${LOGFIL}") mapfile -t pedvars < <(echo "$TELSTRING" | awk '{for(i=5;i<=NF;i++) print $i}') T="T" for i in "${!pedvars[@]}"; do @@ -49,9 +49,9 @@ for R in $RUNS; do fi done if [[ $T != "T1234" ]]; then - EPOCHSTRING=$(grep "Evaluating instrument" ${LOGFIL}) + EPOCHSTRING=$(grep "Evaluating instrument" "${LOGFIL}") EPOCH=$(echo "$EPOCHSTRING" | sed -n 's/.*is: \([^)]*\)).*/\1/p') - ATMOSTRING=$(grep "Evaluating atmosphere ID" ${LOGFIL}) + ATMOSTRING=$(grep "Evaluating atmosphere ID" "${LOGFIL}") ATMOID=$(echo "$ATMOSTRING" | sed -n 's/.*is: \([0-9]*\)).*/\1/p') if [[ $T == "T123" ]]; then ID=5 diff --git a/scripts/preprocessing/check_evndisp_mscw_processing.sh b/scripts/preprocessing/check_evndisp_mscw_processing.sh index 8b10dcb..d892f66 100755 --- a/scripts/preprocessing/check_evndisp_mscw_processing.sh +++ b/scripts/preprocessing/check_evndisp_mscw_processing.sh @@ -12,9 +12,9 @@ echo " exit fi -FF=$(cat ${1}) +FF=$(cat "${1}") DTYPE=${2} -EDVERSION=$(cat $VERITAS_EVNDISP_AUX_DIR/IRFMINORVERSION) +EDVERSION=$(cat "$VERITAS_EVNDISP_AUX_DIR"/IRFMINORVERSION) file_on_disk() { diff --git a/scripts/preprocessing/pack_data_files.sh b/scripts/preprocessing/pack_data_files.sh index 22efa92..f685228 100755 --- a/scripts/preprocessing/pack_data_files.sh +++ b/scripts/preprocessing/pack_data_files.sh @@ -25,11 +25,11 @@ fi DATATYPE=${1} RUNLIST=${2} -VERSION=$(cat $VERITAS_EVNDISP_AUX_DIR/IRFMINORVERSION) -RUNS=$(cat $RUNLIST) +VERSION=$(cat "$VERITAS_EVNDISP_AUX_DIR"/IRFMINORVERSION) +RUNS=$(cat "$RUNLIST") TMPDATADIR="$VERITAS_USER_DATA_DIR/tmp_packing/${3}/${DATATYPE}" -mkdir -p ${TMPDATADIR} +mkdir -p "${TMPDATADIR}" get_suffix() { @@ -39,13 +39,13 @@ get_suffix() else SRUN=${RRUN:0:2} fi - echo ${SRUN} + echo "${SRUN}" } get_file_name() { RRUN=${1} - SRUN=$(get_suffix ${RRUN}) + SRUN=$(get_suffix "${RRUN}") if [[ $DATATYPE == "evndisp" ]]; then echo "$VERITAS_DATA_DIR/processed_data_${VERSION}/${ANATYPE}/${DATATYPE}/${SRUN}/${RRUN}.root" elif [[ $DATATYPE == "mscw" ]]; then @@ -57,24 +57,24 @@ get_file_name() for R in $RUNS do - F=$(get_file_name $R) + F=$(get_file_name "$R") if [[ ! -f ${F} ]] || [[ -z ${F} ]]; then echo "RUN ${R} not processed for ${DATATYPE} (${ANATYPE})" continue fi echo "FOUND ${F}" - SRUN=$(get_suffix ${R}) - mkdir -p ${TMPDATADIR}/${SRUN} - cp -f -v ${F} ${TMPDATADIR}/${SRUN} + SRUN=$(get_suffix "${R}") + mkdir -p "${TMPDATADIR}"/"${SRUN}" + cp -f -v "${F}" "${TMPDATADIR}"/"${SRUN}" done -DTOPACK=$(find ${TMPDATADIR} -mindepth 1 -name "[0-9]*" -type d) +DTOPACK=$(find "${TMPDATADIR}" -mindepth 1 -name "[0-9]*" -type d) for D in ${DTOPACK} do echo "Packing $D" # removing leading directory path RMDATADIR="${TMPDATADIR/\/}" RMDATADIR="${RMDATADIR/$DATATYPE/}" - tar --transform "s|^$RMDATADIR||" -cvzf ${D}.${DATATYPE}.tar.gz ${D} + tar --transform "s|^$RMDATADIR||" -cvzf "${D}"."${DATATYPE}".tar.gz "${D}" done echo "TAR FILE: ${D}.${DATATYPE}.tar.gz" diff --git a/scripts/preprocessing/pack_log_files.sh b/scripts/preprocessing/pack_log_files.sh index 58a0710..9b3c8cb 100755 --- a/scripts/preprocessing/pack_log_files.sh +++ b/scripts/preprocessing/pack_log_files.sh @@ -24,7 +24,7 @@ DDIRS=$(cat "$DLIST") cd "${PDIR}" || exit for DIR in $DDIRS; do - echo $DIR - rm -f logs_${DIR}.tar.gz - find ${DIR} -type f -name "*.log" -exec tar -rf logs_${DIR}.tar.gz {} + + echo "$DIR" + rm -f logs_"${DIR}".tar.gz + find "${DIR}" -type f -name "*.log" -exec tar -rf logs_"${DIR}".tar.gz {} + done diff --git a/scripts/preprocessing/prepare_runlist_after_dqm.sh b/scripts/preprocessing/prepare_runlist_after_dqm.sh index 950e4aa..1437031 100755 --- a/scripts/preprocessing/prepare_runlist_after_dqm.sh +++ b/scripts/preprocessing/prepare_runlist_after_dqm.sh @@ -30,7 +30,7 @@ DBTEXTDIRECTORY="$VERITAS_PREPROCESSED_DATA_DIR/../DBTEXT" # List of broken runs # (not caught with the logic below) -BROKENRUNS=$(cut -d ' ' -f 1 ${2}) +BROKENRUNS=$(cut -d ' ' -f 1 "${2}") get_db_text_tar_file() { @@ -94,9 +94,9 @@ fill_run() fill_timemask() { - TMASK_1=$(echo $2 | cut -d '/' -f 1) + TMASK_1=$(echo "$2" | cut -d '/' -f 1) TMASK_1=$(printf "%.0f" "$TMASK_1") - TMASK_2=$(echo $2 | cut -d '/' -f 2) + TMASK_2=$(echo "$2" | cut -d '/' -f 2) TMASK_2=$(printf "%.0f" "$TMASK_2") TMASK="* $1 $TMASK_1 $((TMASK_2 - TMASK_1)) 0" echo "$TMASK" >> timemask.dat @@ -105,7 +105,7 @@ fill_timemask() prepare_output_files -RUNS=$(cat $RUNLIST) +RUNS=$(cat "$RUNLIST") for RF in $RUNS do @@ -121,7 +121,7 @@ do echo " RUN $R broken (BROKENCUT APPLIED)" continue fi - DBTEXTFILE=$(get_db_text_tar_file ${R}) + DBTEXTFILE=$(get_db_text_tar_file "${R}") # Target file TARGETFILE="${R}/${R}.target" # DQM File @@ -131,14 +131,14 @@ do if [[ -e ${DBTEXTFILE} ]]; then ##### # Check target - if [[ -z $(tar -tzf ${DBTEXTFILE} | grep "${TARGETFILE}") ]]; then + if [[ -z $(tar -tzf "${DBTEXTFILE}" | grep "${TARGETFILE}") ]]; then echo " RUN $R no target file ${TARGETFILE} found (NOTARGETFILE CUT APPLIED)" - echo ${R} >> runlist_NOTARGETFILE.dat + echo "${R}" >> runlist_NOTARGETFILE.dat continue fi # TARGET string - TARGETSTRING=$(tar -axf ${DBTEXTFILE} ${TARGETFILE} -O) - echo $TARGETSTRING + TARGETSTRING=$(tar -axf "${DBTEXTFILE}" "${TARGETFILE}" -O) + echo "$TARGETSTRING" # skip targets DARK... RTARGET=$(echo "${TARGETSTRING}" | cut -d '|' -f 1 | grep -v source_id) echo " RUN $R $RTARGET" @@ -153,21 +153,21 @@ do fi # skip laser and flasher runs if [[ $RTARGET == "laser" ]] || [[ $RTARGET == "flasher" ]]; then - echo " RUN $R $TARGET target (FLASHER CUT APPLIED)" + echo " RUN $R $RTARGET target (FLASHER CUT APPLIED)" continue fi - if [[ -z $(tar -tzf ${DBTEXTFILE} | grep "${DQMFILE}") ]]; then + if [[ -z $(tar -tzf "${DBTEXTFILE}" | grep "${DQMFILE}") ]]; then echo " RUN $R no DQM file ${DQMFILE} found (NODQMFILE CUT APPLIED)" - echo ${R} >> runlist_NODQM.dat + echo "${R}" >> runlist_NODQM.dat continue fi ##### # Check DQM # DQM string - DQMSTRING=$(tar -axf ${DBTEXTFILE} ${DQMFILE} -O) - echo $DQMSTRING + DQMSTRING=$(tar -axf "${DBTEXTFILE}" "${DQMFILE}" -O) + echo "$DQMSTRING" # data category - RCAT=$(echo "${DQMSTRING}" | cut -d '|' -f 2 ${RDQM} | grep -v data_category) + RCAT=$(echo "${DQMSTRING}" | cut -d '|' -f 2 "${RDQM}" | grep -v data_category) # (especially early runs do not have a science category) if [[ ${RCAT} != "science" ]] \ && [[ ${RCAT} != "reducedhv" ]] \ @@ -177,23 +177,23 @@ do continue fi # DQM status - RSTATUS=$(echo "${DQMSTRING}" | cut -d '|' -f 3 ${RDQM} | grep -v status) + RSTATUS=$(echo "${DQMSTRING}" | cut -d '|' -f 3 "${RDQM}" | grep -v status) if [[ ${RSTATUS} == "do_not_use" ]] || [[ ${RSTATUS} == "NULL" ]]; then # early V4 runs without DQM if [[ ${RSTATUS} == "do_not_use" ]] || [[ $R -gt 46642 ]]; then echo " RUN $R $RSTATUS (STATUS CUT APPLIED)" if [[ ${RSTATUS} == "NULL" ]] && [[ ${RCAT} != "NULL" ]]; then - echo $R >> runlist_NULL.dat + echo "$R" >> runlist_NULL.dat fi continue fi fi - INFOSTRING=$(tar -axf ${DBTEXTFILE} ${INFOFILE} -O) - echo $INFOSTRING + INFOSTRING=$(tar -axf "${DBTEXTFILE}" "${INFOFILE}" -O) + echo "$INFOSTRING" # usable duration - RUSABLE=$(echo "${DQMSTRING}" | cut -d '|' -f 6 ${RDQM} | grep -v usable_duration) + RUSABLE=$(echo "${DQMSTRING}" | cut -d '|' -f 6 "${RDQM}" | grep -v usable_duration) if [[ $RUSABLE != "NULL" ]]; then - RTUSABLE=$(echo $RUSABLE | awk 'NR==1 {split($1, arr, "[:]"); print arr[2]}') + RTUSABLE=$(echo "$RUSABLE" | awk 'NR==1 {split($1, arr, "[:]"); print arr[2]}') if [[ $((10#$RTUSABLE)) -lt 2 ]]; then echo " RUN $R $RSTATUS $RTUSABLE (TIME CUT APPLIED; $RUSABLE)" continue @@ -204,8 +204,8 @@ do continue fi # data duration frum run info - RDATAT1=$(echo "${INFOSTRING}" | cut -d '|' -f 7 ${RDQM} | grep -v data_start_time) - RDATAT2=$(echo "${INFOSTRING}" | cut -d '|' -f 8 ${RDQM} | grep -v data_end_time) + RDATAT1=$(echo "${INFOSTRING}" | cut -d '|' -f 7 "${RDQM}" | grep -v data_start_time) + RDATAT2=$(echo "${INFOSTRING}" | cut -d '|' -f 8 "${RDQM}" | grep -v data_end_time) echo " RUN $R $RDATAT1 $RDATAT2" RDATAT1=$(date -u -d "$RDATAT1" +%s) RDATAT2=$(date -u -d "$RDATAT2" +%s) @@ -216,12 +216,12 @@ do continue fi # time mask - RCUTMASK=$(echo "${DQMSTRING}" | cut -d '|' -f 7 ${RDQM} | grep -v time_cut_mask) + RCUTMASK=$(echo "${DQMSTRING}" | cut -d '|' -f 7 "${RDQM}" | grep -v time_cut_mask) if [[ $RCUTMASK != "NULL" ]]; then IFS=',' for TCUT in $RCUTMASK do - fill_timemask $R $TCUT + fill_timemask "$R" "$TCUT" done fi else @@ -229,7 +229,7 @@ do RCUTMASK="NULL" fi echo " $R $RSTATUS $RUSABLE $RCUTMASK" - fill_run $R $RCAT + fill_run "$R" "$RCAT" done sort_output_files diff --git a/scripts/preprocessing/prepro_check_and_clean_files.sh b/scripts/preprocessing/prepro_check_and_clean_files.sh index 5e43ad2..3fe0a73 100755 --- a/scripts/preprocessing/prepro_check_and_clean_files.sh +++ b/scripts/preprocessing/prepro_check_and_clean_files.sh @@ -34,7 +34,7 @@ move_list() # find all runs with errors and move them -FLIST=$(grep -irl "error" $FTYPE/*.log) +FLIST=$(grep -irl "error" "$FTYPE"/*.log) if [[ -n $FLIST ]]; then file_count=$(echo "$FLIST" | wc -w) if [[ ! -z $file_count ]]; then @@ -43,7 +43,7 @@ if [[ -n $FLIST ]]; then move_list error "$FLIST" fi # find all runs with segmentation faults -FLIST=$(grep -rl "segmentation" $FTYPE/*.log) +FLIST=$(grep -rl "segmentation" "$FTYPE"/*.log) if [[ -n $FLIST ]]; then file_count=$(echo "$FLIST" | wc -w) if [[ ! -z $file_count ]]; then @@ -52,7 +52,7 @@ if [[ -n $FLIST ]]; then move_list error "$FLIST" fi # find all runs without errors and remove them from error directory -FLIST=$(grep -iL "error" $FTYPE/*.log) +FLIST=$(grep -iL "error" "$FTYPE"/*.log) if [[ -n $FLIST ]]; then file_count=$(echo "$FLIST" | wc -w) if [[ ! -z $file_count ]]; then @@ -64,7 +64,7 @@ if [[ -n $FLIST ]]; then fi echo "Aux data (and NOTFOUND)" -NAUX=$(ls -1 "$FTYPE"/*.NOTFOUND 2>/dev/null | wc -l) +NAUX=$(find "$FTYPE" -maxdepth 1 -name "*.NOTFOUND" 2>/dev/null | wc -l) if [[ $NAUX -gt 0 ]]; then mkdir -p "$FTYPE"/aux mv -f "$FTYPE"/*.NOTFOUND "$FTYPE"/aux/ diff --git a/scripts/preprocessing/prepro_move_preprocessed_files.sh b/scripts/preprocessing/prepro_move_preprocessed_files.sh index 2429454..24614d0 100755 --- a/scripts/preprocessing/prepro_move_preprocessed_files.sh +++ b/scripts/preprocessing/prepro_move_preprocessed_files.sh @@ -11,7 +11,7 @@ fi FTYPE="$1" ANATYPE="${VERITAS_ANALYSIS_TYPE:0:2}" -VERSION=$(cat $VERITAS_EVNDISP_AUX_DIR/IRFMINORVERSION) +VERSION=$(cat "$VERITAS_EVNDISP_AUX_DIR"/IRFMINORVERSION) ODIR="$VERITAS_DATA_DIR/shared/processed_data_${VERSION}/${ANATYPE}/${FTYPE}" @@ -23,9 +23,9 @@ for F in 11 10 9 8 7 6 5 4 3; do OFDIR="$ODIR/$F" echo "Syncing $OFDIR with ${FTYPE}" mkdir -p "$OFDIR" - NFIL=$(ls -1 ${FTYPE}/${F}*.root 2>/dev/null | wc -l) + NFIL=$(find "$FTYPE" -maxdepth 1 -name "${F}*.root" 2>/dev/null | wc -l) if [[ $NFIL -gt 0 ]]; then - rsync -av --remove-source-files ${FTYPE}/${F}*.root $OFDIR/ - rsync -av --remove-source-files ${FTYPE}/${F}*.log $OFDIR/ + rsync -av --remove-source-files "${FTYPE}"/${F}*.root "$OFDIR"/ + rsync -av --remove-source-files "${FTYPE}"/${F}*.log "$OFDIR"/ fi done diff --git a/scripts/preprocessing/prepro_move_v2dl3_files.sh b/scripts/preprocessing/prepro_move_v2dl3_files.sh index 3133978..0991859 100755 --- a/scripts/preprocessing/prepro_move_v2dl3_files.sh +++ b/scripts/preprocessing/prepro_move_v2dl3_files.sh @@ -14,17 +14,17 @@ DDIR="$2" ANATYPE="AP" ANATYPE="${VERITAS_ANALYSIS_TYPE:0:2}" -VERSION=$(cat $VERITAS_EVNDISP_AUX_DIR/IRFMINORVERSION) +VERSION=$(cat "$VERITAS_EVNDISP_AUX_DIR"/IRFMINORVERSION) ODIR="$VERITAS_DATA_DIR/shared/processed_data_${VERSION}/${ANATYPE}/" for F in 11 10 9 8 7 6 5 4 3; do OFDIR="$ODIR/$DDIR/$F" echo "Syncing $OFDIR with ${FTYPE}" - NFIL=$(ls -1 ${FTYPE}/${F}*.fits.gz 2>/dev/null | wc -l) + NFIL=$(find "$FTYPE" -maxdepth 1 -name "${F}*.fits.gz" 2>/dev/null | wc -l) if [[ $NFIL -gt 0 ]]; then mkdir -p "$OFDIR" - rsync -av --remove-source-files ${FTYPE}/${F}*.fits.gz $ODIR/$DDIR/${F}/ - rsync -av --remove-source-files ${FTYPE}/${F}*.log $ODIR/$DDIR/${F}/ + rsync -av --remove-source-files "${FTYPE}"/${F}*.fits.gz "$ODIR"/"$DDIR"/${F}/ + rsync -av --remove-source-files "${FTYPE}"/${F}*.log "$ODIR"/"$DDIR"/${F}/ fi done diff --git a/scripts/preprocessing/prepro_pack_dl3_directories.sh b/scripts/preprocessing/prepro_pack_dl3_directories.sh index 1851220..4f62315 100755 --- a/scripts/preprocessing/prepro_pack_dl3_directories.sh +++ b/scripts/preprocessing/prepro_pack_dl3_directories.sh @@ -10,5 +10,5 @@ echo "Pack DL3 for version $VERSION" for L in $LDIR do echo "Packing $L" - tar -czf ${L}-${VERSION}.tar.gz ${L} & + tar -czf "${L}"-${VERSION}.tar.gz "${L}" & done diff --git a/scripts/preprocessing/prepro_rsync_data_ucla.sh b/scripts/preprocessing/prepro_rsync_data_ucla.sh index d44c8ed..6083c36 100755 --- a/scripts/preprocessing/prepro_rsync_data_ucla.sh +++ b/scripts/preprocessing/prepro_rsync_data_ucla.sh @@ -18,7 +18,7 @@ if [[ ! -n "${VTS_UCLA_USER}" ]]; then fi USER="${VTS_UCLA_USER}" -VERSION=$(cat $VERITAS_EVNDISP_AUX_DIR/IRFMINORVERSION) +VERSION=$(cat "$VERITAS_EVNDISP_AUX_DIR"/IRFMINORVERSION) VERSION="v491.0" VERSION="v490.7" BACKUP="$1" @@ -43,7 +43,7 @@ if [[ $SYNC_DL3TAR == "TRUE" ]]; then echo "Syncing DL3 tar ball" rsync -avz -e ssh \ ./processed_data_${VERSION}/$ANATYPE/*.tar.gz \ - ${USER}:/home/maierg/processed_Eventdisplay/${VERSION}/$ANATYPE/ + "${USER}":/home/maierg/processed_Eventdisplay/${VERSION}/$ANATYPE/ fi @@ -51,14 +51,14 @@ if [[ $SYNC_DL3 == "TRUE" ]]; then echo "Syncing DL3 files" DLDIRS=$(find ./processed_data_${VERSION}/$ANATYPE/ -type d -name 'dl3_*') for DL in $DLDIRS; do - echo $DL - DL3=$(basename $DL) + echo "$DL" + DL3=$(basename "$DL") echo "SYNC with ${USER}:/home/maierg/processed_Eventdisplay/${VERSION}/$ANATYPE/$DL3/" rsync -avz -e ssh \ --backup --suffix="$BACKUP" \ - $DL/* \ - ${USER}:/home/maierg/processed_Eventdisplay/${VERSION}/$ANATYPE/$DL3/ + "$DL"/* \ + "${USER}":/home/maierg/processed_Eventdisplay/${VERSION}/$ANATYPE/"$DL3"/ done fi @@ -67,7 +67,7 @@ if [[ $SYNC_MSCW == "TRUE" ]]; then rsync -avz -e ssh \ --backup --suffix="$BACKUP" \ ./processed_data_${VERSION}/$ANATYPE/mscw/* \ - ${USER}:/home/maierg/processed_Eventdisplay/${VERSION}/$ANATYPE/mscw/ + "${USER}":/home/maierg/processed_Eventdisplay/${VERSION}/$ANATYPE/mscw/ fi @@ -76,5 +76,5 @@ if [[ $SYNC_EVNDISP == "TRUE" ]]; then rsync -avz -e ssh \ --backup --suffix="$BACKUP" \ ./processed_data_${VERSION}/$ANATYPE/evndisp/* \ - ${USER}:/home/maierg/processed_Eventdisplay/${VERSION}/$ANATYPE/evndisp/ + "${USER}":/home/maierg/processed_Eventdisplay/${VERSION}/$ANATYPE/evndisp/ fi diff --git a/scripts/preprocessing/prepro_rsync_db_ucla.sh b/scripts/preprocessing/prepro_rsync_db_ucla.sh index 6792420..8637a56 100755 --- a/scripts/preprocessing/prepro_rsync_db_ucla.sh +++ b/scripts/preprocessing/prepro_rsync_db_ucla.sh @@ -23,9 +23,9 @@ echo "USER: $USER BACKUP $BACKUP" rsync -avz -e ssh \ --backup --suffix="$BACKUP" \ ./DBFITS \ - ${USER}:/home/maierg/processed_Eventdisplay/ + "${USER}":/home/maierg/processed_Eventdisplay/ rsync -avz -e ssh \ --backup --suffix="$BACKUP" \ ./DBTEXT \ - ${USER}:/home/maierg/processed_Eventdisplay/ + "${USER}":/home/maierg/processed_Eventdisplay/ diff --git a/scripts/preprocessing/print_dqm_string_from_runlist.sh b/scripts/preprocessing/print_dqm_string_from_runlist.sh index a1eb43e..d1827b0 100755 --- a/scripts/preprocessing/print_dqm_string_from_runlist.sh +++ b/scripts/preprocessing/print_dqm_string_from_runlist.sh @@ -27,8 +27,8 @@ unpack_db_textdirectory() fi DBRUNFIL="${DBTEXTDIRECTORY}/${SRUN}/${RRUN}.tar.gz" if [[ -e ${DBRUNFIL} ]]; then - mkdir -p ${TMP_DBTEXTDIRECTORY}/ - tar -xzf ${DBRUNFIL} -C ${TMP_DBTEXTDIRECTORY}/ + mkdir -p "${TMP_DBTEXTDIRECTORY}"/ + tar -xzf "${DBRUNFIL}" -C "${TMP_DBTEXTDIRECTORY}"/ fi echo "${TMP_DBTEXTDIRECTORY}/${RRUN}/" } @@ -57,9 +57,9 @@ do unpack_db_textdirectory "${R}" ./tmp_dbtext/ >/dev/null RDQM="./tmp_dbtext/${R}/${R}.rundqm" if [[ -e ${RDQM} ]]; then - RSTATUS=$(cut -d '|' -f 3 ${RDQM} | grep -v status) - RCUTMASK=$(cut -d '|' -f 7 ${RDQM} | grep -v status) - RCATEGORY=$(cut -d '|' -f 2 ${RDQM} | grep -v data_category) + RSTATUS=$(cut -d '|' -f 3 "${RDQM}" | grep -v status) + RCUTMASK=$(cut -d '|' -f 7 "${RDQM}" | grep -v status) + RCATEGORY=$(cut -d '|' -f 2 "${RDQM}" | grep -v data_category) else RSTATUS="NODQMFILE" RCUTMASK="NULL" @@ -67,10 +67,10 @@ do fi RINF="./tmp_dbtext/${R}/${R}.runinfo" if [[ -e ${RINF} ]]; then - RLENGTH=$(cut -d '|' -f 9 ${RINF} | grep -v duration) - RWEATHER=$(cut -d '|' -f 10 ${RINF} | grep -v weather) - RTARGET=$(cut -d '|' -f 20 ${RINF} | grep -v source_id) - RTYPE=$(cut -d '|' -f 2 ${RINF} | grep -v run_type) + RLENGTH=$(cut -d '|' -f 9 "${RINF}" | grep -v duration) + RWEATHER=$(cut -d '|' -f 10 "${RINF}" | grep -v weather) + RTARGET=$(cut -d '|' -f 20 "${RINF}" | grep -v source_id) + RTYPE=$(cut -d '|' -f 2 "${RINF}" | grep -v run_type) else RLENGTH="NORUNINFOFILE" RWEATHER="NULL" diff --git a/scripts/preprocessing/print_processed_runstatistics.sh b/scripts/preprocessing/print_processed_runstatistics.sh index 254cddc..16da7a7 100755 --- a/scripts/preprocessing/print_processed_runstatistics.sh +++ b/scripts/preprocessing/print_processed_runstatistics.sh @@ -1,5 +1,4 @@ #!/bin/bash -# shellcheck disable=SC2034 # Print processed run statistics for the different # stages of Eventdisplay @@ -25,11 +24,11 @@ count_files() LL=0 if [[ $1 == "V6" ]]; then - LL=$(find ${2} -name "*${3}" ! -name "*IPR.root" -exec basename {} "$3" \; | awk -F '-' '{if ($1 > 63372) print $0}' | wc -l) + LL=$(find "${2}" -name "*${3}" ! -name "*IPR.root" -exec basename {} "$3" \; | awk -F '-' '{if ($1 > 63372) print $0}' | wc -l) elif [[ $1 == "V4" ]]; then - LL=$(find ${2} -name "*${3}" ! -name "*IPR.root" -exec basename {} "$3" \; | awk -F '-' '{if ($1 > 1000 && $1 < 46642) print $1}' | wc -l) + LL=$(find "${2}" -name "*${3}" ! -name "*IPR.root" -exec basename {} "$3" \; | awk -F '-' '{if ($1 > 1000 && $1 < 46642) print $1}' | wc -l) elif [[ $1 == "V5" ]]; then - LL=$(find ${2} -name "*${3}" ! -name "*IPR.root" -exec basename {} "$3" \; | awk -F '-' '{if ($1 > 46641 && $1 < 63373) print $0}' | wc -l) + LL=$(find "${2}" -name "*${3}" ! -name "*IPR.root" -exec basename {} "$3" \; | awk -F '-' '{if ($1 > 46641 && $1 < 63373) print $0}' | wc -l) fi echo "$LL" } @@ -37,15 +36,15 @@ count_files() for E in _V6 _V5 _V4 do GLIST="$GOODFDIR/runlist${E}.dat" - GOODRUNS=$(cat ${GLIST} | wc -l) + GOODRUNS=$(cat "${GLIST}" | wc -l) for S in evndisp mscw do LL="0" if [[ $S == "evndisp" ]]; then - LL=$(count_files ${E:1} ${1}/${S}/ ".root") + LL=$(count_files ${E:1} "$FILEDIR"/${S}/ ".root") elif [[ $S == "mscw" ]]; then - LL=$(count_files ${E:1} ${1}/${S}/ ".mscw.root") + LL=$(count_files ${E:1} "$FILEDIR"/${S}/ ".mscw.root") fi echo "| ${E:1} | $S | ${GOODRUNS} | $LL |" diff --git a/scripts/preprocessing/processing_dqm.sh b/scripts/preprocessing/processing_dqm.sh index 57c7270..2825255 100755 --- a/scripts/preprocessing/processing_dqm.sh +++ b/scripts/preprocessing/processing_dqm.sh @@ -19,71 +19,71 @@ echo "Checking runs in ${1} for data type ${DTYPE}" check_evndisp_log_files() { # check number of log files of all stages - PNLOG=$(ls -1 ${1}/*.ped.log | wc -l) - TNLOG=$(ls -1 ${1}/*.tzero.log | wc -l) - ANLOG=$(ls -1 ${1}/*[0-9].log | wc -l) + PNLOG=$(find "$1" -maxdepth 1 -name "*.ped.log" | wc -l) + TNLOG=$(find "$1" -maxdepth 1 -name "*.tzero.log" | wc -l) + ANLOG=$(find "$1" -maxdepth 1 -name "*[0-9].log" | wc -l) echo "Number of log files: ped $PNLOG tzero $TNLOG evndisp $ANLOG" echo "Ped files: " echo "--------------------" - echo " Container revisions: $(grep -h org.opencontainers.image.revision ${1}/*.ped.log | sort -u)" - echo "$(grep -i error ${1}/*.ped.log)" + echo " Container revisions: $(grep -h org.opencontainers.image.revision "${1}"/*.ped.log | sort -u)" + echo "$(grep -i error "${1}"/*.ped.log)" echo "Tzero files: " echo "--------------------" - echo " Container revisions: $(grep -h org.opencontainers.image.revision ${1}/*.tzero.log | sort -u)" - echo "$(grep -i error ${1}/*.tzero.log)" + echo " Container revisions: $(grep -h org.opencontainers.image.revision "${1}"/*.tzero.log | sort -u)" + echo "$(grep -i error "${1}"/*.tzero.log)" echo "Evndisp files: " echo "--------------------" - echo " Container revisions: $(grep -h org.opencontainers.image.revision ${1}/*[0-9].log | sort -u)" - echo "$(grep -i error ${1}/*[0-9].log)" + echo " Container revisions: $(grep -h org.opencontainers.image.revision "${1}"/*[0-9].log | sort -u)" + echo "$(grep -i error "${1}"/*[0-9].log)" echo "Zero average pulse in evndisp files: " echo "--------------------" - echo "$(grep "average pulse timing for this telescope is 0" ${1}/*[0-9].log)" + echo "$(grep "average pulse timing for this telescope is 0" "${1}"/*[0-9].log)" # echo "Warnings in evndisp files: " # echo "--------------------" # echo "$(grep -i warning ${1}/*[0-9].log | grep -v "WARNING: Skipping mount")" - grep -h -i EVNDISP.reconstruction.runparameter ${1}/*[0-9].log > $TMPLOG + grep -h -i EVNDISP.reconstruction.runparameter "${1}"/*[0-9].log > "$TMPLOG" } check_mscw_log_files() { - NFIL=$(ls -1 ${1}/*.mscw.root | wc -l) + NFIL=$(find "$1" -maxdepth 1 -name "*.mscw.root" | wc -l) echo "Number of mscw file: $NFIL" - echo "Container revisions: $(grep -h org.opencontainers.image.revision ${1}/*.mscw.log | sort -u)" + echo "Container revisions: $(grep -h org.opencontainers.image.revision "${1}"/*.mscw.log | sort -u)" echo "Errors in mscw log files:" - echo "$(grep -i error ${1}/*.mscw.log | grep -v "error weighting parameter" | grep -v BDTDispError | grep -v "disp error")" - grep -h -i "lookuptable:" ${1}/*[0-9].mscw.log > $TMPLOG + echo "$(grep -i error "${1}"/*.mscw.log | grep -v "error weighting parameter" | grep -v BDTDispError | grep -v "disp error")" + grep -h -i "lookuptable:" "${1}"/*[0-9].mscw.log > "$TMPLOG" } check_anasum_log_files() { - NFIL=$(find ${1} -name "*.anasum.root" | wc -l) + NFIL=$(find "${1}" -name "*.anasum.root" | wc -l) echo "Number of anasum file: $NFIL" - echo "Container revisions: $(find ${1} -name "*.anasum.log" -exec grep -h org.opencontainers.image.revision {} \; | sort -u)" + echo "Container revisions: $(find "${1}" -name "*.anasum.log" -exec grep -h org.opencontainers.image.revision {} \; | sort -u)" echo "Errors in anasumlog files:" - echo "$(find ${1} -name "*.anasum.log" -exec grep -H -i error {} \;)" - find ${1} -name "*.anasum.log" -exec grep -h -i "reading effective areas from" {} \;> $TMPLOG + echo "$(find "${1}" -name "*.anasum.log" -exec grep -H -i error {} \;)" + find "${1}" -name "*.anasum.log" -exec grep -h -i "reading effective areas from" {} \;> "$TMPLOG" } check_v2dl3_log_files() { - NFIL=$(find ${1}/point-like -name "*.fits.gz" | wc -l) + NFIL=$(find "${1}"/point-like -name "*.fits.gz" | wc -l) echo "Number of v2dl3 file: $NFIL" echo "Errors in v2dl3 files:" - echo "$(find ${1} -name "*.log" -exec grep -H -i error {} \; | grep -v "several offsets" | grep -v "Coordinate zenith tolerance is")" + echo "$(find "${1}" -name "*.log" -exec grep -H -i error {} \; | grep -v "several offsets" | grep -v "Coordinate zenith tolerance is")" } TMPLOG="$(pwd)/DQM.${DTYPE}.$(uuid).tmp.txt" -rm -f $TMPLOG +rm -f "$TMPLOG" if [[ $DTYPE == "evndisp" ]]; then - check_evndisp_log_files $FDIR - cat $TMPLOG | sort -u + check_evndisp_log_files "$FDIR" + cat "$TMPLOG" | sort -u elif [[ $DTYPE == "mscw" ]]; then - check_mscw_log_files $FDIR - cat $TMPLOG | sort -u + check_mscw_log_files "$FDIR" + cat "$TMPLOG" | sort -u elif [[ $DTYPE == "anasum" ]]; then - check_anasum_log_files $FDIR - cat $TMPLOG | sort -u + check_anasum_log_files "$FDIR" + cat "$TMPLOG" | sort -u elif [[ $DTYPE == "v2dl3" ]]; then - check_v2dl3_log_files $FDIR + check_v2dl3_log_files "$FDIR" fi -rm -f $TMPLOG +rm -f "$TMPLOG" diff --git a/scripts/set_environment.sh b/scripts/set_environment.sh index a5fe6ec..6672bca 100755 --- a/scripts/set_environment.sh +++ b/scripts/set_environment.sh @@ -68,16 +68,18 @@ if [[ $PROCESS == "apptainer"* ]]; then # Alma Linux 9 (al9) processing elif [[ $PROCESS == "al9" ]]; then unset EVNDISP_APPTAINER - TDIR=`pwd` + TDIR=$(pwd) export ROOTSYS=/afs/ifh.de/group/cta/cta/software/root/root_v6.30.02.Linux-almalinux9.3-x86_64-gcc11.4/ export VBFSYS=/afs/ifh.de/group/cta/VERITAS/software/VBF-0.3.4-c17/ export EVNDISPSYS=${USERAFSDIR}/EVNDISP/EVNDISP-400/GITHUB_Eventdisplay/EventDisplay_${EVNDISPVERSION:0:4}-${PROCESS} cd "$ROOTSYS" || return +# shellcheck source=/dev/null source ./bin/thisroot.sh export PATH=$PATH:${VBFSYS}/bin/ export LD_LIBRARY_PATH="$VBFSYS/lib:$LD_LIBRARY_PATH" export SOFASYS=${EVNDISPSYS}/sofa cd "${EVNDISPSYS}" || return +# shellcheck source=/dev/null source ./setObservatory.sh VTS cd "${TDIR}" || return fi