Back to home page

EIC code displayed by LXR

 
 

    


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]["package_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/tracking_performances/Snakefile"
0057 include: "benchmarks/tracking_performances_dis/Snakefile"
0058 include: "benchmarks/lfhcal/Snakefile"
0059 include: "benchmarks/zdc_lyso/Snakefile"
0060 include: "benchmarks/zdc_neutron/Snakefile"
0061 include: "benchmarks/insert_muon/Snakefile"
0062 include: "benchmarks/zdc_lambda/Snakefile"
0063 include: "benchmarks/zdc_photon/Snakefile"
0064 include: "benchmarks/zdc_pi0/Snakefile"
0065 include: "benchmarks/zdc_sigma/Snakefile"
0066 include: "benchmarks/insert_neutron/Snakefile"
0067 include: "benchmarks/insert_tau/Snakefile"
0068 include: "benchmarks/femc_electron/Snakefile"
0069 include: "benchmarks/femc_photon/Snakefile"
0070 include: "benchmarks/femc_pi0/Snakefile"
0071 include: "benchmarks/nhcal_acceptance/Snakefile"
0072 include: "benchmarks/nhcal_basic_distribution/Snakefile"
0073 
0074 use_s3 = config["remote_provider"].lower() == "s3"
0075 use_xrootd = config["remote_provider"].lower() == "xrootd"
0076 
0077 
0078 def get_remote_path(path):
0079     if use_s3:
0080         return f"s3https://eics3.sdcc.bnl.gov:9000/eictest/{path}"
0081     elif use_xrootd:
0082         return f"root://dtn-eic.jlab.org//volatile/eic/{path}"
0083     else:
0084         raise runtime_exception('Unexpected value for config["remote_provider"]: {config["remote_provider"]}')
0085 
0086 
0087 rule fetch_epic:
0088     output:
0089         filepath="EPIC/{PATH}"
0090     params:
0091         # wildcards are not included in hash for caching, we need to add them as params
0092         PATH=lambda wildcards: wildcards.PATH
0093     cache: True
0094     retries: 3
0095     shell: """
0096 xrdcp --debug 2 root://dtn-eic.jlab.org//volatile/eic/{output.filepath} {output.filepath}
0097 """ if use_xrootd else """
0098 mc cp S3/eictest/{output.filepath} {output.filepath}
0099 """ if use_s3 else f"""
0100 echo 'Unexpected value for config["remote_provider"]: {config["remote_provider"]}'
0101 exit 1
0102 """
0103 
0104 
0105 rule warmup_run:
0106     output:
0107         "warmup/{DETECTOR_CONFIG}.edm4hep.root",
0108     message: "Ensuring that calibrations/fieldmaps are available for {wildcards.DETECTOR_CONFIG}"
0109     shell: """
0110 set -m # monitor mode to prevent lingering processes
0111 exec ddsim \
0112   --runType batch \
0113   --numberOfEvents 1 \
0114   --compactFile "$DETECTOR_PATH/{wildcards.DETECTOR_CONFIG}.xml" \
0115   --outputFile "{output}" \
0116   --enableGun
0117 """
0118 
0119 
0120 rule matplotlibrc:
0121     output:
0122         ".matplotlibrc",
0123     run:
0124         with open(output[0], "wt") as fp:
0125             fp.write("backend: Agg\n")
0126             # interactive mode prevents plt.show() from blocking
0127             fp.write("interactive : True\n")
0128 
0129 
0130 rule org2py:
0131     input:
0132         notebook=workflow.basedir + "/{NOTEBOOK}.org",
0133         converter=workflow.source_path("benchmarks/common/org2py.awk"),
0134     output:
0135         "{NOTEBOOK}.py"
0136     shell:
0137         """
0138 awk -f {input.converter} {input.notebook} > {output}
0139 """
0140 
0141 
0142 rule metadata:
0143     output:
0144         "results/metadata.json"
0145     shell:
0146         """
0147 cat > {output} <<EOF
0148 {{
0149   "CI_COMMIT_REF_NAME": "${{CI_COMMIT_REF_NAME:-}}",
0150   "CI_COMMIT_SHA": "${{CI_COMMIT_SHA:-}}",
0151   "CI_PIPELINE_ID": "${{CI_PIPELINE_ID:-}}",
0152   "CI_PIPELINE_SOURCE": "${{CI_PIPELINE_SOURCE:-}}",
0153   "CI_PROJECT_ID": "${{CI_PROJECT_ID:-}}",
0154   "GITHUB_REPOSITORY": "${{GITHUB_REPOSITORY:-}}",
0155   "GITHUB_SHA": "${{GITHUB_SHA:-}}",
0156   "GITHUB_PR": "${{GITHUB_PR:-}}",
0157   "PIPELINE_NAME": "${{PIPELINE_NAME:-}}"
0158 }}
0159 EOF
0160 # validate JSON
0161 jq '.' {output}
0162 """