Back to home page

EIC code displayed by LXR

 
 

    


Warning, /physics_benchmarks/benchmarks/Exclusive-Diffraction-Tagging/demp/Snakefile is written in an unsupported language. File is not indexed.

0001 import os
0002 
0003 #Compile the analysis and plotting scripts
0004 rule demp_compile:
0005     input:
0006         ROOT_BUILD_DIR_PREFIX + "benchmarks/Exclusive-Diffraction-Tagging/demp/analysis/demp_analysis_cxx.so",
0007         ROOT_BUILD_DIR_PREFIX + "benchmarks/Exclusive-Diffraction-Tagging/demp/analysis/demp_plots_cxx.so",
0008 
0009 #Process the simulated files based on the user-defined campaign
0010 rule demp_campaign_reco_get:
0011     input:
0012         lambda wildcards: f"EPIC/RECO/{wildcards.RELEASE_TAG}/{wildcards.DETECTOR_CONFIG}/EXCLUSIVE/DEMP/DEMPgen-1.2.0/{wildcards.EBEAM}x{wildcards.PBEAM}/pi+/DEMPgen-1.2.0_{wildcards.EBEAM}x{wildcards.PBEAM}_pi+_10.000{wildcards.INDEX}.eicrecon.tree.edm4eic.root",
0013     output:
0014         temp("reco/{DETECTOR_CONFIG}/campaign_{RELEASE_TAG}_demp_{EBEAM}x{PBEAM}_{INDEX}.edm4eic.root"),
0015     shell:
0016         """
0017 mv {input} {output}
0018 """
0019 
0020 #Process the afterburned files through the simulations
0021 rule demp_sim:
0022     input:
0023         warmup="warmup/{DETECTOR_CONFIG}.edm4hep.root",
0024         geometry_lib=find_epic_libraries(),
0025     output:
0026         "sim/{DETECTOR_CONFIG}/demp_{EBEAM}x{PBEAM}_{INDEX}.edm4hep.root",
0027     params:
0028         N_EVENTS=100,
0029         DD4HEP_HASH=get_spack_package_hash("dd4hep"),
0030         NPSIM_HASH=get_spack_package_hash("npsim"),
0031     wildcard_constraints:
0032         EBEAM=r"\d+",
0033         PBEAM=r"\d+",
0034         INDEX=r"\d+",
0035     cache: True
0036     shell:
0037         """
0038 npsim \
0039   --runType batch \
0040   --part.minimalKineticEnergy 100*GeV  \
0041   --filter.tracker edep0 \
0042   -v WARNING \
0043   --numberOfEvents {params.N_EVENTS} \
0044   --compactFile $DETECTOR_PATH/{wildcards.DETECTOR_CONFIG}.xml \
0045   --inputFiles root://dtn-eic.jlab.org//volatile/eic/EPIC/EVGEN/EXCLUSIVE/DEMP/DEMPgen-1.2.0/{wildcards.EBEAM}x{wildcards.PBEAM}/pi+/DEMPgen-1.2.0_{wildcards.EBEAM}x{wildcards.PBEAM}_pi+_{wildcards.INDEX}.hepmc3.tree.root \
0046   --outputFile {output}
0047 """
0048 
0049 #Process the files produced in the previous step through eicrecon
0050 rule demp_reco:
0051     input:
0052         "sim/{DETECTOR_CONFIG}/demp_{EBEAM}x{PBEAM}_{INDEX}.edm4hep.root",
0053     output:
0054         "reco/{DETECTOR_CONFIG}/demp_{EBEAM}x{PBEAM}_{INDEX}.edm4eic.root",
0055     params:
0056         EICRECON_HASH=get_spack_package_hash("eicrecon"),
0057     wildcard_constraints:
0058         EBEAM=r"\d+",
0059         PBEAM=r"\d+",
0060         INDEX=r"\d+",
0061     cache: True
0062     shell:
0063         """
0064 DETECTOR_CONFIG={wildcards.DETECTOR_CONFIG} eicrecon {input} -Ppodio:output_file={output}
0065 """
0066 
0067 #Process the files (either from the campaign or eicrecon) through the analysis script
0068 rule demp_analysis:
0069     input:
0070         script="benchmarks/Exclusive-Diffraction-Tagging/demp/analysis/demp_analysis.cxx",
0071         script_compiled=ROOT_BUILD_DIR_PREFIX + "benchmarks/Exclusive-Diffraction-Tagging/demp/analysis/demp_analysis_cxx.so",
0072         data="reco/{DETECTOR_CONFIG}/{PREFIX}demp_{EBEAM}x{PBEAM}_{INDEX}.edm4eic.root",
0073     output:
0074         config="results/{DETECTOR_CONFIG}/demp/{PREFIX}demp_{EBEAM}x{PBEAM}_{INDEX}/config.json",
0075         hists="results/{DETECTOR_CONFIG}/demp/{PREFIX}demp_{EBEAM}x{PBEAM}_{INDEX}/hists.root",
0076     wildcard_constraints:
0077         PREFIX= ".*",
0078         EBEAM=r"\d+",
0079         PBEAM=r"\d+",
0080         INDEX=r"\d+",
0081     shell:
0082         """
0083 cat > {output.config} <<EOF
0084 {{
0085   "rec_file": "{input.data}",
0086   "detector": "{wildcards.DETECTOR_CONFIG}",
0087   "ebeam": {wildcards.EBEAM},
0088   "pbeam": {wildcards.PBEAM},
0089   "output_prefix": "$(dirname "{output.hists}")/hists"
0090 }}
0091 EOF
0092 root -l -b -q '{input.script}+("{output.config}")'
0093 """
0094 
0095 #Merge all the files produced in the previous step
0096 rule demp_combine:
0097     input:
0098         lambda wildcards: [f"results/{wildcards.DETECTOR_CONFIG}/demp/{wildcards.PREFIX}demp_{wildcards.EBEAM}x{wildcards.PBEAM}_{ix}/hists.root" for ix in range(1,int(wildcards.NUM_FILES)+1)],
0099     output:
0100         config="results/{DETECTOR_CONFIG}/demp/{PREFIX}demp_{EBEAM}x{PBEAM}_combined_{NUM_FILES}/config.json",
0101         hists="results/{DETECTOR_CONFIG}/demp/{PREFIX}demp_{EBEAM}x{PBEAM}_combined_{NUM_FILES}/hists.root",
0102     wildcard_constraints:
0103         PREFIX= ".*",
0104         EBEAM=r"\d+",
0105         PBEAM=r"\d+",
0106         NUM_FILES=r"\d+",
0107     shell:
0108         """
0109 cat > {output.config} <<EOF
0110 {{
0111   "hists_file": "{output.hists}",
0112   "detector": "{wildcards.DETECTOR_CONFIG}",
0113   "ebeam": {wildcards.EBEAM},
0114   "pbeam": {wildcards.PBEAM},
0115   "nfiles": {wildcards.NUM_FILES},
0116   "output_prefix": "$(dirname "{output.hists}")/plots"
0117 }}
0118 EOF
0119 hadd {output.hists} {input}
0120 """
0121 
0122 #Process the merged file through the plotting script
0123 rule demp_plots:
0124     input:
0125         script="benchmarks/Exclusive-Diffraction-Tagging/demp/analysis/demp_plots.cxx",
0126         script_compiled=ROOT_BUILD_DIR_PREFIX + "benchmarks/Exclusive-Diffraction-Tagging/demp/analysis/demp_plots_cxx.so",
0127         config="results/{DETECTOR_CONFIG}/demp/{PREFIX}demp_{EBEAM}x{PBEAM}_combined_{NUM_FILES}/config.json",
0128     output:
0129         "results/{DETECTOR_CONFIG}/demp/{PREFIX}demp_{EBEAM}x{PBEAM}_combined_{NUM_FILES}/plots.pdf"
0130     wildcard_constraints:
0131         PREFIX= ".*",
0132         EBEAM=r"\d+",
0133         PBEAM=r"\d+",
0134         NUM_FILES=r"\d+",
0135     shell:
0136         """
0137 root -l -b -q '{input.script}+("{input.config}")'
0138 """
0139 
0140 #Example of invocation
0141 rule demp_run_locally:
0142     input:
0143         "results/" + os.environ["DETECTOR_CONFIG"] + "/demp/demp_5x41_combined_5/plots.pdf",
0144     message:
0145         "See output in {input[0]}"
0146 
0147 rule demp_run_campaign:
0148     input:
0149         "results/epic_craterlake/demp/campaign_24.08.1_demp_5x41_combined_5/plots.pdf",
0150         "results/epic_craterlake/demp/campaign_24.09.0_demp_5x41_combined_5/plots.pdf",
0151     message:
0152         "See output in {input[0]}"
0153