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