LDMX Software
PulseFitter.h
1#pragma once
2
3#include <vector>
4
5#include "Tools/PulseShape.h"
6
7namespace ldmx {
8
42 public:
43 // I like not having underscores for struct members,
44 // but that's not settable until a later version of clang-tidy
45 // NOLINTBEGIN(readability-identifier-naming)
46 struct FitResult {
47 double amplitude{
48 0};
49 double t0{0};
50 double chi2{0};
51 int ndf{0};
52 bool converged{false};
53 };
54 // NOLINTEND(readability-identifier-naming)
55
66 PulseFitter(const PulseShape& shape, double t0_offset_ns,
67 double sampling_interval_ns, double pedestal_adc,
68 double noise_sigma_adc, double t_scan_min_ns = -50.0,
69 double t_scan_max_ns = 150.0, double t_scan_step_ns = 1.0);
70
78 FitResult fit(const std::vector<short>& samples,
79 const std::vector<bool>& used = {}) const;
80
88 FitResult fitFixed(const std::vector<short>& samples, double T,
89 const std::vector<bool>& used = {}) const;
90
96 void setZSThreshold(double thr_adc) { zs_threshold_adc_ = thr_adc; }
97
98 private:
100 std::pair<double, double> evalAtT(const std::vector<short>& samples, double T,
101 const std::vector<bool>& used) const;
102
103 const PulseShape* shape_;
104 double t0_offset_ns_;
105 double sampling_interval_ns_;
106 double pedestal_adc_;
107 double inv_sigma2_;
108 double t_scan_min_ns_;
109 double t_scan_max_ns_;
110 double t_scan_step_ns_;
111 double zs_threshold_adc_{0.};
112};
113
114} // namespace ldmx
Fits a pulse shape to the ADC samples of a single readout channel to extract hit amplitude and time.
Definition PulseFitter.h:41
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.
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.
FitResult fit(const std::vector< short > &samples, const std::vector< bool > &used={}) const
Fit the pulse to the given ADC sample vector.
void setZSThreshold(double thr_adc)
Zero-suppression threshold [ADC over pedestal] for the samples left out by the mask: a model above it...
Definition PulseFitter.h:96
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)
double inv_sigma2_
1/σ², pre-computed.
Abstract base class for front-end readout pulse shapes.
Definition PulseShape.h:30
double chi2
Chi-squared value at the minimum.
Definition PulseFitter.h:50
bool converged
False if no above-pedestal samples found.
Definition PulseFitter.h:52
double t0
Fitted hit arrival time T [ns].
Definition PulseFitter.h:49
double amplitude
Fitted peak amplitude [ADC counts], ped-subtracted.
Definition PulseFitter.h:47
int ndf
Degrees of freedom = n_used_samples − 2.
Definition PulseFitter.h:51