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=config["DETECTOR_PREFIX"] + "/share/epic",
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,EcalEndcapNTruthClusters,EcalEndcapNTruthClusterAssociations,EcalBarrelTruthClusters,EcalBarrelTruthClusterAssociations,EcalEndcapPTruthClusters,EcalEndcapPTruthClusterAssociations
0063 """
0064
0065
0066 rule ecal_gaps:
0067 input:
0068 matplotlibrc=".matplotlibrc",
0069 script="benchmarks/ecal_gaps/ecal_gaps.org2py.py",
0070 truth_script=workflow.source_path("truth_clusters.py"),
0071 # TODO pass as a file list?
0072 _=expand(
0073 "sim_output/ecal_gaps/{{DETECTOR_CONFIG}}/{PARTICLE}/{ENERGY}/{PHASE_SPACE}/{PARTICLE}_{ENERGY}_{PHASE_SPACE}.{INDEX:04d}.eicrecon.edm4eic.root",
0074 PARTICLE=["e-"],
0075 ENERGY=["500MeV", "5GeV", "20GeV"],
0076 PHASE_SPACE=["3to50deg", "45to135deg", "130to177deg"],
0077 INDEX=range(1),
0078 ),
0079 output:
0080 directory("results/{DETECTOR_CONFIG}/ecal_gaps"),
0081 log:
0082 scheduler=".logs/results/{DETECTOR_CONFIG}/ecal_gaps/scheduler.log",
0083 worker=".logs/results/{DETECTOR_CONFIG}/ecal_gaps/worker.log",
0084 threads: workflow.cores
0085 singularity: EIC_SINGULARITY_CONTAINER,
0086 shell:
0087 """
0088 set -m # monitor mode to prevent lingering shells
0089 cleanup() {{
0090 echo Cleaning up
0091 kill $WORKER_PID $SCHEDULER_PID
0092 }}
0093 trap cleanup EXIT
0094
0095 PORT=$RANDOM
0096 dask scheduler --port $PORT 2>{log.scheduler} &
0097 export DASK_SCHEDULER=localhost:$PORT
0098 SCHEDULER_PID=$!
0099 dask worker tcp://$DASK_SCHEDULER --nworkers {threads} --nthreads 1 2>{log.worker} &
0100 WORKER_PID=$!
0101 env \
0102 MATPLOTLIBRC={input.matplotlibrc} \
0103 OUTPUT_DIR={output} \
0104 DETECTOR_CONFIG={wildcards.DETECTOR_CONFIG} \
0105 python {input.script}
0106 python {input.truth_script} --detector-config {wildcards.DETECTOR_CONFIG} --output-dir {output}
0107 """