Back to home page

EIC code displayed by LXR

 
 

    


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

0001 def get_n_events(wildcards):
0002     energy = float(wildcards.P)
0003     n_events = 1000
0004     n_events = int(n_events // ((energy / 20) ** 0.5))
0005     return n_events
0006 
0007 
0008 rule femc_electron_generate:
0009     input:
0010         script=workflow.source_path("analysis/gen_particles.cxx"),
0011     output:
0012         GEN_FILE="sim_output/femc_electron/e-_{P}GeV.hepmc",
0013     params:
0014         N_EVENTS=get_n_events,
0015         th_max=28,
0016         th_min=2.0,
0017         P=lambda wildcards: wildcards.P,
0018     singularity: EIC_SINGULARITY_CONTAINER,
0019     shell:
0020         """
0021 mkdir -p sim_output/femc_electron
0022 root -l -b -q '{input.script}({params.N_EVENTS},"{output.GEN_FILE}", "e-", {params.th_min}, {params.th_max}, 0., 360., {params.P})'
0023 """
0024 
0025 rule femc_electron_simulate:
0026     input:
0027         GEN_FILE="sim_output/femc_electron/e-_{P}GeV.hepmc",
0028         warmup="warmup.edm4hep.root",
0029         geometry_lib=find_epic_libraries(),
0030     output:
0031         SIM_FILE="sim_output/femc_electron/{DETECTOR_CONFIG}_sim_e-_{P}GeV.edm4hep.root",
0032     params:
0033         N_EVENTS=get_n_events,
0034         PHYSICS_LIST="FTFP_BERT",
0035         DETECTOR_PATH=os.environ["DETECTOR_PATH"],
0036         DETECTOR_CONFIG=lambda wildcards: wildcards.DETECTOR_CONFIG,
0037         DD4HEP_HASH=get_spack_package_hash("dd4hep"),
0038         NPSIM_HASH=get_spack_package_hash("npsim"),
0039     cache: True
0040     singularity: EIC_SINGULARITY_CONTAINER,
0041     shell:
0042         """
0043 exec npsim \
0044    --compactFile {params.DETECTOR_PATH}/{params.DETECTOR_CONFIG}.xml \
0045    --random.seed 1 \
0046    --numberOfEvents {params.N_EVENTS} \
0047    --physicsList {params.PHYSICS_LIST} \
0048    --inputFiles {input.GEN_FILE} \
0049    --outputFile {output.SIM_FILE}
0050 """
0051 
0052 rule femc_electron_recon:
0053     input:
0054         SIM_FILE="sim_output/femc_electron/{DETECTOR_CONFIG}_sim_e-_{P}GeV.edm4hep.root",
0055         warmup="warmup.edm4hep.root",
0056     output:
0057         REC_FILE="sim_output/femc_electron/{DETECTOR_CONFIG}_rec_e-_{P}GeV.edm4eic.root",
0058     params:
0059         N_EVENTS=get_n_events,
0060         DETECTOR_CONFIG=lambda wildcards: wildcards.DETECTOR_CONFIG,
0061         EICRECON_HASH=get_spack_package_hash("eicrecon"),
0062     cache: True
0063     singularity: EIC_SINGULARITY_CONTAINER,
0064     shell:
0065         """
0066 env DETECTOR_CONFIG={params.DETECTOR_CONFIG} \
0067   eicrecon {input.SIM_FILE} -Ppodio:output_file={output.REC_FILE} -Ppodio:output_collections=MCParticles,EcalEndcapPClusters -Pjana:nevents={params.N_EVENTS}
0068 """
0069 
0070 rule femc_electron_analysis:
0071     input:
0072         expand("sim_output/femc_electron/{DETECTOR_CONFIG}_rec_e-_{P}GeV.edm4eic.root",
0073             P=[10, 20, 30, 40, 50, 60, 70, 80],
0074             DETECTOR_CONFIG=["{DETECTOR_CONFIG}"]),
0075         script=workflow.source_path("analysis/femc_electron_plots.py"),
0076     output:
0077         results_dir=directory("results/{DETECTOR_CONFIG}/femc_electron"),
0078     singularity: EIC_SINGULARITY_CONTAINER,
0079     shell:
0080         """
0081 mkdir -p {output.results_dir}
0082 python {input.script} {output.results_dir}
0083 """