Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
25 changes: 13 additions & 12 deletions scripts/ANALYSIS.anasum.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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"
Expand All @@ -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|" \
Expand All @@ -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
Expand All @@ -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
26 changes: 13 additions & 13 deletions scripts/ANALYSIS.anasum_allcuts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}/"
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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}"
29 changes: 15 additions & 14 deletions scripts/ANALYSIS.anasum_combine.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -66,15 +65,15 @@ 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"

# 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
Expand All @@ -94,29 +93,31 @@ 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
JOBID=$( echo "$JOBID" | grep -oP "Your job [0-9.-:]+" | awk '{ print $3 }' )
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
Expand Down
17 changes: 8 additions & 9 deletions scripts/ANALYSIS.anasum_link_files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -40,7 +39,7 @@ if [[ ! -f "$RUNLIST" ]]; then
fi

# output directory
mkdir -p ${ODIR}
mkdir -p "${ODIR}"
# directory schema
getNumberedDirectory()
{
Expand All @@ -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
Comment on lines +56 to 60
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
Loading
Loading