Warning, /detector_benchmarks/benchmarks/tracking_performances/Snakefile is written in an unsupported language. File is not indexed.
0001 rule tracking_performance_sim:
0002 input:
0003 steering_file=ancient("EPIC/EVGEN/SINGLE/{PARTICLE}/{ENERGY}/{PHASE_SPACE}/{PARTICLE}_{ENERGY}_{PHASE_SPACE}.steer"),
0004 warmup="warmup/{DETECTOR_CONFIG}.edm4hep.root",
0005 output:
0006 "sim_output/tracking_performance/{DETECTOR_CONFIG}/{PARTICLE}/{ENERGY}/{PHASE_SPACE}/{PARTICLE}_{ENERGY}_{PHASE_SPACE}.{INDEX}.edm4hep.root",
0007 log:
0008 "sim_output/tracking_performance/{DETECTOR_CONFIG}/{PARTICLE}/{ENERGY}/{PHASE_SPACE}/{PARTICLE}_{ENERGY}_{PHASE_SPACE}.{INDEX}.edm4hep.root.log",
0009 wildcard_constraints:
0010 PARTICLE="pi-",
0011 ENERGY="[0-9]+[kMG]eV",
0012 PHASE_SPACE="(3to50|45to135|130to177)deg",
0013 INDEX="\d{4}",
0014 params:
0015 N_EVENTS=10000
0016 shell:
0017 """
0018 set -m # monitor mode to prevent lingering processes
0019 exec ddsim \
0020 --runType batch \
0021 --enableGun \
0022 --steeringFile "{input.steering_file}" \
0023 --random.seed 1{wildcards.INDEX} \
0024 --filter.tracker edep0 \
0025 -v WARNING \
0026 --numberOfEvents {params.N_EVENTS} \
0027 --compactFile $DETECTOR_PATH/{wildcards.DETECTOR_CONFIG}.xml \
0028 --outputFile {output}
0029 """
0030
0031
0032 rule tracking_performance_recon:
0033 input:
0034 "sim_output/tracking_performance/{DETECTOR_CONFIG}/{PARTICLE}/{ENERGY}/{PHASE_SPACE}/{PARTICLE}_{ENERGY}_{PHASE_SPACE}.{INDEX}.edm4hep.root",
0035 output:
0036 "sim_output/tracking_performance/{DETECTOR_CONFIG}/{PARTICLE}/{ENERGY}/{PHASE_SPACE}/{PARTICLE}_{ENERGY}_{PHASE_SPACE}.{INDEX}.eicrecon.tree.edm4eic.root",
0037 log:
0038 "sim_output/tracking_performance/{DETECTOR_CONFIG}/{PARTICLE}/{ENERGY}/{PHASE_SPACE}/{PARTICLE}_{ENERGY}_{PHASE_SPACE}.{INDEX}.eicrecon.tree.edm4eic.root.log",
0039 wildcard_constraints:
0040 INDEX="\d{4}",
0041 shell: """
0042 set -m # monitor mode to prevent lingering processes
0043 exec env DETECTOR_CONFIG={wildcards.DETECTOR_CONFIG} \
0044 eicrecon {input} -Ppodio:output_file={output} \
0045 -Ppodio:output_collections=MCParticles,CentralCKFTrajectories,CentralCKFTrackParameters,CentralCKFSeededTrackParameters,CentralCKFTruthSeededTrackParameters,CentralTrackVertices
0046 """
0047
0048
0049 rule tracking_performance_at_momentum:
0050 input:
0051 script="benchmarks/tracking_performances/Tracking_Performances.C",
0052 # TODO pass as a file list?
0053 sim=lambda wildcards:
0054 expand(
0055 "sim_output/tracking_performance/{DETECTOR_CONFIG}/{{PARTICLE}}/{ENERGY}/{PHASE_SPACE}/{{PARTICLE}}_{ENERGY}_{PHASE_SPACE}.{INDEX:04d}.eicrecon.tree.edm4eic.root",
0056 DETECTOR_CONFIG="epic_craterlake_tracking_only",
0057 ENERGY=f"{float(wildcards.MOMENTUM):.0f}GeV" if float(wildcards.MOMENTUM) >= 1 else f"{float(wildcards.MOMENTUM) * 1000:.0f}MeV",
0058 PHASE_SPACE=["3to50deg", "45to135deg", "130to177deg"],
0059 INDEX=range(1),
0060 )
0061 if wildcards.CAMPAIGN == "local" else
0062 ancient(expand(
0063 "EPIC/RECO/{{CAMPAIGN}}/epic_craterlake/SINGLE/{{PARTICLE}}/{ENERGY}/{PHASE_SPACE}/{{PARTICLE}}_{ENERGY}_{PHASE_SPACE}.{INDEX:04d}.eicrecon.tree.edm4eic.root",
0064 DETECTOR_CONFIG="epic_craterlake",
0065 ENERGY=f"{float(wildcards.MOMENTUM):.0f}GeV" if float(wildcards.MOMENTUM) >= 1 else f"{float(wildcards.MOMENTUM) * 1000:.0f}MeV",
0066 PHASE_SPACE=["3to50deg", "45to135deg", "130to177deg"],
0067 INDEX=range(1),
0068 )),
0069 output:
0070 "{CAMPAIGN}/{SEEDING}/pi-/mom/Performances_mom_{MOMENTUM}_mom_resol_{SEEDING_IGNORE}_{PARTICLE}.root",
0071 "{CAMPAIGN}/{SEEDING}/pi-/dca/Performances_dca_{MOMENTUM}_dca_resol_{SEEDING_IGNORE}_{PARTICLE}.root",
0072 combined_root=temp("{CAMPAIGN}/sim_{SEEDING}_{MOMENTUM}_{SEEDING_IGNORE}_{PARTICLE}.root"),
0073 shell:
0074 """
0075 if [[ "{wildcards.SEEDING}" == "truthseed" ]]; then
0076 TRUTH_SEEDING="true"
0077 elif [[ "{wildcards.SEEDING}" == "realseed" ]]; then
0078 TRUTH_SEEDING="false"
0079 fi
0080 hadd {output.combined_root} {input.sim}
0081 cd {wildcards.CAMPAIGN}
0082 root -l -b -q ../{input.script}'("../{output.combined_root}", "{wildcards.PARTICLE}", {wildcards.MOMENTUM}, 0.15, '$TRUTH_SEEDING')'
0083 """
0084
0085
0086 rule tracking_performance_summary_at_eta:
0087 input:
0088 expand(
0089 [
0090 "{{CAMPAIGN}}/truthseed/pi-/mom/Performances_mom_{MOMENTUM:.1f}_mom_resol_truth_pi-.root",
0091 "{{CAMPAIGN}}/truthseed/pi-/dca/Performances_dca_{MOMENTUM:.1f}_dca_resol_truth_pi-.root",
0092 "{{CAMPAIGN}}/realseed/pi-/mom/Performances_mom_{MOMENTUM:.1f}_mom_resol_realseed_pi-.root",
0093 "{{CAMPAIGN}}/realseed/pi-/dca/Performances_dca_{MOMENTUM:.1f}_dca_resol_realseed_pi-.root",
0094 ],
0095 MOMENTUM=[0.5, 1.0, 2.0, 5.0, 10.0, 20.0],
0096 ),
0097 script="benchmarks/tracking_performances/doCompare_truth_real_widebins_mom.C",
0098 output:
0099 expand(
0100 "{{CAMPAIGN}}/Debug_Plots/{SEEDING}/pi-/mom/{SEEDING}_mom_resol_mom{MOMENTUM:.1f}_{{ETA_MIN}}_eta_{{ETA_MAX}}.png",
0101 SEEDING=["real", "truth"],
0102 MOMENTUM=[0.5, 1.0, 2.0, 5.0, 10.0, 20.0],
0103 ),
0104 "{CAMPAIGN}/Final_Results/pi-/mom/mom_resol_{ETA_MIN}_eta_{ETA_MAX}.png",
0105 "{CAMPAIGN}/Final_Results/pi-/mom/mom_resol_{ETA_MIN}_eta_{ETA_MAX}.root",
0106 shell:
0107 """
0108 if [[ "{wildcards.CAMPAIGN}" == "local" ]]; then
0109 set +e
0110 EPIC_VERSION="${{DETECTOR_VERSION:-}}"
0111 EICRECON_VERSION="$(eicrecon -v | sed -n -e 's/.*\(v[0-9\.]\+\).*/\\1/p')"
0112 # Legacy detection
0113 : ${{EPIC_VERSION:="$(echo $DETECTOR_PATH | sed -n -e 's/.*epic-\([^-/]\+\).*/\\1/p')"}}
0114 set -e
0115
0116 echo "ePIC version: $EPIC_VERSION"
0117 echo "EICrecon version: $EICRECON_VERSION"
0118 EXTRA_LEGEND="ePIC $EPIC_VERSION / EICrecon $EICRECON_VERSION"
0119 else
0120 EXTRA_LEGEND="ePIC Simulation {wildcards.CAMPAIGN}"
0121 fi
0122 cd {wildcards.CAMPAIGN}
0123 root -l -b -q ../{input.script}'("pi-", {wildcards.ETA_MIN}, {wildcards.ETA_MAX}, 1., true, "'"$EXTRA_LEGEND"'")'
0124 """
0125
0126
0127 rule tracking_performance_debug_montage:
0128 input:
0129 expand(
0130 [
0131 "{{CAMPAIGN}}/Debug_Plots/{SEEDING}/pi-/mom/{SEEDING}_mom_resol_mom{MOMENTUM:.1f}_{{ETA_BIN}}.png",
0132 ],
0133 MOMENTUM=[0.5, 1.0, 2.0, 5.0, 10.0, 20.0],
0134 SEEDING=["truth", "real"],
0135 ),
0136 output:
0137 "{CAMPAIGN}/Debug_Plots/pi-/mom/mom_resol_debug_{ETA_BIN}.png",
0138 shell:
0139 """
0140 montage -mode concatenate {input} {output} || true
0141 ls {output}
0142 """
0143
0144
0145 TRACKING_PERFORMANCE_ETA_BINS = [-3.5, -2.5, -1.0, 1.0, 2.5, 3.5]
0146
0147 rule tracking_performance:
0148 input:
0149 expand(
0150 [
0151 "{{CAMPAIGN}}/Final_Results/pi-/mom/mom_resol_{ETA_BIN}.png",
0152 "{{CAMPAIGN}}/Final_Results/pi-/mom/mom_resol_{ETA_BIN}.root",
0153 "{{CAMPAIGN}}/Debug_Plots/pi-/mom/mom_resol_debug_{ETA_BIN}.png",
0154 ],
0155 ETA_BIN=[f"{eta_min:.1f}_eta_{eta_max:.1f}" for eta_min, eta_max in zip(TRACKING_PERFORMANCE_ETA_BINS[:-1], TRACKING_PERFORMANCE_ETA_BINS[1:])],
0156 ),
0157 output:
0158 directory("results/tracking_performances/{CAMPAIGN}/")
0159 shell:
0160 """
0161 mkdir {output}
0162 cp {input} {output}
0163 """
0164
0165
0166 rule tracking_performance_local:
0167 input:
0168 "results/tracking_performances/local",
0169
0170
0171 rule tracking_performance_campaigns:
0172 input:
0173 expand(
0174 "results/tracking_performances/{CAMPAIGN}",
0175 CAMPAIGN=[
0176 "23.10.0",
0177 "23.11.0",
0178 "23.12.0",
0179 "24.03.1",
0180 "24.04.0",
0181 ],
0182 )