Warning, /physics_benchmarks/benchmarks/Inclusive/dis/Snakefile is written in an unsupported language. File is not indexed.
0001 import shutil
0002
0003
0004 rule dis_compile:
0005 input:
0006 ROOT_BUILD_DIR_PREFIX + "benchmarks/Inclusive/dis/analysis/dis_electrons_cxx.so",
0007
0008
0009 rule dis_sim:
0010 input:
0011 warmup="warmup/{DETECTOR_CONFIG}.edm4hep.rnt.root",
0012 geometry_lib=find_epic_libraries(),
0013 output:
0014 "sim_output/{DETECTOR_CONFIG}/pythia8NCDIS_{EBEAM}x{PBEAM}_minQ2={MINQ2}_beamEffects_xAngle=-0.025_hiDiv_1.{INDEX}.edm4hep.rnt.root",
0015 wildcard_constraints:
0016 INDEX=r"\d{4}",
0017 params:
0018 N_EVENTS=100,
0019 SEED=lambda wildcards: "1" + wildcards.INDEX,
0020 EBEAM=lambda wildcards: wildcards.EBEAM,
0021 PBEAM=lambda wildcards: wildcards.PBEAM,
0022 MINQ2=lambda wildcards: wildcards.MINQ2,
0023 DETECTOR_PATH=config["DETECTOR_PATH"],
0024 DETECTOR_CONFIG=lambda wildcards: wildcards.DETECTOR_CONFIG,
0025 DD4HEP_HASH=get_spack_package_hash("dd4hep"),
0026 NPSIM_HASH=get_spack_package_hash("npsim"),
0027 remote_path=lambda wildcards: epic_fetch_url(
0028 f"EPIC/EVGEN/DIS/NC/{wildcards.EBEAM}x{wildcards.PBEAM}/minQ2={wildcards.MINQ2}/"
0029 f"pythia8NCDIS_{wildcards.EBEAM}x{wildcards.PBEAM}_minQ2={wildcards.MINQ2}_"
0030 f"beamEffects_xAngle=-0.025_hiDiv_1.hepmc3.tree.root"
0031 ),
0032 cache: True
0033 shell:
0034 """
0035 npsim \
0036 --runType batch \
0037 --part.minimalKineticEnergy 1000*GeV \
0038 --filter.tracker edep0 \
0039 -v WARNING \
0040 --numberOfEvents {params.N_EVENTS} \
0041 --compactFile {params.DETECTOR_PATH}/{params.DETECTOR_CONFIG}.xml \
0042 --random.seed {params.SEED} \
0043 --inputFiles {params.remote_path} \
0044 --outputConfig.useRNTuple true \
0045 --outputFile {output}
0046 """
0047
0048
0049 rule dis_reco_eicrecon:
0050 # This rule produces RNTuple format output (.edm4eic.rnt.root)
0051 # Analysis scripts (dis_electrons.cxx, kinematics_correlations.py) are format-agnostic
0052 # and work with both TTree and RNTuple formats:
0053 # - RNTuple: .edm4eic.rnt.root (default, used here with -Ppodio:output_backend=rntuple)
0054 # - TTree: .edm4eic.root (remove -Ppodio:output_backend=rntuple for legacy format)
0055 input:
0056 "sim_output/{DETECTOR_CONFIG}/pythia8NCDIS_{EBEAM}x{PBEAM}_minQ2={MINQ2}_beamEffects_xAngle=-0.025_hiDiv_1.{INDEX}.edm4hep.rnt.root",
0057 output:
0058 "sim_output/{DETECTOR_CONFIG}/pythia8NCDIS_{EBEAM}x{PBEAM}_minQ2={MINQ2}_beamEffects_xAngle=-0.025_hiDiv_1.{INDEX}.eicrecon.edm4eic.rnt.root",
0059 params:
0060 DETECTOR_CONFIG=lambda wildcards: wildcards.DETECTOR_CONFIG,
0061 EICRECON_HASH=get_spack_package_hash("eicrecon"),
0062 cache: True
0063 shell:
0064 """
0065 DETECTOR_CONFIG={params.DETECTOR_CONFIG} eicrecon {input} -Ppodio:output_file={output} -Ppodio:output_backend=rntuple
0066 """
0067
0068
0069 rule dis_generate_config:
0070 input:
0071 data="sim_output/{DETECTOR_CONFIG}/pythia8NCDIS_{EBEAM}x{PBEAM}_minQ2={MINQ2}_beamEffects_xAngle=-0.025_hiDiv_1.0000.eicrecon.edm4eic.rnt.root",
0072 output:
0073 config="results/{DETECTOR_CONFIG}/dis/{EBEAM}on{PBEAM}/minQ2={MINQ2}_config.json",
0074 shell: """
0075 cat > {output.config} <<EOF
0076 {{
0077 "rec_file": "{input.data}",
0078 "detector": "{wildcards.DETECTOR_CONFIG}",
0079 "output_prefix": "results/{wildcards.DETECTOR_CONFIG}/dis/{wildcards.EBEAM}on{wildcards.PBEAM}/minQ2={wildcards.MINQ2}/dis_{wildcards.EBEAM}x{wildcards.PBEAM}_minQ2={wildcards.MINQ2}",
0080 "results_path": "results/{wildcards.DETECTOR_CONFIG}/dis/{wildcards.EBEAM}on{wildcards.PBEAM}/minQ2={wildcards.MINQ2}",
0081 "ebeam": {wildcards.EBEAM},
0082 "pbeam": {wildcards.PBEAM},
0083 "minq2": {wildcards.MINQ2},
0084 "plot_tag": "dis_{wildcards.EBEAM}x{wildcards.PBEAM}_minQ2={wildcards.MINQ2}",
0085 "test_tag": "dis_{wildcards.EBEAM}x{wildcards.PBEAM}_minQ2={wildcards.MINQ2}"
0086 }}
0087 EOF
0088 """
0089
0090
0091 rule dis_analysis_electrons:
0092 input:
0093 script="benchmarks/Inclusive/dis/analysis/dis_electrons.cxx",
0094 script_compiled=ROOT_BUILD_DIR_PREFIX + "benchmarks/Inclusive/dis/analysis/dis_electrons_cxx.so",
0095 data="sim_output/{DETECTOR_CONFIG}/pythia8NCDIS_{EBEAM}x{PBEAM}_minQ2={MINQ2}_beamEffects_xAngle=-0.025_hiDiv_1.0000.eicrecon.edm4eic.rnt.root",
0096 config="results/{DETECTOR_CONFIG}/dis/{EBEAM}on{PBEAM}/minQ2={MINQ2}_config.json",
0097 output:
0098 expand("results/{{DETECTOR_CONFIG}}/dis/{{EBEAM}}on{{PBEAM}}/minQ2={{MINQ2}}/{FILENAME}", FILENAME=[
0099 "dis_{EBEAM}x{PBEAM}_minQ2={MINQ2}_logQ2_panels.png",
0100 "dis_{EBEAM}x{PBEAM}_minQ2={MINQ2}_logQ2_overlays.png",
0101 "dis_{EBEAM}x{PBEAM}_minQ2={MINQ2}_Q2_res_panels.png",
0102 "dis_{EBEAM}x{PBEAM}_minQ2={MINQ2}_Q2_res_overlays.png",
0103 "dis_{EBEAM}x{PBEAM}_minQ2={MINQ2}_x_panels.png",
0104 "dis_{EBEAM}x{PBEAM}_minQ2={MINQ2}_x_overlays.png",
0105 "dis_{EBEAM}x{PBEAM}_minQ2={MINQ2}_x_res_panels.png",
0106 "dis_{EBEAM}x{PBEAM}_minQ2={MINQ2}_x_res_overlays.png",
0107 "dis_{EBEAM}x{PBEAM}_minQ2={MINQ2}dis_electrons.json"
0108 ]),
0109 shell: """
0110 root -l -b -q '{input.script}+("{input.config}")'
0111 """
0112
0113
0114 rule dis_analysis_kinematics_correlations:
0115 input:
0116 data="sim_output/{DETECTOR_CONFIG}/pythia8NCDIS_{EBEAM}x{PBEAM}_minQ2={MINQ2}_beamEffects_xAngle=-0.025_hiDiv_1.0000.eicrecon.edm4eic.rnt.root",
0117 output:
0118 results_path=directory("results/{DETECTOR_CONFIG}/dis/{EBEAM}on{PBEAM}/minQ2={MINQ2}/kinematics_correlations"),
0119 params:
0120 N_EVENTS=100
0121 wildcard_constraints:
0122 EBEAM=r"\d+",
0123 PBEAM=r"\d+",
0124 MINQ2=r"\d+",
0125 shell: """
0126 mkdir {output.results_path}
0127 python benchmarks/Inclusive/dis/analysis/kinematics_correlations.py --rec_file "{input.data}" --config dis_{wildcards.EBEAM}x{wildcards.PBEAM}_minQ2={wildcards.MINQ2}_{wildcards.DETECTOR_CONFIG} --results_path {output.results_path} --nevents {params.N_EVENTS}
0128 """