goldpan.rq_cuts

Selections made from already-processed RQs, with no raw traces: the fast path (ported from scdms-analysis-tools).

The idea is the excursion ratio of goldpan.quantities, |max| / std per channel, computed from the RQs a reconstruction has already stored, so that selecting clean random triggers needs no raw-file access:

ratios = phonon_log_ratios(rqs, channels)                  # log10(|max| / std) of each channel
clean = tight_randoms(ratios, low, pileup_thresholds, tight_ranges)

What this module does not contain is any analysis result: the per-channel thresholds, floors and ranges are derived from one dataset’s own distributions, so they are always passed in. The channel names are passed in too (a mapping’s keys, or channels=); Z7_PHONON_CHANNELS is the list of the Z7 phonon channels, for convenience.

Units of the RQ files this was written for (BatCommon’s BasicPulseCalc): P<ch>max is stored in microamps and P<ch>std in amps, so channel_max_amps converts before a ratio is taken (MAX_RQ_UA_TO_A). A channel with no data for an event (absent from the mapping, or NaN) is skipped rather than failing the event. The total phonon channel PT has no max or std RQ of its own: pt_std_proxy estimates its std from the other channels (uncorrelated noise assumed).

Module Attributes

Z7_PHONON_CHANNELS

The twelve phonon channels of Z7, in RQ naming.

MAX_RQ_UA_TO_A

P<ch>max is stored in microamps (BatCommon BasicPulseCalc.cxx, fMaximum = minMax.max*1e6), P<ch>std in amps.

Functions

calibration_line(rqs, windows, detector[, ...])

channel_max_amps(max_rq)

P<ch>max (stored in microamps) converted to amps, the unit of P<ch>std, before taking a ratio.

excursion_band_rq(log_ratio, low, high)

True where log_ratio is in [low, high).

excursion_ratio_rq(amp, std)

|amp| / std: the RQ-only stand-in for goldpan.quantities.excursion_ratio.

log_excursion_ratio_rq(amp, std)

log10(excursion_ratio_rq(amp, std)).

loose_randoms(log_ratios_by_channel, low, ...)

True for a clean-enough random trigger: every channel with data has log10(ratio) >= low, and it is not pileup_randoms.

phonon_log_ratios(rqs, channels)

log10(|P<ch>max| / P<ch>std) for each of channels that has both RQs in rqs (a mapping of RQ name to array).

pileup_randoms(log_ratios_by_channel, thresholds)

True where a random trigger is pileup-contaminated: ANY channel's log10(ratio) is above its entry in thresholds.

pt_std_proxy(std_rqs_by_channel[, channels])

Estimate of the total channel's baseline std from the channels' own std RQs: sqrt(sum(std_i ** 2)).

tight_randoms(log_ratios_by_channel, low, ...)

True for a clean random trigger: loose_randoms, and every channel with data inside its tight_ranges entry.

triggered_physics(rqs, detector[, ...])

goldpan.rq_cuts.Z7_PHONON_CHANNELS = ['PAS1', 'PAS2', 'PBS1', 'PBS2', 'PCS1', 'PCS2', 'PDS1', 'PDS2', 'PES1', 'PES2', 'PFS1', 'PFS2']

The twelve phonon channels of Z7, in RQ naming.

goldpan.rq_cuts.MAX_RQ_UA_TO_A = 1e-06

P<ch>max is stored in microamps (BatCommon BasicPulseCalc.cxx, fMaximum = minMax.max*1e6), P<ch>std in amps.

goldpan.rq_cuts.channel_max_amps(max_rq)[source]

P<ch>max (stored in microamps) converted to amps, the unit of P<ch>std, before taking a ratio.

goldpan.rq_cuts.pt_std_proxy(std_rqs_by_channel, channels=None)[source]

Estimate of the total channel’s baseline std from the channels’ own std RQs: sqrt(sum(std_i ** 2)).

std_rqs_by_channel: a mapping channel -> array (one entry per event), or a list of such arrays. channels limits a mapping to those names (default: all of its keys). Assumes uncorrelated noise, so the variances add; it is an approximation, not an RQ of the processing. Built from whichever channels are present: not all of them are required.

goldpan.rq_cuts.excursion_ratio_rq(amp, std)[source]

|amp| / std: the RQ-only stand-in for goldpan.quantities.excursion_ratio.

amp: channel_max_amps(P<ch>max), or PTOFamps for the total channel (no PTmax exists); std: P<ch>std or pt_std_proxy(...). Same length, aligned to the same events.

goldpan.rq_cuts.log_excursion_ratio_rq(amp, std)[source]

log10(excursion_ratio_rq(amp, std)).

goldpan.rq_cuts.phonon_log_ratios(rqs, channels)[source]

log10(|P<ch>max| / P<ch>std) for each of channels that has both RQs in rqs (a mapping of RQ name to array).

Ready for pileup_randoms, loose_randoms and tight_randoms. A zero std gives infinity, not an error.

goldpan.rq_cuts.excursion_band_rq(log_ratio, low, high)[source]

True where log_ratio is in [low, high). No default band: the bands differ from channel to channel.

goldpan.rq_cuts.pileup_randoms(log_ratios_by_channel, thresholds)[source]

True where a random trigger is pileup-contaminated: ANY channel’s log10(ratio) is above its entry in thresholds.

In every phonon channel the pooled log10(ratio) of random triggers has a main noise peak, a gap, then a sparse pileup cluster; a channel’s threshold is, for example, the start of that gap. The numbers are an analysis result and are passed in. log_ratios_by_channel: channel -> array (from phonon_log_ratios); thresholds: channel -> value. A channel absent from the first, or NaN for an event, is skipped.

goldpan.rq_cuts.loose_randoms(log_ratios_by_channel, low, pileup_thresholds)[source]

True for a clean-enough random trigger: every channel with data has log10(ratio) >= low, and it is not pileup_randoms.

low is one sanity floor for every channel; each channel’s upper limit is its pileup threshold. Only the channels named in pileup_thresholds take part (a channel with no threshold is not judged).

goldpan.rq_cuts.tight_randoms(log_ratios_by_channel, low, pileup_thresholds, tight_ranges)[source]

True for a clean random trigger: loose_randoms, and every channel with data inside its tight_ranges entry.

tight_ranges: channel -> (low, high), the “broad peak” of that channel’s smoothed log10(ratio) histogram with pileup removed (an analysis result, passed in). A subset of loose_randoms.

goldpan.rq_cuts.triggered_physics(rqs, detector, physics_event_type=1)[source]

Warning

Under development: ported from scdms-analysis-tools line_cuts, written for one Z7 calibration line; the RQ names are those of that reconstruction

Physics triggers (EventType == physics_event_type) that were fired by detector (TriggerDetectorNum).

goldpan.rq_cuts.calibration_line(rqs, windows, detector, allow_missing=False)[source]

Warning

Under development: ported from scdms-analysis-tools line_cuts (ten_kev_line); the per-series windows are an analysis result set by eye, and the RQ names are those of the Z7 reconstruction

True for triggered physics events inside their series’ line window: PTOFamps in amp and PTOFdelay in a delay window.

rqs needs series, EventType, TriggerDetectorNum, PTOFamps and PTOFdelay. windows: series -> dict(amp=(lo, hi), delay=[(lo, hi), ...]), passed in (they are an analysis result). detector: the trigger detector number, required. A series of rqs with no window raises ValueError naming it, rather than quietly returning False (which would look like a series with no line events); allow_missing=True gives False for those series instead.