Back to home page

EIC code displayed by LXR

 
 

    


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=ancient("EPIC/EVGEN/SINGLE/{PARTICLE}/{ENERGY}/{PHASE_SPACE}/{PARTICLE}_{ENERGY}_{PHASE_SPACE}.steer"),
0007         warmup="warmup/{DETECTOR_CONFIG}.edm4hep.root",
0008     output:
0009         "sim_output/ecal_gaps/{DETECTOR_CONFIG}/{PARTICLE}/{ENERGY}/{PHASE_SPACE}/{PARTICLE}_{ENERGY}_{PHASE_SPACE}.{INDEX}.edm4hep.root",
0010     log:
0011         "sim_output/ecal_gaps/{DETECTOR_CONFIG}/{PARTICLE}/{ENERGY}/{PHASE_SPACE}/{PARTICLE}_{ENERGY}_{PHASE_SPACE}.{INDEX}.edm4hep.root.log",
0012     wildcard_constraints:
0013         PARTICLE="e-",
0014         ENERGY="(500MeV|5GeV|20GeV)",
0015         PHASE_SPACE="(3to50|45to135|130to177)deg",
0016         INDEX="\d{4}",
0017     params:
0018         N_EVENTS=1000
0019     shell:
0020         """
0021 set -m # monitor mode to prevent lingering processes
0022 exec ddsim \
0023   --runType batch \
0024   --enableGun \
0025   --steeringFile "{input.steering_file}" \
0026   --random.seed 1{wildcards.INDEX} \
0027   --filter.tracker edep0 \
0028   -v WARNING \
0029   --numberOfEvents {params.N_EVENTS} \
0030   --compactFile $DETECTOR_PATH/{wildcards.DETECTOR_CONFIG}.xml \
0031   --outputFile {output}
0032 """
0033 
0034 
0035 rule ecal_gaps_recon:
0036     input:
0037         "sim_output/ecal_gaps/{DETECTOR_CONFIG}/{PARTICLE}/{ENERGY}/{PHASE_SPACE}/{PARTICLE}_{ENERGY}_{PHASE_SPACE}.{INDEX}.edm4hep.root",
0038     output:
0039         "sim_output/ecal_gaps/{DETECTOR_CONFIG}/{PARTICLE}/{ENERGY}/{PHASE_SPACE}/{PARTICLE}_{ENERGY}_{PHASE_SPACE}.{INDEX}.eicrecon.tree.edm4eic.root",
0040     log:
0041         "sim_output/ecal_gaps/{DETECTOR_CONFIG}/{PARTICLE}/{ENERGY}/{PHASE_SPACE}/{PARTICLE}_{ENERGY}_{PHASE_SPACE}.{INDEX}.eicrecon.tree.edm4eic.root.log",
0042     wildcard_constraints:
0043         INDEX="\d{4}",
0044     shell: """
0045 set -m # monitor mode to prevent lingering processes
0046 exec env DETECTOR_CONFIG={wildcards.DETECTOR_CONFIG} \
0047   eicrecon {input} -Ppodio:output_file={output} \
0048   -Ppodio:output_collections=EcalEndcapNRecHits,EcalBarrelScFiRecHits,EcalBarrelImagingRecHits,EcalEndcapPRecHits,MCParticles
0049 """
0050 
0051 
0052 DETECTOR_CONFIG=os.environ["DETECTOR_CONFIG"]
0053 
0054 rule ecal_gaps:
0055     input:
0056         matplotlibrc=".matplotlibrc",
0057         script="benchmarks/ecal_gaps/ecal_gaps.py",
0058         # TODO pass as a file list?
0059         _=expand(
0060             "sim_output/ecal_gaps/{DETECTOR_CONFIG}/{PARTICLE}/{ENERGY}/{PHASE_SPACE}/{PARTICLE}_{ENERGY}_{PHASE_SPACE}.{INDEX:04d}.eicrecon.tree.edm4eic.root",
0061             DETECTOR_CONFIG=DETECTOR_CONFIG,
0062             PARTICLE=["e-"],
0063             ENERGY=["500MeV", "5GeV", "20GeV"],
0064             PHASE_SPACE=["3to50deg", "45to135deg", "130to177deg"],
0065             INDEX=range(1),
0066         ),
0067     output:
0068         directory("results/ecal_gaps"),
0069     threads: workflow.cores
0070     shell:
0071         """
0072 set -m # monitor mode to prevent lingering shells
0073 cleanup() {{
0074   echo Cleaning up
0075   kill $WORKER_PID $SCHEDULER_PID
0076 }}
0077 trap cleanup EXIT
0078 
0079 PORT=$RANDOM
0080 dask scheduler --port $PORT &
0081 export DASK_SCHEDULER=localhost:$PORT
0082 SCHEDULER_PID=$!
0083 dask worker tcp://$DASK_SCHEDULER --nworkers {threads} --nthreads 1 &
0084 WORKER_PID=$!
0085 env \
0086 MATPLOTLIBRC={input.matplotlibrc} \
0087 OUTPUT_DIR={output} \
0088 python {input.script}
0089 """