Skip to content

Commit

Permalink
benchmarks/barrel_ecal/config.yml: run via Snakemake
Browse files Browse the repository at this point in the history
  • Loading branch information
veprbl committed Dec 31, 2023
1 parent a330960 commit 98d9109
Show file tree
Hide file tree
Showing 4 changed files with 336 additions and 31 deletions.
25 changes: 14 additions & 11 deletions benchmarks/barrel_ecal/Snakefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ DETECTOR_PATH = os.environ["DETECTOR_PATH"]

rule emcal_barrel_particles_gen:
input:
script="benchmarks/barrel_ecal/scripts/emcal_barrel_particles_gen.cxx",
workflow.source_path("scripts/emcal_barrel_common_functions.h"),
script=workflow.source_path("scripts/emcal_barrel_particles_gen.cxx"),
params:
JUGGLER_N_EVENTS = 100,
output:
Expand Down Expand Up @@ -67,7 +68,8 @@ ln {input} {output}

rule emcal_barrel_particles_analysis:
input:
script="benchmarks/barrel_ecal/scripts/emcal_barrel_particles_analysis.cxx",
workflow.source_path("scripts/emcal_barrel_common_functions.h"),
script=workflow.source_path("scripts/emcal_barrel_particles_analysis.cxx"),
sim="{DETECTOR_CONFIG}/sim_output/sim_emcal_barrel_{PARTICLE}.edm4hep.root",
wildcard_constraints:
PARTICLE="(electron|photon|piplus|piminus)", # avoid clash with "pions"
Expand All @@ -88,13 +90,13 @@ rule emcal_barrel_particles_analysis:
shell:
"""
cd {wildcards.DETECTOR_CONFIG}
root -l -b -q '../{input.script}+("{wildcards.PARTICLE}", true)'
root -l -b -q '{input.script}+("{wildcards.PARTICLE}", true)'
"""


rule emcal_barrel_pions_analysis:
input:
script="benchmarks/barrel_ecal/scripts/emcal_barrel_pions_analysis.cxx",
script=workflow.source_path("scripts/emcal_barrel_pions_analysis.cxx"),
sim="{DETECTOR_CONFIG}/sim_output/sim_emcal_barrel_piplus_energies5.0_5.0.edm4hep.root",
output:
expand(
Expand All @@ -105,13 +107,13 @@ rule emcal_barrel_pions_analysis:
shell:
"""
cd {wildcards.DETECTOR_CONFIG}
root -l -b -q '../{input.script}+("../{input.sim}")'
root -l -b -q '{input.script}+("../{input.sim}")'
"""


rule emcal_barrel_pi0_analysis:
input:
script="benchmarks/barrel_ecal/scripts/emcal_barrel_pi0_analysis.cxx",
script=workflow.source_path("scripts/emcal_barrel_pi0_analysis.cxx"),
sim="{DETECTOR_CONFIG}/sim_output/sim_emcal_barrel_pi0_energies5.0_5.0.edm4hep.root",
fsam="{DETECTOR_CONFIG}/results/emcal_barrel_electron_calibration.json",
output:
Expand All @@ -124,7 +126,7 @@ rule emcal_barrel_pi0_analysis:
shell:
"""
cd {wildcards.DETECTOR_CONFIG}
root -l -b -q '../{input.script}+("../{input.sim}")'
root -l -b -q '{input.script}+("../{input.sim}")'
"""


Expand All @@ -143,7 +145,7 @@ rule emcal_energy_scan:

rule emcal_barrel_particles_energy_scan_analysis:
input:
script="benchmarks/barrel_ecal/scripts/emcal_barrel_energy_scan_analysis.cxx",
script=workflow.source_path("scripts/emcal_barrel_energy_scan_analysis.cxx"),
scan_points="{DETECTOR_CONFIG}/sim_output/emcal_barrel_energy_scan_points_{PARTICLE}.txt",
output:
"{DETECTOR_CONFIG}/results/energy_scan/emcal_barrel_{PARTICLE}_fsam_scan.png",
Expand All @@ -156,13 +158,14 @@ rule emcal_barrel_particles_energy_scan_analysis:
shell:
"""
cd {wildcards.DETECTOR_CONFIG}
root -l -b -q '../{input.script}+("{wildcards.PARTICLE}")'
root -l -b -q '{input.script}+("{wildcards.PARTICLE}")'
"""


rule emcal_barrel_pion_rejection_analysis:
input:
script="benchmarks/barrel_ecal/scripts/emcal_barrel_pion_rejection_analysis.cxx",
workflow.source_path("scripts/emcal_barrel_common_functions.h"),
script=workflow.source_path("scripts/emcal_barrel_pion_rejection_analysis.cxx"),
electron="{DETECTOR_CONFIG}/sim_output/sim_emcal_barrel_electron_energies1.0_18.0.edm4hep.root",
piminus="{DETECTOR_CONFIG}/sim_output/sim_emcal_barrel_piminus_energies1.0_18.0.edm4hep.root",
output:
Expand Down Expand Up @@ -190,5 +193,5 @@ rule emcal_barrel_pion_rejection_analysis:
shell:
"""
cd {wildcards.DETECTOR_CONFIG}
root -l -b -q '../{input.script}+("../{input.electron}", "../{input.piminus}")'
root -l -b -q '{input.script}+("../{input.electron}", "../{input.piminus}")'
"""
38 changes: 18 additions & 20 deletions benchmarks/barrel_ecal/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,34 @@ sim:emcal_barrel_pions:
extends: .det_benchmark
stage: simulate
script:
- bash benchmarks/barrel_ecal/run_emcal_barrel_particles.sh piplus
- bash benchmarks/barrel_ecal/run_emcal_barrel_particles.sh piminus
- snakemake --cores 1 $DETECTOR_CONFIG/sim_output/sim_emcal_barrel_{piplus,piminus}_energies5.0_5.0.edm4hep.root

sim:emcal_barrel_pi0:
extends: .det_benchmark
stage: simulate
script:
- bash benchmarks/barrel_ecal/run_emcal_barrel_particles.sh pi0
- snakemake --cores 1 $DETECTOR_CONFIG/sim_output/sim_emcal_barrel_pi0_energies5.0_5.0.edm4hep.root

sim:emcal_barrel_electrons:
extends: .det_benchmark
stage: simulate
script:
- if [[ "$RUN_EXTENDED_BENCHMARK" == "true" ]] ; then bash benchmarks/barrel_ecal/run_emcal_barrel_energy_scan.sh electron ; fi
- if [[ "$RUN_EXTENDED_BENCHMARK" == "true" ]] ; then snakemake --cores $DETECTOR_CONFIG/results/energy_scan/emcal_barrel_electron_fsam_scan.png; fi
- export JUGGLER_N_EVENTS=400
- bash benchmarks/barrel_ecal/run_emcal_barrel_particles.sh electron
- snakemake --cores 1 $DETECTOR_CONFIG/sim_output/sim_emcal_barrel_electron_energies5.0_5.0.edm4hep.root

sim:emcal_barrel_photons:
extends: .det_benchmark
stage: simulate
script:
- if [[ "$RUN_EXTENDED_BENCHMARK" == "true" ]] ; then bash benchmarks/barrel_ecal/run_emcal_barrel_energy_scan.sh photon ; fi
- bash benchmarks/barrel_ecal/run_emcal_barrel_particles.sh photon
- if [[ "$RUN_EXTENDED_BENCHMARK" == "true" ]] ; then snakemake --cores $DETECTOR_CONFIG/results/energy_scan/emcal_barrel_proton_fsam_scan.png; fi
- snakemake --cores 1 $DETECTOR_CONFIG/sim_output/sim_emcal_barrel_photon_energies5.0_5.0.edm4hep.root

sim:emcal_barrel_pion_rejection:
extends: .det_benchmark
stage: simulate
script:
- bash benchmarks/barrel_ecal/run_emcal_barrel_pion_rejection.sh electron
- bash benchmarks/barrel_ecal/run_emcal_barrel_pion_rejection.sh piminus
- snakemake --cores 1 $DETECTOR_CONFIG/sim_output/sim_emcal_barrel_{piminus,electron}_energies1.0_18.0.edm4hep.root

calib:emcal_barrel_electrons:
extends: .det_benchmark
Expand All @@ -40,8 +38,8 @@ calib:emcal_barrel_electrons:
- ["sim:emcal_barrel_electrons"]
script:
- ls -lhtR sim_output/
- rootls -t sim_output/sim_emcal_barrel_electron.edm4hep.root
- root -b -q 'benchmarks/barrel_ecal/scripts/emcal_barrel_particles_analysis.cxx+("electron", true)'
- rootls -t sim_output/sim_emcal_barrel_electron_energies5.0_5.0.edm4hep.root
- snakemake --cores 1 $DETECTOR_CONFIG/results/emcal_barrel_electron_calibration.json
- mv sim_output/sim_emcal_barrel_electron.edm4hep.root results/.
- echo "JSON file(s) from analysis:" ; cat results/*.json

Expand All @@ -51,15 +49,15 @@ bench:emcal_barrel_pions:
needs:
- ["sim:emcal_barrel_pions"]
script:
- root -b -q benchmarks/barrel_ecal/scripts/emcal_barrel_pions_analysis.cxx+
- snakemake --cores 1 $DETECTOR_CONFIG/results/emcal_barrel_pions_Ethr.png

bench:emcal_barrel_electrons_scan:
extends: .det_benchmark
stage: benchmarks
needs:
- ["sim:emcal_barrel_electrons"]
script:
- if [[ "$RUN_EXTENDED_BENCHMARK" == "true" ]] ; then root -b -q 'benchmarks/barrel_ecal/scripts/emcal_barrel_energy_scan_analysis.cxx+("electron")' ; fi
- if [[ "$RUN_EXTENDED_BENCHMARK" == "true" ]] ; then snakemake --cores 1 $DETECTOR_CONFIG/results/energy_scan/emcal_barrel_electron_fsam_scan.png; fi

bench:emcal_barrel_pi0:
extends: .det_benchmark
Expand All @@ -68,7 +66,7 @@ bench:emcal_barrel_pi0:
- ["sim:emcal_barrel_pi0", "calib:emcal_barrel_electrons"]
script:
- echo "JSON file(s) from analysis:" ; cat results/*.json
- root -b -q benchmarks/barrel_ecal/scripts/emcal_barrel_pi0_analysis.cxx+
- snakemake --cores 1 epic_craterlake/results/Barrel_emcal_pi0.json

bench:emcal_barrel_photons:
extends: .det_benchmark
Expand All @@ -77,10 +75,10 @@ bench:emcal_barrel_photons:
- ["sim:emcal_barrel_photons"]
script:
- ls -lhtR sim_output/
- rootls -t sim_output/sim_emcal_barrel_photon.edm4hep.root
- root -b -q 'benchmarks/barrel_ecal/scripts/emcal_barrel_particles_analysis.cxx+("photon", false)'
- rootls -t sim_output/sim_emcal_barrel_photon_energies5.0_5.0.edm4hep.root
- snakemake --cores 1 $DETECTOR_CONFIG/results/emcal_barrel_photon_calibration.json
- mv sim_output/sim_emcal_barrel_photon.edm4hep.root results/.
- if [[ "$RUN_EXTENDED_BENCHMARK" == "true" ]] ; then root -b -q 'benchmarks/barrel_ecal/scripts/emcal_barrel_energy_scan_analysis.cxx+("photon")' ; fi
- if [[ "$RUN_EXTENDED_BENCHMARK" == "true" ]] ; then snakemake --cores $DETECTOR_CONFIG/results/energy_scan/emcal_barrel_proton_fsam_scan.png; fi

bench:emcal_barrel_pion_rejection:
extends: .det_benchmark
Expand All @@ -89,9 +87,9 @@ bench:emcal_barrel_pion_rejection:
- ["sim:emcal_barrel_pion_rejection"]
script:
- ls -lhtR sim_output/
- rootls -t sim_output/sim_emcal_barrel_piRej_piminus.edm4hep.root
- rootls -t sim_output/sim_emcal_barrel_piRej_electron.edm4hep.root
- root -b -q benchmarks/barrel_ecal/scripts/emcal_barrel_pion_rejection_analysis.cxx+
- rootls -t $DETECTOR_CONFIG/sim_output/sim_emcal_barrel_piminus_energies1.0_18.0.edm4hep.root
- rootls -t $DETECTOR_CONFIG/sim_output/sim_emcal_barrel_electron_energies1.0_18.0.edm4hep.root
- snakemake --cores 1 $DETECTOR_CONFIG/results/Barrel_emcal_pion_rej.json

collect_results:barrel_ecal:
extends: .det_benchmark
Expand Down
Loading

0 comments on commit 98d9109

Please sign in to comment.