Skip to content

Commit

Permalink
add benchmarks/backgrounds
Browse files Browse the repository at this point in the history
  • Loading branch information
veprbl committed Dec 31, 2023
1 parent fbf24b4 commit decb991
Show file tree
Hide file tree
Showing 6 changed files with 582 additions and 0 deletions.
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")
85 changes: 85 additions & 0 deletions benchmarks/backgrounds/Snakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import os

from snakemake.remote.S3 import RemoteProvider as S3RemoteProvider


S3 = S3RemoteProvider(
endpoint_url="https://dtn01.sdcc.bnl.gov:9000",
access_key_id=os.environ["S3_ACCESS_KEY"],
secret_access_key=os.environ["S3_SECRET_KEY"],
)


rule backgrounds_get:
input:
S3.remote("eictest/EPIC/EVGEN/BACKGROUNDS/BEAMGAS/electron/beam_gas_ep_10GeV_foam_emin10keV_10Mevt_vtx.hepmc"),
S3.remote("eictest/EPIC/EVGEN/BACKGROUNDS/BEAMGAS/proton/ProtonBeamGasEvents/100GeV/100GeV_1.hepmc"),
S3.remote("eictest/EPIC/FULL/23.11.0/epic_craterlake/DIS/NC/10x100/minQ2=10/pythia8NCDIS_10x100_minQ2=10_beamEffects_xAngle=-0.025_hiDiv_1.0000.edm4hep.root"),
output:
"input/backgrounds/beam_gas_electron.hepmc",
"input/backgrounds/beam_gas_proton.hepmc",
dis_sim="input/backgrounds/pythia8NCDIS_10x100_minQ2=10_beamEffects_xAngle=-0.025_hiDiv_1.0000.edm4hep.root",
run:
for src, dst in zip(input, output):
os.link(src, dst)


rule backgrounds_sim:
input:
"input/backgrounds/beam_gas_{BEAM}.hepmc",
output:
"sim/{DETECTOR_CONFIG}/beam_gas_{BEAM}.edm4hep.root",
log:
"sim/{DETECTOR_CONFIG}/beam_gas_{BEAM}.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"),
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/" + DETECTOR_CONFIG + "/beam_gas_electron.edm4hep.root",
physics_signal_sim=rules.backgrounds_get.output.dis_sim,
proton_beam_gas_gen="input/backgrounds/beam_gas_proton.hepmc",
proton_beam_gas_sim="sim/" + DETECTOR_CONFIG + "/beam_gas_proton.edm4hep.root",
output:
directory("results/backgrounds/backwards_ecal")
shell:
"""
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}
"""
22 changes: 22 additions & 0 deletions benchmarks/backgrounds/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
sim:backgrounds:
extends: .det_benchmark
stage: simulate
script:
- snakemake --cores 1 backgrounds_get
- snakemake --cores 1 sim/$DETECTOR_CONFIG/beam_gas_{electron,proton}.edm4hep.root

bench:backgrounds_emcal_backwards:
extends: .det_benchmark
stage: benchmarks
needs:
- ["sim:backgrounds"]
script:
- snakemake --cores 1 backgrounds_ecal_backwards

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

0 comments on commit decb991

Please sign in to comment.