From 359a8e31206e49d298dc699f4ec79263119a58f0 Mon Sep 17 00:00:00 2001 From: Gernot Maier Date: Sat, 30 May 2026 21:29:03 +0200 Subject: [PATCH 1/4] Fix all shellcheck info-level issues; enforce in CI Resolved all 1339 shellcheck info-level issues across 116 shell scripts. Zero issues remain at --severity=info. Main fix categories: - SC2086 (1259): Quote single-value variables; suppress intentional word-splits with inline disable comments - SC2012 (26): Replace ls-based file discovery with find - SC1091 (24): Add shellcheck source=/dev/null before sourced files - SC2196 (11): Replace deprecated egrep with grep -E - SC2153 (6): Fix variable name typos / suppress false positives - SC2021 (4): Fix [A-z] character ranges to [A-Za-z] - SC2162 (2): Add -r flag to read commands - SC2231 (2): Quote expansions in case patterns - SC2030/SC2031 (2): Fix subshell variable visibility bug in RUNLIST.whichRunsAreAtmosphere.sh - SC2013 (1): Replace for-in-$(cat) with while read loop - SC2269 (1): Remove self-assignment - SC2329 (1): Fix always-true expression Update CI to use --severity=info (stricter than the previous --severity=warning). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .github/workflows/CI.yml | 2 +- scripts/ANALYSIS.anasum.sh | 1 + scripts/ANALYSIS.anasum_allcuts.sh | 1 + scripts/ANALYSIS.anasum_combine.sh | 11 +++--- scripts/ANALYSIS.anasum_link_files.sh | 1 + .../ANALYSIS.anasum_parallel_from_runlist.sh | 3 +- scripts/ANALYSIS.dispXGB.sh | 1 + scripts/ANALYSIS.evndisp.sh | 3 ++ scripts/ANALYSIS.evndisp_laser.sh | 1 + scripts/ANALYSIS.evndisp_muon.sh | 1 + scripts/ANALYSIS.mscw_energy.sh | 1 + scripts/ANALYSIS.v2dl3.sh | 5 +-- scripts/IRF.combine_effective_area_parts.sh | 1 + scripts/IRF.combine_lookup_table_parts.sh | 1 + scripts/IRF.compress_evndisp_MC.sh | 6 ++-- scripts/IRF.dispXGB.sh | 1 + scripts/IRF.evndisp_MC.sh | 1 + scripts/IRF.generalproduction.sh | 1 + ...generate_NOISEfiles_from_PedestalEvents.sh | 1 + scripts/IRF.generate_effective_area_parts.sh | 1 + scripts/IRF.generate_lookup_table_parts.sh | 1 + scripts/IRF.generate_radial_acceptance.sh | 1 + scripts/IRF.mscw_energy_MC.sh | 1 + ...RF.optimizeTMVAforGammaHadronSeparation.sh | 1 + scripts/IRF.production.sh | 34 +++++++++---------- ...ectRunsForGammaHadronSeparationTraining.sh | 1 + .../IRF.trainTMVAforAngularReconstruction.sh | 3 +- .../IRF.trainTMVAforGammaHadronSeparation.sh | 3 +- ....trainXGBforAngularReconstructionBinned.sh | 1 + ...rainXGBforGammaHadronSeparationTraining.sh | 3 +- scripts/RUNLIST.findBackgroundRuns.sh | 5 +-- scripts/RUNLIST.findDBSourceCoordinates.sh | 3 +- scripts/RUNLIST.findDBSourceNames.sh | 3 +- scripts/RUNLIST.generate.sh | 3 +- scripts/RUNLIST.preprocessing.sh | 3 +- scripts/RUNLIST.whichRunsAreArrayEpoch.sh | 1 + scripts/RUNLIST.whichRunsAreAtmosphere.sh | 12 +++---- scripts/RUNLIST.whichRunsAreObservingMode.sh | 3 +- scripts/RUNLIST.whichRunsAreOnDisk.sh | 3 +- scripts/RUNLIST.whichRunsAreSource.sh | 6 ++-- scripts/RUNLIST.whichRunsAreWobble.sh | 5 +-- scripts/SPANALYSIS.evndisp_laser_run.sh | 1 + ...LYSIS.evndisp_laser_runs_from_calibfile.sh | 1 + ...NALYSIS.evndisp_laser_runs_from_runlist.sh | 1 + scripts/SPANALYSIS.evndisp_pedestal_events.sh | 1 + scripts/SPANALYSIS.evndisp_tzeros.sh | 1 + scripts/SPANALYSIS.lowgainped.sh | 1 + scripts/SPANALYSIS.make_DST.sh | 1 + .../UTILITY.downloadSoundingDatafromUWYO.sh | 1 + scripts/UTILITY.sortRunsInSubDirectories.sh | 1 + scripts/db_scripts/db_FADCsettings.sh | 1 + scripts/db_scripts/db_HVsettings.sh | 1 + scripts/db_scripts/db_L1_TriggerInfo.sh | 1 + scripts/db_scripts/db_L3.sh | 1 + scripts/db_scripts/db_VPM.sh | 1 + scripts/db_scripts/db_camerarotation.sh | 1 + .../db_copy_old_laser_calibration.sh | 1 + scripts/db_scripts/db_fir.sh | 1 + scripts/db_scripts/db_gain.sh | 1 + scripts/db_scripts/db_laserrun.sh | 2 +- scripts/db_scripts/db_lidar.sh | 1 + scripts/db_scripts/db_mysqldb.sh | 3 +- scripts/db_scripts/db_pack_new_directories.sh | 1 + scripts/db_scripts/db_rawpointing.sh | 1 + scripts/db_scripts/db_run.sh | 1 + scripts/db_scripts/db_rundqm.sh | 1 + scripts/db_scripts/db_runinfo.sh | 1 + scripts/db_scripts/db_target.sh | 1 + scripts/db_scripts/db_toffset.sh | 1 + .../db_scripts/db_update_old_laser_files.sh | 1 + scripts/db_scripts/db_update_tar_balls.sh | 1 + scripts/db_scripts/db_weather.sh | 1 + .../db_scripts/db_write_fits_from_runlist.sh | 1 + scripts/db_scripts/query_run_list.sh | 1 + .../ANALYSIS.anasum_combine_sub.sh | 2 ++ scripts/helper_scripts/ANALYSIS.anasum_sub.sh | 2 ++ .../helper_scripts/ANALYSIS.dispXGB_sub.sh | 1 + .../ANALYSIS.evndisp_laser_sub.sh | 2 ++ .../helper_scripts/ANALYSIS.evndisp_sub.sh | 2 ++ .../ANALYSIS.mscw_energy_sub.sh | 2 ++ scripts/helper_scripts/ANALYSIS.v2dl3_sub.sh | 2 ++ .../IRF.compress_evndisp_MC_sub.sh | 2 ++ scripts/helper_scripts/IRF.dispXGB_sub.sh | 1 + .../IRF.effective_area_combine_sub.sh | 3 +- .../IRF.effective_area_parallel_sub.sh | 3 +- scripts/helper_scripts/IRF.evndisp_MC_sub.sh | 3 +- .../IRF.lookup_table_combine_sub.sh | 3 +- .../IRF.lookup_table_parallel_sub.sh | 9 ++--- .../helper_scripts/IRF.mscw_energy_MC_sub.sh | 4 ++- ...ptimizeTMVAforGammaHadronSeparation_sub.sh | 2 ++ .../IRF.radial_acceptance_sub.sh | 2 ++ ...F.trainTMVAforAngularReconstruction_sub.sh | 15 ++++---- ...F.trainTMVAforGammaHadronSeparation_sub.sh | 3 +- .../SPANALYSIS.lowgainped_sub.sh | 2 ++ .../helper_scripts/SPANALYSIS.make_DST_sub.sh | 3 +- .../UTILITY.check_root_file_closed.sh | 1 + .../UTILITY.condorSubmission.sh | 1 + .../UTILITY.readSubmissionCommand.sh | 5 +-- scripts/helper_scripts/UTILITY.script_init.sh | 2 ++ .../submit_scripts_to_htcondor.sh | 1 + scripts/preprocessing/archive_error_files.sh | 2 +- .../check_dl3_number_of_files_per_cut.sh | 1 + .../check_epochs_for_3tel_irfs.sh | 1 + .../check_evndisp_mscw_processing.sh | 1 + scripts/preprocessing/pack_data_files.sh | 1 + scripts/preprocessing/pack_log_files.sh | 1 + .../prepare_runlist_after_dqm.sh | 3 +- .../prepro_check_and_clean_files.sh | 3 +- .../prepro_move_preprocessed_files.sh | 3 +- .../preprocessing/prepro_move_v2dl3_files.sh | 3 +- .../prepro_pack_dl3_directories.sh | 1 + .../preprocessing/prepro_rsync_data_ucla.sh | 1 + scripts/preprocessing/prepro_rsync_db_ucla.sh | 1 + .../print_dqm_string_from_runlist.sh | 1 + .../print_processed_runstatistics.sh | 2 +- scripts/preprocessing/processing_dqm.sh | 9 ++--- scripts/set_environment.sh | 2 ++ 117 files changed, 204 insertions(+), 86 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index e6193daf..7d130c63 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 8c2e1c4b..a00688ad 100755 --- a/scripts/ANALYSIS.anasum.sh +++ b/scripts/ANALYSIS.anasum.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # script to analyse data files with anasum # qsub parameters diff --git a/scripts/ANALYSIS.anasum_allcuts.sh b/scripts/ANALYSIS.anasum_allcuts.sh index 850e8e6d..799fbdeb 100755 --- a/scripts/ANALYSIS.anasum_allcuts.sh +++ b/scripts/ANALYSIS.anasum_allcuts.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # Run anasum or V2DL3 over all standard cuts # # diff --git a/scripts/ANALYSIS.anasum_combine.sh b/scripts/ANALYSIS.anasum_combine.sh index 1a3f046d..ac844290 100755 --- a/scripts/ANALYSIS.anasum_combine.sh +++ b/scripts/ANALYSIS.anasum_combine.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # script to combine anasum files processed in parallel mode # qsub parameters @@ -74,7 +75,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" sed -e "s|RRUNLIST|$RUNLIST|" \ @@ -100,11 +101,11 @@ if [[ $SUBC == *qsub* ]]; then 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" +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 diff --git a/scripts/ANALYSIS.anasum_link_files.sh b/scripts/ANALYSIS.anasum_link_files.sh index 6cd83b4f..d856f972 100755 --- a/scripts/ANALYSIS.anasum_link_files.sh +++ b/scripts/ANALYSIS.anasum_link_files.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # script to link pre-processed anasum files to an anasum output directory diff --git a/scripts/ANALYSIS.anasum_parallel_from_runlist.sh b/scripts/ANALYSIS.anasum_parallel_from_runlist.sh index 817d6d08..707dd5b0 100755 --- a/scripts/ANALYSIS.anasum_parallel_from_runlist.sh +++ b/scripts/ANALYSIS.anasum_parallel_from_runlist.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # script to analyse data files with anasum (parallel analysis) from a simple run list # qsub parameters @@ -151,7 +152,7 @@ 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 diff --git a/scripts/ANALYSIS.dispXGB.sh b/scripts/ANALYSIS.dispXGB.sh index 48ccd6f9..a3b2aace 100755 --- a/scripts/ANALYSIS.dispXGB.sh +++ b/scripts/ANALYSIS.dispXGB.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # XGBoost analysis on mscw data files. # qsub parameters diff --git a/scripts/ANALYSIS.evndisp.sh b/scripts/ANALYSIS.evndisp.sh index fb6772fe..88761ba2 100755 --- a/scripts/ANALYSIS.evndisp.sh +++ b/scripts/ANALYSIS.evndisp.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # script to run eventdisplay analysis for VTS data # qsub parameters @@ -99,6 +100,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" @@ -302,6 +304,7 @@ if [[ $SUBC == *parallel* ]]; then 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 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 51ccf2f2..2a4b2d3a 100755 --- a/scripts/ANALYSIS.evndisp_laser.sh +++ b/scripts/ANALYSIS.evndisp_laser.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # script run eventdisplay laser analysis with a queue system # qsub parameters diff --git a/scripts/ANALYSIS.evndisp_muon.sh b/scripts/ANALYSIS.evndisp_muon.sh index f12ea82a..f52737c3 100755 --- a/scripts/ANALYSIS.evndisp_muon.sh +++ b/scripts/ANALYSIS.evndisp_muon.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # script to run eventdisplay analysis for VTS data # qsub parameters diff --git a/scripts/ANALYSIS.mscw_energy.sh b/scripts/ANALYSIS.mscw_energy.sh index 0041d353..7c948cd2 100755 --- a/scripts/ANALYSIS.mscw_energy.sh +++ b/scripts/ANALYSIS.mscw_energy.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # script to analyse data files with lookup tables # qsub parameters diff --git a/scripts/ANALYSIS.v2dl3.sh b/scripts/ANALYSIS.v2dl3.sh index 9d6b247c..50ae695c 100755 --- a/scripts/ANALYSIS.v2dl3.sh +++ b/scripts/ANALYSIS.v2dl3.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # script to run V2DL3 # (convert anasum output to FITS-DL3) # run point-like and full-enclosure analysis @@ -61,8 +62,8 @@ rm -f ${LOGDIR}/x* 2>/dev/null sort -u "${RUNLIST}" -o "${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)" diff --git a/scripts/IRF.combine_effective_area_parts.sh b/scripts/IRF.combine_effective_area_parts.sh index 04ffaec8..d90a2f11 100755 --- a/scripts/IRF.combine_effective_area_parts.sh +++ b/scripts/IRF.combine_effective_area_parts.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # combine effective area files into one # job requirements diff --git a/scripts/IRF.combine_lookup_table_parts.sh b/scripts/IRF.combine_lookup_table_parts.sh index d4ceaac8..832987ec 100755 --- a/scripts/IRF.combine_lookup_table_parts.sh +++ b/scripts/IRF.combine_lookup_table_parts.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # script to combine several table file into one # job requirements diff --git a/scripts/IRF.compress_evndisp_MC.sh b/scripts/IRF.compress_evndisp_MC.sh index e581299d..ddfd6dd3 100755 --- a/scripts/IRF.compress_evndisp_MC.sh +++ b/scripts/IRF.compress_evndisp_MC.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # submit cleanup job after running evndisp # @@ -120,9 +121,6 @@ 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 @@ -194,7 +192,7 @@ do SIMDIR=$(dirname ${V}) # size of VBF file - FF=$(ls -ls -Llh ${V} | awk '{print $1}' | sed 's/,/./g') + FF=$(du -shL "${V}" | awk '{print $1}' | sed 's/,/./g') V=$(basename ${V}) echo "SIMDIR: $SIMDIR" echo "VBFILE: ${V} $FF" diff --git a/scripts/IRF.dispXGB.sh b/scripts/IRF.dispXGB.sh index 6fd9f1a6..dcdb590e 100755 --- a/scripts/IRF.dispXGB.sh +++ b/scripts/IRF.dispXGB.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # XGBoost analysis on mscw MC files. # qsub parameters diff --git a/scripts/IRF.evndisp_MC.sh b/scripts/IRF.evndisp_MC.sh index 01abdfa8..11d3c789 100755 --- a/scripts/IRF.evndisp_MC.sh +++ b/scripts/IRF.evndisp_MC.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # submit evndisp for grisu/care simulations # qsub parameters diff --git a/scripts/IRF.generalproduction.sh b/scripts/IRF.generalproduction.sh index acf71285..b1020b21 100755 --- a/scripts/IRF.generalproduction.sh +++ b/scripts/IRF.generalproduction.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # IRF general production script (VERITAS) for large scale # productions process all epochs diff --git a/scripts/IRF.generate_NOISEfiles_from_PedestalEvents.sh b/scripts/IRF.generate_NOISEfiles_from_PedestalEvents.sh index 2d50487f..1a1e9a90 100755 --- a/scripts/IRF.generate_NOISEfiles_from_PedestalEvents.sh +++ b/scripts/IRF.generate_NOISEfiles_from_PedestalEvents.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # generate noise files from a vbf file with pedestal events # # noise files are used in simulations which does not include diff --git a/scripts/IRF.generate_effective_area_parts.sh b/scripts/IRF.generate_effective_area_parts.sh index 34c0134f..522e6342 100755 --- a/scripts/IRF.generate_effective_area_parts.sh +++ b/scripts/IRF.generate_effective_area_parts.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # calculate effective areas for a given point in the parameter space # (output need to be combined afterwards) diff --git a/scripts/IRF.generate_lookup_table_parts.sh b/scripts/IRF.generate_lookup_table_parts.sh index 798b92cb..b34350e0 100755 --- a/scripts/IRF.generate_lookup_table_parts.sh +++ b/scripts/IRF.generate_lookup_table_parts.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # fill lookup tables for a given point in the parameter space # (generated tables need to be combined afterwards) diff --git a/scripts/IRF.generate_radial_acceptance.sh b/scripts/IRF.generate_radial_acceptance.sh index 0a8f0877..f14bd2df 100755 --- a/scripts/IRF.generate_radial_acceptance.sh +++ b/scripts/IRF.generate_radial_acceptance.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # calculate radial acceptances # qsub parameters diff --git a/scripts/IRF.mscw_energy_MC.sh b/scripts/IRF.mscw_energy_MC.sh index c0d1acde..96080500 100755 --- a/scripts/IRF.mscw_energy_MC.sh +++ b/scripts/IRF.mscw_energy_MC.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # Analyze simulation evndisp files using mscw_energy to generate IRF components. # Allow optionally to calculate instrument response functions (for 4 and 3-telescope combinations). diff --git a/scripts/IRF.optimizeTMVAforGammaHadronSeparation.sh b/scripts/IRF.optimizeTMVAforGammaHadronSeparation.sh index 0724b371..83c81935 100755 --- a/scripts/IRF.optimizeTMVAforGammaHadronSeparation.sh +++ b/scripts/IRF.optimizeTMVAforGammaHadronSeparation.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # script to optimize BDT cuts # # diff --git a/scripts/IRF.production.sh b/scripts/IRF.production.sh index e72548e6..5f649ef7 100755 --- a/scripts/IRF.production.sh +++ b/scripts/IRF.production.sh @@ -1,5 +1,5 @@ #!/bin/bash -# shellcheck disable=SC2178,SC2128 +# shellcheck disable=SC2178,SC2128,SC2086 # IRF production script (VERITAS) # EventDisplay version @@ -149,25 +149,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) + 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=$(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) + 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 +188,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}') # 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 +202,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) + 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 ) diff --git a/scripts/IRF.selectRunsForGammaHadronSeparationTraining.sh b/scripts/IRF.selectRunsForGammaHadronSeparationTraining.sh index 4b1bf4db..8ce139dd 100755 --- a/scripts/IRF.selectRunsForGammaHadronSeparationTraining.sh +++ b/scripts/IRF.selectRunsForGammaHadronSeparationTraining.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # select mscw files for BDT gamma/hadron separation training # # selection is based on diff --git a/scripts/IRF.trainTMVAforAngularReconstruction.sh b/scripts/IRF.trainTMVAforAngularReconstruction.sh index 53e09bae..5a1f90cb 100755 --- a/scripts/IRF.trainTMVAforAngularReconstruction.sh +++ b/scripts/IRF.trainTMVAforAngularReconstruction.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # submit TMVA training for angular reconstruction # qsub parameters @@ -109,7 +110,7 @@ do do 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}" diff --git a/scripts/IRF.trainTMVAforGammaHadronSeparation.sh b/scripts/IRF.trainTMVAforGammaHadronSeparation.sh index 8777f765..03c256c7 100755 --- a/scripts/IRF.trainTMVAforGammaHadronSeparation.sh +++ b/scripts/IRF.trainTMVAforGammaHadronSeparation.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # train BDTs for gamma/hadron separation # # note the large amount of hardwired parameters in this scripts: @@ -255,7 +256,7 @@ 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 diff --git a/scripts/IRF.trainXGBforAngularReconstructionBinned.sh b/scripts/IRF.trainXGBforAngularReconstructionBinned.sh index e78b2ab7..c438506e 100755 --- a/scripts/IRF.trainXGBforAngularReconstructionBinned.sh +++ b/scripts/IRF.trainXGBforAngularReconstructionBinned.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # train XGB for angular reconstruction # shellcheck disable=SC2034 diff --git a/scripts/IRF.trainXGBforGammaHadronSeparationTraining.sh b/scripts/IRF.trainXGBforGammaHadronSeparationTraining.sh index 6c216143..f6c4f09d 100755 --- a/scripts/IRF.trainXGBforGammaHadronSeparationTraining.sh +++ b/scripts/IRF.trainXGBforGammaHadronSeparationTraining.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # train XGB for gamma/hadron separation # # - training at wobble offsets 0.5 deg only @@ -135,7 +136,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 diff --git a/scripts/RUNLIST.findBackgroundRuns.sh b/scripts/RUNLIST.findBackgroundRuns.sh index e97c6220..82347157 100755 --- a/scripts/RUNLIST.findBackgroundRuns.sh +++ b/scripts/RUNLIST.findBackgroundRuns.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # Generates a simple run list (one run per line) with quality cuts if [ ! -n "$1" ] || [ "$1" = "-h" ]; then @@ -112,7 +113,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 @@ -129,7 +130,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 6ebfa0cc..edfc3001 100755 --- a/scripts/RUNLIST.findDBSourceCoordinates.sh +++ b/scripts/RUNLIST.findDBSourceCoordinates.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 if [ ! "$#" -eq "1" ] || [ "$1" = "-h" ] ; then echo "Print the coordinates of a source" ; echo @@ -26,7 +27,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 diff --git a/scripts/RUNLIST.findDBSourceNames.sh b/scripts/RUNLIST.findDBSourceNames.sh index 8f1c6c9a..e0e879a0 100755 --- a/scripts/RUNLIST.findDBSourceNames.sh +++ b/scripts/RUNLIST.findDBSourceNames.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # prints list of sources that contain the first input argument if [ ! -n "$1" ] || [ "$1" = "-h" ]; then @@ -49,7 +50,7 @@ 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 cf6c60d5..60a96179 100755 --- a/scripts/RUNLIST.generate.sh +++ b/scripts/RUNLIST.generate.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # Generates a simple run list (one run per line) with quality cuts if [ ! -n "$1" ] || [ "$1" = "-h" ]; then @@ -78,7 +79,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 3a3c653a..6ff778d3 100755 --- a/scripts/RUNLIST.preprocessing.sh +++ b/scripts/RUNLIST.preprocessing.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # Generates a simple run list (one run per line) with quality cuts if [ ! -n "$1" ] || [ "$1" = "-h" ]; then @@ -41,7 +42,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 95bf5d4f..9da18340 100755 --- a/scripts/RUNLIST.whichRunsAreArrayEpoch.sh +++ b/scripts/RUNLIST.whichRunsAreArrayEpoch.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # from a run list, prints the list of runs that are considered V4 runs, before T1 was moved #echo "\$#:$# \$1:$1 \$2:$2 \$3:$3 \$4:$4" diff --git a/scripts/RUNLIST.whichRunsAreAtmosphere.sh b/scripts/RUNLIST.whichRunsAreAtmosphere.sh index a78035e9..86d9f171 100755 --- a/scripts/RUNLIST.whichRunsAreAtmosphere.sh +++ b/scripts/RUNLIST.whichRunsAreAtmosphere.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # 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 @@ -31,7 +32,7 @@ RUNLIST=`cat $RUNFILE` 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 +74,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 +98,7 @@ function IsWinter { break fi fi - done - ) + done <<< "$ATMOTHRESH" # 3 = did not find valid atmo range if [ ! $FOUNDATMO ] ; then echo 3 @@ -142,7 +140,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!" diff --git a/scripts/RUNLIST.whichRunsAreObservingMode.sh b/scripts/RUNLIST.whichRunsAreObservingMode.sh index c8409495..d7475532 100755 --- a/scripts/RUNLIST.whichRunsAreObservingMode.sh +++ b/scripts/RUNLIST.whichRunsAreObservingMode.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # from a run list, prints the list of runs that were taken in a specific observing mode (observing, obsLowHV, obsFilter,...) # @@ -33,7 +34,7 @@ RUNLIST=`cat $RUNFILE` 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!" diff --git a/scripts/RUNLIST.whichRunsAreOnDisk.sh b/scripts/RUNLIST.whichRunsAreOnDisk.sh index 5a41b726..a836ac91 100755 --- a/scripts/RUNLIST.whichRunsAreOnDisk.sh +++ b/scripts/RUNLIST.whichRunsAreOnDisk.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # from a run list, prints the list of runs that are on disk. NOTFLAG=false # flag for if the -n flag was used @@ -82,7 +83,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 diff --git a/scripts/RUNLIST.whichRunsAreSource.sh b/scripts/RUNLIST.whichRunsAreSource.sh index 007aac36..ec01265e 100755 --- a/scripts/RUNLIST.whichRunsAreSource.sh +++ b/scripts/RUNLIST.whichRunsAreSource.sh @@ -1,5 +1,5 @@ #!/bin/bash -# shellcheck disable=SC2034 +# shellcheck disable=SC2034,SC2086 # from a run list, prints the list of runs that target a specific source # variables for coloring terminal output @@ -96,8 +96,6 @@ if $HELPFLAG ; then exit fi -function echoerr(){ echo "$@" 1>&2; } #for spitting out error text - # list of run_id's to read in if [ ! -e $RUNFILE ] ; then echo "File '$RUNFILE' could not be found in $PWD , sorry." @@ -107,7 +105,7 @@ 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!" diff --git a/scripts/RUNLIST.whichRunsAreWobble.sh b/scripts/RUNLIST.whichRunsAreWobble.sh index bfb0592b..429d7a93 100755 --- a/scripts/RUNLIST.whichRunsAreWobble.sh +++ b/scripts/RUNLIST.whichRunsAreWobble.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # from a run list, prints the list of runs that were taken in a specific atmosphere, summer(22) or winter(21) CONORM="\e[0m" @@ -36,7 +37,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 +45,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!" diff --git a/scripts/SPANALYSIS.evndisp_laser_run.sh b/scripts/SPANALYSIS.evndisp_laser_run.sh index 0597ad8f..050fc1f2 100755 --- a/scripts/SPANALYSIS.evndisp_laser_run.sh +++ b/scripts/SPANALYSIS.evndisp_laser_run.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # analyze a laser/flasher run (calculate pedestals, calculate gains) if [ ! -n "$1" ] || [ "$1" = "-h" ]; then diff --git a/scripts/SPANALYSIS.evndisp_laser_runs_from_calibfile.sh b/scripts/SPANALYSIS.evndisp_laser_runs_from_calibfile.sh index 9f362ba9..a6c0e0e3 100755 --- a/scripts/SPANALYSIS.evndisp_laser_runs_from_calibfile.sh +++ b/scripts/SPANALYSIS.evndisp_laser_runs_from_calibfile.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # read a calibration file produced by write_analysis_scripts.pl if [ ! -n "$1" ] || [ "$1" = "-h" ]; then diff --git a/scripts/SPANALYSIS.evndisp_laser_runs_from_runlist.sh b/scripts/SPANALYSIS.evndisp_laser_runs_from_runlist.sh index d2633257..b80b79ce 100755 --- a/scripts/SPANALYSIS.evndisp_laser_runs_from_runlist.sh +++ b/scripts/SPANALYSIS.evndisp_laser_runs_from_runlist.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 if [ ! -n "$1" ] || [ "$1" = "-h" ]; then # begin help message diff --git a/scripts/SPANALYSIS.evndisp_pedestal_events.sh b/scripts/SPANALYSIS.evndisp_pedestal_events.sh index 9e76be39..91da6790 100755 --- a/scripts/SPANALYSIS.evndisp_pedestal_events.sh +++ b/scripts/SPANALYSIS.evndisp_pedestal_events.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # calculate pedestals if [ ! -n "$1" ] || [ "$1" = "-h" ]; then diff --git a/scripts/SPANALYSIS.evndisp_tzeros.sh b/scripts/SPANALYSIS.evndisp_tzeros.sh index e87ad312..6eb6284e 100755 --- a/scripts/SPANALYSIS.evndisp_tzeros.sh +++ b/scripts/SPANALYSIS.evndisp_tzeros.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # calculate mean tzeros if [ ! -n "$1" ] || [ "$1" = "-h" ]; then diff --git a/scripts/SPANALYSIS.lowgainped.sh b/scripts/SPANALYSIS.lowgainped.sh index 979d9939..c7a82a1b 100755 --- a/scripts/SPANALYSIS.lowgainped.sh +++ b/scripts/SPANALYSIS.lowgainped.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # script to run eventdisplay analysis for VTS data # qsub parameters diff --git a/scripts/SPANALYSIS.make_DST.sh b/scripts/SPANALYSIS.make_DST.sh index cefc39a7..acf9b572 100755 --- a/scripts/SPANALYSIS.make_DST.sh +++ b/scripts/SPANALYSIS.make_DST.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # script to make DST files from a raw data file # qsub parameters diff --git a/scripts/UTILITY.downloadSoundingDatafromUWYO.sh b/scripts/UTILITY.downloadSoundingDatafromUWYO.sh index b727f915..05bb30e6 100755 --- a/scripts/UTILITY.downloadSoundingDatafromUWYO.sh +++ b/scripts/UTILITY.downloadSoundingDatafromUWYO.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # download sounding (balloon) data from UWYO for VERITAS # combine the monthly data into one file and create a list of files (in this case just the total file) diff --git a/scripts/UTILITY.sortRunsInSubDirectories.sh b/scripts/UTILITY.sortRunsInSubDirectories.sh index ba39f60d..ce2fffb6 100755 --- a/scripts/UTILITY.sortRunsInSubDirectories.sh +++ b/scripts/UTILITY.sortRunsInSubDirectories.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # sort and move files with file names [runnumber].*suffix # into subdirectories starting with the first (two) digits # of the run number. diff --git a/scripts/db_scripts/db_FADCsettings.sh b/scripts/db_scripts/db_FADCsettings.sh index 10061a52..eb231f2d 100755 --- a/scripts/db_scripts/db_FADCsettings.sh +++ b/scripts/db_scripts/db_FADCsettings.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # if [ ! -n "$3" ] || [ "$1" = "-h" ]; then diff --git a/scripts/db_scripts/db_HVsettings.sh b/scripts/db_scripts/db_HVsettings.sh index 51e47ebe..fdec24b1 100755 --- a/scripts/db_scripts/db_HVsettings.sh +++ b/scripts/db_scripts/db_HVsettings.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # if [ ! -n "$3" ] || [ "$1" = "-h" ]; then diff --git a/scripts/db_scripts/db_L1_TriggerInfo.sh b/scripts/db_scripts/db_L1_TriggerInfo.sh index 82c74b96..b65450c8 100755 --- a/scripts/db_scripts/db_L1_TriggerInfo.sh +++ b/scripts/db_scripts/db_L1_TriggerInfo.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # if [ ! -n "$1" ] || [ "$1" = "-h" ]; then diff --git a/scripts/db_scripts/db_L3.sh b/scripts/db_scripts/db_L3.sh index a30cf253..40982e81 100755 --- a/scripts/db_scripts/db_L3.sh +++ b/scripts/db_scripts/db_L3.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # if [ $# -lt 2 ] || [ "$1" = "-h" ]; then diff --git a/scripts/db_scripts/db_VPM.sh b/scripts/db_scripts/db_VPM.sh index e645532d..d4955ed4 100755 --- a/scripts/db_scripts/db_VPM.sh +++ b/scripts/db_scripts/db_VPM.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # if [ ! -n "$3" ] || [ "$1" = "-h" ]; then diff --git a/scripts/db_scripts/db_camerarotation.sh b/scripts/db_scripts/db_camerarotation.sh index e0fc04cc..704719e5 100755 --- a/scripts/db_scripts/db_camerarotation.sh +++ b/scripts/db_scripts/db_camerarotation.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # if [ ! -n "$2" ] || [ "$1" = "-h" ]; then diff --git a/scripts/db_scripts/db_copy_old_laser_calibration.sh b/scripts/db_scripts/db_copy_old_laser_calibration.sh index ea4f83d8..0cab8433 100755 --- a/scripts/db_scripts/db_copy_old_laser_calibration.sh +++ b/scripts/db_scripts/db_copy_old_laser_calibration.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # Copy gain and toff files and adapt them # according to the DBtext standard # Required for old V4 files with no entries diff --git a/scripts/db_scripts/db_fir.sh b/scripts/db_scripts/db_fir.sh index 9ea3cf0d..7bc12082 100755 --- a/scripts/db_scripts/db_fir.sh +++ b/scripts/db_scripts/db_fir.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # if [ $# -lt 2 ] || [ "$1" = "-h" ]; then diff --git a/scripts/db_scripts/db_gain.sh b/scripts/db_scripts/db_gain.sh index a00128ab..f11556b7 100755 --- a/scripts/db_scripts/db_gain.sh +++ b/scripts/db_scripts/db_gain.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # if [ ! -n "$2" ] || [ "$1" = "-h" ]; then diff --git a/scripts/db_scripts/db_laserrun.sh b/scripts/db_scripts/db_laserrun.sh index e4a27898..f6983c6b 100755 --- a/scripts/db_scripts/db_laserrun.sh +++ b/scripts/db_scripts/db_laserrun.sh @@ -1,5 +1,5 @@ #!/bin/bash -# shellcheck disable=SC2034 +# shellcheck disable=SC2034,SC2086 # if [ ! -n "$1" ] || [ "$1" = "-h" ]; then diff --git a/scripts/db_scripts/db_lidar.sh b/scripts/db_scripts/db_lidar.sh index f63c54fe..8442d1f3 100755 --- a/scripts/db_scripts/db_lidar.sh +++ b/scripts/db_scripts/db_lidar.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # if [ $# -lt 2 ] || [ "$1" = "-h" ]; then diff --git a/scripts/db_scripts/db_mysqldb.sh b/scripts/db_scripts/db_mysqldb.sh index c4d70198..215430e5 100755 --- a/scripts/db_scripts/db_mysqldb.sh +++ b/scripts/db_scripts/db_mysqldb.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # if [ "$1" = "-h" ]; then @@ -13,7 +14,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 fa8a33e9..c30796ec 100755 --- a/scripts/db_scripts/db_pack_new_directories.sh +++ b/scripts/db_scripts/db_pack_new_directories.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # pack newly written directories extracted from the DB # with query_run_list.sh # diff --git a/scripts/db_scripts/db_rawpointing.sh b/scripts/db_scripts/db_rawpointing.sh index d92209fa..2650205d 100755 --- a/scripts/db_scripts/db_rawpointing.sh +++ b/scripts/db_scripts/db_rawpointing.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # if [ ! -n "$3" ] || [ "$1" = "-h" ]; then diff --git a/scripts/db_scripts/db_run.sh b/scripts/db_scripts/db_run.sh index a23d5371..e9f39576 100755 --- a/scripts/db_scripts/db_run.sh +++ b/scripts/db_scripts/db_run.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # # extract information from VERITAS database required # for evndisp analysis diff --git a/scripts/db_scripts/db_rundqm.sh b/scripts/db_scripts/db_rundqm.sh index 1f58a4c8..c7ca85d3 100755 --- a/scripts/db_scripts/db_rundqm.sh +++ b/scripts/db_scripts/db_rundqm.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # if [ ! -n "$1" ] || [ "$1" = "-h" ]; then diff --git a/scripts/db_scripts/db_runinfo.sh b/scripts/db_scripts/db_runinfo.sh index e031c368..1a4e44fa 100755 --- a/scripts/db_scripts/db_runinfo.sh +++ b/scripts/db_scripts/db_runinfo.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # if [ ! -n "$1" ] || [ "$1" = "-h" ]; then diff --git a/scripts/db_scripts/db_target.sh b/scripts/db_scripts/db_target.sh index ae441f1e..95602069 100755 --- a/scripts/db_scripts/db_target.sh +++ b/scripts/db_scripts/db_target.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # if [ ! -n "$1" ] || [ "$1" = "-h" ]; then diff --git a/scripts/db_scripts/db_toffset.sh b/scripts/db_scripts/db_toffset.sh index 58e80df6..f8460b53 100755 --- a/scripts/db_scripts/db_toffset.sh +++ b/scripts/db_scripts/db_toffset.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # if [ ! -n "$2" ] || [ "$1" = "-h" ]; then diff --git a/scripts/db_scripts/db_update_old_laser_files.sh b/scripts/db_scripts/db_update_old_laser_files.sh index e7b492f5..03045cbe 100755 --- a/scripts/db_scripts/db_update_old_laser_files.sh +++ b/scripts/db_scripts/db_update_old_laser_files.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # Update a laser rfiles for very early V4 runs # Some of these runs have no entries for the # laser file in the database diff --git a/scripts/db_scripts/db_update_tar_balls.sh b/scripts/db_scripts/db_update_tar_balls.sh index 17b5eccc..8f6ca92d 100755 --- a/scripts/db_scripts/db_update_tar_balls.sh +++ b/scripts/db_scripts/db_update_tar_balls.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # Update existing tar balls with DB files with new # files. diff --git a/scripts/db_scripts/db_weather.sh b/scripts/db_scripts/db_weather.sh index 103048c8..67aed82f 100755 --- a/scripts/db_scripts/db_weather.sh +++ b/scripts/db_scripts/db_weather.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # if [ $# -lt 2 ] || [ "$1" = "-h" ]; then diff --git a/scripts/db_scripts/db_write_fits_from_runlist.sh b/scripts/db_scripts/db_write_fits_from_runlist.sh index 2f6d47cc..2d28517a 100755 --- a/scripts/db_scripts/db_write_fits_from_runlist.sh +++ b/scripts/db_scripts/db_write_fits_from_runlist.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # # Write DB FITS files from a run list diff --git a/scripts/db_scripts/query_run_list.sh b/scripts/db_scripts/query_run_list.sh index b8b86659..03985090 100755 --- a/scripts/db_scripts/query_run_list.sh +++ b/scripts/db_scripts/query_run_list.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # # Extract information from VERITAS database required # for evndisp analysis for a list of runs diff --git a/scripts/helper_scripts/ANALYSIS.anasum_combine_sub.sh b/scripts/helper_scripts/ANALYSIS.anasum_combine_sub.sh index 8d16cfc9..a7e7b3bd 100755 --- a/scripts/helper_scripts/ANALYSIS.anasum_combine_sub.sh +++ b/scripts/helper_scripts/ANALYSIS.anasum_combine_sub.sh @@ -1,7 +1,9 @@ #!/bin/bash +# shellcheck disable=SC2086 # script to combine anasum runs # # set observatory environmental variables +# shellcheck source=/dev/null if [ ! -n "$EVNDISP_APPTAINER" ]; then source $EVNDISPSYS/setObservatory.sh VTS fi diff --git a/scripts/helper_scripts/ANALYSIS.anasum_sub.sh b/scripts/helper_scripts/ANALYSIS.anasum_sub.sh index 3b44bd22..0a9a8180 100755 --- a/scripts/helper_scripts/ANALYSIS.anasum_sub.sh +++ b/scripts/helper_scripts/ANALYSIS.anasum_sub.sh @@ -1,7 +1,9 @@ #!/bin/bash +# shellcheck disable=SC2086 # 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 diff --git a/scripts/helper_scripts/ANALYSIS.dispXGB_sub.sh b/scripts/helper_scripts/ANALYSIS.dispXGB_sub.sh index 90da6bce..a2fe3397 100755 --- a/scripts/helper_scripts/ANALYSIS.dispXGB_sub.sh +++ b/scripts/helper_scripts/ANALYSIS.dispXGB_sub.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # XGBoost disp stereo and classification analysis on mscw data file # Don't do set -e. diff --git a/scripts/helper_scripts/ANALYSIS.evndisp_laser_sub.sh b/scripts/helper_scripts/ANALYSIS.evndisp_laser_sub.sh index a89cbb65..3dc07364 100755 --- a/scripts/helper_scripts/ANALYSIS.evndisp_laser_sub.sh +++ b/scripts/helper_scripts/ANALYSIS.evndisp_laser_sub.sh @@ -1,6 +1,8 @@ #!/bin/bash +# shellcheck disable=SC2086 # script to analyse laser files +# shellcheck source=/dev/null # set observatory environmental variables source $EVNDISPSYS/setObservatory.sh VTS diff --git a/scripts/helper_scripts/ANALYSIS.evndisp_sub.sh b/scripts/helper_scripts/ANALYSIS.evndisp_sub.sh index 3550a47c..8b7831cb 100755 --- a/scripts/helper_scripts/ANALYSIS.evndisp_sub.sh +++ b/scripts/helper_scripts/ANALYSIS.evndisp_sub.sh @@ -1,7 +1,9 @@ #!/bin/bash +# shellcheck disable=SC2086 # 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 diff --git a/scripts/helper_scripts/ANALYSIS.mscw_energy_sub.sh b/scripts/helper_scripts/ANALYSIS.mscw_energy_sub.sh index 0212caff..8f3b9a9b 100755 --- a/scripts/helper_scripts/ANALYSIS.mscw_energy_sub.sh +++ b/scripts/helper_scripts/ANALYSIS.mscw_energy_sub.sh @@ -1,7 +1,9 @@ #!/bin/bash +# shellcheck disable=SC2086 # 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 diff --git a/scripts/helper_scripts/ANALYSIS.v2dl3_sub.sh b/scripts/helper_scripts/ANALYSIS.v2dl3_sub.sh index 059733af..7928cf73 100755 --- a/scripts/helper_scripts/ANALYSIS.v2dl3_sub.sh +++ b/scripts/helper_scripts/ANALYSIS.v2dl3_sub.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # script to run V2DL3 # (convert anasum output to FITS-DL3) # run point-like and full-enclosure analysis @@ -52,6 +53,7 @@ check_conda_installation() } check_conda_installation +# shellcheck source=/dev/null source activate base conda activate v2dl3Eventdisplay-${V2DL3VERSION} diff --git a/scripts/helper_scripts/IRF.compress_evndisp_MC_sub.sh b/scripts/helper_scripts/IRF.compress_evndisp_MC_sub.sh index c2003a96..5b7ed204 100755 --- a/scripts/helper_scripts/IRF.compress_evndisp_MC_sub.sh +++ b/scripts/helper_scripts/IRF.compress_evndisp_MC_sub.sh @@ -1,6 +1,8 @@ #!/bin/bash +# shellcheck disable=SC2086 # script put log files into evndisp file and compress output +# shellcheck source=/dev/null # set observatory environmental variables source "$EVNDISPSYS"/setObservatory.sh VTS diff --git a/scripts/helper_scripts/IRF.dispXGB_sub.sh b/scripts/helper_scripts/IRF.dispXGB_sub.sh index bce4a3f4..181cf579 100755 --- a/scripts/helper_scripts/IRF.dispXGB_sub.sh +++ b/scripts/helper_scripts/IRF.dispXGB_sub.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # XGBoost disp stereo and classification analysis on mscw MC file # Don't do set -e. diff --git a/scripts/helper_scripts/IRF.effective_area_combine_sub.sh b/scripts/helper_scripts/IRF.effective_area_combine_sub.sh index 281331c7..493232a7 100755 --- a/scripts/helper_scripts/IRF.effective_area_combine_sub.sh +++ b/scripts/helper_scripts/IRF.effective_area_combine_sub.sh @@ -1,9 +1,10 @@ #!/bin/bash -# shellcheck disable=SC2034 +# shellcheck disable=SC2034,SC2086 # combine effective areas # set observatory environmental variables if [ ! -n "$EVNDISP_APPTAINER" ]; then +# shellcheck source=/dev/null source "$EVNDISPSYS"/setObservatory.sh VTS fi diff --git a/scripts/helper_scripts/IRF.effective_area_parallel_sub.sh b/scripts/helper_scripts/IRF.effective_area_parallel_sub.sh index 119f2315..999f6e45 100755 --- a/scripts/helper_scripts/IRF.effective_area_parallel_sub.sh +++ b/scripts/helper_scripts/IRF.effective_area_parallel_sub.sh @@ -1,11 +1,12 @@ #!/bin/bash -# shellcheck disable=SC2034 +# shellcheck disable=SC2034,SC2086 # 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 diff --git a/scripts/helper_scripts/IRF.evndisp_MC_sub.sh b/scripts/helper_scripts/IRF.evndisp_MC_sub.sh index efa126cf..807d3034 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=SC2034,SC2154,SC2086 # 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 diff --git a/scripts/helper_scripts/IRF.lookup_table_combine_sub.sh b/scripts/helper_scripts/IRF.lookup_table_combine_sub.sh index 020a57b7..308e1658 100755 --- a/scripts/helper_scripts/IRF.lookup_table_combine_sub.sh +++ b/scripts/helper_scripts/IRF.lookup_table_combine_sub.sh @@ -1,9 +1,10 @@ #!/bin/bash -# shellcheck disable=SC2034 +# shellcheck disable=SC2034,SC2086 # combine lookup tables # set observatory environmental variables if [ ! -n "$EVNDISP_APPTAINER" ]; then +# shellcheck source=/dev/null source "$EVNDISPSYS"/setObservatory.sh VTS fi diff --git a/scripts/helper_scripts/IRF.lookup_table_parallel_sub.sh b/scripts/helper_scripts/IRF.lookup_table_parallel_sub.sh index 9cc900cf..bed5c442 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=SC2034,SC2154,SC2086 # fill lookup tables # set observatory environmental variables if [ ! -n "$EVNDISP_APPTAINER" ]; then +# shellcheck source=/dev/null source "$EVNDISPSYS"/setObservatory.sh VTS fi @@ -80,8 +81,8 @@ elif [ -n "$(find ${INDIR} -name "*[0-9].root.zst" 2>/dev/null)" ]; then 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="" @@ -96,7 +97,7 @@ logfile="$ODIR/$TABFILE.log" $EVNDISPSYS/bin/mscw_energy -filltables=1 \ -limitEnergyReconstruction \ -write1DHistograms \ - -inputfilelist "$DDIR/$OFILE.list" \ + -inputfilelist "$DDIR/$TABFILE.list" \ -tablefile "${DDIR}/$TABFILE.root" \ -ze=$ZA $MOPT \ -arrayrecid=$RECID \ diff --git a/scripts/helper_scripts/IRF.mscw_energy_MC_sub.sh b/scripts/helper_scripts/IRF.mscw_energy_MC_sub.sh index 29059251..a26d0b66 100755 --- a/scripts/helper_scripts/IRF.mscw_energy_MC_sub.sh +++ b/scripts/helper_scripts/IRF.mscw_energy_MC_sub.sh @@ -1,10 +1,11 @@ #!/bin/bash -# shellcheck disable=SC2034 +# shellcheck disable=SC2034,SC2086 # 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 @@ -240,6 +241,7 @@ get_xgb_output_file() run_xgb() { check_conda_installation +# shellcheck source=/dev/null source activate base conda activate $env_name MSCW_FILE="$outputfilename" diff --git a/scripts/helper_scripts/IRF.optimizeTMVAforGammaHadronSeparation_sub.sh b/scripts/helper_scripts/IRF.optimizeTMVAforGammaHadronSeparation_sub.sh index 2a21da66..58a04be8 100755 --- a/scripts/helper_scripts/IRF.optimizeTMVAforGammaHadronSeparation_sub.sh +++ b/scripts/helper_scripts/IRF.optimizeTMVAforGammaHadronSeparation_sub.sh @@ -1,8 +1,10 @@ #!/bin/bash +# shellcheck disable=SC2086 # script to calculate signal and background rates and # optimize BDTs with TMVA # +# shellcheck source=/dev/null # set observatory environmental variables source $EVNDISPSYS/setObservatory.sh VTS diff --git a/scripts/helper_scripts/IRF.radial_acceptance_sub.sh b/scripts/helper_scripts/IRF.radial_acceptance_sub.sh index 905795a0..0a6323e6 100755 --- a/scripts/helper_scripts/IRF.radial_acceptance_sub.sh +++ b/scripts/helper_scripts/IRF.radial_acceptance_sub.sh @@ -1,6 +1,8 @@ #!/bin/bash +# shellcheck disable=SC2086 # generate a radial acceptance file +# shellcheck source=/dev/null # set observatory environmental variables source $EVNDISPSYS/setObservatory.sh VTS diff --git a/scripts/helper_scripts/IRF.trainTMVAforAngularReconstruction_sub.sh b/scripts/helper_scripts/IRF.trainTMVAforAngularReconstruction_sub.sh index 23e691fd..e7dd3260 100755 --- a/scripts/helper_scripts/IRF.trainTMVAforAngularReconstruction_sub.sh +++ b/scripts/helper_scripts/IRF.trainTMVAforAngularReconstruction_sub.sh @@ -1,9 +1,10 @@ #!/bin/bash -# shellcheck disable=SC2034 +# shellcheck disable=SC2034,SC2086 # 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 @@ -42,13 +43,13 @@ 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 + 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 diff --git a/scripts/helper_scripts/IRF.trainTMVAforGammaHadronSeparation_sub.sh b/scripts/helper_scripts/IRF.trainTMVAforGammaHadronSeparation_sub.sh index 4c0a4fdc..3dc2d37c 100755 --- a/scripts/helper_scripts/IRF.trainTMVAforGammaHadronSeparation_sub.sh +++ b/scripts/helper_scripts/IRF.trainTMVAforGammaHadronSeparation_sub.sh @@ -1,5 +1,5 @@ #!/bin/bash -# shellcheck disable=SC2034 +# shellcheck disable=SC2034,SC2086 # script to train TMVA (BDTs) for gamma/hadron separation RXPAR=RUNPARAM @@ -9,6 +9,7 @@ ODIR=OUTPUTDIR # set observatory environmental variables if [ ! -n "$EVNDISP_APPTAINER" ]; then +# shellcheck source=/dev/null source "$EVNDISPSYS"/setObservatory.sh VTS fi diff --git a/scripts/helper_scripts/SPANALYSIS.lowgainped_sub.sh b/scripts/helper_scripts/SPANALYSIS.lowgainped_sub.sh index f06f1c4b..f4f84376 100755 --- a/scripts/helper_scripts/SPANALYSIS.lowgainped_sub.sh +++ b/scripts/helper_scripts/SPANALYSIS.lowgainped_sub.sh @@ -1,6 +1,8 @@ #!/bin/bash +# shellcheck disable=SC2086 # script to analyse VTS raw files (VBF) with eventdisplay +# shellcheck source=/dev/null # set observatory environmental variables source $EVNDISPSYS/setObservatory.sh VTS diff --git a/scripts/helper_scripts/SPANALYSIS.make_DST_sub.sh b/scripts/helper_scripts/SPANALYSIS.make_DST_sub.sh index 15be9bea..c7ab48ed 100755 --- a/scripts/helper_scripts/SPANALYSIS.make_DST_sub.sh +++ b/scripts/helper_scripts/SPANALYSIS.make_DST_sub.sh @@ -1,8 +1,9 @@ #!/bin/bash -# shellcheck disable=SC2034 +# shellcheck disable=SC2034,SC2086 # script to make DSTs # set observatory environmental variables +# shellcheck source=/dev/null source $EVNDISPSYS/setObservatory.sh VTS # parameters replaced by parent script using sed diff --git a/scripts/helper_scripts/UTILITY.check_root_file_closed.sh b/scripts/helper_scripts/UTILITY.check_root_file_closed.sh index 9650c299..7c3f9d8d 100755 --- a/scripts/helper_scripts/UTILITY.check_root_file_closed.sh +++ b/scripts/helper_scripts/UTILITY.check_root_file_closed.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 #### checks if a root file has been properly closed. diff --git a/scripts/helper_scripts/UTILITY.condorSubmission.sh b/scripts/helper_scripts/UTILITY.condorSubmission.sh index 7e95a938..e6cd96a9 100755 --- a/scripts/helper_scripts/UTILITY.condorSubmission.sh +++ b/scripts/helper_scripts/UTILITY.condorSubmission.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # prepare a condor job submission file if [ "$1" = "-h" ]; then diff --git a/scripts/helper_scripts/UTILITY.readSubmissionCommand.sh b/scripts/helper_scripts/UTILITY.readSubmissionCommand.sh index b6683925..61d9b735 100755 --- a/scripts/helper_scripts/UTILITY.readSubmissionCommand.sh +++ b/scripts/helper_scripts/UTILITY.readSubmissionCommand.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # script to read submission command from a parameter file if [ "$1" = "-h" ]; then @@ -29,11 +30,11 @@ fi # Use submission command with * in front; if multiple commands have an *, # the command that is farthest down in the file will be used -while read STAR LINE; do +while read -r STAR LINE; do if [[ $STAR = "*" ]]; then CMD=$LINE fi -done < $CMDFILE +done < "$CMDFILE" if [[ -z "$CMD" ]]; then echo "ERROR! No submission command is selected in $CMDFILE." diff --git a/scripts/helper_scripts/UTILITY.script_init.sh b/scripts/helper_scripts/UTILITY.script_init.sh index f9789de8..b5a3a704 100755 --- a/scripts/helper_scripts/UTILITY.script_init.sh +++ b/scripts/helper_scripts/UTILITY.script_init.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # simple script to make sure environmental variables are set correctly # Check that the EVNDISP environmental variables are set @@ -23,6 +24,7 @@ if [[ -z $VERITAS_USER_LOG_DIR ]]; then exit 1 fi +# shellcheck source=/dev/null # set the right observatory (environmental variables) source $EVNDISPSYS/setObservatory.sh VTS -q diff --git a/scripts/helper_scripts/submit_scripts_to_htcondor.sh b/scripts/helper_scripts/submit_scripts_to_htcondor.sh index 6b1a6328..6434c38f 100755 --- a/scripts/helper_scripts/submit_scripts_to_htcondor.sh +++ b/scripts/helper_scripts/submit_scripts_to_htcondor.sh @@ -1,4 +1,5 @@ #!/bin/sh +# shellcheck disable=SC2086 # # submit a list of scripts to HTCondor job submission system # diff --git a/scripts/preprocessing/archive_error_files.sh b/scripts/preprocessing/archive_error_files.sh index 1a4aab43..e5906712 100755 --- a/scripts/preprocessing/archive_error_files.sh +++ b/scripts/preprocessing/archive_error_files.sh @@ -1,5 +1,5 @@ #!/bin/bash -# shellcheck disable=SC2034 +# shellcheck disable=SC2034,SC2086 # Move Eventdisplay data products from all stages # into an runs_with_issues directory. # runs are given in a run list 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 dbb42b1c..afb82cec 100755 --- a/scripts/preprocessing/check_dl3_number_of_files_per_cut.sh +++ b/scripts/preprocessing/check_dl3_number_of_files_per_cut.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # Check the number of files DL3 processing if [ ! -n "$1" ] || [ "$1" = "-h" ]; then echo " diff --git a/scripts/preprocessing/check_epochs_for_3tel_irfs.sh b/scripts/preprocessing/check_epochs_for_3tel_irfs.sh index da6abb36..a09fdbe7 100755 --- a/scripts/preprocessing/check_epochs_for_3tel_irfs.sh +++ b/scripts/preprocessing/check_epochs_for_3tel_irfs.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # Read mscw log files and derive epoch lists for summer / winter if [ ! -n "$1" ]; then diff --git a/scripts/preprocessing/check_evndisp_mscw_processing.sh b/scripts/preprocessing/check_evndisp_mscw_processing.sh index 8b10dcb8..2b57765b 100755 --- a/scripts/preprocessing/check_evndisp_mscw_processing.sh +++ b/scripts/preprocessing/check_evndisp_mscw_processing.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # Check if runs read from a run list are processed already with # evndisp or mscw files # diff --git a/scripts/preprocessing/pack_data_files.sh b/scripts/preprocessing/pack_data_files.sh index 22efa92a..ad5581ec 100755 --- a/scripts/preprocessing/pack_data_files.sh +++ b/scripts/preprocessing/pack_data_files.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # Prepare Eventdisplay data products of a certain # type from a run list into tar balls # diff --git a/scripts/preprocessing/pack_log_files.sh b/scripts/preprocessing/pack_log_files.sh index 58a0710d..1b12c599 100755 --- a/scripts/preprocessing/pack_log_files.sh +++ b/scripts/preprocessing/pack_log_files.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # Pack log files in production directories into # individual tar ball depending on the data level # diff --git a/scripts/preprocessing/prepare_runlist_after_dqm.sh b/scripts/preprocessing/prepare_runlist_after_dqm.sh index 950e4aa1..4220710a 100755 --- a/scripts/preprocessing/prepare_runlist_after_dqm.sh +++ b/scripts/preprocessing/prepare_runlist_after_dqm.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # Prepare run lists and time cuts using the # DQM information. # @@ -153,7 +154,7 @@ 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 diff --git a/scripts/preprocessing/prepro_check_and_clean_files.sh b/scripts/preprocessing/prepro_check_and_clean_files.sh index 5e43ad27..4ba9f360 100755 --- a/scripts/preprocessing/prepro_check_and_clean_files.sh +++ b/scripts/preprocessing/prepro_check_and_clean_files.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 if [ $# -lt 1 ]; then echo " ./prepro_check_and_clean_files.sh @@ -64,7 +65,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 2429454b..ebf43da1 100755 --- a/scripts/preprocessing/prepro_move_preprocessed_files.sh +++ b/scripts/preprocessing/prepro_move_preprocessed_files.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 if [ $# -lt 1 ]; then echo " ./prepro_move_preprocessed_files.sh @@ -23,7 +24,7 @@ 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/ diff --git a/scripts/preprocessing/prepro_move_v2dl3_files.sh b/scripts/preprocessing/prepro_move_v2dl3_files.sh index 3133978a..f68ae7c3 100755 --- a/scripts/preprocessing/prepro_move_v2dl3_files.sh +++ b/scripts/preprocessing/prepro_move_v2dl3_files.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 if [ $# -lt 2 ]; then echo " ./prepro_move_preprocessed_files.sh @@ -21,7 +22,7 @@ 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}/ diff --git a/scripts/preprocessing/prepro_pack_dl3_directories.sh b/scripts/preprocessing/prepro_pack_dl3_directories.sh index 18512203..a85bb7ef 100755 --- a/scripts/preprocessing/prepro_pack_dl3_directories.sh +++ b/scripts/preprocessing/prepro_pack_dl3_directories.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # Pack dl3 directories into tar packages # diff --git a/scripts/preprocessing/prepro_rsync_data_ucla.sh b/scripts/preprocessing/prepro_rsync_data_ucla.sh index d44c8ede..139696db 100755 --- a/scripts/preprocessing/prepro_rsync_data_ucla.sh +++ b/scripts/preprocessing/prepro_rsync_data_ucla.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # Sync pre-processed Eventdisplay data with UCLA # This includes Eventdisplay data products diff --git a/scripts/preprocessing/prepro_rsync_db_ucla.sh b/scripts/preprocessing/prepro_rsync_db_ucla.sh index 67924208..60b49c84 100755 --- a/scripts/preprocessing/prepro_rsync_db_ucla.sh +++ b/scripts/preprocessing/prepro_rsync_db_ucla.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # Sync pre-processed DBFITS and DBTEXT files with UCLA if [ ! -n "$1" ] || [ "$1" = "-h" ]; then diff --git a/scripts/preprocessing/print_dqm_string_from_runlist.sh b/scripts/preprocessing/print_dqm_string_from_runlist.sh index a1eb43e2..7974a75c 100755 --- a/scripts/preprocessing/print_dqm_string_from_runlist.sh +++ b/scripts/preprocessing/print_dqm_string_from_runlist.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # Print DQM information in one single line # for each run using DBText files # diff --git a/scripts/preprocessing/print_processed_runstatistics.sh b/scripts/preprocessing/print_processed_runstatistics.sh index 254cddc8..063bd226 100755 --- a/scripts/preprocessing/print_processed_runstatistics.sh +++ b/scripts/preprocessing/print_processed_runstatistics.sh @@ -1,5 +1,5 @@ #!/bin/bash -# shellcheck disable=SC2034 +# shellcheck disable=SC2034,SC2086 # Print processed run statistics for the different # stages of Eventdisplay diff --git a/scripts/preprocessing/processing_dqm.sh b/scripts/preprocessing/processing_dqm.sh index 57c7270b..0df932b6 100755 --- a/scripts/preprocessing/processing_dqm.sh +++ b/scripts/preprocessing/processing_dqm.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 # Error checks in log files for preprocessing # @@ -19,9 +20,9 @@ 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 "--------------------" @@ -46,7 +47,7 @@ check_evndisp_log_files() 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 "Errors in mscw log files:" diff --git a/scripts/set_environment.sh b/scripts/set_environment.sh index 14fce01a..f1a57eee 100755 --- a/scripts/set_environment.sh +++ b/scripts/set_environment.sh @@ -73,11 +73,13 @@ elif [[ $PROCESS == "al9" ]]; then 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 From 473d21a347acd141ea60e089c50fb4990db22208 Mon Sep 17 00:00:00 2001 From: Gernot Maier Date: Sun, 31 May 2026 09:33:43 +0200 Subject: [PATCH 2/4] Shellcheck info fixes --- scripts/ANALYSIS.anasum.sh | 13 +++--- scripts/ANALYSIS.anasum_combine.sh | 11 +++-- scripts/ANALYSIS.anasum_link_files.sh | 7 ++- .../ANALYSIS.anasum_parallel_from_runlist.sh | 13 +++--- scripts/ANALYSIS.dispXGB.sh | 6 +-- scripts/ANALYSIS.evndisp.sh | 23 +++++----- scripts/ANALYSIS.evndisp_laser.sh | 13 +++--- scripts/ANALYSIS.evndisp_muon.sh | 17 ++++--- scripts/ANALYSIS.mscw_energy.sh | 11 +++-- scripts/ANALYSIS.v2dl3.sh | 8 ++-- scripts/IRF.combine_effective_area_parts.sh | 9 ++-- scripts/IRF.combine_lookup_table_parts.sh | 9 ++-- scripts/IRF.compress_evndisp_MC.sh | 17 ++++--- scripts/IRF.dispXGB.sh | 6 +-- scripts/IRF.evndisp_MC.sh | 5 +-- ...generate_NOISEfiles_from_PedestalEvents.sh | 2 +- scripts/IRF.generate_effective_area_parts.sh | 5 +-- scripts/IRF.generate_lookup_table_parts.sh | 5 +-- scripts/IRF.generate_radial_acceptance.sh | 15 +++---- scripts/IRF.mscw_energy_MC.sh | 5 +-- ...RF.optimizeTMVAforGammaHadronSeparation.sh | 29 ++++++------ scripts/IRF.production.sh | 7 ++- ...ectRunsForGammaHadronSeparationTraining.sh | 4 +- .../IRF.trainTMVAforAngularReconstruction.sh | 7 ++- .../IRF.trainTMVAforGammaHadronSeparation.sh | 45 +++++++++---------- ....trainXGBforAngularReconstructionBinned.sh | 7 ++- ...rainXGBforGammaHadronSeparationTraining.sh | 9 ++-- scripts/RUNLIST.findBackgroundRuns.sh | 7 ++- scripts/RUNLIST.findDBSourceCoordinates.sh | 8 ++-- scripts/RUNLIST.findDBSourceNames.sh | 5 +-- scripts/RUNLIST.generate.sh | 5 +-- scripts/RUNLIST.preprocessing.sh | 5 +-- scripts/RUNLIST.whichRunsAreArrayEpoch.sh | 12 ++--- scripts/RUNLIST.whichRunsAreAtmosphere.sh | 20 ++++----- scripts/RUNLIST.whichRunsAreObservingMode.sh | 12 ++--- scripts/RUNLIST.whichRunsAreOnDisk.sh | 24 +++++----- scripts/RUNLIST.whichRunsAreSource.sh | 24 +++++----- scripts/RUNLIST.whichRunsAreWobble.sh | 18 ++++---- scripts/SPANALYSIS.evndisp_laser_run.sh | 7 ++- ...LYSIS.evndisp_laser_runs_from_calibfile.sh | 7 ++- ...NALYSIS.evndisp_laser_runs_from_runlist.sh | 11 +++-- scripts/SPANALYSIS.evndisp_pedestal_events.sh | 3 +- scripts/SPANALYSIS.evndisp_tzeros.sh | 5 +-- scripts/SPANALYSIS.lowgainped.sh | 15 +++---- scripts/SPANALYSIS.make_DST.sh | 11 +++-- .../UTILITY.downloadSoundingDatafromUWYO.sh | 4 +- scripts/db_scripts/db_mysqldb.sh | 2 +- scripts/db_scripts/db_run.sh | 6 +-- .../ANALYSIS.anasum_combine_sub.sh | 10 +++-- scripts/helper_scripts/ANALYSIS.anasum_sub.sh | 16 ++++--- .../helper_scripts/ANALYSIS.evndisp_sub.sh | 6 +-- .../ANALYSIS.mscw_energy_sub.sh | 20 +++++---- scripts/helper_scripts/ANALYSIS.v2dl3_sub.sh | 4 +- .../IRF.compress_evndisp_MC_sub.sh | 2 +- .../IRF.effective_area_combine_sub.sh | 2 +- .../IRF.effective_area_parallel_sub.sh | 8 ++-- scripts/helper_scripts/IRF.evndisp_MC_sub.sh | 8 ++-- .../IRF.lookup_table_combine_sub.sh | 2 +- .../IRF.lookup_table_parallel_sub.sh | 2 +- .../helper_scripts/IRF.mscw_energy_MC_sub.sh | 4 +- ...F.trainTMVAforGammaHadronSeparation_sub.sh | 4 +- .../UTILITY.check_root_file_closed.sh | 3 +- .../submit_scripts_to_htcondor.sh | 26 ++++++----- scripts/preprocessing/archive_error_files.sh | 2 +- scripts/set_environment.sh | 2 +- 65 files changed, 309 insertions(+), 331 deletions(-) diff --git a/scripts/ANALYSIS.anasum.sh b/scripts/ANALYSIS.anasum.sh index a00688ad..607c4217 100755 --- a/scripts/ANALYSIS.anasum.sh +++ b/scripts/ANALYSIS.anasum.sh @@ -38,8 +38,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 @@ -56,7 +55,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 @@ -65,7 +64,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" @@ -77,7 +76,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|" \ @@ -91,13 +90,13 @@ 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` + JOBID=$($SUBC $FSCRIPT.sh) # account for -terse changing the job number format if [[ $SUBC != *-terse* ]] ; then diff --git a/scripts/ANALYSIS.anasum_combine.sh b/scripts/ANALYSIS.anasum_combine.sh index ac844290..4d36bb77 100755 --- a/scripts/ANALYSIS.anasum_combine.sh +++ b/scripts/ANALYSIS.anasum_combine.sh @@ -40,9 +40,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 @@ -58,7 +57,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 @@ -67,7 +66,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" @@ -86,13 +85,13 @@ 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` + 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 diff --git a/scripts/ANALYSIS.anasum_link_files.sh b/scripts/ANALYSIS.anasum_link_files.sh index d856f972..0efc8d11 100755 --- a/scripts/ANALYSIS.anasum_link_files.sh +++ b/scripts/ANALYSIS.anasum_link_files.sh @@ -26,8 +26,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 @@ -55,8 +54,8 @@ getNumberedDirectory() 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 diff --git a/scripts/ANALYSIS.anasum_parallel_from_runlist.sh b/scripts/ANALYSIS.anasum_parallel_from_runlist.sh index 707dd5b0..ff7b7b06 100755 --- a/scripts/ANALYSIS.anasum_parallel_from_runlist.sh +++ b/scripts/ANALYSIS.anasum_parallel_from_runlist.sh @@ -63,9 +63,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 @@ -202,7 +201,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 @@ -211,7 +210,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" @@ -222,7 +221,7 @@ mkdir -p "$ODIR" # Job submission script SUBSCRIPT="$(dirname "$0")/helper_scripts/ANALYSIS.anasum_sub" -TIMETAG=`date +"%s"` +TIMETAG=$(date +"%s") # directory schema getNumberedDirectory() @@ -295,13 +294,13 @@ 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` + 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 diff --git a/scripts/ANALYSIS.dispXGB.sh b/scripts/ANALYSIS.dispXGB.sh index a3b2aace..d7922a27 100755 --- a/scripts/ANALYSIS.dispXGB.sh +++ b/scripts/ANALYSIS.dispXGB.sh @@ -51,7 +51,7 @@ 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" @@ -59,7 +59,7 @@ 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 @@ -77,7 +77,7 @@ do 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/ANALYSIS.evndisp.sh b/scripts/ANALYSIS.evndisp.sh index 88761ba2..25dc2a45 100755 --- a/scripts/ANALYSIS.evndisp.sh +++ b/scripts/ANALYSIS.evndisp.sh @@ -66,9 +66,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 @@ -112,13 +111,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" @@ -127,7 +126,7 @@ 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 @@ -255,7 +254,7 @@ do fi if [[ $SUBC == *qsub* ]]; then - JOBID=`$SUBC $FSCRIPT.sh` + 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 @@ -299,10 +298,12 @@ if [[ $SUBC == *parallel* ]]; then 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 + { + echo "echo \"==================================\"" + echo "echo \"List of scripts to run\"" + cat $LOGDIR/runscripts.sh | sort -u | awk "{print \$1}" | sed 's/.*/echo \" & \"/' + echo "cat $LOGDIR/runscripts.sh | sort -u | $SUBC" + } >> Run_me.sh chmod +x Run_me.sh # shellcheck source=/dev/null source Run_me.sh diff --git a/scripts/ANALYSIS.evndisp_laser.sh b/scripts/ANALYSIS.evndisp_laser.sh index 2a4b2d3a..7db3980c 100755 --- a/scripts/ANALYSIS.evndisp_laser.sh +++ b/scripts/ANALYSIS.evndisp_laser.sh @@ -34,8 +34,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 @@ -48,12 +47,12 @@ 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 # 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 @@ -65,7 +64,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 @@ -91,9 +90,9 @@ for RUN in $RUNNUMS; 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` + JOBID=$($SUBC $FSCRIPT.sh) # account for -terse changing the job number format if [[ $SUBC != *-terse* ]] ; then diff --git a/scripts/ANALYSIS.evndisp_muon.sh b/scripts/ANALYSIS.evndisp_muon.sh index f52737c3..29358d62 100755 --- a/scripts/ANALYSIS.evndisp_muon.sh +++ b/scripts/ANALYSIS.evndisp_muon.sh @@ -7,7 +7,7 @@ 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 @@ -67,8 +67,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 @@ -110,19 +109,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 # 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 @@ -172,9 +171,9 @@ 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` + 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 diff --git a/scripts/ANALYSIS.mscw_energy.sh b/scripts/ANALYSIS.mscw_energy.sh index 7c948cd2..37b25fd7 100755 --- a/scripts/ANALYSIS.mscw_energy.sh +++ b/scripts/ANALYSIS.mscw_energy.sh @@ -48,9 +48,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 @@ -80,14 +79,14 @@ 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() @@ -155,10 +154,10 @@ do # 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` + 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 diff --git a/scripts/ANALYSIS.v2dl3.sh b/scripts/ANALYSIS.v2dl3.sh index 50ae695c..dccca639 100755 --- a/scripts/ANALYSIS.v2dl3.sh +++ b/scripts/ANALYSIS.v2dl3.sh @@ -52,7 +52,7 @@ 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" @@ -69,7 +69,7 @@ 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 @@ -87,13 +87,13 @@ 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` + 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 diff --git a/scripts/IRF.combine_effective_area_parts.sh b/scripts/IRF.combine_effective_area_parts.sh index d90a2f11..342317da 100755 --- a/scripts/IRF.combine_effective_area_parts.sh +++ b/scripts/IRF.combine_effective_area_parts.sh @@ -46,9 +46,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") @@ -65,7 +64,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} @@ -140,13 +139,13 @@ 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` + JOBID=$($SUBC $FSCRIPT.sh) echo "JOBID: $JOBID" elif [[ $SUBC == *condor* ]]; then "$(dirname "$0")/helper_scripts/UTILITY.condorSubmission.sh" "$FSCRIPT.sh" "$h_vmem" "$tmpdir_size" diff --git a/scripts/IRF.combine_lookup_table_parts.sh b/scripts/IRF.combine_lookup_table_parts.sh index 832987ec..67c90f26 100755 --- a/scripts/IRF.combine_lookup_table_parts.sh +++ b/scripts/IRF.combine_lookup_table_parts.sh @@ -41,9 +41,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") @@ -90,7 +89,7 @@ mkdir -p "$LOGDIR" FLIST=$OFILE.list rm -f "$ODIR/$FLIST" ls -1 $INDIR/*ID${RECID}.root > "$ODIR/$FLIST" -NFIL=`cat "$ODIR/$FLIST" | wc -l` +NFIL=$(cat "$ODIR/$FLIST" | wc -l) if [[ $NFIL = "0" ]]; then echo "No lookup table root files found" exit @@ -113,13 +112,13 @@ 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` + JOBID=$($SUBC $FSCRIPT.sh) echo "JOBID: $JOBID" elif [[ $SUBC == *condor* ]]; then "$(dirname "$0")/helper_scripts/UTILITY.condorSubmission.sh" "$FSCRIPT.sh" "$h_vmem" "$tmpdir_size" diff --git a/scripts/IRF.compress_evndisp_MC.sh b/scripts/IRF.compress_evndisp_MC.sh index ddfd6dd3..b70cc96c 100755 --- a/scripts/IRF.compress_evndisp_MC.sh +++ b/scripts/IRF.compress_evndisp_MC.sh @@ -49,13 +49,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 @@ -104,7 +103,7 @@ elif [ ${SIMTYPE:0:4} = "CARE" ]; then [[ ${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 @@ -207,7 +206,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" @@ -223,14 +222,14 @@ do 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` + 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" diff --git a/scripts/IRF.dispXGB.sh b/scripts/IRF.dispXGB.sh index dcdb590e..bfc9df0f 100755 --- a/scripts/IRF.dispXGB.sh +++ b/scripts/IRF.dispXGB.sh @@ -51,7 +51,7 @@ 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="$(dirname $INPUTDIR)/submit-XGB-${XGB_TYPE}-${DATE}-$(uuidgen)/" mkdir -p "$LOGDIR" echo -e "Log files will be written to:\n $LOGDIR" @@ -59,7 +59,7 @@ rm -f ${LOGDIR}/x* 2>/dev/null # Job submission script SUBSCRIPT="$(dirname "$0")/helper_scripts/IRF.dispXGB_sub" -TIMETAG=`date +"%s"` +TIMETAG=$(date +"%s") for FILE in $FILES do @@ -77,7 +77,7 @@ do 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 11d3c789..85ae4878 100755 --- a/scripts/IRF.evndisp_MC.sh +++ b/scripts/IRF.evndisp_MC.sh @@ -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 SIMDIR="$1" @@ -196,7 +195,7 @@ touch "${FSCRIPT}.txt" for V in $VBFNAME; do echo "$RUNNUM $(basename $V)" >> "${FSCRIPT}.txt" - let "RUNNUM = ${RUNNUM} + 100" + (( RUNNUM += 100 )) done # Job submission script diff --git a/scripts/IRF.generate_NOISEfiles_from_PedestalEvents.sh b/scripts/IRF.generate_NOISEfiles_from_PedestalEvents.sh index 1a1e9a90..1a63b910 100755 --- a/scripts/IRF.generate_NOISEfiles_from_PedestalEvents.sh +++ b/scripts/IRF.generate_NOISEfiles_from_PedestalEvents.sh @@ -16,7 +16,7 @@ # - length of noise traces ############################################################## # EventDisplay version -EDVERSION=`$EVNDISPSYS/bin/evndisp --version | tr -d .` +EDVERSION=$($EVNDISPSYS/bin/evndisp --version | tr -d .) if [[ $EDVERSION = "v4"* ]]; then echo "Noise file writer not implemented for Eventdisplay version $EDVERSION" exit diff --git a/scripts/IRF.generate_effective_area_parts.sh b/scripts/IRF.generate_effective_area_parts.sh index 522e6342..08cd53fc 100755 --- a/scripts/IRF.generate_effective_area_parts.sh +++ b/scripts/IRF.generate_effective_area_parts.sh @@ -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 CUTSFILE="$1" EPOCH="$2" @@ -127,7 +126,7 @@ if [[ $SUBC == *"ERROR"* ]]; then exit 1 fi if [[ $SUBC == *qsub* ]]; then - JOBID=`$SUBC $FSCRIPT` + JOBID=$($SUBC $FSCRIPT) echo "JOBID: $JOBID" elif [[ $SUBC == *condor* ]]; then "$(dirname "$0")/helper_scripts/UTILITY.condorSubmission.sh" "$FSCRIPT" "$h_vmem" "$tmpdir_size" diff --git a/scripts/IRF.generate_lookup_table_parts.sh b/scripts/IRF.generate_lookup_table_parts.sh index b34350e0..0d71cfe7 100755 --- a/scripts/IRF.generate_lookup_table_parts.sh +++ b/scripts/IRF.generate_lookup_table_parts.sh @@ -48,9 +48,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" @@ -114,7 +113,7 @@ if [[ $SUBC == *"ERROR"* ]]; then exit 1 fi if [[ $SUBC == *qsub* ]]; then - JOBID=`$SUBC $FSCRIPT` + JOBID=$($SUBC $FSCRIPT) echo "JOBID: $JOBID" elif [[ $SUBC == *condor* ]]; then "$(dirname "$0")/helper_scripts/UTILITY.condorSubmission.sh" "$FSCRIPT" "$h_vmem" "$tmpdir_size" diff --git a/scripts/IRF.generate_radial_acceptance.sh b/scripts/IRF.generate_radial_acceptance.sh index f14bd2df..250611a8 100755 --- a/scripts/IRF.generate_radial_acceptance.sh +++ b/scripts/IRF.generate_radial_acceptance.sh @@ -50,8 +50,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 @@ -61,7 +60,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" @@ -82,7 +81,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" @@ -111,7 +110,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 @@ -121,7 +120,7 @@ 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} @@ -153,14 +152,14 @@ for CUTS in "${CUTLIST[@]}"; do # 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 exit fi if [[ $SUBC == *qsub* ]]; then echo "$SUBC" "$FSCRIPT.sh" - JOBID=`$SUBC $FSCRIPT.sh` + JOBID=$($SUBC $FSCRIPT.sh) echo "JOBID: $JOBID" elif [[ $SUBC == *condor* ]]; then "$(dirname "$0")/helper_scripts/UTILITY.condorSubmission.sh" "$FSCRIPT.sh" "$h_vmem" "$tmpdir_size" diff --git a/scripts/IRF.mscw_energy_MC.sh b/scripts/IRF.mscw_energy_MC.sh index 96080500..ff3771e1 100755 --- a/scripts/IRF.mscw_energy_MC.sh +++ b/scripts/IRF.mscw_energy_MC.sh @@ -56,9 +56,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" @@ -139,7 +138,7 @@ if [[ $SUBC == *"ERROR"* ]]; then exit 1 fi if [[ $SUBC == *qsub* ]]; then - JOBID=`$SUBC $FSCRIPT` + JOBID=$($SUBC $FSCRIPT) echo "JOBID: $JOBID" elif [[ $SUBC == *condor* ]]; then "$(dirname "$0")/helper_scripts/UTILITY.condorSubmission.sh" "$FSCRIPT" "$h_vmem" "$tmpdir_size" diff --git a/scripts/IRF.optimizeTMVAforGammaHadronSeparation.sh b/scripts/IRF.optimizeTMVAforGammaHadronSeparation.sh index 83c81935..48f249c3 100755 --- a/scripts/IRF.optimizeTMVAforGammaHadronSeparation.sh +++ b/scripts/IRF.optimizeTMVAforGammaHadronSeparation.sh @@ -33,8 +33,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 @@ -62,7 +61,7 @@ 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 @@ -95,23 +94,23 @@ 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++ )) + 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=$( 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 + 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 @@ -120,7 +119,7 @@ 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" @@ -140,13 +139,13 @@ 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 exit fi if [[ $SUBC == *qsub* ]]; then - JOBID=`$SUBC $FSCRIPT.sh` + 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 diff --git a/scripts/IRF.production.sh b/scripts/IRF.production.sh index 5f649ef7..4400f9f5 100755 --- a/scripts/IRF.production.sh +++ b/scripts/IRF.production.sh @@ -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 @@ -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 =====" diff --git a/scripts/IRF.selectRunsForGammaHadronSeparationTraining.sh b/scripts/IRF.selectRunsForGammaHadronSeparationTraining.sh index 8ce139dd..8196efd5 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 @@ -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 5a1f90cb..c5b23286 100755 --- a/scripts/IRF.trainTMVAforAngularReconstruction.sh +++ b/scripts/IRF.trainTMVAforAngularReconstruction.sh @@ -45,9 +45,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" @@ -137,13 +136,13 @@ 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` + JOBID=$($SUBC $FSCRIPT) echo "RUN $RUNNUM: JOBID $JOBID" elif [[ $SUBC == *condor* ]]; then "$(dirname "$0")/helper_scripts/UTILITY.condorSubmission.sh" "$FSCRIPT" "$h_vmem" "$tmpdir_size" diff --git a/scripts/IRF.trainTMVAforGammaHadronSeparation.sh b/scripts/IRF.trainTMVAforGammaHadronSeparation.sh index 03c256c7..cdb7262d 100755 --- a/scripts/IRF.trainTMVAforGammaHadronSeparation.sh +++ b/scripts/IRF.trainTMVAforGammaHadronSeparation.sh @@ -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 BDIR="$1" RUNPAR="$2" @@ -86,7 +85,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 @@ -94,7 +93,7 @@ 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}" @@ -113,23 +112,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 @@ -138,7 +137,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 @@ -163,15 +162,15 @@ 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" @@ -185,11 +184,11 @@ do 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 { diff --git a/scripts/IRF.trainXGBforAngularReconstructionBinned.sh b/scripts/IRF.trainXGBforAngularReconstructionBinned.sh index c438506e..293fac62 100755 --- a/scripts/IRF.trainXGBforAngularReconstructionBinned.sh +++ b/scripts/IRF.trainXGBforAngularReconstructionBinned.sh @@ -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 EPOCH="$1" ATM="$2" @@ -114,13 +113,13 @@ 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 exit fi if [[ $SUBC == *qsub* ]]; then - JOBID=`$SUBC $FSCRIPT` + JOBID=$($SUBC $FSCRIPT) echo "RUN $RUNNUM: JOBID $JOBID" elif [[ $SUBC == *condor* ]]; then "$(dirname "$0")/helper_scripts/UTILITY.condorSubmission.sh" "$FSCRIPT" "$h_vmem" "$tmpdir_size" diff --git a/scripts/IRF.trainXGBforGammaHadronSeparationTraining.sh b/scripts/IRF.trainXGBforGammaHadronSeparationTraining.sh index f6c4f09d..e68eee07 100755 --- a/scripts/IRF.trainXGBforGammaHadronSeparationTraining.sh +++ b/scripts/IRF.trainXGBforGammaHadronSeparationTraining.sh @@ -38,9 +38,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" @@ -78,7 +77,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 @@ -149,7 +148,7 @@ echo "Background file list: $BCKLIST" rm -f "${BCKLIST}" touch "${BCKLIST}" tmpfile=$(mktemp) -for ((i=0; i<${NEZE}; i++)); do +for ((i=0; i" ; 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." @@ -27,7 +27,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 | grep -E -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.findDBSourceNames.sh b/scripts/RUNLIST.findDBSourceNames.sh index e0e879a0..b53f4199 100755 --- a/scripts/RUNLIST.findDBSourceNames.sh +++ b/scripts/RUNLIST.findDBSourceNames.sh @@ -42,15 +42,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 | grep -E -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 60a96179..58c65aab 100755 --- a/scripts/RUNLIST.generate.sh +++ b/scripts/RUNLIST.generate.sh @@ -46,8 +46,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 @@ -79,7 +78,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 | grep -E -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 6ff778d3..353f7321 100755 --- a/scripts/RUNLIST.preprocessing.sh +++ b/scripts/RUNLIST.preprocessing.sh @@ -25,8 +25,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" @@ -42,7 +41,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 | grep -E -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 9da18340..833f0641 100755 --- a/scripts/RUNLIST.whichRunsAreArrayEpoch.sh +++ b/scripts/RUNLIST.whichRunsAreArrayEpoch.sh @@ -4,19 +4,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 @@ -29,7 +29,7 @@ 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? diff --git a/scripts/RUNLIST.whichRunsAreAtmosphere.sh b/scripts/RUNLIST.whichRunsAreAtmosphere.sh index 86d9f171..a9f50ac9 100755 --- a/scripts/RUNLIST.whichRunsAreAtmosphere.sh +++ b/scripts/RUNLIST.whichRunsAreAtmosphere.sh @@ -3,18 +3,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 @@ -27,12 +27,12 @@ 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 '[:upper:]' '[:lower:]'` # 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 @@ -140,7 +140,7 @@ function badAtmosphere { } # get database url from parameter file -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}'` +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!" @@ -156,7 +156,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 @@ -178,7 +178,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 d7475532..56c4f002 100755 --- a/scripts/RUNLIST.whichRunsAreObservingMode.sh +++ b/scripts/RUNLIST.whichRunsAreObservingMode.sh @@ -3,15 +3,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" @@ -28,13 +28,13 @@ 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" | grep -E -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!" @@ -50,7 +50,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 a836ac91..6942f6cd 100755 --- a/scripts/RUNLIST.whichRunsAreOnDisk.sh +++ b/scripts/RUNLIST.whichRunsAreOnDisk.sh @@ -8,9 +8,9 @@ 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'" +#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 @@ -22,7 +22,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 @@ -43,7 +43,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 @@ -55,13 +55,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 @@ -73,7 +73,7 @@ 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..." @@ -83,7 +83,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 | grep -E -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 @@ -97,7 +97,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.whichRunsAreSource.sh b/scripts/RUNLIST.whichRunsAreSource.sh index ec01265e..990fec3e 100755 --- a/scripts/RUNLIST.whichRunsAreSource.sh +++ b/scripts/RUNLIST.whichRunsAreSource.sh @@ -10,7 +10,7 @@ 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 +25,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 +46,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 +59,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,27 +69,27 @@ 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 @@ -101,11 +101,11 @@ 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" | grep -E -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!" @@ -121,7 +121,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 429d7a93..18796a0e 100755 --- a/scripts/RUNLIST.whichRunsAreWobble.sh +++ b/scripts/RUNLIST.whichRunsAreWobble.sh @@ -5,18 +5,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 @@ -29,7 +29,7 @@ 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 @@ -37,7 +37,7 @@ SOUTFLAG=false EASTFLAG=false WESTFLAG=false -LOWARG=`echo "$1" | tr '[:upper:]' '[:lower:]'` # 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 @@ -45,7 +45,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" | grep -E -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!" @@ -61,7 +61,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 050fc1f2..1134b7dc 100755 --- a/scripts/SPANALYSIS.evndisp_laser_run.sh +++ b/scripts/SPANALYSIS.evndisp_laser_run.sh @@ -32,8 +32,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 @@ -51,7 +50,7 @@ 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 @@ -67,7 +66,7 @@ if [[ $RUNMODE == 2 ]]; then 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 diff --git a/scripts/SPANALYSIS.evndisp_laser_runs_from_calibfile.sh b/scripts/SPANALYSIS.evndisp_laser_runs_from_calibfile.sh index a6c0e0e3..21cc0208 100755 --- a/scripts/SPANALYSIS.evndisp_laser_runs_from_calibfile.sh +++ b/scripts/SPANALYSIS.evndisp_laser_runs_from_calibfile.sh @@ -20,8 +20,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 @@ -29,14 +28,14 @@ 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"` + DFILE=$(find -L $DDIR -name "$RUN.cvbf") if [[ -f $DFILE ]]; then "$(dirname "$0")/SPANALYSIS.evndisp_laser_run.sh" $DTEL $DFILE diff --git a/scripts/SPANALYSIS.evndisp_laser_runs_from_runlist.sh b/scripts/SPANALYSIS.evndisp_laser_runs_from_runlist.sh index b80b79ce..67892480 100755 --- a/scripts/SPANALYSIS.evndisp_laser_runs_from_runlist.sh +++ b/scripts/SPANALYSIS.evndisp_laser_runs_from_runlist.sh @@ -27,13 +27,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/" @@ -44,17 +43,17 @@ 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 else diff --git a/scripts/SPANALYSIS.evndisp_pedestal_events.sh b/scripts/SPANALYSIS.evndisp_pedestal_events.sh index 91da6790..df446a1a 100755 --- a/scripts/SPANALYSIS.evndisp_pedestal_events.sh +++ b/scripts/SPANALYSIS.evndisp_pedestal_events.sh @@ -27,8 +27,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 diff --git a/scripts/SPANALYSIS.evndisp_tzeros.sh b/scripts/SPANALYSIS.evndisp_tzeros.sh index 6eb6284e..378aba70 100755 --- a/scripts/SPANALYSIS.evndisp_tzeros.sh +++ b/scripts/SPANALYSIS.evndisp_tzeros.sh @@ -29,8 +29,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 @@ -41,7 +40,7 @@ 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 diff --git a/scripts/SPANALYSIS.lowgainped.sh b/scripts/SPANALYSIS.lowgainped.sh index c7a82a1b..c6fa0fa1 100755 --- a/scripts/SPANALYSIS.lowgainped.sh +++ b/scripts/SPANALYSIS.lowgainped.sh @@ -38,11 +38,10 @@ 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 .) # create extra stdout for duplication of command output # look for ">&5" below @@ -62,10 +61,10 @@ 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 @@ -73,7 +72,7 @@ mkdir -p $LOGDIR 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 @@ -106,14 +105,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 exit fi echo $SUBC if [[ $SUBC == *qsub* ]]; then - JOBID=`$SUBC $FSCRIPT.sh` + 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 diff --git a/scripts/SPANALYSIS.make_DST.sh b/scripts/SPANALYSIS.make_DST.sh index acf9b572..a13fe5b2 100755 --- a/scripts/SPANALYSIS.make_DST.sh +++ b/scripts/SPANALYSIS.make_DST.sh @@ -41,8 +41,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 @@ -57,10 +56,10 @@ 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 @@ -102,9 +101,9 @@ for RUN in $RUNNUMS; 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` + 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" diff --git a/scripts/UTILITY.downloadSoundingDatafromUWYO.sh b/scripts/UTILITY.downloadSoundingDatafromUWYO.sh index 05bb30e6..f61bc47f 100755 --- a/scripts/UTILITY.downloadSoundingDatafromUWYO.sh +++ b/scripts/UTILITY.downloadSoundingDatafromUWYO.sh @@ -27,11 +27,11 @@ 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]} diff --git a/scripts/db_scripts/db_mysqldb.sh b/scripts/db_scripts/db_mysqldb.sh index 215430e5..12412892 100755 --- a/scripts/db_scripts/db_mysqldb.sh +++ b/scripts/db_scripts/db_mysqldb.sh @@ -14,7 +14,7 @@ fi # get url of veritas db PARAFILE="${VERITAS_EVNDISP_AUX_DIR}/ParameterFiles/EVNDISP.global.runparameter" -MYSQLDB=`grep '^\*[ \t]*DBSERVER[ \t]*mysql://' ${PARAFILE} | grep -E -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_run.sh b/scripts/db_scripts/db_run.sh index e9f39576..ab8194c6 100755 --- a/scripts/db_scripts/db_run.sh +++ b/scripts/db_scripts/db_run.sh @@ -256,7 +256,7 @@ read_pixel_data() { read_run_from_DB L1_TriggerInfo - for (( j=0; j<${NTEL}; j++ )); + for (( j=0; j> ${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 \ diff --git a/scripts/helper_scripts/ANALYSIS.anasum_sub.sh b/scripts/helper_scripts/ANALYSIS.anasum_sub.sh index 0a9a8180..403549f5 100755 --- a/scripts/helper_scripts/ANALYSIS.anasum_sub.sh +++ b/scripts/helper_scripts/ANALYSIS.anasum_sub.sh @@ -140,11 +140,11 @@ if [[ $FLIST == "NOTDEFINED" ]]; then 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)}'`} + 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)}'` + TELTOANA=$(echo $RUNINFO | awk '{print "T"$(5)}') ATMO=$(prepare_atmo_string $ATMO $EPOCH $OBSL) @@ -231,9 +231,11 @@ $EVNDISPSYS/bin/anasum \ -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)" diff --git a/scripts/helper_scripts/ANALYSIS.evndisp_sub.sh b/scripts/helper_scripts/ANALYSIS.evndisp_sub.sh index 8b7831cb..0df444e6 100755 --- a/scripts/helper_scripts/ANALYSIS.evndisp_sub.sh +++ b/scripts/helper_scripts/ANALYSIS.evndisp_sub.sh @@ -188,7 +188,7 @@ if [[ $CALIB == "1" || $CALIB == "2" || $CALIB == "4" || $CALIB == "5" ]]; then -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 @@ -221,7 +221,7 @@ if [[ $CALIB == "1" || $CALIB == "3" || $CALIB == "4" || $CALIB == "5" ]]; then -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 @@ -256,7 +256,7 @@ LOGFILE="$LOGDIR/$RUN.log" -outputfile "$TEMPDIR/$RUN.root" \ "${OPT[@]}" \ -calibrationdirectory "$CALDIR" &> "$LOGFILE" - echo "$(inspect_executables)" >> "$LOGFILE" + inspect_executables >> "$LOGFILE" echo "RUN$RUN EVNDISPLOG $LOGFILE" fi diff --git a/scripts/helper_scripts/ANALYSIS.mscw_energy_sub.sh b/scripts/helper_scripts/ANALYSIS.mscw_energy_sub.sh index 8f3b9a9b..ad836f3f 100755 --- a/scripts/helper_scripts/ANALYSIS.mscw_energy_sub.sh +++ b/scripts/helper_scripts/ANALYSIS.mscw_energy_sub.sh @@ -35,8 +35,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 @@ -69,9 +69,9 @@ 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)}'` +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 @@ -205,16 +205,18 @@ $EVNDISPSYS/bin/mscw_energy \ -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} 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 diff --git a/scripts/helper_scripts/ANALYSIS.v2dl3_sub.sh b/scripts/helper_scripts/ANALYSIS.v2dl3_sub.sh index 7928cf73..0f1ea1ee 100755 --- a/scripts/helper_scripts/ANALYSIS.v2dl3_sub.sh +++ b/scripts/helper_scripts/ANALYSIS.v2dl3_sub.sh @@ -23,8 +23,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 diff --git a/scripts/helper_scripts/IRF.compress_evndisp_MC_sub.sh b/scripts/helper_scripts/IRF.compress_evndisp_MC_sub.sh index 5b7ed204..7693df38 100755 --- a/scripts/helper_scripts/IRF.compress_evndisp_MC_sub.sh +++ b/scripts/helper_scripts/IRF.compress_evndisp_MC_sub.sh @@ -34,7 +34,7 @@ compare_log_file() 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 diff --git a/scripts/helper_scripts/IRF.effective_area_combine_sub.sh b/scripts/helper_scripts/IRF.effective_area_combine_sub.sh index 493232a7..c8935cc2 100755 --- a/scripts/helper_scripts/IRF.effective_area_combine_sub.sh +++ b/scripts/helper_scripts/IRF.effective_area_combine_sub.sh @@ -56,5 +56,5 @@ echo "File list: $ODIR/$OFILE.list" $EVNDISPSYS/bin/combineEffectiveAreas "$OPTODIR/$OFILE.list" ${OPTODIR}/$OFILE DL3reduced &> ${ODIR}/$OFILE.log # log files -echo "$(inspect_executables)" >> "$ODIR/$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 999f6e45..b0e59606 100755 --- a/scripts/helper_scripts/IRF.effective_area_parallel_sub.sh +++ b/scripts/helper_scripts/IRF.effective_area_parallel_sub.sh @@ -67,14 +67,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" @@ -134,7 +134,7 @@ 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 diff --git a/scripts/helper_scripts/IRF.evndisp_MC_sub.sh b/scripts/helper_scripts/IRF.evndisp_MC_sub.sh index 807d3034..b5142e02 100755 --- a/scripts/helper_scripts/IRF.evndisp_MC_sub.sh +++ b/scripts/helper_scripts/IRF.evndisp_MC_sub.sh @@ -217,7 +217,7 @@ if [[ ${SIMTYPE:0:4} == "CARE" ]]; then 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" + inspect_executables >> "$ODIR/$RUNNUM.ped.log" if grep -Fq "END OF ANALYSIS, exiting" $ODIR/$RUNNUM.ped.log; then echo " successful pedestal analysis" @@ -239,7 +239,7 @@ if [[ ${SIMTYPE:0:5} = "GRISU" ]]; then 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" +inspect_executables &>> "$ODIR/$RUNNUM.tzero.log" if grep -Fq "END OF ANALYSIS, exiting" $ODIR/$RUNNUM.tzero.log; then echo " successful tzero analysis" @@ -267,7 +267,7 @@ fi 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" +inspect_executables >> "$ODIR/$ONAME.log" ################################################################################# # cleanup @@ -284,7 +284,7 @@ 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 diff --git a/scripts/helper_scripts/IRF.lookup_table_combine_sub.sh b/scripts/helper_scripts/IRF.lookup_table_combine_sub.sh index 308e1658..eb1d6d66 100755 --- a/scripts/helper_scripts/IRF.lookup_table_combine_sub.sh +++ b/scripts/helper_scripts/IRF.lookup_table_combine_sub.sh @@ -53,7 +53,7 @@ ls -1 "${DDIR}"/*.root > "$DDIR/$FLIST" $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" diff --git a/scripts/helper_scripts/IRF.lookup_table_parallel_sub.sh b/scripts/helper_scripts/IRF.lookup_table_parallel_sub.sh index bed5c442..046f2c82 100755 --- a/scripts/helper_scripts/IRF.lookup_table_parallel_sub.sh +++ b/scripts/helper_scripts/IRF.lookup_table_parallel_sub.sh @@ -103,6 +103,6 @@ $EVNDISPSYS/bin/mscw_energy -filltables=1 \ -arrayrecid=$RECID \ -woff=$WOBBLE &> "$logfile" -echo "$(inspect_executables)" >> "$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 a26d0b66..5cadcb0b 100755 --- a/scripts/helper_scripts/IRF.mscw_energy_MC_sub.sh +++ b/scripts/helper_scripts/IRF.mscw_energy_MC_sub.sh @@ -172,7 +172,7 @@ 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" @@ -363,7 +363,7 @@ PARAMFILE=" $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 echo "Filling mscwTableLog file into root file: $OSUBDIR/$EAPARAMS.log" diff --git a/scripts/helper_scripts/IRF.trainTMVAforGammaHadronSeparation_sub.sh b/scripts/helper_scripts/IRF.trainTMVAforGammaHadronSeparation_sub.sh index 3dc2d37c..8344ba4d 100755 --- a/scripts/helper_scripts/IRF.trainTMVAforGammaHadronSeparation_sub.sh +++ b/scripts/helper_scripts/IRF.trainTMVAforGammaHadronSeparation_sub.sh @@ -60,9 +60,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` +CDIR=$(dirname $RXPAR) rm -f -v "$CDIR"/$ONAME*.C diff --git a/scripts/helper_scripts/UTILITY.check_root_file_closed.sh b/scripts/helper_scripts/UTILITY.check_root_file_closed.sh index 7c3f9d8d..8be23fda 100755 --- a/scripts/helper_scripts/UTILITY.check_root_file_closed.sh +++ b/scripts/helper_scripts/UTILITY.check_root_file_closed.sh @@ -9,7 +9,6 @@ fi 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/submit_scripts_to_htcondor.sh b/scripts/helper_scripts/submit_scripts_to_htcondor.sh index 6434c38f..cbad3a54 100755 --- a/scripts/helper_scripts/submit_scripts_to_htcondor.sh +++ b/scripts/helper_scripts/submit_scripts_to_htcondor.sh @@ -32,20 +32,24 @@ if find "${JDIR}" -name "*.condor" -print -quit | grep -q .; then mkdir -p ${JDIR}/output mkdir -p ${JDIR}/error - echo "executable = \$(file)" >> ${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} + { + 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 diff --git a/scripts/preprocessing/archive_error_files.sh b/scripts/preprocessing/archive_error_files.sh index e5906712..ea8b5868 100755 --- a/scripts/preprocessing/archive_error_files.sh +++ b/scripts/preprocessing/archive_error_files.sh @@ -16,7 +16,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 diff --git a/scripts/set_environment.sh b/scripts/set_environment.sh index f1a57eee..9144f007 100755 --- a/scripts/set_environment.sh +++ b/scripts/set_environment.sh @@ -68,7 +68,7 @@ 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} From d5419fa66bb769cec42a16d7b0536d90381bc426 Mon Sep 17 00:00:00 2001 From: Gernot Maier Date: Sun, 31 May 2026 12:30:57 +0200 Subject: [PATCH 3/4] sc --- scripts/ANALYSIS.anasum.sh | 17 ++-- scripts/ANALYSIS.anasum_allcuts.sh | 27 +++--- scripts/ANALYSIS.anasum_combine.sh | 13 +-- scripts/ANALYSIS.anasum_link_files.sh | 11 ++- .../ANALYSIS.anasum_parallel_from_runlist.sh | 34 +++---- scripts/ANALYSIS.dispXGB.sh | 18 ++-- scripts/ANALYSIS.evndisp.sh | 30 ++++--- scripts/ANALYSIS.evndisp_laser.sh | 28 +++--- scripts/ANALYSIS.evndisp_muon.sh | 32 +++---- scripts/ANALYSIS.mscw_energy.sh | 32 +++---- scripts/ANALYSIS.v2dl3.sh | 22 ++--- scripts/IRF.combine_effective_area_parts.sh | 17 ++-- scripts/IRF.combine_lookup_table_parts.sh | 14 +-- scripts/IRF.compress_evndisp_MC.sh | 76 ++++++++-------- scripts/IRF.dispXGB.sh | 18 ++-- scripts/IRF.evndisp_MC.sh | 43 +++++---- scripts/IRF.generalproduction.sh | 31 ++++--- ...generate_NOISEfiles_from_PedestalEvents.sh | 5 +- scripts/IRF.generate_effective_area_parts.sh | 19 ++-- scripts/IRF.generate_lookup_table_parts.sh | 11 +-- scripts/IRF.generate_radial_acceptance.sh | 34 +++---- scripts/IRF.mscw_energy_MC.sh | 13 +-- ...RF.optimizeTMVAforGammaHadronSeparation.sh | 55 ++++-------- scripts/IRF.production.sh | 62 ++++++------- ...ectRunsForGammaHadronSeparationTraining.sh | 3 +- .../IRF.trainTMVAforAngularReconstruction.sh | 21 ++--- .../IRF.trainTMVAforGammaHadronSeparation.sh | 48 +++++----- ....trainXGBforAngularReconstructionBinned.sh | 19 ++-- ...rainXGBforGammaHadronSeparationTraining.sh | 22 +++-- scripts/RUNLIST.findBackgroundRuns.sh | 5 +- scripts/RUNLIST.findDBSourceCoordinates.sh | 13 ++- scripts/RUNLIST.findDBSourceNames.sh | 3 +- scripts/RUNLIST.generate.sh | 3 +- scripts/RUNLIST.preprocessing.sh | 3 +- scripts/RUNLIST.whichRunsAreArrayEpoch.sh | 19 ++-- scripts/RUNLIST.whichRunsAreAtmosphere.sh | 13 ++- scripts/RUNLIST.whichRunsAreObservingMode.sh | 9 +- scripts/RUNLIST.whichRunsAreOnDisk.sh | 25 +++--- scripts/RUNLIST.whichRunsAreSource.sh | 25 +++--- scripts/RUNLIST.whichRunsAreWobble.sh | 13 ++- scripts/SPANALYSIS.evndisp_laser_run.sh | 10 +-- ...LYSIS.evndisp_laser_runs_from_calibfile.sh | 9 +- ...NALYSIS.evndisp_laser_runs_from_runlist.sh | 11 ++- scripts/SPANALYSIS.evndisp_pedestal_events.sh | 4 +- scripts/SPANALYSIS.evndisp_tzeros.sh | 8 +- scripts/SPANALYSIS.lowgainped.sh | 39 ++++---- scripts/SPANALYSIS.make_DST.sh | 30 ++++--- .../UTILITY.downloadSoundingDatafromUWYO.sh | 9 +- scripts/UTILITY.sortRunsInSubDirectories.sh | 11 ++- scripts/db_scripts/db_FADCsettings.sh | 3 +- scripts/db_scripts/db_HVsettings.sh | 3 +- scripts/db_scripts/db_L1_TriggerInfo.sh | 3 +- scripts/db_scripts/db_L3.sh | 3 +- scripts/db_scripts/db_VPM.sh | 7 +- scripts/db_scripts/db_camerarotation.sh | 3 +- .../db_copy_old_laser_calibration.sh | 15 ++-- scripts/db_scripts/db_fir.sh | 3 +- scripts/db_scripts/db_gain.sh | 3 +- scripts/db_scripts/db_laserrun.sh | 5 +- scripts/db_scripts/db_lidar.sh | 3 +- scripts/db_scripts/db_mysqldb.sh | 3 +- scripts/db_scripts/db_pack_new_directories.sh | 11 ++- scripts/db_scripts/db_rawpointing.sh | 3 +- scripts/db_scripts/db_run.sh | 89 +++++++++---------- scripts/db_scripts/db_rundqm.sh | 3 +- scripts/db_scripts/db_runinfo.sh | 3 +- scripts/db_scripts/db_target.sh | 3 +- scripts/db_scripts/db_toffset.sh | 3 +- .../db_scripts/db_update_old_laser_files.sh | 23 +++-- scripts/db_scripts/db_update_tar_balls.sh | 13 ++- scripts/db_scripts/db_weather.sh | 3 +- .../db_scripts/db_write_fits_from_runlist.sh | 5 +- scripts/db_scripts/query_run_list.sh | 5 +- .../ANALYSIS.anasum_combine_sub.sh | 35 ++++---- scripts/helper_scripts/ANALYSIS.anasum_sub.sh | 27 +++--- .../helper_scripts/ANALYSIS.dispXGB_sub.sh | 15 ++-- .../ANALYSIS.evndisp_laser_sub.sh | 5 +- .../helper_scripts/ANALYSIS.evndisp_sub.sh | 43 +++++---- .../ANALYSIS.mscw_energy_sub.sh | 56 ++++++------ scripts/helper_scripts/ANALYSIS.v2dl3_sub.sh | 46 +++++----- .../IRF.compress_evndisp_MC_sub.sh | 23 +++-- scripts/helper_scripts/IRF.dispXGB_sub.sh | 9 +- .../IRF.effective_area_combine_sub.sh | 10 +-- .../IRF.effective_area_parallel_sub.sh | 28 +++--- scripts/helper_scripts/IRF.evndisp_MC_sub.sh | 80 +++++++++-------- .../IRF.lookup_table_combine_sub.sh | 10 +-- .../IRF.lookup_table_parallel_sub.sh | 18 ++-- .../helper_scripts/IRF.mscw_energy_MC_sub.sh | 71 ++++++++------- ...ptimizeTMVAforGammaHadronSeparation_sub.sh | 11 ++- .../IRF.radial_acceptance_sub.sh | 7 +- ...F.trainTMVAforAngularReconstruction_sub.sh | 20 ++--- ...F.trainTMVAforGammaHadronSeparation_sub.sh | 9 +- .../SPANALYSIS.lowgainped_sub.sh | 16 ++-- .../helper_scripts/SPANALYSIS.make_DST_sub.sh | 17 ++-- .../UTILITY.check_root_file_closed.sh | 3 +- .../UTILITY.condorSubmission.sh | 3 +- .../UTILITY.readSubmissionCommand.sh | 3 +- scripts/helper_scripts/UTILITY.script_init.sh | 3 +- .../submit_scripts_to_htcondor.sh | 17 ++-- scripts/preprocessing/archive_error_files.sh | 9 +- .../check_dl3_number_of_files_per_cut.sh | 7 +- .../check_epochs_for_3tel_irfs.sh | 13 ++- .../check_evndisp_mscw_processing.sh | 5 +- scripts/preprocessing/pack_data_files.sh | 23 +++-- scripts/preprocessing/pack_log_files.sh | 7 +- .../prepare_runlist_after_dqm.sh | 51 ++++++----- .../prepro_check_and_clean_files.sh | 7 +- .../prepro_move_preprocessed_files.sh | 7 +- .../preprocessing/prepro_move_v2dl3_files.sh | 7 +- .../prepro_pack_dl3_directories.sh | 3 +- .../preprocessing/prepro_rsync_data_ucla.sh | 17 ++-- scripts/preprocessing/prepro_rsync_db_ucla.sh | 5 +- .../print_dqm_string_from_runlist.sh | 19 ++-- .../print_processed_runstatistics.sh | 13 ++- scripts/preprocessing/processing_dqm.sh | 53 ++++++----- 115 files changed, 998 insertions(+), 1088 deletions(-) diff --git a/scripts/ANALYSIS.anasum.sh b/scripts/ANALYSIS.anasum.sh index 9890a026..84be27b8 100755 --- a/scripts/ANALYSIS.anasum.sh +++ b/scripts/ANALYSIS.anasum.sh @@ -1,9 +1,8 @@ #!/bin/bash -# shellcheck disable=SC2086 # 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 @@ -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 @@ -96,7 +95,8 @@ if [[ $SUBC == *"ERROR"* ]]; then 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 799fbdeb..3bf912ca 100755 --- a/scripts/ANALYSIS.anasum_allcuts.sh +++ b/scripts/ANALYSIS.anasum_allcuts.sh @@ -1,5 +1,4 @@ #!/bin/bash -# shellcheck disable=SC2086 # Run anasum or V2DL3 over all standard cuts # # @@ -29,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}/" @@ -48,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 @@ -62,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 @@ -85,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 b61b03f8..60fe9ded 100755 --- a/scripts/ANALYSIS.anasum_combine.sh +++ b/scripts/ANALYSIS.anasum_combine.sh @@ -1,9 +1,8 @@ #!/bin/bash -# shellcheck disable=SC2086 # 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 @@ -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 @@ -100,7 +99,8 @@ if [[ $SUBC == *"ERROR"* ]]; then 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,7 +108,7 @@ 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 + condor_submit "$FSCRIPT".sh.condor echo "OUTFILE $OUTFILE JOBID $JOBID" echo "OUTFILE $OUTFILE SCRIPT $FSCRIPT.sh" if [[ $SUBC != */dev/null* ]] ; then @@ -116,7 +116,8 @@ echo "OUTFILE $OUTFILE JOBID $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 0efc8d11..720889d9 100755 --- a/scripts/ANALYSIS.anasum_link_files.sh +++ b/scripts/ANALYSIS.anasum_link_files.sh @@ -1,5 +1,4 @@ #!/bin/bash -# shellcheck disable=SC2086 # script to link pre-processed anasum files to an anasum output directory @@ -40,7 +39,7 @@ if [[ ! -f "$RUNLIST" ]]; then fi # output directory -mkdir -p ${ODIR} +mkdir -p "${ODIR}" # directory schema getNumberedDirectory() { @@ -51,7 +50,7 @@ getNumberedDirectory() else NDIR="${IDIR}/${TRUN:0:2}/" fi - echo ${NDIR} + echo "${NDIR}" } RUNS=$(cat "$RUNLIST") @@ -59,9 +58,9 @@ 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 ff7b7b06..91e4b97f 100755 --- a/scripts/ANALYSIS.anasum_parallel_from_runlist.sh +++ b/scripts/ANALYSIS.anasum_parallel_from_runlist.sh @@ -1,13 +1,12 @@ #!/bin/bash -# shellcheck disable=SC2086 # 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" @@ -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 $CUTRADACC + 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 @@ -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|" \ @@ -300,7 +299,8 @@ for RUN in "${RUNS[@]}"; do 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 d7922a27..5b44564a 100755 --- a/scripts/ANALYSIS.dispXGB.sh +++ b/scripts/ANALYSIS.dispXGB.sh @@ -1,9 +1,8 @@ #!/bin/bash -# shellcheck disable=SC2086 # 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 @@ -47,7 +46,7 @@ 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 @@ -55,7 +54,7 @@ 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" @@ -65,16 +64,16 @@ 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\"") @@ -87,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 25dc2a45..ca786bd3 100755 --- a/scripts/ANALYSIS.evndisp.sh +++ b/scripts/ANALYSIS.evndisp.sh @@ -1,13 +1,12 @@ #!/bin/bash -# shellcheck disable=SC2086 # 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 " @@ -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 @@ -129,7 +128,7 @@ SUBC=$("$(dirname "$0")/helper_scripts/UTILITY.readSubmissionCommand.sh") 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" @@ -147,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)" @@ -159,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)" @@ -193,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 @@ -254,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 @@ -276,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" @@ -297,11 +298,12 @@ if [[ $SUBC == *parallel* ]]; then echo echo "$LOGDIR/runscripts.sh" echo - chmod +x $LOGDIR/runscripts.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 \" & \"/' + 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 diff --git a/scripts/ANALYSIS.evndisp_laser.sh b/scripts/ANALYSIS.evndisp_laser.sh index 7db3980c..c5cb6ff8 100755 --- a/scripts/ANALYSIS.evndisp_laser.sh +++ b/scripts/ANALYSIS.evndisp_laser.sh @@ -1,9 +1,8 @@ #!/bin/bash -# shellcheck disable=SC2086 # 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 @@ -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") 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" @@ -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\"") 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 29358d62..30b242ef 100755 --- a/scripts/ANALYSIS.evndisp_muon.sh +++ b/scripts/ANALYSIS.evndisp_muon.sh @@ -1,13 +1,12 @@ #!/bin/bash -# shellcheck disable=SC2086 # 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 @@ -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") 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") -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" @@ -173,7 +172,8 @@ do SUBC=$("$(dirname "$0")/helper_scripts/UTILITY.readSubmissionCommand.sh") 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 26ffdbcd..c0f12724 100755 --- a/scripts/ANALYSIS.mscw_energy.sh +++ b/scripts/ANALYSIS.mscw_energy.sh @@ -1,13 +1,12 @@ #!/bin/bash -# shellcheck disable=SC2086 # 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 @@ -71,7 +70,7 @@ 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 @@ -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\"") 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 dccca639..de13df84 100755 --- a/scripts/ANALYSIS.v2dl3.sh +++ b/scripts/ANALYSIS.v2dl3.sh @@ -1,12 +1,11 @@ #!/bin/bash -# shellcheck disable=SC2086 # script to run V2DL3 # (convert anasum output to FITS-DL3) # run point-like and full-enclosure analysis # # 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 @@ -48,7 +47,7 @@ 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 @@ -56,11 +55,11 @@ 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=$(find "$LOGDIR" -maxdepth 1 -name "x*" | sort) NFILELISTS=$(find "$LOGDIR" -maxdepth 1 -name "x*" | wc -l) @@ -75,13 +74,13 @@ 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" @@ -93,7 +92,8 @@ do 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 @@ -115,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" @@ -126,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 342317da..46bab66e 100755 --- a/scripts/IRF.combine_effective_area_parts.sh +++ b/scripts/IRF.combine_effective_area_parts.sh @@ -1,13 +1,12 @@ #!/bin/bash -# shellcheck disable=SC2086 # 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 " @@ -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,11 +127,11 @@ 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" @@ -145,7 +144,8 @@ if [[ $SUBC == *"ERROR"* ]]; then 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 67c90f26..92876b03 100755 --- a/scripts/IRF.combine_lookup_table_parts.sh +++ b/scripts/IRF.combine_lookup_table_parts.sh @@ -1,13 +1,12 @@ #!/bin/bash -# shellcheck disable=SC2086 # 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 " @@ -88,7 +87,7 @@ mkdir -p "$LOGDIR" # Create list of partial table files FLIST=$OFILE.list rm -f "$ODIR/$FLIST" -ls -1 $INDIR/*ID${RECID}.root > "$ODIR/$FLIST" +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" @@ -105,7 +104,7 @@ 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" @@ -118,7 +117,8 @@ if [[ $SUBC == *"ERROR"* ]]; then 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 b70cc96c..9dfa8fae 100755 --- a/scripts/IRF.compress_evndisp_MC.sh +++ b/scripts/IRF.compress_evndisp_MC.sh @@ -1,10 +1,9 @@ #!/bin/bash -# shellcheck disable=SC2086 # submit cleanup job after running evndisp # # 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 @@ -52,7 +51,7 @@ fi 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") @@ -86,18 +85,12 @@ 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" @@ -123,62 +116,62 @@ if [[ ${SIMTYPE:0:5} == "GRISU" ]]; then # 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 ####################################################### @@ -188,11 +181,11 @@ fi for V in ${VBFNAME} do echo "Processing ${V}" - SIMDIR=$(dirname ${V}) + SIMDIR=$(dirname "${V}") # size of VBF file FF=$(du -shL "${V}" | awk '{print $1}' | sed 's/,/./g') - V=$(basename ${V}) + V=$(basename "${V}") echo "SIMDIR: $SIMDIR" echo "VBFILE: ${V} $FF" echo "NOISEFILE: ${NOISEFILE}" @@ -217,10 +210,10 @@ 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 (( RUNNUM += 100 )) @@ -229,7 +222,8 @@ do 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" @@ -240,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 bfc9df0f..541d2f78 100755 --- a/scripts/IRF.dispXGB.sh +++ b/scripts/IRF.dispXGB.sh @@ -1,9 +1,8 @@ #!/bin/bash -# shellcheck disable=SC2086 # 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 @@ -47,34 +46,33 @@ 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)/" +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\"") diff --git a/scripts/IRF.evndisp_MC.sh b/scripts/IRF.evndisp_MC.sh index 85ae4878..8831ef53 100755 --- a/scripts/IRF.evndisp_MC.sh +++ b/scripts/IRF.evndisp_MC.sh @@ -1,9 +1,8 @@ #!/bin/bash -# shellcheck disable=SC2086 # 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") @@ -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,7 +193,7 @@ rm -f "${FSCRIPT}.txt" touch "${FSCRIPT}.txt" for V in $VBFNAME; do - echo "$RUNNUM $(basename $V)" >> "${FSCRIPT}.txt" + echo "$RUNNUM $(basename "$V")" >> "${FSCRIPT}.txt" (( RUNNUM += 100 )) done @@ -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 0d71cfe7..4c08c9aa 100755 --- a/scripts/IRF.generate_lookup_table_parts.sh +++ b/scripts/IRF.generate_lookup_table_parts.sh @@ -1,14 +1,13 @@ #!/bin/bash -# shellcheck disable=SC2086 # fill lookup tables for a given point in the parameter space # (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 @@ -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 250611a8..90539827 100755 --- a/scripts/IRF.generate_radial_acceptance.sh +++ b/scripts/IRF.generate_radial_acceptance.sh @@ -1,9 +1,8 @@ #!/bin/bash -# shellcheck disable=SC2086 # 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 @@ -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" @@ -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,9 +143,9 @@ 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 @@ -154,20 +153,22 @@ for CUTS in "${CUTLIST[@]}"; do echo "$LOGDIR" 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 ff3771e1..3683b8f2 100755 --- a/scripts/IRF.mscw_energy_MC.sh +++ b/scripts/IRF.mscw_energy_MC.sh @@ -1,14 +1,13 @@ #!/bin/bash -# shellcheck disable=SC2086 # Analyze simulation evndisp files using mscw_energy to generate IRF components. # 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 @@ -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 48f249c3..fe926420 100755 --- a/scripts/IRF.optimizeTMVAforGammaHadronSeparation.sh +++ b/scripts/IRF.optimizeTMVAforGammaHadronSeparation.sh @@ -1,10 +1,9 @@ #!/bin/bash -# shellcheck disable=SC2086 # script to optimize BDT cuts # # -# 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 @@ -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 @@ -64,7 +54,7 @@ fi 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,29 +80,15 @@ 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 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]} - (( z++ )) - done - NENE=$((${#EBINMAX[@]})) + NENE=$(( ${#EBINARRAY[@]} / 2 )) fi ##################################### @@ -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\"") 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 4400f9f5..a11adc37 100755 --- a/scripts/IRF.production.sh +++ b/scripts/IRF.production.sh @@ -1,9 +1,9 @@ #!/bin/bash -# shellcheck disable=SC2178,SC2128,SC2086 +# shellcheck disable=SC2178,SC2128 # 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 " @@ -164,7 +164,7 @@ elif [ "${SIMTYPE}" == "CARE_RedHV" ]; then elif [[ "${SIMTYPE}" == "CARE_June2020" ]]; then SIMDIR="${VERITAS_DATA_DIR}/shared/simulations/NSOffsetSimulations/Atmosphere${ATMOS}" ZENITH_ANGLES=$(find "${SIMDIR}" -mindepth 1 -maxdepth 1 -type d -name "Zd*" -exec basename {} \; | awk -F "Zd" '{print $2}' | sort | uniq) - set -- $ZENITH_ANGLES + 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) ###################################### @@ -189,8 +189,8 @@ elif [[ "${SIMTYPE}" == "CARE_RedHV_Feb2024" ]]; then SIMDIR="${VERITAS_DCACHE_DIR}/simulations/NSOffsetSimulations_redHV/Atmosphere${ATMOS}" 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=$(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) @@ -202,8 +202,8 @@ elif [[ "${SIMTYPE}" == "CARE_RedHV_Feb2024" ]]; then elif [[ "${SIMTYPE}" == "CARE_202404" ]] || [[ "${SIMTYPE}" == "CARE_24_20" ]]; then SIMDIR="${VERITAS_DCACHE_DIR}/simulations/NSOffsetSimulations_202404/Atmosphere${ATMOS}" 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}') + set -- "$ZENITH_ANGLES" + ze_first_bin=$(echo "$ZENITH_ANGLES" | awk '{print $1}') # assume same NSB and wobble offsets in all bins 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) @@ -219,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 ) @@ -241,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 @@ -263,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 =====" @@ -370,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 @@ -387,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 @@ -420,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 @@ -442,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 @@ -471,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 @@ -483,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 7ab657aa..63748589 100755 --- a/scripts/IRF.selectRunsForGammaHadronSeparationTraining.sh +++ b/scripts/IRF.selectRunsForGammaHadronSeparationTraining.sh @@ -1,5 +1,4 @@ #!/bin/bash -# shellcheck disable=SC2086 # select mscw files for BDT gamma/hadron separation training # # selection is based on @@ -114,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++)) diff --git a/scripts/IRF.trainTMVAforAngularReconstruction.sh b/scripts/IRF.trainTMVAforAngularReconstruction.sh index c5b23286..d354c53c 100755 --- a/scripts/IRF.trainTMVAforAngularReconstruction.sh +++ b/scripts/IRF.trainTMVAforAngularReconstruction.sh @@ -1,13 +1,12 @@ #!/bin/bash -# shellcheck disable=SC2086 # 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 @@ -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,14 +99,14 @@ 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 find "$INDIR" -maxdepth 1 -name "*[0-9].root.zst" | sort -R | head -n 1 >> "${EVNLIST}" done @@ -138,11 +137,12 @@ do 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) + # 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 cdb7262d..72d87a77 100755 --- a/scripts/IRF.trainTMVAforGammaHadronSeparation.sh +++ b/scripts/IRF.trainTMVAforGammaHadronSeparation.sh @@ -1,5 +1,4 @@ #!/bin/bash -# shellcheck disable=SC2086 # train BDTs for gamma/hadron separation # # note the large amount of hardwired parameters in this scripts: @@ -8,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 " @@ -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 @@ -175,11 +174,11 @@ do # 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 @@ -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 293fac62..7864ec0a 100755 --- a/scripts/IRF.trainXGBforAngularReconstructionBinned.sh +++ b/scripts/IRF.trainXGBforAngularReconstructionBinned.sh @@ -1,11 +1,10 @@ #!/bin/bash -# shellcheck disable=SC2086 # 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 " @@ -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 @@ -115,11 +114,12 @@ echo "$FSCRIPT" 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) + # 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 e68eee07..632fbb9c 100755 --- a/scripts/IRF.trainXGBforGammaHadronSeparationTraining.sh +++ b/scripts/IRF.trainXGBforGammaHadronSeparationTraining.sh @@ -1,12 +1,11 @@ #!/bin/bash -# shellcheck disable=SC2086 # train XGB for gamma/hadron separation # # - 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 " @@ -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" ##################################### @@ -153,7 +151,7 @@ for ((i=0; i> "${tmpfile}" + find "${BDIR}"/Ze_${i} -name "*.root" | shuf -n 1000 >> "${tmpfile}" done shuf "$tmpfile" > "${BCKLIST}" rm "$tmpfile" @@ -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 40ffbf77..ab7895d4 100755 --- a/scripts/RUNLIST.findBackgroundRuns.sh +++ b/scripts/RUNLIST.findBackgroundRuns.sh @@ -1,5 +1,4 @@ #!/bin/bash -# shellcheck disable=SC2086 # Generates a simple run list (one run per line) with quality cuts if [ ! -n "$1" ] || [ "$1" = "-h" ]; then @@ -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 | grep -E -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" diff --git a/scripts/RUNLIST.findDBSourceCoordinates.sh b/scripts/RUNLIST.findDBSourceCoordinates.sh index 0eed1195..1d783071 100755 --- a/scripts/RUNLIST.findDBSourceCoordinates.sh +++ b/scripts/RUNLIST.findDBSourceCoordinates.sh @@ -1,17 +1,16 @@ #!/bin/bash -# shellcheck disable=SC2086 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." @@ -27,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 | grep -E -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 @@ -40,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 b53f4199..ab6d35b7 100755 --- a/scripts/RUNLIST.findDBSourceNames.sh +++ b/scripts/RUNLIST.findDBSourceNames.sh @@ -1,5 +1,4 @@ #!/bin/bash -# shellcheck disable=SC2086 # prints list of sources that contain the first input argument if [ ! -n "$1" ] || [ "$1" = "-h" ]; then @@ -49,7 +48,7 @@ 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 | grep -E -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 58c65aab..a8b3984a 100755 --- a/scripts/RUNLIST.generate.sh +++ b/scripts/RUNLIST.generate.sh @@ -1,5 +1,4 @@ #!/bin/bash -# shellcheck disable=SC2086 # Generates a simple run list (one run per line) with quality cuts if [ ! -n "$1" ] || [ "$1" = "-h" ]; then @@ -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 | grep -E -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 353f7321..70fce6c3 100755 --- a/scripts/RUNLIST.preprocessing.sh +++ b/scripts/RUNLIST.preprocessing.sh @@ -1,5 +1,4 @@ #!/bin/bash -# shellcheck disable=SC2086 # Generates a simple run list (one run per line) with quality cuts if [ ! -n "$1" ] || [ "$1" = "-h" ]; then @@ -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 | grep -E -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 833f0641..09c541bf 100755 --- a/scripts/RUNLIST.whichRunsAreArrayEpoch.sh +++ b/scripts/RUNLIST.whichRunsAreArrayEpoch.sh @@ -1,5 +1,4 @@ #!/bin/bash -# shellcheck disable=SC2086 # from a run list, prints the list of runs that are considered V4 runs, before T1 was moved #echo "\$#:$# \$1:$1 \$2:$2 \$3:$3 \$4:$4" @@ -10,13 +9,13 @@ if [[ "$ISPIPEFILE" =~ ^/dev/pts/[0-9]{1,2} ]] ; then # its a terminal (not a pi 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 @@ -25,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? @@ -41,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 @@ -70,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 @@ -86,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 a9f50ac9..7bdb5920 100755 --- a/scripts/RUNLIST.whichRunsAreAtmosphere.sh +++ b/scripts/RUNLIST.whichRunsAreAtmosphere.sh @@ -1,5 +1,4 @@ #!/bin/bash -# shellcheck disable=SC2086 # 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 @@ -7,14 +6,14 @@ 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 @@ -23,11 +22,11 @@ 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 diff --git a/scripts/RUNLIST.whichRunsAreObservingMode.sh b/scripts/RUNLIST.whichRunsAreObservingMode.sh index 56c4f002..f53d5698 100755 --- a/scripts/RUNLIST.whichRunsAreObservingMode.sh +++ b/scripts/RUNLIST.whichRunsAreObservingMode.sh @@ -1,5 +1,4 @@ #!/bin/bash -# shellcheck disable=SC2086 # from a run list, prints the list of runs that were taken in a specific observing mode (observing, obsLowHV, obsFilter,...) # @@ -9,9 +8,9 @@ if [[ "$ISPIPEFILE" =~ ^/dev/pts/[0-9]{1,2} ]] ; then # its a terminal (not a pi 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" @@ -24,11 +23,11 @@ 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" diff --git a/scripts/RUNLIST.whichRunsAreOnDisk.sh b/scripts/RUNLIST.whichRunsAreOnDisk.sh index 6942f6cd..8e277412 100755 --- a/scripts/RUNLIST.whichRunsAreOnDisk.sh +++ b/scripts/RUNLIST.whichRunsAreOnDisk.sh @@ -1,5 +1,4 @@ #!/bin/bash -# shellcheck disable=SC2086 # from a run list, prints the list of runs that are on disk. NOTFLAG=false # flag for if the -n flag was used @@ -7,7 +6,7 @@ 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}') +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 @@ -22,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 @@ -43,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 @@ -55,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 @@ -69,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..." @@ -83,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 | grep -E -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 @@ -123,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 990fec3e..90da887b 100755 --- a/scripts/RUNLIST.whichRunsAreSource.sh +++ b/scripts/RUNLIST.whichRunsAreSource.sh @@ -1,11 +1,6 @@ #!/bin/bash -# shellcheck disable=SC2034,SC2086 # 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 @@ -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,27 +64,27 @@ 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 @@ -97,11 +92,11 @@ if $HELPFLAG ; then fi # 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 diff --git a/scripts/RUNLIST.whichRunsAreWobble.sh b/scripts/RUNLIST.whichRunsAreWobble.sh index 18796a0e..68d8c31f 100755 --- a/scripts/RUNLIST.whichRunsAreWobble.sh +++ b/scripts/RUNLIST.whichRunsAreWobble.sh @@ -1,5 +1,4 @@ #!/bin/bash -# shellcheck disable=SC2086 # from a run list, prints the list of runs that were taken in a specific atmosphere, summer(22) or winter(21) CONORM="\e[0m" @@ -10,13 +9,13 @@ if [[ "$ISPIPEFILE" =~ ^/dev/pts/[0-9]{1,2} ]] ; then # its a terminal (not a pi 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 @@ -25,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 diff --git a/scripts/SPANALYSIS.evndisp_laser_run.sh b/scripts/SPANALYSIS.evndisp_laser_run.sh index 1134b7dc..6a1f8783 100755 --- a/scripts/SPANALYSIS.evndisp_laser_run.sh +++ b/scripts/SPANALYSIS.evndisp_laser_run.sh @@ -1,5 +1,4 @@ #!/bin/bash -# shellcheck disable=SC2086 # analyze a laser/flasher run (calculate pedestals, calculate gains) if [ ! -n "$1" ] || [ "$1" = "-h" ]; then @@ -50,7 +49,7 @@ 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 @@ -62,14 +61,15 @@ OPT="-runmode=$RUNMODE -runnumber=$RUNNUM -lasermin=$LASERMIN -calibrationsumwin # 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 + # shellcheck disable=SC2086 + "$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 21cc0208..d39f1c09 100755 --- a/scripts/SPANALYSIS.evndisp_laser_runs_from_calibfile.sh +++ b/scripts/SPANALYSIS.evndisp_laser_runs_from_calibfile.sh @@ -1,5 +1,4 @@ #!/bin/bash -# shellcheck disable=SC2086 # read a calibration file produced by write_analysis_scripts.pl if [ ! -n "$1" ] || [ "$1" = "-h" ]; then @@ -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 67892480..825ec242 100755 --- a/scripts/SPANALYSIS.evndisp_laser_runs_from_runlist.sh +++ b/scripts/SPANALYSIS.evndisp_laser_runs_from_runlist.sh @@ -1,5 +1,4 @@ #!/bin/bash -# shellcheck disable=SC2086 if [ ! -n "$1" ] || [ "$1" = "-h" ]; then # begin help message @@ -32,7 +31,7 @@ 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 df446a1a..15af296e 100755 --- a/scripts/SPANALYSIS.evndisp_pedestal_events.sh +++ b/scripts/SPANALYSIS.evndisp_pedestal_events.sh @@ -1,5 +1,4 @@ #!/bin/bash -# shellcheck disable=SC2086 # calculate pedestals if [ ! -n "$1" ] || [ "$1" = "-h" ]; then @@ -58,6 +57,7 @@ fi # Run evndisp echo "$EVNDISPSYS/bin/evndisp -runnumber=$RUNNUM $OPT " -$EVNDISPSYS/bin/evndisp -runnumber=$RUNNUM $OPT +# shellcheck disable=SC2086 +"$EVNDISPSYS"/bin/evndisp -runnumber="$RUNNUM" $OPT exit diff --git a/scripts/SPANALYSIS.evndisp_tzeros.sh b/scripts/SPANALYSIS.evndisp_tzeros.sh index 378aba70..ff75dc2c 100755 --- a/scripts/SPANALYSIS.evndisp_tzeros.sh +++ b/scripts/SPANALYSIS.evndisp_tzeros.sh @@ -1,5 +1,4 @@ #!/bin/bash -# shellcheck disable=SC2086 # calculate mean tzeros if [ ! -n "$1" ] || [ "$1" = "-h" ]; then @@ -40,7 +39,7 @@ 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 @@ -51,13 +50,14 @@ if [[ $CALDB == "1" ]]; then else OPT="$OPT -nocalibnoproblem" fi -echo $OPT +echo "$OPT" # run options OPT="-runmode=7 -runnumber=$RUNNUM -teltoana=$TELTOANA $OPT" # Run evndisp echo "$EVNDISPSYS/bin/evndisp $OPT" -$EVNDISPSYS/bin/evndisp $OPT +# shellcheck disable=SC2086 +"$EVNDISPSYS"/bin/evndisp $OPT exit diff --git a/scripts/SPANALYSIS.lowgainped.sh b/scripts/SPANALYSIS.lowgainped.sh index c6fa0fa1..187d76cf 100755 --- a/scripts/SPANALYSIS.lowgainped.sh +++ b/scripts/SPANALYSIS.lowgainped.sh @@ -1,9 +1,8 @@ #!/bin/bash -# shellcheck disable=SC2086 # 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 @@ -40,9 +39,6 @@ fi # Run init script bash "$( cd "$( dirname "$0" )" && pwd )/helper_scripts/UTILITY.script_init.sh" || exit 1 -# EventDisplay version -EDVERSION=$($EVNDISPSYS/bin/evndisp --version | tr -d .) - # create extra stdout for duplication of command output # look for ">&5" below exec 5>&1 @@ -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") 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" @@ -107,12 +103,13 @@ do SUBC=$("$(dirname "$0")/helper_scripts/UTILITY.readSubmissionCommand.sh") 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 a13fe5b2..40655c59 100755 --- a/scripts/SPANALYSIS.make_DST.sh +++ b/scripts/SPANALYSIS.make_DST.sh @@ -1,9 +1,8 @@ #!/bin/bash -# shellcheck disable=SC2086 # 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 @@ -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") 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\"") 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 f61bc47f..899305d8 100755 --- a/scripts/UTILITY.downloadSoundingDatafromUWYO.sh +++ b/scripts/UTILITY.downloadSoundingDatafromUWYO.sh @@ -1,5 +1,4 @@ #!/bin/bash -# shellcheck disable=SC2086 # download sounding (balloon) data from UWYO for VERITAS # combine the monthly data into one file and create a list of files (in this case just the total file) @@ -36,12 +35,12 @@ 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 ce2fffb6..a680bbf5 100755 --- a/scripts/UTILITY.sortRunsInSubDirectories.sh +++ b/scripts/UTILITY.sortRunsInSubDirectories.sh @@ -1,5 +1,4 @@ #!/bin/bash -# shellcheck disable=SC2086 # sort and move files with file names [runnumber].*suffix # into subdirectories starting with the first (two) digits # of the run number. @@ -31,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 eb231f2d..d4d5ce7d 100755 --- a/scripts/db_scripts/db_FADCsettings.sh +++ b/scripts/db_scripts/db_FADCsettings.sh @@ -1,5 +1,4 @@ #!/bin/bash -# shellcheck disable=SC2086 # if [ ! -n "$3" ] || [ "$1" = "-h" ]; then @@ -19,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 fdec24b1..fb33c767 100755 --- a/scripts/db_scripts/db_HVsettings.sh +++ b/scripts/db_scripts/db_HVsettings.sh @@ -1,5 +1,4 @@ #!/bin/bash -# shellcheck disable=SC2086 # if [ ! -n "$3" ] || [ "$1" = "-h" ]; then @@ -19,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 b65450c8..5492e075 100755 --- a/scripts/db_scripts/db_L1_TriggerInfo.sh +++ b/scripts/db_scripts/db_L1_TriggerInfo.sh @@ -1,5 +1,4 @@ #!/bin/bash -# shellcheck disable=SC2086 # if [ ! -n "$1" ] || [ "$1" = "-h" ]; then @@ -18,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 40982e81..dc951456 100755 --- a/scripts/db_scripts/db_L3.sh +++ b/scripts/db_scripts/db_L3.sh @@ -1,5 +1,4 @@ #!/bin/bash -# shellcheck disable=SC2086 # if [ $# -lt 2 ] || [ "$1" = "-h" ]; then @@ -28,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 d4955ed4..3288d13e 100755 --- a/scripts/db_scripts/db_VPM.sh +++ b/scripts/db_scripts/db_VPM.sh @@ -1,5 +1,4 @@ #!/bin/bash -# shellcheck disable=SC2086 # if [ ! -n "$3" ] || [ "$1" = "-h" ]; then @@ -16,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 704719e5..273b10ac 100755 --- a/scripts/db_scripts/db_camerarotation.sh +++ b/scripts/db_scripts/db_camerarotation.sh @@ -1,5 +1,4 @@ #!/bin/bash -# shellcheck disable=SC2086 # if [ ! -n "$2" ] || [ "$1" = "-h" ]; then @@ -18,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 0cab8433..ef98a5a1 100755 --- a/scripts/db_scripts/db_copy_old_laser_calibration.sh +++ b/scripts/db_scripts/db_copy_old_laser_calibration.sh @@ -1,5 +1,4 @@ #!/bin/bash -# shellcheck disable=SC2086 # Copy gain and toff files and adapt them # according to the DBtext standard # Required for old V4 files with no entries @@ -35,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 7bc12082..93fd8dcd 100755 --- a/scripts/db_scripts/db_fir.sh +++ b/scripts/db_scripts/db_fir.sh @@ -1,5 +1,4 @@ #!/bin/bash -# shellcheck disable=SC2086 # if [ $# -lt 2 ] || [ "$1" = "-h" ]; then @@ -16,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 f11556b7..8d23a200 100755 --- a/scripts/db_scripts/db_gain.sh +++ b/scripts/db_scripts/db_gain.sh @@ -1,5 +1,4 @@ #!/bin/bash -# shellcheck disable=SC2086 # if [ ! -n "$2" ] || [ "$1" = "-h" ]; then @@ -19,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 f6983c6b..6d3418d7 100755 --- a/scripts/db_scripts/db_laserrun.sh +++ b/scripts/db_scripts/db_laserrun.sh @@ -1,5 +1,4 @@ #!/bin/bash -# shellcheck disable=SC2034,SC2086 # 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 8442d1f3..5b17957f 100755 --- a/scripts/db_scripts/db_lidar.sh +++ b/scripts/db_scripts/db_lidar.sh @@ -1,5 +1,4 @@ #!/bin/bash -# shellcheck disable=SC2086 # if [ $# -lt 2 ] || [ "$1" = "-h" ]; then @@ -19,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 12412892..bca5cc69 100755 --- a/scripts/db_scripts/db_mysqldb.sh +++ b/scripts/db_scripts/db_mysqldb.sh @@ -1,5 +1,4 @@ #!/bin/bash -# shellcheck disable=SC2086 # if [ "$1" = "-h" ]; then @@ -14,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} | grep -E -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 c30796ec..3643b6c8 100755 --- a/scripts/db_scripts/db_pack_new_directories.sh +++ b/scripts/db_scripts/db_pack_new_directories.sh @@ -1,5 +1,4 @@ #!/bin/bash -# shellcheck disable=SC2086 # pack newly written directories extracted from the DB # with query_run_list.sh # @@ -16,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 2650205d..8f9fcbeb 100755 --- a/scripts/db_scripts/db_rawpointing.sh +++ b/scripts/db_scripts/db_rawpointing.sh @@ -1,5 +1,4 @@ #!/bin/bash -# shellcheck disable=SC2086 # if [ ! -n "$3" ] || [ "$1" = "-h" ]; then @@ -29,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 dee864f6..ab15b02b 100755 --- a/scripts/db_scripts/db_run.sh +++ b/scripts/db_scripts/db_run.sh @@ -1,5 +1,4 @@ #!/bin/bash -# shellcheck disable=SC2086 # # extract information from VERITAS database required # for evndisp analysis @@ -29,7 +28,7 @@ OVERWRITE="0" NTEL="4" DBDIR="${VERITAS_DATA_DIR%/}/shared/DBTEXT/" -mkdir -p ${DBDIR} +mkdir -p "${DBDIR}" getDBTextFileDirectory() { @@ -39,7 +38,7 @@ getDBTextFileDirectory() else ODIR="${DBDIR%/}/${TRUN:0:2}/${TRUN}" fi - echo ${ODIR} + echo "${ODIR}" } get_file_status() @@ -52,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 @@ -69,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 @@ -87,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 @@ -111,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}" @@ -119,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 @@ -146,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}" } @@ -167,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 @@ -188,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 @@ -200,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}" @@ -229,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}" @@ -251,8 +250,8 @@ 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() @@ -261,8 +260,8 @@ read_pixel_data() 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 8f6ca92d..f1a336a1 100755 --- a/scripts/db_scripts/db_update_tar_balls.sh +++ b/scripts/db_scripts/db_update_tar_balls.sh @@ -1,5 +1,4 @@ #!/bin/bash -# shellcheck disable=SC2086 # Update existing tar balls with DB files with new # files. @@ -29,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 @@ -48,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 67aed82f..6b78a780 100755 --- a/scripts/db_scripts/db_weather.sh +++ b/scripts/db_scripts/db_weather.sh @@ -1,5 +1,4 @@ #!/bin/bash -# shellcheck disable=SC2086 # if [ $# -lt 2 ] || [ "$1" = "-h" ]; then @@ -16,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 2d28517a..20c4eb3e 100755 --- a/scripts/db_scripts/db_write_fits_from_runlist.sh +++ b/scripts/db_scripts/db_write_fits_from_runlist.sh @@ -1,5 +1,4 @@ #!/bin/bash -# shellcheck disable=SC2086 # # Write DB FITS files from a run list @@ -13,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 03985090..4a7cf698 100755 --- a/scripts/db_scripts/query_run_list.sh +++ b/scripts/db_scripts/query_run_list.sh @@ -1,5 +1,4 @@ #!/bin/bash -# shellcheck disable=SC2086 # # Extract information from VERITAS database required # for evndisp analysis for a list of runs @@ -14,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 dcf3e784..c7270ec6 100755 --- a/scripts/helper_scripts/ANALYSIS.anasum_combine_sub.sh +++ b/scripts/helper_scripts/ANALYSIS.anasum_combine_sub.sh @@ -1,11 +1,10 @@ #!/bin/bash -# shellcheck disable=SC2086 # 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 @@ -22,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() @@ -34,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 @@ -55,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 @@ -73,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" @@ -103,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}" @@ -117,20 +116,20 @@ 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 ==========================" - $EVNDISPSYS/bin/printCrabSensitivity ${OUTPUTDATAFILE}.root + "$EVNDISPSYS"/bin/printCrabSensitivity "${OUTPUTDATAFILE}".root echo "========================== ==========================" } >> "${OUTFILE}.log" fi @@ -138,9 +137,9 @@ fi 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 a3735390..01fae23b 100755 --- a/scripts/helper_scripts/ANALYSIS.anasum_sub.sh +++ b/scripts/helper_scripts/ANALYSIS.anasum_sub.sh @@ -1,5 +1,4 @@ #!/bin/bash -# shellcheck disable=SC2086 # script to analyse one run with anasum # set observatory environmental variables @@ -50,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 @@ -81,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 } @@ -123,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) + 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)}') + 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 @@ -207,9 +206,9 @@ 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 @@ -220,7 +219,7 @@ $EVNDISPSYS/bin/anasum \ } >> "${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 a2fe3397..a9a1a8af 100755 --- a/scripts/helper_scripts/ANALYSIS.dispXGB_sub.sh +++ b/scripts/helper_scripts/ANALYSIS.dispXGB_sub.sh @@ -1,5 +1,4 @@ #!/bin/bash -# shellcheck disable=SC2086 # XGBoost disp stereo and classification analysis on mscw data file # Don't do set -e. @@ -59,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 3dc07364..6046daa2 100755 --- a/scripts/helper_scripts/ANALYSIS.evndisp_laser_sub.sh +++ b/scripts/helper_scripts/ANALYSIS.evndisp_laser_sub.sh @@ -1,10 +1,9 @@ #!/bin/bash -# shellcheck disable=SC2086 # 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 @@ -14,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 ca43eba3..de56d4ca 100755 --- a/scripts/helper_scripts/ANALYSIS.evndisp_sub.sh +++ b/scripts/helper_scripts/ANALYSIS.evndisp_sub.sh @@ -1,5 +1,4 @@ #!/bin/bash -# shellcheck disable=SC2086 # script to analyse VTS raw files (VBF) with eventdisplay # set observatory environmental variables @@ -59,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 } @@ -75,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 @@ -106,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[@]}" @@ -137,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) @@ -148,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 @@ -174,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" @@ -198,7 +197,7 @@ 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[@]}" \ @@ -230,7 +229,7 @@ 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" \ @@ -265,7 +264,7 @@ 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" \ @@ -277,19 +276,19 @@ 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 c794d162..03046ec8 100755 --- a/scripts/helper_scripts/ANALYSIS.mscw_energy_sub.sh +++ b/scripts/helper_scripts/ANALYSIS.mscw_energy_sub.sh @@ -1,5 +1,4 @@ #!/bin/bash -# shellcheck disable=SC2086 # analyse MC files with lookup tables # set observatory environmental variables @@ -68,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 @@ -99,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" @@ -108,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() @@ -116,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 } @@ -155,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 @@ -168,7 +167,7 @@ fi # run analysis MSCWLOGFILE="$ODIR/$BFILE.mscw.log" -rm -f ${MSCWLOGFILE} +rm -f "${MSCWLOGFILE}" MSCWDATAFILE="$ODIR/$BFILE.mscw.root" echo "MSCWDATAFILE $MSCWDATAFILE" @@ -190,8 +189,8 @@ if [ $DISPBDT -eq 1 ]; then # MOPT="$MOPT -minfui=0.2" # MOPT="$MOPT -minfitstat=3" # unzip XML files into DDIR - cp -v -f ${DISPDIR}/*.xml.gz ${DDIR}/ - gunzip -v ${DDIR}/*xml.gz + 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_" @@ -201,20 +200,21 @@ if [ $DISPBDT -eq 1 ]; then echo "DISP BDT options: $MOPT" fi -$EVNDISPSYS/bin/mscw_energy \ +# shellcheck disable=SC2086 +"$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}" -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}" @@ -224,19 +224,19 @@ fi # 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 c2aa7af2..2ae104b0 100755 --- a/scripts/helper_scripts/ANALYSIS.v2dl3_sub.sh +++ b/scripts/helper_scripts/ANALYSIS.v2dl3_sub.sh @@ -1,5 +1,4 @@ #!/bin/bash -# shellcheck disable=SC2086 # script to run V2DL3 # (convert anasum output to FITS-DL3) # run point-like and full-enclosure analysis @@ -63,10 +62,10 @@ pip show v2dl3-eventdisplay &>/dev/null 2>&1 || pip install -e "${V2DL3SYS%/}-v$ 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() @@ -78,7 +77,7 @@ getNumberedDirectory() else ODIR="${IDIR}/${TRUN:0:2}/" fi - echo ${ODIR} + echo "${ODIR}" } # interpolator; might depend on IRF type @@ -101,20 +100,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" @@ -130,27 +129,28 @@ do do if [[ "$p" != "-all-events" ]]; then V2DL3SELECT="--evt_filter ${EVENTFILTER}" - ls -1 ${EVENTFILTER} + ls -1 "${EVENTFILTER}" else V2DL3SELECT="" fi echo "EVENTFILTER $V2DL3SELECT" mkdir -p ${ODIR}/${m}${p} - rm -f ${ODIR}/${m}${p}/${RUN}.log + rm -f ${ODIR}/${m}${p}/"${RUN}".log + # shellcheck disable=SC2086 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 + --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 7693df38..f82b81fe 100755 --- a/scripts/helper_scripts/IRF.compress_evndisp_MC_sub.sh +++ b/scripts/helper_scripts/IRF.compress_evndisp_MC_sub.sh @@ -1,5 +1,4 @@ #!/bin/bash -# shellcheck disable=SC2086 # script put log files into evndisp file and compress output # shellcheck source=/dev/null @@ -17,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 -c "Error: log file object") + 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" @@ -48,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 @@ -59,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 @@ -71,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 181cf579..36b6671a 100755 --- a/scripts/helper_scripts/IRF.dispXGB_sub.sh +++ b/scripts/helper_scripts/IRF.dispXGB_sub.sh @@ -1,5 +1,4 @@ #!/bin/bash -# shellcheck disable=SC2086 # XGBoost disp stereo and classification analysis on mscw MC file # Don't do set -e. @@ -58,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 c8935cc2..ab5d1dd0 100755 --- a/scripts/helper_scripts/IRF.effective_area_combine_sub.sh +++ b/scripts/helper_scripts/IRF.effective_area_combine_sub.sh @@ -1,5 +1,4 @@ #!/bin/bash -# shellcheck disable=SC2034,SC2086 # combine effective areas # set observatory environmental variables @@ -27,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 @@ -37,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 } @@ -47,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 inspect_executables >> "$ODIR/$OFILE.log" -$EVNDISPSYS/bin/logFile effAreaCombineLog "${OPTODIR}/$OFILE.root" "${OPTODIR}/$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 b0e59606..3191f780 100755 --- a/scripts/helper_scripts/IRF.effective_area_parallel_sub.sh +++ b/scripts/helper_scripts/IRF.effective_area_parallel_sub.sh @@ -1,5 +1,4 @@ #!/bin/bash -# shellcheck disable=SC2034,SC2086 # calculate effective areas # # v490: possible issue with "RERUN_STEREO_RECONSTRUCTION_3TEL" option @@ -43,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() @@ -51,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 } @@ -72,9 +70,9 @@ 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" @@ -90,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 @@ -118,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 @@ -127,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" 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 2a1ab537..27192b87 100755 --- a/scripts/helper_scripts/IRF.evndisp_MC_sub.sh +++ b/scripts/helper_scripts/IRF.evndisp_MC_sub.sh @@ -1,5 +1,5 @@ #!/bin/bash -# shellcheck disable=SC2034,SC2154,SC2086 +# shellcheck disable=SC2154 # script to run evndisp for simulations on one of the cluster nodes (VBF) # set observatory environmental variables @@ -12,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 @@ -97,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 @@ -114,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 } @@ -148,7 +151,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 @@ -157,17 +160,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 @@ -177,7 +180,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 @@ -200,12 +203,12 @@ 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 @@ -216,11 +219,12 @@ 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 + rm -f $ODIR/"$RUNNUM".ped.log PEDOPT="-runmode=1 -calibrationnevents=${PEDNEVENTS}" - $EVNDISPSYS/bin/evndisp $MCOPT $PEDOPT &> "$ODIR/$RUNNUM.ped.log" + # shellcheck disable=SC2086 + "$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; + if grep -Fq "END OF ANALYSIS, exiting" $ODIR/"$RUNNUM".ped.log; then echo " successful pedestal analysis" else @@ -234,15 +238,16 @@ fi 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 +rm -f $ODIR/"$RUNNUM".tzero.log ### eventdisplay GRISU run options if [[ ${SIMTYPE:0:5} = "GRISU" ]]; then TZEROPT="$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 "$EVNDISPSYS/bin/evndisp $MCOPT $TZEROPT" &> $ODIR/"$RUNNUM".tzero.log +# shellcheck disable=SC2086 +"$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; +if grep -Fq "END OF ANALYSIS, exiting" $ODIR/"$RUNNUM".tzero.log; then echo " successful tzero analysis" else @@ -267,14 +272,15 @@ 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 "$EVNDISPSYS/bin/evndisp $MCOPT $ANAOPT" &> $ODIR/"$ONAME".log +# shellcheck disable=SC2086 +"$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" @@ -286,11 +292,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 -c "Error: log file object") + 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" @@ -307,36 +313,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 eb1d6d66..f63fb615 100755 --- a/scripts/helper_scripts/IRF.lookup_table_combine_sub.sh +++ b/scripts/helper_scripts/IRF.lookup_table_combine_sub.sh @@ -1,5 +1,4 @@ #!/bin/bash -# shellcheck disable=SC2034,SC2086 # combine lookup tables # set observatory environmental variables @@ -33,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() @@ -41,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 } @@ -50,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 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 046f2c82..780517e5 100755 --- a/scripts/helper_scripts/IRF.lookup_table_parallel_sub.sh +++ b/scripts/helper_scripts/IRF.lookup_table_parallel_sub.sh @@ -1,5 +1,5 @@ #!/bin/bash -# shellcheck disable=SC2034,SC2154,SC2086 +# shellcheck disable=SC2154 # fill lookup tables # set observatory environmental variables @@ -49,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() @@ -57,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}" @@ -72,9 +71,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" @@ -94,7 +93,8 @@ fi echo "Running mscw_energy (table filling)" logfile="$ODIR/$TABFILE.log" -$EVNDISPSYS/bin/mscw_energy -filltables=1 \ +# shellcheck disable=SC2086 +"$EVNDISPSYS"/bin/mscw_energy -filltables=1 \ -limitEnergyReconstruction \ -write1DHistograms \ -inputfilelist "$DDIR/$TABFILE.list" \ @@ -104,5 +104,5 @@ $EVNDISPSYS/bin/mscw_energy -filltables=1 \ -woff=$WOBBLE &> "$logfile" inspect_executables >> "$logfile" -$EVNDISPSYS/bin/logFile makeTableLog "${DDIR}/$TABFILE.root" "$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 46573825..682d0f37 100755 --- a/scripts/helper_scripts/IRF.mscw_energy_MC_sub.sh +++ b/scripts/helper_scripts/IRF.mscw_energy_MC_sub.sh @@ -1,5 +1,4 @@ #!/bin/bash -# shellcheck disable=SC2034,SC2086 # Analyse MC files with lookup tables (mscw_energy stage) # (optional) Calculate instrument response functions (effective areas) for 4 and 3-telescope combinations @@ -62,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 @@ -71,7 +69,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 } @@ -118,8 +116,8 @@ if [ $DISPBDT -eq 1 ]; then fi fi # unzip XML files into DDIR - cp -v -f ${DISPDIR}/*.xml.gz ${DDIR}/ - gunzip -v ${DDIR}/*xml.gz + 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_" @@ -143,9 +141,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" @@ -159,9 +157,10 @@ cat "$DDIR/$OFILE.list" echo "Running mscw_energy" outputfilename="$DDIR/$OFILE.mscw.root" logfile="$OSUBDIR/$OFILE.log" -$EVNDISPSYS/bin/mscw_energy $MOPT \ +# shellcheck disable=SC2086 +"$EVNDISPSYS"/bin/mscw_energy $MOPT \ -inputfilelist "$DDIR/$OFILE.list" \ - -outputfile $outputfilename \ + -outputfile "$outputfilename" \ -noise=$NOISE &> $logfile echo "READING evndisp files from ${INDIR}" >> $logfile @@ -173,13 +172,13 @@ fi 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 @@ -193,17 +192,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 @@ -231,7 +230,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" } @@ -262,7 +261,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" @@ -272,7 +271,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" @@ -302,10 +301,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" @@ -321,7 +320,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} @@ -341,7 +340,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}" @@ -353,32 +352,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" 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 58a04be8..02afb5a3 100755 --- a/scripts/helper_scripts/IRF.optimizeTMVAforGammaHadronSeparation_sub.sh +++ b/scripts/helper_scripts/IRF.optimizeTMVAforGammaHadronSeparation_sub.sh @@ -1,12 +1,11 @@ #!/bin/bash -# shellcheck disable=SC2086 # script to calculate signal and background rates and # 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 @@ -24,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." @@ -57,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 0a6323e6..0c4e34c8 100755 --- a/scripts/helper_scripts/IRF.radial_acceptance_sub.sh +++ b/scripts/helper_scripts/IRF.radial_acceptance_sub.sh @@ -1,10 +1,9 @@ #!/bin/bash -# shellcheck disable=SC2086 # 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 @@ -16,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 e7dd3260..f59c1c6c 100755 --- a/scripts/helper_scripts/IRF.trainTMVAforAngularReconstruction_sub.sh +++ b/scripts/helper_scripts/IRF.trainTMVAforAngularReconstruction_sub.sh @@ -1,5 +1,4 @@ #!/bin/bash -# shellcheck disable=SC2034,SC2086 # train TMVA (BDTs) for angular reconstruction # set observatory environmental variables @@ -38,7 +37,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 # decompress @@ -50,11 +48,11 @@ do 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 +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} @@ -78,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" \ @@ -89,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" \ @@ -99,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 8344ba4d..b112fb11 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,SC2086 # script to train TMVA (BDTs) for gamma/hadron separation RXPAR=RUNPARAM @@ -29,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" @@ -49,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 } @@ -64,5 +61,5 @@ 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 f4f84376..350a0b60 100755 --- a/scripts/helper_scripts/SPANALYSIS.lowgainped_sub.sh +++ b/scripts/helper_scripts/SPANALYSIS.lowgainped_sub.sh @@ -1,10 +1,9 @@ #!/bin/bash -# shellcheck disable=SC2086 # 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 @@ -21,7 +20,7 @@ else TEMPDIR="$VERITAS_USER_DATA_DIR/TMPDIR" fi echo "Scratch dir: $TEMPDIR" -mkdir -p $TEMPDIR +mkdir -p "$TEMPDIR" LOGDIR="$TEMPDIR" @@ -33,16 +32,17 @@ OPT=" -calibrationsumwindow=$CALIBRATIONSUMWINDOW -calibrationsumfirst=$CALIBRAT ######################################### # pedestal calculation -rm -f $LOGDIR/$RUN.ped.log -$EVNDISPSYS/bin/evndisp -runmode=6 -runnumber=$RUN -reconstructionparameter $ACUTS $OPT &> $LOGDIR/$RUN.ped.log +rm -f "$LOGDIR"/$RUN.ped.log +# shellcheck disable=SC2086 +"$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 c7ab48ed..c3224344 100755 --- a/scripts/helper_scripts/SPANALYSIS.make_DST_sub.sh +++ b/scripts/helper_scripts/SPANALYSIS.make_DST_sub.sh @@ -1,14 +1,14 @@ #!/bin/bash -# shellcheck disable=SC2034,SC2086 # script to make DSTs # set observatory environmental variables # shellcheck source=/dev/null -source $EVNDISPSYS/setObservatory.sh VTS +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 @@ -19,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 @@ -36,11 +36,11 @@ 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 @@ -56,10 +56,11 @@ 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 +# shellcheck disable=SC2086 +"$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 8be23fda..05af6472 100755 --- a/scripts/helper_scripts/UTILITY.check_root_file_closed.sh +++ b/scripts/helper_scripts/UTILITY.check_root_file_closed.sh @@ -1,5 +1,4 @@ #!/bin/bash -# shellcheck disable=SC2086 #### checks if a root file has been properly closed. @@ -7,7 +6,7 @@ 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 if ! root -b -l -q -e "$EVNDISPSYS/macros/checkCorrupted.C(\"$filename_to_check\")" >/dev/null 2>&1; then exit 1 diff --git a/scripts/helper_scripts/UTILITY.condorSubmission.sh b/scripts/helper_scripts/UTILITY.condorSubmission.sh index e6cd96a9..43391e7b 100755 --- a/scripts/helper_scripts/UTILITY.condorSubmission.sh +++ b/scripts/helper_scripts/UTILITY.condorSubmission.sh @@ -1,5 +1,4 @@ #!/bin/bash -# shellcheck disable=SC2086 # prepare a condor job submission file if [ "$1" = "-h" ]; then @@ -16,7 +15,7 @@ SUBFIL=${SUBSCRIPT}.condor [[ -f "$SUBFIL" ]] && rm -f "$SUBFIL". -cat > ${SUBFIL} < "${SUBFIL}" <> "${SUBMITF}" # assume that all condor files have similar requests - CONDORFILE=$(find ${JDIR} -name "*.condor" | head -n 1) + CONDORFILE=$(find "${JDIR}" -name "*.condor" | head -n 1) { grep -h request_memory "$CONDORFILE" grep -h request_disk "$CONDORFILE" @@ -53,9 +52,9 @@ if find "${JDIR}" -name "*.condor" -print -quit | grep -q .; then 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 ea8b5868..2b32e56e 100755 --- a/scripts/preprocessing/archive_error_files.sh +++ b/scripts/preprocessing/archive_error_files.sh @@ -1,5 +1,4 @@ #!/bin/bash -# shellcheck disable=SC2034,SC2086 # 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 afb82cec..3f77e2e3 100755 --- a/scripts/preprocessing/check_dl3_number_of_files_per_cut.sh +++ b/scripts/preprocessing/check_dl3_number_of_files_per_cut.sh @@ -1,5 +1,4 @@ #!/bin/bash -# shellcheck disable=SC2086 # Check the number of files DL3 processing if [ ! -n "$1" ] || [ "$1" = "-h" ]; then echo " @@ -11,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" @@ -24,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 a09fdbe7..12a9a0c0 100755 --- a/scripts/preprocessing/check_epochs_for_3tel_irfs.sh +++ b/scripts/preprocessing/check_epochs_for_3tel_irfs.sh @@ -1,5 +1,4 @@ #!/bin/bash -# shellcheck disable=SC2086 # Read mscw log files and derive epoch lists for summer / winter if [ ! -n "$1" ]; then @@ -12,7 +11,7 @@ exit fi RUNLIST="${1}" -RUNS=$(cat $RUNLIST) +RUNS=$(cat "$RUNLIST") DDIR="$VERITAS_PREPROCESSED_DATA_DIR/${VERITAS_ANALYSIS_TYPE:0:2}/mscw/" @@ -33,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 @@ -50,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 2b57765b..d892f665 100755 --- a/scripts/preprocessing/check_evndisp_mscw_processing.sh +++ b/scripts/preprocessing/check_evndisp_mscw_processing.sh @@ -1,5 +1,4 @@ #!/bin/bash -# shellcheck disable=SC2086 # Check if runs read from a run list are processed already with # evndisp or mscw files # @@ -13,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 ad5581ec..f685228b 100755 --- a/scripts/preprocessing/pack_data_files.sh +++ b/scripts/preprocessing/pack_data_files.sh @@ -1,5 +1,4 @@ #!/bin/bash -# shellcheck disable=SC2086 # Prepare Eventdisplay data products of a certain # type from a run list into tar balls # @@ -26,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() { @@ -40,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 @@ -58,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 1b12c599..9b3c8cb2 100755 --- a/scripts/preprocessing/pack_log_files.sh +++ b/scripts/preprocessing/pack_log_files.sh @@ -1,5 +1,4 @@ #!/bin/bash -# shellcheck disable=SC2086 # Pack log files in production directories into # individual tar ball depending on the data level # @@ -25,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 4220710a..1437031c 100755 --- a/scripts/preprocessing/prepare_runlist_after_dqm.sh +++ b/scripts/preprocessing/prepare_runlist_after_dqm.sh @@ -1,5 +1,4 @@ #!/bin/bash -# shellcheck disable=SC2086 # Prepare run lists and time cuts using the # DQM information. # @@ -31,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() { @@ -95,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 @@ -106,7 +105,7 @@ fill_timemask() prepare_output_files -RUNS=$(cat $RUNLIST) +RUNS=$(cat "$RUNLIST") for RF in $RUNS do @@ -122,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 @@ -132,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" @@ -157,18 +156,18 @@ do 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" ]] \ @@ -178,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 @@ -205,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) @@ -217,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 @@ -230,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 4ba9f360..3fe0a730 100755 --- a/scripts/preprocessing/prepro_check_and_clean_files.sh +++ b/scripts/preprocessing/prepro_check_and_clean_files.sh @@ -1,5 +1,4 @@ #!/bin/bash -# shellcheck disable=SC2086 if [ $# -lt 1 ]; then echo " ./prepro_check_and_clean_files.sh @@ -35,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 @@ -44,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 @@ -53,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 diff --git a/scripts/preprocessing/prepro_move_preprocessed_files.sh b/scripts/preprocessing/prepro_move_preprocessed_files.sh index ebf43da1..24614d04 100755 --- a/scripts/preprocessing/prepro_move_preprocessed_files.sh +++ b/scripts/preprocessing/prepro_move_preprocessed_files.sh @@ -1,5 +1,4 @@ #!/bin/bash -# shellcheck disable=SC2086 if [ $# -lt 1 ]; then echo " ./prepro_move_preprocessed_files.sh @@ -12,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}" @@ -26,7 +25,7 @@ for F in 11 10 9 8 7 6 5 4 3; do mkdir -p "$OFDIR" 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 f68ae7c3..09918596 100755 --- a/scripts/preprocessing/prepro_move_v2dl3_files.sh +++ b/scripts/preprocessing/prepro_move_v2dl3_files.sh @@ -1,5 +1,4 @@ #!/bin/bash -# shellcheck disable=SC2086 if [ $# -lt 2 ]; then echo " ./prepro_move_preprocessed_files.sh @@ -15,7 +14,7 @@ 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}/" @@ -25,7 +24,7 @@ for F in 11 10 9 8 7 6 5 4 3; do 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 a85bb7ef..4f623157 100755 --- a/scripts/preprocessing/prepro_pack_dl3_directories.sh +++ b/scripts/preprocessing/prepro_pack_dl3_directories.sh @@ -1,5 +1,4 @@ #!/bin/bash -# shellcheck disable=SC2086 # Pack dl3 directories into tar packages # @@ -11,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 139696db..6083c368 100755 --- a/scripts/preprocessing/prepro_rsync_data_ucla.sh +++ b/scripts/preprocessing/prepro_rsync_data_ucla.sh @@ -1,5 +1,4 @@ #!/bin/bash -# shellcheck disable=SC2086 # Sync pre-processed Eventdisplay data with UCLA # This includes Eventdisplay data products @@ -19,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" @@ -44,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 @@ -52,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 @@ -68,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 @@ -77,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 60b49c84..8637a56b 100755 --- a/scripts/preprocessing/prepro_rsync_db_ucla.sh +++ b/scripts/preprocessing/prepro_rsync_db_ucla.sh @@ -1,5 +1,4 @@ #!/bin/bash -# shellcheck disable=SC2086 # Sync pre-processed DBFITS and DBTEXT files with UCLA if [ ! -n "$1" ] || [ "$1" = "-h" ]; then @@ -24,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 7974a75c..d1827b05 100755 --- a/scripts/preprocessing/print_dqm_string_from_runlist.sh +++ b/scripts/preprocessing/print_dqm_string_from_runlist.sh @@ -1,5 +1,4 @@ #!/bin/bash -# shellcheck disable=SC2086 # Print DQM information in one single line # for each run using DBText files # @@ -28,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}/" } @@ -58,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" @@ -68,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 063bd226..16da7a76 100755 --- a/scripts/preprocessing/print_processed_runstatistics.sh +++ b/scripts/preprocessing/print_processed_runstatistics.sh @@ -1,5 +1,4 @@ #!/bin/bash -# shellcheck disable=SC2034,SC2086 # 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 0df932b6..28252553 100755 --- a/scripts/preprocessing/processing_dqm.sh +++ b/scripts/preprocessing/processing_dqm.sh @@ -1,5 +1,4 @@ #!/bin/bash -# shellcheck disable=SC2086 # Error checks in log files for preprocessing # @@ -26,65 +25,65 @@ check_evndisp_log_files() 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=$(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" From 0fd41a0d5befb391d927e19647786f7a99d40c0e Mon Sep 17 00:00:00 2001 From: Gernot Maier Date: Sun, 31 May 2026 12:40:01 +0200 Subject: [PATCH 4/4] SC2086 --- scripts/SPANALYSIS.evndisp_laser_run.sh | 17 +++- scripts/SPANALYSIS.evndisp_pedestal_events.sh | 44 ++++++---- scripts/SPANALYSIS.evndisp_tzeros.sh | 13 ++- .../ANALYSIS.mscw_energy_sub.sh | 49 +++++++---- scripts/helper_scripts/ANALYSIS.v2dl3_sub.sh | 17 ++-- scripts/helper_scripts/IRF.evndisp_MC_sub.sh | 86 ++++++++++++++----- .../IRF.lookup_table_parallel_sub.sh | 18 ++-- .../helper_scripts/IRF.mscw_energy_MC_sub.sh | 54 ++++++++---- .../SPANALYSIS.lowgainped_sub.sh | 16 ++-- .../helper_scripts/SPANALYSIS.make_DST_sub.sh | 9 +- 10 files changed, 218 insertions(+), 105 deletions(-) diff --git a/scripts/SPANALYSIS.evndisp_laser_run.sh b/scripts/SPANALYSIS.evndisp_laser_run.sh index 6a1f8783..becbc689 100755 --- a/scripts/SPANALYSIS.evndisp_laser_run.sh +++ b/scripts/SPANALYSIS.evndisp_laser_run.sh @@ -56,7 +56,19 @@ if [ ${#SF} = 0 ]; then 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 @@ -68,8 +80,7 @@ fi TELTOANA=$(echo "$TELTOANA" | fold -w1) for i in $TELTOANA; do echo "Calculating gains for run $RUNNUM, telescope $i" - # shellcheck disable=SC2086 - "$EVNDISPSYS"/bin/evndisp -teltoana="$i" $OPT + "$EVNDISPSYS"/bin/evndisp -teltoana="$i" "${OPT[@]}" done exit diff --git a/scripts/SPANALYSIS.evndisp_pedestal_events.sh b/scripts/SPANALYSIS.evndisp_pedestal_events.sh index 15af296e..db3031c5 100755 --- a/scripts/SPANALYSIS.evndisp_pedestal_events.sh +++ b/scripts/SPANALYSIS.evndisp_pedestal_events.sh @@ -33,31 +33,41 @@ 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 " -# shellcheck disable=SC2086 -"$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 ff75dc2c..cb97111c 100755 --- a/scripts/SPANALYSIS.evndisp_tzeros.sh +++ b/scripts/SPANALYSIS.evndisp_tzeros.sh @@ -46,18 +46,17 @@ if [[ ${#SF} = 0 ]]; then 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" -# shellcheck disable=SC2086 -"$EVNDISPSYS"/bin/evndisp $OPT +echo "$EVNDISPSYS/bin/evndisp ${OPT[*]}" +"$EVNDISPSYS"/bin/evndisp "${OPT[@]}" exit diff --git a/scripts/helper_scripts/ANALYSIS.mscw_energy_sub.sh b/scripts/helper_scripts/ANALYSIS.mscw_energy_sub.sh index 03046ec8..2e432e97 100755 --- a/scripts/helper_scripts/ANALYSIS.mscw_energy_sub.sh +++ b/scripts/helper_scripts/ANALYSIS.mscw_energy_sub.sh @@ -173,36 +173,51 @@ 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_" + 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 -# shellcheck disable=SC2086 "$EVNDISPSYS"/bin/mscw_energy \ - ${MOPT} \ + "${MOPT[@]}" \ -updateEpoch=1 \ -tablefile "$TABFILE" \ -arrayrecid=$RECID \ diff --git a/scripts/helper_scripts/ANALYSIS.v2dl3_sub.sh b/scripts/helper_scripts/ANALYSIS.v2dl3_sub.sh index 2ae104b0..4a44aa1a 100755 --- a/scripts/helper_scripts/ANALYSIS.v2dl3_sub.sh +++ b/scripts/helper_scripts/ANALYSIS.v2dl3_sub.sh @@ -59,7 +59,11 @@ 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" @@ -123,25 +127,24 @@ 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}" + 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 - # shellcheck disable=SC2086 v2dl3-eventdisplay \ --${m} \ - ${V2DL3OPT} ${V2DL3SELECT} \ + "${V2DL3OPT[@]}" "${V2DL3SELECT[@]}" \ --file_pair "${ANASUMFILE}" "$VERITAS_EVNDISP_AUX_DIR"/EffectiveAreas/"${EFFAREA}" \ --logfile ${ODIR}/${m}${p}/"${RUN}".log \ --instrument_epoch "${EPOCH}" \ diff --git a/scripts/helper_scripts/IRF.evndisp_MC_sub.sh b/scripts/helper_scripts/IRF.evndisp_MC_sub.sh index 27192b87..f7e41efa 100755 --- a/scripts/helper_scripts/IRF.evndisp_MC_sub.sh +++ b/scripts/helper_scripts/IRF.evndisp_MC_sub.sh @@ -134,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 @@ -142,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 @@ -192,11 +196,29 @@ 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 @@ -220,9 +242,8 @@ fi if [[ ${SIMTYPE:0:4} == "CARE" ]]; then echo "Calculating pedestals for run $RUNNUM" rm -f $ODIR/"$RUNNUM".ped.log - PEDOPT="-runmode=1 -calibrationnevents=${PEDNEVENTS}" - # shellcheck disable=SC2086 - "$EVNDISPSYS"/bin/evndisp $MCOPT $PEDOPT &> "$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 @@ -236,16 +257,26 @@ fi ############################################### # calculate tzeros echo "Calculating average tzeros for run $RUNNUM" -TZEROPT="-runmode=7 -calibrationnevents=${TZERONEVENTS} -pedestalnoiselevel=$NOISE " -TZEROPT="$TZEROPT -lowgainpedestallevel=$LOWPEDLEV -lowgaincalibrationfile ${LOWGAINCALIBRATIONFILE}" +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 -# shellcheck disable=SC2086 -"$EVNDISPSYS"/bin/evndisp $MCOPT $TZEROPT &>> $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 @@ -261,20 +292,31 @@ 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 -# shellcheck disable=SC2086 -"$EVNDISPSYS"/bin/evndisp $MCOPT $ANAOPT &>> $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" ################################################################################# diff --git a/scripts/helper_scripts/IRF.lookup_table_parallel_sub.sh b/scripts/helper_scripts/IRF.lookup_table_parallel_sub.sh index 780517e5..ef9867da 100755 --- a/scripts/helper_scripts/IRF.lookup_table_parallel_sub.sh +++ b/scripts/helper_scripts/IRF.lookup_table_parallel_sub.sh @@ -84,22 +84,28 @@ 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" -# shellcheck disable=SC2086 "$EVNDISPSYS"/bin/mscw_energy -filltables=1 \ -limitEnergyReconstruction \ -write1DHistograms \ -inputfilelist "$DDIR/$TABFILE.list" \ -tablefile "${DDIR}/$TABFILE.root" \ - -ze=$ZA $MOPT \ + -ze=$ZA "${MOPT[@]}" \ -arrayrecid=$RECID \ -woff=$WOBBLE &> "$logfile" diff --git a/scripts/helper_scripts/IRF.mscw_energy_MC_sub.sh b/scripts/helper_scripts/IRF.mscw_energy_MC_sub.sh index 682d0f37..be9349f0 100755 --- a/scripts/helper_scripts/IRF.mscw_energy_MC_sub.sh +++ b/scripts/helper_scripts/IRF.mscw_energy_MC_sub.sh @@ -74,20 +74,35 @@ inspect_executables() } # 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 @@ -118,13 +133,21 @@ if [ $DISPBDT -eq 1 ]; then # 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_" + 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 @@ -157,8 +180,7 @@ cat "$DDIR/$OFILE.list" echo "Running mscw_energy" outputfilename="$DDIR/$OFILE.mscw.root" logfile="$OSUBDIR/$OFILE.log" -# shellcheck disable=SC2086 -"$EVNDISPSYS"/bin/mscw_energy $MOPT \ +"$EVNDISPSYS"/bin/mscw_energy "${MOPT[@]}" \ -inputfilelist "$DDIR/$OFILE.list" \ -outputfile "$outputfilename" \ -noise=$NOISE &> $logfile diff --git a/scripts/helper_scripts/SPANALYSIS.lowgainped_sub.sh b/scripts/helper_scripts/SPANALYSIS.lowgainped_sub.sh index 350a0b60..c4e7333e 100755 --- a/scripts/helper_scripts/SPANALYSIS.lowgainped_sub.sh +++ b/scripts/helper_scripts/SPANALYSIS.lowgainped_sub.sh @@ -26,16 +26,22 @@ 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 -# shellcheck disable=SC2086 -"$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 " +"$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 diff --git a/scripts/helper_scripts/SPANALYSIS.make_DST_sub.sh b/scripts/helper_scripts/SPANALYSIS.make_DST_sub.sh index c3224344..b0e2c0d4 100755 --- a/scripts/helper_scripts/SPANALYSIS.make_DST_sub.sh +++ b/scripts/helper_scripts/SPANALYSIS.make_DST_sub.sh @@ -30,7 +30,7 @@ LOGDIR="$ODIR" mkdir -p $LOGDIR # eventdisplay reconstruction parameter -ACUTS=RRRRPFILE +ACUTS=("RRRRPFILE") ######################################### # pedestal and tzero calculation. No tzeros needed for lmult. @@ -48,16 +48,15 @@ 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 -# shellcheck disable=SC2086 -"$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