|
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 |
| Fit the pulse to the given ADC sample vector. | |
| FitResult | fitFixed (const std::vector< short > &samples, double T) const |
| Amplitude only fit with the hit time T known, e.g. | |
Private Member Functions | |
| std::pair< double, double > | evalAtT (const std::vector< short > &samples, double T) 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_ |
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.
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 40 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 8 of file PulseFitter.cxx.
|
private |
Evaluate χ²(T) and the corresponding best-fit amplitude.
Definition at line 25 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 |
Fit the pulse to the given ADC sample vector.
| samples | ADC values (one per sample, any integer type cast to short). |
Definition at line 66 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 |
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]. |
Definition at line 159 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().
|
private |
|
private |
Definition at line 94 of file PulseFitter.h.
|
private |
Definition at line 93 of file PulseFitter.h.
|
private |
Definition at line 91 of file PulseFitter.h.
|
private |
Definition at line 92 of file PulseFitter.h.
|
private |
Definition at line 97 of file PulseFitter.h.
|
private |
Definition at line 96 of file PulseFitter.h.
|
private |
Definition at line 98 of file PulseFitter.h.