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