From fb1ca6d3b86447b53db2d881f4e4a2178e5047d8 Mon Sep 17 00:00:00 2001
From: Wouter Deconinck <wdconinc@gmail.com>
Date: Sun, 24 Apr 2022 20:46:43 +0000
Subject: [PATCH] Add finegrained scripts for single

---
 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      |  4 ++--
 6 files changed, 78 insertions(+), 3 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

diff --git a/benchmarks/single/analyze.sh b/benchmarks/single/analyze.sh
new file mode 100644
index 00000000..1c55c077
--- /dev/null
+++ b/benchmarks/single/analyze.sh
@@ -0,0 +1,10 @@
+#!/bin/bash
+
+source 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..420923a3
--- /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_${JUGGLER_FILE_NAME_TAG}.edm4hep.root"
+export JUGGLER_REC_FILE="rec_${JUGGLER_FILE_NAME_TAG}.root"
diff --git a/benchmarks/single/config.yml b/benchmarks/single/config.yml
index e65abc06..b294ad95 100644
--- a/benchmarks/single/config.yml
+++ b/benchmarks/single/config.yml
@@ -4,10 +4,34 @@ single:compile:
   script:
     - compile_analyses.py single
 
-single:simulate:
+single:simulate_old:
   extends: .phy_benchmark
   timeout: 24 hours
   stage: simulate
   needs: ["common:detector", "single:compile"]
   script:
     - bash benchmarks/single/single.sh e-_1GeV_45to135deg
+
+single:simulate:
+  extends: .phy_benchmark
+  timeout: 2 hours
+  stage: simulate
+  needs: ["common:detector"]
+  script:
+    - 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..22167378
--- /dev/null
+++ b/benchmarks/single/reconstruct.sh
@@ -0,0 +1,15 @@
+#!/bin/bash
+
+source 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..b8fa210c
--- /dev/null
+++ b/benchmarks/single/simulate.sh
@@ -0,0 +1,18 @@
+#!/bin/bash
+
+source 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
index f4b4c9cc..80270b30 100644
--- a/benchmarks/single/single.sh
+++ b/benchmarks/single/single.sh
@@ -29,14 +29,14 @@ 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}
+    gaudirun.py ${JUGGLER_GAUDI_OPTIONS:-} ${rec}
   if [[ "$?" -ne "0" ]] ; then
     echo "ERROR running juggler"
     exit 1
   fi
 done
 
-# Analysis
+# Analyze
 root -l -b -q "benchmarks/single/analysis/analyze.cxx+(\"${JUGGLER_REC_FILE}\")"
 if [[ "$?" -ne "0" ]] ; then
   echo "ERROR analysis failed"
-- 
GitLab