Warning, /detector_benchmarks/benchmarks/beamline/Snakefile is written in an unsupported language. File is not indexed.
0001 SIMOUTDIR="sim_output/beamline/"
0002 ANALYSISDIR=SIMOUTDIR+"analysis/"
0003
0004 ##########################################################################################
0005 ### Rules for checking the steering of the electron beam through the magnets
0006 ##########################################################################################
0007
0008 rule beamline_steering_sim:
0009 input:
0010 warmup="warmup/epic_ip6_extended.edm4hep.root",
0011 macro=workflow.source_path("beamlineGPS.mac"),
0012 geometry_lib=find_epic_libraries(),
0013 output:
0014 SIMOUTDIR+"beamlineTest{CAMPAIGN}.edm4hep.root",
0015 params:
0016 DD4HEP_HASH=get_spack_package_hash("dd4hep"),
0017 NPSIM_HASH=get_spack_package_hash("npsim"),
0018 cache: True
0019 shell:
0020 """
0021 exec npsim \
0022 --runType run \
0023 --random.seed 1 \
0024 --enableG4GPS \
0025 --macroFile {input.macro} \
0026 --compactFile $DETECTOR_PATH/epic_ip6_extended.xml \
0027 --printLevel WARNING \
0028 --outputFile {output} \
0029 --physics.rangecut 100*m
0030 """
0031
0032 rule beamline_steering_analysis:
0033 input:
0034 warmup="warmup/epic_ip6_extended.edm4hep.root",
0035 script=workflow.source_path("beamlineAnalysis.C"),
0036 header=workflow.source_path("shared_functions.h"),
0037 data=SIMOUTDIR+"beamlineTest{CAMPAIGN}.edm4hep.root",
0038 output:
0039 rootfile=ANALYSISDIR+"beamlineTestAnalysis{CAMPAIGN}.root",
0040 beamspot_canvas=ANALYSISDIR+"beamspot_{CAMPAIGN}.png",
0041 x_px_canvas=ANALYSISDIR+"x_px_{CAMPAIGN}.png",
0042 y_py_canvas=ANALYSISDIR+"y_py_{CAMPAIGN}.png",
0043 fitted_position_means_stdevs_canvas=ANALYSISDIR+"fitted_position_means_stdevs_{CAMPAIGN}.png",
0044 fitted_momentum_means_stdevs_canvas=ANALYSISDIR+"fitted_momentum_means_stdevs_{CAMPAIGN}.png",
0045 pipe_parameter_canvas=ANALYSISDIR+"pipe_parameter_{CAMPAIGN}.png",
0046 params:
0047 xml=os.getenv("DETECTOR_PATH")+"/epic_ip6_extended.xml",
0048 shell:
0049 """
0050 root -l -b -q '{input.script}("{input.data}", "{output.rootfile}", "{params.xml}",
0051 "{output.beamspot_canvas}", "{output.x_px_canvas}", "{output.y_py_canvas}",
0052 "{output.fitted_position_means_stdevs_canvas}", "{output.fitted_momentum_means_stdevs_canvas}",
0053 "{output.pipe_parameter_canvas}")'
0054 """
0055
0056 ##########################################################################################
0057 ### Rules for checking the acceptance of electrons at each stage of the beamline
0058 ##########################################################################################
0059
0060 rule beamline_acceptance_sim:
0061 input:
0062 warmup="warmup/epic_ip6_extended.edm4hep.root",
0063 macro=workflow.source_path("acceptanceGPS.mac"),
0064 geometry_lib=find_epic_libraries(),
0065 output:
0066 SIMOUTDIR+"acceptanceTest{CAMPAIGN}.edm4hep.root",
0067 params:
0068 DD4HEP_HASH=get_spack_package_hash("dd4hep"),
0069 NPSIM_HASH=get_spack_package_hash("npsim"),
0070 cache: True
0071 shell:
0072 """
0073 exec npsim \
0074 --runType run \
0075 --random.seed 1 \
0076 --enableG4GPS \
0077 --macroFile {input.macro} \
0078 --compactFile $DETECTOR_PATH/epic_ip6_extended.xml \
0079 --outputFile {output} \
0080 --physics.rangecut 100*m
0081 """
0082
0083 rule beamline_acceptance_analysis:
0084 input:
0085 warmup="warmup/epic_ip6_extended.edm4hep.root",
0086 script=workflow.source_path("acceptanceAnalysis.C"),
0087 header=workflow.source_path("shared_functions.h"),
0088 data=SIMOUTDIR+"acceptanceTest{CAMPAIGN}.edm4hep.root",
0089 output:
0090 rootfile=ANALYSISDIR+"acceptanceTestAnalysis{CAMPAIGN}.root",
0091 beampipe_canvas=ANALYSISDIR+"acceptance_in_beampipe_{CAMPAIGN}.png",
0092 etheta_canvas=ANALYSISDIR+"acceptance_energy_theta_{CAMPAIGN}.png",
0093 etheta_acceptance_canvas=ANALYSISDIR+"acceptance_energy_theta_acceptance_{CAMPAIGN}.png",
0094 entries_canvas=ANALYSISDIR+"acceptance_entries_{CAMPAIGN}.png",
0095 params:
0096 xml=os.getenv("DETECTOR_PATH")+"/epic_ip6_extended.xml",
0097 shell:
0098 """
0099 root -l -b -q '{input.script}("{input.data}", "{output.rootfile}", "{params.xml}", "{output.beampipe_canvas}","{output.etheta_canvas}","{output.etheta_acceptance_canvas}",
0100 "{output.entries_canvas}")'
0101 """
0102
0103 ##########################################################################################
0104 # Combine results
0105 ##########################################################################################
0106 rule beamline:
0107 input:
0108 ANALYSISDIR+"beamlineTestAnalysis{CAMPAIGN}.root",
0109 ANALYSISDIR+"beamspot_{CAMPAIGN}.png",
0110 ANALYSISDIR+"x_px_{CAMPAIGN}.png",
0111 ANALYSISDIR+"y_py_{CAMPAIGN}.png",
0112 ANALYSISDIR+"fitted_position_means_stdevs_{CAMPAIGN}.png",
0113 ANALYSISDIR+"fitted_momentum_means_stdevs_{CAMPAIGN}.png",
0114 ANALYSISDIR+"pipe_parameter_{CAMPAIGN}.png",
0115 ANALYSISDIR+"acceptanceTestAnalysis{CAMPAIGN}.root",
0116 ANALYSISDIR+"acceptance_in_beampipe_{CAMPAIGN}.png",
0117 ANALYSISDIR+"acceptance_energy_theta_{CAMPAIGN}.png",
0118 ANALYSISDIR+"acceptance_energy_theta_acceptance_{CAMPAIGN}.png",
0119 ANALYSISDIR+"acceptance_entries_{CAMPAIGN}.png"
0120 output:
0121 directory("results/beamline/steering_{CAMPAIGN}/")
0122 shell:
0123 """
0124 mkdir {output}
0125 cp -r {input} {output}
0126 """
0127
0128 ##########################################################################################
0129 # Defualt running
0130 ##########################################################################################
0131 rule beamline_local:
0132 input:
0133 "results/beamline/steering_local/"