Back to home page

EIC code displayed by LXR

 
 

    


Warning, /detector_benchmarks/benchmarks/femc_photon/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_photon_generate:
0009     input:
0010         script=workflow.source_path("analysis/gen_particles.cxx"),
0011     output:
0012         GEN_FILE="sim_output/femc_photon/photon_{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         SEED=lambda wildcards: stable_seed("femc_photon", wildcards.P),
0019     singularity: EIC_SINGULARITY_CONTAINER,
0020     shell:
0021         """
0022 mkdir -p sim_output/femc_photon
0023 root -l -b -q '{input.script}({params.N_EVENTS},"{output.GEN_FILE}", "gamma", {params.th_min}, {params.th_max}, 0., 360., {params.P}, 0, 1, {params.SEED})'
0024 """
0025 
0026 rule femc_photon_simulate:
0027     input:
0028         GEN_FILE="sim_output/femc_photon/photon_{P}GeV.hepmc",
0029         warmup="warmup.edm4hep.root",
0030         geometry_lib=find_epic_libraries(),
0031     output:
0032         SIM_FILE="sim_output/femc_photon/{DETECTOR_CONFIG}_sim_photon_{P}GeV.edm4hep.rnt.root",
0033     params:
0034         N_EVENTS=get_n_events,
0035         PHYSICS_LIST="FTFP_BERT",
0036         DETECTOR_PATH=config["DETECTOR_PREFIX"] + "/share/epic",
0037         DETECTOR_CONFIG=lambda wildcards: wildcards.DETECTOR_CONFIG,
0038         DD4HEP_HASH=get_spack_package_hash("dd4hep"),
0039         NPSIM_HASH=get_spack_package_hash("npsim"),
0040     cache: True
0041     singularity: EIC_SINGULARITY_CONTAINER,
0042     shell:
0043         """
0044 exec npsim \
0045    --compactFile {params.DETECTOR_PATH}/{params.DETECTOR_CONFIG}.xml \
0046    --random.seed 1 \
0047    --numberOfEvents {params.N_EVENTS} \
0048    --physicsList {params.PHYSICS_LIST} \
0049    --inputFiles {input.GEN_FILE} \
0050    --outputConfig.useRNTuple true \
0051    --outputFile {output.SIM_FILE}
0052 """
0053 
0054 rule femc_photon_recon:
0055     input:
0056         SIM_FILE="sim_output/femc_photon/{DETECTOR_CONFIG}_sim_photon_{P}GeV.edm4hep.rnt.root",
0057         warmup="warmup.edm4hep.root",
0058     output:
0059         REC_FILE="sim_output/femc_photon/{DETECTOR_CONFIG}_rec_photon_{P}GeV.edm4eic.root",
0060     params:
0061         N_EVENTS=get_n_events,
0062         DETECTOR_CONFIG=lambda wildcards: wildcards.DETECTOR_CONFIG,
0063         EICRECON_HASH=get_spack_package_hash("eicrecon"),
0064     cache: True
0065     singularity: EIC_SINGULARITY_CONTAINER,
0066     shell:
0067         """
0068 env DETECTOR_CONFIG={params.DETECTOR_CONFIG} \
0069   eicrecon {input.SIM_FILE} -Ppodio:output_file={output.REC_FILE} -Ppodio:output_collections=MCParticles,EcalEndcapPClusters -Pjana:nevents={params.N_EVENTS}
0070 """
0071 
0072 rule femc_photon_analysis:
0073     input:
0074         expand("sim_output/femc_photon/{DETECTOR_CONFIG}_rec_photon_{P}GeV.edm4eic.root",
0075             P=[10, 20, 30, 40, 50, 60, 70, 80],
0076             DETECTOR_CONFIG=["{DETECTOR_CONFIG}"]),
0077         script=workflow.source_path("analysis/femc_photon_plots.py"),
0078     output:
0079         results_dir=directory("results/{DETECTOR_CONFIG}/femc_photon"),
0080     singularity: EIC_SINGULARITY_CONTAINER,
0081     shell:
0082         """
0083 mkdir -p {output.results_dir}
0084 python {input.script} {output.results_dir}
0085 """