Warning, /detector_benchmarks/benchmarks/ecal_gaps/Snakefile is written in an unsupported language. File is not indexed.
0001 import os
0002
0003
0004 rule ecal_gaps_sim:
0005 input:
0006 steering_file="EPIC/EVGEN/SINGLE/{PARTICLE}/{ENERGY}/{PHASE_SPACE}/{PARTICLE}_{ENERGY}_{PHASE_SPACE}.steer",
0007 warmup="warmup.edm4hep.root",
0008 geometry_lib=find_epic_libraries(),
0009 output:
0010 "sim_output/ecal_gaps/{DETECTOR_CONFIG}/{PARTICLE}/{ENERGY}/{PHASE_SPACE}/{PARTICLE}_{ENERGY}_{PHASE_SPACE}.{INDEX}.edm4hep.root",
0011 log:
0012 "sim_output/ecal_gaps/{DETECTOR_CONFIG}/{PARTICLE}/{ENERGY}/{PHASE_SPACE}/{PARTICLE}_{ENERGY}_{PHASE_SPACE}.{INDEX}.edm4hep.root.log",
0013 wildcard_constraints:
0014 PARTICLE="e-",
0015 ENERGY="(500MeV|5GeV|20GeV)",
0016 PHASE_SPACE="(3to50|45to135|130to177)deg",
0017 INDEX=r"\d{4}",
0018 params:
0019 N_EVENTS=1000,
0020 SEED=lambda wildcards: "1" + wildcards.INDEX,
0021 DETECTOR_PATH=os.environ["DETECTOR_PATH"],
0022 DETECTOR_CONFIG=lambda wildcards: wildcards.DETECTOR_CONFIG,
0023 DD4HEP_HASH=get_spack_package_hash("dd4hep"),
0024 NPSIM_HASH=get_spack_package_hash("npsim"),
0025 cache: True
0026 singularity: EIC_SINGULARITY_CONTAINER,
0027 shell:
0028 """
0029 set -m # monitor mode to prevent lingering processes
0030 exec npsim \
0031 --runType batch \
0032 --enableGun \
0033 --steeringFile "{input.steering_file}" \
0034 --random.seed {params.SEED} \
0035 --filter.tracker edep0 \
0036 -v WARNING \
0037 --numberOfEvents {params.N_EVENTS} \
0038 --compactFile {params.DETECTOR_PATH}/{params.DETECTOR_CONFIG}.xml \
0039 --outputFile {output}
0040 """
0041
0042
0043 rule ecal_gaps_recon:
0044 input:
0045 sim="sim_output/ecal_gaps/{DETECTOR_CONFIG}/{PARTICLE}/{ENERGY}/{PHASE_SPACE}/{PARTICLE}_{ENERGY}_{PHASE_SPACE}.{INDEX}.edm4hep.root",
0046 warmup="warmup.edm4hep.root",
0047 output:
0048 "sim_output/ecal_gaps/{DETECTOR_CONFIG}/{PARTICLE}/{ENERGY}/{PHASE_SPACE}/{PARTICLE}_{ENERGY}_{PHASE_SPACE}.{INDEX}.eicrecon.edm4eic.root",
0049 log:
0050 "sim_output/ecal_gaps/{DETECTOR_CONFIG}/{PARTICLE}/{ENERGY}/{PHASE_SPACE}/{PARTICLE}_{ENERGY}_{PHASE_SPACE}.{INDEX}.eicrecon.edm4eic.root.log",
0051 wildcard_constraints:
0052 INDEX=r"\d{4}",
0053 params:
0054 DETECTOR_CONFIG=lambda wildcards: wildcards.DETECTOR_CONFIG,
0055 EICRECON_HASH=get_spack_package_hash("eicrecon"),
0056 cache: True
0057 singularity: EIC_SINGULARITY_CONTAINER,
0058 shell: """
0059 set -m # monitor mode to prevent lingering processes
0060 exec env DETECTOR_CONFIG={params.DETECTOR_CONFIG} \
0061 eicrecon {input.sim} -Ppodio:output_file={output} \
0062 -Ppodio:output_collections=EcalEndcapNRecHits,EcalBarrelScFiRecHits,EcalBarrelImagingRecHits,EcalEndcapPRecHits,MCParticles
0063 """
0064
0065
0066 rule ecal_gaps:
0067 input:
0068 matplotlibrc=".matplotlibrc",
0069 script="benchmarks/ecal_gaps/ecal_gaps.org2py.py",
0070 # TODO pass as a file list?
0071 _=expand(
0072 "sim_output/ecal_gaps/{{DETECTOR_CONFIG}}/{PARTICLE}/{ENERGY}/{PHASE_SPACE}/{PARTICLE}_{ENERGY}_{PHASE_SPACE}.{INDEX:04d}.eicrecon.edm4eic.root",
0073 PARTICLE=["e-"],
0074 ENERGY=["500MeV", "5GeV", "20GeV"],
0075 PHASE_SPACE=["3to50deg", "45to135deg", "130to177deg"],
0076 INDEX=range(1),
0077 ),
0078 output:
0079 directory("results/{DETECTOR_CONFIG}/ecal_gaps"),
0080 log:
0081 scheduler=".logs/results/{DETECTOR_CONFIG}/ecal_gaps/scheduler.log",
0082 worker=".logs/results/{DETECTOR_CONFIG}/ecal_gaps/worker.log",
0083 threads: workflow.cores
0084 singularity: EIC_SINGULARITY_CONTAINER,
0085 shell:
0086 """
0087 set -m # monitor mode to prevent lingering shells
0088 cleanup() {{
0089 echo Cleaning up
0090 kill $WORKER_PID $SCHEDULER_PID
0091 }}
0092 trap cleanup EXIT
0093
0094 PORT=$RANDOM
0095 dask scheduler --port $PORT 2>{log.scheduler} &
0096 export DASK_SCHEDULER=localhost:$PORT
0097 SCHEDULER_PID=$!
0098 dask worker tcp://$DASK_SCHEDULER --nworkers {threads} --nthreads 1 2>{log.worker} &
0099 WORKER_PID=$!
0100 env \
0101 MATPLOTLIBRC={input.matplotlibrc} \
0102 OUTPUT_DIR={output} \
0103 DETECTOR_CONFIG={wildcards.DETECTOR_CONFIG} \
0104 python {input.script}
0105 """