Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add benchmarks/backgrounds #2

Merged
merged 25 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
e10fa7a
benchmarks/barrel_ecal/config.yml: run via Snakemake
veprbl Nov 10, 2023
11a8db5
add benchmarks/backgrounds
veprbl Dec 19, 2023
a3b60b1
Snakefile: sim/ -> sim_output/
veprbl Dec 31, 2023
f09eb96
add benchmarks/backgrounds/requirements.txt
veprbl Dec 31, 2023
7055630
backgrounds/config.yml: sim/ -> sim_output/
veprbl Jan 1, 2024
4f61610
use dask-scheduler (provides multiprocesssing)
veprbl Jan 3, 2024
dddb0d0
ecal_backwards.org: handle case of insufficient events
veprbl Jan 3, 2024
e4385c4
Snakefile: split get to avoid unnecessary downloads/simulations
veprbl Jan 3, 2024
9ae1ead
backgrounds/config.yml: more threads
veprbl Jan 4, 2024
3987a98
ecal_backwards.org: use step_size (should work in uproot 5.2.0+)
veprbl Jan 4, 2024
ac8a127
Revert "ecal_backwards.org: use step_size (should work in uproot 5.2.…
veprbl Jan 6, 2024
5c52170
store hepmc in $LOCAL_DATA_PATH
veprbl Jan 6, 2024
8f6febe
reduce steps_per_file
veprbl Jan 6, 2024
606ed98
os.link -> os.rename
veprbl Jan 7, 2024
2620492
os.rename -> shutil.move
veprbl Jan 7, 2024
19d4472
don't try to create the directory the second time
veprbl Jan 20, 2024
74ae547
fix: use eics3 instead of deprecated dtn01
veprbl Jan 29, 2024
7d3d526
debug: print timing
veprbl Jan 30, 2024
d86f592
fix legend position to not waste too much cpu
veprbl Feb 5, 2024
b867642
render to png
veprbl Feb 5, 2024
9288150
ecal_backwards.org: forward compat for new geometry
veprbl Feb 6, 2024
f800550
benchmark/backgrounds: switch from minQ2=10 to 1 (requires running si…
veprbl Feb 12, 2024
49ed8bb
Revert "debug: print timing"
veprbl Feb 12, 2024
93d8a47
Snakefile: use XRootD by default
veprbl Feb 12, 2024
323bf91
config.yaml: switch back to S3
veprbl Feb 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ get_data:
- runner_system_failure

include:
- local: 'benchmarks/backgrounds/config.yml'
- local: 'benchmarks/tracking_detectors/config.yml'
- local: 'benchmarks/barrel_ecal/config.yml'
- local: 'benchmarks/barrel_hcal/config.yml'
Expand Down
10 changes: 10 additions & 0 deletions Snakefile
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
include: "benchmarks/backgrounds/Snakefile"
include: "benchmarks/barrel_ecal/Snakefile"

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")
110 changes: 110 additions & 0 deletions benchmarks/backgrounds/Snakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
import os
import shutil

from snakemake.remote.S3 import RemoteProvider as S3RemoteProvider


S3 = 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"],
)
wdconinc marked this conversation as resolved.
Show resolved Hide resolved


rule backgrounds_get_beam_gas_electron:
input:
S3.remote("eictest/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:
S3.remote("eictest/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:
S3.remote("eictest/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:
"input/backgrounds/{NAME}.hepmc",
output:
"sim_output/{DETECTOR_CONFIG}/{NAME}.edm4hep.root",
log:
"sim_output/{DETECTOR_CONFIG}/{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} \
--outputFile {output}
"""


rule backgrounds_org2py:
input:
notebook=workflow.source_path("ecal_backwards.org"),
wdconinc marked this conversation as resolved.
Show resolved Hide resolved
converter=workflow.source_path("./org2py.awk"),
output:
"ecal_backwards.py"
shell:
"""
awk -f {input.converter} {input.notebook} > {output}
"""

DETECTOR_CONFIG=os.environ["DETECTOR_CONFIG"]

rule backgrounds_ecal_backwards:
input:
matplotlibrc=".matplotlibrc",
script="ecal_backwards.py",
electron_beam_gas_gen="input/backgrounds/beam_gas_electron.hepmc",
electron_beam_gas_sim="sim_output/" + DETECTOR_CONFIG + "/beam_gas_electron.edm4hep.root",
physics_signal_sim="sim_output/" + DETECTOR_CONFIG + "/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 + "/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
"""
26 changes: 26 additions & 0 deletions benchmarks/backgrounds/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
sim:backgrounds:
extends: .det_benchmark
stage: simulate
script:
- mkdir $LOCAL_DATA_PATH/input
- ln -s $LOCAL_DATA_PATH/input input
- snakemake --cores 2 sim_output/$DETECTOR_CONFIG/beam_gas_{electron,proton}.edm4hep.root sim_output/$DETECTOR_CONFIG/pythia8NCDIS_10x100_minQ2=1_beamEffects_xAngle=-0.025_hiDiv_vtxfix_1.edm4hep.root

bench:backgrounds_emcal_backwards:
extends: .det_benchmark
stage: benchmarks
needs:
- ["sim:backgrounds"]
script:
- ln -s $LOCAL_DATA_PATH/input input
- export PYTHONUSERBASE=$LOCAL_DATA_PATH/deps
- pip install -r benchmarks/backgrounds/requirements.txt
- snakemake --cores 8 backgrounds_ecal_backwards

collect_results:backgrounds:
extends: .det_benchmark
stage: collect
needs:
- "bench:backgrounds_emcal_backwards"
script:
- ls -lrht
Loading