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