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=ancient("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         SEED=lambda wildcards: "1" + wildcards.INDEX,
0033         PHYSICS_LIST="FTFP_BERT",
0034         DETECTOR_PATH=os.environ["DETECTOR_PATH"],
0035         DETECTOR_CONFIG=lambda wildcards: wildcards.DETECTOR_CONFIG,
0036         DD4HEP_HASH=get_spack_package_hash("dd4hep"),
0037         NPSIM_HASH=get_spack_package_hash("npsim"),
0038     cache: True
0039     shell:
0040         """
0041 exec npsim \
0042    --compactFile {params.DETECTOR_PATH}/{params.DETECTOR_CONFIG}.xml \
0043    --random.seed {params.SEED} \
0044    --numberOfEvents {params.N_EVENTS} \
0045    --skipNEvents $(( {params.N_EVENTS} * {params.INDEX} )) \
0046    --physicsList {params.PHYSICS_LIST} \
0047    --inputFiles {input.GEN_FILE} \
0048    --outputFile {output.SIM_FILE}
0049 """
0050 
0051 rule insert_tau_recon:
0052     input:
0053         SIM_FILE="sim_output/insert_tau/{DETECTOR_CONFIG}_sim_tau-_{P}GeV_{INDEX}.edm4hep.root",
0054         warmup=ancient("warmup/{DETECTOR_CONFIG}.edm4hep.root"),
0055     output:
0056         REC_FILE="sim_output/insert_tau/{DETECTOR_CONFIG}_rec_tau-_{P}GeV_{INDEX}.edm4eic.root",
0057     params:
0058         N_EVENTS=get_n_events,
0059         DETECTOR_CONFIG=lambda wildcards: wildcards.DETECTOR_CONFIG,
0060         EICRECON_HASH=get_spack_package_hash("eicrecon"),
0061     cache: True
0062     shell:
0063         """
0064 env DETECTOR_CONFIG={params.DETECTOR_CONFIG} \
0065   eicrecon {input.SIM_FILE} -Ppodio:output_file={output.REC_FILE} -Ppodio:output_collections=MCParticles,HcalEndcapPInsertRecHits,HcalEndcapPInsertClusters,HcalEndcapPInsertSubcellHits,EcalEndcapPClusters,LFHCALClusters  -Pjana:nevents={params.N_EVENTS}
0066 """
0067 
0068 rule insert_tau_analysis:
0069     input:
0070         expand("sim_output/insert_tau/{DETECTOR_CONFIG}_rec_tau-_{P}GeV_{INDEX}.edm4eic.root",
0071             P=[20, 30, 40, 50, 60, 80, 100],
0072             DETECTOR_CONFIG=["{DETECTOR_CONFIG}"],
0073             INDEX=range(5),
0074         ),
0075         script="benchmarks/insert_tau/analysis/tau_plots.py",
0076     output:
0077         results_dir=directory("results/{DETECTOR_CONFIG}/insert_tau"),
0078     shell:
0079         """
0080 mkdir -p {output.results_dir}
0081 python {input.script} {output.results_dir}
0082 """