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