Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into add_lowq2_benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
simonge committed May 16, 2024
2 parents 861c47b + 7be4db4 commit 8569cbe
Show file tree
Hide file tree
Showing 34 changed files with 1,390 additions and 457 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/mirror.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Mirror and Trigger EICweb

on:
push:
workflow_dispatch:

concurrency:
group: mirror
cancel-in-progress: false

jobs:
build:
name: Mirror and Trigger EICweb
runs-on: ubuntu-latest
permissions:
actions: write
contents: read
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Push to EICweb
uses: eic/gitlab-sync@master
with:
url: https://eicweb.phy.anl.gov/EIC/benchmarks/detector_benchmarks.git/
token: ${{ secrets.GITLAB_TOKEN }}
username: ${{ secrets.GITLAB_USERNAME }}
ciskip: true
- name: Trigger EICweb
uses: eic/trigger-gitlab-ci@v2
with:
url: https://eicweb.phy.anl.gov
project_id: 399
token: ${{ secrets.EICWEB_DETECTOR_BENCHMARKS_TRIGGER }}
ref_name: ${{ github.event.pull_request.head.ref || github.ref }}
variables:
GITHUB_REPOSITORY=${{ github.repository }}
GITHUB_SHA=${{ github.event.pull_request.head.sha || github.sha }}
GITHUB_PR=${{ github.event.pull_request.number }}
PIPELINE_NAME=${{ github.event.pull_request.title }}
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,7 @@ __pycache__/
calorimeters/test/
*.d
*.pcm

# org2py output
benchmarks/backgrounds/ecal_backwards.py
benchmarks/ecal_gaps/ecal_gaps.py
74 changes: 33 additions & 41 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
image: ${BENCHMARKS_REGISTRY}/${BENCHMARKS_CONTAINER}:${BENCHMARKS_TAG}

variables:
DETECTOR: epic
DETECTOR_CONFIG: epic_craterlake
DETECTOR_REPOSITORYURL: 'https://github.com/eic/epic.git'
GITHUB_SHA: ''
GITHUB_REPOSITORY: ''

workflow:
name: '$PIPELINE_NAME'
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
- if: '$CI_PIPELINE_SOURCE == "web"'
- if: '$CI_PIPELINE_SOURCE == "webide"'
- if: '$CI_PIPELINE_SOURCE == "trigger"'
- if: '$CI_COMMIT_BRANCH == "master"'
- if: '$CI_COMMIT_TAG'

Expand All @@ -21,10 +30,10 @@ default:
- .local/share
- results
- config
- juggler.env
- .env
- summary.txt
reports:
dotenv: juggler.env
dotenv: .env

stages:
- status-pending
Expand All @@ -40,6 +49,7 @@ stages:
- status-report

.status:
image: curlimages/curl:latest
script:
- |
if [ -n "${GITHUB_SHA}" ] ; then
Expand Down Expand Up @@ -67,49 +77,17 @@ benchmarks:detector:pending:
common:setup:
stage: config
before_script:
script:
- |
if [[ "${COMMON_BENCH_VERSION}" == "" ]] ; then
export COMMON_BENCH_VERSION="master"
fi
echo "COMMON_BENCH_VERSION = ${COMMON_BENCH_VERSION}"
echo "COMMON_BENCH_VERSION=${COMMON_BENCH_VERSION}" >> .env
git clone -b "${COMMON_BENCH_VERSION}" https://eicweb.phy.anl.gov/EIC/benchmarks/common_bench.git setup
script:
- |
if [[ "x${CI_PIPELINE_SOURCE}" == "xmerge_request_event" || "$CI_COMMIT_BRANCH" == "master" ]]; then
echo "DETECTOR = ${DETECTOR}"
echo "DETECTOR_CONFIG = ${DETECTOR_CONFIG}"
echo "DETECTOR_VERSION = ${DETECTOR_VERSION}"
echo "DETECTOR_REPOSITORYURL = ${DETECTOR_REPOSITORYURL}"
echo "DETECTOR=$DETECTOR" >> juggler.env
echo "DETECTOR_CONFIG=$DETECTOR_CONFIG" >> juggler.env
echo "DETECTOR_VERSION=$DETECTOR_VERSION" >> juggler.env
echo "DETECTOR_REPOSITORYURL=$DETECTOR_REPOSITORYURL" >> juggler.env
echo "DETECTOR_DEPLOY_TOKEN_USERNAME=${DEPLOY_TOKEN_USERNAME}" >> juggler.env
echo "DETECTOR_DEPLOY_TOKEN_PASSWORD=${DEPLOY_TOKEN_PASSWORD}" >> juggler.env
echo "COMMON_BENCH_VERSION=$COMMON_BENCH_VERSION" >> juggler.env
else
if [[ "${DETECTOR}" == "" ]] ; then
export DETECTOR="epic"
fi
if [[ "${DETECTOR_CONFIG}" == "" ]] ; then
export DETECTOR_CONFIG="${DETECTOR}"
fi
if [[ "${DETECTOR_VERSION}" == "" ]] ; then
export DETECTOR_VERSION="main"
fi
if [[ "${DETECTOR_REPOSITORYURL}" == "" ]] ; then
export DETECTOR_REPOSITORYURL="https://github.com/eic/${DETECTOR}"
fi
echo "DETECTOR = ${DETECTOR}"
echo "DETECTOR_CONFIG = ${DETECTOR_CONFIG}"
echo "DETECTOR_VERSION = ${DETECTOR_VERSION}"
echo "DETECTOR_REPOSITORYURL = ${DETECTOR_REPOSITORYURL}"
echo "DETECTOR=$DETECTOR" >> juggler.env
echo "DETECTOR_CONFIG=$DETECTOR_CONFIG" >> juggler.env
echo "DETECTOR_VERSION=$DETECTOR_VERSION" >> juggler.env
echo "DETECTOR_REPOSITORYURL=$DETECTOR_REPOSITORYURL" >> juggler.env
echo "COMMON_BENCH_VERSION=$COMMON_BENCH_VERSION" >> juggler.env
fi
echo "BENCHMARKS_TAG: ${BENCHMARKS_TAG}"
echo "BENCHMARKS_CONTAINER: ${BENCHMARKS_CONTAINER}"
echo "BENCHMARKS_REGISTRY: ${BENCHMARKS_REGISTRY}"
- source setup/bin/env.sh && ./setup/bin/install_common.sh


Expand Down Expand Up @@ -140,34 +118,41 @@ get_data:
- ls -lrtha
- ln -s "${LOCAL_DATA_PATH}/sim_output" sim_output
- ln -s "${LOCAL_DATA_PATH}/datasets/data" data
# snakemake support
- mkdir "${DETECTOR_CONFIG}"
- ln -s "${LOCAL_DATA_PATH}/sim_output" "${DETECTOR_CONFIG}/sim_output"
- ln -s "../results" "${DETECTOR_CONFIG}/results"
- ls -lrtha
retry:
max: 2
when:
- runner_system_failure

include:
# - local: 'benchmarks/backgrounds/config.yml'
- local: 'benchmarks/ecal_gaps/config.yml'
- local: 'benchmarks/tracking_detectors/config.yml'
- local: 'benchmarks/barrel_ecal/config.yml'
- local: 'benchmarks/barrel_hcal/config.yml'
- local: 'benchmarks/zdc/config.yml'
- local: 'benchmarks/material_maps/config.yml'
- local: 'benchmarks/material_scan/config.yml'
- local: 'benchmarks/pid/config.yml'
- local: 'benchmarks/timing/config.yml'
- local: 'benchmarks/b0_tracker/config.yml'
- local: 'benchmarks/LOWQ2/config.yml'
- local: 'benchmarks/others/config.yml'

deploy_results:
stage: deploy
needs:
- ["collect_results:zdc","collect_results:barrel_ecal","collect_results:barrel_hcal","collect_results:materialscan"]
- ["collect_results:zdc","collect_results:barrel_ecal","collect_results:barrel_hcal","collect_results:material_scan"]
script:
- echo "deploy results!"
- find results -print | sort | tee summary.txt

benchmarks:detector:success:
stage: status-report
dependencies: []
extends: .status
variables:
STATE: "success"
Expand All @@ -176,6 +161,7 @@ benchmarks:detector:success:

benchmarks:detector:failure:
stage: status-report
dependencies: []
extends: .status
variables:
STATE: "failure"
Expand All @@ -194,6 +180,9 @@ benchmarks:reconstruction:
DETECTOR_DEPLOY_TOKEN_USERNAME: "${DETECTOR_DEPLOY_TOKEN_USERNAME}"
DETECTOR_DEPLOY_TOKEN_PASSWORD: "${DETECTOR_DEPLOY_TOKEN_PASSWORD}"
COMMON_BENCH_VERSION: "$COMMON_BENCH_VERSION"
BENCHMARKS_TAG: "${BENCHMARKS_TAG}"
BENCHMARKS_CONTAINER: "${BENCHMARKS_CONTAINER}"
BENCHMARKS_REGISTRY: "${BENCHMARKS_REGISTRY}"
trigger:
project: EIC/benchmarks/reconstruction_benchmarks
strategy: depend
Expand All @@ -211,6 +200,9 @@ benchmarks:physics:
DETECTOR_DEPLOY_TOKEN_USERNAME: "${DETECTOR_DEPLOY_TOKEN_USERNAME}"
DETECTOR_DEPLOY_TOKEN_PASSWORD: "${DETECTOR_DEPLOY_TOKEN_PASSWORD}"
COMMON_BENCH_VERSION: "$COMMON_BENCH_VERSION"
BENCHMARKS_TAG: "${BENCHMARKS_TAG}"
BENCHMARKS_CONTAINER: "${BENCHMARKS_CONTAINER}"
BENCHMARKS_REGISTRY: "${BENCHMARKS_REGISTRY}"
trigger:
project: EIC/benchmarks/physics_benchmarks
strategy: depend
Expand Down
1 change: 1 addition & 0 deletions .rootlogon.C
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
gROOT->ProcessLine(".include include");

R__LOAD_LIBRARY(fmt)
R__LOAD_LIBRARY(HepMC3)

// Setting for Graphs
gROOT->SetStyle("Plain");
Expand Down
59 changes: 59 additions & 0 deletions Snakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
configfile: "config.yaml"

if config["remote"] == "S3":
from snakemake.remote.S3 import RemoteProvider as S3RemoteProvider
provider = S3RemoteProvider(
endpoint_url="https://eics3.sdcc.bnl.gov:9000",
access_key_id=os.environ["S3_ACCESS_KEY"],
secret_access_key=os.environ["S3_SECRET_KEY"],
)
remote_path = lambda path: f"eictest/{path}"
elif config["remote"] == "XRootD":
from snakemake.remote.XRootD import RemoteProvider as XRootDRemoteProvider
provider = XRootDRemoteProvider(
stay_on_remote=False,
)
remote_path = lambda path: f"root://dtn-eic.jlab.org//work/eic2/{path}"
else:
raise ValueError(f"Unexpected config[\"remote\"] = {config['remote']}")

include: "benchmarks/backgrounds/Snakefile"
include: "benchmarks/barrel_ecal/Snakefile"
include: "benchmarks/ecal_gaps/Snakefile"
include: "benchmarks/material_scan/Snakefile"


rule warmup_run:
output:
"warmup/{DETECTOR_CONFIG}.edm4hep.root",
message: "Ensuring that calibrations/fieldmaps are available for {wildcards.DETECTOR_CONFIG}"
shell: """
ddsim \
--runType batch \
--numberOfEvents 1 \
--compactFile "$DETECTOR_PATH/{wildcards.DETECTOR_CONFIG}.xml" \
--outputFile "{output}" \
--enableGun
"""


rule matplotlibrc:
output:
".matplotlibrc",
run:
with open(output[0], "wt") as fp:
fp.write("backend: Agg\n")
# interactive mode prevents plt.show() from blocking
fp.write("interactive : True\n")


rule org2py:
input:
notebook=workflow.basedir + "/{NOTEBOOK}.org",
converter=workflow.source_path("benchmarks/common/org2py.awk"),
output:
"{NOTEBOOK}.py"
shell:
"""
awk -f {input.converter} {input.notebook} > {output}
"""
91 changes: 91 additions & 0 deletions benchmarks/backgrounds/Snakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import os
import shutil


rule backgrounds_get_beam_gas_electron:
input:
provider.remote(remote_path("EPIC/EVGEN/BACKGROUNDS/BEAMGAS/electron/beam_gas_ep_10GeV_foam_emin10keV_10Mevt_vtx.hepmc")),
output:
"input/backgrounds/beam_gas_electron.hepmc",
run:
shutil.move(input[0], output[0])


rule backgrounds_get_beam_gas_proton:
input:
provider.remote(remote_path("EPIC/EVGEN/BACKGROUNDS/BEAMGAS/proton/ProtonBeamGasEvents/100GeV/100GeV_1.hepmc")),
output:
"input/backgrounds/beam_gas_proton.hepmc",
run:
shutil.move(input[0], output[0])


rule backgrounds_get_DIS:
input:
provider.remote(remote_path("EPIC/EVGEN/DIS/NC/{BEAM}/minQ2={MINQ2}/pythia8NCDIS_{BEAM}_minQ2={MINQ2}_{SUFFIX}.hepmc")),
wildcard_constraints:
BEAM="\d+x\d+",
MINQ2="\d+",
output:
"input/backgrounds/pythia8NCDIS_{BEAM}_minQ2={MINQ2}_{SUFFIX}.hepmc",
run:
shutil.move(input[0], output[0])


rule backgrounds_sim:
input:
hepmc="input/backgrounds/{NAME}.hepmc",
warmup="warmup/{DETECTOR_CONFIG}.edm4hep.root",
output:
"sim_output/{DETECTOR_CONFIG}/backgrounds/{NAME}.edm4hep.root",
log:
"sim_output/{DETECTOR_CONFIG}/backgrounds/{NAME}.edm4hep.root.log",
params:
N_EVENTS=100
shell:
"""
ddsim \
--runType batch \
--part.minimalKineticEnergy 100*GeV \
--filter.tracker edep0 \
-v WARNING \
--numberOfEvents {params.N_EVENTS} \
--compactFile $DETECTOR_PATH/{wildcards.DETECTOR_CONFIG}.xml \
--inputFiles {input.hepmc} \
--outputFile {output}
"""


DETECTOR_CONFIG=os.environ["DETECTOR_CONFIG"]

rule backgrounds_ecal_backwards:
input:
matplotlibrc=".matplotlibrc",
script="benchmarks/backgrounds/ecal_backwards.py",
electron_beam_gas_gen="input/backgrounds/beam_gas_electron.hepmc",
electron_beam_gas_sim="sim_output/" + DETECTOR_CONFIG + "/backgrounds/beam_gas_electron.edm4hep.root",
physics_signal_sim="sim_output/" + DETECTOR_CONFIG + "/backgrounds/pythia8NCDIS_10x100_minQ2=1_beamEffects_xAngle=-0.025_hiDiv_1.edm4hep.root",
proton_beam_gas_gen="input/backgrounds/beam_gas_proton.hepmc",
proton_beam_gas_sim="sim_output/" + DETECTOR_CONFIG + "/backgrounds/beam_gas_proton.edm4hep.root",
output:
directory("results/backgrounds/backwards_ecal")
threads: workflow.cores
shell:
"""
PORT=$RANDOM
dask scheduler --port $PORT &
export DASK_SCHEDULER=localhost:$PORT
SCHEDULER_PID=$!
dask worker tcp://$DASK_SCHEDULER --nworkers {threads} --nthreads 1 &
WORKER_PID=$!
env \
MATPLOTLIBRC={input.matplotlibrc} \
ELECTRON_BEAM_GAS_GEN=$(realpath {input.electron_beam_gas_gen}) \
ELECTRON_BEAM_GAS_SIM=$(realpath {input.electron_beam_gas_sim}) \
PHYSICS_PROCESS_SIM=$(realpath {input.physics_signal_sim}) \
PROTON_BEAM_GAS_GEN=$(realpath {input.proton_beam_gas_gen}) \
PROTON_BEAM_GAS_SIM=$(realpath {input.proton_beam_gas_sim}) \
OUTPUT_DIR={output} \
python {input.script}
kill $WORKER_PID $SCHEDULER_PID
"""
Loading

0 comments on commit 8569cbe

Please sign in to comment.