HPGe calibration

Peak splitting, DSP and quality cuts

JuLeAna.process_daq_energy_calibration_cal — Function
process_daq_energy_calibration_cal(processing_config, l200::LegendData, period::DataPeriod, run::DataRun;
    reprocess::Bool=false, timeout::Real=0)

Calibrate the DAQ online energy (daqenergy) of the HPGe detectors (geds) of a cal run.

For each detector, the daqenergy of the raw cal files of the run listed in the runinfo, except the filekeys marked unprocessable, is calibrated automatically with the Th-228 lines (th228_cal_lines) by autocal_energy. The result is a linear calibration c * daqenergy in keV, which process_peak_split_cal and process_peak_split_phy use to select the events of their peaks. When the calibration fails, the uncalibrated spectrum is plotted instead.

Inputs

  • raw tier of the cal filekeys of the run listed in the runinfo, except the filekeys marked unprocessable
  • dataprod_config(l200).raw(filekey), sections default and per detector

Outputs

  • l200.par.rpars.daqecal[period, run]: per detector the calibration constant c and the calibration function func, with a validity entry of category all for the run
  • plot :daq_energy for each calibrated detector, :daq_energy_failed for each detector whose calibration failed
  • run report :daq_energy_calibration_cal with one row per detector

Keywords

  • reprocess: discard the existing parameters and calibrate all detectors; otherwise a detector with parameters is skipped
  • timeout: seconds allowed per detector in parallel (0 = no limit)

Returns

Return nothing.

source
JuLeAna.process_peak_split_cal — Function
process_peak_split_cal(processing_config, l200::LegendData, period::DataPeriod, run::DataRun;
    reprocess::Bool=false, timeout::Real=0)

Extract the events in the Th-228 peaks from the raw cal data of the HPGe detectors (geds) of a run.

For each detector, the DAQ energy of the raw cal files of the run listed in the runinfo, except the filekeys marked unprocessable, is calibrated with the parameters of process_daq_energy_calibration_cal, and the events inside the energy windows given by peaks (for example Tl208FEP and Tl208SEP) are written with their raw waveforms. A detector without DAQ energy calibration fails. The processor throws an error if no file is found.

Inputs

  • raw tier of the cal filekeys of the run listed in the runinfo, except the filekeys marked unprocessable
  • l200.par.rpars.daqecal[period, run]: DAQ energy calibration function func per detector
  • dataprod_config(l200).raw(filekey), sections default and per detector, entry peaks

Outputs

  • jlpks tier file of the start filekey of the run for each detector, with one table per entry of peaks
  • run report :peak_split, with one row per detector (number of events per peak, time, allocations)

Keywords

  • reprocess: recreate the jlpks files; otherwise a detector with a readable jlpks file is skipped (an unreadable file is removed and recreated)
  • timeout: seconds allowed per detector in parallel (0 = no limit)
  • use_cache: write each output file to a local cache directory first and move it to its place when done; otherwise write it next to its final location (default: false)

Returns

Return nothing.

source
JuLeAna.process_peak_split_phy — Function
process_peak_split_phy(processing_config, l200::LegendData, period::DataPeriod, run::DataRun;
    reprocess::Bool=false, timeout::Real=0)

Extract the events in the peaks of the phy raw config, such as the K-40 and K-42 lines, from the raw phy data of the HPGe detectors (geds) of a run.

The same as process_peak_split_cal for the phy files of the run. The DAQ energy is calibrated with the parameters of process_daq_energy_calibration_cal of the cal data of the same run.

Inputs

  • raw tier of the phy filekeys of the run listed in the runinfo, except the filekeys marked unprocessable
  • l200.par.rpars.daqecal[period, run]: DAQ energy calibration function func per detector
  • dataprod_config(l200).raw(filekey) for the phy filekey, sections default and per detector, entry peaks

Outputs

  • jlpks tier file of the start phy filekey of the run for each detector, with one table per entry of peaks
  • run report :peak_split_phy, with one row per detector (number of events per peak, time, allocations)

Keywords

  • reprocess: recreate the jlpks files; otherwise a detector with a readable jlpks file is skipped (an unreadable file is removed and recreated)
  • timeout: seconds allowed per detector in parallel (0 = no limit)
  • use_cache: write each output file to a local cache directory first and move it to its place when done; otherwise write it next to its final location (default: false)

Returns

Return nothing.

source
JuLeAna.process_dsp_cal — Function
process_dsp_cal(processing_config, l200::LegendData, period::DataPeriod, run::DataRun;
    reprocess::Bool=false, timeout::Real=0,
    max_wvfs::Int=10000)

Run the DSP on the cal raw data of the HPGe detectors (geds) of a run.

For every raw cal file of the run, each detector is processed with its DSP configuration, its pole-zero decay time, and its energy and A/E filter optimization parameters, in three @process_steps: DSP parameters of <detector> in <filekey>, raw data loading of <detector> in <filekey> and DSP of <detector> in <filekey>. A detector fails, and the others go on, if the decay time is missing, if its DSP configuration has no required_fltopt_selection or required_aoeopt_selection, if a parameter listed in required_fltopt (or required_aoeopt) is missing for a detector whose channel info row satisfies required_fltopt_selection (or required_aoeopt_selection), or if its raw data or its DSP throws an error. The selections are strings of LegendDataManagement.ljl_propfunc expressions, e.g. "usability == :on && (low_aoe_status == :valid || low_aoe_status == :present)". run_step with detectors and debug = true captures each failed step of these detectors with the variables of the processor, e.g. the raw data of a failed DSP.

Inputs

  • raw tier of the cal filekeys of the run listed in the runinfo, except the filekeys marked unprocessable
  • dataprod_config(l200).dsp(filekey)
  • the decay time and the optimization parameters of each detector from get_dsp_pars(l200, filekey, detector, pars_cat) with pars_cat :pz, :fltopt and :aoeopt, read from the pars_type that the DSP config sets for the detector, e.g. ppars or rpars. A detector whose parameters cannot be loaded fails. Filter parameters that are not set for a detector take the defaults of its DSP configuration.
  • the QC evaluator from load_qc_evaluator(l200, filekey)

Outputs

  • jldsp tier file for each filekey, with one table per detector
  • run report :dsp_cal, with one row per filekey (number of processed detectors, failed detectors, time, allocations) and the time of each detector summed over the filekeys (see JuLeAna.timing_table)

Keywords

  • reprocess: remove the existing jldsp files and process all detectors again; otherwise detectors already present in a file are skipped
  • timeout: seconds allowed per filekey in parallel (0 = no limit)
  • use_cache: write each output file to a local cache directory first and move it to its place when done; otherwise write it next to its final location (default: true)
  • max_wvfs: not used by this processor

Returns

Return nothing.

source
JuLeAna.process_dsp_phy — Function
process_dsp_phy(processing_config, l200::LegendData, period::DataPeriod, run::DataRun;
    reprocess::Bool=false, timeout::Real=0,
    max_wvfs::Int=10000)

Run the DSP on the phy raw data of a run for the additional detectors, PMTs, SiPMs (spms) and HPGe detectors (geds).

For every raw phy file of the run, the channel groups are processed in this order: the detectors listed under additional_detectors in the DSP configuration, the PMTs, the SiPMs (with their per-detector thresholds), and the HPGe detectors (with their pole-zero decay time and energy and A/E filter optimization parameters). Each detector is processed in @process_steps: DSP parameters of <detector> in <filekey> for all but the PMTs, then raw data loading of <detector> in <filekey> and DSP of <detector> in <filekey>. A detector fails, and the others go on, if its parameters are missing, or if its raw data or its DSP throws an error. An HPGe detector also fails if its DSP configuration has no required_fltopt_selection or required_aoeopt_selection, or if a parameter listed in required_fltopt (or required_aoeopt) is missing for a detector whose channel info row satisfies required_fltopt_selection (or required_aoeopt_selection). The selections are strings of LegendDataManagement.ljl_propfunc expressions, e.g. "usability == :on && (low_aoe_status == :valid || low_aoe_status == :present)". A PMT without raw data in a file is skipped and counts as processed. run_step with detectors and debug = true captures each failed step of these detectors with the variables of the processor, e.g. the raw data of a failed DSP.

Inputs

  • raw tier of the phy filekeys of the run listed in the runinfo, except the filekeys marked unprocessable
  • dataprod_config(l200).dsp(filekey), dataprod_config(l200).sipm(filekey) and dataprod_config(l200).pmt(filekey)
  • the decay time, the optimization parameters and the SiPM thresholds of each detector from get_dsp_pars(l200, filekey, detector, pars_cat) with pars_cat :pz, :fltopt, :aoeopt and :sipmopt, read from the pars_type that the DSP config sets for the detector, e.g. ppars or rpars. A detector whose parameters cannot be loaded fails. Filter parameters that are not set for an HPGe detector take the defaults of its DSP configuration.
  • the QC evaluator from load_qc_evaluator(l200, filekey)

Outputs

  • jldsp tier file for each filekey, with one table per detector
  • run report :dsp_phy, with one row per filekey (number of processed detectors, failed detectors, time, allocations) and the time of each detector summed over the filekeys (see JuLeAna.timing_table)

Keywords

  • reprocess: remove the existing jldsp files and process all detectors again; otherwise detectors already present in a file are skipped
  • timeout: seconds allowed per filekey in parallel (0 = no limit)
  • use_cache: write each output file to a local cache directory first and move it to its place when done; otherwise write it next to its final location (default: true)
  • max_wvfs: not used by this processor

Returns

Return nothing.

source
JuLeAna.process_dsp_aux_phy — Function
process_dsp_aux_phy(processing_config, l200::LegendData, period::DataPeriod, run::DataRun;
    reprocess::Bool=false, timeout::Real=0)

Run the DSP and the calibration for the auxiliary detectors (for example the pulser) of the phy data of a run, per filekey.

The auxiliary detectors are the channels selected by get_aux_evt_detsel_propfunc. For each filekey, the raw fields listed under raw_fields for the DSP function of each auxiliary detector (additional_detectors in the DSP configuration) are read and processed with that function, and the result is extended by the auxiliary calibration property function. After all filekeys, each detector is summarized over the run without the filekeys in bad_filekeys (also the removed ones): its number of events, a cross-check histogram of the energy named in the cal.aux_trig condition of the event configuration with the trigger threshold marked, and, for detectors with a cal.aux_trig_intime condition, a 2D histogram of that energy versus the time column of the condition (t_max, or t50 for the pulser) with its time window marked.

Inputs

  • raw tier of the phy filekeys of the run listed in the runinfo, except the filekeys marked unprocessable
  • dataprod_config(l200).dsp(filekey), sections additional_detectors and raw_fields
  • dataprod_config(l200).evt(filekey), section aux
  • the auxiliary calibration from get_aux_cal_propfunc(l200, filekey, det)

Outputs

  • jlaux tier file for each filekey, with one table per auxiliary detector (DSP and calibrated columns)
  • plots :dsp_aux_energy and :dsp_aux_energy_time for each auxiliary detector (debug plot level)
  • run report :dsp_aux_phy, with one row per detector (status, number of events) and one row per filekey

Keywords

  • reprocess: remove the existing jlaux files and process all detectors again; otherwise detectors already present in a file are skipped
  • timeout: seconds allowed per filekey and per detector summary in parallel (0 = no limit)
  • use_cache: write each output file to a local cache directory first and move it to its place when done; otherwise write it next to its final location (default: true)

Returns

Return nothing.

source
JuLeAna.process_qcs_cal — Function
process_qcs_cal(processing_config, l200::LegendData, period::DataPeriod, run::DataRun;
    reprocess::Bool=false, timeout::Real=0)

Generate the quality-cut (QC) flags and their survival fractions for the cal data of the HPGe detectors (geds) of a run.

The QC flags are generated per filekey: for each detector, the QC labels and the is_single_pulse flag defined in the QC configuration are evaluated on the jldsp data, and pulser events are flagged by coincidence of the event timestamps with the raw timestamps of the pulser channel (pulser.puls_detector) of the filekey. Each detector is then summarized over the run without the removed filekeys: the survival fraction of each flag is computed for the pulser events and for the Tl-208 full-energy peak, which is located with a simple Th-228 calibration of the non-pulser events. Only the Tl-208 FEP survival fraction of is_single_pulse has an uncertainty; it is NaN for the other flags. A detector with fewer than 5000 events fails. A detector with single-pulse events that fail the is_valid_e flag gets the status warning. The single-pulse survival fraction of the pulser events of each filekey is compared with that of the other nonremoved filekeys by an exact count test, and deviations above filekey_stability.sigma of the QC config are reported without changing the status; the non-pulser survival fraction is shown for diagnosis only.

Inputs

  • jldsp tier of the cal filekeys of the run listed in the runinfo, except the filekeys marked unprocessable
  • raw tier timestamps of the pulser channel
  • the filekeys marked removed in datasets/ignored_daq_cycles, which are left out of the run summary
  • dataprod_config(l200).qc(filekey) and dataprod_config(l200).energy(filekey)
  • l200.par.rpars.qcs[period, run] (existing parameters, unless reprocess is true)

Outputs

  • jlqcs tier file for each filekey, with one table per detector (QC flags, timestamp, is_pulser)
  • l200.par.rpars.qcs[period, run] (flag definition, survival fractions, event counts, and per filekey the event counts and stability tests in filekey_summary) with its validity (category cal)
  • plots :raw_energy_e_trap, :qc_filekey_efficiency and :qc_survival_fractions for each detector; :qc_survival_fractions is saved only at the debug plot level
  • run report :qcs_cal, with the stability warnings, one row per detector and one row per filekey

Keywords

  • reprocess: remove the existing jlqcs files and parameters and process all detectors again; otherwise detectors already present in a jlqcs file are skipped there. The run summary of every detector is always recomputed.
  • timeout: seconds allowed per filekey and per detector summary in parallel (0 = no limit)
  • use_cache: write each output file to a local cache directory first and move it to its place when done; otherwise write it next to its final location (default: true)

Returns

Return nothing.

source
JuLeAna.process_qcs_phy — Function
process_qcs_phy(processing_config, l200::LegendData, period::DataPeriod, run::DataRun;
    reprocess::Bool=false, timeout::Real=0)

Generate the quality-cut (QC) flags and their survival fractions for the phy data of the HPGe detectors (geds) of a run.

The QC flags are generated per filekey: for each detector, the QC labels and the is_single_pulse and is_empty_trace flags defined in the QC configuration are evaluated on the jldsp data. Pulser events and forced-trigger events (without pulser events) are taken from the aux_trig flags of the pulser channel (pulser.puls_detector) and of the forced-trigger channel (forced_trigger.detector) of the filekey. Each detector is then summarized over the run without the removed filekeys: the survival fraction of each flag is computed for the pulser events and for the forced-trigger events. A detector with single-pulse events that fail the is_valid_dsp flag gets the status warning. The pulser single-pulse and forced-trigger empty-trace survival fractions of each filekey are compared with those of the other nonremoved filekeys by an exact count test, and deviations above filekey_stability.sigma of the QC config are reported without changing the status.

Inputs

  • jldsp tier of the phy filekeys of the run listed in the runinfo, except the filekeys marked unprocessable
  • jlaux tier column aux_trig of the pulser and forced-trigger channels
  • the filekeys marked removed in datasets/ignored_daq_cycles, which are left out of the run summary
  • dataprod_config(l200).qc(filekey)
  • l200.par.rpars.qcs[period, Symbol("<run>-phy")] (existing parameters, unless reprocess is true)

Outputs

  • jlqcs tier file for each filekey, with one table per detector (QC flags, timestamp, is_pulser, is_forced)
  • l200.par.rpars.qcs[period, Symbol("<run>-phy")] (flag definition, survival fractions, event counts, and per filekey the event counts and stability tests in filekey_summary) with its validity (category phy)
  • plots :qc_filekey_efficiency, :qc_survival_fractions and :qc_survival_fractions_forced_trigger for each detector; :qc_survival_fractions_forced_trigger is saved only at the debug plot level
  • run report :qcs_phy, with the stability warnings, one row per detector and one row per filekey

Keywords

  • reprocess: remove the existing jlqcs files and parameters and process all detectors again; otherwise detectors already present in a jlqcs file are skipped there. The run summary of every detector is always recomputed.
  • timeout: seconds allowed per filekey and per detector summary in parallel (0 = no limit)
  • use_cache: write each output file to a local cache directory first and move it to its place when done; otherwise write it next to its final location (default: true)

Returns

Return nothing.

source

Decay time and filter optimization

JuLeAna.process_decay_time_cal — Function
process_decay_time_cal(processing_config, l200::LegendData, period::DataPeriod, run::DataRun;
    reprocess::Bool=false, timeout::Real=0)

Determine the preamplifier decay time of the HPGe detectors (geds) from the cal data of a run.

For each detector, the presummed waveforms of the peak named by peakname in the pz section of the DSP configuration are read from the jlpks tier. If there are more than max_wvfs waveforms, max_wvfs of them are selected at random, without repetition and in their original order. Waveforms that fail the QC condition qc are removed. The decay time of each remaining waveform is computed, and a truncated Gaussian is fitted to the values between min_tau and max_tau; its mean is the decay time. A detector gets warning status if the decay time is outside 350 to 700 µs. A detector fails if its jlpks file is missing or if loading, QC, DSP or the fit throws an error.

Inputs

  • jlpks tier of the start filekey of the run, entry peakname
  • dataprod_config(l200).dsp(filekey), sections default, per detector, and pz (min_tau, max_tau, nbins, rel_cut_fit, peakname, qc, max_wvfs)
  • the QC evaluator from load_qc_evaluator(l200, filekey)
  • l200.par.rpars.pz[period, run] (existing parameters, unless reprocess is true)

Outputs

  • l200.par.rpars.pz[period, run] with the decay time τ and the fit result of each detector, with its validity
  • plot :decay_time for each detector (debug plot level)
  • If error_plots is on, a failed decay time extraction saves error_decay_time_extraction.
  • run report :decay_time, with one row per detector (decay time, width)

Keywords

  • reprocess: discard the existing parameters and process all detectors; otherwise detectors that already have parameters are skipped
  • timeout: seconds allowed per detector in parallel (0 = no limit)

Returns

Return nothing.

source
JuLeAna.p_process_decay_time_cal — Function
p_process_decay_time_cal(processing_config, l200::LegendData, period::DataPeriod;
    reprocess::Bool=false, timeout::Real=0, only_first_period::Bool=true) -> Bool

Determine the preamplifier decay time of the HPGe detectors (geds) for every cal partition that contains period.

For each detector and partition, the presummed waveforms of the peak named by peakname in the pz section of the DSP configuration are read from the jlpks tier of the runs of the partition, n_evts events per run. If there are more than max_wvfs waveforms in total, max_wvfs of them are selected at random, without repetition and in their original order. Waveforms that fail the QC condition qc are removed. The decay time of each remaining waveform is computed, and a truncated Gaussian is fitted to the values between min_tau and max_tau; its mean is the decay time. An entry gets warning status if the decay time is outside 350 to 700 µs. An entry fails if loading, QC, DSP or the fit throws an error.

Inputs

  • jlpks tier of all runs of each partition, entry peakname
  • dataprod_config(l200).dsp(filekey), sections default, per detector, and pz (p_default, p)
  • the QC evaluator from load_qc_evaluator(l200, filekey)
  • l200.par.ppars.pz[det, part] (existing parameters, unless reprocess is true)

Outputs

  • l200.par.ppars.pz[det, part] with the decay time τ and the fit result, for each detector and partition, and the validity of all partitions
  • plot :decay_time for each detector and partition (debug plot level)
  • If error_plots is on, a failed decay time extraction saves error_decay_time_extraction.
  • partition report :decay_time, with one row per detector and partition

Keywords

  • reprocess: discard the existing parameters and process all entries again; otherwise entries that already have parameters are skipped
  • timeout: seconds allowed per detector and partition in parallel (0 = no limit)
  • only_first_period: skip a detector whose partition starts in an earlier period than period; it is then processed with that period. run_processing sets this to true when the previous period is also being processed.

Returns

true if at least one detector was skipped because of only_first_period, false otherwise. run_processing then waits for this step in the previous period.

source
JuLeAna.process_filter_optimization_cal — Function
process_filter_optimization_cal(processing_config, l200::LegendData, period::DataPeriod, run::DataRun;
    reprocess::Bool=false, timeout::Real=0)

Optimize the energy filter rise time and flat-top time for all processable HPGe detectors (geds) of the cal run.

For each filter type listed under e_filter in the optimization config, the rise time is chosen first from a sweep over the baseline noise (minimal ENC at a fixed flat-top time). The flat-top time is then chosen from a sweep over the full-energy-peak events as the one with the smallest objective (see fit_fwhm_ft). If joint_search is enabled, a search over rise time and flat-top time on the sampling lattice, starting from these two values, gives the optimum instead. Waveforms of the peak named by peakname are taken from the jlpks tier. At most max_wvfs waveforms, selected with a seeded random number generator, are used. Quality cuts are applied before the sweeps: an event is kept if, for every column => k of the optional qc_mad section of the optimization config (e.g. blsigma, blslope), its value lies within k normalized MADs of the median of the finite values, and the qc expression holds on the QC table of dsp_qc_flt_optimization_compressed extended by qdrift. Without a qc_mad section no MAD cut is applied. Filter types that already have results from this method are skipped unless reprocess is set; results lacking objective, w90, ct_spread or joint_search are optimized again (families instead of joint_search for dplms).

If e_filter lists dplms, a DPLMS filter is synthesized after the other filter types on the same QC-selected waveforms with dsp_dplms_optimization, for every point of LegendDSP's dplms_default_grid, with the flat-top widenings ff of the config range e_filter.dplms.ff (start, stop, step; whole multiples of the sample time) if given and multiples of the number of samples of the pulse rise of the DPLMS reference otherwise. The grid points that share all weights (nm, za, ft, ct, zo) form a family. For each family the FEP is fitted at every ff with fit_fwhm_ft and the objective of the config, and the ff with the smallest objective is selected (rel_tol is zero: the DPLMS filter length does not depend on ff, so the scan minimum is taken without a preference for long flat tops). The family with the smallest objective is kept and the result stores the objective, FWHM and ff of every family and its scan over ff under families. The qc_mad section is required if e_filter lists dplms. The qc expression must remove events with a non-finite qdrift and events with a t50_pre outside the current window; the DPLMS synthesis throws otherwise.

Inputs

  • jlpks tier of the start cal filekey of the run, for each detector (peak waveforms named by peakname).
  • dataprod_config(l200).dsp(filekey), in particular the flt_optimization section (default and per-detector entries) and the DSP config used for the filter grids.
  • l200.par.rpars.pz[period, run] (decay times).
  • Quality-cut evaluator loaded by load_qc_evaluator(l200, filekey).
  • l200.par.rpars.fltopt[period, run] (existing results, unless reprocess is set).

Outputs

  • l200.par.rpars.fltopt[period, run]: per detector and filter type the optimal rise time rt and flat-top time ft (the flat-top time the CUSP and ZAC filters apply), the objective with its value min_objective, the fwhm, w90, asym, fct and ct_spread at the optimum, ctc_rel_uncertainty, joint_search, containment, the noise sweep results rt_enc and min_enc, and n_evals and converged of the joint search if it ran, together with the validity entry for the run. The dplms entry holds instead the filter coefficients, the reference pulse over the window (n_pre samples before to n_post after t50, unit plateau), its filter output response over the n_pre + n_post + 1 samples from t50, the read-out time t_pickoff after t50, shaping_time, flat_top, ff (in samples), n_pre, n_post, the synthesis weights, the output_area of the filter output, the objective fields of the other filters (objective, ctc_rel_uncertainty, containment, min_objective, min_fwhm, w90, asym, fct, ct_spread) and per family its weights, ff (in samples), min_objective, min_fwhm and the scan (ff in µs, fwhm, w90, status per grid point) under families.
  • Per detector and filter type, plots noise_sweep_<filter_type>, fwhm_ft_scan_<filter_type>, rtft_landscape_<filter_type> (joint search only), ctc_<filter_type>, residuals_<filter_type> and example_wvfs_<filter_type>, saved only at the debug plot level. For dplms: fwhm_ft_scan_dplms (scan over ff of the selected family), dplms_filter, dplms_reference, dplms_response and dplms_matrices, and no noise sweep, joint search, CTC, residual or example waveform plots.
  • Run report :filter_optimization (Main Log, Metadata, Results table with one row per detector and filter type; the dplms row shows shaping time and flat top in the rise-time and flat-top columns).

Keywords

  • reprocess: redo all detectors and filter types, discarding existing results in l200.par.rpars.fltopt[period, run]. If false, only filter types without results are processed.
  • timeout: seconds allowed per detector in parallel (0 = no limit).

Returns

nothing.

source
JuLeAna.p_process_filter_optimization_cal — Function
p_process_filter_optimization_cal(processing_config, l200::LegendData, period::DataPeriod;
    reprocess::Bool=false, timeout::Real=0, only_first_period::Bool=true)

Optimize the energy filter rise time and flat-top time per detector and cal partition for all partitions that contain period, using all analysis runs of the partition (HPGe detectors geds).

The method is the same as in process_filter_optimization_cal: for each filter type listed under e_filter, the rise time is chosen from a baseline noise sweep and the flat-top time from a sweep over full-energy-peak events, or both from a joint search if joint_search is enabled. The waveforms of the peak named by peakname are read from the jlpks tier of all runs of the partition (n_evts events per run, drawn randomly with a seeded random number generator if select_random is set) and at most max_wvfs of them are used. The quality cuts (qc expression and optional qc_mad section) are those of process_filter_optimization_cal. Results lacking objective, w90, ct_spread or joint_search are optimized again (families instead of joint_search for dplms).

If e_filter lists dplms, a DPLMS filter is synthesized and selected after the other filter types as in process_filter_optimization_cal, on the same QC-selected waveforms and with the flat-top widenings ff of the config range e_filter.dplms.ff (start, stop, step; whole multiples of the sample time) if given. The qc_mad section is required, and the qc expression must remove events with a non-finite qdrift and events with a t50_pre outside the current window; the DPLMS synthesis throws otherwise.

Inputs

  • jlpks tier of the cal runs of each partition, for each detector.
  • dataprod_config(l200).dsp(filekey), in particular flt_optimization.p_default and the per-detector entries flt_optimization.p, and the DSP config used for the filter grids.
  • l200.par.ppars.pz[det, part] (decay times).
  • Quality-cut evaluator loaded by load_qc_evaluator(l200, filekey).
  • l200.par.ppars.fltopt[det, part] (existing results, if present).

Outputs

  • l200.par.ppars.fltopt[det, part]: per filter type the optimal rise time rt and flat-top time ft (the flat-top time the CUSP and ZAC filters apply), the objective with its value min_objective, the fwhm, w90, asym, fct and ct_spread at the optimum, ctc_rel_uncertainty, joint_search, containment, the noise sweep results rt_enc and min_enc, and n_evals and converged of the joint search if it ran, with validity entries for the partition; the validity of all partitions of the period is written to l200.par.ppars.fltopt. The dplms entry holds instead the filter coefficients, the reference pulse over the window (n_pre samples before to n_post after t50, unit plateau), its filter output response over the n_pre + n_post + 1 samples from t50, the read-out time t_pickoff after t50, shaping_time, flat_top, ff (in samples), n_pre, n_post, the synthesis weights, the output_area of the filter output, the objective fields of the other filters (objective, ctc_rel_uncertainty, containment, min_objective, min_fwhm, w90, asym, fct, ct_spread) and per family its weights, ff (in samples), min_objective, min_fwhm and the scan (ff in µs, fwhm, w90, status per grid point) under families.
  • Per detector, partition and filter type, plots noise_sweep_<filter_type>, fwhm_ft_scan_<filter_type>, rtft_landscape_<filter_type> (joint search only), ctc_<filter_type>, residuals_<filter_type> and example_wvfs_<filter_type>, saved only at the debug plot level. For dplms: fwhm_ft_scan_dplms (scan over ff of the selected family), dplms_filter, dplms_reference, dplms_response and dplms_matrices, and no noise sweep, joint search, CTC, residual or example waveform plots.
  • Partition report :filter_optimization (Main Log, Metadata, Results table with one row per detector, partition and filter type; the dplms row shows shaping time and flat top in the rise-time and flat-top columns).

Keywords

  • reprocess: redo all filter types, ignoring results in l200.par.ppars.fltopt[det, part]. If false, only filter types without results are processed.
  • timeout: seconds allowed per detector and partition in parallel (0 = no limit).
  • only_first_period: if true, a detector whose partition starts in an earlier period is skipped (it is processed with that earlier period). run_processing sets this to true when the previous period is also being processed.

Returns

true if at least one detector and partition was skipped because of only_first_period, otherwise false. run_processing uses this to wait for the same step in the previous period.

source

Energy calibration

JuLeAna.process_ct_correction_cal — Function
process_ct_correction_cal(processing_config, l200::LegendData, period::DataPeriod, run::DataRun;
    reprocess::Bool=false, timeout::Real=0)

Determine the charge-trapping correction for all processable HPGe detectors (geds) of the cal run.

For each energy type in energy_types of the ctc section of the energy config, the energy is calibrated with a simple Th-228 calibration, and the correction parameters (polynomial in qdrift of order ctc_order) are optimized on the peak peak within the window (left_window_size, right_window_size). The FWHM of the peak before and after the correction is reported. Only single-pulse, non-pulser events passing the quality cuts are used.

Inputs

  • jlqcs tier (event mask is_single_pulse && !is_pulser) and jldsp tier of the cal run (energy types and qdrift), for each detector. A missing jlqcs file counts as a failure of that detector.
  • dataprod_config(l200).energy(filekey) (default, ctc.default and per-detector entries).
  • l200.par.rpars.ctc[period, run] (existing results, unless reprocess is set).

Outputs

  • l200.par.rpars.ctc[period, run]: per detector and energy type the correction result (including fct, fwhm_before, fwhm_after), together with the validity entry for the run.
  • Per detector and energy type, plots simple_calibration_<e_type> and ctc_<e_type>, saved only at the debug plot level.
  • If error_plots is on, a failed simple calibration saves error_simple_calibration_<e_type> and a failed alpha generation error_alpha_generation_<e_type>.
  • Run report :ct_correction (Main Log, Metadata, Results table with one row per detector and energy type).

Keywords

  • reprocess: redo all detectors and energy types, discarding existing results in l200.par.rpars.ctc[period, run]. If false, only energy types without results are processed.
  • timeout: seconds allowed per detector in parallel (0 = no limit).

Returns

nothing.

source
JuLeAna.process_energy_calibration_cal — Function
process_energy_calibration_cal(processing_config, l200::LegendData, period::DataPeriod, run::DataRun;
    reprocess::Bool=false, timeout::Real=0)

Calibrate the energy of all processable HPGe detectors (geds) of the cal run with the Th-228 spectrum.

For each energy type in energy_types of the energy config, the uncalibrated energies of single-pulse, non-pulser events passing the quality cuts are calibrated in three steps: a simple calibration locates the Th-228 peaks, the peaks are fitted with the functions in th228_fit_func, and a polynomial calibration curve (cal_pol_order) and a FWHM curve (fwhm_pol_order for energy types ending in _ctc, otherwise a quadratic FWHM² model) are fitted to the peaks that pass the fit quality cuts in qc. Peaks in cal_fit_excluded_peaks and fwhm_fit_excluded_peaks are left out of the respective fit. Energy types ending in _ctc use the charge-trapping-corrected energy expression from the CT correction results.

Inputs

  • jlqcs tier (event mask is_single_pulse && !is_pulser) and jldsp tier of the cal run, for each detector.
  • dataprod_config(l200).energy(filekey) (default and per-detector entries).
  • l200.par.rpars.ctc[period, run] (needed for _ctc energy types).
  • l200.par.rpars.ecal[period, run] (existing results, unless reprocess is set).

Outputs

  • l200.par.rpars.ecal[period, run]: per detector and energy type the simple calibration constant (m_cal_simple), FWHM curve (fwhm), calibration curve (cal) and calibrated peak fit results (fit), together with the validity entry for the run.
  • Per detector and energy type, plots simple_calibration_<e_type>, peak_fits_<e_type>, calibration_curve_<e_type> and fwhm_<e_type>. simple_calibration_<e_type> and peak_fits_<e_type> are saved only at the debug plot level.
  • Run report :energy_calibration (Main Log, Metadata, Results table with one row per detector and energy type).

Keywords

  • reprocess: redo all detectors and energy types, discarding existing results in l200.par.rpars.ecal[period, run]. If false, only energy types without results are processed.
  • timeout: seconds allowed per detector in parallel (0 = no limit).

Returns

nothing.

source
JuLeAna.p_process_energy_cal — Function
p_process_energy_cal(processing_config, l200::LegendData, period::DataPeriod;
    reprocess::Bool=false, timeout::Real=0, only_first_period::Bool=true)

Calibrate the energy per detector and cal partition for all partitions that contain period (HPGe detectors geds).

For each energy type in energy_types of the partition energy config, the energies of all runs of the partition are calibrated with the run-level calibration function (cal.func from l200.par.rpars.ecal) and concatenated, after selecting single-pulse, non-pulser events that pass the quality cuts. The Th-228 peaks in the resulting spectrum are fitted with the functions in th228_fit_func, then a polynomial calibration curve (cal_pol_order) and a FWHM curve (fwhm_pol_order for energy types ending in _ctc, otherwise a quadratic FWHM² model) are fitted to the peaks that pass the fit quality cuts in qc. Peaks in cal_fit_excluded_peaks and fwhm_fit_excluded_peaks are left out of the respective fit.

Inputs

  • jlqcs and jldsp tiers of all cal runs of each partition, for each detector.
  • l200.par.rpars.ecal[period, run] (run-level calibration function) for each run of the partition.
  • dataprod_config(l200).energy(filekey), sections p_default and per-detector entries p.
  • l200.par.ppars.ecal[det, part] (existing results, unless reprocess is set).

Outputs

  • l200.par.ppars.ecal[det, part]: per energy type the FWHM curve (fwhm), calibration curve (cal) and peak fit results (fit), with validity entries for the partition; the validity of all partitions of the period is written to l200.par.ppars.ecal.
  • Per detector, partition and energy type, plots partition_spectrum_<e_type>, peak_fits_<e_type>, calibration_curve_<e_type> and fwhm_<e_type>. peak_fits_<e_type> is saved only at the debug plot level.
  • If error_plots is on, a failed peak fitting saves error_peak_fitting_<e_type>.
  • Partition report :energy (Main Log, Metadata, Results table with one row per detector, partition and energy type).

Keywords

  • reprocess: redo all energy types, ignoring results in l200.par.ppars.ecal[det, part]. If false, only energy types without results are processed.
  • timeout: seconds allowed per detector and partition in parallel (0 = no limit).
  • only_first_period: if true, a detector whose partition starts in an earlier period is skipped (it is processed with that earlier period). run_processing sets this to true when the previous period is also being processed.

Returns

true if at least one detector and partition was skipped because of only_first_period, otherwise false. run_processing uses this to wait for the same step in the previous period.

source