Back to home page

EIC code displayed by LXR

 
 

    


Warning, /detector_benchmarks/benchmarks/insert_tau/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 rule insert_tau_generate:
0008     input:
0009         script="benchmarks/insert_tau/analysis/gen_particles.cxx",
0010     output:
0011         GEN_FILE="sim_output/insert_tau/tau-_{P}GeV.hepmc",
0012     params:
0013         N_EVENTS=get_n_events,
0014         th_max=7.0,
0015         th_min=1.7,
0016         P=lambda wildcards: wildcards.P,
0017     shell:
0018         """
0019 root -l -b -q '{input.script}({params.N_EVENTS},"{output.GEN_FILE}", "tau-", {params.th_min}, {params.th_max}, 0., 360., {params.P})'
0020 """
0021 
0022 rule insert_tau_simulate:
0023     input:
0024         GEN_FILE="sim_output/insert_tau/tau-_{P}GeV.hepmc",
0025         warmup="warmup/{DETECTOR_CONFIG}.edm4hep.root",
0026         geometry_lib=find_epic_libraries(),
0027     output:
0028         SIM_FILE="sim_output/insert_tau/{DETECTOR_CONFIG}_sim_tau-_{P}GeV_{INDEX}.edm4hep.root",
0029     params:
0030         N_EVENTS=get_n_events,
0031         INDEX=lambda wildcards: wildcards.INDEX,
0032         PHYSICS_LIST="FTFP_BERT",
0033         DETECTOR_PATH=os.environ["DETECTOR_PATH"],
0034         DETECTOR_CONFIG=lambda wildcards: wildcards.DETECTOR_CONFIG,
0035         DD4HEP_HASH=get_spack_package_hash("dd4hep"),
0036         NPSIM_HASH=get_spack_package_hash("npsim"),
0037     cache: True
0038     shell:
0039         """
0040 # Running simulation
0041 npsim \
0042    --compactFile {params.DETECTOR_PATH}/{params.DETECTOR_CONFIG}.xml \
0043    --numberOfEvents {params.N_EVENTS} \
0044    --skipNEvents $(( {params.N_EVENTS} * {params.INDEX} )) \
0045    --physicsList {params.PHYSICS_LIST} \
0046    --inputFiles {input.GEN_FILE} \
0047    --outputFile {output.SIM_FILE}
0048 """
0049 
0050 rule insert_tau_recon:
0051     input:
0052         SIM_FILE="sim_output/insert_tau/{DETECTOR_CONFIG}_sim_tau-_{P}GeV_{INDEX}.edm4hep.root",
0053     output:
0054         REC_FILE="sim_output/insert_tau/{DETECTOR_CONFIG}_rec_tau-_{P}GeV_{INDEX}.edm4eic.root",
0055     params:
0056         N_EVENTS=get_n_events,
0057         DETECTOR_CONFIG=lambda wildcards: wildcards.DETECTOR_CONFIG,
0058         EICRECON_HASH=get_spack_package_hash("eicrecon"),
0059     cache: True
0060     shell:
0061         """
0062 env DETECTOR_CONFIG={params.DETECTOR_CONFIG} \
0063   eicrecon {input.SIM_FILE} -Ppodio:output_file={output.REC_FILE} -Ppodio:output_collections=MCParticles,HcalEndcapPInsertRecHits,HcalEndcapPInsertClusters,HcalEndcapPInsertSubcellHits,EcalEndcapPInsertRecHits,EcalEndcapPInsertClusters,EcalEndcapPClusters,LFHCALClusters  -Pjana:nevents={params.N_EVENTS}
0064 """
0065 
0066 rule insert_tau_analysis:
0067     input:
0068         expand("sim_output/insert_tau/{DETECTOR_CONFIG}_rec_tau-_{P}GeV_{INDEX}.edm4eic.root",
0069             P=[20, 30, 40, 50, 60, 80, 100],
0070             DETECTOR_CONFIG=["{DETECTOR_CONFIG}"],
0071             INDEX=range(5),
0072         ),
0073         script="benchmarks/insert_tau/analysis/tau_plots.py",
0074     output:
0075         results_dir=directory("results/{DETECTOR_CONFIG}/insert_tau"),
0076     shell:
0077         """
0078 mkdir -p {output.results_dir}
0079 python {input.script} {output.results_dir}
0080 """