Back to home page

EIC code displayed by LXR

 
 

    


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="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=r"\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=r"\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_hadd_final_hist_dca:
0087     input:
0088         lambda wildcards: expand(
0089             [
0090                 "{{CAMPAIGN}}/{{SEEDING}}/pi-/dca/Performances_dca_{MOMENTUM:.1f}_dca_resol_{SEEDING_ALT}_pi-.root",
0091             ],
0092             MOMENTUM=[0.5, 1.0, 2.0, 5.0, 10.0, 20.0],
0093             SEEDING_ALT={"truthseed": "truth", "realseed": "realseed"}[wildcards.SEEDING],
0094         ),
0095     output:
0096         "{CAMPAIGN}/{SEEDING}/pi-/dca/final_hist_dca_{SEEDING}.root",
0097     shell:
0098         """
0099 hadd -f {output} {input}
0100 """
0101 
0102 
0103 rule tracking_performance_summary_at_eta:
0104     input:
0105         expand(
0106             [
0107                 "{{CAMPAIGN}}/truthseed/pi-/mom/Performances_mom_{MOMENTUM:.1f}_mom_resol_truth_pi-.root",
0108                 "{{CAMPAIGN}}/truthseed/pi-/dca/Performances_dca_{MOMENTUM:.1f}_dca_resol_truth_pi-.root",
0109                 "{{CAMPAIGN}}/realseed/pi-/mom/Performances_mom_{MOMENTUM:.1f}_mom_resol_realseed_pi-.root",
0110                 "{{CAMPAIGN}}/realseed/pi-/dca/Performances_dca_{MOMENTUM:.1f}_dca_resol_realseed_pi-.root",
0111             ],
0112             MOMENTUM=[0.5, 1.0, 2.0, 5.0, 10.0, 20.0],
0113         ),
0114         "{CAMPAIGN}/truthseed/pi-/dca/final_hist_dca_truthseed.root",
0115         "{CAMPAIGN}/realseed/pi-/dca/final_hist_dca_realseed.root",
0116         script_mom="benchmarks/tracking_performances/doCompare_truth_real_widebins_mom.C",
0117         script_dcaT="benchmarks/tracking_performances/doCompare_truth_real_widebins_dcaT.C",
0118         script_dcaz="benchmarks/tracking_performances/doCompare_truth_real_widebins_dcaz.C",
0119     output:
0120         expand(
0121             "{{CAMPAIGN}}/Debug_Plots/{SEEDING}/pi-/mom/{SEEDING}_mom_resol_mom{MOMENTUM:.1f}_{{ETA_MIN}}_eta_{{ETA_MAX}}.png",
0122             SEEDING=["real", "truth"],
0123             MOMENTUM=[0.5, 1.0, 2.0, 5.0, 10.0, 20.0],
0124         ),
0125         expand(
0126             "{{CAMPAIGN}}/Debug_Plots/{SEEDING}/pi-/dca/{SEEDING}_dcaxy_resol_mom{MOMENTUM:.1f}_{{ETA_MIN}}_eta_{{ETA_MAX}}.png",
0127             SEEDING=["real", "truth"],
0128             MOMENTUM=[0.2, 0.3, 0.5,1.0, 1.5, 2.0, 5.0, 8.0, 10., 15.0],
0129         ),
0130         expand(
0131             "{{CAMPAIGN}}/Debug_Plots/{SEEDING}/pi-/dca/{SEEDING}_dcaz_resol_mom{MOMENTUM:.1f}_{{ETA_MIN}}_eta_{{ETA_MAX}}.png",
0132             SEEDING=["real", "truth"],
0133             MOMENTUM=[0.2, 0.3, 0.5,1.0, 1.5, 2.0, 5.0, 8.0, 10., 15.0],
0134         ),
0135         "{CAMPAIGN}/Final_Results/pi-/mom/mom_resol_{ETA_MIN}_eta_{ETA_MAX}.png",
0136         "{CAMPAIGN}/Final_Results/pi-/mom/mom_resol_{ETA_MIN}_eta_{ETA_MAX}.root",
0137         "{CAMPAIGN}/Final_Results/pi-/dca/dcaxy_resol_{ETA_MIN}_eta_{ETA_MAX}.png", 
0138         "{CAMPAIGN}/Final_Results/pi-/dca/dcaxy_resol_{ETA_MIN}_eta_{ETA_MAX}.root", 
0139         "{CAMPAIGN}/Final_Results/pi-/dca/dcaz_resol_{ETA_MIN}_eta_{ETA_MAX}.png", 
0140         "{CAMPAIGN}/Final_Results/pi-/dca/dcaz_resol_{ETA_MIN}_eta_{ETA_MAX}.root",    
0141     shell:
0142         r"""
0143 if [[ "{wildcards.CAMPAIGN}" == "local" ]]; then
0144         set +e
0145         EPIC_VERSION="${{DETECTOR_VERSION:-}}"
0146         EICRECON_VERSION="$(eicrecon -v | sed -n -e 's/.*\(v[0-9\.]\+\).*/\\1/p')"
0147         # Legacy detection
0148         : ${{EPIC_VERSION:="$(echo $DETECTOR_PATH | sed -n -e 's/.*epic-\([^-/]\+\).*/\\1/p')"}}
0149         set -e
0150 
0151         echo "ePIC version: $EPIC_VERSION"
0152         echo "EICrecon version: $EICRECON_VERSION"
0153         EXTRA_LEGEND="ePIC $EPIC_VERSION / EICrecon $EICRECON_VERSION"
0154 else
0155         EXTRA_LEGEND="ePIC Simulation {wildcards.CAMPAIGN}"
0156 fi
0157 cd {wildcards.CAMPAIGN}
0158 root -l -b -q ../{input.script_mom}'("pi-", {wildcards.ETA_MIN}, {wildcards.ETA_MAX}, 1., true, "'"$EXTRA_LEGEND"'")'
0159 root -l -b -q ../{input.script_dcaT}'("pi-", {wildcards.ETA_MIN}, {wildcards.ETA_MAX}, true, "'"$EXTRA_LEGEND"'")'
0160 root -l -b -q ../{input.script_dcaz}'("pi-", {wildcards.ETA_MIN}, {wildcards.ETA_MAX}, true, "'"$EXTRA_LEGEND"'")'
0161 """
0162 
0163 
0164 rule tracking_performance_debug_montage:
0165     input:
0166         expand(
0167             [
0168                 "{{CAMPAIGN}}/Debug_Plots/{SEEDING}/pi-/mom/{SEEDING}_mom_resol_mom{MOMENTUM:.1f}_{{ETA_BIN}}.png",
0169             ],
0170             MOMENTUM=[0.5, 1.0, 2.0, 5.0, 10.0, 20.0],
0171             SEEDING=["truth", "real"],
0172         ),
0173     output:
0174         "{CAMPAIGN}/Debug_Plots/pi-/mom/mom_resol_debug_{ETA_BIN}.png",
0175     shell:
0176         """
0177 montage -mode concatenate {input} {output} || true
0178 ls {output}
0179 """
0180 
0181 
0182 TRACKING_PERFORMANCE_ETA_BINS = [-3.5, -2.5, -1.0, 1.0, 2.5, 3.5]
0183 
0184 rule tracking_performance:
0185     input:
0186         expand(
0187             [
0188                 "{{CAMPAIGN}}/Final_Results/pi-/mom/mom_resol_{ETA_BIN}.png",
0189                 "{{CAMPAIGN}}/Final_Results/pi-/mom/mom_resol_{ETA_BIN}.root",
0190                 "{{CAMPAIGN}}/Debug_Plots/pi-/mom/mom_resol_debug_{ETA_BIN}.png",
0191             ],
0192             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:])],
0193         ),
0194     output:
0195         directory("results/tracking_performances/{CAMPAIGN}/")
0196     shell:
0197         """
0198 mkdir {output}
0199 cp {input} {output}
0200 """
0201 
0202 
0203 rule tracking_performance_local:
0204     input:
0205         "results/tracking_performances/local",
0206 
0207 
0208 rule tracking_performance_campaigns:
0209     input:
0210         expand(
0211             "results/tracking_performances/{CAMPAIGN}",
0212             CAMPAIGN=[
0213                 "24.10.1",
0214             ],
0215         )