Warning, /physics_benchmarks/benchmarks/Exclusive-Diffraction-Tagging/dvmp/Snakefile is written in an unsupported language. File is not indexed.
0001 # Compile the analysis scripts
0002 rule dvmp_compile:
0003 input:
0004 ROOT_BUILD_DIR_PREFIX + "benchmarks/Exclusive-Diffraction-Tagging/dvmp/analysis/vm_mass_cxx.so",
0005 ROOT_BUILD_DIR_PREFIX + "benchmarks/Exclusive-Diffraction-Tagging/dvmp/analysis/vm_invar_cxx.so",
0006
0007 # Generation rule (uses lager event generator)
0008 rule dvmp_gen:
0009 output:
0010 hepmc="input/gen-{CONFIG}_{DECAY}_{N_EVENTS}.hepmc",
0011 config=temp("tmp/gen-{CONFIG}_{DECAY}_{N_EVENTS}.json"),
0012 params:
0013 N_EVENTS=lambda wildcards: int(wildcards.N_EVENTS),
0014 RNG_SEED=config["BENCHMARK_RNG_SEED"],
0015 EBEAM=lambda wildcards: 10, # Default for 10x100
0016 PBEAM=lambda wildcards: 100,
0017 BRANCHING=lambda wildcards: "0.05961" if wildcards.DECAY == "muon" else "0.05971",
0018 DECAY_PID=lambda wildcards: "13" if wildcards.DECAY == "muon" else "11",
0019 wildcard_constraints:
0020 CONFIG=r"[a-z_]+",
0021 DECAY=r"(muon|electron)",
0022 N_EVENTS=r"\d+",
0023 shell:
0024 """
0025 # Create generator configuration from template
0026 mkdir -p tmp input
0027 sed -e "s/@TAG@/gen-{wildcards.CONFIG}_{wildcards.DECAY}_{params.N_EVENTS}/" \
0028 -e "s/@EBEAM@/{params.EBEAM}/" \
0029 -e "s/@PBEAM@/{params.PBEAM}/" \
0030 -e "s/@DECAY_LEPTON@/{params.DECAY_PID}/" \
0031 -e "s/@BRANCHING@/{params.BRANCHING}/" \
0032 benchmarks/Exclusive-Diffraction-Tagging/dvmp/generator/{wildcards.CONFIG}.json.in > {output.config}
0033
0034 # Run the generator
0035 lager -r {params.RNG_SEED} \
0036 -c {output.config} \
0037 -e {params.N_EVENTS} \
0038 -o tmp
0039
0040 # Move output to input directory
0041 for ext in hepmc json log root ; do
0042 if [ -f tmp/*.gen-{wildcards.CONFIG}_{wildcards.DECAY}_{params.N_EVENTS}.*.${{ext}} ]; then
0043 mv tmp/*.gen-{wildcards.CONFIG}_{wildcards.DECAY}_{params.N_EVENTS}.*.${{ext}} input/gen-{wildcards.CONFIG}_{wildcards.DECAY}_{params.N_EVENTS}.${{ext}}
0044 fi
0045 done
0046 """
0047
0048 # Simulation rule
0049 rule dvmp_sim:
0050 input:
0051 warmup="warmup/{DETECTOR_CONFIG}.edm4hep.rnt.root",
0052 geometry_lib=find_epic_libraries(),
0053 gen_file="input/gen-{CONFIG}_{DECAY}_{N_EVENTS}.hepmc",
0054 output:
0055 "sim/{DETECTOR_CONFIG}/sim-{CONFIG}_{DECAY}_{N_EVENTS}.edm4hep.rnt.root",
0056 params:
0057 N_EVENTS=lambda wildcards: int(wildcards.N_EVENTS),
0058 DD4HEP_HASH=get_spack_package_hash("dd4hep"),
0059 NPSIM_HASH=get_spack_package_hash("npsim"),
0060 wildcard_constraints:
0061 CONFIG=r"[a-z_]+",
0062 DECAY=r"(muon|electron)",
0063 N_EVENTS=r"\d+",
0064 cache: True
0065 shell:
0066 """
0067 npsim \
0068 --runType batch \
0069 --part.minimalKineticEnergy 100*GeV \
0070 --filter.tracker edep0 \
0071 -v WARNING \
0072 --numberOfEvents {params.N_EVENTS} \
0073 --compactFile $DETECTOR_PATH/{wildcards.DETECTOR_CONFIG}.xml \
0074 --inputFiles {input.gen_file} \
0075 --outputConfig.useRNTuple true \
0076 --outputFile {output}
0077 """
0078
0079 # Reconstruction rule
0080 rule dvmp_reco:
0081 input:
0082 "sim/{DETECTOR_CONFIG}/sim-{CONFIG}_{DECAY}_{N_EVENTS}.edm4hep.rnt.root",
0083 output:
0084 "reco/{DETECTOR_CONFIG}/rec-{CONFIG}_{DECAY}_{N_EVENTS}.edm4eic.root",
0085 params:
0086 EICRECON_HASH=get_spack_package_hash("eicrecon"),
0087 wildcard_constraints:
0088 CONFIG=r"[a-z_]+",
0089 DECAY=r"(muon|electron)",
0090 N_EVENTS=r"\d+",
0091 cache: True
0092 shell:
0093 """
0094 DETECTOR_CONFIG={wildcards.DETECTOR_CONFIG} eicrecon {input} -Ppodio:output_file={output}
0095 """
0096
0097 # Analysis rule for vm_mass
0098 rule dvmp_analysis_vm_mass:
0099 input:
0100 script="benchmarks/Exclusive-Diffraction-Tagging/dvmp/analysis/vm_mass.cxx",
0101 script_compiled=ROOT_BUILD_DIR_PREFIX + "benchmarks/Exclusive-Diffraction-Tagging/dvmp/analysis/vm_mass_cxx.so",
0102 data="reco/{DETECTOR_CONFIG}/rec-{CONFIG}_{DECAY}_{N_EVENTS}.edm4eic.root",
0103 output:
0104 config="results/{DETECTOR_CONFIG}/dvmp/{CONFIG}_{DECAY}_{N_EVENTS}/vm_mass_config.json",
0105 done="results/{DETECTOR_CONFIG}/dvmp/{CONFIG}_{DECAY}_{N_EVENTS}/vm_mass_done.txt",
0106 params:
0107 EBEAM=10,
0108 PBEAM=100,
0109 LEADING="jpsi",
0110 wildcard_constraints:
0111 CONFIG=r"[a-z_]+",
0112 DECAY=r"(muon|electron)",
0113 N_EVENTS=r"\d+",
0114 shell:
0115 """
0116 mkdir -p results/{wildcards.DETECTOR_CONFIG}/dvmp/{wildcards.CONFIG}_{wildcards.DECAY}_{wildcards.N_EVENTS}
0117 cat > {output.config} <<EOF
0118 {{
0119 "rec_file": "{input.data}",
0120 "vm_name": "{params.LEADING}",
0121 "decay": "{wildcards.DECAY}",
0122 "detector": "{wildcards.DETECTOR_CONFIG}",
0123 "output_prefix": "results/{wildcards.DETECTOR_CONFIG}/dvmp/{wildcards.CONFIG}_{wildcards.DECAY}_{wildcards.N_EVENTS}/{wildcards.CONFIG}_{wildcards.DECAY}",
0124 "test_tag": "{params.LEADING}_{wildcards.DECAY}_{params.EBEAM}x{params.PBEAM}"
0125 }}
0126 EOF
0127 root -l -b -q '{input.script}+("{output.config}")'
0128 touch {output.done}
0129 """
0130
0131 # Analysis rule for vm_invar
0132 rule dvmp_analysis_vm_invar:
0133 input:
0134 script="benchmarks/Exclusive-Diffraction-Tagging/dvmp/analysis/vm_invar.cxx",
0135 script_compiled=ROOT_BUILD_DIR_PREFIX + "benchmarks/Exclusive-Diffraction-Tagging/dvmp/analysis/vm_invar_cxx.so",
0136 data="reco/{DETECTOR_CONFIG}/rec-{CONFIG}_{DECAY}_{N_EVENTS}.edm4eic.root",
0137 output:
0138 config="results/{DETECTOR_CONFIG}/dvmp/{CONFIG}_{DECAY}_{N_EVENTS}/vm_invar_config.json",
0139 done="results/{DETECTOR_CONFIG}/dvmp/{CONFIG}_{DECAY}_{N_EVENTS}/vm_invar_done.txt",
0140 params:
0141 EBEAM=10,
0142 PBEAM=100,
0143 LEADING="jpsi",
0144 wildcard_constraints:
0145 CONFIG=r"[a-z_]+",
0146 DECAY=r"(muon|electron)",
0147 N_EVENTS=r"\d+",
0148 shell:
0149 """
0150 mkdir -p results/{wildcards.DETECTOR_CONFIG}/dvmp/{wildcards.CONFIG}_{wildcards.DECAY}_{wildcards.N_EVENTS}
0151 cat > {output.config} <<EOF
0152 {{
0153 "rec_file": "{input.data}",
0154 "vm_name": "{params.LEADING}",
0155 "decay": "{wildcards.DECAY}",
0156 "detector": "{wildcards.DETECTOR_CONFIG}",
0157 "output_prefix": "results/{wildcards.DETECTOR_CONFIG}/dvmp/{wildcards.CONFIG}_{wildcards.DECAY}_{wildcards.N_EVENTS}/{wildcards.CONFIG}_{wildcards.DECAY}",
0158 "test_tag": "{params.LEADING}_{wildcards.DECAY}_{params.EBEAM}x{params.PBEAM}"
0159 }}
0160 EOF
0161 root -l -b -q '{input.script}+("{output.config}")'
0162 touch {output.done}
0163 """
0164
0165 # Aggregate both analysis outputs
0166 rule dvmp_analysis_complete:
0167 input:
0168 "results/{DETECTOR_CONFIG}/dvmp/{CONFIG}_{DECAY}_{N_EVENTS}/vm_mass_done.txt",
0169 "results/{DETECTOR_CONFIG}/dvmp/{CONFIG}_{DECAY}_{N_EVENTS}/vm_invar_done.txt",
0170 output:
0171 "results/{DETECTOR_CONFIG}/dvmp/{CONFIG}_{DECAY}_{N_EVENTS}/analysis_done.txt",
0172 shell:
0173 """
0174 touch {output}
0175 """
0176
0177 # Top-level rule to run generation for a specific config
0178 rule dvmp_gen_config:
0179 input:
0180 "input/gen-{CONFIG}_muon_{N_EVENTS}.hepmc",
0181 "input/gen-{CONFIG}_electron_{N_EVENTS}.hepmc",
0182 message:
0183 "Generation complete for {wildcards.CONFIG}"
0184
0185 # Top-level rule to run everything for a specific config
0186 rule dvmp_run_config:
0187 input:
0188 "results/{DETECTOR_CONFIG}/dvmp/{CONFIG}_muon_{N_EVENTS}/analysis_done.txt",
0189 "results/{DETECTOR_CONFIG}/dvmp/{CONFIG}_electron_{N_EVENTS}/analysis_done.txt",
0190 message:
0191 "DVMP benchmark complete for {wildcards.CONFIG}. See output in results/{wildcards.DETECTOR_CONFIG}/dvmp/"
0192
0193 # Generation-only target, used by the dvmp:generate CI job (which runs in the
0194 # lager image). CI names the rule; the event count comes from the configuration.
0195 rule dvmp_generate:
0196 input:
0197 expand("input/gen-jpsi_barrel_{decay}_{n_events}.hepmc",
0198 decay=["muon", "electron"],
0199 n_events=[config["BENCHMARK_N_EVENTS"]]),
0200 message:
0201 "Generation complete. See output in input/"
0202
0203
0204 # Default run for local execution (jpsi_barrel with the configured event count)
0205 rule dvmp_run_locally:
0206 input:
0207 expand("results/" + config["DETECTOR_CONFIG"] + "/dvmp/jpsi_barrel_{decay}_{n_events}/analysis_done.txt",
0208 decay=["muon", "electron"],
0209 n_events=[config["BENCHMARK_N_EVENTS"]]),
0210 message:
0211 "DVMP benchmark complete. See output in results/" + config["DETECTOR_CONFIG"] + "/dvmp/"