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