Warning, /detector_benchmarks/benchmarks/lfhcal/Snakefile is written in an unsupported language. File is not indexed.
0001 def get_n_events(wildcards):
0002 energy = float(wildcards.ENERGY.replace("GeV", "").replace("MeV", "e-3"))
0003 n_events = 1000
0004 n_events = int(n_events // (energy ** 0.5))
0005 return n_events
0006
0007
0008 rule lfhcal_sim:
0009 input:
0010 steering_file="EPIC/EVGEN/SINGLE/{PARTICLE}/{ENERGY}/{PHASE_SPACE}/{PARTICLE}_{ENERGY}_{PHASE_SPACE}.steer",
0011 warmup="warmup.edm4hep.root",
0012 geometry_lib=find_epic_libraries(),
0013 output:
0014 "sim_output/lfhcal/{DETECTOR_CONFIG}/{PARTICLE}/{ENERGY}/{PHASE_SPACE}/{PARTICLE}_{ENERGY}_{PHASE_SPACE}.{INDEX}.edm4hep.root",
0015 log:
0016 "sim_output/lfhcal/{DETECTOR_CONFIG}/{PARTICLE}/{ENERGY}/{PHASE_SPACE}/{PARTICLE}_{ENERGY}_{PHASE_SPACE}.{INDEX}.edm4hep.root.log",
0017 wildcard_constraints:
0018 ENERGY="[0-9]+[kMG]eV",
0019 PARTICLE="(neutron|pi-|gamma)",
0020 PHASE_SPACE="3to50deg",
0021 INDEX=r"\d{4}",
0022 params:
0023 N_EVENTS=get_n_events,
0024 DD4HEP_HASH=get_spack_package_hash("dd4hep"),
0025 NPSIM_HASH=get_spack_package_hash("npsim"),
0026 cache: True
0027 singularity: EIC_SINGULARITY_CONTAINER,
0028 shell:
0029 """
0030 npsim \
0031 --runType batch \
0032 --enableGun \
0033 --steeringFile "{input.steering_file}" \
0034 --random.seed 1{wildcards.INDEX} \
0035 --filter.tracker edep0 \
0036 -v INFO \
0037 --numberOfEvents {params.N_EVENTS} \
0038 --compactFile $DETECTOR_PATH/{wildcards.DETECTOR_CONFIG}.xml \
0039 --outputFile {output}
0040 """
0041
0042
0043 rule lfhcal_recon:
0044 input:
0045 sim="sim_output/lfhcal/{DETECTOR_CONFIG}/{PARTICLE}/{ENERGY}/{PHASE_SPACE}/{PARTICLE}_{ENERGY}_{PHASE_SPACE}.{INDEX}.edm4hep.root",
0046 warmup="warmup.edm4hep.root",
0047 output:
0048 "sim_output/lfhcal/{DETECTOR_CONFIG}/{PARTICLE}/{ENERGY}/{PHASE_SPACE}/{PARTICLE}_{ENERGY}_{PHASE_SPACE}.{INDEX}.eicrecon.edm4eic.root",
0049 log:
0050 "sim_output/lfhcal/{DETECTOR_CONFIG}/{PARTICLE}/{ENERGY}/{PHASE_SPACE}/{PARTICLE}_{ENERGY}_{PHASE_SPACE}.{INDEX}.eicrecon.edm4eic.root.log",
0051 wildcard_constraints:
0052 INDEX=r"\d{4}",
0053 params:
0054 EICRECON_HASH=get_spack_package_hash("eicrecon"),
0055 cache: True
0056 singularity: EIC_SINGULARITY_CONTAINER,
0057 shell: """
0058 env DETECTOR_CONFIG={wildcards.DETECTOR_CONFIG} \
0059 eicrecon {input.sim} -Ppodio:output_file={output} \
0060 -Ppodio:output_collections=MCParticles,ReconstructedParticles,LFHCALTruthClusters,LFHCALClusters,LFHCALHits,EcalEndcapPTruthClusters,EcalEndcapPClusters,EcalEndcapPHits
0061 """
0062
0063 rule lfhcal_at_momentum:
0064 input:
0065 script=workflow.source_path("LFHCAL_Performance.C"),
0066 # TODO pass as a file list?
0067 sim=lambda wildcards:
0068 expand(
0069 "sim_output/lfhcal/{DETECTOR_CONFIG}/{{PARTICLE}}/{ENERGY}/{PHASE_SPACE}/{{PARTICLE}}_{ENERGY}_{PHASE_SPACE}.{INDEX:04d}.eicrecon.edm4eic.root",
0070 DETECTOR_CONFIG="epic_craterlake",
0071 ENERGY=f"{float(wildcards.MOMENTUM):.0f}GeV" if float(wildcards.MOMENTUM) >= 1 else f"{float(wildcards.MOMENTUM) * 1000:.0f}MeV",
0072 PHASE_SPACE=["3to50deg"],
0073 INDEX=range(1),
0074 )
0075 if wildcards.CAMPAIGN == "local" else
0076 ancient(expand(
0077 "EPIC/RECO/{{CAMPAIGN}}/epic_craterlake/SINGLE/{{PARTICLE}}/{ENERGY}/{PHASE_SPACE}/{{PARTICLE}}_{ENERGY}_{PHASE_SPACE}.{INDEX:04d}.eicrecon{TREE_SUFFIX}.edm4eic.root",
0078 DETECTOR_CONFIG="epic_craterlake",
0079 ENERGY=f"{float(wildcards.MOMENTUM):.0f}GeV" if float(wildcards.MOMENTUM) >= 1 else f"{float(wildcards.MOMENTUM) * 1000:.0f}MeV",
0080 PHASE_SPACE=["3to50deg"],
0081 INDEX=range(1),
0082 TREE_SUFFIX=".tree" if int(wildcards.CAMPAIGN[:2]) < 25 else "", # backwards compatibility
0083 )),
0084 output:
0085 "{CAMPAIGN}/{PARTICLE}/mom/lfhcal_mom_{MOMENTUM}_mom_resol_{PARTICLE}.root",
0086 combined_root=temp("{CAMPAIGN}/lfhcal_sim_{MOMENTUM}_{PARTICLE}.root"),
0087 singularity: EIC_SINGULARITY_CONTAINER,
0088 shell:
0089 """
0090 hadd {output.combined_root} {input.sim}
0091 root -l -b -q {input.script}'("{output.combined_root}", "{wildcards.PARTICLE}", {wildcards.MOMENTUM}, 0.15, "", "{wildcards.CAMPAIGN}")'
0092 """
0093
0094 rule lfhcal_summary_at_eta:
0095 input:
0096 expand(
0097 [
0098 "{{CAMPAIGN}}/{{PARTICLE}}/mom/lfhcal_mom_{MOMENTUM:.1f}_mom_resol_{{PARTICLE}}.root",
0099 ],
0100 MOMENTUM=[0.5, 1.0, 2.0, 5.0, 10.0, 20.0],
0101 ),
0102 script=workflow.source_path("doCompare_widebins_mom.C"),
0103 output:
0104 "{CAMPAIGN}/Final_Results/{PARTICLE}/mom/lfhcal_mom_resol_{PARTICLE}_{ETA_MIN}_eta_{ETA_MAX}.png",
0105 "{CAMPAIGN}/Final_Results/{PARTICLE}/mom/lfhcal_mom_resol_{PARTICLE}_{ETA_MIN}_eta_{ETA_MAX}.root",
0106 singularity: EIC_SINGULARITY_CONTAINER,
0107 shell:
0108 r"""
0109 if [[ "{wildcards.CAMPAIGN}" == "local" ]]; then
0110 set +e
0111 EPIC_VERSION="${{DETECTOR_VERSION:-}}"
0112 EICRECON_VERSION="$(eicrecon -v | sed -n -e 's/.*\(v[0-9\.]\+\).*/\\1/p')"
0113 # Legacy detection
0114 : ${{EPIC_VERSION:="$(echo $DETECTOR_PATH | sed -n -e 's/.*epic-\([^-/]\+\).*/\\1/p')"}}
0115 set -e
0116
0117 echo "ePIC version: $EPIC_VERSION"
0118 echo "EICrecon version: $EICRECON_VERSION"
0119 EXTRA_LEGEND="ePIC $EPIC_VERSION / EICrecon $EICRECON_VERSION"
0120 else
0121 EXTRA_LEGEND="ePIC Simulation {wildcards.CAMPAIGN}"
0122 fi
0123 root -l -b -q {input.script}'("{wildcards.PARTICLE}", {wildcards.ETA_MIN}, {wildcards.ETA_MAX}, 1., true, "'"$EXTRA_LEGEND"'", "{wildcards.CAMPAIGN}")'
0124 """
0125
0126 LFHCAL_ETA_BINS = [1.2,1.5,2,2.5,3,3.5]
0127
0128 rule lfhcal:
0129 input:
0130 lambda wildcards: expand(
0131 [
0132 "{{CAMPAIGN}}/Final_Results/{PARTICLE}/mom/lfhcal_mom_resol_{PARTICLE}_{ETA_BIN}.png",
0133 "{{CAMPAIGN}}/Final_Results/{PARTICLE}/mom/lfhcal_mom_resol_{PARTICLE}_{ETA_BIN}.root",
0134 ],
0135 ETA_BIN=[f"{eta_min:.1f}_eta_{eta_max:.1f}" for eta_min, eta_max in zip(LFHCAL_ETA_BINS[:-1], LFHCAL_ETA_BINS[1:])],
0136 PARTICLE=["neutron", "pi-", "gamma"] if wildcards.CAMPAIGN == "local" else ["pi-"],
0137 )
0138 output:
0139 directory("results/lfhcal/{CAMPAIGN}/")
0140 singularity: EIC_SINGULARITY_CONTAINER,
0141 shell:
0142 """
0143 mkdir {output}
0144 cp {input} {output}
0145 """
0146
0147
0148 rule lfhcal_local:
0149 input:
0150 "results/lfhcal/local",
0151
0152
0153 rule lfhcal_campaigns:
0154 input:
0155 expand(
0156 "results/lfhcal/{CAMPAIGN}",
0157 CAMPAIGN=[
0158 "24.10.1",
0159 "25.10.4",
0160 ],
0161 )