Warning, /detector_benchmarks/benchmarks/tracking_performances_dis/Snakefile is written in an unsupported language. File is not indexed.
0001 import os
0002
0003 rule trk_dis_compile:
0004 input:
0005 "benchmarks/tracking_performances_dis/analysis/trk_dis_analysis_cxx.so",
0006 "benchmarks/tracking_performances_dis/analysis/trk_dis_plots_cxx.so",
0007 "benchmarks/tracking_performances_dis/analysis/vtx_dis_analysis_cxx.so",
0008 "benchmarks/tracking_performances_dis/analysis/vtx_dis_plots_cxx.so",
0009
0010 # Process the generated HepMC files through the simulation
0011 rule trk_dis_sim:
0012 input:
0013 warmup="warmup.edm4hep.root",
0014 geometry_lib=find_epic_libraries(),
0015 output:
0016 "sim_output/tracking_performances_dis/{DETECTOR_CONFIG}/pythia8NCDIS_{EBEAM}x{PBEAM}_minQ2={MINQ2}_beamEffects_xAngle=-0.025_hiDiv_{INDEX}.edm4hep.root",
0017 params:
0018 N_EVENTS=200,
0019 EBEAM=lambda wildcards: wildcards.EBEAM,
0020 INDEX=lambda wildcards: wildcards.INDEX,
0021 PBEAM=lambda wildcards: wildcards.PBEAM,
0022 MINQ2=lambda wildcards: wildcards.MINQ2,
0023 SEED=lambda wildcards: "1" + wildcards.INDEX,
0024 DETECTOR_PATH=os.environ["DETECTOR_PATH"],
0025 DETECTOR_CONFIG=lambda wildcards: wildcards.DETECTOR_CONFIG,
0026 DD4HEP_HASH=get_spack_package_hash("dd4hep"),
0027 NPSIM_HASH=get_spack_package_hash("npsim"),
0028 cache: True
0029 singularity: EIC_SINGULARITY_CONTAINER,
0030 shell:
0031 """
0032 npsim \
0033 --runType batch \
0034 --part.minimalKineticEnergy 1000*GeV \
0035 --random.seed {params.SEED} \
0036 --filter.tracker edep0 \
0037 -v WARNING \
0038 --numberOfEvents {params.N_EVENTS} \
0039 --compactFile {params.DETECTOR_PATH}/{params.DETECTOR_CONFIG}.xml \
0040 --inputFiles root://dtn-eic.jlab.org//volatile/eic/EPIC/EVGEN/DIS/NC/{params.EBEAM}x{params.PBEAM}/minQ2={params.MINQ2}/pythia8NCDIS_{params.EBEAM}x{params.PBEAM}_minQ2={params.MINQ2}_beamEffects_xAngle=-0.025_hiDiv_vtxfix_{params.INDEX}.hepmc3.tree.root \
0041 --outputFile {output}
0042 """
0043
0044 # Process the files produced in the previous step through EICRecon
0045 rule trk_dis_reco:
0046 input:
0047 sim="sim_output/tracking_performances_dis/{DETECTOR_CONFIG}/pythia8NCDIS_{EBEAM}x{PBEAM}_minQ2={MINQ2}_beamEffects_xAngle=-0.025_hiDiv_{INDEX}.edm4hep.root",
0048 warmup="warmup.edm4hep.root",
0049 output:
0050 "sim_output/tracking_performances_dis/{DETECTOR_CONFIG}/pythia8NCDIS_{EBEAM}x{PBEAM}_minQ2={MINQ2}_beamEffects_xAngle=-0.025_hiDiv_{INDEX}.edm4eic.root",
0051 params:
0052 DETECTOR_CONFIG=lambda wildcards: wildcards.DETECTOR_CONFIG,
0053 EBEAM=lambda wildcards: wildcards.EBEAM,
0054 PBEAM=lambda wildcards: wildcards.PBEAM,
0055 MINQ2=lambda wildcards: wildcards.MINQ2,
0056 INDEX=lambda wildcards: wildcards.INDEX,
0057 EICRECON_HASH=get_spack_package_hash("eicrecon"),
0058 cache: True
0059 singularity: EIC_SINGULARITY_CONTAINER,
0060 shell:
0061 """
0062 set -m # monitor mode to prevent lingering processes
0063 exec env DETECTOR_CONFIG={wildcards.DETECTOR_CONFIG} \
0064 eicrecon {input.sim} -Ppodio:output_file={output} \
0065 -Ppodio:output_collections=MCParticles,ReconstructedChargedParticles,ReconstructedTruthSeededChargedParticles,CentralCKFTrackAssociations,CentralCKFTruthSeededTrackAssociations,CentralTrackVertices,SecondaryVerticesHelix
0066 """
0067
0068 # Process the files -- either from the campaign or local running -- through the analysis script
0069 rule dis_analysis:
0070 input:
0071 script_trk=workflow.source_path("analysis/trk_dis_analysis.cxx"),
0072 script_trk_compiled="benchmarks/tracking_performances_dis/analysis/trk_dis_analysis_cxx.so",
0073 script_vtx=workflow.source_path("analysis/vtx_dis_analysis.cxx"),
0074 script_vtx_compiled="benchmarks/tracking_performances_dis/analysis/vtx_dis_analysis_cxx.so",
0075 data="sim_output/tracking_performances_dis/{DETECTOR_CONFIG}/{PREFIX}pythia8NCDIS_{EBEAM}x{PBEAM}_minQ2={MINQ2}_beamEffects_xAngle=-0.025_hiDiv_{INDEX}.edm4eic.root",
0076 output:
0077 config_trk="results/tracking_performances_dis/{DETECTOR_CONFIG}/{PREFIX}pythia8NCDIS_{EBEAM}x{PBEAM}_minQ2={MINQ2}_{INDEX}/config.json",
0078 hists_trk="results/tracking_performances_dis/{DETECTOR_CONFIG}/{PREFIX}pythia8NCDIS_{EBEAM}x{PBEAM}_minQ2={MINQ2}_{INDEX}/hists.root",
0079 config_vtx="results/vertexing_performances_dis/{DETECTOR_CONFIG}/{PREFIX}pythia8NCDIS_{EBEAM}x{PBEAM}_minQ2={MINQ2}_{INDEX}/config.json",
0080 hists_vtx="results/vertexing_performances_dis/{DETECTOR_CONFIG}/{PREFIX}pythia8NCDIS_{EBEAM}x{PBEAM}_minQ2={MINQ2}_{INDEX}/hists.root",
0081 wildcard_constraints:
0082 PREFIX= ".*",
0083 EBEAM=r"\d+",
0084 PBEAM=r"\d+",
0085 MINQ2=r"\d+",
0086 INDEX=r"\d+",
0087 singularity: EIC_SINGULARITY_CONTAINER,
0088 shell:
0089 """
0090 cat > {output.config_trk} <<EOF
0091 {{
0092 "rec_file": "{input.data}",
0093 "detector": "{wildcards.DETECTOR_CONFIG}",
0094 "ebeam": {wildcards.EBEAM},
0095 "pbeam": {wildcards.PBEAM},
0096 "Min_Q2": {wildcards.MINQ2},
0097 "output_prefix": "$(dirname "{output.hists_trk}")/hists"
0098 }}
0099 EOF
0100 root -l -b -q '{input.script_trk}+("{output.config_trk}")'
0101
0102 cat > {output.config_vtx} <<EOF
0103 {{
0104 "rec_file": "{input.data}",
0105 "detector": "{wildcards.DETECTOR_CONFIG}",
0106 "ebeam": {wildcards.EBEAM},
0107 "pbeam": {wildcards.PBEAM},
0108 "Min_Q2": {wildcards.MINQ2},
0109 "output_prefix": "$(dirname "{output.hists_vtx}")/hists"
0110 }}
0111 EOF
0112 root -l -b -q '{input.script_vtx}+("{output.config_vtx}")'
0113 """
0114
0115 #Merge all the files produced in the previous step
0116 rule dis_combine:
0117 input:
0118 lambda wildcards: [f"results/tracking_performances_dis/{wildcards.DETECTOR_CONFIG}/{wildcards.PREFIX}pythia8NCDIS_{wildcards.EBEAM}x{wildcards.PBEAM}_minQ2={wildcards.MINQ2}_{ix}/hists.root" for ix in range(1,int(wildcards.NUM_FILES)+1)],
0119 lambda wildcards: [f"results/vertexing_performances_dis/{wildcards.DETECTOR_CONFIG}/{wildcards.PREFIX}pythia8NCDIS_{wildcards.EBEAM}x{wildcards.PBEAM}_minQ2={wildcards.MINQ2}_{ix}/hists.root" for ix in range(1,int(wildcards.NUM_FILES)+1)],
0120 output:
0121 config_trk="results/tracking_performances_dis/{DETECTOR_CONFIG}/{PREFIX}pythia8NCDIS_{EBEAM}x{PBEAM}_minQ2={MINQ2}_combined_{NUM_FILES}/config.json",
0122 hists_trk="results/tracking_performances_dis/{DETECTOR_CONFIG}/{PREFIX}pythia8NCDIS_{EBEAM}x{PBEAM}_minQ2={MINQ2}_combined_{NUM_FILES}/hists.root",
0123 config_vtx="results/vertexing_performances_dis/{DETECTOR_CONFIG}/{PREFIX}pythia8NCDIS_{EBEAM}x{PBEAM}_minQ2={MINQ2}_combined_{NUM_FILES}/config.json",
0124 hists_vtx="results/vertexing_performances_dis/{DETECTOR_CONFIG}/{PREFIX}pythia8NCDIS_{EBEAM}x{PBEAM}_minQ2={MINQ2}_combined_{NUM_FILES}/hists.root",
0125 wildcard_constraints:
0126 PREFIX= ".*",
0127 EBEAM=r"\d+",
0128 PBEAM=r"\d+",
0129 MINQ2=r"\d+",
0130 NUM_FILES=r"\d+",
0131 singularity: EIC_SINGULARITY_CONTAINER,
0132 shell:
0133 """
0134 cat > {output.config_trk} <<EOF
0135 {{
0136 "hists_file": "{output.hists_trk}",
0137 "detector": "{wildcards.DETECTOR_CONFIG}",
0138 "ebeam": {wildcards.EBEAM},
0139 "pbeam": {wildcards.PBEAM},
0140 "Min_Q2": {wildcards.MINQ2},
0141 "nfiles": {wildcards.NUM_FILES},
0142 "output_prefix": "$(dirname "{output.hists_trk}")/plots"
0143 }}
0144 EOF
0145 hadd {output.hists_trk} {input}
0146
0147 cat > {output.config_vtx} <<EOF
0148 {{
0149 "hists_file": "{output.hists_vtx}",
0150 "detector": "{wildcards.DETECTOR_CONFIG}",
0151 "ebeam": {wildcards.EBEAM},
0152 "pbeam": {wildcards.PBEAM},
0153 "Min_Q2": {wildcards.MINQ2},
0154 "nfiles": {wildcards.NUM_FILES},
0155 "output_prefix": "$(dirname "{output.hists_vtx}")/plots"
0156 }}
0157 EOF
0158 hadd {output.hists_vtx} {input}
0159 """
0160
0161 #Process the merged file through the plotting script
0162 rule trk_dis_plots:
0163 input:
0164 script=workflow.source_path("analysis/trk_dis_plots.cxx"),
0165 script_compiled="benchmarks/tracking_performances_dis/analysis/trk_dis_plots_cxx.so",
0166 config="results/tracking_performances_dis/{DETECTOR_CONFIG}/{PREFIX}pythia8NCDIS_{EBEAM}x{PBEAM}_minQ2={MINQ2}_combined_{NUM_FILES}/config.json",
0167 output:
0168 "results/tracking_performances_dis/{DETECTOR_CONFIG}/{PREFIX}pythia8NCDIS_{EBEAM}x{PBEAM}_minQ2={MINQ2}_combined_{NUM_FILES}/plots.pdf"
0169 wildcard_constraints:
0170 PREFIX= ".*",
0171 EBEAM=r"\d+",
0172 PBEAM=r"\d+",
0173 MINQ2=r"\d+",
0174 NUM_FILES=r"\d+",
0175 singularity: EIC_SINGULARITY_CONTAINER,
0176 shell:
0177 """
0178 root -l -b -q '{input.script}+("{input.config}")'
0179 """
0180
0181 rule vtx_dis_plots:
0182 input:
0183 script=workflow.source_path("analysis/vtx_dis_plots.cxx"),
0184 script_compiled="benchmarks/tracking_performances_dis/analysis/vtx_dis_plots_cxx.so",
0185 config="results/vertexing_performances_dis/{DETECTOR_CONFIG}/{PREFIX}pythia8NCDIS_{EBEAM}x{PBEAM}_minQ2={MINQ2}_combined_{NUM_FILES}/config.json",
0186 output:
0187 "results/vertexing_performances_dis/{DETECTOR_CONFIG}/{PREFIX}pythia8NCDIS_{EBEAM}x{PBEAM}_minQ2={MINQ2}_combined_{NUM_FILES}/plots.pdf"
0188 wildcard_constraints:
0189 PREFIX= ".*",
0190 EBEAM=r"\d+",
0191 PBEAM=r"\d+",
0192 MINQ2=r"\d+",
0193 NUM_FILES=r"\d+",
0194 singularity: EIC_SINGULARITY_CONTAINER,
0195 shell:
0196 """
0197 root -l -b -q '{input.script}+("{input.config}")'
0198 """
0199
0200 #Examples of invocation
0201 rule trk_dis_run_locally:
0202 input:
0203 "results/tracking_performances_dis/" + os.environ["DETECTOR_CONFIG"] + "/pythia8NCDIS_18x275_minQ2=1_combined_5/plots.pdf",
0204 message:
0205 "See output in {input[0]}"
0206
0207 rule vtx_dis_run_locally:
0208 input:
0209 "results/vertexing_performances_dis/" + os.environ["DETECTOR_CONFIG"] + "/pythia8NCDIS_18x275_minQ2=1_combined_5/plots.pdf",
0210 message:
0211 "See output in {input[0]}"
0212
0213
0214 rule trk_dis_run_locally_trk_only:
0215 input:
0216 "results/tracking_performances_dis/epic_craterlake_tracking_only/pythia8NCDIS_18x275_minQ2=1_combined_5/plots.pdf",
0217 message:
0218 "See output in {input[0]}"
0219
0220
0221 rule vtx_dis_run_locally_trk_only:
0222 input:
0223 "results/vertexing_performances_dis/epic_craterlake_tracking_only/pythia8NCDIS_18x275_minQ2=1_combined_5/plots.pdf",
0224 message:
0225 "See output in {input[0]}"