Warning, /detector_benchmarks/benchmarks/nhcal_sampling_fraction/Snakefile is written in an unsupported language. File is not indexed.
0001 def get_total_energy(particle, kinetic_energy):
0002 """Convert kinetic energy to total energy by adding particle mass."""
0003 masses = {
0004 "neutron": 0.94,
0005 "pi-": 0.14,
0006 "e-": 0.0005
0007 }
0008 ke = float(kinetic_energy)
0009 mass = masses[particle]
0010 return f"{ke + mass:.2f}"
0011
0012 rule nhcal_sampling_fraction_simulate:
0013 input:
0014 geometry_lib=find_epic_libraries(),
0015 output:
0016 "sim_output/nhcal_sampling_fraction/{PARTICLE}/Ekin{ENERGY}GeV/sim.edm4hep.rnt.root",
0017 params:
0018 N_EVENTS=5000,
0019 DETECTOR_PATH=config["DETECTOR_PREFIX"] + "/share/epic",
0020 DETECTOR_CONFIG="epic_backward_hcal_only_sampF.xml",
0021 DD4HEP_HASH=get_spack_package_hash("dd4hep"),
0022 NPSIM_HASH=get_spack_package_hash("npsim"),
0023 PARTICLE=lambda wildcards: wildcards.PARTICLE,
0024 TOTAL_ENERGY=lambda wildcards: get_total_energy(wildcards.PARTICLE, wildcards.ENERGY),
0025 SEED=lambda wildcards: stable_seed("nhcal_sampling_fraction", wildcards.PARTICLE, wildcards.ENERGY),
0026 cache: True
0027 singularity: EIC_SINGULARITY_CONTAINER,
0028 shell:
0029 """
0030 set -m
0031 exec npsim \
0032 --compactFile {params.DETECTOR_PATH}/{params.DETECTOR_CONFIG} \
0033 --numberOfEvents {params.N_EVENTS} \
0034 --random.seed {params.SEED} \
0035 --enableGun \
0036 -v WARNING \
0037 --gun.particle {wildcards.PARTICLE} \
0038 --gun.thetaMin 120*degree \
0039 --gun.thetaMax 180*degree \
0040 --gun.distribution uniform \
0041 --gun.energy "{params.TOTAL_ENERGY}*GeV" \
0042 --outputConfig.useRNTuple true \
0043 --outputFile {output}
0044 """
0045
0046
0047 rule nhcal_sampling_fraction_analysis:
0048 input:
0049 sim=expand(
0050 "sim_output/nhcal_sampling_fraction/{PARTICLE}/Ekin{ENERGY}GeV/sim.edm4hep.rnt.root",
0051 ENERGY=["0.5", "0.7", "1.0", "2.0", "5.0", "10.0"],
0052 PARTICLE=["pi-", "neutron", "e-"],
0053 ),
0054 script=workflow.source_path("scripts/sampling_fraction_analysis.cxx"),
0055 output:
0056 pdf="results/nhcal_sampling_fraction/hist_sampf_vs_Ehit.pdf",
0057 png="results/nhcal_sampling_fraction/hist_sampf_vs_Ehit.png",
0058 params:
0059 DETECTOR_PATH=config["DETECTOR_PREFIX"] + "/share/epic",
0060 DETECTOR_CONFIG="epic_backward_hcal_only_sampF.xml",
0061 binary="results/nhcal_sampling_fraction/sampling_fraction_analysis",
0062 SIM_GLOB="sim_output/nhcal_sampling_fraction/*/Ekin*GeV/sim.edm4hep.rnt.root",
0063 singularity: EIC_SINGULARITY_CONTAINER,
0064 shell:
0065 """
0066 g++ {input.script} \
0067 $(root-config --cflags --libs) \
0068 $(python-config --includes) \
0069 -I/opt/local/include \
0070 -L/opt/local/lib \
0071 -lpodio -lpodioIO -lpodioRootIO -ledm4hep -lDDCore -lDDRec \
0072 -o {output.pdf}.bin && \
0073 {output.pdf}.bin "{params.SIM_GLOB}" "{output.pdf}" "{output.png}" "{params.DETECTOR_PATH}/{params.DETECTOR_CONFIG}" && \
0074 rm {output.pdf}.bin
0075 """