Back to home page

EIC code displayed by LXR

 
 

    


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

0001 rule nhcal_basic_distribution_simulate:
0002     input:
0003         warmup=ancient("warmup/{DETECTOR_CONFIG}.edm4hep.root"),
0004         geometry_lib=find_epic_libraries(),
0005     output:
0006         "sim_output/nhcal_basic_distribution/E{ENERGY}GeV/sim_{DETECTOR_CONFIG}.{INDEX}.edm4hep.root",
0007     params:
0008         N_EVENTS=10000,
0009         SEED=lambda wildcards: "1" + wildcards.INDEX,
0010         DETECTOR_PATH=os.environ["DETECTOR_PATH"],
0011         DETECTOR_CONFIG=lambda wildcards: wildcards.DETECTOR_CONFIG,
0012         ENERGY=lambda wildcards: wildcards.ENERGY,
0013         DD4HEP_HASH=get_spack_package_hash("dd4hep"),
0014         NPSIM_HASH=get_spack_package_hash("npsim"),
0015     cache: True
0016     shell:
0017         """
0018 exec npsim \
0019     --compactFile {params.DETECTOR_PATH}/{params.DETECTOR_CONFIG}.xml \
0020     --numberOfEvents {params.N_EVENTS} \
0021     --random.seed {params.SEED} \
0022     --enableGun \
0023     -v WARNING \
0024     --gun.particle neutron \
0025     --gun.thetaMin 120*degree \
0026     --gun.thetaMax 180*degree \
0027     --gun.distribution uniform \
0028     --gun.energy "{params.ENERGY}*GeV" \
0029     --outputFile {output}
0030 """
0031 
0032 
0033 rule nhcal_basic_distribution_combine:
0034     input:
0035         lambda wildcards: expand(
0036             "sim_output/nhcal_basic_distribution/E{ENERGY:.1f}GeV/sim_{DETECTOR_CONFIG}.{INDEX:02d}.edm4hep.root", 
0037             DETECTOR_CONFIG=wildcards.DETECTOR_CONFIG,
0038             ENERGY=float(wildcards.ENERGY),
0039             INDEX=range(int(wildcards.N)),
0040         ),
0041     wildcard_constraints:
0042         N=r"\d+",
0043         ENERGY=r"\d+(\.\d+)?"
0044     output:
0045         temp("sim_output/nhcal_basic_distribution/sim_{DETECTOR_CONFIG}_E{ENERGY}GeV_combined_{N}files.edm4hep.root"),
0046     shell:
0047         """
0048 hadd -f {output} {input} 
0049 """
0050 
0051 rule nhcal_basic_distribution_analysis:
0052     input:
0053         combined="sim_output/nhcal_basic_distribution/sim_{DETECTOR_CONFIG}_E{ENERGY}GeV_combined_{N}files.edm4hep.root",
0054         script="benchmarks/nhcal_basic_distribution/scripts/basic_distribution_analysis.cxx",
0055     output:
0056         pdf=f"results/nhcal_basic_distribution/analysis_{{DETECTOR_CONFIG}}_E{{ENERGY}}GeV_combined_{{N}}files.pdf",
0057         png=f"results/nhcal_basic_distribution/analysis_{{DETECTOR_CONFIG}}_E{{ENERGY}}GeV_combined_{{N}}files.png",
0058     shell:
0059         """
0060     root -l -b -q '{input.script}("{input.combined}","{output.pdf}","{output.png}")'
0061 """