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     output:
0060         "sim_output/tracking_performances_dis/{DETECTOR_CONFIG}/pythia8NCDIS_{EBEAM}x{PBEAM}_minQ2={MINQ2}_beamEffects_xAngle=-0.025_hiDiv_{INDEX}.edm4eic.root",
0061     params:
0062         DETECTOR_CONFIG=lambda wildcards: wildcards.DETECTOR_CONFIG,
0063         EBEAM=lambda wildcards: wildcards.EBEAM,
0064         PBEAM=lambda wildcards: wildcards.PBEAM,
0065         MINQ2=lambda wildcards: wildcards.MINQ2,
0066         INDEX=lambda wildcards: wildcards.INDEX,
0067         EICRECON_HASH=get_spack_package_hash("eicrecon"),
0068     cache: True
0069     shell:
0070         """
0071 set -m # monitor mode to prevent lingering processes
0072 exec env DETECTOR_CONFIG={wildcards.DETECTOR_CONFIG} \
0073   eicrecon {input} -Ppodio:output_file={output} \
0074   -Ppodio:output_collections=MCParticles,ReconstructedChargedParticles,ReconstructedTruthSeededChargedParticles,CentralCKFTrackAssociations,CentralCKFTruthSeededTrackAssociations,CentralTrackVertices
0075 """
0076 
0077 # Process the files -- either from the campaign or local running -- through the analysis script
0078 rule dis_analysis:
0079     input:
0080         script_trk="benchmarks/tracking_performances_dis/analysis/trk_dis_analysis.cxx",
0081         script_trk_compiled="benchmarks/tracking_performances_dis/analysis/trk_dis_analysis_cxx.so",
0082         script_vtx="benchmarks/tracking_performances_dis/analysis/vtx_dis_analysis.cxx",
0083         script_vtx_compiled="benchmarks/tracking_performances_dis/analysis/vtx_dis_analysis_cxx.so",
0084         data="sim_output/tracking_performances_dis/{DETECTOR_CONFIG}/{PREFIX}pythia8NCDIS_{EBEAM}x{PBEAM}_minQ2={MINQ2}_beamEffects_xAngle=-0.025_hiDiv_{INDEX}.edm4eic.root",
0085     output:
0086         config_trk="results/tracking_performances_dis/{DETECTOR_CONFIG}/{PREFIX}pythia8NCDIS_{EBEAM}x{PBEAM}_minQ2={MINQ2}_{INDEX}/config.json",
0087         hists_trk="results/tracking_performances_dis/{DETECTOR_CONFIG}/{PREFIX}pythia8NCDIS_{EBEAM}x{PBEAM}_minQ2={MINQ2}_{INDEX}/hists.root",
0088         config_vtx="results/vertexing_performances_dis/{DETECTOR_CONFIG}/{PREFIX}pythia8NCDIS_{EBEAM}x{PBEAM}_minQ2={MINQ2}_{INDEX}/config.json",
0089         hists_vtx="results/vertexing_performances_dis/{DETECTOR_CONFIG}/{PREFIX}pythia8NCDIS_{EBEAM}x{PBEAM}_minQ2={MINQ2}_{INDEX}/hists.root",
0090     wildcard_constraints:
0091         PREFIX= ".*",
0092         EBEAM=r"\d+",
0093         PBEAM=r"\d+",
0094         MINQ2=r"\d+",
0095         INDEX=r"\d+",
0096     shell:
0097         """
0098 cat > {output.config_trk} <<EOF
0099 {{
0100   "rec_file": "{input.data}",
0101   "detector": "{wildcards.DETECTOR_CONFIG}",
0102   "ebeam": {wildcards.EBEAM},
0103   "pbeam": {wildcards.PBEAM},
0104   "Min_Q2": {wildcards.MINQ2},
0105   "output_prefix": "$(dirname "{output.hists_trk}")/hists"
0106 }}
0107 EOF
0108 root -l -b -q '{input.script_trk}+("{output.config_trk}")'
0109 
0110 cat > {output.config_vtx} <<EOF
0111 {{
0112   "rec_file": "{input.data}",
0113   "detector": "{wildcards.DETECTOR_CONFIG}",
0114   "ebeam": {wildcards.EBEAM},
0115   "pbeam": {wildcards.PBEAM},
0116   "Min_Q2": {wildcards.MINQ2},
0117   "output_prefix": "$(dirname "{output.hists_vtx}")/hists"
0118 }}
0119 EOF
0120 root -l -b -q '{input.script_vtx}+("{output.config_vtx}")'
0121 """
0122 
0123 #Merge all the files produced in the previous step
0124 rule dis_combine:
0125     input:
0126         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)],
0127         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)],
0128     output:
0129         config_trk="results/tracking_performances_dis/{DETECTOR_CONFIG}/{PREFIX}pythia8NCDIS_{EBEAM}x{PBEAM}_minQ2={MINQ2}_combined_{NUM_FILES}/config.json",
0130         hists_trk="results/tracking_performances_dis/{DETECTOR_CONFIG}/{PREFIX}pythia8NCDIS_{EBEAM}x{PBEAM}_minQ2={MINQ2}_combined_{NUM_FILES}/hists.root",
0131         config_vtx="results/vertexing_performances_dis/{DETECTOR_CONFIG}/{PREFIX}pythia8NCDIS_{EBEAM}x{PBEAM}_minQ2={MINQ2}_combined_{NUM_FILES}/config.json",
0132         hists_vtx="results/vertexing_performances_dis/{DETECTOR_CONFIG}/{PREFIX}pythia8NCDIS_{EBEAM}x{PBEAM}_minQ2={MINQ2}_combined_{NUM_FILES}/hists.root",
0133     wildcard_constraints:
0134         PREFIX= ".*",
0135         EBEAM=r"\d+",
0136         PBEAM=r"\d+",
0137         MINQ2=r"\d+",
0138         NUM_FILES=r"\d+",
0139     shell:
0140         """
0141 cat > {output.config_trk} <<EOF
0142 {{
0143   "hists_file": "{output.hists_trk}",
0144   "detector": "{wildcards.DETECTOR_CONFIG}",
0145   "ebeam": {wildcards.EBEAM},
0146   "pbeam": {wildcards.PBEAM},
0147   "Min_Q2": {wildcards.MINQ2},
0148   "nfiles": {wildcards.NUM_FILES},
0149   "output_prefix": "$(dirname "{output.hists_trk}")/plots"
0150 }}
0151 EOF
0152 hadd {output.hists_trk} {input}
0153 
0154 cat > {output.config_vtx} <<EOF
0155 {{
0156   "hists_file": "{output.hists_vtx}",
0157   "detector": "{wildcards.DETECTOR_CONFIG}",
0158   "ebeam": {wildcards.EBEAM},
0159   "pbeam": {wildcards.PBEAM},
0160   "Min_Q2": {wildcards.MINQ2},
0161   "nfiles": {wildcards.NUM_FILES},
0162   "output_prefix": "$(dirname "{output.hists_vtx}")/plots"
0163 }}
0164 EOF
0165 hadd {output.hists_vtx} {input}
0166 """
0167 
0168 #Process the merged file through the plotting script
0169 rule trk_dis_plots:
0170     input:
0171         script="benchmarks/tracking_performances_dis/analysis/trk_dis_plots.cxx",
0172         script_compiled="benchmarks/tracking_performances_dis/analysis/trk_dis_plots_cxx.so",
0173         config="results/tracking_performances_dis/{DETECTOR_CONFIG}/{PREFIX}pythia8NCDIS_{EBEAM}x{PBEAM}_minQ2={MINQ2}_combined_{NUM_FILES}/config.json",
0174     output:
0175         "results/tracking_performances_dis/{DETECTOR_CONFIG}/{PREFIX}pythia8NCDIS_{EBEAM}x{PBEAM}_minQ2={MINQ2}_combined_{NUM_FILES}/plots.pdf"
0176     wildcard_constraints:
0177         PREFIX= ".*",
0178         EBEAM=r"\d+",
0179         PBEAM=r"\d+",
0180         MINQ2=r"\d+",
0181         NUM_FILES=r"\d+",
0182     shell:
0183         """
0184 root -l -b -q '{input.script}+("{input.config}")'
0185 """
0186 
0187 rule vtx_dis_plots:
0188     input:
0189         script="benchmarks/tracking_performances_dis/analysis/vtx_dis_plots.cxx",
0190         script_compiled="benchmarks/tracking_performances_dis/analysis/vtx_dis_plots_cxx.so",
0191         config="results/vertexing_performances_dis/{DETECTOR_CONFIG}/{PREFIX}pythia8NCDIS_{EBEAM}x{PBEAM}_minQ2={MINQ2}_combined_{NUM_FILES}/config.json",
0192     output:
0193         "results/vertexing_performances_dis/{DETECTOR_CONFIG}/{PREFIX}pythia8NCDIS_{EBEAM}x{PBEAM}_minQ2={MINQ2}_combined_{NUM_FILES}/plots.pdf"
0194     wildcard_constraints:
0195         PREFIX= ".*",
0196         EBEAM=r"\d+",
0197         PBEAM=r"\d+",
0198         MINQ2=r"\d+",
0199         NUM_FILES=r"\d+",
0200     shell:
0201         """
0202 root -l -b -q '{input.script}+("{input.config}")'
0203 """
0204 
0205 #Examples of invocation
0206 rule trk_dis_run_locally:
0207     input:
0208         "results/tracking_performances_dis/" + os.environ["DETECTOR_CONFIG"] + "/pythia8NCDIS_18x275_minQ2=1_combined_5/plots.pdf",
0209     message:
0210         "See output in {input[0]}"
0211 
0212 rule vtx_dis_run_locally:
0213     input:
0214         "results/vertexing_performances_dis/" + os.environ["DETECTOR_CONFIG"] + "/pythia8NCDIS_18x275_minQ2=1_combined_5/plots.pdf",
0215     message:
0216         "See output in {input[0]}"
0217 
0218 
0219 rule trk_dis_run_locally_trk_only:
0220     input:
0221         "results/tracking_performances_dis/epic_craterlake_tracking_only/pythia8NCDIS_18x275_minQ2=1_combined_5/plots.pdf",
0222     message:
0223         "See output in {input[0]}"
0224 
0225 
0226 rule vtx_dis_run_locally_trk_only:
0227     input:
0228         "results/vertexing_performances_dis/epic_craterlake_tracking_only/pythia8NCDIS_18x275_minQ2=1_combined_5/plots.pdf",
0229     message:
0230         "See output in {input[0]}"