From 4a2efde5bbd99e56db97b6f4f58f9c7b1c0f7913 Mon Sep 17 00:00:00 2001
From: Wouter Deconinck <wdconinc@gmail.com>
Date: Sun, 24 Apr 2022 22:50:26 +0000
Subject: [PATCH] Rename stage process to simulate, reconstruct, analyze

---
 .gitlab-ci.yml                    |  4 ++-
 benchmarks/dis/config.yml         |  6 ++---
 benchmarks/dvcs/config.yml        |  6 ++---
 benchmarks/dvmp/config.yml        |  6 ++---
 benchmarks/single/analyze.sh      | 10 +++++++
 benchmarks/single/common.sh       |  8 ++++++
 benchmarks/single/config.yml      | 26 ++++++++++++++----
 benchmarks/single/reconstruct.sh  | 15 +++++++++++
 benchmarks/single/simulate.sh     | 18 +++++++++++++
 benchmarks/single/single.sh       | 44 -------------------------------
 benchmarks/synchrotron/config.yml |  6 ++---
 benchmarks/tcs/config.yml         |  6 ++---
 benchmarks/u_omega/config.yml     |  6 ++---
 13 files changed, 93 insertions(+), 68 deletions(-)
 create mode 100644 benchmarks/single/analyze.sh
 create mode 100644 benchmarks/single/common.sh
 create mode 100644 benchmarks/single/reconstruct.sh
 create mode 100644 benchmarks/single/simulate.sh
 delete mode 100644 benchmarks/single/single.sh

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 7cdd83db..46cbc369 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -25,7 +25,9 @@ stages:
   - initialize
   - compile
   - generate
-  - process
+  - simulate
+  - reconstruct
+  - analyze
   - collect
   - finish
 
diff --git a/benchmarks/dis/config.yml b/benchmarks/dis/config.yml
index c5bcbb2a..2277cb7b 100644
--- a/benchmarks/dis/config.yml
+++ b/benchmarks/dis/config.yml
@@ -20,8 +20,8 @@ dis:generate:
   script:
     - bash benchmarks/dis/get.sh --config dis_${EBEAM}x${PBEAM} --ebeam ${EBEAM} --pbeam ${PBEAM}
 
-dis:process:
-  stage: process
+dis:simulate:
+  stage: simulate
   extends: .phy_benchmark
   needs: ["dis:generate"]
   parallel:
@@ -42,6 +42,6 @@ dis:process:
 
 dis:results:
   stage: collect
-  needs: ["dis:process"]
+  needs: ["dis:simulate"]
   script:
     - collect_tests.py dis
diff --git a/benchmarks/dvcs/config.yml b/benchmarks/dvcs/config.yml
index e1648bd3..12a1bf69 100644
--- a/benchmarks/dvcs/config.yml
+++ b/benchmarks/dvcs/config.yml
@@ -4,8 +4,8 @@ dvcs:compile:
   script:
     - compile_analyses.py dvcs
 
-dvcs:process:
-  stage: process
+dvcs:simulate:
+  stage: simulate
   extends: .phy_benchmark
   tags:
     - phy
@@ -16,7 +16,7 @@ dvcs:process:
 
 dvcs:results:
   stage: collect
-  needs: ["dvcs:process"]
+  needs: ["dvcs:simulate"]
   script:
     - ls -lrth
       #pip install junitparser
diff --git a/benchmarks/dvmp/config.yml b/benchmarks/dvmp/config.yml
index ab66e16a..d90a0be9 100644
--- a/benchmarks/dvmp/config.yml
+++ b/benchmarks/dvmp/config.yml
@@ -17,8 +17,8 @@ dvmp:generate:
           --decay muon --decay electron
           --nproc 5
 
-dvmp:process:
-  stage: process
+dvmp:simulate:
+  stage: simulate
   extends: .phy_benchmark
   needs: ["dvmp:generate"]
   timeout: 2 hour
@@ -37,6 +37,6 @@ dvmp:process:
 
 dvmp:results:
   stage: collect
-  needs: ["dvmp:process"]
+  needs: ["dvmp:simulate"]
   script:
     - collect_tests.py dvmp
diff --git a/benchmarks/single/analyze.sh b/benchmarks/single/analyze.sh
new file mode 100644
index 00000000..e9931c78
--- /dev/null
+++ b/benchmarks/single/analyze.sh
@@ -0,0 +1,10 @@
+#!/bin/bash
+
+source $(dirname $0)/common.sh $*
+
+# Analyze
+root -l -b -q "benchmarks/single/analysis/analyze.cxx+(\"${JUGGLER_REC_FILE}\")"
+if [[ "$?" -ne "0" ]] ; then
+  echo "ERROR analysis failed"
+  exit 1
+fi
diff --git a/benchmarks/single/common.sh b/benchmarks/single/common.sh
new file mode 100644
index 00000000..e7ef78ae
--- /dev/null
+++ b/benchmarks/single/common.sh
@@ -0,0 +1,8 @@
+if [[ ! -n  "${JUGGLER_N_EVENTS}" ]] ; then 
+  export JUGGLER_N_EVENTS=100
+fi
+
+export JUGGLER_FILE_NAME_TAG="${1:-e-_1GeV_45to135deg}"
+export JUGGLER_GEN_FILE="benchmarks/single/${JUGGLER_FILE_NAME_TAG}.steer"
+export JUGGLER_SIM_FILE="sim_output/sim_${JUGGLER_FILE_NAME_TAG}.edm4hep.root"
+export JUGGLER_REC_FILE="sim_output/rec_${JUGGLER_FILE_NAME_TAG}.root"
diff --git a/benchmarks/single/config.yml b/benchmarks/single/config.yml
index cac524ca..291bdeb5 100644
--- a/benchmarks/single/config.yml
+++ b/benchmarks/single/config.yml
@@ -4,10 +4,26 @@ single:compile:
   script:
     - compile_analyses.py single
 
-single:process:
+single:simulate:
   extends: .phy_benchmark
-  timeout: 24 hours
-  stage: process
-  needs: ["common:detector", "single:compile"]
+  timeout: 2 hours
+  stage: simulate
+  needs: ["common:detector"]
   script:
-    - bash benchmarks/single/single.sh e-_1GeV_45to135deg
+    - bash benchmarks/single/simulate.sh e-_1GeV_45to135deg
+
+single:reconstruct:
+  extends: .phy_benchmark
+  timeout: 2 hours
+  stage: reconstruct
+  needs: ["single:simulate"]
+  script:
+    - bash benchmarks/single/reconstruct.sh e-_1GeV_45to135deg
+
+single:analyze:
+  extends: .phy_benchmark
+  timeout: 2 hours
+  stage: analyze
+  needs: ["single:reconstruct", "single:compile"]
+  script:
+    - bash benchmarks/single/analyze.sh e-_1GeV_45to135deg
diff --git a/benchmarks/single/reconstruct.sh b/benchmarks/single/reconstruct.sh
new file mode 100644
index 00000000..7c9d6113
--- /dev/null
+++ b/benchmarks/single/reconstruct.sh
@@ -0,0 +1,15 @@
+#!/bin/bash
+
+source $(dirname $0)/common.sh $*
+
+# Reconstruct
+for rec in options/*.py ; do
+  unset tag
+  [[ $(basename ${rec} .py) =~ (.*)\.(.*) ]] && tag=".${BASH_REMATCH[2]}"
+  JUGGLER_REC_FILE=${JUGGLER_REC_FILE/.root/${tag:-}.root} \
+    gaudirun.py ${JUGGLER_GAUDI_OPTIONS:-} ${rec}
+  if [[ "$?" -ne "0" ]] ; then
+    echo "ERROR running juggler"
+    exit 1
+  fi
+done
diff --git a/benchmarks/single/simulate.sh b/benchmarks/single/simulate.sh
new file mode 100644
index 00000000..ddb191a8
--- /dev/null
+++ b/benchmarks/single/simulate.sh
@@ -0,0 +1,18 @@
+#!/bin/bash
+
+source $(dirname $0)/common.sh $*
+
+# Simulate
+ddsim --runType run \
+      --printLevel WARNING \
+      --enableGun \
+      --steeringFile ${JUGGLER_GEN_FILE} \
+      --numberOfEvents ${JUGGLER_N_EVENTS} \
+      --part.minimalKineticEnergy 1*TeV  \
+      --filter.tracker edep0 \
+      --compactFile ${DETECTOR_PATH}/${JUGGLER_DETECTOR}.xml \
+      --outputFile  ${JUGGLER_SIM_FILE}
+if [[ "$?" -ne "0" ]] ; then
+  echo "ERROR running ddsim"
+  exit 1
+fi
diff --git a/benchmarks/single/single.sh b/benchmarks/single/single.sh
deleted file mode 100644
index f4b4c9cc..00000000
--- a/benchmarks/single/single.sh
+++ /dev/null
@@ -1,44 +0,0 @@
-#!/bin/bash
-
-if [[ ! -n  "${JUGGLER_N_EVENTS}" ]] ; then 
-  export JUGGLER_N_EVENTS=100
-fi
-
-export JUGGLER_FILE_NAME_TAG="${1:-e-_1GeV_45to135deg}"
-export JUGGLER_GEN_FILE="benchmarks/single/${JUGGLER_FILE_NAME_TAG}.steer"
-export JUGGLER_SIM_FILE="sim_${JUGGLER_FILE_NAME_TAG}.edm4hep.root"
-export JUGGLER_REC_FILE="rec_${JUGGLER_FILE_NAME_TAG}.root"
-
-# Simulate
-ddsim --runType run \
-      --printLevel WARNING \
-      --enableGun \
-      --steeringFile ${JUGGLER_GEN_FILE} \
-      --numberOfEvents ${JUGGLER_N_EVENTS} \
-      --part.minimalKineticEnergy 1*TeV  \
-      --filter.tracker edep0 \
-      --compactFile ${DETECTOR_PATH}/${JUGGLER_DETECTOR}.xml \
-      --outputFile  ${JUGGLER_SIM_FILE}
-if [[ "$?" -ne "0" ]] ; then
-  echo "ERROR running ddsim"
-  exit 1
-fi
-
-# Reconstruct
-for rec in options/*.py ; do
-  unset tag
-  [[ $(basename ${rec} .py) =~ (.*)\.(.*) ]] && tag=".${BASH_REMATCH[2]}"
-  JUGGLER_REC_FILE=${JUGGLER_REC_FILE/.root/${tag:-}.root} \
-    gaudirun.py ${rec}
-  if [[ "$?" -ne "0" ]] ; then
-    echo "ERROR running juggler"
-    exit 1
-  fi
-done
-
-# Analysis
-root -l -b -q "benchmarks/single/analysis/analyze.cxx+(\"${JUGGLER_REC_FILE}\")"
-if [[ "$?" -ne "0" ]] ; then
-  echo "ERROR analysis failed"
-  exit 1
-fi
diff --git a/benchmarks/synchrotron/config.yml b/benchmarks/synchrotron/config.yml
index bf95232d..f1664212 100644
--- a/benchmarks/synchrotron/config.yml
+++ b/benchmarks/synchrotron/config.yml
@@ -4,8 +4,8 @@ synchrotron:compile:
   script:
     - compile_analyses.py synchrotron
 
-synchrotron:process:
-  stage: process
+synchrotron:simulate:
+  stage: simulate
   extends: .phy_benchmark
   tags:
     - s3
@@ -15,6 +15,6 @@ synchrotron:process:
 
 synchrotron:results:
   stage: collect
-  needs: ["synchrotron:process"]
+  needs: ["synchrotron:simulate"]
   script:
     - ls -lrth
diff --git a/benchmarks/tcs/config.yml b/benchmarks/tcs/config.yml
index 1fa13e1a..35cf7153 100644
--- a/benchmarks/tcs/config.yml
+++ b/benchmarks/tcs/config.yml
@@ -4,8 +4,8 @@ tcs:compile:
   script:
     - compile_analyses.py tcs
 
-tcs:process:
-  stage: process
+tcs:simulate:
+  stage: simulate
   extends: .phy_benchmark
   tags:
     - phy
@@ -27,6 +27,6 @@ tcs:process:
 
 tcs:results:
   stage: collect
-  needs: ["tcs:process"]
+  needs: ["tcs:simulate"]
   script:
     - ls -lrth
diff --git a/benchmarks/u_omega/config.yml b/benchmarks/u_omega/config.yml
index cca2b656..e53ce1a3 100644
--- a/benchmarks/u_omega/config.yml
+++ b/benchmarks/u_omega/config.yml
@@ -4,8 +4,8 @@ u_omega:compile:
   script:
     - compile_analyses.py u_omega
 
-u_omega:process:
-  stage: process
+u_omega:simulate:
+  stage: simulate
   extends: .phy_benchmark
   tags:
     - phy
@@ -16,6 +16,6 @@ u_omega:process:
 
 u_omega:results:
   stage: collect
-  needs: ["u_omega:process"]
+  needs: ["u_omega:simulate"]
   script:
     - ls -lrth
-- 
GitLab