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     output:
0025         "sim/{DETECTOR_CONFIG}/demp_{EBEAM}x{PBEAM}_{INDEX}.edm4hep.root",
0026     params:
0027         N_EVENTS=100
0028     wildcard_constraints:
0029         EBEAM="\d+",
0030         PBEAM="\d+",
0031         INDEX="\d+",
0032     shell:
0033         """
0034 ddsim \
0035   --runType batch \
0036   --part.minimalKineticEnergy 100*GeV  \
0037   --filter.tracker edep0 \
0038   -v WARNING \
0039   --numberOfEvents {params.N_EVENTS} \
0040   --compactFile $DETECTOR_PATH/{wildcards.DETECTOR_CONFIG}.xml \
0041   --inputFiles root://dtn-eic.jlab.org//work/eic2/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 \
0042   --outputFile {output}
0043 """
0044 
0045 #Process the files produced in the previous step through eicrecon
0046 rule demp_reco:
0047     input:
0048         "sim/{DETECTOR_CONFIG}/demp_{EBEAM}x{PBEAM}_{INDEX}.edm4hep.root",
0049     output:
0050         "reco/{DETECTOR_CONFIG}/demp_{EBEAM}x{PBEAM}_{INDEX}.edm4eic.root",
0051     wildcard_constraints:
0052         EBEAM="\d+",
0053         PBEAM="\d+",
0054         INDEX="\d+",
0055     shell:
0056         """
0057 DETECTOR_CONFIG={wildcards.DETECTOR_CONFIG} eicrecon {input} -Ppodio:output_file={output}
0058 """
0059 
0060 #Process the files (either from the campaign or eicrecon) through the analysis script
0061 rule demp_analysis:
0062     input:
0063         script="benchmarks/Exclusive-Diffraction-Tagging/demp/analysis/demp_analysis.cxx",
0064         script_compiled=ROOT_BUILD_DIR_PREFIX + "benchmarks/Exclusive-Diffraction-Tagging/demp/analysis/demp_analysis_cxx.so",
0065         data="reco/{DETECTOR_CONFIG}/{PREFIX}demp_{EBEAM}x{PBEAM}_{INDEX}.edm4eic.root",
0066     output:
0067         config="results/{DETECTOR_CONFIG}/demp/{PREFIX}demp_{EBEAM}x{PBEAM}_{INDEX}/config.json",
0068         hists="results/{DETECTOR_CONFIG}/demp/{PREFIX}demp_{EBEAM}x{PBEAM}_{INDEX}/hists.root",
0069     wildcard_constraints:
0070         PREFIX= ".*",
0071         EBEAM="\d+",
0072         PBEAM="\d+",
0073         INDEX="\d+",
0074     shell:
0075         """
0076 cat > {output.config} <<EOF
0077 {{
0078   "rec_file": "{input.data}",
0079   "detector": "{wildcards.DETECTOR_CONFIG}",
0080   "ebeam": {wildcards.EBEAM},
0081   "pbeam": {wildcards.PBEAM},
0082   "output_prefix": "$(dirname "{output.hists}")/hists"
0083 }}
0084 EOF
0085 root -l -b -q '{input.script}+("{output.config}")'
0086 """
0087 
0088 #Merge all the files produced in the previous step
0089 rule demp_combine:
0090     input:
0091         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)],
0092     output:
0093         config="results/{DETECTOR_CONFIG}/demp/{PREFIX}demp_{EBEAM}x{PBEAM}_combined_{NUM_FILES}/config.json",
0094         hists="results/{DETECTOR_CONFIG}/demp/{PREFIX}demp_{EBEAM}x{PBEAM}_combined_{NUM_FILES}/hists.root",
0095     wildcard_constraints:
0096         PREFIX= ".*",
0097         EBEAM="\d+",
0098         PBEAM="\d+",
0099         NUM_FILES="\d+",
0100     shell:
0101         """
0102 cat > {output.config} <<EOF
0103 {{
0104   "hists_file": "{output.hists}",
0105   "detector": "{wildcards.DETECTOR_CONFIG}",
0106   "ebeam": {wildcards.EBEAM},
0107   "pbeam": {wildcards.PBEAM},
0108   "nfiles": {wildcards.NUM_FILES},
0109   "output_prefix": "$(dirname "{output.hists}")/plots"
0110 }}
0111 EOF
0112 hadd {output.hists} {input}
0113 """
0114 
0115 #Process the merged file through the plotting script
0116 rule demp_plots:
0117     input:
0118         script="benchmarks/Exclusive-Diffraction-Tagging/demp/analysis/demp_plots.cxx",
0119         script_compiled=ROOT_BUILD_DIR_PREFIX + "benchmarks/Exclusive-Diffraction-Tagging/demp/analysis/demp_plots_cxx.so",
0120         config="results/{DETECTOR_CONFIG}/demp/{PREFIX}demp_{EBEAM}x{PBEAM}_combined_{NUM_FILES}/config.json",
0121     output:
0122         "results/{DETECTOR_CONFIG}/demp/{PREFIX}demp_{EBEAM}x{PBEAM}_combined_{NUM_FILES}/plots.pdf"
0123     wildcard_constraints:
0124         PREFIX= ".*",
0125         EBEAM="\d+",
0126         PBEAM="\d+",
0127         NUM_FILES="\d+",
0128     shell:
0129         """
0130 root -l -b -q '{input.script}+("{input.config}")'
0131 """
0132 
0133 #Example of invocation
0134 rule demp_run_locally:
0135     input:
0136         "results/" + os.environ["DETECTOR_CONFIG"] + "/demp/demp_5x41_combined_5/plots.pdf",
0137     message:
0138         "See output in {input[0]}"
0139 
0140 rule demp_run_campaign:
0141     input:
0142         "results/epic_craterlake/demp/campaign_24.08.1_demp_5x41_combined_5/plots.pdf",
0143         "results/epic_craterlake/demp/campaign_24.09.0_demp_5x41_combined_5/plots.pdf",
0144     message:
0145         "See output in {input[0]}"
0146