Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Oct 11, 2024
1 parent 2788f58 commit 00313ea
Show file tree
Hide file tree
Showing 10 changed files with 343 additions and 253 deletions.
64 changes: 48 additions & 16 deletions benchmarks/barrel_ecal/Snakefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ rule emcal_barrel_particles_gen:
workflow.source_path("scripts/emcal_barrel_common_functions.h"),
script=workflow.source_path("scripts/emcal_barrel_particles_gen.cxx"),
params:
JUGGLER_N_EVENTS = 100,
JUGGLER_N_EVENTS=100,
output:
"data/emcal_barrel_{PARTICLE}_energies{E_MIN}_{E_MAX}.hepmc",
shell:
Expand All @@ -19,24 +19,28 @@ env \

rule emcal_barrel_particles:
input:
"data/emcal_barrel_{PARTICLE}_energies{E_MIN}_{E_MAX}.hepmc"
"data/emcal_barrel_{PARTICLE}_energies{E_MIN}_{E_MAX}.hepmc",
params:
JUGGLER_N_EVENTS = 100,
JUGGLER_N_EVENTS=100,
output:
"{DETECTOR_CONFIG}/sim_output/sim_emcal_barrel_{PARTICLE}_energies{E_MIN}_{E_MAX}.edm4hep.root"
"{DETECTOR_CONFIG}/sim_output/sim_emcal_barrel_{PARTICLE}_energies{E_MIN}_{E_MAX}.edm4hep.root",
shell:
"""
(
"""
set -m # monitor mode to prevent lingering processes
exec ddsim \
--runType batch \
-v WARNING \
--part.minimalKineticEnergy 0.5*GeV \
--filter.tracker edep0 \
--numberOfEvents {params.JUGGLER_N_EVENTS} \
--compactFile """ + DETECTOR_PATH + """/{wildcards.DETECTOR_CONFIG}.xml \
--inputFiles {input} \
--outputFile {output}
"""
--compactFile """
+ DETECTOR_PATH
+ """/{wildcards.DETECTOR_CONFIG}.xml \
--inputFiles {input} \
--outputFile {output}
"""
)


# This is needed to bridge snakemake rule files to "normal" benchmarks
Expand Down Expand Up @@ -73,7 +77,7 @@ rule emcal_barrel_particles_analysis:
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"
PARTICLE="(electron|photon|piplus|piminus)", # avoid clash with "pions"
output:
"{DETECTOR_CONFIG}/results/emcal_barrel_{PARTICLE}_calibration.json",
"{DETECTOR_CONFIG}/results/emcal_barrel_{PARTICLE}_Ethr.png",
Expand Down Expand Up @@ -123,19 +127,24 @@ rule emcal_barrel_pi0_analysis:
var_name=["Ethr", "nhits", "Esim", "dE_rel"],
extension=["pdf", "png"],
),
"{DETECTOR_CONFIG}/results/Barrel_emcal_pi0.json"
"{DETECTOR_CONFIG}/results/Barrel_emcal_pi0.json",
shell:
"""
cd {wildcards.DETECTOR_CONFIG}
root -l -b -q '{input.script}+("../{input.sim}")'
"""


ENERGY_SCAN_ENERGIES = [0.5, 1., 2., 5., 10.]
ENERGY_SCAN_ENERGIES = [0.5, 1.0, 2.0, 5.0, 10.0]


rule emcal_energy_scan:
input:
# Require all simulations produced for this rule
expand("{{DETECTOR_CONFIG}}/sim_output/energy_scan/{energy}/sim_emcal_barrel_{{PARTICLE}}.edm4hep.root", energy=ENERGY_SCAN_ENERGIES),
expand(
"{{DETECTOR_CONFIG}}/sim_output/energy_scan/{energy}/sim_emcal_barrel_{{PARTICLE}}.edm4hep.root",
energy=ENERGY_SCAN_ENERGIES,
),
output:
"{DETECTOR_CONFIG}/sim_output/emcal_barrel_energy_scan_points_{PARTICLE}.txt",
run:
Expand All @@ -154,7 +163,15 @@ rule emcal_barrel_particles_energy_scan_analysis:
expand(
"{{DETECTOR_CONFIG}}/results/energy_scan/{energy}/emcal_barrel_{{PARTICLE}}_{plot}.png",
energy=ENERGY_SCAN_ENERGIES,
plot=["Esim_layer", "Layer_nodep", "Layer_Esim_mean", "Ethr", "nhits", "Esim", "fsam"],
plot=[
"Esim_layer",
"Layer_nodep",
"Layer_Esim_mean",
"Ethr",
"nhits",
"Esim",
"fsam",
],
),
shell:
"""
Expand All @@ -174,7 +191,16 @@ rule emcal_barrel_pion_rejection_analysis:
"{DETECTOR_CONFIG}/results/Barrel_emcal_pion_rej.json",
expand(
"{{DETECTOR_CONFIG}}/results/emcal_barrel_pion_rej_uncut_comb_{var_save}.png",
var_save=["Esim", "EsimTot", "EDep6", "EDep6OverP", "pT", "eta", "EsimScFi", "EsimScFiOverP"],
var_save=[
"Esim",
"EsimTot",
"EDep6",
"EDep6OverP",
"pT",
"eta",
"EsimScFi",
"EsimScFiOverP",
],
),
expand(
"{{DETECTOR_CONFIG}}/results/emcal_barrel_pion_rej_uncut_comb_E{i}Eta{j}.png",
Expand All @@ -187,7 +213,13 @@ rule emcal_barrel_pion_rejection_analysis:
eta_bin=range(2, 4),
tag=(
["cut_mom_ele", "cut_mom_pim", "cut_ratio_pim"]
+ sum([[f"cut_{var}_ele", f"cut_{var}_pim", f"cut_{var}_comb"] for var in ["pT", "EDep6OverP"]], [])
+ sum(
[
[f"cut_{var}_ele", f"cut_{var}_pim", f"cut_{var}_comb"]
for var in ["pT", "EDep6OverP"]
],
[],
)
),
extension=["pdf", "png"],
),
Expand Down
12 changes: 8 additions & 4 deletions benchmarks/ecal_gaps/Snakefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import os

rule ecal_gaps_sim:
input:
steering_file=ancient("EPIC/EVGEN/SINGLE/{PARTICLE}/{ENERGY}/{PHASE_SPACE}/{PARTICLE}_{ENERGY}_{PHASE_SPACE}.steer"),
steering_file=ancient(
"EPIC/EVGEN/SINGLE/{PARTICLE}/{ENERGY}/{PHASE_SPACE}/{PARTICLE}_{ENERGY}_{PHASE_SPACE}.steer"
),
warmup="warmup/{DETECTOR_CONFIG}.edm4hep.root",
output:
"sim_output/ecal_gaps/{DETECTOR_CONFIG}/{PARTICLE}/{ENERGY}/{PHASE_SPACE}/{PARTICLE}_{ENERGY}_{PHASE_SPACE}.{INDEX}.edm4hep.root",
Expand All @@ -15,7 +17,7 @@ rule ecal_gaps_sim:
PHASE_SPACE="(3to50|45to135|130to177)deg",
INDEX="\d{4}",
params:
N_EVENTS=1000
N_EVENTS=1000,
shell:
"""
set -m # monitor mode to prevent lingering processes
Expand All @@ -41,15 +43,17 @@ rule ecal_gaps_recon:
"sim_output/ecal_gaps/{DETECTOR_CONFIG}/{PARTICLE}/{ENERGY}/{PHASE_SPACE}/{PARTICLE}_{ENERGY}_{PHASE_SPACE}.{INDEX}.eicrecon.tree.edm4eic.root.log",
wildcard_constraints:
INDEX="\d{4}",
shell: """
shell:
"""
set -m # monitor mode to prevent lingering processes
exec env DETECTOR_CONFIG={wildcards.DETECTOR_CONFIG} \
eicrecon {input} -Ppodio:output_file={output} \
-Ppodio:output_collections=EcalEndcapNRecHits,EcalBarrelScFiRecHits,EcalBarrelImagingRecHits,EcalEndcapPRecHits,MCParticles
"""


DETECTOR_CONFIG=os.environ["DETECTOR_CONFIG"]
DETECTOR_CONFIG = os.environ["DETECTOR_CONFIG"]


rule ecal_gaps:
input:
Expand Down
71 changes: 38 additions & 33 deletions benchmarks/femc_electron/Snakefile
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
rule femc_electron_generate:
input:
script="benchmarks/femc_electron/analysis/gen_particles.cxx",
params:
NEVENTS_GEN=1000,
th_max=28,
th_min=2.0
output:
GEN_FILE="sim_output/femc_electron/e-_{P}GeV.hepmc"
shell:
"""
input:
script="benchmarks/femc_electron/analysis/gen_particles.cxx",
params:
NEVENTS_GEN=1000,
th_max=28,
th_min=2.0,
output:
GEN_FILE="sim_output/femc_electron/e-_{P}GeV.hepmc",
shell:
"""
mkdir -p sim_output/femc_electron
root -l -b -q '{input.script}({params.NEVENTS_GEN},"{output.GEN_FILE}", "e-", {params.th_min}, {params.th_max}, 0., 360., {wildcards.P})'
"""


rule femc_electron_simulate:
input:
GEN_FILE="sim_output/femc_electron/e-_{P}GeV.hepmc"
params:
PHYSICS_LIST="FTFP_BERT"
output:
SIM_FILE="sim_output/femc_electron/{DETECTOR_CONFIG}_sim_e-_{P}GeV.edm4hep.root"
shell:
"""
input:
GEN_FILE="sim_output/femc_electron/e-_{P}GeV.hepmc",
params:
PHYSICS_LIST="FTFP_BERT",
output:
SIM_FILE="sim_output/femc_electron/{DETECTOR_CONFIG}_sim_e-_{P}GeV.edm4hep.root",
shell:
"""
NEVENTS_SIM=1000
# Running simulation
npsim \
Expand All @@ -32,27 +33,31 @@ npsim \
--outputFile {output.SIM_FILE}
"""


rule femc_electron_recon:
input:
SIM_FILE="sim_output/femc_electron/{DETECTOR_CONFIG}_sim_e-_{P}GeV.edm4hep.root"
output:
REC_FILE="sim_output/femc_electron/{DETECTOR_CONFIG}_rec_e-_{P}GeV.edm4eic.root"
shell:
"""
input:
SIM_FILE="sim_output/femc_electron/{DETECTOR_CONFIG}_sim_e-_{P}GeV.edm4hep.root",
output:
REC_FILE="sim_output/femc_electron/{DETECTOR_CONFIG}_rec_e-_{P}GeV.edm4eic.root",
shell:
"""
NEVENTS_REC=1000
eicrecon {input.SIM_FILE} -Ppodio:output_file={output.REC_FILE} -Pdd4hep:xml_files=$DETECTOR_PATH/{wildcards.DETECTOR_CONFIG}.xml -Ppodio:output_collections=MCParticles,HcalEndcapPInsertRecHits,HcalEndcapPInsertClusters,HcalEndcapPInsertSubcellHits,EcalEndcapPInsertRecHits,EcalEndcapPInsertClusters,EcalEndcapPInsertRecHits,EcalEndcapPClusters -Pjana:nevents=$NEVENTS_REC
"""


rule femc_electron_analysis:
input:
expand("sim_output/femc_electron/{DETECTOR_CONFIG}_rec_e-_{P}GeV.edm4eic.root",
P=[10, 20, 30, 40, 50, 60, 70, 80],
DETECTOR_CONFIG=["{DETECTOR_CONFIG}"]),
script="benchmarks/femc_electron/analysis/femc_electron_plots.py",
output:
results_dir=directory("results/{DETECTOR_CONFIG}/femc_electron"),
shell:
"""
input:
expand(
"sim_output/femc_electron/{DETECTOR_CONFIG}_rec_e-_{P}GeV.edm4eic.root",
P=[10, 20, 30, 40, 50, 60, 70, 80],
DETECTOR_CONFIG=["{DETECTOR_CONFIG}"],
),
script="benchmarks/femc_electron/analysis/femc_electron_plots.py",
output:
results_dir=directory("results/{DETECTOR_CONFIG}/femc_electron"),
shell:
"""
mkdir -p {output.results_dir}
python {input.script} {output.results_dir}
"""
71 changes: 38 additions & 33 deletions benchmarks/femc_photon/Snakefile
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
rule femc_photon_generate:
input:
script="benchmarks/femc_photon/analysis/gen_particles.cxx",
params:
NEVENTS_GEN=1000,
th_max=28,
th_min=2.0
output:
GEN_FILE="sim_output/femc_photon/photon_{P}GeV.hepmc"
shell:
"""
input:
script="benchmarks/femc_photon/analysis/gen_particles.cxx",
params:
NEVENTS_GEN=1000,
th_max=28,
th_min=2.0,
output:
GEN_FILE="sim_output/femc_photon/photon_{P}GeV.hepmc",
shell:
"""
mkdir -p sim_output/femc_photon
root -l -b -q '{input.script}({params.NEVENTS_GEN},"{output.GEN_FILE}", "gamma", {params.th_min}, {params.th_max}, 0., 360., {wildcards.P})'
"""


rule femc_photon_simulate:
input:
GEN_FILE="sim_output/femc_photon/photon_{P}GeV.hepmc"
params:
PHYSICS_LIST="FTFP_BERT"
output:
SIM_FILE="sim_output/femc_photon/{DETECTOR_CONFIG}_sim_photon_{P}GeV.edm4hep.root"
shell:
"""
input:
GEN_FILE="sim_output/femc_photon/photon_{P}GeV.hepmc",
params:
PHYSICS_LIST="FTFP_BERT",
output:
SIM_FILE="sim_output/femc_photon/{DETECTOR_CONFIG}_sim_photon_{P}GeV.edm4hep.root",
shell:
"""
NEVENTS_SIM=1000
# Running simulation
npsim \
Expand All @@ -32,27 +33,31 @@ npsim \
--outputFile {output.SIM_FILE}
"""


rule femc_photon_recon:
input:
SIM_FILE="sim_output/femc_photon/{DETECTOR_CONFIG}_sim_photon_{P}GeV.edm4hep.root"
output:
REC_FILE="sim_output/femc_photon/{DETECTOR_CONFIG}_rec_photon_{P}GeV.edm4eic.root"
shell:
"""
input:
SIM_FILE="sim_output/femc_photon/{DETECTOR_CONFIG}_sim_photon_{P}GeV.edm4hep.root",
output:
REC_FILE="sim_output/femc_photon/{DETECTOR_CONFIG}_rec_photon_{P}GeV.edm4eic.root",
shell:
"""
NEVENTS_REC=1000
eicrecon {input.SIM_FILE} -Ppodio:output_file={output.REC_FILE} -Pdd4hep:xml_files=$DETECTOR_PATH/{wildcards.DETECTOR_CONFIG}.xml -Ppodio:output_collections=MCParticles,HcalEndcapPInsertRecHits,HcalEndcapPInsertClusters,HcalEndcapPInsertSubcellHits,EcalEndcapPInsertRecHits,EcalEndcapPInsertClusters,EcalEndcapPInsertRecHits,EcalEndcapPClusters -Pjana:nevents=$NEVENTS_REC
"""


rule femc_photon_analysis:
input:
expand("sim_output/femc_photon/{DETECTOR_CONFIG}_rec_photon_{P}GeV.edm4eic.root",
P=[10, 20, 30, 40, 50, 60, 70, 80],
DETECTOR_CONFIG=["{DETECTOR_CONFIG}"]),
script="benchmarks/femc_photon/analysis/femc_photon_plots.py",
output:
results_dir=directory("results/{DETECTOR_CONFIG}/femc_photon"),
shell:
"""
input:
expand(
"sim_output/femc_photon/{DETECTOR_CONFIG}_rec_photon_{P}GeV.edm4eic.root",
P=[10, 20, 30, 40, 50, 60, 70, 80],
DETECTOR_CONFIG=["{DETECTOR_CONFIG}"],
),
script="benchmarks/femc_photon/analysis/femc_photon_plots.py",
output:
results_dir=directory("results/{DETECTOR_CONFIG}/femc_photon"),
shell:
"""
mkdir -p {output.results_dir}
python {input.script} {output.results_dir}
"""
Loading

0 comments on commit 00313ea

Please sign in to comment.