From 9bb0f094f0190427af25225c8ca4ea78d925642f Mon Sep 17 00:00:00 2001
From: Wouter Deconinck <wdconinc@gmail.com>
Date: Thu, 28 Jul 2022 18:55:25 -0500
Subject: [PATCH] fix: migrate from JUGGLER_DETECTOR to simply DETECTOR

---
 .gitlab-ci.yml        | 22 +++++++++++-----------
 bin/build_detector.sh | 38 +++++++++++++++++++-------------------
 bin/env.sh            | 28 +++++++---------------------
 bin/print_env.sh      |  6 +++---
 4 files changed, 40 insertions(+), 54 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 3863241..be9faa8 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -75,23 +75,23 @@ detector_benchmarks:
     - if: '$CI_SERVER_HOST == "eicweb.phy.anl.gov"' 
   needs: ["common:variables"]
   variables:
-    JUGGLER_DETECTOR: "ecce"
-    JUGGLER_DETECTOR_CONFIG: "ecce"
+    DETECTOR: "ecce"
+    DETECTOR_CONFIG: "ecce"
     COMMON_BENCH_VERSION: "$COMMON_BENCH_VERSION"
   trigger:
     project: EIC/benchmarks/detector_benchmarks
     strategy: depend
   parallel:
     matrix:
-      - JUGGLER_DETECTOR: 'athena'
-        JUGGLER_DETECTOR_CONFIG: 'athena'
-        JUGGLER_DETECTOR_VERSION: 'master'
-      - JUGGLER_DETECTOR: 'ecce'
-        JUGGLER_DETECTOR_CONFIG: 'ecce_imaging'
-        JUGGLER_DETECTOR_VERSION: 'main'
-      - JUGGLER_DETECTOR: 'ecce'
-        JUGGLER_DETECTOR_CONFIG: 'ecce_sciglass'
-        JUGGLER_DETECTOR_VERSION: 'main'
+      - DETECTOR: 'athena'
+        DETECTOR_CONFIG: 'athena'
+        DETECTOR_VERSION: 'master'
+      - DETECTOR: 'ecce'
+        DETECTOR_CONFIG: 'ecce_imaging'
+        DETECTOR_VERSION: 'main'
+      - DETECTOR: 'ecce'
+        DETECTOR_CONFIG: 'ecce_sciglass'
+        DETECTOR_VERSION: 'main'
 
 pages:
   image: eicweb.phy.anl.gov:4567/containers/eic_container/alpine
diff --git a/bin/build_detector.sh b/bin/build_detector.sh
index 3803f3f..fcfdc5b 100755
--- a/bin/build_detector.sh
+++ b/bin/build_detector.sh
@@ -1,19 +1,19 @@
 #!/bin/bash
 
 ## =============================================================================
-## Build and install the JUGGLER_DETECTOR detector package into our local prefix
+## Build and install the DETECTOR detector package into our local prefix
 ## =============================================================================
 
 ## =============================================================================
 ## Load the environment variables. To build the detector we need the following
 ## variables:
 ##
-## - JUGGLER_DETECTOR: the detector package we want to use for this benchmark
+## - 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}
+##                     this is the same as ${DETECTOR_PREFIX}/${DETECTOR}
 
 if [ -n "${LOCAL_PREFIX}" ] ; then 
   source .local/bin/env.sh
@@ -29,23 +29,23 @@ pushd ${DETECTOR_PREFIX}
 ## We need an up-to-date copy of the detector
 ## start clean to avoid issues...
 
-if [ -d "${JUGGLER_DETECTOR}" ]; then
-  echo "cleaning up ${JUGGLER_DETECTOR}" 
-  mv "${JUGGLER_DETECTOR}" "$(mktemp)-${JUGGLER_DETECTOR}"
+if [ -d "${DETECTOR}" ]; then
+  echo "cleaning up ${DETECTOR}" 
+  mv "${DETECTOR}" "$(mktemp)-${DETECTOR}"
 fi
-echo "Fetching ${JUGGLER_DETECTOR}"
-if [ -n "${JUGGLER_DETECTOR_DEPLOY_TOKEN_USERNAME:-}" -a -n "${JUGGLER_DETECTOR_DEPLOY_TOKEN_PASSWORD:-}" ]; then
-  DEPLOY_TOKEN="${JUGGLER_DETECTOR_DEPLOY_TOKEN_USERNAME}:${JUGGLER_DETECTOR_DEPLOY_TOKEN_PASSWORD}@"
-  echo "Deploy token for ${JUGGLER_DETECTOR_DEPLOY_TOKEN_USERNAME} is masked in the next line."
+echo "Fetching ${DETECTOR}"
+if [ -n "${DETECTOR_DEPLOY_TOKEN_USERNAME:-}" -a -n "${DETECTOR_DEPLOY_TOKEN_PASSWORD:-}" ]; then
+  DEPLOY_TOKEN="${DETECTOR_DEPLOY_TOKEN_USERNAME}:${DETECTOR_DEPLOY_TOKEN_PASSWORD}@"
+  echo "Deploy token for ${DETECTOR_DEPLOY_TOKEN_USERNAME} is masked in the next line."
 else
   DEPLOY_TOKEN=""
 fi
-echo "git clone -b ${JUGGLER_DETECTOR_VERSION} --depth 1 ${JUGGLER_DETECTOR_REPOSITORYURL:-https://eicweb.phy.anl.gov/EIC/detectors/${JUGGLER_DETECTOR}.git}"
-git clone -b ${JUGGLER_DETECTOR_VERSION} --depth 1 ${JUGGLER_DETECTOR_REPOSITORYURL:-https://${DEPLOY_TOKEN}eicweb.phy.anl.gov/EIC/detectors/${JUGGLER_DETECTOR}.git}
-if [ -f "${JUGGLER_DETECTOR}/requirements.txt" ] ; then
-  python -m pip install -r ${JUGGLER_DETECTOR}/requirements.txt
+echo "git clone -b ${DETECTOR_VERSION} --depth 1 ${DETECTOR_REPOSITORYURL:-https://eicweb.phy.anl.gov/EIC/detectors/${DETECTOR}.git}"
+git clone -b ${DETECTOR_VERSION} --depth 1 ${DETECTOR_REPOSITORYURL:-https://${DEPLOY_TOKEN}eicweb.phy.anl.gov/EIC/detectors/${DETECTOR}.git}
+if [ -f "${DETECTOR}/requirements.txt" ] ; then
+  python -m pip install -r ${DETECTOR}/requirements.txt
 fi
-rm -rf "${JUGGLER_DETECTOR}/.git"
+rm -rf "${DETECTOR}/.git"
 
 ## We need an up-to-date copy of the detector
 ## start clean to avoid issues...
@@ -86,13 +86,13 @@ ln -s -f ${DETECTOR_PREFIX}/${BEAMLINE_CONFIG}/${BEAMLINE_CONFIG} ${DETECTOR_PAT
 popd
 ## =============================================================================
 ## Step 2: Compile and install the detector definition
-echo "Building and installing the ${JUGGLER_DETECTOR} package"
+echo "Building and installing the ${DETECTOR} package"
 
-mkdir -p ${DETECTOR_PREFIX}/${JUGGLER_DETECTOR}_build
-pushd ${DETECTOR_PREFIX}/${JUGGLER_DETECTOR}_build
+mkdir -p ${DETECTOR_PREFIX}/${DETECTOR}_build
+pushd ${DETECTOR_PREFIX}/${DETECTOR}_build
 cmake ${DETECTOR_PATH} -DCMAKE_INSTALL_PREFIX=${LOCAL_PREFIX} -DCMAKE_CXX_STANDARD=17 && make -j$(($(nproc)/4+1)) install || exit 1
 popd
-rm -rf ${DETECTOR_PREFIX}/${JUGGLER_DETECTOR}_build
+rm -rf ${DETECTOR_PREFIX}/${DETECTOR}_build
 
 mkdir -p ${DETECTOR_PREFIX}/${BEAMLINE_CONFIG}_build
 pushd ${DETECTOR_PREFIX}/${BEAMLINE_CONFIG}_build
diff --git a/bin/env.sh b/bin/env.sh
index be93756..83053ca 100755
--- a/bin/env.sh
+++ b/bin/env.sh
@@ -7,9 +7,9 @@
 ##
 ##  - BEAMLINE_CONFIG:         compact detector files for the interaciton point beamline
 ##  - BEAMLINE_CONFIG_VERSION: compact detector files for the interaciton point beamline
-##  - JUGGLER_DETECTOR:        detector package to be used for the benchmark
-##  - JUGGLER_DETECTOR_CONFIG: detector package config to be used for the benchmark
-##  - JUGGLER_DETECTOR_VERSION:        detector package to be used for the benchmark
+##  - DETECTOR:        detector package to be used for the benchmark
+##  - DETECTOR_CONFIG: detector package config to be used for the benchmark
+##  - DETECTOR_VERSION:        detector package to be used for the benchmark
 ##  - JUGGLER_N_EVENTS:        events processed by simulation/reconstruction
 ##  - JUGGLER_INSTALL_PREFIX:  location where Juggler (digi/recon) is installed
 ##  - JUGGLER_N_THREADS:       Number of threads/processes to spawn in parallel
@@ -56,20 +56,6 @@ if [ ! -n  "${DETECTOR_VERSION}" ] ; then
 fi
 
 
-## Detector package to be used during the benchmark process
-if [ ! -n  "${JUGGLER_DETECTOR}" ] ; then 
-  export JUGGLER_DETECTOR="ecce"
-fi
-
-if [ ! -n  "${JUGGLER_DETECTOR_CONFIG}" ] ; then
-  export JUGGLER_DETECTOR_CONFIG="${JUGGLER_DETECTOR}"
-fi
-
-if [ ! -n  "${JUGGLER_DETECTOR_VERSION}" ] ; then 
-  export JUGGLER_DETECTOR_VERSION="main"
-fi
-
-
 ## Number of events that will be processed by the reconstruction
 if [ ! -n  "${JUGGLER_N_EVENTS}" ] ; then 
   export JUGGLER_N_EVENTS=100
@@ -129,16 +115,16 @@ export DETECTOR_PREFIX="${LOCAL_PREFIX}/detector"
 mkdir -p ${DETECTOR_PREFIX}
 
 ## detector path: actual detector definition path
-export DETECTOR_PATH="${DETECTOR_PREFIX}/${JUGGLER_DETECTOR}"
+export DETECTOR_PATH="${DETECTOR_PREFIX}/${DETECTOR}"
 
 ## build dir for ROOT to put its binaries etc.
 export ROOT_BUILD_DIR=$LOCAL_PREFIX/root_build
 
 export ROOT_INCLUDE_PATH=${LOCAL_PREFIX}/include:${ROOT_INCLUDE_PATH}
 
-echo "JUGGLER_DETECTOR:           ${JUGGLER_DETECTOR}"
-echo "JUGGLER_DETECTOR_CONFIG:    ${JUGGLER_DETECTOR_CONFIG}"
-echo "JUGGLER_DETECTOR_VERSION:   ${JUGGLER_DETECTOR_VERSION}"
+echo "DETECTOR:           ${DETECTOR}"
+echo "DETECTOR_CONFIG:    ${DETECTOR_CONFIG}"
+echo "DETECTOR_VERSION:   ${DETECTOR_VERSION}"
 echo "JUGGLER_N_EVENTS:           ${JUGGLER_N_EVENTS}"
 echo "JUGGLER_N_THREADS:          ${JUGGLER_N_THREADS}"
 echo "JUGGLER_RNG_SEED:           ${JUGGLER_RNG_SEED}"
diff --git a/bin/print_env.sh b/bin/print_env.sh
index 5c37447..d04b8ad 100755
--- a/bin/print_env.sh
+++ b/bin/print_env.sh
@@ -1,9 +1,9 @@
 #!/bin/bash
 
 echo "JUGGLER_TAG:                ${JUGGLER_TAG}"
-echo "JUGGLER_DETECTOR:           ${JUGGLER_DETECTOR}"
-echo "JUGGLER_DETECTOR_CONFIG:    ${JUGGLER_DETECTOR_CONFIG}"
-echo "JUGGLER_DETECTOR_VERSION:   ${JUGGLER_DETECTOR_VERSION}"
+echo "DETECTOR:           ${DETECTOR}"
+echo "DETECTOR_CONFIG:    ${DETECTOR_CONFIG}"
+echo "DETECTOR_VERSION:   ${DETECTOR_VERSION}"
 echo "JUGGLER_N_EVENTS:           ${JUGGLER_N_EVENTS}"
 echo "JUGGLER_N_THREADS:          ${JUGGLER_N_THREADS}"
 echo "JUGGLER_RNG_SEED:           ${JUGGLER_RNG_SEED}"
-- 
GitLab