Warning, /detector_benchmarks/Snakefile is written in an unsupported language. File is not indexed.
0001 configfile: "snakemake.yml"
0002
0003 import functools
0004 import os
0005 from snakemake.logging import logger
0006
0007
0008 rule compile_analysis:
0009 input:
0010 "{path}/{filename}.cxx",
0011 output:
0012 "{path}/{filename}_cxx.d",
0013 "{path}/{filename}_cxx.so",
0014 "{path}/{filename}_cxx_ACLiC_dict_rdict.pcm",
0015 shell:
0016 """
0017 root -l -b -q -e '.L {input}+'
0018 """
0019
0020
0021 @functools.cache
0022 def get_spack_package_hash(package_name):
0023 import json
0024 try:
0025 ver_info = json.loads(subprocess.check_output(["spack", "find", "--json", package_name]))
0026 return ver_info[0]["hash"]
0027 except FileNotFoundError as e:
0028 logger.warning("Spack is not installed")
0029 return ""
0030 except subprocess.CalledProcessError as e:
0031 print(e)
0032 return ""
0033
0034
0035 @functools.cache
0036 def find_epic_libraries():
0037 import ctypes.util
0038 # if library is not found (not avaliable) we return an empty list to let DAG still evaluate
0039 libs = []
0040 lib = ctypes.util.find_library("epic")
0041 if lib is not None:
0042 libs.append(os.environ["DETECTOR_PATH"] + "/../../lib/" + lib)
0043 return libs
0044
0045
0046 include: "benchmarks/backgrounds/Snakefile"
0047 include: "benchmarks/backwards_ecal/Snakefile"
0048 include: "benchmarks/barrel_ecal/Snakefile"
0049 include: "benchmarks/beamline/Snakefile"
0050 include: "benchmarks/calo_pid/Snakefile"
0051 include: "benchmarks/campaign/Snakefile"
0052 include: "benchmarks/ecal_gaps/Snakefile"
0053 include: "benchmarks/far_forward_dvcs/Snakefile"
0054 include: "benchmarks/lowq2_reconstruction/Snakefile"
0055 include: "benchmarks/material_scan/Snakefile"
0056 include: "benchmarks/secondary_vertexing_dis/Snakefile"
0057 include: "benchmarks/tracking_performances/Snakefile"
0058 include: "benchmarks/tracking_performances_dis/Snakefile"
0059 include: "benchmarks/lfhcal/Snakefile"
0060 include: "benchmarks/zdc_lyso/Snakefile"
0061 include: "benchmarks/zdc_neutron/Snakefile"
0062 include: "benchmarks/insert_muon/Snakefile"
0063 include: "benchmarks/zdc_lambda/Snakefile"
0064 include: "benchmarks/zdc_photon/Snakefile"
0065 include: "benchmarks/zdc_pi0/Snakefile"
0066 include: "benchmarks/zdc_sigma/Snakefile"
0067 include: "benchmarks/insert_neutron/Snakefile"
0068 include: "benchmarks/insert_tau/Snakefile"
0069 include: "benchmarks/femc_electron/Snakefile"
0070 include: "benchmarks/femc_photon/Snakefile"
0071 include: "benchmarks/femc_pi0/Snakefile"
0072 include: "benchmarks/nhcal_acceptance/Snakefile"
0073 include: "benchmarks/nhcal_basic_distribution/Snakefile"
0074
0075 use_s3 = config["remote_provider"].lower() == "s3"
0076 use_xrootd = config["remote_provider"].lower() == "xrootd"
0077
0078
0079 def get_remote_path(path):
0080 if use_s3:
0081 return f"s3https://eics3.sdcc.bnl.gov:9000/eictest/{path}"
0082 elif use_xrootd:
0083 return f"root://dtn-eic.jlab.org//volatile/eic/{path}"
0084 else:
0085 raise runtime_exception('Unexpected value for config["remote_provider"]: {config["remote_provider"]}')
0086
0087
0088 rule fetch_epic:
0089 output:
0090 filepath="EPIC/{PATH}"
0091 params:
0092 # wildcards are not included in hash for caching, we need to add them as params
0093 PATH=lambda wildcards: wildcards.PATH
0094 cache: True
0095 retries: 3
0096 shell: """
0097 xrdcp --debug 2 root://dtn-eic.jlab.org//volatile/eic/{output.filepath} {output.filepath}
0098 """ if use_xrootd else """
0099 mc cp S3/eictest/{output.filepath} {output.filepath}
0100 """ if use_s3 else f"""
0101 echo 'Unexpected value for config["remote_provider"]: {config["remote_provider"]}'
0102 exit 1
0103 """
0104
0105
0106 rule warmup_run:
0107 output:
0108 "warmup.edm4hep.root",
0109 message: "Ensuring that calibrations/fieldmaps are available"
0110 shell: """
0111 set -m # monitor mode to prevent lingering processes
0112 exec ddsim \
0113 --runType batch \
0114 --numberOfEvents 1 \
0115 --compactFile "$DETECTOR_PATH/epic_ip6.xml" \
0116 --outputFile "{output}" \
0117 --enableGun
0118 """
0119
0120
0121 rule matplotlibrc:
0122 output:
0123 ".matplotlibrc",
0124 run:
0125 with open(output[0], "wt") as fp:
0126 fp.write("backend: Agg\n")
0127 # interactive mode prevents plt.show() from blocking
0128 fp.write("interactive : True\n")
0129
0130
0131 rule org2py:
0132 input:
0133 notebook=workflow.basedir + "/{NOTEBOOK}.org",
0134 converter=workflow.source_path("benchmarks/common/org2py.awk"),
0135 output:
0136 "{NOTEBOOK}.py"
0137 shell:
0138 """
0139 awk -f {input.converter} {input.notebook} > {output}
0140 """
0141
0142
0143 rule metadata:
0144 output:
0145 "results/metadata.json"
0146 shell:
0147 """
0148 cat > {output} <<EOF
0149 {{
0150 "CI_COMMIT_REF_NAME": "${{CI_COMMIT_REF_NAME:-}}",
0151 "CI_COMMIT_SHA": "${{CI_COMMIT_SHA:-}}",
0152 "CI_PIPELINE_ID": "${{CI_PIPELINE_ID:-}}",
0153 "CI_PIPELINE_SOURCE": "${{CI_PIPELINE_SOURCE:-}}",
0154 "CI_PROJECT_ID": "${{CI_PROJECT_ID:-}}",
0155 "GITHUB_REPOSITORY": "${{GITHUB_REPOSITORY:-}}",
0156 "GITHUB_SHA": "${{GITHUB_SHA:-}}",
0157 "GITHUB_PR": "${{GITHUB_PR:-}}",
0158 "PIPELINE_NAME": $(echo "${{PIPELINE_NAME:-}}" | jq -Rs .)
0159 }}
0160 EOF
0161 # validate JSON
0162 jq '.' {output}
0163 """