Warning, /detector_benchmarks/benchmarks/barrel_ecal/Snakefile is written in an unsupported language. File is not indexed.
0001 DETECTOR_PATH = config["DETECTOR_PREFIX"] + "/share/epic"
0002
0003
0004 rule emcal_barrel_particles_gen:
0005 input:
0006 workflow.source_path("scripts/emcal_barrel_common_functions.h"),
0007 script=workflow.source_path("scripts/emcal_barrel_particles_gen.cxx"),
0008 params:
0009 JUGGLER_N_EVENTS = 100,
0010 PARTICLE = lambda wildcards: wildcards.PARTICLE,
0011 E_MIN = lambda wildcards: wildcards.E_MIN,
0012 E_MAX = lambda wildcards: wildcards.E_MAX,
0013 output:
0014 "data/emcal_barrel_{PARTICLE}_energies{E_MIN}_{E_MAX}.hepmc",
0015 singularity: EIC_SINGULARITY_CONTAINER,
0016 shell:
0017 """
0018 root -l -b -q '{input.script}+("{output}", {params.JUGGLER_N_EVENTS}, {wildcards.E_MIN}, {wildcards.E_MAX}, "{wildcards.PARTICLE}")'
0019 """
0020
0021
0022 rule emcal_barrel_particles:
0023 input:
0024 hepmc="data/emcal_barrel_{PARTICLE}_energies{E_MIN}_{E_MAX}.hepmc",
0025 geometry_lib=find_epic_libraries(),
0026 params:
0027 JUGGLER_N_EVENTS = 100,
0028 DD4HEP_HASH=get_spack_package_hash("dd4hep"),
0029 NPSIM_HASH=get_spack_package_hash("npsim"),
0030 DETECTOR_CONFIG = lambda wildcards: wildcards.DETECTOR_CONFIG,
0031 PARTICLE = lambda wildcards: wildcards.PARTICLE,
0032 E_MIN = lambda wildcards: wildcards.E_MIN,
0033 E_MAX = lambda wildcards: wildcards.E_MAX,
0034 output:
0035 "{DETECTOR_CONFIG}/sim_output/sim_emcal_barrel_{PARTICLE}_energies{E_MIN}_{E_MAX}.edm4hep.root"
0036 cache: True
0037 singularity: EIC_SINGULARITY_CONTAINER,
0038 shell:
0039 """
0040 set -m # monitor mode to prevent lingering processes
0041 exec npsim \
0042 --runType batch \
0043 -v WARNING \
0044 --part.minimalKineticEnergy 0.5*GeV \
0045 --filter.tracker edep0 \
0046 --numberOfEvents {params.JUGGLER_N_EVENTS} \
0047 --compactFile """ + DETECTOR_PATH + """/{wildcards.DETECTOR_CONFIG}.xml \
0048 --inputFiles {input.hepmc} \
0049 --outputFile {output}
0050 """
0051
0052
0053 # This is needed to bridge snakemake rule files to "normal" benchmarks
0054 rule emcal_barrel_particles_compat_normal:
0055 input:
0056 "{DETECTOR_CONFIG}/sim_output/sim_emcal_barrel_{PARTICLE}_energies5.0_5.0.edm4hep.root",
0057 wildcard_constraints:
0058 PARTICLE="[^_]+",
0059 output:
0060 "{DETECTOR_CONFIG}/sim_output/sim_emcal_barrel_{PARTICLE}.edm4hep.root",
0061 singularity: EIC_SINGULARITY_CONTAINER,
0062 shell:
0063 """
0064 ln {input} {output}
0065 """
0066
0067
0068 # This is needed to bridge snakemake rule files to "energy_scan" benchmarks
0069 rule emcal_barrel_particles_compat_energy_scan:
0070 input:
0071 "{DETECTOR_CONFIG}/sim_output/sim_emcal_barrel_{PARTICLE}_energies{E}_{E}.edm4hep.root",
0072 wildcard_constraints:
0073 PARTICLE="[^_]+",
0074 output:
0075 "{DETECTOR_CONFIG}/sim_output/energy_scan/{E}/sim_emcal_barrel_{PARTICLE}.edm4hep.root",
0076 singularity: EIC_SINGULARITY_CONTAINER,
0077 shell:
0078 """
0079 ln {input} {output}
0080 """
0081
0082
0083 rule emcal_barrel_particles_analysis:
0084 input:
0085 workflow.source_path("scripts/emcal_barrel_common_functions.h"),
0086 script=workflow.source_path("scripts/emcal_barrel_particles_analysis.cxx"),
0087 sim="{DETECTOR_CONFIG}/sim_output/sim_emcal_barrel_{PARTICLE}.edm4hep.root",
0088 wildcard_constraints:
0089 PARTICLE="(electron|photon|piplus|piminus)", # avoid clash with "pions"
0090 output:
0091 "{DETECTOR_CONFIG}/results/emcal_barrel_{PARTICLE}_calibration.json",
0092 "{DETECTOR_CONFIG}/results/emcal_barrel_{PARTICLE}_Ethr.png",
0093 "{DETECTOR_CONFIG}/results/emcal_barrel_{PARTICLE}_Ethr.pdf",
0094 "{DETECTOR_CONFIG}/results/emcal_barrel_{PARTICLE}_nhits.png",
0095 "{DETECTOR_CONFIG}/results/emcal_barrel_{PARTICLE}_nhits.pdf",
0096 "{DETECTOR_CONFIG}/results/emcal_barrel_{PARTICLE}_Esim.png",
0097 "{DETECTOR_CONFIG}/results/emcal_barrel_{PARTICLE}_Esim.pdf",
0098 "{DETECTOR_CONFIG}/results/emcal_barrel_{PARTICLE}_fsam.png",
0099 "{DETECTOR_CONFIG}/results/emcal_barrel_{PARTICLE}_fsam.pdf",
0100 "{DETECTOR_CONFIG}/results/emcal_barrel_{PARTICLE}_fsamImg.png",
0101 "{DETECTOR_CONFIG}/results/emcal_barrel_{PARTICLE}_fsamImg.pdf",
0102 "{DETECTOR_CONFIG}/results/emcal_barrel_{PARTICLE}_fsamScFi.png",
0103 "{DETECTOR_CONFIG}/results/emcal_barrel_{PARTICLE}_fsamScFi.pdf",
0104 singularity: EIC_SINGULARITY_CONTAINER,
0105 shell:
0106 """
0107 cd {wildcards.DETECTOR_CONFIG}
0108 root -l -b -q '{input.script}+("{wildcards.PARTICLE}", true)'
0109 """
0110
0111
0112 rule emcal_barrel_pions_analysis:
0113 input:
0114 script=workflow.source_path("scripts/emcal_barrel_pions_analysis.cxx"),
0115 sim="{DETECTOR_CONFIG}/sim_output/sim_emcal_barrel_piplus_energies5.0_5.0.edm4hep.root",
0116 output:
0117 expand(
0118 "{{DETECTOR_CONFIG}}/results/emcal_barrel_pions_{var_name}.{extension}",
0119 var_name=["Ethr", "nhits", "Esim", "fsam", "pid"],
0120 extension=["pdf", "png"],
0121 ),
0122 singularity: EIC_SINGULARITY_CONTAINER,
0123 shell:
0124 """
0125 cd {wildcards.DETECTOR_CONFIG}
0126 root -l -b -q '{input.script}+("../{input.sim}")'
0127 """
0128
0129
0130 rule emcal_barrel_pi0_analysis:
0131 input:
0132 script=workflow.source_path("scripts/emcal_barrel_pi0_analysis.cxx"),
0133 sim="{DETECTOR_CONFIG}/sim_output/sim_emcal_barrel_pi0_energies5.0_5.0.edm4hep.root",
0134 fsam="{DETECTOR_CONFIG}/results/emcal_barrel_electron_calibration.json",
0135 output:
0136 expand(
0137 "{{DETECTOR_CONFIG}}/results/emcal_barrel_pi0_{var_name}.{extension}",
0138 var_name=["Ethr", "nhits", "Esim", "dE_rel"],
0139 extension=["pdf", "png"],
0140 ),
0141 singularity: EIC_SINGULARITY_CONTAINER,
0142 shell:
0143 """
0144 cd {wildcards.DETECTOR_CONFIG}
0145 root -l -b -q '{input.script}+("../{input.sim}")'
0146 """
0147
0148
0149 ENERGY_SCAN_ENERGIES = [0.5, 1., 2., 5., 10.]
0150 rule emcal_energy_scan:
0151 input:
0152 # Require all simulations produced for this rule
0153 expand("{{DETECTOR_CONFIG}}/sim_output/energy_scan/{energy}/sim_emcal_barrel_{{PARTICLE}}.edm4hep.root", energy=ENERGY_SCAN_ENERGIES),
0154 output:
0155 "{DETECTOR_CONFIG}/sim_output/emcal_barrel_energy_scan_points_{PARTICLE}.txt",
0156 run:
0157 with open(output[0], "wt") as fp:
0158 for energy in ENERGY_SCAN_ENERGIES:
0159 fp.write(f"{energy}\n")
0160
0161
0162 rule emcal_barrel_particles_energy_scan_analysis:
0163 input:
0164 script=workflow.source_path("scripts/emcal_barrel_energy_scan_analysis.cxx"),
0165 scan_points="{DETECTOR_CONFIG}/sim_output/emcal_barrel_energy_scan_points_{PARTICLE}.txt",
0166 output:
0167 "{DETECTOR_CONFIG}/results/energy_scan/emcal_barrel_{PARTICLE}_fsam_scan.png",
0168 "{DETECTOR_CONFIG}/results/energy_scan/emcal_barrel_{PARTICLE}_fsam_scan_res.png",
0169 expand(
0170 "{{DETECTOR_CONFIG}}/results/energy_scan/{energy}/emcal_barrel_{{PARTICLE}}_{plot}.png",
0171 energy=ENERGY_SCAN_ENERGIES,
0172 plot=["Esim_layer", "Layer_nodep", "Layer_Esim_mean", "Ethr", "nhits", "Esim", "fsam"],
0173 ),
0174 singularity: EIC_SINGULARITY_CONTAINER,
0175 shell:
0176 """
0177 cd {wildcards.DETECTOR_CONFIG}
0178 root -l -b -q '{input.script}+("{wildcards.PARTICLE}")'
0179 """
0180
0181
0182 rule emcal_barrel_pion_rejection_analysis:
0183 input:
0184 workflow.source_path("scripts/emcal_barrel_common_functions.h"),
0185 script=workflow.source_path("scripts/emcal_barrel_pion_rejection_analysis.cxx"),
0186 electron="{DETECTOR_CONFIG}/sim_output/sim_emcal_barrel_electron_energies1.0_18.0.edm4hep.root",
0187 piminus="{DETECTOR_CONFIG}/sim_output/sim_emcal_barrel_piminus_energies1.0_18.0.edm4hep.root",
0188 output:
0189 "{DETECTOR_CONFIG}/results/emcal_barrel_pion_rej_RatioRej.png",
0190 expand(
0191 "{{DETECTOR_CONFIG}}/results/emcal_barrel_pion_rej_uncut_comb_{var_save}.png",
0192 var_save=["Esim", "EsimTot", "EDep6", "EDep6OverP", "pT", "eta", "EsimScFi", "EsimScFiOverP"],
0193 ),
0194 expand(
0195 "{{DETECTOR_CONFIG}}/results/emcal_barrel_pion_rej_uncut_comb_E{i}Eta{j}.png",
0196 i=range(6),
0197 j=range(2),
0198 ),
0199 expand(
0200 "{{DETECTOR_CONFIG}}/results/emcal_barrel_pion_rej_{tag}_E{energy}_eta{eta_bin}.{extension}",
0201 energy=[5, 10, 18],
0202 eta_bin=range(2, 4),
0203 tag=(
0204 ["cut_mom_ele", "cut_mom_pim", "cut_ratio_pim"]
0205 + sum([[f"cut_{var}_ele", f"cut_{var}_pim", f"cut_{var}_comb"] for var in ["pT", "EDep6OverP"]], [])
0206 ),
0207 extension=["pdf", "png"],
0208 ),
0209 singularity: EIC_SINGULARITY_CONTAINER,
0210 shell:
0211 """
0212 cd {wildcards.DETECTOR_CONFIG}
0213 root -l -b -q '{input.script}+g("../{input.electron}", "../{input.piminus}")'
0214 """