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