Back to home page

EIC code displayed by LXR

 
 

    


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

0001 import os
0002 
0003 rule compile_analysis:
0004     input:
0005         "{path}/{filename}.cxx",
0006     output:
0007         "{path}/{filename}_cxx.d",
0008         "{path}/{filename}_cxx.so",
0009         "{path}/{filename}_cxx_ACLiC_dict_rdict.pcm",
0010     shell:
0011         """
0012 root -l -b -q -e '.L {input}+'
0013 """
0014 
0015 rule trk_dis_compile:
0016     input:
0017         "benchmarks/tracking_performances_dis/analysis/trk_dis_analysis_cxx.so",
0018         "benchmarks/tracking_performances_dis/analysis/trk_dis_plots_cxx.so",
0019         "benchmarks/tracking_performances_dis/analysis/vtx_dis_analysis_cxx.so",
0020         "benchmarks/tracking_performances_dis/analysis/vtx_dis_plots_cxx.so",
0021 
0022 # Process the generated HepMC files through the simulation
0023 rule trk_dis_sim:
0024     input:
0025         warmup="warmup/{DETECTOR_CONFIG}.edm4hep.root",
0026         geometry_lib=find_epic_libraries(),
0027     output:
0028         "sim_output/tracking_performances_dis/{DETECTOR_CONFIG}/pythia8NCDIS_{EBEAM}x{PBEAM}_minQ2={MINQ2}_beamEffects_xAngle=-0.025_hiDiv_{INDEX}.edm4hep.root",
0029     params:
0030         N_EVENTS=200,
0031         EBEAM=lambda wildcards: wildcards.EBEAM,
0032         INDEX=lambda wildcards: wildcards.INDEX,
0033         PBEAM=lambda wildcards: wildcards.PBEAM,
0034         MINQ2=lambda wildcards: wildcards.MINQ2,
0035         SEED=lambda wildcards: "1" + wildcards.INDEX,
0036         DETECTOR_PATH=os.environ["DETECTOR_PATH"],
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     shell:
0042         """
0043 ddsim \
0044   --runType batch \
0045   --part.minimalKineticEnergy 1000*GeV  \
0046   --random.seed {params.SEED} \
0047   --filter.tracker edep0 \
0048   -v WARNING \
0049   --numberOfEvents {params.N_EVENTS} \
0050   --compactFile {params.DETECTOR_PATH}/{params.DETECTOR_CONFIG}.xml \
0051   --inputFiles root://dtn-eic.jlab.org//volatile/eic/EPIC/EVGEN/DIS/NC/{params.EBEAM}x{params.PBEAM}/minQ2={params.MINQ2}/pythia8NCDIS_{params.EBEAM}x{params.PBEAM}_minQ2={params.MINQ2}_beamEffects_xAngle=-0.025_hiDiv_vtxfix_{params.INDEX}.hepmc3.tree.root \
0052   --outputFile {output}
0053 """
0054 
0055 # Process the files produced in the previous step through EICRecon
0056 rule trk_dis_reco:
0057     input:
0058         "sim_output/tracking_performances_dis/{DETECTOR_CONFIG}/pythia8NCDIS_{EBEAM}x{PBEAM}_minQ2={MINQ2}_beamEffects_xAngle=-0.025_hiDiv_{INDEX}.edm4hep.root",
0059         warmup="warmup/{DETECTOR_CONFIG}.edm4hep.root",
0060     output:
0061         "sim_output/tracking_performances_dis/{DETECTOR_CONFIG}/pythia8NCDIS_{EBEAM}x{PBEAM}_minQ2={MINQ2}_beamEffects_xAngle=-0.025_hiDiv_{INDEX}.edm4eic.root",
0062     params:
0063         DETECTOR_CONFIG=lambda wildcards: wildcards.DETECTOR_CONFIG,
0064         EBEAM=lambda wildcards: wildcards.EBEAM,
0065         PBEAM=lambda wildcards: wildcards.PBEAM,
0066         MINQ2=lambda wildcards: wildcards.MINQ2,
0067         INDEX=lambda wildcards: wildcards.INDEX,
0068         EICRECON_HASH=get_spack_package_hash("eicrecon"),
0069     cache: True
0070     shell:
0071         """
0072 set -m # monitor mode to prevent lingering processes
0073 exec env DETECTOR_CONFIG={wildcards.DETECTOR_CONFIG} \
0074   eicrecon {input} -Ppodio:output_file={output} \
0075   -Ppodio:output_collections=MCParticles,ReconstructedChargedParticles,ReconstructedTruthSeededChargedParticles,CentralCKFTrackAssociations,CentralCKFTruthSeededTrackAssociations,CentralTrackVertices
0076 """
0077 
0078 # Process the files -- either from the campaign or local running -- through the analysis script
0079 rule dis_analysis:
0080     input:
0081         script_trk="benchmarks/tracking_performances_dis/analysis/trk_dis_analysis.cxx",
0082         script_trk_compiled="benchmarks/tracking_performances_dis/analysis/trk_dis_analysis_cxx.so",
0083         script_vtx="benchmarks/tracking_performances_dis/analysis/vtx_dis_analysis.cxx",
0084         script_vtx_compiled="benchmarks/tracking_performances_dis/analysis/vtx_dis_analysis_cxx.so",
0085         data="sim_output/tracking_performances_dis/{DETECTOR_CONFIG}/{PREFIX}pythia8NCDIS_{EBEAM}x{PBEAM}_minQ2={MINQ2}_beamEffects_xAngle=-0.025_hiDiv_{INDEX}.edm4eic.root",
0086     output:
0087         config_trk="results/tracking_performances_dis/{DETECTOR_CONFIG}/{PREFIX}pythia8NCDIS_{EBEAM}x{PBEAM}_minQ2={MINQ2}_{INDEX}/config.json",
0088         hists_trk="results/tracking_performances_dis/{DETECTOR_CONFIG}/{PREFIX}pythia8NCDIS_{EBEAM}x{PBEAM}_minQ2={MINQ2}_{INDEX}/hists.root",
0089         config_vtx="results/vertexing_performances_dis/{DETECTOR_CONFIG}/{PREFIX}pythia8NCDIS_{EBEAM}x{PBEAM}_minQ2={MINQ2}_{INDEX}/config.json",
0090         hists_vtx="results/vertexing_performances_dis/{DETECTOR_CONFIG}/{PREFIX}pythia8NCDIS_{EBEAM}x{PBEAM}_minQ2={MINQ2}_{INDEX}/hists.root",
0091     wildcard_constraints:
0092         PREFIX= ".*",
0093         EBEAM=r"\d+",
0094         PBEAM=r"\d+",
0095         MINQ2=r"\d+",
0096         INDEX=r"\d+",
0097     shell:
0098         """
0099 cat > {output.config_trk} <<EOF
0100 {{
0101   "rec_file": "{input.data}",
0102   "detector": "{wildcards.DETECTOR_CONFIG}",
0103   "ebeam": {wildcards.EBEAM},
0104   "pbeam": {wildcards.PBEAM},
0105   "Min_Q2": {wildcards.MINQ2},
0106   "output_prefix": "$(dirname "{output.hists_trk}")/hists"
0107 }}
0108 EOF
0109 root -l -b -q '{input.script_trk}+("{output.config_trk}")'
0110 
0111 cat > {output.config_vtx} <<EOF
0112 {{
0113   "rec_file": "{input.data}",
0114   "detector": "{wildcards.DETECTOR_CONFIG}",
0115   "ebeam": {wildcards.EBEAM},
0116   "pbeam": {wildcards.PBEAM},
0117   "Min_Q2": {wildcards.MINQ2},
0118   "output_prefix": "$(dirname "{output.hists_vtx}")/hists"
0119 }}
0120 EOF
0121 root -l -b -q '{input.script_vtx}+("{output.config_vtx}")'
0122 """
0123 
0124 #Merge all the files produced in the previous step
0125 rule dis_combine:
0126     input:
0127         lambda wildcards: [f"results/tracking_performances_dis/{wildcards.DETECTOR_CONFIG}/{wildcards.PREFIX}pythia8NCDIS_{wildcards.EBEAM}x{wildcards.PBEAM}_minQ2={wildcards.MINQ2}_{ix}/hists.root" for ix in range(1,int(wildcards.NUM_FILES)+1)],
0128         lambda wildcards: [f"results/vertexing_performances_dis/{wildcards.DETECTOR_CONFIG}/{wildcards.PREFIX}pythia8NCDIS_{wildcards.EBEAM}x{wildcards.PBEAM}_minQ2={wildcards.MINQ2}_{ix}/hists.root" for ix in range(1,int(wildcards.NUM_FILES)+1)],
0129     output:
0130         config_trk="results/tracking_performances_dis/{DETECTOR_CONFIG}/{PREFIX}pythia8NCDIS_{EBEAM}x{PBEAM}_minQ2={MINQ2}_combined_{NUM_FILES}/config.json",
0131         hists_trk="results/tracking_performances_dis/{DETECTOR_CONFIG}/{PREFIX}pythia8NCDIS_{EBEAM}x{PBEAM}_minQ2={MINQ2}_combined_{NUM_FILES}/hists.root",
0132         config_vtx="results/vertexing_performances_dis/{DETECTOR_CONFIG}/{PREFIX}pythia8NCDIS_{EBEAM}x{PBEAM}_minQ2={MINQ2}_combined_{NUM_FILES}/config.json",
0133         hists_vtx="results/vertexing_performances_dis/{DETECTOR_CONFIG}/{PREFIX}pythia8NCDIS_{EBEAM}x{PBEAM}_minQ2={MINQ2}_combined_{NUM_FILES}/hists.root",
0134     wildcard_constraints:
0135         PREFIX= ".*",
0136         EBEAM=r"\d+",
0137         PBEAM=r"\d+",
0138         MINQ2=r"\d+",
0139         NUM_FILES=r"\d+",
0140     shell:
0141         """
0142 cat > {output.config_trk} <<EOF
0143 {{
0144   "hists_file": "{output.hists_trk}",
0145   "detector": "{wildcards.DETECTOR_CONFIG}",
0146   "ebeam": {wildcards.EBEAM},
0147   "pbeam": {wildcards.PBEAM},
0148   "Min_Q2": {wildcards.MINQ2},
0149   "nfiles": {wildcards.NUM_FILES},
0150   "output_prefix": "$(dirname "{output.hists_trk}")/plots"
0151 }}
0152 EOF
0153 hadd {output.hists_trk} {input}
0154 
0155 cat > {output.config_vtx} <<EOF
0156 {{
0157   "hists_file": "{output.hists_vtx}",
0158   "detector": "{wildcards.DETECTOR_CONFIG}",
0159   "ebeam": {wildcards.EBEAM},
0160   "pbeam": {wildcards.PBEAM},
0161   "Min_Q2": {wildcards.MINQ2},
0162   "nfiles": {wildcards.NUM_FILES},
0163   "output_prefix": "$(dirname "{output.hists_vtx}")/plots"
0164 }}
0165 EOF
0166 hadd {output.hists_vtx} {input}
0167 """
0168 
0169 #Process the merged file through the plotting script
0170 rule trk_dis_plots:
0171     input:
0172         script="benchmarks/tracking_performances_dis/analysis/trk_dis_plots.cxx",
0173         script_compiled="benchmarks/tracking_performances_dis/analysis/trk_dis_plots_cxx.so",
0174         config="results/tracking_performances_dis/{DETECTOR_CONFIG}/{PREFIX}pythia8NCDIS_{EBEAM}x{PBEAM}_minQ2={MINQ2}_combined_{NUM_FILES}/config.json",
0175     output:
0176         "results/tracking_performances_dis/{DETECTOR_CONFIG}/{PREFIX}pythia8NCDIS_{EBEAM}x{PBEAM}_minQ2={MINQ2}_combined_{NUM_FILES}/plots.pdf"
0177     wildcard_constraints:
0178         PREFIX= ".*",
0179         EBEAM=r"\d+",
0180         PBEAM=r"\d+",
0181         MINQ2=r"\d+",
0182         NUM_FILES=r"\d+",
0183     shell:
0184         """
0185 root -l -b -q '{input.script}+("{input.config}")'
0186 """
0187 
0188 rule vtx_dis_plots:
0189     input:
0190         script="benchmarks/tracking_performances_dis/analysis/vtx_dis_plots.cxx",
0191         script_compiled="benchmarks/tracking_performances_dis/analysis/vtx_dis_plots_cxx.so",
0192         config="results/vertexing_performances_dis/{DETECTOR_CONFIG}/{PREFIX}pythia8NCDIS_{EBEAM}x{PBEAM}_minQ2={MINQ2}_combined_{NUM_FILES}/config.json",
0193     output:
0194         "results/vertexing_performances_dis/{DETECTOR_CONFIG}/{PREFIX}pythia8NCDIS_{EBEAM}x{PBEAM}_minQ2={MINQ2}_combined_{NUM_FILES}/plots.pdf"
0195     wildcard_constraints:
0196         PREFIX= ".*",
0197         EBEAM=r"\d+",
0198         PBEAM=r"\d+",
0199         MINQ2=r"\d+",
0200         NUM_FILES=r"\d+",
0201     shell:
0202         """
0203 root -l -b -q '{input.script}+("{input.config}")'
0204 """
0205 
0206 #Examples of invocation
0207 rule trk_dis_run_locally:
0208     input:
0209         "results/tracking_performances_dis/" + os.environ["DETECTOR_CONFIG"] + "/pythia8NCDIS_18x275_minQ2=1_combined_5/plots.pdf",
0210     message:
0211         "See output in {input[0]}"
0212 
0213 rule vtx_dis_run_locally:
0214     input:
0215         "results/vertexing_performances_dis/" + os.environ["DETECTOR_CONFIG"] + "/pythia8NCDIS_18x275_minQ2=1_combined_5/plots.pdf",
0216     message:
0217         "See output in {input[0]}"
0218 
0219 
0220 rule trk_dis_run_locally_trk_only:
0221     input:
0222         "results/tracking_performances_dis/epic_craterlake_tracking_only/pythia8NCDIS_18x275_minQ2=1_combined_5/plots.pdf",
0223     message:
0224         "See output in {input[0]}"
0225 
0226 
0227 rule vtx_dis_run_locally_trk_only:
0228     input:
0229         "results/vertexing_performances_dis/epic_craterlake_tracking_only/pythia8NCDIS_18x275_minQ2=1_combined_5/plots.pdf",
0230     message:
0231         "See output in {input[0]}"