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=workflow.source_path("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         SEED=lambda wildcards: stable_seed("insert_tau", wildcards.P),
0018     singularity: EIC_SINGULARITY_CONTAINER,
0019     shell:
0020         """
0021 root -l -b -q '{input.script}({params.N_EVENTS},"{output.GEN_FILE}", "tau-", {params.th_min}, {params.th_max}, 0., 360., {params.P}, 0, 1, {params.SEED})'
0022 """
0023 
0024 rule insert_tau_simulate:
0025     input:
0026         GEN_FILE="sim_output/insert_tau/tau-_{P}GeV.hepmc",
0027         warmup="warmup.edm4hep.root",
0028         geometry_lib=find_epic_libraries(),
0029     output:
0030         SIM_FILE="sim_output/insert_tau/{DETECTOR_CONFIG}_sim_tau-_{P}GeV_{INDEX}.edm4hep.rnt.root",
0031     params:
0032         N_EVENTS=get_n_events,
0033         INDEX=lambda wildcards: wildcards.INDEX,
0034         SEED=lambda wildcards: "1" + wildcards.INDEX,
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 {params.SEED} \
0047    --numberOfEvents {params.N_EVENTS} \
0048    --skipNEvents $(( {params.N_EVENTS} * {params.INDEX} )) \
0049    --physicsList {params.PHYSICS_LIST} \
0050    --inputFiles {input.GEN_FILE} \
0051    --outputConfig.useRNTuple true \
0052    --outputFile {output.SIM_FILE}
0053 """
0054 
0055 rule insert_tau_recon:
0056     input:
0057         SIM_FILE="sim_output/insert_tau/{DETECTOR_CONFIG}_sim_tau-_{P}GeV_{INDEX}.edm4hep.rnt.root",
0058         warmup="warmup.edm4hep.root",
0059     output:
0060         REC_FILE="sim_output/insert_tau/{DETECTOR_CONFIG}_rec_tau-_{P}GeV_{INDEX}.edm4eic.root",
0061     params:
0062         N_EVENTS=get_n_events,
0063         DETECTOR_CONFIG=lambda wildcards: wildcards.DETECTOR_CONFIG,
0064         EICRECON_HASH=get_spack_package_hash("eicrecon"),
0065     cache: True
0066     singularity: EIC_SINGULARITY_CONTAINER,
0067     shell:
0068         """
0069 env DETECTOR_CONFIG={params.DETECTOR_CONFIG} \
0070   eicrecon {input.SIM_FILE} -Ppodio:output_file={output.REC_FILE} -Ppodio:output_collections=MCParticles,HcalEndcapPInsertRecHits,HcalEndcapPInsertClusters,HcalEndcapPInsertSubcellHits,EcalEndcapPClusters,LFHCALClusters  -Pjana:nevents={params.N_EVENTS}
0071 """
0072 
0073 rule insert_tau_analysis:
0074     input:
0075         expand("sim_output/insert_tau/{DETECTOR_CONFIG}_rec_tau-_{P}GeV_{INDEX}.edm4eic.root",
0076             P=[20, 30, 40, 50, 60, 80, 100],
0077             DETECTOR_CONFIG=["{DETECTOR_CONFIG}"],
0078             INDEX=range(5),
0079         ),
0080         script=workflow.source_path("analysis/tau_plots.py"),
0081     output:
0082         results_dir=directory("results/{DETECTOR_CONFIG}/insert_tau"),
0083     singularity: EIC_SINGULARITY_CONTAINER,
0084     shell:
0085         """
0086 mkdir -p {output.results_dir}
0087 python {input.script} {output.results_dir}
0088 """