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