Back to home page

EIC code displayed by LXR

 
 

    


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.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.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.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             --printLevel WARNING \
0080             --outputFile {output} \
0081             --physics.rangecut 100*m
0082         """
0083 
0084 rule beamline_acceptance_analysis:
0085     input:
0086         warmup="warmup.edm4hep.root",
0087         script=workflow.source_path("acceptanceAnalysis.C"),
0088         header=workflow.source_path("shared_functions.h"),
0089         data=SIMOUTDIR+"acceptanceTest{CAMPAIGN}.edm4hep.root",
0090     output:
0091         rootfile=ANALYSISDIR+"acceptanceTestAnalysis{CAMPAIGN}.root",
0092         beampipe_canvas=ANALYSISDIR+"acceptance_in_beampipe_{CAMPAIGN}.png",
0093         etheta_canvas=ANALYSISDIR+"acceptance_energy_theta_{CAMPAIGN}.png",
0094         etheta_acceptance_canvas=ANALYSISDIR+"acceptance_energy_theta_acceptance_{CAMPAIGN}.png",
0095         entries_canvas=ANALYSISDIR+"acceptance_entries_{CAMPAIGN}.png",
0096     params:
0097         xml=os.getenv("DETECTOR_PATH")+"/epic_ip6_extended.xml",
0098     shell:
0099         """
0100             root -l -b -q '{input.script}+("{input.data}", "{output.rootfile}", "{params.xml}", "{output.beampipe_canvas}","{output.etheta_canvas}","{output.etheta_acceptance_canvas}",
0101             "{output.entries_canvas}")'
0102         """
0103 
0104 ##########################################################################################
0105 # Combine results
0106 ##########################################################################################
0107 rule beamline:
0108     input:
0109         ANALYSISDIR+"beamlineTestAnalysis{CAMPAIGN}.root",
0110         ANALYSISDIR+"beamspot_{CAMPAIGN}.png",
0111         ANALYSISDIR+"x_px_{CAMPAIGN}.png",
0112         ANALYSISDIR+"y_py_{CAMPAIGN}.png",
0113         ANALYSISDIR+"fitted_position_means_stdevs_{CAMPAIGN}.png",
0114         ANALYSISDIR+"fitted_momentum_means_stdevs_{CAMPAIGN}.png",
0115         ANALYSISDIR+"pipe_parameter_{CAMPAIGN}.png",  
0116         ANALYSISDIR+"acceptanceTestAnalysis{CAMPAIGN}.root",
0117         ANALYSISDIR+"acceptance_in_beampipe_{CAMPAIGN}.png",
0118         ANALYSISDIR+"acceptance_energy_theta_{CAMPAIGN}.png",
0119         ANALYSISDIR+"acceptance_energy_theta_acceptance_{CAMPAIGN}.png",     
0120         ANALYSISDIR+"acceptance_entries_{CAMPAIGN}.png"
0121     output:
0122         directory("results/beamline/steering_{CAMPAIGN}/")
0123     shell:
0124         """
0125             mkdir {output}        
0126             cp -r {input} {output}
0127         """
0128 
0129 ##########################################################################################
0130 # Defualt running
0131 ##########################################################################################
0132 rule beamline_local:
0133     input:
0134         "results/beamline/steering_local/"