22Snakemake rules for building dsp pars for HPGes, before running build_dsp()
33- extraction of pole zero constant(s) for each channel from cal data
44- extraction of energy filter parameters and charge trapping correction for each channel from cal data
5+
6+ Outputs should be dsp_pars, dsp_plots, dsp_pars_lh5 and dsp_objects, to be fed into merge rules
57"""
68
79from legenddataflow .methods import ParsKeyResolve
@@ -32,8 +34,8 @@ rule build_pars_dsp_pz_geds:
3234 ),
3335 pulser = get_pattern_pars_tmp_channel (config , "tcm" , "pulser_ids" ),
3436 output :
35- decay_const = temp (get_pattern_pars_tmp_channel (config , "dsp" , "decay_constant" )),
36- plots = temp (get_pattern_plts_tmp_channel (config , "dsp" , "decay_constant" )),
37+ dsp_pars = temp (get_pattern_pars_tmp_channel (config , "dsp" , "decay_constant" )),
38+ dsp_plots = temp (get_pattern_plts_tmp_channel (config , "dsp" , "decay_constant" )),
3739 log :
3840 get_pattern_log_channel (config , "par_dsp_decay_constant" , time ),
3941 group :
@@ -78,8 +80,8 @@ rule build_pars_dsp_pz_geds:
7880 "--config-file {params.config_file} "
7981 "--processing-chain {params.processing_chain} "
8082 "--raw-table-name {params.raw_table_name} "
81- "--plot-path {output.plots } "
82- "--output-file {output.decay_const } "
83+ "--plot-path {output.dsp_plots } "
84+ "--output-file {output.dsp_pars } "
8385 "--pulser-file {input.pulser} "
8486 "--raw-files {input.files} "
8587 "--pz-files {input.pz_files}"
@@ -91,7 +93,7 @@ rule build_pars_evtsel_geds:
9193 filelist_path (config ), "all-{experiment}-{period}-{run}-cal-raw.filelist"
9294 ),
9395 pulser_file = get_pattern_pars_tmp_channel (config , "tcm" , "pulser_ids" ),
94- database = rules .build_pars_dsp_pz_geds .output .decay_const ,
96+ database = rules .build_pars_dsp_pz_geds .output .dsp_pars ,
9597 raw_cal_curve = get_blinding_curve_file ,
9698 output :
9799 peak_file = temp (
@@ -157,13 +159,13 @@ rule build_pars_dsp_nopt_geds:
157159 files = os .path .join (
158160 filelist_path (config ), "all-{experiment}-{period}-{run}-fft-raw.filelist"
159161 ),
160- database = rules .build_pars_dsp_pz_geds .output .decay_const ,
161- inplots = rules .build_pars_dsp_pz_geds .output .plots ,
162+ database = rules .build_pars_dsp_pz_geds .output .dsp_pars ,
163+ inplots = rules .build_pars_dsp_pz_geds .output .dsp_plots ,
162164 output :
163- dsp_pars_nopt = temp (
164- get_pattern_pars_tmp_channel (config , "dsp" , "noise_optimization" )
165+ dsp_pars = temp (get_pattern_pars_tmp_channel (config , "dsp" , "noise_optimization" )),
166+ dsp_plots = temp (
167+ get_pattern_plts_tmp_channel (config , "dsp" , "noise_optimization" )
165168 ),
166- plots = temp (get_pattern_plts_tmp_channel (config , "dsp" , "noise_optimization" )),
167169 log :
168170 get_pattern_log_channel (config , "par_dsp_noise_optimization" , time ),
169171 group :
@@ -210,8 +212,8 @@ rule build_pars_dsp_nopt_geds:
210212 "--processing-chain {params.processing_chain} "
211213 "--raw-table-name {params.raw_table_name} "
212214 "--inplots {input.inplots} "
213- "--plot-path {output.plots } "
214- "--dsp-pars {output.dsp_pars_nopt } "
215+ "--plot-path {output.dsp_plots } "
216+ "--dsp-pars {output.dsp_pars } "
215217 "--raw-filelist {input.files}"
216218
217219
@@ -222,12 +224,14 @@ rule build_pars_dsp_dplms_geds:
222224 filelist_path (config ), "all-{experiment}-{period}-{run}-fft-raw.filelist"
223225 ),
224226 peak_file = rules .build_pars_evtsel_geds .output .peak_file ,
225- database = rules .build_pars_dsp_nopt_geds .output .dsp_pars_nopt ,
226- inplots = rules .build_pars_dsp_nopt_geds .output .plots ,
227+ dsp_pars = rules .build_pars_dsp_pz_geds .output .dsp_pars ,
228+ inplots = rules .build_pars_dsp_pz_geds .output .dsp_plots ,
227229 output :
228230 dsp_pars = temp (get_pattern_pars_tmp_channel (config , "dsp" , "dplms" )),
229- lh5_path = temp (get_pattern_pars_tmp_channel (config , "dsp" , extension = "lh5" )),
230- plots = temp (get_pattern_plts_tmp_channel (config , "dsp" , "dplms" )),
231+ dsp_pars_lh5 = temp (
232+ get_pattern_pars_tmp_channel (config , "dsp" , "dplms" , extension = "lh5" )
233+ ),
234+ dsp_plots = temp (get_pattern_plts_tmp_channel (config , "dsp" , "dplms" )),
231235 log :
232236 get_pattern_log_channel (config , "pars_dsp_dplms" , time ),
233237 group :
@@ -270,7 +274,7 @@ rule build_pars_dsp_dplms_geds:
270274 shell :
271275 execenv_pyexe (config , "par-geds-dsp-dplms" ) + "--peak-file {input.peak_file} "
272276 "--fft-raw-filelist {input.fft_files} "
273- "--database {input.database } "
277+ "--database {input.dsp_pars } "
274278 "--inplots {input.inplots} "
275279 "--log {log} "
276280 "--log-config {params.log_config} "
@@ -279,22 +283,24 @@ rule build_pars_dsp_dplms_geds:
279283 "--processing-chain {params.processing_chain} "
280284 "--raw-table-name {params.raw_table_name} "
281285 "--dsp-pars {output.dsp_pars} "
282- "--lh5-path {output.lh5_path } "
283- "--plot-path {output.plots } "
286+ "--lh5-path {output.dsp_pars_lh5 } "
287+ "--plot-path {output.dsp_plots } "
284288
285289
286290# This rule builds the optimal energy filter parameters for the dsp using calibration dsp files
287291rule build_pars_dsp_eopt_geds :
288292 input :
289293 peak_file = rules .build_pars_evtsel_geds .output .peak_file ,
290- decay_const = rules .build_pars_dsp_dplms_geds .output .dsp_pars ,
291- inplots = rules .build_pars_dsp_dplms_geds .output .plots ,
294+ dsp_pars = rules .build_pars_dsp_pz_geds .output .dsp_pars ,
295+ inplots = rules .build_pars_dsp_pz_geds .output .dsp_plots ,
292296 output :
293297 dsp_pars = temp (get_pattern_pars_tmp_channel (config , "dsp_eopt" )),
294- qbb_grid = temp (
295- get_pattern_pars_tmp_channel (config , "dsp" , "objects" , extension = "pkl" )
298+ dsp_objects = temp (
299+ get_pattern_pars_tmp_channel (
300+ config , "dsp" , "eopt_objects" , extension = "pkl"
301+ )
296302 ),
297- plots = temp (get_pattern_plts_tmp_channel (config , "dsp" )),
303+ dsp_plots = temp (get_pattern_plts_tmp_channel (config , "dsp" , "eopt " )),
298304 log :
299305 get_pattern_log_channel (config , "pars_dsp_eopt" , time ),
300306 group :
@@ -340,9 +346,9 @@ rule build_pars_dsp_eopt_geds:
340346 "--raw-table-name {params.raw_table_name} "
341347 "--peak-file {input.peak_file} "
342348 "--inplots {input.inplots} "
343- "--decay-const {input.decay_const } "
344- "--plot-path {output.plots } "
345- "--qbb-grid-path {output.qbb_grid } "
349+ "--decay-const {input.dsp_pars } "
350+ "--plot-path {output.dsp_plots } "
351+ "--qbb-grid-path {output.dsp_objects } "
346352 "--final-dsp-pars {output.dsp_pars}"
347353
348354
@@ -400,10 +406,9 @@ rule build_svm_dsp_geds:
400406
401407rule build_pars_dsp_svm_geds :
402408 input :
403- dsp_pars = rules .build_pars_dsp_eopt_geds .output .dsp_pars ,
404409 svm_file = rules .build_svm_dsp_geds .output .dsp_pars ,
405410 output :
406- dsp_pars = temp (get_pattern_pars_tmp_channel (config , "dsp" )),
411+ dsp_pars = temp (get_pattern_pars_tmp_channel (config , "dsp" , "svm" )),
407412 log :
408413 get_pattern_log_channel (config , "pars_dsp_svm" , time ),
409414 group :
@@ -412,6 +417,17 @@ rule build_pars_dsp_svm_geds:
412417 runtime = 300 ,
413418 shell :
414419 execenv_pyexe (config , "par-geds-dsp-svm" ) + "--log {log} "
415- "--input-file {input.dsp_pars} "
420+ # "--input-file {input.dsp_pars} "
416421 "--output-file {output.dsp_pars} "
417422 "--svm-file {input.svm_file}"
423+
424+
425+ build_in_channel_merge_rules (
426+ [
427+ rules .build_pars_dsp_eopt_geds ,
428+ rules .build_pars_dsp_nopt_geds ,
429+ rules .build_pars_dsp_svm_geds ,
430+ rules .build_pars_dsp_dplms_geds ,
431+ ],
432+ "dsp" ,
433+ )
0 commit comments