|
LDMX Software
|
Fits a pulse shape to the ADC samples of a single readout channel to extract hit amplitude and time. More...
#include <PulseFitter.h>
Classes | |
| struct | FitResult |
Public Member Functions | |
| PulseFitter (const PulseShape &shape, double t0_offset_ns, double sampling_interval_ns, double pedestal_adc, double noise_sigma_adc, double t_scan_min_ns=-50.0, double t_scan_max_ns=150.0, double t_scan_step_ns=1.0) | |
| FitResult | fit (const std::vector< short > &samples, const std::vector< bool > &used={}) const |
| Fit the pulse to the given ADC sample vector. | |
| FitResult | fitFixed (const std::vector< short > &samples, double T, const std::vector< bool > &used={}) const |
| Amplitude only fit with the hit time T known, e.g. | |
| void | setZSThreshold (double thr_adc) |
| Zero-suppression threshold [ADC over pedestal] for the samples left out by the mask: a model above it adds ((model − thr)/σ)² to χ², so the fit cannot hide the pulse in suppressed samples. | |
Private Member Functions | |
| std::pair< double, double > | evalAtT (const std::vector< short > &samples, double T, const std::vector< bool > &used) const |
| Evaluate χ²(T) and the corresponding best-fit amplitude. | |
Private Attributes | |
| const PulseShape * | shape_ |
| double | t0_offset_ns_ |
| double | sampling_interval_ns_ |
| double | pedestal_adc_ |
| double | inv_sigma2_ |
| 1/σ², pre-computed. | |
| double | t_scan_min_ns_ |
| double | t_scan_max_ns_ |
| double | t_scan_step_ns_ |
| double | zs_threshold_adc_ {0.} |
Fits a pulse shape to the ADC samples of a single readout channel to extract hit amplitude and time.
With N ADC samples and 2 free parameters (amplitude A and hit time T), the chi-squared is:
χ²(T) = Σ_i [(S_i − ped − A(T)·f(t_i − T)) / σ]²
where t_i = t0_offset + i·Δt are the sample times and f is the pulse shape. For each candidate T, A is solved analytically:
A(T) = Σ_i (S_i − ped)·f(t_i − T) / Σ_i f(t_i − T)²
A 1-D scan over T followed by a parabolic refinement near the minimum gives the fitted values. This is O(n_scan × N_samples) per strip and runs in < 1 µs. In a masked fit (zero suppression) with a flat χ² minimum, e.g. one kept sample, T is the middle of the flat range.
The fit result t0 is defined as T − t0_offset, i.e. the hit arrival time relative to sample 0. A value of t0 = tp (peaking time) means the pulse peak coincides with sample 0.
Sample i is taken at time t_i = t0_offset_ns + i · sampling_interval_ns The pulse shape is evaluated at f(t_i − T) where T is the absolute hit arrival time in the same frame. The output t0 = T is stored directly so the caller can subtract their own reference as needed.
Definition at line 41 of file PulseFitter.h.
| ldmx::PulseFitter::PulseFitter | ( | const PulseShape & | shape, |
| double | t0_offset_ns, | ||
| double | sampling_interval_ns, | ||
| double | pedestal_adc, | ||
| double | noise_sigma_adc, | ||
| double | t_scan_min_ns = -50.0, | ||
| double | t_scan_max_ns = 150.0, | ||
| double | t_scan_step_ns = 1.0 ) |
| shape | Pulse shape function (owned externally). |
| t0_offset_ns | Time of sample 0 in the hit-time frame [ns]. |
| sampling_interval_ns | Interval between samples [ns]. |
| pedestal_adc | Per-sample pedestal [ADC counts]. |
| noise_sigma_adc | Per-sample noise RMS [ADC counts], used for χ². |
| t_scan_min_ns | Lower bound of the T scan range [ns]. |
| t_scan_max_ns | Upper bound of the T scan range [ns]. |
| t_scan_step_ns | Step size of the coarse T scan [ns]. |
Definition at line 24 of file PulseFitter.cxx.
|
private |
Evaluate χ²(T) and the corresponding best-fit amplitude.
Definition at line 41 of file PulseFitter.cxx.
References ldmx::PulseShape::eval(), and inv_sigma2_.
Referenced by fit(), and fitFixed().
| PulseFitter::FitResult ldmx::PulseFitter::fit | ( | const std::vector< short > & | samples, |
| const std::vector< bool > & | used = {} ) const |
Fit the pulse to the given ADC sample vector.
| samples | ADC values (one per sample, any integer type cast to short). |
| used | Samples to fit, e.g. not zero suppressed; empty = all. |
Definition at line 93 of file PulseFitter.cxx.
References ldmx::PulseFitter::FitResult::amplitude, ldmx::PulseFitter::FitResult::chi2, ldmx::PulseFitter::FitResult::converged, evalAtT(), ldmx::PulseFitter::FitResult::ndf, and ldmx::PulseFitter::FitResult::t0.
Referenced by ecal::EcalRecProducer::produce(), and tracking::reco::SiStripWaveformFitProcessor::produce().
| PulseFitter::FitResult ldmx::PulseFitter::fitFixed | ( | const std::vector< short > & | samples, |
| double | T, | ||
| const std::vector< bool > & | used = {} ) const |
Amplitude only fit with the hit time T known, e.g.
from another detector.
| samples | ADC values (one per sample). |
| T | Hit time in the same frame as t0_offset [ns]. |
| used | Samples to fit, e.g. not zero suppressed; empty = all. |
Definition at line 187 of file PulseFitter.cxx.
References ldmx::PulseFitter::FitResult::amplitude, ldmx::PulseFitter::FitResult::chi2, ldmx::PulseFitter::FitResult::converged, evalAtT(), ldmx::PulseFitter::FitResult::ndf, and ldmx::PulseFitter::FitResult::t0.
Referenced by ecal::EcalRecProducer::produce().
|
inline |
Zero-suppression threshold [ADC over pedestal] for the samples left out by the mask: a model above it adds ((model − thr)/σ)² to χ², so the fit cannot hide the pulse in suppressed samples.
≤ 0 (default) turns it off.
Definition at line 96 of file PulseFitter.h.
Referenced by ecal::EcalRecProducer::produce().
|
private |
|
private |
Definition at line 106 of file PulseFitter.h.
|
private |
Definition at line 105 of file PulseFitter.h.
|
private |
Definition at line 103 of file PulseFitter.h.
|
private |
Definition at line 104 of file PulseFitter.h.
|
private |
Definition at line 109 of file PulseFitter.h.
|
private |
Definition at line 108 of file PulseFitter.h.
|
private |
Definition at line 110 of file PulseFitter.h.
|
private |
Definition at line 111 of file PulseFitter.h.