Skip to content

Commit

Permalink
use bash arrays in test/get*HLT.sh scripts
Browse files Browse the repository at this point in the history
Update of the scripts

HLTrigger/Configuration/test/getHLT.sh , and
HLTrigger/Configuration/test/getFrozenHLT.sh

to use an associative array to specify which
HLT configurations should be downloaded from ConfDB.

This allows for more flexibility for non-standard use cases
(e.g. having to specify different version numbers for different subtables).
In getFrozenHLT.sh , this change also avoids having
to specify the list of configurations in a separate string
(which was named TABLES prior to this commit):
now, it is sufficient to add a new configuration to the associative array.

The downside of using associative arrays is that
the configurations are not downloaded anymore in a specific order,
but said order is (and should be) unimportant in this context.
  • Loading branch information
missirol committed Aug 5, 2023
1 parent e8de730 commit 825d43a
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 25 deletions.
28 changes: 18 additions & 10 deletions HLTrigger/Configuration/test/getFrozenHLT.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
#!/bin/bash

# ConfDB configurations to use
TABLES="Fake Fake1 Fake2 2023v12"
HLT_Fake="/dev/CMSSW_13_0_0/Fake"
HLT_Fake1="/dev/CMSSW_13_0_0/Fake1"
HLT_Fake2="/dev/CMSSW_13_0_0/Fake2"
HLT_2023v12="/frozen/2023/2e34/v1.2/HLT"
# - if no explicit version, the most recent one is taken
# - to use explicit version, specify it in the entries below
# - to skip a given configuration, remove or comment the corresponding entry in the array TABLES
# - new configurations can be added by expanding the array TABLES
# - for new configurations, ensure that the corresponding "auto" GTs are defined in
# Configuration/HLT/python/autoCondHLT.py , and
# HLTrigger/Configuration/python/Tools/options.py
declare -A TABLES=(
["Fake"]="/dev/CMSSW_13_0_0/Fake"
["Fake1"]="/dev/CMSSW_13_0_0/Fake1"
["Fake2"]="/dev/CMSSW_13_0_0/Fake2"
["2023v12"]="/frozen/2023/2e34/v1.2/HLT"
)

# command-line arguments
VERBOSE=false # print extra messages to stdout
Expand Down Expand Up @@ -52,8 +60,8 @@ INITDIR="${PWD}"
cd "${CMSSW_BASE}"/src/HLTrigger/Configuration/test

# create cff fragments and cfg configs
for TABLE in ${TABLES}; do
CONFIG=$(eval echo \$$(echo HLT_"${TABLE}"))
for TABLE in "${!TABLES[@]}"; do
CONFIG="${TABLES[${TABLE}]}"
echo "${TABLE} (config: ${CONFIG})"

# cff fragment of each HLT menu (do not use any conditions or L1T override)
Expand All @@ -62,10 +70,10 @@ for TABLE in ${TABLES}; do

# GlobalTag
AUTOGT="auto:run3_hlt_${TABLE}"
if [ "${TABLE}" = "Fake1" ] || [ "${TABLE}" = "Fake2" ] || [ "${TABLE}" = "2018" ]; then
AUTOGT="auto:run2_hlt_${TABLE}"
elif [ "${TABLE}" = "Fake" ]; then
if [ "${TABLE}" = "Fake" ]; then
AUTOGT="auto:run1_hlt_${TABLE}"
elif [ "${TABLE}" = "Fake1" ] || [ "${TABLE}" = "Fake2" ]; then
AUTOGT="auto:run2_hlt_${TABLE}"
fi

# standalone cfg file of each HLT menu
Expand Down
38 changes: 23 additions & 15 deletions HLTrigger/Configuration/test/getHLT.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
#!/bin/bash

# ConfDB configurations to use
MASTER="/dev/CMSSW_13_0_0/HLT" # no explicit version, take the most recent
TARGET="/dev/CMSSW_13_0_0/\$TABLE" # no explicit version, take the most recent
# ConfDB directory hosting the HLT configurations
CONFDBDIR="/dev/CMSSW_13_0_0"

TABLES="GRun HIon PIon PRef" # $TABLE in the above variable will be expanded to these TABLES
# ConfDB configurations to use
# - if no explicit version, the most recent one is taken
# - to use explicit version, specify it in the entries below
# - to skip a given configuration, remove or comment the corresponding entry in the array TABLES
# - new configurations can be added by expanding the array TABLES
# - for new configurations, ensure that the corresponding "auto" GTs are defined in
# Configuration/HLT/python/autoCondHLT.py , and
# HLTrigger/Configuration/python/Tools/options.py
declare -A TABLES=(
["FULL"]="${CONFDBDIR}/HLT"
["GRun"]="${CONFDBDIR}/GRun"
["HIon"]="${CONFDBDIR}/HIon"
["PIon"]="${CONFDBDIR}/PIon"
["PRef"]="${CONFDBDIR}/PRef"
)

# command-line arguments
VERBOSE=false # print extra messages to stdout
Expand Down Expand Up @@ -51,26 +64,21 @@ INITDIR="${PWD}"
cd "${CMSSW_BASE}"/src/HLTrigger/Configuration/test

# create cff fragments and cfg configs
for TABLE in FULL ${TABLES}; do
if [ "${TABLE}" = "FULL" ]; then
CONFIG="${MASTER}"
else
CONFIG=$(eval echo ${TARGET})
fi

for TABLE in "${!TABLES[@]}"; do
CONFIG="${TABLES[${TABLE}]}"
echo "${TABLE} (config: ${CONFIG})"

# cff fragment of each HLT menu (do not use any conditions or L1T override)
log " creating cff fragment of HLT menu..."
hltGetConfiguration "${CONFIG}" --cff --data --type "${TABLE}" ${DBPROXYOPTS} > ../python/HLT_"${TABLE}"_cff.py

# cff fragment of EventContents (only for MASTER config)
# cff fragment of EventContents (only for FULL config)
if [ "${TABLE}" = "FULL" ]; then
log " creating cff fragment of EventContents..."
./getEventContent.py "${MASTER}" ${DBPROXYOPTS} > ../python/HLTrigger_EventContent_cff.py
./getEventContent.py "${CONFIG}" ${DBPROXYOPTS} > ../python/HLTrigger_EventContent_cff.py
fi

# cff fragment of PrimaryDatasets of each HLT menu (except for MASTER config)
# cff fragment of PrimaryDatasets of each HLT menu (except for FULL config)
if [ "${TABLE}" != "FULL" ]; then
log " creating cff fragment of Primary Datasets..."
./getDatasets.py "${CONFIG}" ${DBPROXYOPTS} > ../python/HLTrigger_Datasets_"${TABLE}"_cff.py
Expand All @@ -84,7 +92,7 @@ for TABLE in FULL ${TABLES}; do
AUTOGT="auto:run1_hlt_${TABLE}"
fi

# standalone cfg file of each HLT menu (incl. MASTER config)
# standalone cfg file of each HLT menu (incl. FULL config)
log " creating full cfg of HLT menu..."
hltGetConfiguration "${CONFIG}" --full --data --type "${TABLE}" --unprescale --process "HLT${TABLE}" --globaltag "${AUTOGT}" \
--input "file:RelVal_Raw_${TABLE}_DATA.root" ${DBPROXYOPTS} > OnLine_HLT_"${TABLE}".py
Expand Down

0 comments on commit 825d43a

Please sign in to comment.