diff --git a/bin/build_detector.sh b/bin/build_detector.sh index 20b863002d839084df3ec42eb2920208d672684b..aab1ed0079d62f3e91bef37d6da0585353814db8 100755 --- a/bin/build_detector.sh +++ b/bin/build_detector.sh @@ -5,8 +5,8 @@ ## ============================================================================= ## make sure we launch this script from the project root directory -#PROJECT_ROOT="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"/.. -#pushd ${PROJECT_ROOT} +PROJECT_ROOT="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"/.. +pushd ${PROJECT_ROOT} ## ============================================================================= ## Load the environment variables. To build the detector we need the following @@ -14,14 +14,13 @@ ## ## - JUGGLER_DETECTOR: the detector package we want to use for this benchmark ## - LOCAL_PREFIX: location where local packages should be installed -## - LOCAL_DATA_PATH: local storage for pipeline jobs ## - DETECTOR_PREFIX: prefix for the detector definitions ## - DETECTOR_PATH: full path for the detector definitions ## this is the same as ${DETECTOR_PREFIX}/${JUGGLER_DETECTOR} ## ## You can read options/env.sh for more in-depth explanations of the variables ## and how they can be controlled. -source $(dirname "$0")/env.sh +source options/env.sh ## ============================================================================= ## Step 1: download/update the detector definitions (if needed) @@ -29,63 +28,44 @@ pushd ${DETECTOR_PREFIX} ## We need an up-to-date copy of the detector ## start clean to avoid issues... -if [ -d "${JUGGLER_DETECTOR}" ]; then +if [ -d ${JUGGLER_DETECTOR} ]; then echo "cleaning up ${JUGGLER_DETECTOR}" - mv "${JUGGLER_DETECTOR}" /tmp/. + rm -rf ${JUGGLER_DETECTOR} fi echo "Fetching ${JUGGLER_DETECTOR}" -git clone -b ${JUGGLER_DETECTOR_VERSION} --depth 1 https://eicweb.phy.anl.gov/EIC/detectors/${JUGGLER_DETECTOR}.git -[[ -n "$?" ]] || exit 1 -rm -rf "${JUGGLER_DETECTOR}/.git" - -## We need an up-to-date copy of the detector -## start clean to avoid issues... -if [ -d "${BEAMLINE_CONFIG}" ]; then - echo "cleaning up ${BEAMLINE_CONFIG}" - mv "${BEAMLINE_CONFIG}" /tmp/. -fi -echo "Fetching ${BEAMLINE_CONFIG}" -echo "git clone -b ${BEAMLINE_CONFIG_VERSION} --depth 1 https://eicweb.phy.anl.gov/EIC/detectors/${BEAMLINE_CONFIG}.git" -git clone -b ${BEAMLINE_CONFIG_VERSION} --depth 1 https://eicweb.phy.anl.gov/EIC/detectors/${BEAMLINE_CONFIG}.git -[[ -n "$?" ]] || exit 1 -rm -rf "${BEAMLINE_CONFIG}/.git" - +git clone -b ${JUGGLER_DETECTOR_VERSION} https://eicweb.phy.anl.gov/EIC/detectors/${JUGGLER_DETECTOR}.git +#else + #echo "Updating ${JUGGLER_DETECTOR}" + #pushd ${JUGGLER_DETECTOR} + #git pull --ff-only + #popd +#fi ## We also need an up-to-date copy of the accelerator. For now this is done ## manually. Down the road we could maybe automize this with cmake if [ -d accelerator ]; then echo "cleaning up accelerator" - mv accelerator /tmp/. + rm -rf accelerator fi echo "Fetching accelerator" -git clone --depth 1 https://eicweb.phy.anl.gov/EIC/detectors/accelerator.git -[[ -n "$?" ]] || exit 1 -rm -rf "accelerator/.git" - +git clone https://eicweb.phy.anl.gov/EIC/detectors/accelerator.git +#else +# echo "Updating accelerator" +# pushd accelerator +# git pull --ff-only +# popd +#fi ## Now symlink the accelerator definition into the detector definition echo "Linking accelerator definition into detector definition" ln -s -f ${DETECTOR_PREFIX}/accelerator/eic ${DETECTOR_PATH}/eic -[[ -n "$?" ]] || exit 1 -ln -s -f ${DETECTOR_PREFIX}/${BEAMLINE_CONFIG}/${BEAMLINE_CONFIG} ${DETECTOR_PATH}/${BEAMLINE_CONFIG} -[[ -n "$?" ]] || exit 1 -popd ## ============================================================================= ## Step 2: Compile and install the detector definition echo "Building and installing the ${JUGGLER_DETECTOR} package" -mkdir -p ${DETECTOR_PREFIX}/${JUGGLER_DETECTOR}_build -pushd ${DETECTOR_PREFIX}/${JUGGLER_DETECTOR}_build -cmake ${DETECTOR_PATH} -DCMAKE_INSTALL_PREFIX=${LOCAL_PREFIX} -DCMAKE_CXX_STANDARD=17 && make -j30 install || exit 1 -popd -rm -rf ${DETECTOR_PREFIX}/${JUGGLER_DETECTOR}_build - -mkdir -p ${DETECTOR_PREFIX}/${BEAMLINE_CONFIG}_build -pushd ${DETECTOR_PREFIX}/${BEAMLINE_CONFIG}_build -cmake ${DETECTOR_PREFIX}/${BEAMLINE_CONFIG} -DCMAKE_INSTALL_PREFIX=${LOCAL_PREFIX} -DCMAKE_CXX_STANDARD=17 && make -j30 install || exit 1 -popd -rm -rf ${DETECTOR_PREFIX}/${BEAMLINE_CONFIG}_build - - +mkdir -p ${DETECTOR_PREFIX}/build +pushd ${DETECTOR_PREFIX}/build +cmake ${DETECTOR_PATH} -DCMAKE_INSTALL_PREFIX=${LOCAL_PREFIX} -DCMAKE_CXX_STANDARD=17 && + make -j30 install || exit 1 ## ============================================================================= ## Step 3: That's all! diff --git a/bin/parse_cmd.sh b/bin/parse_cmd.sh new file mode 100755 index 0000000000000000000000000000000000000000..04028d8958d03df22f7b2d964a75acf2d9b47317 --- /dev/null +++ b/bin/parse_cmd.sh @@ -0,0 +1,127 @@ +#!/bin/bash + +## ============================================================================= +## Generic utility script to parse command line arguments for the various +## bash scripts that control the CI. This script should be source'd with +## command line arguments from a bash-like (non-POSIX) shell such as +## bash or zsh. +## +## To control some of the functionality of the script, you can set the following +## environment variables prior to calling the script: +## - REQUIRE_DECAY: require the --decay flag to be set +## ============================================================================= + +## Commented out because this should be taken care of by the +## calling script to not enforce a fixed directory structure. +## make sure we launch this script from the project root directory +#PROJECT_ROOT="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"/.. +#pushd ${PROJECT_ROOT} + +## ============================================================================= +## Step 1: Process the command line arguments + +function print_the_help { + echo "USAGE: --ebeam E --pbeam E --config C1 --decay D2" + echo " [--config C2 --decay D2 --decay D3 ...]" + echo "REQUIRED ARGUMENTS:" + echo " --ebeam Electron beam energy" + echo " --pbeam Ion beam energy" + echo " --config Generator configuration identifiers (at least one)" + if [ ! -z ${REQUIRE_DECAY} ]; then + echo " --decay Specific decay particle (e.g. muon)." + fi + if [ ! -z ${REQUIRE_LEADING} ]; then + echo " --leading Leading particle of interest (e.g. jpsi)." + fi + echo " -h,--help Print this message" + echo "" + echo " Generate multiple monte carlo samples for a desired process." + exit +} + +## Required variables +EBEAM= +PBEAM= +DECAYS= +CONFIG= + +while [ $# -gt 0 ] +do + key="$1" + case $key in + --config) + CONFIG="$2" + shift # past argument + shift # past value + ;; + --ebeam) + EBEAM="$2" + shift # past argument + shift # past value + ;; + --pbeam) + PBEAM="$2" + shift # past argument + shift # past value + ;; + --leading) + LEADING="$2" + shift # past argument + shift # past value + ;; + --decay) + DECAY="$2" + shift # past argument + shift # past value + ;; + -h|--help) + print_the_help + exit 0 + ;; + *) # unknown option + echo "unknown option" + exit 1 + ;; + esac +done + +if [ -z $CONFIG ]; then + echo "ERROR: CONFIG not defined: --config <config>" + print_the_help + exit 1 +elif [ -z $EBEAM ]; then + echo "ERROR: EBEAM not defined: --ebeam <energy>" + print_the_help + exit 1 +elif [ -z $PBEAM ]; then + echo "ERROR: PBEAM not defined: --pbeam <energy>" + print_the_help + exit 1 +elif [ -z $LEADING ] && [ ! -z $REQUIRE_LEADING ]; then + echo "ERROR: LEADING not defined: --leading <channel>" + print_the_help + exit 1 +elif [ ! -z $LEADING ] && [ -z $REQUIRE_LEADING ]; then + echo "ERROR: LEADING flag specified but not required" + print_the_help + exit 1 +elif [ -z $DECAY ] && [ ! -z $REQUIRE_DECAY ]; then + echo "ERROR: DECAY not defined: --decay <channel>" + print_the_help + exit 1 +elif [ ! -z $DECAY ] && [ -z $REQUIRE_DECAY ]; then + echo "ERROR: DECAY flag specified but not required" + print_the_help + exit 1 +fi + +## Export the configured variables +export CONFIG +export EBEAM +export PBEAM +if [ ! -z $REQUIRE_LEADING ]; then + export LEADING +fi +if [ ! -z $REQUIRE_DECAY ]; then + export DECAY +fi diff --git a/bin/print_env.sh b/bin/print_env.sh index d8b19f517d873525029b474c9ff8bab0011bc687..431ab79f09acf50d57854a46b976c5ac990da218 100755 --- a/bin/print_env.sh +++ b/bin/print_env.sh @@ -8,8 +8,6 @@ echo "JUGGLER_N_THREADS: ${JUGGLER_N_THREADS}" echo "JUGGLER_RNG_SEED: ${JUGGLER_RNG_SEED}" echo "JUGGLER_INSTALL_PREFIX: ${JUGGLER_INSTALL_PREFIX}" echo "LOCAL_PREFIX: ${LOCAL_PREFIX}" -echo "LOCAL_DATA_PATH: ${LOCAL_DATA_PATH}" echo "DETECTOR_PREFIX: ${DETECTOR_PREFIX}" echo "DETECTOR_PATH: ${DETECTOR_PATH}" -echo "BEAMLINE_CONFIG: ${BEAMLINE_CONFIG}" -echo "BEAMLINE_CONFIG_VERSION: ${BEAMLINE_CONFIG_VERSION}" +echo "EIC_DATA_MODEL_VERSION: ${EIC_DATA_MODEL_VERSION}"