Back to home page

EIC code displayed by LXR

 
 

    


Warning, /detector_benchmarks/benchmarks/barrel_ecal/Snakefile is written in an unsupported language. File is not indexed.

0001 DETECTOR_PATH = config["DETECTOR_PREFIX"] + "/share/epic"
0002 
0003 
0004 rule emcal_barrel_particles_gen:
0005     input:
0006         workflow.source_path("scripts/emcal_barrel_common_functions.h"),
0007         script=workflow.source_path("scripts/emcal_barrel_particles_gen.cxx"),
0008     params:
0009         JUGGLER_N_EVENTS = 100,
0010         PARTICLE = lambda wildcards: wildcards.PARTICLE,
0011         E_MIN = lambda wildcards: wildcards.E_MIN,
0012         E_MAX = lambda wildcards: wildcards.E_MAX,
0013     output:
0014         "data/emcal_barrel_{PARTICLE}_energies{E_MIN}_{E_MAX}.hepmc",
0015     singularity: EIC_SINGULARITY_CONTAINER,
0016     shell:
0017         """
0018 root -l -b -q '{input.script}+("{output}", {params.JUGGLER_N_EVENTS}, {wildcards.E_MIN}, {wildcards.E_MAX}, "{wildcards.PARTICLE}")'
0019 """
0020 
0021 
0022 rule emcal_barrel_particles:
0023     input:
0024         hepmc="data/emcal_barrel_{PARTICLE}_energies{E_MIN}_{E_MAX}.hepmc",
0025         geometry_lib=find_epic_libraries(),
0026     params:
0027         JUGGLER_N_EVENTS = 100,
0028         DD4HEP_HASH=get_spack_package_hash("dd4hep"),
0029         NPSIM_HASH=get_spack_package_hash("npsim"),
0030         DETECTOR_CONFIG = lambda wildcards: wildcards.DETECTOR_CONFIG,
0031         PARTICLE = lambda wildcards: wildcards.PARTICLE,
0032         E_MIN = lambda wildcards: wildcards.E_MIN,
0033         E_MAX = lambda wildcards: wildcards.E_MAX,
0034         SEED = lambda wildcards: stable_seed("emcal_barrel", wildcards.PARTICLE, wildcards.E_MIN, wildcards.E_MAX),
0035     output:
0036         "{DETECTOR_CONFIG}/sim_output/sim_emcal_barrel_{PARTICLE}_energies{E_MIN}_{E_MAX}.edm4hep.rnt.root"
0037     cache: True
0038     singularity: EIC_SINGULARITY_CONTAINER,
0039     shell:
0040         """
0041 set -m # monitor mode to prevent lingering processes
0042 exec npsim \
0043    --runType batch \
0044    -v WARNING \
0045    --part.minimalKineticEnergy 0.5*GeV  \
0046    --filter.tracker edep0 \
0047    --numberOfEvents {params.JUGGLER_N_EVENTS} \
0048    --random.seed {params.SEED} \
0049    --compactFile """ + DETECTOR_PATH + """/{wildcards.DETECTOR_CONFIG}.xml \
0050    --inputFiles {input.hepmc} \
0051    --outputConfig.useRNTuple true \
0052    --outputFile {output}
0053 """
0054 
0055 
0056 # This is needed to bridge snakemake rule files to "normal" benchmarks
0057 rule emcal_barrel_particles_compat_normal:
0058     input:
0059         "{DETECTOR_CONFIG}/sim_output/sim_emcal_barrel_{PARTICLE}_energies5.0_5.0.edm4hep.rnt.root",
0060     wildcard_constraints:
0061         PARTICLE="[^_]+",
0062     output:
0063         "{DETECTOR_CONFIG}/sim_output/sim_emcal_barrel_{PARTICLE}.edm4hep.rnt.root",
0064     singularity: EIC_SINGULARITY_CONTAINER,
0065     shell:
0066         """
0067 ln {input} {output}
0068 """
0069 
0070 
0071 # This is needed to bridge snakemake rule files to "energy_scan" benchmarks
0072 rule emcal_barrel_particles_compat_energy_scan:
0073     input:
0074         "{DETECTOR_CONFIG}/sim_output/sim_emcal_barrel_{PARTICLE}_energies{E}_{E}.edm4hep.rnt.root",
0075     wildcard_constraints:
0076         PARTICLE="[^_]+",
0077     output:
0078         "{DETECTOR_CONFIG}/sim_output/energy_scan/{E}/sim_emcal_barrel_{PARTICLE}.edm4hep.rnt.root",
0079     singularity: EIC_SINGULARITY_CONTAINER,
0080     shell:
0081         """
0082 ln {input} {output}
0083 """
0084 
0085 
0086 rule emcal_barrel_particles_analysis:
0087     input:
0088         workflow.source_path("scripts/emcal_barrel_common_functions.h"),
0089         script=workflow.source_path("scripts/emcal_barrel_particles_analysis.cxx"),
0090         sim="{DETECTOR_CONFIG}/sim_output/sim_emcal_barrel_{PARTICLE}.edm4hep.rnt.root",
0091     wildcard_constraints:
0092         PARTICLE="(electron|photon|piplus|piminus)", # avoid clash with "pions"
0093     output:
0094         "{DETECTOR_CONFIG}/results/emcal_barrel_{PARTICLE}_calibration.json",
0095         "{DETECTOR_CONFIG}/results/emcal_barrel_{PARTICLE}_Ethr.png",
0096         "{DETECTOR_CONFIG}/results/emcal_barrel_{PARTICLE}_Ethr.pdf",
0097         "{DETECTOR_CONFIG}/results/emcal_barrel_{PARTICLE}_nhits.png",
0098         "{DETECTOR_CONFIG}/results/emcal_barrel_{PARTICLE}_nhits.pdf",
0099         "{DETECTOR_CONFIG}/results/emcal_barrel_{PARTICLE}_Esim.png",
0100         "{DETECTOR_CONFIG}/results/emcal_barrel_{PARTICLE}_Esim.pdf",
0101         "{DETECTOR_CONFIG}/results/emcal_barrel_{PARTICLE}_fsam.png",
0102         "{DETECTOR_CONFIG}/results/emcal_barrel_{PARTICLE}_fsam.pdf",
0103         "{DETECTOR_CONFIG}/results/emcal_barrel_{PARTICLE}_fsamImg.png",
0104         "{DETECTOR_CONFIG}/results/emcal_barrel_{PARTICLE}_fsamImg.pdf",
0105         "{DETECTOR_CONFIG}/results/emcal_barrel_{PARTICLE}_fsamScFi.png",
0106         "{DETECTOR_CONFIG}/results/emcal_barrel_{PARTICLE}_fsamScFi.pdf",
0107     singularity: EIC_SINGULARITY_CONTAINER,
0108     shell:
0109         """
0110 cd {wildcards.DETECTOR_CONFIG}
0111 root -l -b -q '{input.script}+("{wildcards.PARTICLE}", true)'
0112 """
0113 
0114 
0115 rule emcal_barrel_pions_analysis:
0116     input:
0117         script=workflow.source_path("scripts/emcal_barrel_pions_analysis.cxx"),
0118         sim="{DETECTOR_CONFIG}/sim_output/sim_emcal_barrel_piplus_energies5.0_5.0.edm4hep.rnt.root",
0119     output:
0120         expand(
0121             "{{DETECTOR_CONFIG}}/results/emcal_barrel_pions_{var_name}.{extension}",
0122             var_name=["Ethr", "nhits", "Esim", "fsam", "pid"],
0123             extension=["pdf", "png"],
0124         ),
0125     singularity: EIC_SINGULARITY_CONTAINER,
0126     shell:
0127         """
0128 cd {wildcards.DETECTOR_CONFIG}
0129 root -l -b -q '{input.script}+("../{input.sim}")'
0130 """
0131 
0132 
0133 rule emcal_barrel_pi0_analysis:
0134     input:
0135         script=workflow.source_path("scripts/emcal_barrel_pi0_analysis.cxx"),
0136         sim="{DETECTOR_CONFIG}/sim_output/sim_emcal_barrel_pi0_energies5.0_5.0.edm4hep.rnt.root",
0137         fsam="{DETECTOR_CONFIG}/results/emcal_barrel_electron_calibration.json",
0138     output:
0139         expand(
0140             "{{DETECTOR_CONFIG}}/results/emcal_barrel_pi0_{var_name}.{extension}",
0141             var_name=["Ethr", "nhits", "Esim", "dE_rel"],
0142             extension=["pdf", "png"],
0143         ),
0144     singularity: EIC_SINGULARITY_CONTAINER,
0145     shell:
0146         """
0147 cd {wildcards.DETECTOR_CONFIG}
0148 root -l -b -q '{input.script}+("../{input.sim}")'
0149 """
0150 
0151 
0152 ENERGY_SCAN_ENERGIES = [0.5, 1., 2., 5., 10.]
0153 rule emcal_energy_scan:
0154     input:
0155         # Require all simulations produced for this rule
0156         expand("{{DETECTOR_CONFIG}}/sim_output/energy_scan/{energy}/sim_emcal_barrel_{{PARTICLE}}.edm4hep.rnt.root", energy=ENERGY_SCAN_ENERGIES),
0157     output:
0158         "{DETECTOR_CONFIG}/sim_output/emcal_barrel_energy_scan_points_{PARTICLE}.txt",
0159     run:
0160         with open(output[0], "wt") as fp:
0161             for energy in ENERGY_SCAN_ENERGIES:
0162                 fp.write(f"{energy}\n")
0163 
0164 
0165 rule emcal_barrel_particles_energy_scan_analysis:
0166     input:
0167         script=workflow.source_path("scripts/emcal_barrel_energy_scan_analysis.cxx"),
0168         scan_points="{DETECTOR_CONFIG}/sim_output/emcal_barrel_energy_scan_points_{PARTICLE}.txt",
0169     output:
0170         "{DETECTOR_CONFIG}/results/energy_scan/emcal_barrel_{PARTICLE}_fsam_scan.png",
0171         "{DETECTOR_CONFIG}/results/energy_scan/emcal_barrel_{PARTICLE}_fsam_scan_res.png",
0172         expand(
0173             "{{DETECTOR_CONFIG}}/results/energy_scan/{energy}/emcal_barrel_{{PARTICLE}}_{plot}.png",
0174             energy=ENERGY_SCAN_ENERGIES,
0175             plot=["Esim_layer", "Layer_nodep", "Layer_Esim_mean", "Ethr", "nhits", "Esim", "fsam"],
0176         ),
0177     singularity: EIC_SINGULARITY_CONTAINER,
0178     shell:
0179         """
0180 cd {wildcards.DETECTOR_CONFIG}
0181 root -l -b -q '{input.script}+("{wildcards.PARTICLE}")'
0182 """
0183 
0184 
0185 rule emcal_barrel_pion_rejection_analysis:
0186     input:
0187         workflow.source_path("scripts/emcal_barrel_common_functions.h"),
0188         script=workflow.source_path("scripts/emcal_barrel_pion_rejection_analysis.cxx"),
0189         electron="{DETECTOR_CONFIG}/sim_output/sim_emcal_barrel_electron_energies1.0_18.0.edm4hep.rnt.root",
0190         piminus="{DETECTOR_CONFIG}/sim_output/sim_emcal_barrel_piminus_energies1.0_18.0.edm4hep.rnt.root",
0191     output:
0192         "{DETECTOR_CONFIG}/results/emcal_barrel_pion_rej_RatioRej.png",
0193         expand(
0194             "{{DETECTOR_CONFIG}}/results/emcal_barrel_pion_rej_uncut_comb_{var_save}.png",
0195             var_save=["Esim", "EsimTot", "EDep6", "EDep6OverP", "pT", "eta", "EsimScFi", "EsimScFiOverP"],
0196         ),
0197         expand(
0198             "{{DETECTOR_CONFIG}}/results/emcal_barrel_pion_rej_uncut_comb_E{i}Eta{j}.png",
0199             i=range(6),
0200             j=range(2),
0201         ),
0202         expand(
0203             "{{DETECTOR_CONFIG}}/results/emcal_barrel_pion_rej_{tag}_E{energy}_eta{eta_bin}.{extension}",
0204             energy=[5, 10, 18],
0205             eta_bin=range(2, 4),
0206             tag=(
0207                 ["cut_mom_ele", "cut_mom_pim", "cut_ratio_pim"]
0208                 + sum([[f"cut_{var}_ele", f"cut_{var}_pim", f"cut_{var}_comb"] for var in ["pT", "EDep6OverP"]], [])
0209             ),
0210             extension=["pdf", "png"],
0211         ),
0212     singularity: EIC_SINGULARITY_CONTAINER,
0213     shell:
0214         """
0215 cd {wildcards.DETECTOR_CONFIG}
0216 root -l -b -q '{input.script}+g("../{input.electron}", "../{input.piminus}")'
0217 """